aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-10-19 22:49:00 +0000
committerChris Lattner <sabre@nondot.org>2009-10-19 22:49:00 +0000
commit2743f3605a9fcd16f1045a8d9bcb8950cab0860e (patch)
tree780cf54d2b720b26384e0b76dc1b554a3b041013 /lib
parent4c565d8576a1ceb933301e7437723978ba985553 (diff)
downloadexternal_llvm-2743f3605a9fcd16f1045a8d9bcb8950cab0860e.zip
external_llvm-2743f3605a9fcd16f1045a8d9bcb8950cab0860e.tar.gz
external_llvm-2743f3605a9fcd16f1045a8d9bcb8950cab0860e.tar.bz2
add a twine version of MCContext::GetOrCreateSymbol.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84561 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/MC/MCContext.cpp10
-rw-r--r--lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp9
-rw-r--r--lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp4
3 files changed, 16 insertions, 7 deletions
diff --git a/lib/MC/MCContext.cpp b/lib/MC/MCContext.cpp
index db59f7f..09479c5 100644
--- a/lib/MC/MCContext.cpp
+++ b/lib/MC/MCContext.cpp
@@ -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())
diff --git a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
index 7e89b9f..576cc9c 100644
--- a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
+++ b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
@@ -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.
diff --git a/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
index a07d82d..ae8e6d3 100644
--- a/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
+++ b/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
@@ -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));
}
}