mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Rename getOrCreateSymbolData to registerSymbol and return void.
Another step in merging MCSymbol and MCSymbolData. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238607 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9589ff8949
commit
f00654bc0f
@ -884,15 +884,13 @@ public:
|
||||
|
||||
bool hasSymbolData(const MCSymbol &Symbol) const { return Symbol.hasData(); }
|
||||
|
||||
MCSymbolData &getOrCreateSymbolData(const MCSymbol &Symbol,
|
||||
bool *Created = nullptr) {
|
||||
void registerSymbol(const MCSymbol &Symbol, bool *Created = nullptr) {
|
||||
if (Created)
|
||||
*Created = !hasSymbolData(Symbol);
|
||||
if (!hasSymbolData(Symbol)) {
|
||||
Symbol.initializeData();
|
||||
Symbols.push_back(&Symbol);
|
||||
}
|
||||
return Symbol.getData();
|
||||
}
|
||||
|
||||
ArrayRef<std::string> getFileNames() { return FileNames; }
|
||||
|
@ -56,8 +56,8 @@ public:
|
||||
/// Object streamers require the integrated assembler.
|
||||
bool isIntegratedAssemblerRequired() const override { return true; }
|
||||
|
||||
MCSymbolData &getOrCreateSymbolData(const MCSymbol *Symbol) {
|
||||
return getAssembler().getOrCreateSymbolData(*Symbol);
|
||||
void getOrCreateSymbolData(const MCSymbol *Symbol) {
|
||||
getAssembler().registerSymbol(*Symbol);
|
||||
}
|
||||
void EmitFrames(MCAsmBackend *MAB);
|
||||
void EmitCFISections(bool EH, bool Debug) override;
|
||||
|
@ -1256,7 +1256,7 @@ void ELFObjectWriter::WriteObject(MCAssembler &Asm,
|
||||
MCSectionELF *RelSection = createRelocationSection(Ctx, Section);
|
||||
|
||||
if (SignatureSymbol) {
|
||||
Asm.getOrCreateSymbolData(*SignatureSymbol);
|
||||
Asm.registerSymbol(*SignatureSymbol);
|
||||
unsigned &GroupIdx = RevGroupMap[SignatureSymbol];
|
||||
if (!GroupIdx) {
|
||||
MCSectionELF *Group = Ctx.createELFGroupSection(SignatureSymbol);
|
||||
|
@ -155,7 +155,7 @@ void MCELFStreamer::ChangeSection(MCSection *Section,
|
||||
auto *SectionELF = static_cast<const MCSectionELF *>(Section);
|
||||
const MCSymbol *Grp = SectionELF->getGroup();
|
||||
if (Grp)
|
||||
Asm.getOrCreateSymbolData(*Grp);
|
||||
Asm.registerSymbol(*Grp);
|
||||
|
||||
this->MCObjectStreamer::ChangeSection(Section, Subsection);
|
||||
MCContext &Ctx = getContext();
|
||||
@ -165,13 +165,13 @@ void MCELFStreamer::ChangeSection(MCSection *Section,
|
||||
Section->setBeginSymbol(Begin);
|
||||
}
|
||||
if (Begin->isUndefined()) {
|
||||
Asm.getOrCreateSymbolData(*Begin);
|
||||
Asm.registerSymbol(*Begin);
|
||||
MCELF::SetType(*Begin, ELF::STT_SECTION);
|
||||
}
|
||||
}
|
||||
|
||||
void MCELFStreamer::EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) {
|
||||
getAssembler().getOrCreateSymbolData(*Symbol);
|
||||
getAssembler().registerSymbol(*Symbol);
|
||||
const MCExpr *Value = MCSymbolRefExpr::Create(
|
||||
Symbol, MCSymbolRefExpr::VK_WEAKREF, getContext());
|
||||
Alias->setVariableValue(Value);
|
||||
@ -211,9 +211,10 @@ bool MCELFStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
|
||||
}
|
||||
|
||||
// Adding a symbol attribute always introduces the symbol, note that an
|
||||
// important side effect of calling getOrCreateSymbolData here is to register
|
||||
// important side effect of calling registerSymbol here is to register
|
||||
// the symbol with the assembler.
|
||||
MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
|
||||
getAssembler().registerSymbol(*Symbol);
|
||||
MCSymbolData &SD = Symbol->getData();
|
||||
|
||||
// The implementation of symbol attributes is designed to match 'as', but it
|
||||
// leaves much to desired. It doesn't really make sense to arbitrarily add and
|
||||
@ -311,8 +312,9 @@ bool MCELFStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
|
||||
}
|
||||
|
||||
void MCELFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||
unsigned ByteAlignment) {
|
||||
MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
|
||||
unsigned ByteAlignment) {
|
||||
getAssembler().registerSymbol(*Symbol);
|
||||
MCSymbolData &SD = Symbol->getData();
|
||||
|
||||
if (!BindingExplicitlySet.count(Symbol)) {
|
||||
MCELF::SetBinding(*Symbol, ELF::STB_GLOBAL);
|
||||
@ -343,7 +345,8 @@ void MCELFStreamer::EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) {
|
||||
void MCELFStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||
unsigned ByteAlignment) {
|
||||
// FIXME: Should this be caught and done earlier?
|
||||
MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
|
||||
getAssembler().registerSymbol(*Symbol);
|
||||
MCSymbolData &SD = Symbol->getData();
|
||||
MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
|
||||
SD.setExternal(false);
|
||||
BindingExplicitlySet.insert(Symbol);
|
||||
@ -460,7 +463,7 @@ void MCELFStreamer::fixSymbolsInTLSFixups(const MCExpr *expr) {
|
||||
case MCSymbolRefExpr::VK_PPC_TLSLD:
|
||||
break;
|
||||
}
|
||||
getAssembler().getOrCreateSymbolData(symRef.getSymbol());
|
||||
getAssembler().registerSymbol(symRef.getSymbol());
|
||||
MCELF::SetType(symRef.getSymbol(), ELF::STT_TLS);
|
||||
break;
|
||||
}
|
||||
|
@ -172,8 +172,8 @@ void MCMachOStreamer::ChangeSection(MCSection *Section,
|
||||
|
||||
void MCMachOStreamer::EmitEHSymAttributes(const MCSymbol *Symbol,
|
||||
MCSymbol *EHSymbol) {
|
||||
MCSymbolData &SD =
|
||||
getAssembler().getOrCreateSymbolData(*Symbol);
|
||||
getAssembler().registerSymbol(*Symbol);
|
||||
MCSymbolData &SD = Symbol->getData();
|
||||
if (SD.isExternal())
|
||||
EmitSymbolAttribute(EHSymbol, MCSA_Global);
|
||||
if (Symbol->getFlags() & SF_WeakDefinition)
|
||||
@ -293,9 +293,10 @@ bool MCMachOStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
|
||||
}
|
||||
|
||||
// Adding a symbol attribute always introduces the symbol, note that an
|
||||
// important side effect of calling getOrCreateSymbolData here is to register
|
||||
// important side effect of calling registerSymbol here is to register
|
||||
// the symbol with the assembler.
|
||||
MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
|
||||
getAssembler().registerSymbol(*Symbol);
|
||||
MCSymbolData &SD = Symbol->getData();
|
||||
|
||||
// The implementation of symbol attributes is designed to match 'as', but it
|
||||
// leaves much to desired. It doesn't really make sense to arbitrarily add and
|
||||
@ -378,7 +379,7 @@ void MCMachOStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
|
||||
// Encode the 'desc' value into the lowest implementation defined bits.
|
||||
assert(DescValue == (DescValue & SF_DescFlagsMask) &&
|
||||
"Invalid .desc value!");
|
||||
getAssembler().getOrCreateSymbolData(*Symbol);
|
||||
getAssembler().registerSymbol(*Symbol);
|
||||
Symbol->setFlags(DescValue & SF_DescFlagsMask);
|
||||
}
|
||||
|
||||
@ -389,7 +390,8 @@ void MCMachOStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||
|
||||
AssignSection(Symbol, nullptr);
|
||||
|
||||
MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
|
||||
getAssembler().registerSymbol(*Symbol);
|
||||
MCSymbolData &SD = Symbol->getData();
|
||||
SD.setExternal(true);
|
||||
Symbol->setCommon(Size, ByteAlignment);
|
||||
}
|
||||
@ -414,7 +416,8 @@ void MCMachOStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol,
|
||||
|
||||
assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
|
||||
|
||||
MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
|
||||
getAssembler().registerSymbol(*Symbol);
|
||||
MCSymbolData &SD = Symbol->getData();
|
||||
|
||||
// Emit an align fragment if necessary.
|
||||
if (ByteAlignment != 1)
|
||||
|
@ -121,7 +121,7 @@ MCDataFragment *MCObjectStreamer::getOrCreateDataFragment() {
|
||||
}
|
||||
|
||||
void MCObjectStreamer::visitUsedSymbol(const MCSymbol &Sym) {
|
||||
Assembler->getOrCreateSymbolData(Sym);
|
||||
Assembler->registerSymbol(Sym);
|
||||
}
|
||||
|
||||
void MCObjectStreamer::EmitCFISections(bool EH, bool Debug) {
|
||||
@ -163,7 +163,8 @@ void MCObjectStreamer::EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame) {
|
||||
void MCObjectStreamer::EmitLabel(MCSymbol *Symbol) {
|
||||
MCStreamer::EmitLabel(Symbol);
|
||||
|
||||
MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
|
||||
getAssembler().registerSymbol(*Symbol);
|
||||
MCSymbolData &SD = Symbol->getData();
|
||||
assert(!SD.getFragment() && "Unexpected fragment on symbol data!");
|
||||
|
||||
// If there is a current fragment, mark the symbol as pointing into it.
|
||||
@ -226,7 +227,7 @@ bool MCObjectStreamer::changeSectionImpl(MCSection *Section,
|
||||
}
|
||||
|
||||
void MCObjectStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
|
||||
getAssembler().getOrCreateSymbolData(*Symbol);
|
||||
getAssembler().registerSymbol(*Symbol);
|
||||
MCStreamer::EmitAssignment(Symbol, Value);
|
||||
}
|
||||
|
||||
|
@ -500,7 +500,7 @@ void MachObjectWriter::BindIndirectSymbols(MCAssembler &Asm) {
|
||||
// Initialize the section indirect symbol base, if necessary.
|
||||
IndirectSymBase.insert(std::make_pair(it->Section, IndirectIndex));
|
||||
|
||||
Asm.getOrCreateSymbolData(*it->Symbol);
|
||||
Asm.registerSymbol(*it->Symbol);
|
||||
}
|
||||
|
||||
// Then lazy symbol pointers and symbol stubs.
|
||||
@ -520,7 +520,7 @@ void MachObjectWriter::BindIndirectSymbols(MCAssembler &Asm) {
|
||||
//
|
||||
// FIXME: Do not hardcode.
|
||||
bool Created;
|
||||
Asm.getOrCreateSymbolData(*it->Symbol, &Created);
|
||||
Asm.registerSymbol(*it->Symbol, &Created);
|
||||
if (Created)
|
||||
it->Symbol->setFlags(it->Symbol->getFlags() | 0x0001);
|
||||
}
|
||||
|
@ -96,7 +96,8 @@ bool MCWinCOFFStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
|
||||
Symbol->getSection().getVariant() == MCSection::SV_COFF) &&
|
||||
"Got non-COFF section in the COFF backend!");
|
||||
|
||||
MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
|
||||
getAssembler().registerSymbol(*Symbol);
|
||||
MCSymbolData &SD = Symbol->getData();
|
||||
|
||||
switch (Attribute) {
|
||||
default: return false;
|
||||
@ -136,7 +137,7 @@ void MCWinCOFFStreamer::EmitCOFFSymbolStorageClass(int StorageClass) {
|
||||
FatalError("storage class value '" + Twine(StorageClass) +
|
||||
"' out of range");
|
||||
|
||||
getAssembler().getOrCreateSymbolData(*CurSymbol);
|
||||
getAssembler().registerSymbol(*CurSymbol);
|
||||
CurSymbol->modifyFlags(StorageClass << COFF::SF_ClassShift,
|
||||
COFF::SF_ClassMask);
|
||||
}
|
||||
@ -148,7 +149,7 @@ void MCWinCOFFStreamer::EmitCOFFSymbolType(int Type) {
|
||||
if (Type & ~0xffff)
|
||||
FatalError("type value '" + Twine(Type) + "' out of range");
|
||||
|
||||
getAssembler().getOrCreateSymbolData(*CurSymbol);
|
||||
getAssembler().registerSymbol(*CurSymbol);
|
||||
CurSymbol->modifyFlags(Type << COFF::SF_TypeShift, COFF::SF_TypeMask);
|
||||
}
|
||||
|
||||
@ -195,7 +196,8 @@ void MCWinCOFFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||
|
||||
AssignSection(Symbol, nullptr);
|
||||
|
||||
MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
|
||||
getAssembler().registerSymbol(*Symbol);
|
||||
MCSymbolData &SD = Symbol->getData();
|
||||
SD.setExternal(true);
|
||||
Symbol->setCommon(Size, ByteAlignment);
|
||||
|
||||
@ -224,7 +226,8 @@ void MCWinCOFFStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||
if (Section->getAlignment() < ByteAlignment)
|
||||
Section->setAlignment(ByteAlignment);
|
||||
|
||||
MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
|
||||
getAssembler().registerSymbol(*Symbol);
|
||||
MCSymbolData &SD = Symbol->getData();
|
||||
SD.setExternal(false);
|
||||
|
||||
AssignSection(Symbol, Section);
|
||||
|
@ -164,7 +164,8 @@ private:
|
||||
MCSymbol *Symbol = getContext().getOrCreateSymbol(
|
||||
Name + "." + Twine(MappingSymbolCounter++));
|
||||
|
||||
MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
|
||||
getAssembler().registerSymbol(*Symbol);
|
||||
MCSymbolData &SD = Symbol->getData();
|
||||
MCELF::SetType(*Symbol, ELF::STT_NOTYPE);
|
||||
MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
|
||||
SD.setExternal(false);
|
||||
|
@ -566,7 +566,8 @@ private:
|
||||
getContext().getOrCreateSymbol(Name + "." +
|
||||
Twine(MappingSymbolCounter++));
|
||||
|
||||
MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
|
||||
getAssembler().registerSymbol(*Symbol);
|
||||
MCSymbolData &SD = Symbol->getData();
|
||||
MCELF::SetType(*Symbol, ELF::STT_NOTYPE);
|
||||
MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
|
||||
SD.setExternal(false);
|
||||
|
@ -689,7 +689,7 @@ void MipsTargetELFStreamer::emitDirectiveCpLoad(unsigned RegNo) {
|
||||
StringRef SymName("_gp_disp");
|
||||
MCAssembler &MCA = getStreamer().getAssembler();
|
||||
MCSymbol *GP_Disp = MCA.getContext().getOrCreateSymbol(SymName);
|
||||
MCA.getOrCreateSymbolData(*GP_Disp);
|
||||
MCA.registerSymbol(*GP_Disp);
|
||||
|
||||
MCInst TmpInst;
|
||||
TmpInst.setOpcode(Mips::LUi);
|
||||
|
Loading…
Reference in New Issue
Block a user