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; }
/// 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;
MCSectionELF *RelSection = createRelocationSection(Ctx, Section);
if (SignatureSymbol) {
- Asm.getOrCreateSymbolData(*SignatureSymbol);
+ Asm.registerSymbol(*SignatureSymbol);
unsigned &GroupIdx = RevGroupMap[SignatureSymbol];
if (!GroupIdx) {
MCSectionELF *Group = Ctx.createELFGroupSection(SignatureSymbol);
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();
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);
}
// 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
}
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);
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);
case MCSymbolRefExpr::VK_PPC_TLSLD:
break;
}
- getAssembler().getOrCreateSymbolData(symRef.getSymbol());
+ getAssembler().registerSymbol(symRef.getSymbol());
MCELF::SetType(symRef.getSymbol(), ELF::STT_TLS);
break;
}
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)
}
// 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
// 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);
}
AssignSection(Symbol, nullptr);
- MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
+ getAssembler().registerSymbol(*Symbol);
+ MCSymbolData &SD = Symbol->getData();
SD.setExternal(true);
Symbol->setCommon(Size, ByteAlignment);
}
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)
}
void MCObjectStreamer::visitUsedSymbol(const MCSymbol &Sym) {
- Assembler->getOrCreateSymbolData(Sym);
+ Assembler->registerSymbol(Sym);
}
void MCObjectStreamer::EmitCFISections(bool EH, bool Debug) {
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.
}
void MCObjectStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
- getAssembler().getOrCreateSymbolData(*Symbol);
+ getAssembler().registerSymbol(*Symbol);
MCStreamer::EmitAssignment(Symbol, Value);
}
// 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.
//
// 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);
}
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;
FatalError("storage class value '" + Twine(StorageClass) +
"' out of range");
- getAssembler().getOrCreateSymbolData(*CurSymbol);
+ getAssembler().registerSymbol(*CurSymbol);
CurSymbol->modifyFlags(StorageClass << COFF::SF_ClassShift,
COFF::SF_ClassMask);
}
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);
}
AssignSection(Symbol, nullptr);
- MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
+ getAssembler().registerSymbol(*Symbol);
+ MCSymbolData &SD = Symbol->getData();
SD.setExternal(true);
Symbol->setCommon(Size, ByteAlignment);
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);
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);
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);
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);