mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
eliminate uses of mangler and simplify code.
llvm-svn: 93615
This commit is contained in:
parent
8813339969
commit
ea72cfbd42
@ -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 @@ MachineModuleInfoMachO &ARMMCInstLower::getMachOMMI() const {
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
|
@ -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::
|
||||
|
@ -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 @@ void PIC16AsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
|
||||
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 @@ void PIC16AsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
|
||||
LibcallDecls.push_back(createESName(Sym));
|
||||
}
|
||||
|
||||
O << Sym;
|
||||
O << Sym;
|
||||
break;
|
||||
}
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
@ -317,16 +314,14 @@ void PIC16AsmPrinter::EmitFunctionDecls(Module &M) {
|
||||
// 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 @@ void PIC16AsmPrinter::EmitFunctionDecls(Module &M) {
|
||||
// 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 @@ void PIC16AsmPrinter::EmitUndefinedVars(Module &M) {
|
||||
|
||||
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 @@ void PIC16AsmPrinter::EmitDefinedVars(Module &M) {
|
||||
|
||||
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 @@ bool PIC16AsmPrinter::doFinalization(Module &M) {
|
||||
|
||||
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 @@ void PIC16AsmPrinter::EmitInitializedDataSection(const PIC16Section *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();
|
||||
int AddrSpace = Items[j]->getType()->getAddressSpace();
|
||||
O << Name;
|
||||
GetGlobalValueSymbol(Items[j])->print(O, MAI);
|
||||
EmitGlobalConstant(C, AddrSpace);
|
||||
}
|
||||
}
|
||||
@ -465,11 +462,11 @@ EmitUninitializedDataSection(const PIC16Section *S) {
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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"
|
||||
|
@ -83,33 +83,24 @@ GetGlobalAddressSymbol(const MachineOperand &MO) const {
|
||||
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??
|
||||
|
@ -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 @@ void XCoreAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
|
||||
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();
|
||||
|
Loading…
Reference in New Issue
Block a user