[PATCH] [llvm-mc] Fix bad sign extension on callw immediate
Douglas Katzman
dougk at google.com
Fri Jun 26 09:59:06 PDT 2015
REPOSITORY
rL LLVM
http://reviews.llvm.org/D9514
Files:
llvm/trunk/lib/Target/X86/Disassembler/X86Disassembler.cpp
llvm/trunk/test/MC/Disassembler/X86/x86-16.txt
llvm/trunk/test/MC/Disassembler/X86/x86-32.txt
llvm/trunk/test/MC/Disassembler/X86/x86-64.txt
Index: llvm/trunk/lib/Target/X86/Disassembler/X86Disassembler.cpp
===================================================================
--- llvm/trunk/lib/Target/X86/Disassembler/X86Disassembler.cpp
+++ llvm/trunk/lib/Target/X86/Disassembler/X86Disassembler.cpp
@@ -551,9 +551,15 @@
case TYPE_REL8:
isBranch = true;
pcrel = insn.startLocation + insn.immediateOffset + insn.immediateSize;
- if(immediate & 0x80)
+ if (immediate & 0x80)
immediate |= ~(0xffull);
break;
+ case TYPE_REL16:
+ isBranch = true;
+ pcrel = insn.startLocation + insn.immediateOffset + insn.immediateSize;
+ if (immediate & 0x8000)
+ immediate |= ~(0xffffull);
+ break;
case TYPE_REL32:
case TYPE_REL64:
isBranch = true;
Index: llvm/trunk/test/MC/Disassembler/X86/x86-32.txt
===================================================================
--- llvm/trunk/test/MC/Disassembler/X86/x86-32.txt
+++ llvm/trunk/test/MC/Disassembler/X86/x86-32.txt
@@ -54,6 +54,9 @@
# CHECK: calll -1234
0xe8 0x2e 0xfb 0xff 0xff
+# CHECK: callw -1
+0x66 0xe8 0xff 0xff
+
# CHECK: lfence
0x0f 0xae 0xe8
Index: llvm/trunk/test/MC/Disassembler/X86/x86-16.txt
===================================================================
--- llvm/trunk/test/MC/Disassembler/X86/x86-16.txt
+++ llvm/trunk/test/MC/Disassembler/X86/x86-16.txt
@@ -786,3 +786,5 @@
# CHECK: lretl
0x66 0xcb
+# CHECK: callw -1
+0xe8 0xff 0xff
Index: llvm/trunk/test/MC/Disassembler/X86/x86-64.txt
===================================================================
--- llvm/trunk/test/MC/Disassembler/X86/x86-64.txt
+++ llvm/trunk/test/MC/Disassembler/X86/x86-64.txt
@@ -339,3 +339,9 @@
# CHECK: vaddps (%rdx,%xmm1), %zmm20, %zmm15
# FIXME: vaddps (%rdx,%rcx), %zmm20, %zmm15
0x62 0x71 0x5c 0x40 0x58 0x3c 0x0a
+
+# CHECK: callq 32767
+0xe8 0xff 0x7f 0x00 0x00
+
+# CHECK: callq -32769
+0xe8 0xff 0x7f 0xff 0xff
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9514.28569.patch
Type: text/x-patch
Size: 1901 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150626/3153c59b/attachment.bin>
More information about the llvm-commits
mailing list