diff --git a/lib/Target/X86/X86InstrArithmetic.td b/lib/Target/X86/X86InstrArithmetic.td index 9f7a4b06dc6..c7eb18d8b9e 100644 --- a/lib/Target/X86/X86InstrArithmetic.td +++ b/lib/Target/X86/X86InstrArithmetic.td @@ -650,6 +650,15 @@ class BinOpRR_Rev opcode, string mnemonic, X86TypeInfo typeinfo> let isCodeGenOnly = 1; } +// BinOpRR_F_Rev - Instructions like "cmp reg, reg" (reversed encoding). +class BinOpRR_F_Rev opcode, string mnemonic, X86TypeInfo typeinfo> + : ITy { + // The disassembler should know about this, but not the asmparser. + let isCodeGenOnly = 1; +} + // BinOpRM - Instructions like "add reg, reg, [mem]". class BinOpRM opcode, string mnemonic, X86TypeInfo typeinfo, dag outlist, list pattern> @@ -1017,10 +1026,10 @@ multiclass ArithBinOp_F BaseOpc, bits<8> BaseOpc2, bits<8> BaseOpc4, def #NAME#64rr : BinOpRR_F; } // isCommutable - def #NAME#8rr_REV : BinOpRR_Rev; - def #NAME#16rr_REV : BinOpRR_Rev; - def #NAME#32rr_REV : BinOpRR_Rev; - def #NAME#64rr_REV : BinOpRR_Rev; + def #NAME#8rr_REV : BinOpRR_F_Rev; + def #NAME#16rr_REV : BinOpRR_F_Rev; + def #NAME#32rr_REV : BinOpRR_F_Rev; + def #NAME#64rr_REV : BinOpRR_F_Rev; def #NAME#8rm : BinOpRM_F; def #NAME#16rm : BinOpRM_F; diff --git a/test/MC/Disassembler/X86/simple-tests.txt b/test/MC/Disassembler/X86/simple-tests.txt index 62f3464d830..d4e7b128703 100644 --- a/test/MC/Disassembler/X86/simple-tests.txt +++ b/test/MC/Disassembler/X86/simple-tests.txt @@ -161,3 +161,15 @@ # CHECK: pause 0xf3 0x90 + +# CHECK: addl %eax, %edi +0x01 0xc7 + +# CHECK: addl %edi, %eax +0x03 0xc7 + +# CHECK: movl %eax, %edi +0x89 0xc7 + +# CHECK: movl %edi, %eax +0x8b 0xc7 diff --git a/utils/TableGen/X86RecognizableInstr.cpp b/utils/TableGen/X86RecognizableInstr.cpp index f43a93938bb..23c0fa8cd9f 100644 --- a/utils/TableGen/X86RecognizableInstr.cpp +++ b/utils/TableGen/X86RecognizableInstr.cpp @@ -345,7 +345,7 @@ RecognizableInstr::filter_ret RecognizableInstr::filter() const { return FILTER_STRONG; if (Form == X86Local::Pseudo || - IsCodeGenOnly) + (IsCodeGenOnly && Name.find("_REV") == Name.npos)) return FILTER_STRONG; if (Form == X86Local::MRMInitReg)