From c8ae35a8e8a6a39ae05b1c876afbf404e20961ff Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 8 Sep 2010 05:51:12 +0000 Subject: [PATCH] add support for the commuted form of the test instruction, rdar://8018260. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113352 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/AsmParser/X86AsmParser.cpp | 10 ++++++++++ test/MC/AsmParser/X86/x86_32-new-encoder.s | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/lib/Target/X86/AsmParser/X86AsmParser.cpp b/lib/Target/X86/AsmParser/X86AsmParser.cpp index 90bd4e3d1b5..7d62c466b27 100644 --- a/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -856,6 +856,16 @@ ParseInstruction(StringRef Name, SMLoc NameLoc, std::swap(Operands[1], Operands[2]); } + // The assembler accepts "testX , " and "testX , " as + // synonyms. Our tables only have the ", " form, so if we see the + // other operand order, swap them. + if (Name == "testb" || Name == "testw" || Name == "testl" || Name == "testq") + if (Operands.size() == 3 && + static_cast(Operands[1])->isReg() && + static_cast(Operands[2])->isMem()) { + std::swap(Operands[1], Operands[2]); + } + return false; } diff --git a/test/MC/AsmParser/X86/x86_32-new-encoder.s b/test/MC/AsmParser/X86/x86_32-new-encoder.s index ed8ee868196..6d9d7ed4074 100644 --- a/test/MC/AsmParser/X86/x86_32-new-encoder.s +++ b/test/MC/AsmParser/X86/x86_32-new-encoder.s @@ -452,3 +452,10 @@ sysret sysretl // CHECK: sysretl // CHECK: encoding: [0x0f,0x07] + +// rdar://8018260 +testl %ecx, -24(%ebp) +// CHECK: testl -24(%ebp), %ecx +testl -24(%ebp), %ecx +// CHECK: testl -24(%ebp), %ecx + -- 2.34.1