From 36a9b31b981553350f5cc4adad9917656c20e96e Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Mon, 7 Oct 2013 04:28:06 +0000 Subject: [PATCH] Add disassembler support for long encodings for INC/DEC in 32-bit mode. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192086 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86InstrArithmetic.td | 16 ++++++++++++++- test/MC/Disassembler/X86/x86-32.txt | 24 +++++++++++++++++++++++ test/MC/Disassembler/X86/x86-64.txt | 26 ++++++++++++++++++++++++- utils/TableGen/X86RecognizableInstr.cpp | 3 ++- 4 files changed, 66 insertions(+), 3 deletions(-) diff --git a/lib/Target/X86/X86InstrArithmetic.td b/lib/Target/X86/X86InstrArithmetic.td index 04119753946..7fc9c443373 100644 --- a/lib/Target/X86/X86InstrArithmetic.td +++ b/lib/Target/X86/X86InstrArithmetic.td @@ -497,6 +497,21 @@ def DEC64_32r : I<0xFF, MRM1r, (outs GR32:$dst), (ins GR32:$src1), Requires<[In64BitMode]>; } // isConvertibleToThreeAddress = 1, CodeSize = 2 +let isCodeGenOnly = 1, CodeSize = 2 in { +def INC32_16r : I<0xFF, MRM0r, (outs GR16:$dst), (ins GR16:$src1), + "inc{w}\t$dst", [], IIC_UNARY_REG>, + OpSize, Requires<[In32BitMode]>; +def INC32_32r : I<0xFF, MRM0r, (outs GR32:$dst), (ins GR32:$src1), + "inc{l}\t$dst", [], IIC_UNARY_REG>, + Requires<[In32BitMode]>; +def DEC32_16r : I<0xFF, MRM1r, (outs GR16:$dst), (ins GR16:$src1), + "dec{w}\t$dst", [], IIC_UNARY_REG>, + OpSize, Requires<[In32BitMode]>; +def DEC32_32r : I<0xFF, MRM1r, (outs GR32:$dst), (ins GR32:$src1), + "dec{l}\t$dst", [], IIC_UNARY_REG>, + Requires<[In32BitMode]>; +} // isCodeGenOnly = 1, CodeSize = 2 + } // Constraints = "$src1 = $dst", SchedRW let CodeSize = 2, SchedRW = [WriteALULd, WriteRMW] in { @@ -578,7 +593,6 @@ let CodeSize = 2, SchedRW = [WriteALULd, WriteRMW] in { } // CodeSize = 2, SchedRW } // Defs = [EFLAGS] - /// X86TypeInfo - This is a bunch of information that describes relevant X86 /// information about value types. For example, it can tell you what the /// register class and preferred load to use. diff --git a/test/MC/Disassembler/X86/x86-32.txt b/test/MC/Disassembler/X86/x86-32.txt index d53da5b7d29..2d2b3351de6 100644 --- a/test/MC/Disassembler/X86/x86-32.txt +++ b/test/MC/Disassembler/X86/x86-32.txt @@ -666,3 +666,27 @@ # CHECK: movl %eax, 878082192 0xa3 0x90 0x78 0x56 0x34 + +# CHECK: incl %ecx +0xff 0xc1 + +# CHECK: decl %ecx +0xff 0xc9 + +# CHECK: incw %cx +0x66 0xff 0xc1 + +# CHECK: decw %cx +0x66 0xff 0xc9 + +# CHECK: incb %cl +0xfe 0xc1 + +# CHECK: decb %cl +0xfe 0xc9 + +# CHECK: incl %ecx +0x41 + +# CHECK: decl %ecx +0x49 diff --git a/test/MC/Disassembler/X86/x86-64.txt b/test/MC/Disassembler/X86/x86-64.txt index 4e4107ebac2..8c3e4fdf4fc 100644 --- a/test/MC/Disassembler/X86/x86-64.txt +++ b/test/MC/Disassembler/X86/x86-64.txt @@ -198,4 +198,28 @@ 0x0f 0x38 0xcd 0xd1 # CHECK: sha256msg2 (%rax), %xmm2 -0x0f 0x38 0xcd 0x10 \ No newline at end of file +0x0f 0x38 0xcd 0x10 + +# CHECK: incl %ecx +0xff 0xc1 + +# CHECK: decl %ecx +0xff 0xc9 + +# CHECK: incw %cx +0x66 0xff 0xc1 + +# CHECK: decw %cx +0x66 0xff 0xc9 + +# CHECK: incb %cl +0xfe 0xc1 + +# CHECK: decb %cl +0xfe 0xc9 + +# CHECK: incq %rcx +0x48 0xff 0xc1 + +# CHECK: decq %rcx +0x48 0xff 0xc9 diff --git a/utils/TableGen/X86RecognizableInstr.cpp b/utils/TableGen/X86RecognizableInstr.cpp index 7c8b84ee460..fed3f7758ed 100644 --- a/utils/TableGen/X86RecognizableInstr.cpp +++ b/utils/TableGen/X86RecognizableInstr.cpp @@ -491,7 +491,8 @@ RecognizableInstr::filter_ret RecognizableInstr::filter() const { assert(Rec->isSubClassOf("X86Inst") && "Can only filter X86 instructions"); if (Form == X86Local::Pseudo || - (IsCodeGenOnly && Name.find("_REV") == Name.npos)) + (IsCodeGenOnly && Name.find("_REV") == Name.npos && + Name.find("INC32") == Name.npos && Name.find("DEC32") == Name.npos)) return FILTER_STRONG; -- 2.34.1