diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2014-03-13 07:02:41 +0000 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2014-03-13 07:02:41 +0000 |
commit | dadf94ce848f5009db77b4dae4a9f58897017f76 (patch) | |
tree | 276a03dd6b98e682e818f51623448736c7bccd64 /llvm/lib | |
parent | 9b7c0af2926d45c1c4ea178be784e31a853a0ec9 (diff) | |
download | bcm5719-llvm-dadf94ce848f5009db77b4dae4a9f58897017f76.tar.gz bcm5719-llvm-dadf94ce848f5009db77b4dae4a9f58897017f76.zip |
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.
llvm-svn: 203762
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp index 3b2ca73aecd..716b22e3b37 100644 --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp +++ b/llvm/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. |