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
This commit is contained in:
Chris Lattner 2010-09-08 05:51:12 +00:00
parent ba8e81cca2
commit c8ae35a8e8
2 changed files with 17 additions and 0 deletions

View File

@ -856,6 +856,16 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
std::swap(Operands[1], Operands[2]); std::swap(Operands[1], Operands[2]);
} }
// The assembler accepts "testX <reg>, <mem>" and "testX <mem>, <reg>" as
// synonyms. Our tables only have the "<mem>, <reg>" 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<X86Operand*>(Operands[1])->isReg() &&
static_cast<X86Operand*>(Operands[2])->isMem()) {
std::swap(Operands[1], Operands[2]);
}
return false; return false;
} }

View File

@ -452,3 +452,10 @@ sysret
sysretl sysretl
// CHECK: sysretl // CHECK: sysretl
// CHECK: encoding: [0x0f,0x07] // CHECK: encoding: [0x0f,0x07]
// rdar://8018260
testl %ecx, -24(%ebp)
// CHECK: testl -24(%ebp), %ecx
testl -24(%ebp), %ecx
// CHECK: testl -24(%ebp), %ecx