class MCSection;
class MCSymbol;
class StringRef;
class MCSection;
class MCSymbol;
class StringRef;
/// MCContext - Context object for machine code objects. This class owns all
/// of the sections that it creates.
/// MCContext - Context object for machine code objects. This class owns all
/// of the sections that it creates.
/// @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);
/// @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.
/// CreateTemporarySymbol - Create a new temporary symbol with the specified
/// @param Name.
//===----------------------------------------------------------------------===//
#include "llvm/MC/MCContext.h"
//===----------------------------------------------------------------------===//
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCValue.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() {
using namespace llvm;
MCContext::MCContext() {
return Entry = new (*this) MCSymbol(Name, false);
}
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())
MCSymbol *MCContext::CreateTemporarySymbol(const StringRef &Name) {
// If unnamed, just create a symbol.
if (Name.empty())
else {
// FIXME: Remove this when Darwin transition to @GOT like syntax.
Name = Mang->getMangledName(GV, "$non_lazy_ptr", true);
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>();
MachineModuleInfoMachO &MMIMachO =
MMI->getObjFileInfo<MachineModuleInfoMachO>();
// Emit the label.
// FIXME: MOVE TO SHARED PLACE.
// Emit the label.
// FIXME: MOVE TO SHARED PLACE.
unsigned Id = (unsigned)MI->getOperand(2).getImm();
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);
std::string Name = Mang->makeNameProper(MO.getSymbolName());
if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) {
Name += "$stub";
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());
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));