ARM: fix thumb literal loads decoding

This fixes two previous issues:
- Negative offsets were not correctly disassembled
- The decoded opcodes were not the right one

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184180 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Amaury de la Vieuville
2013-06-18 08:03:06 +00:00
parent cea0032f73
commit ce046b98ed
4 changed files with 293 additions and 31 deletions
+21 -7
View File
@@ -315,15 +315,29 @@ void ARMInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
void ARMInstPrinter::printThumbLdrLabelOperand(const MCInst *MI, unsigned OpNum,
raw_ostream &O) {
const MCOperand &MO1 = MI->getOperand(OpNum);
if (MO1.isExpr())
if (MO1.isExpr()) {
O << *MO1.getExpr();
else if (MO1.isImm()) {
O << markup("<mem:") << "[pc, "
<< markup("<imm:") << "#" << formatImm(MO1.getImm())
<< markup(">]>", "]");
return;
}
else
llvm_unreachable("Unknown LDR label operand?");
O << markup("<mem:") << "[pc, ";
int32_t OffImm = (int32_t)MO1.getImm();
bool isSub = OffImm < 0;
// Special value for #-0. All others are normal.
if (OffImm == INT32_MIN)
OffImm = 0;
if (isSub) {
O << markup("<imm:")
<< "#-" << formatImm(-OffImm)
<< markup(">");
} else {
O << markup("<imm:")
<< "#" << formatImm(OffImm)
<< markup(">");
}
O << "]" << markup(">");
}
// so_reg is a 4-operand unit corresponding to register forms of the A5.1