mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-22 10:29:35 +00:00
Move getSymbol to TargetLoweringObjectFile.
This allows constructing a Mangler with just a TargetMachine. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193630 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
faf4ed2da8
commit
93cf0939f9
@ -20,7 +20,6 @@ namespace llvm {
|
||||
|
||||
class GlobalValue;
|
||||
class MCContext;
|
||||
class MCSymbol;
|
||||
template <typename T> class SmallVectorImpl;
|
||||
class TargetMachine;
|
||||
class Twine;
|
||||
@ -34,7 +33,6 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
MCContext &Context;
|
||||
const TargetMachine *TM;
|
||||
|
||||
/// AnonGlobalIDs - We need to give global values the same name every time
|
||||
@ -48,12 +46,7 @@ private:
|
||||
unsigned NextAnonGlobalID;
|
||||
|
||||
public:
|
||||
Mangler(MCContext &Context, const TargetMachine *TM)
|
||||
: Context(Context), TM(TM), NextAnonGlobalID(1) {}
|
||||
|
||||
/// getSymbol - Return the MCSymbol for the specified global value. This
|
||||
/// symbol is the main label that is the address of the global.
|
||||
MCSymbol *getSymbol(const GlobalValue *GV);
|
||||
Mangler(const TargetMachine *TM) : TM(TM), NextAnonGlobalID(1) {}
|
||||
|
||||
/// getNameWithPrefix - Fill OutName with the name of the appropriate prefix
|
||||
/// and the specified global variable's name. If the global variable doesn't
|
||||
|
@ -117,6 +117,10 @@ public:
|
||||
MachineModuleInfo *MMI, unsigned Encoding,
|
||||
MCStreamer &Streamer) const;
|
||||
|
||||
/// Return the MCSymbol for the specified global value. This symbol is the
|
||||
/// main label that is the address of the global
|
||||
MCSymbol *getSymbol(Mangler &M, const GlobalValue *GV) const;
|
||||
|
||||
// getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality.
|
||||
virtual MCSymbol *
|
||||
getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
|
||||
|
@ -164,7 +164,7 @@ bool AsmPrinter::doInitialization(Module &M) {
|
||||
|
||||
OutStreamer.InitStreamer();
|
||||
|
||||
Mang = new Mangler(OutContext, &TM);
|
||||
Mang = new Mangler(&TM);
|
||||
|
||||
// Allow the target to emit any magic that it wants at the start of the file.
|
||||
EmitStartOfAsmFile(M);
|
||||
@ -264,7 +264,7 @@ void AsmPrinter::EmitLinkage(unsigned L, MCSymbol *GVSym) const {
|
||||
}
|
||||
|
||||
MCSymbol *AsmPrinter::getSymbol(const GlobalValue *GV) const {
|
||||
return Mang->getSymbol(GV);
|
||||
return getObjFileLowering().getSymbol(*Mang, GV);
|
||||
}
|
||||
|
||||
/// EmitGlobalVariable - Emit the specified global variable to the .s file.
|
||||
|
@ -52,10 +52,10 @@ TargetLoweringObjectFileELF::getCFIPersonalitySymbol(const GlobalValue *GV,
|
||||
default:
|
||||
report_fatal_error("We do not support this DWARF encoding yet!");
|
||||
case dwarf::DW_EH_PE_absptr:
|
||||
return Mang->getSymbol(GV);
|
||||
return getSymbol(*Mang, GV);
|
||||
case dwarf::DW_EH_PE_pcrel: {
|
||||
return getContext().GetOrCreateSymbol(StringRef("DW.ref.") +
|
||||
Mang->getSymbol(GV)->getName());
|
||||
getSymbol(*Mang, GV)->getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -104,7 +104,7 @@ getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
|
||||
MCSymbol *SSym = getContext().GetOrCreateSymbol(Name.str());
|
||||
MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym);
|
||||
if (StubSym.getPointer() == 0) {
|
||||
MCSymbol *Sym = Mang->getSymbol(GV);
|
||||
MCSymbol *Sym = getSymbol(*Mang, GV);
|
||||
StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
|
||||
}
|
||||
|
||||
@ -252,7 +252,7 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
|
||||
Prefix = getSectionPrefixForGlobal(Kind);
|
||||
|
||||
SmallString<128> Name(Prefix, Prefix+strlen(Prefix));
|
||||
MCSymbol *Sym = Mang->getSymbol(GV);
|
||||
MCSymbol *Sym = getSymbol(*Mang, GV);
|
||||
Name.append(Sym->getName().begin(), Sym->getName().end());
|
||||
StringRef Group = "";
|
||||
unsigned Flags = getELFSectionFlags(Kind);
|
||||
@ -613,7 +613,7 @@ shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler *Mang) const {
|
||||
// FIXME: ObjC metadata is currently emitted as internal symbols that have
|
||||
// \1L and \0l prefixes on them. Fix them to be Private/LinkerPrivate and
|
||||
// this horrible hack can go away.
|
||||
MCSymbol *Sym = Mang->getSymbol(GV);
|
||||
MCSymbol *Sym = getSymbol(*Mang, GV);
|
||||
if (Sym->getName()[0] == 'L' || Sym->getName()[0] == 'l')
|
||||
return false;
|
||||
}
|
||||
@ -642,7 +642,7 @@ getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
|
||||
GV->hasHiddenVisibility() ? MachOMMI.getHiddenGVStubEntry(SSym) :
|
||||
MachOMMI.getGVStubEntry(SSym);
|
||||
if (StubSym.getPointer() == 0) {
|
||||
MCSymbol *Sym = Mang->getSymbol(GV);
|
||||
MCSymbol *Sym = getSymbol(*Mang, GV);
|
||||
StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
|
||||
}
|
||||
|
||||
@ -671,7 +671,7 @@ getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
|
||||
MCSymbol *SSym = getContext().GetOrCreateSymbol(Name.str());
|
||||
MachineModuleInfoImpl::StubValueTy &StubSym = MachOMMI.getGVStubEntry(SSym);
|
||||
if (StubSym.getPointer() == 0) {
|
||||
MCSymbol *Sym = Mang->getSymbol(GV);
|
||||
MCSymbol *Sym = getSymbol(*Mang, GV);
|
||||
StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
|
||||
}
|
||||
|
||||
|
@ -350,9 +350,7 @@ void LTOCodeGenerator::applyScopeRestrictions() {
|
||||
passes.add(createVerifierPass());
|
||||
|
||||
// mark which symbols can not be internalized
|
||||
MCContext MContext(TargetMach->getMCAsmInfo(), TargetMach->getRegisterInfo(),
|
||||
NULL);
|
||||
Mangler Mangler(MContext, TargetMach);
|
||||
Mangler Mangler(TargetMach);
|
||||
std::vector<const char*> MustPreserveList;
|
||||
std::vector<const char*> DSOList;
|
||||
SmallPtrSet<GlobalValue*, 8> AsmUsed;
|
||||
|
@ -43,7 +43,7 @@ using namespace llvm;
|
||||
LTOModule::LTOModule(llvm::Module *m, llvm::TargetMachine *t)
|
||||
: _module(m), _target(t),
|
||||
_context(_target->getMCAsmInfo(), _target->getRegisterInfo(), NULL),
|
||||
_mangler(_context, t) {}
|
||||
_mangler(t) {}
|
||||
|
||||
/// isBitcodeFile - Returns 'true' if the file (or memory contents) is LLVM
|
||||
/// bitcode.
|
||||
|
@ -47,7 +47,7 @@ getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
|
||||
MCStreamer &Streamer) const {
|
||||
assert(Encoding == DW_EH_PE_absptr && "Can handle absptr encoding only");
|
||||
|
||||
return MCSymbolRefExpr::Create(Mang->getSymbol(GV),
|
||||
return MCSymbolRefExpr::Create(getSymbol(*Mang, GV),
|
||||
MCSymbolRefExpr::VK_ARM_TARGET2,
|
||||
getContext());
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ void Mangler::getNameWithPrefix(SmallVectorImpl<char> &OutName,
|
||||
StringRef Name = GVName.toStringRef(TmpData);
|
||||
assert(!Name.empty() && "getNameWithPrefix requires non-empty name");
|
||||
|
||||
const MCAsmInfo *MAI = Context.getAsmInfo();
|
||||
const MCAsmInfo *MAI = TM->getMCAsmInfo();
|
||||
|
||||
// If the global name is not led with \1, add the appropriate prefixes.
|
||||
if (Name[0] == '\1') {
|
||||
@ -212,7 +212,7 @@ void Mangler::getNameWithPrefix(SmallVectorImpl<char> &OutName,
|
||||
|
||||
// If we are supposed to add a microsoft-style suffix for stdcall/fastcall,
|
||||
// add it.
|
||||
if (Context.getAsmInfo()->hasMicrosoftFastStdCallMangling()) {
|
||||
if (TM->getMCAsmInfo()->hasMicrosoftFastStdCallMangling()) {
|
||||
if (const Function *F = dyn_cast<Function>(GV)) {
|
||||
CallingConv::ID CC = F->getCallingConv();
|
||||
|
||||
@ -236,13 +236,3 @@ void Mangler::getNameWithPrefix(SmallVectorImpl<char> &OutName,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// getSymbol - Return the MCSymbol for the specified global value. This
|
||||
/// symbol is the main label that is the address of the global.
|
||||
MCSymbol *Mangler::getSymbol(const GlobalValue *GV) {
|
||||
SmallString<60> NameStr;
|
||||
getNameWithPrefix(NameStr, GV, false);
|
||||
return Context.GetOrCreateSymbol(NameStr.str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -887,7 +887,7 @@ bool NVPTXAsmPrinter::doInitialization(Module &M) {
|
||||
const_cast<TargetLoweringObjectFile &>(getObjFileLowering())
|
||||
.Initialize(OutContext, TM);
|
||||
|
||||
Mang = new Mangler(OutContext, &TM);
|
||||
Mang = new Mangler(&TM);
|
||||
|
||||
// Emit header before any dwarf directives are emitted below.
|
||||
emitHeader(M, OS1);
|
||||
|
@ -68,6 +68,7 @@ public:
|
||||
}
|
||||
|
||||
virtual void Initialize(MCContext &ctx, const TargetMachine &TM) {
|
||||
TargetLoweringObjectFile::Initialize(ctx, TM);
|
||||
TextSection = new NVPTXSection(MCSection::SV_ELF, SectionKind::getText());
|
||||
DataSection =
|
||||
new NVPTXSection(MCSection::SV_ELF, SectionKind::getDataRel());
|
||||
|
@ -97,10 +97,20 @@ static bool IsNullTerminatedString(const Constant *C) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Return the MCSymbol for the specified global value. This
|
||||
/// symbol is the main label that is the address of the global.
|
||||
MCSymbol *TargetLoweringObjectFile::getSymbol(Mangler &M,
|
||||
const GlobalValue *GV) const {
|
||||
SmallString<60> NameStr;
|
||||
M.getNameWithPrefix(NameStr, GV, false);
|
||||
return Ctx->GetOrCreateSymbol(NameStr.str());
|
||||
}
|
||||
|
||||
|
||||
MCSymbol *TargetLoweringObjectFile::
|
||||
getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
|
||||
MachineModuleInfo *MMI) const {
|
||||
return Mang->getSymbol(GV);
|
||||
return getSymbol(*Mang, GV);
|
||||
}
|
||||
|
||||
void TargetLoweringObjectFile::emitPersonalityValue(MCStreamer &Streamer,
|
||||
@ -293,7 +303,7 @@ getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
|
||||
MachineModuleInfo *MMI, unsigned Encoding,
|
||||
MCStreamer &Streamer) const {
|
||||
const MCSymbolRefExpr *Ref =
|
||||
MCSymbolRefExpr::Create(Mang->getSymbol(GV), getContext());
|
||||
MCSymbolRefExpr::Create(getSymbol(*Mang, GV), getContext());
|
||||
|
||||
return getTTypeReference(Ref, Encoding, Streamer);
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
|
||||
// On Darwin/X86-64, we can reference dwarf symbols with foo@GOTPCREL+4, which
|
||||
// is an indirect pc-relative reference.
|
||||
if (Encoding & (DW_EH_PE_indirect | DW_EH_PE_pcrel)) {
|
||||
const MCSymbol *Sym = Mang->getSymbol(GV);
|
||||
const MCSymbol *Sym = getSymbol(*Mang, GV);
|
||||
const MCExpr *Res =
|
||||
MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_GOTPCREL, getContext());
|
||||
const MCExpr *Four = MCConstantExpr::Create(4, getContext());
|
||||
@ -39,7 +39,7 @@ getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
|
||||
MCSymbol *X86_64MachoTargetObjectFile::
|
||||
getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
|
||||
MachineModuleInfo *MMI) const {
|
||||
return Mang->getSymbol(GV);
|
||||
return getSymbol(*Mang, GV);
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user