mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-25 16:24:23 +00:00
switch X86 target off CurFunctionName and MCIze more.
Note that the code wasn't calling DecorateCygMingName when emitting the ".ascii -export" stuff at the end of file for DLLExported functions. I don't know if it should or not, but I'm preserving behavior. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93603 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -170,8 +170,9 @@ void SparcAsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
|
|||||||
case Function::WeakAnyLinkage:
|
case Function::WeakAnyLinkage:
|
||||||
case Function::WeakODRLinkage:
|
case Function::WeakODRLinkage:
|
||||||
// Function is weak
|
// Function is weak
|
||||||
O << "\t.weak\t";CurrentFnSym->print(O, MAI);
|
O << "\t.weak\t";
|
||||||
O << '\n' ;
|
CurrentFnSym->print(O, MAI);
|
||||||
|
O << '\n';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,8 +71,8 @@ void X86AsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
|
|||||||
if (Subtarget->isTargetCygMing()) {
|
if (Subtarget->isTargetCygMing()) {
|
||||||
X86COFFMachineModuleInfo &COFFMMI =
|
X86COFFMachineModuleInfo &COFFMMI =
|
||||||
MMI->getObjFileInfo<X86COFFMachineModuleInfo>();
|
MMI->getObjFileInfo<X86COFFMachineModuleInfo>();
|
||||||
COFFMMI.DecorateCygMingName(CurrentFnName, F, *TM.getTargetData());
|
COFFMMI.DecorateCygMingName(CurrentFnSym, OutContext, F,
|
||||||
CurrentFnSym = OutContext.GetOrCreateSymbol(StringRef(CurrentFnName));
|
*TM.getTargetData());
|
||||||
}
|
}
|
||||||
|
|
||||||
OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(F, Mang, TM));
|
OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(F, Mang, TM));
|
||||||
@ -238,24 +238,25 @@ void X86AsmPrinter::printSymbolOperand(const MachineOperand &MO) {
|
|||||||
case MachineOperand::MO_GlobalAddress: {
|
case MachineOperand::MO_GlobalAddress: {
|
||||||
const GlobalValue *GV = MO.getGlobal();
|
const GlobalValue *GV = MO.getGlobal();
|
||||||
|
|
||||||
const char *Suffix = "";
|
const MCSymbol *GVSym;
|
||||||
if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB)
|
if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB)
|
||||||
Suffix = "$stub";
|
GVSym = GetPrivateGlobalValueSymbolStub(GV, "$stub");
|
||||||
else if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
|
else if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
|
||||||
MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE ||
|
MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE ||
|
||||||
MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE)
|
MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE)
|
||||||
Suffix = "$non_lazy_ptr";
|
GVSym = GetPrivateGlobalValueSymbolStub(GV, "$non_lazy_ptr");
|
||||||
|
else
|
||||||
std::string Name = Mang->getMangledName(GV, Suffix, Suffix[0] != '\0');
|
GVSym = GetGlobalValueSymbol(GV);
|
||||||
|
|
||||||
if (Subtarget->isTargetCygMing()) {
|
if (Subtarget->isTargetCygMing()) {
|
||||||
X86COFFMachineModuleInfo &COFFMMI =
|
X86COFFMachineModuleInfo &COFFMMI =
|
||||||
MMI->getObjFileInfo<X86COFFMachineModuleInfo>();
|
MMI->getObjFileInfo<X86COFFMachineModuleInfo>();
|
||||||
COFFMMI.DecorateCygMingName(Name, GV, *TM.getTargetData());
|
COFFMMI.DecorateCygMingName(GVSym, OutContext, GV, *TM.getTargetData());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle dllimport linkage.
|
// Handle dllimport linkage.
|
||||||
if (MO.getTargetFlags() == X86II::MO_DLLIMPORT)
|
if (MO.getTargetFlags() == X86II::MO_DLLIMPORT)
|
||||||
Name = "__imp_" + Name;
|
GVSym = OutContext.GetOrCreateSymbol(Twine("__imp_") + GVSym->getName());
|
||||||
|
|
||||||
if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
|
if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
|
||||||
MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE) {
|
MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE) {
|
||||||
@ -296,11 +297,13 @@ void X86AsmPrinter::printSymbolOperand(const MachineOperand &MO) {
|
|||||||
|
|
||||||
// If the name begins with a dollar-sign, enclose it in parens. We do this
|
// If the name begins with a dollar-sign, enclose it in parens. We do this
|
||||||
// to avoid having it look like an integer immediate to the assembler.
|
// to avoid having it look like an integer immediate to the assembler.
|
||||||
if (Name[0] == '$')
|
if (GVSym->getName()[0] != '$')
|
||||||
O << '(' << Name << ')';
|
GVSym->print(O, MAI);
|
||||||
else
|
else {
|
||||||
O << Name;
|
O << '(';
|
||||||
|
GVSym->print(O, MAI);
|
||||||
|
O << ')';
|
||||||
|
}
|
||||||
printOffset(MO.getOffset());
|
printOffset(MO.getOffset());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -916,36 +919,39 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
|
|||||||
|
|
||||||
if (Subtarget->isTargetCygMing()) {
|
if (Subtarget->isTargetCygMing()) {
|
||||||
// Necessary for dllexport support
|
// Necessary for dllexport support
|
||||||
std::vector<std::string> DLLExportedFns, DLLExportedGlobals;
|
std::vector<const MCSymbol*> DLLExportedFns, DLLExportedGlobals;
|
||||||
|
|
||||||
TargetLoweringObjectFileCOFF &TLOFCOFF =
|
TargetLoweringObjectFileCOFF &TLOFCOFF =
|
||||||
static_cast<TargetLoweringObjectFileCOFF&>(getObjFileLowering());
|
static_cast<TargetLoweringObjectFileCOFF&>(getObjFileLowering());
|
||||||
|
|
||||||
for (Module::const_iterator I = M.begin(), E = M.end(); I != E; ++I)
|
for (Module::const_iterator I = M.begin(), E = M.end(); I != E; ++I)
|
||||||
if (I->hasDLLExportLinkage()) {
|
if (I->hasDLLExportLinkage()) {
|
||||||
std::string Name = Mang->getMangledName(I);
|
const MCSymbol *Sym = GetGlobalValueSymbol(I);
|
||||||
COFFMMI.DecorateCygMingName(Name, I, *TM.getTargetData());
|
COFFMMI.DecorateCygMingName(Sym, OutContext, I, *TM.getTargetData());
|
||||||
DLLExportedFns.push_back(Name);
|
DLLExportedFns.push_back(Sym);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Module::const_global_iterator I = M.global_begin(),
|
for (Module::const_global_iterator I = M.global_begin(),
|
||||||
E = M.global_end(); I != E; ++I)
|
E = M.global_end(); I != E; ++I)
|
||||||
if (I->hasDLLExportLinkage()) {
|
if (I->hasDLLExportLinkage())
|
||||||
std::string Name = Mang->getMangledName(I);
|
DLLExportedGlobals.push_back(GetGlobalValueSymbol(I));
|
||||||
COFFMMI.DecorateCygMingName(Name, I, *TM.getTargetData());
|
|
||||||
DLLExportedGlobals.push_back(Mang->getMangledName(I));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Output linker support code for dllexported globals on windows.
|
// Output linker support code for dllexported globals on windows.
|
||||||
if (!DLLExportedGlobals.empty() || !DLLExportedFns.empty()) {
|
if (!DLLExportedGlobals.empty() || !DLLExportedFns.empty()) {
|
||||||
OutStreamer.SwitchSection(TLOFCOFF.getCOFFSection(".section .drectve",
|
OutStreamer.SwitchSection(TLOFCOFF.getCOFFSection(".section .drectve",
|
||||||
true,
|
true,
|
||||||
SectionKind::getMetadata()));
|
SectionKind::getMetadata()));
|
||||||
for (unsigned i = 0, e = DLLExportedGlobals.size(); i != e; ++i)
|
for (unsigned i = 0, e = DLLExportedGlobals.size(); i != e; ++i) {
|
||||||
O << "\t.ascii \" -export:" << DLLExportedGlobals[i] << ",data\"\n";
|
O << "\t.ascii \" -export:";
|
||||||
|
DLLExportedGlobals[i]->print(O, MAI);
|
||||||
|
O << ",data\"\n";
|
||||||
|
}
|
||||||
|
|
||||||
for (unsigned i = 0, e = DLLExportedFns.size(); i != e; ++i)
|
for (unsigned i = 0, e = DLLExportedFns.size(); i != e; ++i) {
|
||||||
O << "\t.ascii \" -export:" << DLLExportedFns[i] << "\"\n";
|
O << "\t.ascii \" -export:";
|
||||||
|
DLLExportedFns[i]->print(O, MAI);
|
||||||
|
O << "\"\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
#include "X86MachineFunctionInfo.h"
|
#include "X86MachineFunctionInfo.h"
|
||||||
#include "llvm/DerivedTypes.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
#include "llvm/Function.h"
|
#include "llvm/Function.h"
|
||||||
|
#include "llvm/MC/MCContext.h"
|
||||||
|
#include "llvm/MC/MCSymbol.h"
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
#include "llvm/ADT/SmallString.h"
|
#include "llvm/ADT/SmallString.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
@ -23,7 +25,6 @@ using namespace llvm;
|
|||||||
X86COFFMachineModuleInfo::X86COFFMachineModuleInfo(const MachineModuleInfo &) {
|
X86COFFMachineModuleInfo::X86COFFMachineModuleInfo(const MachineModuleInfo &) {
|
||||||
}
|
}
|
||||||
X86COFFMachineModuleInfo::~X86COFFMachineModuleInfo() {
|
X86COFFMachineModuleInfo::~X86COFFMachineModuleInfo() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void X86COFFMachineModuleInfo::AddFunctionInfo(const Function *F,
|
void X86COFFMachineModuleInfo::AddFunctionInfo(const Function *F,
|
||||||
@ -114,10 +115,12 @@ void X86COFFMachineModuleInfo::DecorateCygMingName(SmallVectorImpl<char> &Name,
|
|||||||
|
|
||||||
/// DecorateCygMingName - Query FunctionInfoMap and use this information for
|
/// DecorateCygMingName - Query FunctionInfoMap and use this information for
|
||||||
/// various name decorations for Cygwin and MingW.
|
/// various name decorations for Cygwin and MingW.
|
||||||
void X86COFFMachineModuleInfo::DecorateCygMingName(std::string &Name,
|
void X86COFFMachineModuleInfo::DecorateCygMingName(const MCSymbol *&Name,
|
||||||
|
MCContext &Ctx,
|
||||||
const GlobalValue *GV,
|
const GlobalValue *GV,
|
||||||
const TargetData &TD) {
|
const TargetData &TD) {
|
||||||
SmallString<128> NameStr(Name.begin(), Name.end());
|
SmallString<128> NameStr(Name->getName().begin(), Name->getName().end());
|
||||||
DecorateCygMingName(NameStr, GV, TD);
|
DecorateCygMingName(NameStr, GV, TD);
|
||||||
Name.assign(NameStr.begin(), NameStr.end());
|
|
||||||
|
Name = Ctx.GetOrCreateSymbol(NameStr.str());
|
||||||
}
|
}
|
||||||
|
@ -46,8 +46,8 @@ public:
|
|||||||
~X86COFFMachineModuleInfo();
|
~X86COFFMachineModuleInfo();
|
||||||
|
|
||||||
|
|
||||||
void DecorateCygMingName(std::string &Name, const GlobalValue *GV,
|
void DecorateCygMingName(const MCSymbol* &Name, MCContext &Ctx,
|
||||||
const TargetData &TD);
|
const GlobalValue *GV, const TargetData &TD);
|
||||||
void DecorateCygMingName(SmallVectorImpl<char> &Name, const GlobalValue *GV,
|
void DecorateCygMingName(SmallVectorImpl<char> &Name, const GlobalValue *GV,
|
||||||
const TargetData &TD);
|
const TargetData &TD);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user