1 ;;;; the PPC definitions of some general purpose memory reference VOPs
2 ;;;; inherited by basic memory reference operations
4 ;;;; This software is part of the SBCL system. See the README file for
7 ;;;; This software is derived from the CMU CL system, which was
8 ;;;; written at Carnegie Mellon University and released into the
9 ;;;; public domain. The software is in the public domain and is
10 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
11 ;;;; files for more information.
15 ;;; Cell-Ref and Cell-Set are used to define VOPs like CAR, where the offset to
16 ;;; be read or written is a property of the VOP used.
18 (define-vop (cell-ref)
19 (:args (object :scs (descriptor-reg)))
20 (:results (value :scs (descriptor-reg any-reg)))
21 (:variant-vars offset lowtag)
24 (loadw value object offset lowtag)))
26 (define-vop (cell-set)
27 (:args (object :scs (descriptor-reg))
28 (value :scs (descriptor-reg any-reg)))
29 (:variant-vars offset lowtag)
32 (storew value object offset lowtag)))
34 ;;; Slot-Ref and Slot-Set are used to define VOPs like Closure-Ref, where the
35 ;;; offset is constant at compile time, but varies for different uses. We add
36 ;;; in the standard g-vector overhead.
38 (define-vop (slot-ref)
39 (:args (object :scs (descriptor-reg)))
40 (:results (value :scs (descriptor-reg any-reg)))
41 (:variant-vars base lowtag)
44 (loadw value object (+ base offset) lowtag)))
46 (define-vop (slot-set)
47 (:args (object :scs (descriptor-reg))
48 (value :scs (descriptor-reg any-reg)))
49 (:variant-vars base lowtag)
52 (storew value object (+ base offset) lowtag)))
56 ;;;; Indexed references:
58 ;;; Define some VOPs for indexed memory reference.
59 (defmacro define-indexer (name write-p ri-op rr-op shift &optional sign-extend-byte)
61 (:args (object :scs (descriptor-reg))
62 (index :scs (any-reg zero immediate))
64 '((value :scs (any-reg descriptor-reg) :target result))))
65 (:arg-types * tagged-num ,@(when write-p '(*)))
66 (:temporary (:scs (non-descriptor-reg)) temp)
67 (:results (,(if write-p 'result 'value)
68 :scs (any-reg descriptor-reg)))
70 (:variant-vars offset lowtag)
75 (let ((offset (- (+ (if (sc-is index zero)
78 (- word-shift ,shift)))
79 (ash offset word-shift))
83 (inst ,ri-op value object offset))
84 ((or (unsigned-byte 32) (signed-byte 32))
86 (inst ,rr-op value object temp)))))
88 ,@(unless (zerop shift)
89 `((inst srwi temp index ,shift)))
90 (inst addi temp ,(if (zerop shift) 'index 'temp)
91 (- (ash offset word-shift) lowtag))
92 (inst ,rr-op value object temp)))
93 ,@(when sign-extend-byte
94 `((inst extsb value value)))
96 '((move result value))))))
98 (define-indexer word-index-ref nil lwz lwzx 0)
99 (define-indexer word-index-set t stw stwx 0)
100 (define-indexer halfword-index-ref nil lhz lhzx 1)
101 (define-indexer signed-halfword-index-ref nil lha lhax 1)
102 (define-indexer halfword-index-set t sth sthx 1)
103 (define-indexer byte-index-ref nil lbz lbzx 2)
104 (define-indexer signed-byte-index-ref nil lbz lbzx 2 t)
105 (define-indexer byte-index-set t stb stbx 2)