summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2014-01-08 03:28:14 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2014-01-08 03:28:14 +0000
commitd88affb53c86405230402cf86c0724e4a1ac2579 (patch)
treeb52d7037908b16b6719a4a88a6eddb0afc381d29 /llvm/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp
parentbe981ebcf07fee5a14c6a298d83bed5a473db7cc (diff)
downloadbcm5719-llvm-d88affb53c86405230402cf86c0724e4a1ac2579.tar.gz
bcm5719-llvm-d88affb53c86405230402cf86c0724e4a1ac2579.zip
ARM IAS: properly handle expression operands
Operands which involved label arithemetic would previously fail to parse. This corrects that by adding the additional case for the shift operand validation. llvm-svn: 198735
Diffstat (limited to 'llvm/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp')
-rw-r--r--llvm/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp33
1 files changed, 23 insertions, 10 deletions
diff --git a/llvm/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp b/llvm/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp
index f89702853d4..da3fe016d0f 100644
--- a/llvm/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp
+++ b/llvm/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp
@@ -307,17 +307,30 @@ void ARMInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
<< markup(">");
} else {
assert(Op.isExpr() && "unknown operand kind in printOperand");
- // If a symbolic branch target was added as a constant expression then print
- // that address in hex. And only print 32 unsigned bits for the address.
- const MCConstantExpr *BranchTarget = dyn_cast<MCConstantExpr>(Op.getExpr());
- int64_t Address;
- if (BranchTarget && BranchTarget->EvaluateAsAbsolute(Address)) {
- O << "0x";
- O.write_hex((uint32_t)Address);
+ const MCExpr *Expr = Op.getExpr();
+ switch (Expr->getKind()) {
+ case MCExpr::Binary:
+ O << '#' << *Expr;
+ break;
+ case MCExpr::Constant: {
+ // If a symbolic branch target was added as a constant expression then
+ // print that address in hex. And only print 32 unsigned bits for the
+ // address.
+ const MCConstantExpr *Constant = cast<MCConstantExpr>(Expr);
+ int64_t TargetAddress;
+ if (!Constant->EvaluateAsAbsolute(TargetAddress)) {
+ O << '#' << *Expr;
+ } else {
+ O << "0x";
+ O.write_hex(static_cast<uint32_t>(TargetAddress));
+ }
+ break;
}
- else {
- // Otherwise, just print the expression.
- O << *Op.getExpr();
+ default:
+ // FIXME: Should we always treat this as if it is a constant literal and
+ // prefix it with '#'?
+ O << *Expr;
+ break;
}
}
}
OpenPOWER on IntegriCloud