mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-27 14:34:58 +00:00
MCCodeEmitter: Add target independent fixup flag for is-pc-relative.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98954 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
cf871e5abf
commit
b36052f0e4
@ -22,6 +22,12 @@ template<typename T> class SmallVectorImpl;
|
|||||||
|
|
||||||
/// MCFixupKindInfo - Target independent information on a fixup kind.
|
/// MCFixupKindInfo - Target independent information on a fixup kind.
|
||||||
struct MCFixupKindInfo {
|
struct MCFixupKindInfo {
|
||||||
|
enum FixupKindFlags {
|
||||||
|
/// Is this fixup kind PCrelative. This is used by the assembler backend to
|
||||||
|
/// evaluate fixup values in a target independent manner when possible.
|
||||||
|
FKF_IsPCRel = (1 << 0)
|
||||||
|
};
|
||||||
|
|
||||||
/// A target specific name for the fixup kind. The names will be unique for
|
/// A target specific name for the fixup kind. The names will be unique for
|
||||||
/// distinct kinds on any given target.
|
/// distinct kinds on any given target.
|
||||||
const char *Name;
|
const char *Name;
|
||||||
@ -36,6 +42,9 @@ struct MCFixupKindInfo {
|
|||||||
/// The number of bits written by this fixup. The bits are assumed to be
|
/// The number of bits written by this fixup. The bits are assumed to be
|
||||||
/// contiguous.
|
/// contiguous.
|
||||||
unsigned TargetSize;
|
unsigned TargetSize;
|
||||||
|
|
||||||
|
/// Flags describing additional information on this fixup kind.
|
||||||
|
unsigned Flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// MCCodeEmitter - Generic instruction encoding interface.
|
/// MCCodeEmitter - Generic instruction encoding interface.
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#define DEBUG_TYPE "assembler"
|
#define DEBUG_TYPE "assembler"
|
||||||
#include "llvm/MC/MCAssembler.h"
|
#include "llvm/MC/MCAssembler.h"
|
||||||
#include "llvm/MC/MCAsmLayout.h"
|
#include "llvm/MC/MCAsmLayout.h"
|
||||||
|
#include "llvm/MC/MCCodeEmitter.h"
|
||||||
#include "llvm/MC/MCExpr.h"
|
#include "llvm/MC/MCExpr.h"
|
||||||
#include "llvm/MC/MCObjectWriter.h"
|
#include "llvm/MC/MCObjectWriter.h"
|
||||||
#include "llvm/MC/MCSymbol.h"
|
#include "llvm/MC/MCSymbol.h"
|
||||||
@ -37,17 +38,6 @@ STATISTIC(EmittedFragments, "Number of emitted assembler fragments");
|
|||||||
// object file, which may truncate it. We should detect that truncation where
|
// object file, which may truncate it. We should detect that truncation where
|
||||||
// invalid and report errors back.
|
// invalid and report errors back.
|
||||||
|
|
||||||
static bool isFixupKindPCRel(unsigned Kind) {
|
|
||||||
switch (Kind) {
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
case X86::reloc_pcrel_1byte:
|
|
||||||
case X86::reloc_pcrel_4byte:
|
|
||||||
case X86::reloc_riprel_4byte:
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* *** */
|
/* *** */
|
||||||
|
|
||||||
MCFragment::MCFragment() : Kind(FragmentType(~0)) {
|
MCFragment::MCFragment() : Kind(FragmentType(~0)) {
|
||||||
@ -258,7 +248,9 @@ bool MCAssembler::EvaluateFixup(const MCAsmLayout &Layout, MCAsmFixup &Fixup,
|
|||||||
|
|
||||||
Value = Target.getConstant();
|
Value = Target.getConstant();
|
||||||
|
|
||||||
bool IsResolved = true, IsPCRel = isFixupKindPCRel(Fixup.Kind);
|
bool IsPCRel =
|
||||||
|
Emitter.getFixupKindInfo(Fixup.Kind).Flags & MCFixupKindInfo::FKF_IsPCRel;
|
||||||
|
bool IsResolved = true;
|
||||||
if (const MCSymbolRefExpr *A = Target.getSymA()) {
|
if (const MCSymbolRefExpr *A = Target.getSymA()) {
|
||||||
if (A->getSymbol().isDefined())
|
if (A->getSymbol().isDefined())
|
||||||
Value += getSymbolData(A->getSymbol()).getAddress();
|
Value += getSymbolData(A->getSymbol()).getAddress();
|
||||||
|
@ -19,10 +19,10 @@ MCCodeEmitter::~MCCodeEmitter() {
|
|||||||
|
|
||||||
const MCFixupKindInfo &MCCodeEmitter::getFixupKindInfo(MCFixupKind Kind) const {
|
const MCFixupKindInfo &MCCodeEmitter::getFixupKindInfo(MCFixupKind Kind) const {
|
||||||
static const MCFixupKindInfo Builtins[] = {
|
static const MCFixupKindInfo Builtins[] = {
|
||||||
{ "FK_Data_1", 0, 8 },
|
{ "FK_Data_1", 0, 8, 0 },
|
||||||
{ "FK_Data_2", 0, 16 },
|
{ "FK_Data_2", 0, 16, 0 },
|
||||||
{ "FK_Data_4", 0, 32 },
|
{ "FK_Data_4", 0, 32, 0 },
|
||||||
{ "FK_Data_8", 0, 64 }
|
{ "FK_Data_8", 0, 64, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
assert(Kind <= 3 && "Unknown fixup kind");
|
assert(Kind <= 3 && "Unknown fixup kind");
|
||||||
|
@ -43,10 +43,10 @@ public:
|
|||||||
|
|
||||||
const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const {
|
const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const {
|
||||||
const static MCFixupKindInfo Infos[] = {
|
const static MCFixupKindInfo Infos[] = {
|
||||||
{ "reloc_pcrel_4byte", 0, 4 * 8 },
|
{ "reloc_pcrel_4byte", 0, 4 * 8, MCFixupKindInfo::FKF_IsPCRel },
|
||||||
{ "reloc_pcrel_1byte", 0, 1 * 8 },
|
{ "reloc_pcrel_1byte", 0, 1 * 8, MCFixupKindInfo::FKF_IsPCRel },
|
||||||
{ "reloc_riprel_4byte", 0, 4 * 8 },
|
{ "reloc_riprel_4byte", 0, 4 * 8, MCFixupKindInfo::FKF_IsPCRel },
|
||||||
{ "reloc_riprel_4byte_movq_load", 0, 4 * 8 }
|
{ "reloc_riprel_4byte_movq_load", 0, 4 * 8, MCFixupKindInfo::FKF_IsPCRel }
|
||||||
};
|
};
|
||||||
|
|
||||||
if (Kind < FirstTargetFixupKind)
|
if (Kind < FirstTargetFixupKind)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user