mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-01 07:30:31 +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:
parent
10054fb7b0
commit
20cf3f41e7
@ -834,7 +834,7 @@ public:
|
|||||||
|
|
||||||
/// Find the symbol which defines the atom containing the given symbol, or
|
/// Find the symbol which defines the atom containing the given symbol, or
|
||||||
/// null if there is no such symbol.
|
/// null if there is no such symbol.
|
||||||
const MCSymbol *getAtom(const MCSymbolData *Symbol) const;
|
const MCSymbol *getAtom(const MCSymbol &S) const;
|
||||||
|
|
||||||
/// Check whether a particular symbol is visible to the linker and is required
|
/// Check whether a particular symbol is visible to the linker and is required
|
||||||
/// in the symbol table, or whether it can be discarded by the assembler. This
|
/// in the symbol table, or whether it can be discarded by the assembler. This
|
||||||
|
@ -120,12 +120,13 @@ uint64_t MCAsmLayout::getFragmentOffset(const MCFragment *F) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Simple getSymbolOffset helper for the non-varibale case.
|
// 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) {
|
bool ReportError, uint64_t &Val) {
|
||||||
|
const MCSymbolData &SD = S.getData();
|
||||||
if (!SD.getFragment()) {
|
if (!SD.getFragment()) {
|
||||||
if (ReportError)
|
if (ReportError)
|
||||||
report_fatal_error("unable to evaluate offset to undefined symbol '" +
|
report_fatal_error("unable to evaluate offset to undefined symbol '" +
|
||||||
SD.getSymbol().getName() + "'");
|
S.getName() + "'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Val = Layout.getFragmentOffset(SD.getFragment()) + SD.getOffset();
|
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,
|
static bool getSymbolOffsetImpl(const MCAsmLayout &Layout, const MCSymbol &S,
|
||||||
bool ReportError, uint64_t &Val) {
|
bool ReportError, uint64_t &Val) {
|
||||||
if (!S.isVariable())
|
if (!S.isVariable())
|
||||||
return getLabelOffset(Layout, S.getData(), ReportError, Val);
|
return getLabelOffset(Layout, S, ReportError, Val);
|
||||||
|
|
||||||
// If SD is a variable, evaluate it.
|
// If SD is a variable, evaluate it.
|
||||||
MCValue Target;
|
MCValue Target;
|
||||||
@ -145,13 +146,10 @@ static bool getSymbolOffsetImpl(const MCAsmLayout &Layout, const MCSymbol &S,
|
|||||||
|
|
||||||
uint64_t Offset = Target.getConstant();
|
uint64_t Offset = Target.getConstant();
|
||||||
|
|
||||||
const MCAssembler &Asm = Layout.getAssembler();
|
|
||||||
|
|
||||||
const MCSymbolRefExpr *A = Target.getSymA();
|
const MCSymbolRefExpr *A = Target.getSymA();
|
||||||
if (A) {
|
if (A) {
|
||||||
uint64_t ValA;
|
uint64_t ValA;
|
||||||
if (!getLabelOffset(Layout, Asm.getSymbolData(A->getSymbol()), ReportError,
|
if (!getLabelOffset(Layout, A->getSymbol(), ReportError, ValA))
|
||||||
ValA))
|
|
||||||
return false;
|
return false;
|
||||||
Offset += ValA;
|
Offset += ValA;
|
||||||
}
|
}
|
||||||
@ -159,8 +157,7 @@ static bool getSymbolOffsetImpl(const MCAsmLayout &Layout, const MCSymbol &S,
|
|||||||
const MCSymbolRefExpr *B = Target.getSymB();
|
const MCSymbolRefExpr *B = Target.getSymB();
|
||||||
if (B) {
|
if (B) {
|
||||||
uint64_t ValB;
|
uint64_t ValB;
|
||||||
if (!getLabelOffset(Layout, Asm.getSymbolData(B->getSymbol()), ReportError,
|
if (!getLabelOffset(Layout, B->getSymbol(), ReportError, ValB))
|
||||||
ValB))
|
|
||||||
return false;
|
return false;
|
||||||
Offset -= ValB;
|
Offset -= ValB;
|
||||||
}
|
}
|
||||||
@ -457,23 +454,23 @@ bool MCAssembler::isSymbolLinkerVisible(const MCSymbol &Symbol) const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MCSymbol *MCAssembler::getAtom(const MCSymbolData *SD) const {
|
const MCSymbol *MCAssembler::getAtom(const MCSymbol &S) const {
|
||||||
// Linker visible symbols define atoms.
|
// Linker visible symbols define atoms.
|
||||||
if (isSymbolLinkerVisible(SD->getSymbol()))
|
if (isSymbolLinkerVisible(S))
|
||||||
return &SD->getSymbol();
|
return &S;
|
||||||
|
|
||||||
// Absolute and undefined symbols have no defining atom.
|
// Absolute and undefined symbols have no defining atom.
|
||||||
if (!SD->getFragment())
|
if (!S.getData().getFragment())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
// Non-linker visible symbols in sections which can't be atomized have no
|
// Non-linker visible symbols in sections which can't be atomized have no
|
||||||
// defining atom.
|
// defining atom.
|
||||||
if (!getContext().getAsmInfo()->isSectionAtomizableBySymbols(
|
if (!getContext().getAsmInfo()->isSectionAtomizableBySymbols(
|
||||||
SD->getFragment()->getParent()->getSection()))
|
S.getData().getFragment()->getParent()->getSection()))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
// Otherwise, return the atom for the containing fragment.
|
// Otherwise, return the atom for the containing fragment.
|
||||||
return SD->getFragment()->getAtom();
|
return S.getData().getFragment()->getAtom();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MCAssembler::evaluateFixup(const MCAsmLayout &Layout,
|
bool MCAssembler::evaluateFixup(const MCAsmLayout &Layout,
|
||||||
|
@ -210,11 +210,11 @@ void AArch64MachObjectWriter::RecordRelocation(
|
|||||||
} else if (Target.getSymB()) { // A - B + constant
|
} else if (Target.getSymB()) { // A - B + constant
|
||||||
const MCSymbol *A = &Target.getSymA()->getSymbol();
|
const MCSymbol *A = &Target.getSymA()->getSymbol();
|
||||||
const MCSymbolData &A_SD = Asm.getSymbolData(*A);
|
const MCSymbolData &A_SD = Asm.getSymbolData(*A);
|
||||||
const MCSymbol *A_Base = Asm.getAtom(&A_SD);
|
const MCSymbol *A_Base = Asm.getAtom(*A);
|
||||||
|
|
||||||
const MCSymbol *B = &Target.getSymB()->getSymbol();
|
const MCSymbol *B = &Target.getSymB()->getSymbol();
|
||||||
const MCSymbolData &B_SD = Asm.getSymbolData(*B);
|
const MCSymbolData &B_SD = Asm.getSymbolData(*B);
|
||||||
const MCSymbol *B_Base = Asm.getAtom(&B_SD);
|
const MCSymbol *B_Base = Asm.getAtom(*B);
|
||||||
|
|
||||||
// Check for "_foo@got - .", which comes through here as:
|
// Check for "_foo@got - .", which comes through here as:
|
||||||
// Ltmp0:
|
// Ltmp0:
|
||||||
@ -296,7 +296,7 @@ void AArch64MachObjectWriter::RecordRelocation(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const MCSymbolData &SD = Asm.getSymbolData(*Symbol);
|
const MCSymbolData &SD = Asm.getSymbolData(*Symbol);
|
||||||
const MCSymbol *Base = Asm.getAtom(&SD);
|
const MCSymbol *Base = Asm.getAtom(*Symbol);
|
||||||
|
|
||||||
// If the symbol is a variable and we weren't able to get a Base for it
|
// If the symbol is a variable and we weren't able to get a Base for it
|
||||||
// (i.e., it's not in the symbol table associated with a section) resolve
|
// (i.e., it's not in the symbol table associated with a section) resolve
|
||||||
|
@ -143,13 +143,13 @@ void X86MachObjectWriter::RecordX86_64Relocation(
|
|||||||
if (A->isTemporary())
|
if (A->isTemporary())
|
||||||
A = &Writer->findAliasedSymbol(*A);
|
A = &Writer->findAliasedSymbol(*A);
|
||||||
const MCSymbolData &A_SD = Asm.getSymbolData(*A);
|
const MCSymbolData &A_SD = Asm.getSymbolData(*A);
|
||||||
const MCSymbol *A_Base = Asm.getAtom(&A_SD);
|
const MCSymbol *A_Base = Asm.getAtom(*A);
|
||||||
|
|
||||||
const MCSymbol *B = &Target.getSymB()->getSymbol();
|
const MCSymbol *B = &Target.getSymB()->getSymbol();
|
||||||
if (B->isTemporary())
|
if (B->isTemporary())
|
||||||
B = &Writer->findAliasedSymbol(*B);
|
B = &Writer->findAliasedSymbol(*B);
|
||||||
const MCSymbolData &B_SD = Asm.getSymbolData(*B);
|
const MCSymbolData &B_SD = Asm.getSymbolData(*B);
|
||||||
const MCSymbol *B_Base = Asm.getAtom(&B_SD);
|
const MCSymbol *B_Base = Asm.getAtom(*B);
|
||||||
|
|
||||||
// Neither symbol can be modified.
|
// Neither symbol can be modified.
|
||||||
if (Target.getSymA()->getKind() != MCSymbolRefExpr::VK_None ||
|
if (Target.getSymA()->getKind() != MCSymbolRefExpr::VK_None ||
|
||||||
@ -212,7 +212,7 @@ void X86MachObjectWriter::RecordX86_64Relocation(
|
|||||||
Asm.addLocalUsedInReloc(*Symbol);
|
Asm.addLocalUsedInReloc(*Symbol);
|
||||||
}
|
}
|
||||||
const MCSymbolData &SD = Asm.getSymbolData(*Symbol);
|
const MCSymbolData &SD = Asm.getSymbolData(*Symbol);
|
||||||
RelSymbol = Asm.getAtom(&SD);
|
RelSymbol = Asm.getAtom(*Symbol);
|
||||||
|
|
||||||
// Relocations inside debug sections always use local relocations when
|
// Relocations inside debug sections always use local relocations when
|
||||||
// possible. This seems to be done because the debugger doesn't fully
|
// possible. This seems to be done because the debugger doesn't fully
|
||||||
|
Loading…
Reference in New Issue
Block a user