[llvm-commits] [llvm] r84561 - in /llvm/trunk: include/llvm/MC/MCContext.h lib/MC/MCContext.cpp lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
Chris Lattner
sabre at nondot.org
Mon Oct 19 15:49:00 PDT 2009
Author: lattner
Date: Mon Oct 19 17:49:00 2009
New Revision: 84561
URL: http://llvm.org/viewvc/llvm-project?rev=84561&view=rev
Log:
add a twine version of MCContext::GetOrCreateSymbol.
Modified:
llvm/trunk/include/llvm/MC/MCContext.h
llvm/trunk/lib/MC/MCContext.cpp
llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
Modified: llvm/trunk/include/llvm/MC/MCContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCContext.h?rev=84561&r1=84560&r2=84561&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCContext.h (original)
+++ llvm/trunk/include/llvm/MC/MCContext.h Mon Oct 19 17:49:00 2009
@@ -19,6 +19,7 @@
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 @@
/// @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.
Modified: llvm/trunk/lib/MC/MCContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCContext.cpp?rev=84561&r1=84560&r2=84561&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCContext.cpp (original)
+++ llvm/trunk/lib/MC/MCContext.cpp Mon Oct 19 17:49:00 2009
@@ -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 @@
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())
Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=84561&r1=84560&r2=84561&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Mon Oct 19 17:49:00 2009
@@ -173,7 +173,7 @@
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 @@
// 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.
Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp?rev=84561&r1=84560&r2=84561&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Mon Oct 19 17:49:00 2009
@@ -288,12 +288,12 @@
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));
}
}
More information about the llvm-commits
mailing list