mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-13 23:18:58 +00:00
add a twine version of MCContext::GetOrCreateSymbol.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84561 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a70e644820
commit
7c5b021793
@ -19,6 +19,7 @@ namespace llvm {
|
||||
class MCSection;
|
||||
class MCSymbol;
|
||||
class StringRef;
|
||||
class Twine;
|
||||
|
||||
/// MCContext - Context object for machine code objects. This class owns all
|
||||
/// of the sections that it creates.
|
||||
@ -58,6 +59,7 @@ namespace llvm {
|
||||
/// @param IsTemporary - Whether this symbol is an assembler temporary,
|
||||
/// which should not survive into the symbol table for the translation unit.
|
||||
MCSymbol *GetOrCreateSymbol(const StringRef &Name);
|
||||
MCSymbol *GetOrCreateSymbol(const Twine &Name);
|
||||
|
||||
/// CreateTemporarySymbol - Create a new temporary symbol with the specified
|
||||
/// @param Name.
|
||||
|
@ -8,10 +8,11 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/MC/MCContext.h"
|
||||
|
||||
#include "llvm/MC/MCSection.h"
|
||||
#include "llvm/MC/MCSymbol.h"
|
||||
#include "llvm/MC/MCValue.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/ADT/Twine.h"
|
||||
using namespace llvm;
|
||||
|
||||
MCContext::MCContext() {
|
||||
@ -38,6 +39,13 @@ MCSymbol *MCContext::GetOrCreateSymbol(const StringRef &Name) {
|
||||
return Entry = new (*this) MCSymbol(Name, false);
|
||||
}
|
||||
|
||||
MCSymbol *MCContext::GetOrCreateSymbol(const Twine &Name) {
|
||||
SmallString<128> NameSV;
|
||||
Name.toVector(NameSV);
|
||||
return GetOrCreateSymbol(NameSV.str());
|
||||
}
|
||||
|
||||
|
||||
MCSymbol *MCContext::CreateTemporarySymbol(const StringRef &Name) {
|
||||
// If unnamed, just create a symbol.
|
||||
if (Name.empty())
|
||||
|
@ -173,7 +173,7 @@ namespace {
|
||||
else {
|
||||
// FIXME: Remove this when Darwin transition to @GOT like syntax.
|
||||
Name = Mang->getMangledName(GV, "$non_lazy_ptr", true);
|
||||
MCSymbol *Sym = OutContext.GetOrCreateSymbol(Name.c_str());
|
||||
MCSymbol *Sym = OutContext.GetOrCreateSymbol(StringRef(Name));
|
||||
|
||||
MachineModuleInfoMachO &MMIMachO =
|
||||
MMI->getObjFileInfo<MachineModuleInfoMachO>();
|
||||
@ -1336,10 +1336,11 @@ void ARMAsmPrinter::printInstructionThroughMCStreamer(const MachineInstr *MI) {
|
||||
|
||||
// Emit the label.
|
||||
// FIXME: MOVE TO SHARED PLACE.
|
||||
SmallString<60> Name;
|
||||
unsigned Id = (unsigned)MI->getOperand(2).getImm();
|
||||
raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix() << "PC" << Id;
|
||||
OutStreamer.EmitLabel(OutContext.GetOrCreateSymbol(Name.str()));
|
||||
const char *Prefix = MAI->getPrivateGlobalPrefix();
|
||||
MCSymbol *Label =
|
||||
OutContext.GetOrCreateSymbol(Twine(Prefix)+"PC"+Twine(Id));
|
||||
OutStreamer.EmitLabel(Label);
|
||||
|
||||
|
||||
// Form and emit tha dd.
|
||||
|
@ -288,12 +288,12 @@ void X86AsmPrinter::printSymbolOperand(const MachineOperand &MO) {
|
||||
std::string Name = Mang->makeNameProper(MO.getSymbolName());
|
||||
if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) {
|
||||
Name += "$stub";
|
||||
MCSymbol *Sym = OutContext.GetOrCreateSymbol(Name);
|
||||
MCSymbol *Sym = OutContext.GetOrCreateSymbol(StringRef(Name));
|
||||
const MCSymbol *&StubSym =
|
||||
MMI->getObjFileInfo<MachineModuleInfoMachO>().getFnStubEntry(Sym);
|
||||
if (StubSym == 0) {
|
||||
Name.erase(Name.end()-5, Name.end());
|
||||
StubSym = OutContext.GetOrCreateSymbol(Name);
|
||||
StubSym = OutContext.GetOrCreateSymbol(StringRef(Name));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user