convert X86ATTAsmPrinter::GetExternalSymbolSymbol to use SmallString

instead of std::string and Mangler.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81503 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2009-09-11 04:36:43 +00:00
parent cf1ed75f7f
commit a0602b4b14

View File

@ -92,9 +92,9 @@ MCSymbol *X86ATTAsmPrinter::GetGlobalAddressSymbol(const MachineOperand &MO) {
} }
MCSymbol *X86ATTAsmPrinter::GetExternalSymbolSymbol(const MachineOperand &MO) { MCSymbol *X86ATTAsmPrinter::GetExternalSymbolSymbol(const MachineOperand &MO) {
std::string Name = Mang->makeNameProper(MO.getSymbolName()); SmallString<256> Name;
if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) Name += MAI->getGlobalPrefix();
Name += "$stub"; Name += MO.getSymbolName();
switch (MO.getTargetFlags()) { switch (MO.getTargetFlags()) {
default: llvm_unreachable("Unknown target flag on GV operand"); default: llvm_unreachable("Unknown target flag on GV operand");
@ -102,12 +102,16 @@ MCSymbol *X86ATTAsmPrinter::GetExternalSymbolSymbol(const MachineOperand &MO) {
case X86II::MO_GOT_ABSOLUTE_ADDRESS: // Doesn't modify symbol name. case X86II::MO_GOT_ABSOLUTE_ADDRESS: // Doesn't modify symbol name.
case X86II::MO_PIC_BASE_OFFSET: // Doesn't modify symbol name. case X86II::MO_PIC_BASE_OFFSET: // Doesn't modify symbol name.
break; break;
case X86II::MO_DLLIMPORT: case X86II::MO_DLLIMPORT: {
// Handle dllimport linkage. // Handle dllimport linkage.
Name = "__imp_" + Name; const char *Prefix = "__imp_";
Name.insert(Name.begin(), Prefix, Prefix+strlen(Prefix));
break; break;
}
case X86II::MO_DARWIN_STUB: case X86II::MO_DARWIN_STUB:
FnStubs[Name] = Mang->makeNameProper(MO.getSymbolName()); // Insert: FnStub["_foo$stub"] = "_foo";
Name += "$stub";
FnStubs[Name.str()] = StringRef(Name.data(), Name.size()-5);
break; break;
// FIXME: These probably should be a modifier on the symbol or something?? // FIXME: These probably should be a modifier on the symbol or something??
case X86II::MO_TLSGD: Name += "@TLSGD"; break; case X86II::MO_TLSGD: Name += "@TLSGD"; break;
@ -121,7 +125,7 @@ MCSymbol *X86ATTAsmPrinter::GetExternalSymbolSymbol(const MachineOperand &MO) {
case X86II::MO_PLT: Name += "@PLT"; break; case X86II::MO_PLT: Name += "@PLT"; break;
} }
return OutContext.GetOrCreateSymbol(Name); return OutContext.GetOrCreateSymbol(Name.str());
} }
MCSymbol *X86ATTAsmPrinter::GetJumpTableSymbol(const MachineOperand &MO) { MCSymbol *X86ATTAsmPrinter::GetJumpTableSymbol(const MachineOperand &MO) {