[llvm-commits] [llvm] r93615 - in /llvm/trunk/lib/Target: ARM/AsmPrinter/ARMMCInstLower.cpp MSP430/AsmPrinter/MSP430MCInstLower.cpp PIC16/AsmPrinter/PIC16AsmPrinter.cpp X86/AsmPrinter/X86AsmPrinter.cpp X86/AsmPrinter/X86MCInstLower.cpp XCore/AsmPrinter/XCoreAsmPrinter.cpp
Chris Lattner
sabre at nondot.org
Fri Jan 15 17:40:08 PST 2010
Author: lattner
Date: Fri Jan 15 19:40:07 2010
New Revision: 93615
URL: http://llvm.org/viewvc/llvm-project?rev=93615&view=rev
Log:
eliminate uses of mangler and simplify code.
Modified:
llvm/trunk/lib/Target/ARM/AsmPrinter/ARMMCInstLower.cpp
llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430MCInstLower.cpp
llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp
llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp
llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp
Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMMCInstLower.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMMCInstLower.cpp?rev=93615&r1=93614&r2=93615&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMMCInstLower.cpp (original)
+++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMMCInstLower.cpp Fri Jan 15 19:40:07 2010
@@ -22,7 +22,6 @@
#include "llvm/MC/MCInst.h"
//#include "llvm/MC/MCStreamer.h"
#include "llvm/Support/raw_ostream.h"
-#include "llvm/Support/Mangler.h"
#include "llvm/ADT/SmallString.h"
using namespace llvm;
@@ -40,33 +39,24 @@
MCSymbol *ARMMCInstLower::
GetGlobalAddressSymbol(const MachineOperand &MO) const {
- const GlobalValue *GV = MO.getGlobal();
-
- SmallString<128> Name;
- Mang.getNameWithPrefix(Name, GV, false);
-
// FIXME: HANDLE PLT references how??
switch (MO.getTargetFlags()) {
default: assert(0 && "Unknown target flag on GV operand");
case 0: break;
}
- return Ctx.GetOrCreateSymbol(Name.str());
+ return Printer.GetGlobalValueSymbol(MO.getGlobal());
}
MCSymbol *ARMMCInstLower::
GetExternalSymbolSymbol(const MachineOperand &MO) const {
- SmallString<128> Name;
- Name += Printer.MAI->getGlobalPrefix();
- Name += MO.getSymbolName();
-
// FIXME: HANDLE PLT references how??
switch (MO.getTargetFlags()) {
default: assert(0 && "Unknown target flag on GV operand");
case 0: break;
}
- return Ctx.GetOrCreateSymbol(Name.str());
+ return Printer.GetExternalSymbolSymbol(MO.getSymbolName());
}
Modified: llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430MCInstLower.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430MCInstLower.cpp?rev=93615&r1=93614&r2=93615&view=diff
==============================================================================
--- llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430MCInstLower.cpp (original)
+++ llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430MCInstLower.cpp Fri Jan 15 19:40:07 2010
@@ -22,37 +22,27 @@
#include "llvm/MC/MCInst.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/Mangler.h"
#include "llvm/ADT/SmallString.h"
using namespace llvm;
MCSymbol *MSP430MCInstLower::
GetGlobalAddressSymbol(const MachineOperand &MO) const {
- const GlobalValue *GV = MO.getGlobal();
-
- SmallString<128> Name;
- Mang.getNameWithPrefix(Name, GV, false);
-
switch (MO.getTargetFlags()) {
default: llvm_unreachable("Unknown target flag on GV operand");
case 0: break;
}
- return Ctx.GetOrCreateSymbol(Name.str());
+ return Printer.GetGlobalValueSymbol(MO.getGlobal());
}
MCSymbol *MSP430MCInstLower::
GetExternalSymbolSymbol(const MachineOperand &MO) const {
- SmallString<128> Name;
- Name += Printer.MAI->getGlobalPrefix();
- Name += MO.getSymbolName();
-
switch (MO.getTargetFlags()) {
default: assert(0 && "Unknown target flag on GV operand");
case 0: break;
}
- return Ctx.GetOrCreateSymbol(Name.str());
+ return Printer.GetExternalSymbolSymbol(MO.getSymbolName());
}
MCSymbol *MSP430MCInstLower::
Modified: llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp?rev=93615&r1=93614&r2=93615&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp Fri Jan 15 19:40:07 2010
@@ -29,7 +29,6 @@
#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h"
-#include "llvm/Support/Mangler.h"
#include <cstring>
using namespace llvm;
@@ -185,24 +184,22 @@
return;
case MachineOperand::MO_GlobalAddress: {
- std::string Sname = Mang->getMangledName(MO.getGlobal());
+ MCSymbol *Sym = GetGlobalValueSymbol(MO.getGlobal());
// FIXME: currently we do not have a memcpy def coming in the module
// by any chance, as we do not link in those as .bc lib. So these calls
// are always external and it is safe to emit an extern.
- if (PAN::isMemIntrinsic(Sname)) {
- LibcallDecls.push_back(createESName(Sname));
- }
+ if (PAN::isMemIntrinsic(Sym->getName()))
+ LibcallDecls.push_back(createESName(Sym->getName()));
- O << Sname;
+ Sym->print(O, MAI);
break;
}
case MachineOperand::MO_ExternalSymbol: {
const char *Sname = MO.getSymbolName();
// If its a libcall name, record it to decls section.
- if (PAN::getSymbolTag(Sname) == PAN::LIBCALL) {
+ if (PAN::getSymbolTag(Sname) == PAN::LIBCALL)
LibcallDecls.push_back(Sname);
- }
// Record a call to intrinsic to print the extern declaration for it.
std::string Sym = Sname;
@@ -211,7 +208,7 @@
LibcallDecls.push_back(createESName(Sym));
}
- O << Sym;
+ O << Sym;
break;
}
case MachineOperand::MO_MachineBasicBlock:
@@ -317,16 +314,14 @@
// Emit declarations for external functions.
O <<"\n"<<MAI->getCommentString() << "Function Declarations - BEGIN." <<"\n";
for (Module::iterator I = M.begin(), E = M.end(); I != E; I++) {
- if (I->isIntrinsic())
- continue;
-
- std::string Name = Mang->getMangledName(I);
- if (Name.compare("@abort") == 0)
+ if (I->isIntrinsic() || I->getName() == "@abort")
continue;
if (!I->isDeclaration() && !I->hasExternalLinkage())
continue;
+ MCSymbol *Sym = GetGlobalValueSymbol(I);
+
// Do not emit memcpy, memset, and memmove here.
// Calls to these routines can be generated in two ways,
// 1. User calling the standard lib function
@@ -335,14 +330,14 @@
// second case the call is via and externalsym and the prototype is missing.
// So declarations for these are currently always getting printing by
// tracking both kind of references in printInstrunction.
- if (I->isDeclaration() && PAN::isMemIntrinsic(Name)) continue;
+ if (I->isDeclaration() && PAN::isMemIntrinsic(Sym->getName())) continue;
const char *directive = I->isDeclaration() ? MAI->getExternDirective() :
MAI->getGlobalDirective();
- O << directive << Name << "\n";
- O << directive << PAN::getRetvalLabel(Name) << "\n";
- O << directive << PAN::getArgsLabel(Name) << "\n";
+ O << directive << Sym->getName() << "\n";
+ O << directive << PAN::getRetvalLabel(Sym->getName()) << "\n";
+ O << directive << PAN::getArgsLabel(Sym->getName()) << "\n";
}
O << MAI->getCommentString() << "Function Declarations - END." <<"\n";
@@ -355,7 +350,9 @@
O << "\n" << MAI->getCommentString() << "Imported Variables - BEGIN" << "\n";
for (unsigned j = 0; j < Items.size(); j++) {
- O << MAI->getExternDirective() << Mang->getMangledName(Items[j]) << "\n";
+ O << MAI->getExternDirective();
+ GetGlobalValueSymbol(Items[j])->print(O, MAI);
+ O << "\n";
}
O << MAI->getCommentString() << "Imported Variables - END" << "\n";
}
@@ -367,7 +364,9 @@
O << "\n" << MAI->getCommentString() << "Exported Variables - BEGIN" << "\n";
for (unsigned j = 0; j < Items.size(); j++) {
- O << MAI->getGlobalDirective() << Mang->getMangledName(Items[j]) << "\n";
+ O << MAI->getGlobalDirective();
+ GetGlobalValueSymbol(Items[j])->print(O, MAI);
+ O << "\n";
}
O << MAI->getCommentString() << "Exported Variables - END" << "\n";
}
@@ -392,7 +391,6 @@
void PIC16AsmPrinter::EmitFunctionFrame(MachineFunction &MF) {
const Function *F = MF.getFunction();
- std::string FuncName = Mang->getMangledName(F);
const TargetData *TD = TM.getTargetData();
// Emit the data section name.
O << "\n";
@@ -446,10 +444,9 @@
std::vector<const GlobalVariable*> Items = S->Items;
for (unsigned j = 0; j < Items.size(); j++) {
- std::string Name = Mang->getMangledName(Items[j]);
Constant *C = Items[j]->getInitializer();
int AddrSpace = Items[j]->getType()->getAddressSpace();
- O << Name;
+ GetGlobalValueSymbol(Items[j])->print(O, MAI);
EmitGlobalConstant(C, AddrSpace);
}
}
@@ -465,11 +462,11 @@
OutStreamer.SwitchSection(S);
std::vector<const GlobalVariable*> Items = S->Items;
for (unsigned j = 0; j < Items.size(); j++) {
- std::string Name = Mang->getMangledName(Items[j]);
Constant *C = Items[j]->getInitializer();
const Type *Ty = C->getType();
unsigned Size = TD->getTypeAllocSize(Ty);
- O << Name << " RES " << Size << "\n";
+ GetGlobalValueSymbol(Items[j])->print(O, MAI);
+ O << " RES " << Size << "\n";
}
}
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=93615&r1=93614&r2=93615&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Fri Jan 15 19:40:07 2010
@@ -36,7 +36,6 @@
#include "llvm/CodeGen/MachineModuleInfoImpls.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h"
-#include "llvm/Support/Mangler.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Target/TargetOptions.h"
Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp?rev=93615&r1=93614&r2=93615&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Fri Jan 15 19:40:07 2010
@@ -83,33 +83,24 @@
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str());
const MCSymbol *&StubSym = getMachOMMI().getGVStubEntry(Sym);
- if (StubSym == 0) {
- Name.clear();
- Mang->getNameWithPrefix(Name, GV, false);
- StubSym = Ctx.GetOrCreateSymbol(Name.str());
- }
+ if (StubSym == 0)
+ StubSym = AsmPrinter.GetGlobalValueSymbol(GV);
return Sym;
}
case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE: {
Name += "$non_lazy_ptr";
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str());
const MCSymbol *&StubSym = getMachOMMI().getHiddenGVStubEntry(Sym);
- if (StubSym == 0) {
- Name.clear();
- Mang->getNameWithPrefix(Name, GV, false);
- StubSym = Ctx.GetOrCreateSymbol(Name.str());
- }
+ if (StubSym == 0)
+ StubSym = AsmPrinter.GetGlobalValueSymbol(GV);
return Sym;
}
case X86II::MO_DARWIN_STUB: {
Name += "$stub";
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str());
const MCSymbol *&StubSym = getMachOMMI().getFnStubEntry(Sym);
- if (StubSym == 0) {
- Name.clear();
- Mang->getNameWithPrefix(Name, GV, false);
- StubSym = Ctx.GetOrCreateSymbol(Name.str());
- }
+ if (StubSym == 0)
+ StubSym = AsmPrinter.GetGlobalValueSymbol(GV);
return Sym;
}
// FIXME: These probably should be a modifier on the symbol or something??
Modified: llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp?rev=93615&r1=93614&r2=93615&view=diff
==============================================================================
--- llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp Fri Jan 15 19:40:07 2010
@@ -37,7 +37,6 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h"
-#include "llvm/Support/Mangler.h"
#include "llvm/Support/MathExtras.h"
#include <algorithm>
#include <cctype>
@@ -340,7 +339,7 @@
GetMBBSymbol(MO.getMBB()->getNumber())->print(O, MAI);
break;
case MachineOperand::MO_GlobalAddress:
- O << Mang->getMangledName(MO.getGlobal());
+ GetGlobalValueSymbol(MO.getGlobal())->print(O, MAI);
break;
case MachineOperand::MO_ExternalSymbol:
O << MO.getSymbolName();
More information about the llvm-commits
mailing list