Modify DisassembleThumb2LdStEx() to be more robust/correct in light of recent change to

t2LDREX/t2STREX instructions.  Add two test cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128293 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Johnny Chen
2011-03-25 18:29:49 +00:00
parent 8b2b43c41d
commit ceceabd4b1
2 changed files with 12 additions and 6 deletions

View File

@ -1194,8 +1194,8 @@ static bool DisassembleThumb2LdStEx(MCInst &MI, unsigned Opcode, uint32_t insn,
OpIdx = 0; OpIdx = 0;
assert(NumOps >= 2 assert(NumOps >= 2
&& OpInfo[0].RegClass == ARM::GPRRegClassID && OpInfo[0].RegClass > 0
&& OpInfo[1].RegClass == ARM::GPRRegClassID && OpInfo[1].RegClass > 0
&& "Expect >=2 operands and first two as reg operands"); && "Expect >=2 operands and first two as reg operands");
bool isStore = (ARM::t2STREX <= Opcode && Opcode <= ARM::t2STREXH); bool isStore = (ARM::t2STREX <= Opcode && Opcode <= ARM::t2STREXH);
@ -1205,25 +1205,25 @@ static bool DisassembleThumb2LdStEx(MCInst &MI, unsigned Opcode, uint32_t insn,
// Add the destination operand for store. // Add the destination operand for store.
if (isStore) { if (isStore) {
MI.addOperand(MCOperand::CreateReg( MI.addOperand(MCOperand::CreateReg(
getRegisterEnum(B, ARM::GPRRegClassID, getRegisterEnum(B, OpInfo[OpIdx].RegClass,
isSW ? decodeRs(insn) : decodeRm(insn)))); isSW ? decodeRs(insn) : decodeRm(insn))));
++OpIdx; ++OpIdx;
} }
// Source operand for store and destination operand for load. // Source operand for store and destination operand for load.
MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, ARM::GPRRegClassID, MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, OpInfo[OpIdx].RegClass,
decodeRd(insn)))); decodeRd(insn))));
++OpIdx; ++OpIdx;
// Thumb2 doubleword complication: with an extra source/destination operand. // Thumb2 doubleword complication: with an extra source/destination operand.
if (isDW) { if (isDW) {
MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, ARM::GPRRegClassID, MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B,OpInfo[OpIdx].RegClass,
decodeRs(insn)))); decodeRs(insn))));
++OpIdx; ++OpIdx;
} }
// Finally add the pointer operand. // Finally add the pointer operand.
MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, ARM::GPRRegClassID, MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, OpInfo[OpIdx].RegClass,
decodeRn(insn)))); decodeRn(insn))));
++OpIdx; ++OpIdx;

View File

@ -154,3 +154,9 @@
# CHECK: ldrd r3, r8, [r11, #-60] # CHECK: ldrd r3, r8, [r11, #-60]
0x5b 0xe9 0x0f 0x38 0x5b 0xe9 0x0f 0x38
# CHECK: ldrex r8, [r2]
0x52 0xe8 0x00 0x8f
# CHECK: strexd r1, r7, r8, [r2]
0xc2 0xe8 0x71 0x78