mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
supplement CurrentFnName with CurrentFnSym, which will eventually
replace it. Upgrade Alpha, Blackfin, and part of CellSPU to not use mangler anymore. CellSPU needs more invasive surgery. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93589 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
263d989a71
commit
d1947ed2f8
@ -134,7 +134,8 @@ namespace llvm {
|
||||
/// Cache of mangled name for current function. This is recalculated at the
|
||||
/// beginning of each call to runOnMachineFunction().
|
||||
///
|
||||
std::string CurrentFnName;
|
||||
std::string CurrentFnName; // FIXME: REMOVE.
|
||||
const MCSymbol *CurrentFnSym;
|
||||
|
||||
/// getCurrentSection() - Return the current section we are emitting to.
|
||||
const MCSection *getCurrentSection() const;
|
||||
|
@ -224,6 +224,7 @@ bool AsmPrinter::doFinalization(Module &M) {
|
||||
void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
|
||||
// What's my mangled name?
|
||||
CurrentFnName = Mang->getMangledName(MF.getFunction());
|
||||
CurrentFnSym = GetGlobalValueSymbol(MF.getFunction());
|
||||
IncrementFunctionNumber();
|
||||
|
||||
if (VerboseAsm)
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Target/TargetRegistry.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/Mangler.h"
|
||||
#include "llvm/Support/FormattedStream.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
using namespace llvm;
|
||||
@ -108,7 +107,7 @@ void AlphaAsmPrinter::printOp(const MachineOperand &MO, bool IsCallOp) {
|
||||
return;
|
||||
|
||||
case MachineOperand::MO_GlobalAddress:
|
||||
O << Mang->getMangledName(MO.getGlobal());
|
||||
GetGlobalValueSymbol(MO.getGlobal())->print(O, MAI);
|
||||
return;
|
||||
|
||||
case MachineOperand::MO_JumpTableIndex:
|
||||
@ -208,7 +207,7 @@ void AlphaAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
|
||||
if (EmitSpecialLLVMGlobal(GVar))
|
||||
return;
|
||||
|
||||
std::string name = Mang->getMangledName(GVar);
|
||||
MCSymbol *GVarSym = GetGlobalValueSymbol(GVar);
|
||||
Constant *C = GVar->getInitializer();
|
||||
unsigned Size = TD->getTypeAllocSize(C->getType());
|
||||
unsigned Align = TD->getPreferredAlignmentLog(GVar);
|
||||
@ -218,38 +217,47 @@ void AlphaAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
|
||||
TM));
|
||||
|
||||
// 1: Check visibility
|
||||
printVisibility(name, GVar->getVisibility());
|
||||
printVisibility(GVarSym, GVar->getVisibility());
|
||||
|
||||
// 2: Kind
|
||||
switch (GVar->getLinkage()) {
|
||||
case GlobalValue::LinkOnceAnyLinkage:
|
||||
case GlobalValue::LinkOnceODRLinkage:
|
||||
case GlobalValue::WeakAnyLinkage:
|
||||
case GlobalValue::WeakODRLinkage:
|
||||
case GlobalValue::CommonLinkage:
|
||||
O << MAI->getWeakRefDirective() << name << '\n';
|
||||
case GlobalValue::LinkOnceAnyLinkage:
|
||||
case GlobalValue::LinkOnceODRLinkage:
|
||||
case GlobalValue::WeakAnyLinkage:
|
||||
case GlobalValue::WeakODRLinkage:
|
||||
case GlobalValue::CommonLinkage:
|
||||
O << MAI->getWeakRefDirective();
|
||||
GVarSym->print(O, MAI);
|
||||
O << '\n';
|
||||
break;
|
||||
case GlobalValue::AppendingLinkage:
|
||||
case GlobalValue::ExternalLinkage:
|
||||
O << MAI->getGlobalDirective() << name << "\n";
|
||||
break;
|
||||
case GlobalValue::InternalLinkage:
|
||||
case GlobalValue::PrivateLinkage:
|
||||
case GlobalValue::LinkerPrivateLinkage:
|
||||
break;
|
||||
default:
|
||||
llvm_unreachable("Unknown linkage type!");
|
||||
}
|
||||
case GlobalValue::AppendingLinkage:
|
||||
case GlobalValue::ExternalLinkage:
|
||||
O << MAI->getGlobalDirective();
|
||||
GVarSym->print(O, MAI);
|
||||
O << '\n';
|
||||
break;
|
||||
case GlobalValue::InternalLinkage:
|
||||
case GlobalValue::PrivateLinkage:
|
||||
case GlobalValue::LinkerPrivateLinkage:
|
||||
break;
|
||||
default:
|
||||
llvm_unreachable("Unknown linkage type!");
|
||||
}
|
||||
|
||||
// 3: Type, Size, Align
|
||||
if (MAI->hasDotTypeDotSizeDirective()) {
|
||||
O << "\t.type\t" << name << ", @object\n";
|
||||
O << "\t.size\t" << name << ", " << Size << "\n";
|
||||
O << "\t.type\t";
|
||||
GVarSym->print(O, MAI);
|
||||
O << ", @object\n";
|
||||
O << "\t.size\t";
|
||||
GVarSym->print(O, MAI);
|
||||
O << ", " << Size << "\n";
|
||||
}
|
||||
|
||||
EmitAlignment(Align, GVar);
|
||||
|
||||
O << name << ":\n";
|
||||
|
||||
GVarSym->print(O, MAI);
|
||||
O << ":\n";
|
||||
|
||||
EmitGlobalConstant(C);
|
||||
O << '\n';
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "llvm/Target/TargetLoweringObjectFile.h"
|
||||
#include "llvm/Target/TargetRegistry.h"
|
||||
#include "llvm/Support/Mangler.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
@ -55,7 +54,7 @@ namespace {
|
||||
void printInstruction(const MachineInstr *MI); // autogenerated.
|
||||
static const char *getRegisterName(unsigned RegNo);
|
||||
|
||||
void emitLinkage(const std::string &n, GlobalValue::LinkageTypes l);
|
||||
void emitLinkage(const MCSymbol *GVSym, GlobalValue::LinkageTypes l);
|
||||
bool runOnMachineFunction(MachineFunction &F);
|
||||
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
unsigned AsmVariant, const char *ExtraCode);
|
||||
@ -71,23 +70,29 @@ extern "C" void LLVMInitializeBlackfinAsmPrinter() {
|
||||
RegisterAsmPrinter<BlackfinAsmPrinter> X(TheBlackfinTarget);
|
||||
}
|
||||
|
||||
void BlackfinAsmPrinter::emitLinkage(const std::string &name,
|
||||
GlobalValue::LinkageTypes l) {
|
||||
switch (l) {
|
||||
void BlackfinAsmPrinter::emitLinkage(const MCSymbol *GVSym,
|
||||
GlobalValue::LinkageTypes L) {
|
||||
switch (L) {
|
||||
default: llvm_unreachable("Unknown linkage type!");
|
||||
case GlobalValue::InternalLinkage: // Symbols default to internal.
|
||||
case GlobalValue::PrivateLinkage:
|
||||
case GlobalValue::LinkerPrivateLinkage:
|
||||
break;
|
||||
case GlobalValue::ExternalLinkage:
|
||||
O << MAI->getGlobalDirective() << name << "\n";
|
||||
O << MAI->getGlobalDirective();
|
||||
GVSym->print(O, MAI);
|
||||
O << "\n";
|
||||
break;
|
||||
case GlobalValue::LinkOnceAnyLinkage:
|
||||
case GlobalValue::LinkOnceODRLinkage:
|
||||
case GlobalValue::WeakAnyLinkage:
|
||||
case GlobalValue::WeakODRLinkage:
|
||||
O << MAI->getGlobalDirective() << name << "\n";
|
||||
O << MAI->getWeakDefDirective() << name << "\n";
|
||||
O << MAI->getGlobalDirective();
|
||||
GVSym->print(O, MAI);
|
||||
O << "\n";
|
||||
O << MAI->getWeakDefDirective();
|
||||
GVSym->print(O, MAI);
|
||||
O << "\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -98,18 +103,24 @@ void BlackfinAsmPrinter::PrintGlobalVariable(const GlobalVariable* GV) {
|
||||
if (!GV->hasInitializer() || EmitSpecialLLVMGlobal(GV))
|
||||
return;
|
||||
|
||||
std::string name = Mang->getMangledName(GV);
|
||||
MCSymbol *GVSym = GetGlobalValueSymbol(GV);
|
||||
Constant *C = GV->getInitializer();
|
||||
|
||||
OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GV, Mang,
|
||||
TM));
|
||||
emitLinkage(name, GV->getLinkage());
|
||||
emitLinkage(GVSym, GV->getLinkage());
|
||||
EmitAlignment(TD->getPreferredAlignmentLog(GV), GV);
|
||||
printVisibility(name, GV->getVisibility());
|
||||
printVisibility(GVSym, GV->getVisibility());
|
||||
|
||||
O << "\t.type " << name << ", STT_OBJECT\n";
|
||||
O << "\t.size " << name << ',' << TD->getTypeAllocSize(C->getType()) << '\n';
|
||||
O << name << ":\n";
|
||||
O << "\t.type ";
|
||||
GVSym->print(O, MAI);
|
||||
O << ", STT_OBJECT\n";
|
||||
O << "\t.size ";
|
||||
GVSym->print(O, MAI);
|
||||
O << "\n";
|
||||
O << ',' << TD->getTypeAllocSize(C->getType()) << '\n';
|
||||
GVSym->print(O, MAI);
|
||||
O << ":\n";
|
||||
EmitGlobalConstant(C);
|
||||
}
|
||||
|
||||
@ -124,11 +135,14 @@ bool BlackfinAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||
const Function *F = MF.getFunction();
|
||||
OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(F, Mang, TM));
|
||||
EmitAlignment(2, F);
|
||||
emitLinkage(CurrentFnName, F->getLinkage());
|
||||
printVisibility(CurrentFnName, F->getVisibility());
|
||||
emitLinkage(CurrentFnSym, F->getLinkage());
|
||||
printVisibility(CurrentFnSym, F->getVisibility());
|
||||
|
||||
O << "\t.type\t" << CurrentFnName << ", STT_FUNC\n"
|
||||
<< CurrentFnName << ":\n";
|
||||
O << "\t.type\t";
|
||||
CurrentFnSym->print(O, MAI);
|
||||
O << ", STT_FUNC\n";
|
||||
CurrentFnSym->print(O, MAI);
|
||||
O << ":\n";
|
||||
|
||||
if (DW)
|
||||
DW->BeginFunction(&MF);
|
||||
@ -154,7 +168,11 @@ bool BlackfinAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||
}
|
||||
}
|
||||
|
||||
O << "\t.size " << CurrentFnName << ", .-" << CurrentFnName << "\n";
|
||||
O << "\t.size ";
|
||||
CurrentFnSym->print(O, MAI);
|
||||
O << ", .-";
|
||||
CurrentFnSym->print(O, MAI);
|
||||
O << "\n";
|
||||
|
||||
if (DW)
|
||||
DW->EndFunction(&MF);
|
||||
@ -178,7 +196,7 @@ void BlackfinAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
|
||||
GetMBBSymbol(MO.getMBB()->getNumber())->print(O, MAI);
|
||||
return;
|
||||
case MachineOperand::MO_GlobalAddress:
|
||||
O << Mang->getMangledName(MO.getGlobal());
|
||||
GetGlobalValueSymbol(MO.getGlobal())->print(O, MAI);
|
||||
printOffset(MO.getOffset());
|
||||
break;
|
||||
case MachineOperand::MO_ExternalSymbol:
|
||||
|
@ -437,18 +437,27 @@ bool LinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||
case Function::InternalLinkage: // Symbols default to internal.
|
||||
break;
|
||||
case Function::ExternalLinkage:
|
||||
O << "\t.global\t" << CurrentFnName << "\n"
|
||||
<< "\t.type\t" << CurrentFnName << ", @function\n";
|
||||
O << "\t.global\t";
|
||||
CurrentFnSym->print(O, MAI);
|
||||
O << "\n" << "\t.type\t";
|
||||
CurrentFnSym->print(O, MAI);
|
||||
O << ", @function\n";
|
||||
break;
|
||||
case Function::WeakAnyLinkage:
|
||||
case Function::WeakODRLinkage:
|
||||
case Function::LinkOnceAnyLinkage:
|
||||
case Function::LinkOnceODRLinkage:
|
||||
O << "\t.global\t" << CurrentFnName << "\n";
|
||||
O << "\t.weak_definition\t" << CurrentFnName << "\n";
|
||||
O << "\t.global\t";
|
||||
CurrentFnSym->print(O, MAI);
|
||||
O << "\n";
|
||||
O << "\t.weak_definition\t";
|
||||
CurrentFnSym->print(O, MAI);
|
||||
O << "\n";
|
||||
break;
|
||||
}
|
||||
O << CurrentFnName << ":\n";
|
||||
|
||||
CurrentFnSym->print(O, MAI);
|
||||
O << ":\n";
|
||||
|
||||
// Emit pre-function debug information.
|
||||
DW->BeginFunction(&MF);
|
||||
@ -467,7 +476,11 @@ bool LinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||
}
|
||||
}
|
||||
|
||||
O << "\t.size\t" << CurrentFnName << ",.-" << CurrentFnName << "\n";
|
||||
O << "\t.size\t";
|
||||
CurrentFnSym->print(O, MAI);
|
||||
O << ",.-";
|
||||
CurrentFnSym->print(O, MAI);
|
||||
O << "\n";
|
||||
|
||||
// Print out jump tables referenced by the function.
|
||||
EmitJumpTableInfo(MF.getJumpTableInfo(), MF);
|
||||
|
Loading…
Reference in New Issue
Block a user