aboutsummaryrefslogtreecommitdiffstats
path: root/lib/hipe/amd64/hipe_amd64_encode.erl
diff options
context:
space:
mode:
authorMagnus Lång <[email protected]>2016-11-16 18:29:16 +0100
committerMagnus Lång <[email protected]>2016-11-16 19:48:24 +0100
commitfda3c9575d77bed0250f76f17e92d18836e15d0c (patch)
treeff0e90f7353c7dfb668364070986f619478f305c /lib/hipe/amd64/hipe_amd64_encode.erl
parent053e54e5a937deb685dc71e3873074cb8efc96ea (diff)
downloadotp-fda3c9575d77bed0250f76f17e92d18836e15d0c.tar.gz
otp-fda3c9575d77bed0250f76f17e92d18836e15d0c.tar.bz2
otp-fda3c9575d77bed0250f76f17e92d18836e15d0c.zip
hipe_x86: Fix encoding of test instr w/ neg imm
Also, use byte form for immediates up to 255, since there's no sign extension in byte form. HiPE seems to never generate negative test immediates currently, but we should at least not output incorrect encodings.
Diffstat (limited to 'lib/hipe/amd64/hipe_amd64_encode.erl')
-rw-r--r--lib/hipe/amd64/hipe_amd64_encode.erl6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/hipe/amd64/hipe_amd64_encode.erl b/lib/hipe/amd64/hipe_amd64_encode.erl
index c41eaa3c6a..16bd705055 100644
--- a/lib/hipe/amd64/hipe_amd64_encode.erl
+++ b/lib/hipe/amd64/hipe_amd64_encode.erl
@@ -828,12 +828,16 @@ test_encode(Opnds) ->
[?PFX_OPND_16BITS, 16#A9 | le16(Imm16, [])];
{eax, {imm32,Imm32}} ->
[16#A9 | le32(Imm32, [])];
+ {rax, {imm32,Imm32}} ->
+ [rex([{w,1}]), 16#A9 | le32(Imm32, [])];
{{rm8,RM8}, {imm8,Imm8}} ->
[rex([{r8,RM8}]), 16#F6 | encode_rm(RM8, 2#000, [Imm8])];
{{rm16,RM16}, {imm16,Imm16}} ->
[?PFX_OPND_16BITS, 16#F7 | encode_rm(RM16, 2#000, le16(Imm16, []))];
{{rm32,RM32}, {imm32,Imm32}} ->
[16#F7 | encode_rm(RM32, 2#000, le32(Imm32, []))];
+ {{rm64,RM64}, {imm32,Imm32}} ->
+ [rex([{w,1}]), 16#F7 | encode_rm(RM64, 2#000, le32(Imm32, []))];
{{rm32,RM32}, {reg32,Reg32}} ->
[16#85 | encode_rm(RM32, Reg32, [])];
{{rm64,RM64}, {reg64,Reg64}} ->
@@ -1478,10 +1482,12 @@ dotest1(OS) ->
t(OS,'test',{al,Imm8}),
t(OS,'test',{ax,Imm16}),
t(OS,'test',{eax,Imm32}),
+ t(OS,'test',{rax,Imm32}),
t(OS,'test',{RM8,Imm8}),
t(OS,'test',{RM8REX,Imm8}),
t(OS,'test',{RM16,Imm16}),
t(OS,'test',{RM32,Imm32}),
+ t(OS,'test',{RM64,Imm32}),
t(OS,'test',{RM32,Reg32}),
t(OS,'test',{RM64,Reg64}),
t(OS,'xor',{eax,Imm32}),