From 5f4a2ac3e793dc45c797f64f3292f6d160068b7b Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Tue, 6 Sep 2016 21:03:36 +0200 Subject: [PATCH] Fix cross-compilation of negative fixnums * module/system/vm/assembler.scm (encoder): Use immediate-bits instead of object-address, to fix cross-compilation. --- module/system/vm/assembler.scm | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/module/system/vm/assembler.scm b/module/system/vm/assembler.scm index c72622e70..a2992b495 100644 --- a/module/system/vm/assembler.scm +++ b/module/system/vm/assembler.scm @@ -551,7 +551,7 @@ later by the linker." (record-label-reference asm label) (emit asm opcode)) ((X8_S8_I16 a imm) - (emit asm (pack-u8-u8-u16 opcode a (object-address imm)))) + (emit asm (pack-u8-u8-u16 opcode a (immediate-bits asm imm)))) ((X8_S12_S12 a b) (emit asm (pack-u8-u12-u12 opcode a b))) ((X8_S12_C12 a b) @@ -573,15 +573,14 @@ later by the linker." ((C32 a) (emit asm a)) ((I32 imm) - (let ((val (object-address imm))) - (unless (zero? (ash val -32)) - (error "FIXME: enable truncation of negative fixnums when cross-compiling")) + (let ((val (immediate-bits asm imm))) (emit asm val))) ((A32 imm) (unless (= (asm-word-size asm) 8) (error "make-long-immediate unavailable for this target")) - (emit asm (ash (object-address imm) -32)) - (emit asm (logand (object-address imm) (1- (ash 1 32))))) + (let ((bits (immediate-bits asm imm))) + (emit asm (ash bits -32)) + (emit asm (logand bits (1- (ash 1 32)))))) ((AF32 f64) (let ((u64 (u64vector-ref (f64vector f64) 0))) (emit asm (ash u64 -32))