summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/ARM/InstPrinter
diff options
context:
space:
mode:
authorKevin Enderby <enderby@apple.com>2011-10-04 22:44:48 +0000
committerKevin Enderby <enderby@apple.com>2011-10-04 22:44:48 +0000
commit5dcda643383fe718f7dc91be090f76269559fe86 (patch)
tree9a20955feeca30e643f005724408e737bf9754e9 /llvm/lib/Target/ARM/InstPrinter
parent7f99513e8f9d1899474176d109fa4f586a1462d3 (diff)
downloadbcm5719-llvm-5dcda643383fe718f7dc91be090f76269559fe86.tar.gz
bcm5719-llvm-5dcda643383fe718f7dc91be090f76269559fe86.zip
Adding back support for printing operands symbolically to ARM's new disassembler
using llvm's public 'C' disassembler API now including annotations. Hooked this up to Darwin's otool(1) so it can again print things like branch targets for example this: blx _puts instead of this: blx #-36 and includes support for annotations for branches to symbol stubs like: bl 0x40 @ symbol stub for: _puts and annotations for pc relative loads like this: ldr r3, #8 @ literal pool for: Hello, world! Also again can print the expression encoded in the Mach-O relocation entries for things like this: movt r0, :upper16:((_foo-_bar)+1234) llvm-svn: 141129
Diffstat (limited to 'llvm/lib/Target/ARM/InstPrinter')
-rw-r--r--llvm/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp b/llvm/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp
index f3e29f80b8f..e70f8460d6f 100644
--- a/llvm/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp
+++ b/llvm/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp
@@ -207,7 +207,18 @@ void ARMInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
O << '#' << Op.getImm();
} else {
assert(Op.isExpr() && "unknown operand kind in printOperand");
- O << *Op.getExpr();
+ // If a symbolic branch target was added as a constant expression then print
+ // that address in hex.
+ const MCConstantExpr *BranchTarget = dyn_cast<MCConstantExpr>(Op.getExpr());
+ int64_t Address;
+ if (BranchTarget && BranchTarget->EvaluateAsAbsolute(Address)) {
+ O << "0x";
+ O.write_hex(Address);
+ }
+ else {
+ // Otherwise, just print the expression.
+ O << *Op.getExpr();
+ }
}
}
OpenPOWER on IntegriCloud