mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-21 02:24:22 +00:00
MC: Update MCAssembler to use MCSymbol, NFC
Use `MCSymbol` over `MCSymbolData` where both are needed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237803 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -120,12 +120,13 @@ uint64_t MCAsmLayout::getFragmentOffset(const MCFragment *F) const {
|
||||
}
|
||||
|
||||
// Simple getSymbolOffset helper for the non-varibale case.
|
||||
static bool getLabelOffset(const MCAsmLayout &Layout, const MCSymbolData &SD,
|
||||
static bool getLabelOffset(const MCAsmLayout &Layout, const MCSymbol &S,
|
||||
bool ReportError, uint64_t &Val) {
|
||||
const MCSymbolData &SD = S.getData();
|
||||
if (!SD.getFragment()) {
|
||||
if (ReportError)
|
||||
report_fatal_error("unable to evaluate offset to undefined symbol '" +
|
||||
SD.getSymbol().getName() + "'");
|
||||
S.getName() + "'");
|
||||
return false;
|
||||
}
|
||||
Val = Layout.getFragmentOffset(SD.getFragment()) + SD.getOffset();
|
||||
@ -135,7 +136,7 @@ static bool getLabelOffset(const MCAsmLayout &Layout, const MCSymbolData &SD,
|
||||
static bool getSymbolOffsetImpl(const MCAsmLayout &Layout, const MCSymbol &S,
|
||||
bool ReportError, uint64_t &Val) {
|
||||
if (!S.isVariable())
|
||||
return getLabelOffset(Layout, S.getData(), ReportError, Val);
|
||||
return getLabelOffset(Layout, S, ReportError, Val);
|
||||
|
||||
// If SD is a variable, evaluate it.
|
||||
MCValue Target;
|
||||
@ -145,13 +146,10 @@ static bool getSymbolOffsetImpl(const MCAsmLayout &Layout, const MCSymbol &S,
|
||||
|
||||
uint64_t Offset = Target.getConstant();
|
||||
|
||||
const MCAssembler &Asm = Layout.getAssembler();
|
||||
|
||||
const MCSymbolRefExpr *A = Target.getSymA();
|
||||
if (A) {
|
||||
uint64_t ValA;
|
||||
if (!getLabelOffset(Layout, Asm.getSymbolData(A->getSymbol()), ReportError,
|
||||
ValA))
|
||||
if (!getLabelOffset(Layout, A->getSymbol(), ReportError, ValA))
|
||||
return false;
|
||||
Offset += ValA;
|
||||
}
|
||||
@ -159,8 +157,7 @@ static bool getSymbolOffsetImpl(const MCAsmLayout &Layout, const MCSymbol &S,
|
||||
const MCSymbolRefExpr *B = Target.getSymB();
|
||||
if (B) {
|
||||
uint64_t ValB;
|
||||
if (!getLabelOffset(Layout, Asm.getSymbolData(B->getSymbol()), ReportError,
|
||||
ValB))
|
||||
if (!getLabelOffset(Layout, B->getSymbol(), ReportError, ValB))
|
||||
return false;
|
||||
Offset -= ValB;
|
||||
}
|
||||
@ -457,23 +454,23 @@ bool MCAssembler::isSymbolLinkerVisible(const MCSymbol &Symbol) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
const MCSymbol *MCAssembler::getAtom(const MCSymbolData *SD) const {
|
||||
const MCSymbol *MCAssembler::getAtom(const MCSymbol &S) const {
|
||||
// Linker visible symbols define atoms.
|
||||
if (isSymbolLinkerVisible(SD->getSymbol()))
|
||||
return &SD->getSymbol();
|
||||
if (isSymbolLinkerVisible(S))
|
||||
return &S;
|
||||
|
||||
// Absolute and undefined symbols have no defining atom.
|
||||
if (!SD->getFragment())
|
||||
if (!S.getData().getFragment())
|
||||
return nullptr;
|
||||
|
||||
// Non-linker visible symbols in sections which can't be atomized have no
|
||||
// defining atom.
|
||||
if (!getContext().getAsmInfo()->isSectionAtomizableBySymbols(
|
||||
SD->getFragment()->getParent()->getSection()))
|
||||
S.getData().getFragment()->getParent()->getSection()))
|
||||
return nullptr;
|
||||
|
||||
// Otherwise, return the atom for the containing fragment.
|
||||
return SD->getFragment()->getAtom();
|
||||
return S.getData().getFragment()->getAtom();
|
||||
}
|
||||
|
||||
bool MCAssembler::evaluateFixup(const MCAsmLayout &Layout,
|
||||
|
Reference in New Issue
Block a user