summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2014-03-13 07:02:41 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2014-03-13 07:02:41 +0000
commit0ed4ef85a85095f3f20f06db6c5eaec12eeb97e7 (patch)
treef7cea16ca8230dbce965bc44a8ca10901dcfcc3e /lib
parentb0f12dfab6b938351d373ca26c3ee56fd91fad8b (diff)
downloadllvm-0ed4ef85a85095f3f20f06db6c5eaec12eeb97e7.tar.gz
llvm-0ed4ef85a85095f3f20f06db6c5eaec12eeb97e7.tar.bz2
llvm-0ed4ef85a85095f3f20f06db6c5eaec12eeb97e7.tar.xz
ARM: support emission of complex SO expressions
Support to the IAS was added to actually parse and handle the complex SO expressions. However, the object file lowering was not updated to compensate for the fact that the shift operand may be an absolute expression. When trying to assemble to an object file, the lowering would fail while succeeding when emitting purely assembly. Add an appropriate test. The test case is inspired by the test case provided by Jiangning Liu who also brought the issue to light. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203762 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp b/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp
index 3b2ca73aec..716b22e3b3 100644
--- a/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp
+++ b/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp
@@ -271,8 +271,19 @@ public:
unsigned getSOImmOpValue(const MCInst &MI, unsigned Op,
SmallVectorImpl<MCFixup> &Fixups,
const MCSubtargetInfo &STI) const {
- unsigned SoImm = MI.getOperand(Op).getImm();
- int SoImmVal = ARM_AM::getSOImmVal(SoImm);
+ int SoImmVal = -1;
+
+ const MCOperand &MO = MI.getOperand(Op);
+ if (MO.isImm()) {
+ SoImmVal = ARM_AM::getSOImmVal(MO.getImm());
+ } else if (MO.isExpr()) {
+ int64_t Value;
+ bool Invalid = MO.getExpr()->EvaluateAsAbsolute(Value);
+ assert(!Invalid && "non-constant expression is not a valid SOImm operand");
+ assert((Value >= INT32_MIN && Value <= INT32_MAX) &&
+ "expression must be representable in 32 bits");
+ SoImmVal = Value;
+ }
assert(SoImmVal != -1 && "Not a valid so_imm value!");
// Encode rotate_imm.