mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-05 13:26:55 +00:00
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:
@@ -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:
|
||||
|
Reference in New Issue
Block a user