[llvm] r199653 - [x86] Fix 16-bit disassembly of JCXZ/JECXZ
David Woodhouse
dwmw2 at infradead.org
Mon Jan 20 04:02:49 PST 2014
Author: dwmw2
Date: Mon Jan 20 06:02:48 2014
New Revision: 199653
URL: http://llvm.org/viewvc/llvm-project?rev=199653&view=rev
Log:
[x86] Fix 16-bit disassembly of JCXZ/JECXZ
Modified:
llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c
llvm/trunk/test/MC/Disassembler/X86/x86-16.txt
Modified: llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c?rev=199653&r1=199652&r2=199653&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c (original)
+++ llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c Mon Jan 20 06:02:48 2014
@@ -987,6 +987,25 @@ static int getID(struct InternalInstruct
if (getIDWithAttrMask(&instructionID, insn, attrMask))
return -1;
+ /*
+ * JCXZ/JECXZ need special handling for 16-bit mode because the meaning
+ * of the AdSize prefix is inverted w.r.t. 32-bit mode.
+ */
+ if (insn->mode == MODE_16BIT && insn->opcode == 0xE3) {
+ const struct InstructionSpecifier *spec;
+ spec = specifierForUID(instructionID);
+
+ /*
+ * Check for Ii8PCRel instructions. We could alternatively do a
+ * string-compare on the names, but this is probably cheaper.
+ */
+ if (x86OperandSets[spec->operands][0].type == TYPE_REL8) {
+ attrMask ^= ATTR_ADSIZE;
+ if (getIDWithAttrMask(&instructionID, insn, attrMask))
+ return -1;
+ }
+ }
+
/* The following clauses compensate for limitations of the tables. */
if ((insn->mode == MODE_16BIT || insn->prefixPresent[0x66]) &&
Modified: llvm/trunk/test/MC/Disassembler/X86/x86-16.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/X86/x86-16.txt?rev=199653&r1=199652&r2=199653&view=diff
==============================================================================
--- llvm/trunk/test/MC/Disassembler/X86/x86-16.txt (original)
+++ llvm/trunk/test/MC/Disassembler/X86/x86-16.txt Mon Jan 20 06:02:48 2014
@@ -297,10 +297,10 @@
# CHECK: lcalll $2, $4660
0x66 0x9a 0x34 0x12 0x00 0x00 0x02 0x00
-# CHECKX: jcxz
+# CHECK: jcxz
0xe3 0x00
-# CHECKX: jecxz
+# CHECK: jecxz
0x67 0xe3 0x00
# CHECK: iretw
More information about the llvm-commits
mailing list