4 (define-assembly-routine (generic-+
6 (:return-style :full-call)
10 ((:arg x (descriptor-reg any-reg) a0-offset)
11 (:arg y (descriptor-reg any-reg) a1-offset)
13 (:res res (descriptor-reg any-reg) a0-offset)
15 (:temp temp non-descriptor-reg nl0-offset)
16 (:temp temp1 non-descriptor-reg nl1-offset)
17 (:temp temp2 non-descriptor-reg nl2-offset)
18 (:temp pa-flag non-descriptor-reg nl4-offset)
19 (:temp lip interior-reg lip-offset)
20 (:temp nargs any-reg nargs-offset)
21 (:temp ocfp any-reg ocfp-offset))
23 (inst and temp fixnum-tag-mask)
24 (inst beq temp DO-ADD)
25 (inst sra temp1 x n-fixnum-tag-bits)
28 (inst lw lip null-tn (static-fun-offset 'two-arg-+))
29 (inst li nargs (fixnumize 2))
30 (inst move ocfp cfp-tn)
32 (inst move cfp-tn csp-tn)
35 (inst sra temp2 y n-fixnum-tag-bits)
36 (inst addu temp temp1 temp2)
38 (inst sra temp1 temp (- n-word-bits n-lowtag-bits))
39 (inst beq temp1 RETURN)
40 (inst nor temp1 temp1)
41 (inst beq temp1 RETURN)
43 (with-fixed-allocation (res pa-flag temp2 bignum-widetag (1+ bignum-digits-offset))
44 (storew temp res bignum-digits-offset other-pointer-lowtag))
49 (inst sll res temp n-fixnum-tag-bits)
54 (define-assembly-routine (generic--
56 (:return-style :full-call)
60 ((:arg x (descriptor-reg any-reg) a0-offset)
61 (:arg y (descriptor-reg any-reg) a1-offset)
63 (:res res (descriptor-reg any-reg) a0-offset)
65 (:temp temp non-descriptor-reg nl0-offset)
66 (:temp temp1 non-descriptor-reg nl1-offset)
67 (:temp temp2 non-descriptor-reg nl2-offset)
68 (:temp pa-flag non-descriptor-reg nl4-offset)
69 (:temp lip interior-reg lip-offset)
70 (:temp nargs any-reg nargs-offset)
71 (:temp ocfp any-reg ocfp-offset))
73 (inst and temp fixnum-tag-mask)
74 (inst beq temp DO-SUB)
75 (inst sra temp1 x n-fixnum-tag-bits)
78 (inst lw lip null-tn (static-fun-offset 'two-arg--))
79 (inst li nargs (fixnumize 2))
80 (inst move ocfp cfp-tn)
82 (inst move cfp-tn csp-tn)
85 (inst sra temp2 y n-fixnum-tag-bits)
86 (inst subu temp temp1 temp2)
88 (inst sra temp1 temp (- n-word-bits n-lowtag-bits))
89 (inst beq temp1 RETURN)
90 (inst nor temp1 temp1)
91 (inst beq temp1 RETURN)
93 (with-fixed-allocation (res pa-flag temp2 bignum-widetag (1+ bignum-digits-offset))
94 (storew temp res bignum-digits-offset other-pointer-lowtag))
99 (inst sll res temp n-fixnum-tag-bits)
104 (define-assembly-routine (generic-*
106 (:return-style :full-call)
110 ((:arg x (descriptor-reg any-reg) a0-offset)
111 (:arg y (descriptor-reg any-reg) a1-offset)
113 (:res res (descriptor-reg any-reg) a0-offset)
115 (:temp temp non-descriptor-reg nl0-offset)
116 (:temp lo non-descriptor-reg nl1-offset)
117 (:temp hi non-descriptor-reg nl2-offset)
118 (:temp pa-flag non-descriptor-reg nl4-offset)
119 (:temp lip interior-reg lip-offset)
120 (:temp nargs any-reg nargs-offset)
121 (:temp ocfp any-reg ocfp-offset))
122 ;; If either arg is not a fixnum, call the static function.
124 (inst and temp fixnum-tag-mask)
125 (inst bne temp DO-STATIC-FUN)
126 ;; Remove the tag from one arg so that the result will have the correct
128 (inst sra temp x n-fixnum-tag-bits)
132 ;; Check to see if the result will fit in a fixnum. (I.e. the high word
133 ;; is just 32 copies of the sign bit of the low word).
134 (inst sra temp res 31)
135 (inst beq temp hi DONE)
136 ;; Shift the double word hi:res down two bits into hi:low to get rid of the
138 (inst srl lo res n-fixnum-tag-bits)
139 (inst sll temp hi (- n-word-bits n-fixnum-tag-bits))
141 (inst sra hi n-fixnum-tag-bits)
143 ;; Do we need one word or two? Assume two.
144 (inst sra temp lo 31)
145 (inst bne temp hi TWO-WORDS)
146 ;; Assume a two word header.
147 (inst li temp (logior (ash 2 n-widetag-bits) bignum-widetag))
149 ;; Only need one word, fix the header.
150 (inst li temp (logior (ash 1 n-widetag-bits) bignum-widetag))
152 (pseudo-atomic (pa-flag :extra (pad-data-block (+ 1 bignum-digits-offset)))
153 (inst or res alloc-tn other-pointer-lowtag)
154 (storew temp res 0 other-pointer-lowtag))
156 (storew lo res bignum-digits-offset other-pointer-lowtag)
163 (pseudo-atomic (pa-flag :extra (pad-data-block (+ 2 bignum-digits-offset)))
164 (inst or res alloc-tn other-pointer-lowtag)
165 (storew temp res 0 other-pointer-lowtag))
167 (storew lo res bignum-digits-offset other-pointer-lowtag)
168 (storew hi res (1+ bignum-digits-offset) other-pointer-lowtag)
175 (inst lw lip null-tn (static-fun-offset 'two-arg-*))
176 (inst li nargs (fixnumize 2))
177 (inst move ocfp cfp-tn)
179 (inst move cfp-tn csp-tn)
185 ;;;; Comparison routines.
188 ((define-cond-assem-rtn (name translate static-fn cmp)
189 `(define-assembly-routine (,name
191 (:return-style :full-call)
193 (:translate ,translate)
195 ((:arg x (descriptor-reg any-reg) a0-offset)
196 (:arg y (descriptor-reg any-reg) a1-offset)
198 (:res res descriptor-reg a0-offset)
200 (:temp temp non-descriptor-reg nl0-offset)
201 (:temp lip interior-reg lip-offset)
202 (:temp nargs any-reg nargs-offset)
203 (:temp ocfp any-reg ocfp-offset))
205 (inst and temp fixnum-tag-mask)
206 (inst beq temp DO-COMPARE)
210 (inst lw lip null-tn (static-fun-offset ',static-fn))
211 (inst li nargs (fixnumize 2))
212 (inst move ocfp cfp-tn)
214 (inst move cfp-tn csp-tn)
218 (inst move res null-tn)
223 (define-cond-assem-rtn generic-< < two-arg-< (inst slt temp x y))
224 (define-cond-assem-rtn generic-> > two-arg-> (inst slt temp y x)))
227 (define-assembly-routine (generic-eql
229 (:return-style :full-call)
233 ((:arg x (descriptor-reg any-reg) a0-offset)
234 (:arg y (descriptor-reg any-reg) a1-offset)
236 (:res res descriptor-reg a0-offset)
238 (:temp temp non-descriptor-reg nl0-offset)
239 (:temp lip interior-reg lip-offset)
240 (:temp nargs any-reg nargs-offset)
241 (:temp ocfp any-reg ocfp-offset))
242 (inst beq x y RETURN-T)
244 (inst and temp fixnum-tag-mask)
245 (inst beq temp RETURN)
249 (inst lw lip null-tn (static-fun-offset 'eql))
250 (inst li nargs (fixnumize 2))
251 (inst move ocfp cfp-tn)
253 (inst move cfp-tn csp-tn)
257 (inst move res null-tn)
265 (define-assembly-routine (generic-=
267 (:return-style :full-call)
271 ((:arg x (descriptor-reg any-reg) a0-offset)
272 (:arg y (descriptor-reg any-reg) a1-offset)
274 (:res res descriptor-reg a0-offset)
276 (:temp temp non-descriptor-reg nl0-offset)
277 (:temp lip interior-reg lip-offset)
278 (:temp nargs any-reg nargs-offset)
279 (:temp ocfp any-reg ocfp-offset))
281 (inst and temp fixnum-tag-mask)
282 (inst beq temp RETURN)
286 (inst lw lip null-tn (static-fun-offset 'two-arg-=))
287 (inst li nargs (fixnumize 2))
288 (inst move ocfp cfp-tn)
290 (inst move cfp-tn csp-tn)
294 (inst move res null-tn)
300 (define-assembly-routine (generic-/=
302 (:return-style :full-call)
306 ((:arg x (descriptor-reg any-reg) a0-offset)
307 (:arg y (descriptor-reg any-reg) a1-offset)
309 (:res res descriptor-reg a0-offset)
311 (:temp temp non-descriptor-reg nl0-offset)
312 (:temp lip interior-reg lip-offset)
313 (:temp nargs any-reg nargs-offset)
314 (:temp ocfp any-reg ocfp-offset))
316 (inst and temp fixnum-tag-mask)
317 (inst beq temp RETURN)
321 (inst lw lip null-tn (static-fun-offset 'two-arg-/=))
322 (inst li nargs (fixnumize 2))
323 (inst move ocfp cfp-tn)
325 (inst move cfp-tn csp-tn)
329 (inst move res null-tn)