summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-04-29 07:17:41 -0700
committerKaz Kylheku <kaz@kylheku.com>2018-04-29 07:17:41 -0700
commit77502289f6214128b706aeb042500cbf92840003 (patch)
treea190d5c0745a1027607f5333bd02c4d854ec5211
parent0f9d67c5893d1593ca4067bc2a73adce9c068f68 (diff)
downloadtxr-77502289f6214128b706aeb042500cbf92840003.tar.gz
txr-77502289f6214128b706aeb042500cbf92840003.tar.bz2
txr-77502289f6214128b706aeb042500cbf92840003.zip
compiler/assembler: bugfix: bignums can't be immediate ops.
* share/txr/stdlib/asm.tl (assembler immediate-fits-type): Do not include bignum types as candidates for immediate operand. We take the sys:bits representation of the object, and that of course is a pointer. This case actually happens on 32 bit platforms because the value that is one less than the most negative fixnum still fits into the fixnum representational range, due to the way two's complement works, but is actually a bignum. Concretely, the value #x-20000000 is a bignum, but its width is 29, which falsely suggests that its representation can fit into 32 bits as a literal. * share/txr/stdlib/compiler.tl (compiler comp-atom): Test for fixnum here rather than integerp, so in the above discussed case, we don't generate a movi instruction.
-rw-r--r--share/txr/stdlib/asm.tl2
-rw-r--r--share/txr/stdlib/compiler.tl2
2 files changed, 2 insertions, 2 deletions
diff --git a/share/txr/stdlib/asm.tl b/share/txr/stdlib/asm.tl
index a03ead4e..74ba5866 100644
--- a/share/txr/stdlib/asm.tl
+++ b/share/txr/stdlib/asm.tl
@@ -135,7 +135,7 @@
(defmeth assembler immediate-fits-type (me arg operand-type)
(and (member (typeof arg)
- '(fixnum bignum chr))
+ '(fixnum chr))
(<= (+ (width arg)
[me.sign-bits (typeof arg)]
2)
diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl
index 886cad47..4275daf0 100644
--- a/share/txr/stdlib/compiler.tl
+++ b/share/txr/stdlib/compiler.tl
@@ -339,7 +339,7 @@
(defmeth compiler comp-atom (me oreg form)
(cond
((null form) (new (frag '(t 0) nil)))
- ((or (and (integerp form)
+ ((or (and (fixnump form)
(<= (width form) (- %imm-width% 3)))
(chrp form))
(new (frag oreg ^((movi ,oreg ,form)))))