4 (define-move-fun (load-immediate 1) (vop x y)
6 (any-reg descriptor-reg))
7 (let ((val (tn-value x)))
10 (inst li y (fixnumize val)))
16 (inst li y (logior (ash (char-code val) n-widetag-bits)
17 character-widetag))))))
19 (define-move-fun (load-number 1) (vop x y)
21 (signed-reg unsigned-reg))
22 (inst li y (tn-value x)))
24 (define-move-fun (load-character 1) (vop x y)
25 ((immediate) (character-reg))
26 (inst li y (char-code (tn-value x))))
28 (define-move-fun (load-system-area-pointer 1) (vop x y)
29 ((immediate) (sap-reg))
30 (inst li y (sap-int (tn-value x))))
32 (define-move-fun (load-constant 5) (vop x y)
33 ((constant) (descriptor-reg any-reg))
34 (loadw y code-tn (tn-offset x) other-pointer-lowtag))
36 (define-move-fun (load-stack 5) (vop x y)
37 ((control-stack) (any-reg descriptor-reg))
40 (define-move-fun (load-number-stack 5) (vop x y)
41 ((character-stack) (character-reg)
43 (signed-stack) (signed-reg)
44 (unsigned-stack) (unsigned-reg))
45 (let ((nfp (current-nfp-tn vop)))
46 (loadw y nfp (tn-offset x))))
48 (define-move-fun (store-stack 5) (vop x y)
49 ((any-reg descriptor-reg null zero) (control-stack))
52 (define-move-fun (store-number-stack 5) (vop x y)
53 ((character-reg) (character-stack)
55 (signed-reg) (signed-stack)
56 (unsigned-reg) (unsigned-stack))
57 (let ((nfp (current-nfp-tn vop)))
58 (storew x nfp (tn-offset y))))
65 :scs (any-reg descriptor-reg zero null)
66 :load-if (not (location= x y))))
67 (:results (y :scs (any-reg descriptor-reg control-stack)
68 :load-if (not (location= x y))))
72 (unless (location= x y)
74 ((any-reg descriptor-reg)
77 (store-stack-tn y x))))))
79 (define-move-vop move :move
80 (any-reg descriptor-reg zero null)
81 (any-reg descriptor-reg))
83 ;;; Make Move the check VOP for T so that type check generation doesn't think
84 ;;; it is a hairy type. This also allows checking of a few of the values in a
85 ;;; continuation to fall out.
87 (primitive-type-vop move (:check) t)
89 ;;; The Move-Argument VOP is used for moving descriptor values into another
90 ;;; frame for argument or known value passing.
92 (define-vop (move-arg)
94 :scs (any-reg descriptor-reg null zero))
96 :load-if (not (sc-is y any-reg descriptor-reg))))
100 ((any-reg descriptor-reg)
103 (storew x fp (tn-offset y))))))
105 (define-move-vop move-arg :move-arg
106 (any-reg descriptor-reg null zero)
107 (any-reg descriptor-reg))
113 ;;; This VOP exists just to begin the lifetime of a TN that couldn't be written
114 ;;; legally due to a type error. An error is signalled before this VOP is
115 ;;; so we don't need to do anything (not that there would be anything sensible
118 (define-vop (illegal-move)
123 (:save-p :compute-only)
125 (error-call vop object-not-type-error x type)))
129 ;;;; Moves and coercions:
131 ;;; These MOVE-TO-WORD VOPs move a tagged integer to a raw full-word
132 ;;; representation. Similarly, the MOVE-FROM-WORD VOPs converts a raw integer
133 ;;; to a tagged bignum or fixnum.
135 ;;; Arg is a fixnum, so just shift it. We need a type restriction because some
136 ;;; possible arg SCs (control-stack) overlap with possible bignum arg SCs.
138 (define-vop (move-to-word/fixnum)
139 (:args (x :scs (any-reg descriptor-reg)))
140 (:results (y :scs (signed-reg unsigned-reg)))
141 (:arg-types tagged-num)
142 (:note "fixnum untagging")
144 (inst sra y x n-fixnum-tag-bits)))
146 (define-move-vop move-to-word/fixnum :move
147 (any-reg descriptor-reg) (signed-reg unsigned-reg))
149 ;;; Arg is a non-immediate constant, load it.
150 (define-vop (move-to-word-c)
151 (:args (x :scs (constant)))
152 (:results (y :scs (signed-reg unsigned-reg)))
153 (:note "constant load")
155 (cond ((sb!c::tn-leaf x)
156 (inst li y (tn-value x)))
158 (loadw y code-tn (tn-offset x) other-pointer-lowtag)
159 (inst sra y y n-fixnum-tag-bits)))))
161 (define-move-vop move-to-word-c :move
162 (constant) (signed-reg unsigned-reg))
164 ;;; Arg is a fixnum or bignum, figure out which and load if necessary.
165 (define-vop (move-to-word/integer)
166 (:args (x :scs (descriptor-reg)))
167 (:results (y :scs (signed-reg unsigned-reg)))
168 (:note "integer to untagged word coercion")
169 (:temporary (:scs (non-descriptor-reg)) temp)
171 (let ((done (gen-label)))
172 (inst and temp x fixnum-tag-mask)
174 (inst sra y x n-fixnum-tag-bits)
176 (loadw y x bignum-digits-offset other-pointer-lowtag)
179 (define-move-vop move-to-word/integer :move
180 (descriptor-reg) (signed-reg unsigned-reg))
183 ;;; Result is a fixnum, so we can just shift. We need the result type
184 ;;; restriction because of the control-stack ambiguity noted above.
186 (define-vop (move-from-word/fixnum)
187 (:args (x :scs (signed-reg unsigned-reg)))
188 (:results (y :scs (any-reg descriptor-reg)))
189 (:result-types tagged-num)
190 (:note "fixnum tagging")
192 (inst sll y x n-fixnum-tag-bits)))
194 (define-move-vop move-from-word/fixnum :move
195 (signed-reg unsigned-reg) (any-reg descriptor-reg))
197 ;;; Result may be a bignum, so we have to check. Use a worst-case cost to make
198 ;;; sure people know they may be number consing.
200 (define-vop (move-from-signed)
201 (:args (arg :scs (signed-reg unsigned-reg) :target x))
202 (:results (y :scs (any-reg descriptor-reg)))
203 (:temporary (:scs (non-descriptor-reg) :from (:argument 0)) x temp)
204 (:temporary (:sc non-descriptor-reg :offset nl4-offset) pa-flag)
205 (:note "signed word to integer coercion")
208 (let ((fixnum (gen-label))
210 (inst sra temp x n-positive-fixnum-bits)
211 (inst beq temp fixnum)
212 (inst nor temp zero-tn)
214 (inst sll y x n-fixnum-tag-bits)
216 (with-fixed-allocation
217 (y pa-flag temp bignum-widetag (1+ bignum-digits-offset) nil)
218 (storew x y bignum-digits-offset other-pointer-lowtag))
223 (inst sll y x n-fixnum-tag-bits)
226 (define-move-vop move-from-signed :move
227 (signed-reg) (descriptor-reg))
230 ;;; Check for fixnum, and possibly allocate one or two word bignum result. Use
231 ;;; a worst-case cost to make sure people know they may be number consing.
233 (define-vop (move-from-unsigned)
234 (:args (arg :scs (signed-reg unsigned-reg) :target x))
235 (:results (y :scs (any-reg descriptor-reg)))
236 (:temporary (:scs (non-descriptor-reg) :from (:argument 0)) x temp)
237 (:temporary (:sc non-descriptor-reg :offset nl4-offset) pa-flag)
238 (:note "unsigned word to integer coercion")
241 (inst srl temp x n-positive-fixnum-bits)
243 (inst sll y x n-fixnum-tag-bits)
246 (pa-flag :extra (pad-data-block (+ bignum-digits-offset 2)))
247 (inst or y alloc-tn other-pointer-lowtag)
248 (inst slt temp x zero-tn)
249 (inst sll temp n-widetag-bits)
250 (inst addu temp (logior (ash 1 n-widetag-bits) bignum-widetag))
251 (storew temp y 0 other-pointer-lowtag))
253 (storew x y bignum-digits-offset other-pointer-lowtag)
256 (define-move-vop move-from-unsigned :move
257 (unsigned-reg) (descriptor-reg))
260 ;;; Move untagged numbers.
262 (define-vop (word-move)
264 :scs (signed-reg unsigned-reg)
265 :load-if (not (location= x y))))
266 (:results (y :scs (signed-reg unsigned-reg)
267 :load-if (not (location= x y))))
270 (:note "word integer move")
274 (define-move-vop word-move :move
275 (signed-reg unsigned-reg) (signed-reg unsigned-reg))
278 ;;; Move untagged number arguments/return-values.
280 (define-vop (move-word-arg)
282 :scs (signed-reg unsigned-reg))
284 :load-if (not (sc-is y sap-reg))))
286 (:note "word integer argument move")
289 ((signed-reg unsigned-reg)
291 ((signed-stack unsigned-stack)
292 (storew x fp (tn-offset y))))))
294 (define-move-vop move-word-arg :move-arg
295 (descriptor-reg any-reg signed-reg unsigned-reg) (signed-reg unsigned-reg))
298 ;;; Use standard MOVE-ARGUMENT + coercion to move an untagged number to a
299 ;;; descriptor passing location.
301 (define-move-vop move-arg :move-arg
302 (signed-reg unsigned-reg) (any-reg descriptor-reg))