ARM IAS: support emitting constant values in target expressions

A 32-bit immediate value can be formed from a constant expression and loaded
into a register.  Add support to emit this into an object file.  Because this
value is a constant, a relocation must *not* be produced for it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199023 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Saleem Abdulrasool
2014-01-11 23:03:48 +00:00
parent ccdb9c9483
commit 8009754517
2 changed files with 51 additions and 0 deletions

View File

@@ -26,6 +26,7 @@
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
@@ -912,6 +913,20 @@ ARMMCCodeEmitter::getHiLo16ImmOpValue(const MCInst &MI, unsigned OpIdx,
const ARMMCExpr *ARM16Expr = cast<ARMMCExpr>(E);
E = ARM16Expr->getSubExpr();
if (const MCConstantExpr *MCE = dyn_cast<MCConstantExpr>(E)) {
const int64_t Value = MCE->getValue();
if (Value > UINT32_MAX)
report_fatal_error("constant value truncated (limited to 32-bit)");
switch (ARM16Expr->getKind()) {
case ARMMCExpr::VK_ARM_HI16:
return (int32_t(Value) & 0xffff0000) >> 16;
case ARMMCExpr::VK_ARM_LO16:
return (int32_t(Value) & 0x0000ffff);
default: llvm_unreachable("Unsupported ARMFixup");
}
}
switch (ARM16Expr->getKind()) {
default: llvm_unreachable("Unsupported ARMFixup");
case ARMMCExpr::VK_ARM_HI16: