mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-14 15:19:33 +00:00
Fix ARM disassembly for PLD/PLDW/PLI which suffers from code rot and add some test cases.
Add comments to ThumbDisassemblerCore.h for recent change made for t2PLD disassembly. llvm-svn: 128417
This commit is contained in:
parent
8c488cb152
commit
8b921cebc6
@ -2893,8 +2893,8 @@ static bool DisassemblePreLoadFrm(MCInst &MI, unsigned Opcode, uint32_t insn,
|
||||
unsigned short NumOps, unsigned &NumOpsAdded, BO B) {
|
||||
|
||||
// Preload Data/Instruction requires either 2 or 3 operands.
|
||||
// PLDi, PLDWi, PLIi: addrmode_imm12
|
||||
// PLDr[a|m], PLDWr[a|m], PLIr[a|m]: ldst_so_reg
|
||||
// PLDi12, PLDWi12, PLIi12: addrmode_imm12
|
||||
// PLDrs, PLDWrs, PLIrs: ldst_so_reg
|
||||
|
||||
MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, ARM::GPRRegClassID,
|
||||
decodeRn(insn))));
|
||||
@ -2903,10 +2903,19 @@ static bool DisassemblePreLoadFrm(MCInst &MI, unsigned Opcode, uint32_t insn,
|
||||
|| Opcode == ARM::PLIi12) {
|
||||
unsigned Imm12 = slice(insn, 11, 0);
|
||||
bool Negative = getUBit(insn) == 0;
|
||||
|
||||
// A8.6.118 PLD (literal) PLDWi12 with Rn=PC is transformed to PLDi12.
|
||||
if (Opcode == ARM::PLDWi12 && slice(insn, 19, 16) == 0xF) {
|
||||
DEBUG(errs() << "Rn == '1111': PLDWi12 morphed to PLDi12\n");
|
||||
MI.setOpcode(ARM::PLDi12);
|
||||
}
|
||||
|
||||
// -0 is represented specially. All other values are as normal.
|
||||
int Offset = Negative ? -1 * Imm12 : Imm12;
|
||||
if (Imm12 == 0 && Negative)
|
||||
Imm12 = INT32_MIN;
|
||||
MI.addOperand(MCOperand::CreateImm(Imm12));
|
||||
Offset = INT32_MIN;
|
||||
|
||||
MI.addOperand(MCOperand::CreateImm(Offset));
|
||||
NumOpsAdded = 2;
|
||||
} else {
|
||||
MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, ARM::GPRRegClassID,
|
||||
|
@ -1799,8 +1799,12 @@ static bool DisassembleThumb2PreLoad(MCInst &MI, unsigned Opcode, uint32_t insn,
|
||||
// A8.6.117 Encoding T2: add = FALSE
|
||||
unsigned Imm8 = getImm8(insn);
|
||||
Offset = -1 * Imm8;
|
||||
} else // The i12 forms. See, for example, A8.6.117 Encoding T1.
|
||||
} else {
|
||||
// The i12 forms. See, for example, A8.6.117 Encoding T1.
|
||||
// Note that currently t2PLDi12 also handles the previously named t2PLDpci
|
||||
// opcode, that's why we use decodeImm12(insn) which returns +/- imm12.
|
||||
Offset = decodeImm12(insn);
|
||||
}
|
||||
MI.addOperand(MCOperand::CreateImm(Offset));
|
||||
}
|
||||
++OpIdx;
|
||||
|
@ -190,3 +190,12 @@
|
||||
|
||||
# CHECK: umull r1, r2, r3, r4
|
||||
0x93 0x14 0x82 0xe0
|
||||
|
||||
# CHECK: pld [pc, #-0]
|
||||
0x00 0xf0 0x1f 0xf5
|
||||
|
||||
# CHECK: pli [pc, #-0]
|
||||
0x00 0xf0 0x5f 0xf4
|
||||
|
||||
# CHECK: pli [r3, r1, lsl #2]
|
||||
0x01 0xf1 0xd3 0xf6
|
||||
|
Loading…
Reference in New Issue
Block a user