aboutsummaryrefslogtreecommitdiff
path: root/src/boot/be
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2010-10-12 16:51:27 -0700
committerGraydon Hoare <[email protected]>2010-10-12 16:51:27 -0700
commit69ae63d4b02b15d47ab90a4bf96880329601f116 (patch)
treea54493f852b7c8c187cb363a09f0f223efae4e1a /src/boot/be
parentrustc: Add mutability to tuple literals (diff)
downloadrust-69ae63d4b02b15d47ab90a4bf96880329601f116.tar.xz
rust-69ae63d4b02b15d47ab90a4bf96880329601f116.zip
Fix horribly embarassing signedness bug in backend, plus related regressions.
Diffstat (limited to 'src/boot/be')
-rw-r--r--src/boot/be/asm.ml5
-rw-r--r--src/boot/be/il.ml6
-rw-r--r--src/boot/be/x86.ml5
3 files changed, 13 insertions, 3 deletions
diff --git a/src/boot/be/asm.ml b/src/boot/be/asm.ml
index 4b05e347..939b297c 100644
--- a/src/boot/be/asm.ml
+++ b/src/boot/be/asm.ml
@@ -590,8 +590,9 @@ and lower_frag
| WORD (m,e) ->
iflog sess
(fun _ ->
- log sess "lowering word %s"
- (string_of_ty_mach m));
+ log sess "lowering word %s with val %s"
+ (string_of_ty_mach m)
+ (fmt_to_str fmt_frag frag));
word (bytes_of_ty_mach m) (mach_is_signed m) e
| ALIGN_FILE (n, frag) ->
diff --git a/src/boot/be/il.ml b/src/boot/be/il.ml
index 0888f8e8..9a63576e 100644
--- a/src/boot/be/il.ml
+++ b/src/boot/be/il.ml
@@ -812,6 +812,12 @@ let umov (dst:cell) (src:operand) : quad' =
else unary UMOV dst src
;;
+let imov (dst:cell) (src:operand) : quad' =
+ if (cell_is_nil dst || operand_is_nil src)
+ then Dead
+ else unary IMOV dst src
+;;
+
let zero (dst:cell) (count:operand) : quad' =
unary ZERO dst count
;;
diff --git a/src/boot/be/x86.ml b/src/boot/be/x86.ml
index d2d70ea2..c9b13d04 100644
--- a/src/boot/be/x86.ml
+++ b/src/boot/be/x86.ml
@@ -663,6 +663,7 @@ let emit_c_call
let emit = Il.emit e in
let mov dst src = emit (Il.umov dst src) in
+ let imov dst src = emit (Il.imov dst src) in
let binary op dst imm = emit (Il.binary op dst (c dst) (immi imm)) in
(* rust calls get task as arg0 *)
@@ -702,6 +703,8 @@ let emit_c_call
mov (r tmp1) arg;
mov (word_n (h esp) i) (c (r tmp1));
end
+ | Il.Imm (_, tm) when mach_is_signed tm ->
+ imov (word_n (h esp) i) arg
| _ ->
mov (word_n (h esp) i) arg
end
@@ -2151,7 +2154,7 @@ let mov (signed:bool) (dst:Il.cell) (src:Il.operand) : Asm.frag =
(* rm32 <- imm32 *)
| (_, _, Il.Imm (i, _)) when is_rm32 dst || is_r8 dst ->
- let t = if signed then TY_u32 else TY_i32 in
+ let t = if signed then TY_i32 else TY_u32 in
insn_rm_r_imm 0xc7 dst slash0 t i
| _ -> raise Unrecognized