Changeset 7916 for branches/ia32/level0
 Timestamp:
 Dec 17, 2007, 3:14:37 AM (12 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

branches/ia32/level0/X86/X8632/x8632bignum.lisp
r7915 r7916 158 158 159 159 ;;; To normalize a bignum is to drop "trailing" digits which are 160 ;;; redundant sign information. When returnfixnump is t, make160 ;;; redundant sign information. When returnfixnump is nonnil, make 161 161 ;;; the resultant bignum into a fixnum if it fits. 162 162 (defx8632lapfunction %normalizebignum2 ((returnfixnump arg_y) (bignum arg_z)) … … 164 164 (markasimm temp0) 165 165 (markasimm temp1) 166 ;; %zerotrailingsigndigits167 166 (let ((len arg_y) 168 167 (sign temp0) … … 170 169 (vectorlength bignum len) 171 170 (cmpl ($ '1) (% len)) 172 (jle @maybefixnumize) 171 (jle @maybereturnfixnum) 172 ;; Zero trailing sign digits. 173 (push (% len)) 173 174 ;; nexttolast digit 174 175 (movl (@ ( x8632::miscdataoffset 8) (% bignum) (% len)) (% next)) … … 180 181 (movl ($ 0) (@ x8632::miscdataoffset (% bignum) (% len))) 181 182 (cmpl ($ '1) (% len)) ;any more digits? 182 (je @ maybefixnumize)183 (je @adjustlength) 183 184 (movl (% next) (% sign)) 184 185 ;; (bignumref bignum ( len 2)), i.e., nexttolast digit … … 190 191 (testl (% imm0) (% imm0)) ;whole digit only sign? 191 192 (jz @loop) 192 @maybefixnumize 193 ;; New length now in len. 194 @adjustlength 195 (pop (% imm0)) ;original length 196 (cmpl (% len) (% imm0)) 197 ;; If the new length is the same as the original length, we know 198 ;; that the bignum is at least two digits long, and will never fit 199 ;; in a fixnum. Therefore, there's no need to do either of the 200 ;; tests at @maybereturnfixnum. 201 (je @done) 202 (movl (% len) (% imm0)) 203 (shll ($ ( x8632::numsubtagbits x8632::fixnumshift)) (% imm0)) 204 (movb ($ x8632::subtagbignum) (% imm0.b)) 205 (movl (% imm0) (@ x8632::mischeaderoffset (% bignum))) 206 @maybereturnfixnum 207 ;; could use SETcc here to avoid one branch 193 208 (pop (% returnfixnump)) 194 (cmpl ($ x8632::nilvalue) ( % returnfixnump))209 (cmpl ($ x8632::nilvalue) (@ 0 (% esp))) ;returnfixnump 195 210 (je @done) 196 (vectorlength bignum len) 197 (cmpl ($ '1) (% len)) 198 (jg @done) 211 (cmpl ($ x8632::onedigitbignumheader) (% bignum)) 212 (jne @done) 199 213 ;; Bignum has one digit. If it fits in a fixnum, return a fixnum. 200 214 (movl (@ x8632::miscdataoffset (% bignum)) (% imm0)) 201 215 (boxfixnum imm0 arg_y) 202 (cmpl ($ #x3fffffff) (% imm0)) 203 (cmovbel (% arg_y) (% arg_z)) 216 (unboxfixnum arg_y temp0) 217 (cmpl (% temp0) (% imm0)) 218 (cmovel (% arg_y) (% arg_z)) 204 219 @done 220 (pop (% imm0)) ;discard saved returnfixnump 205 221 (markasnode temp0) 206 222 (markasnode temp1)
Note: See TracChangeset
for help on using the changeset viewer.