forked from OSchip/llvm-project
Eliminate textual section switching from the x86 backend, one
more step towards "semantics sections" llvm-svn: 78002
This commit is contained in:
parent
4d93a4f9d4
commit
d2c179c8f6
|
@ -26,7 +26,6 @@ namespace llvm {
|
||||||
class Mangler;
|
class Mangler;
|
||||||
class TargetMachine;
|
class TargetMachine;
|
||||||
|
|
||||||
|
|
||||||
class TargetLoweringObjectFile {
|
class TargetLoweringObjectFile {
|
||||||
MCContext *Ctx;
|
MCContext *Ctx;
|
||||||
protected:
|
protected:
|
||||||
|
@ -250,6 +249,11 @@ public:
|
||||||
/// FIXME: REMOVE this (rdar://7071300)
|
/// FIXME: REMOVE this (rdar://7071300)
|
||||||
virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
|
virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
|
||||||
Mangler *) const;
|
Mangler *) const;
|
||||||
|
|
||||||
|
/// getMachOSection - Return the MCSection for the specified mach-o section.
|
||||||
|
/// FIXME: Switch this to a semantic view eventually.
|
||||||
|
const MCSection *getMachOSection(const char *Name, bool isDirective,
|
||||||
|
SectionKind K);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -264,6 +268,11 @@ public:
|
||||||
virtual const MCSection *
|
virtual const MCSection *
|
||||||
SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
|
SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
|
||||||
Mangler *Mang, const TargetMachine &TM) const;
|
Mangler *Mang, const TargetMachine &TM) const;
|
||||||
|
|
||||||
|
/// getCOFFSection - Return the MCSection for the specified COFF section.
|
||||||
|
/// FIXME: Switch this to a semantic view eventually.
|
||||||
|
const MCSection *getCOFFSection(const char *Name, bool isDirective,
|
||||||
|
SectionKind K);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace llvm
|
} // end namespace llvm
|
||||||
|
|
|
@ -532,6 +532,14 @@ getSectionForConstant(SectionKind Kind) const {
|
||||||
// MachO
|
// MachO
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
const MCSection *TargetLoweringObjectFileMachO::
|
||||||
|
getMachOSection(const char *Name, bool isDirective, SectionKind K) {
|
||||||
|
// FOR NOW, Just forward.
|
||||||
|
return getOrCreateSection(Name, isDirective, K);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void TargetLoweringObjectFileMachO::Initialize(MCContext &Ctx,
|
void TargetLoweringObjectFileMachO::Initialize(MCContext &Ctx,
|
||||||
const TargetMachine &TM) {
|
const TargetMachine &TM) {
|
||||||
TargetLoweringObjectFile::Initialize(Ctx, TM);
|
TargetLoweringObjectFile::Initialize(Ctx, TM);
|
||||||
|
@ -733,6 +741,11 @@ shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler *Mang) const {
|
||||||
// COFF
|
// COFF
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
const MCSection *TargetLoweringObjectFileCOFF::
|
||||||
|
getCOFFSection(const char *Name, bool isDirective, SectionKind K) {
|
||||||
|
return getOrCreateSection(Name, isDirective, K);
|
||||||
|
}
|
||||||
|
|
||||||
void TargetLoweringObjectFileCOFF::Initialize(MCContext &Ctx,
|
void TargetLoweringObjectFileCOFF::Initialize(MCContext &Ctx,
|
||||||
const TargetMachine &TM) {
|
const TargetMachine &TM) {
|
||||||
TargetLoweringObjectFile::Initialize(Ctx, TM);
|
TargetLoweringObjectFile::Initialize(Ctx, TM);
|
||||||
|
|
|
@ -899,8 +899,9 @@ bool X86ATTAsmPrinter::doFinalization(Module &M) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Subtarget->isTargetDarwin()) {
|
if (Subtarget->isTargetDarwin()) {
|
||||||
//TargetLoweringObjectFileMachO &TLOFMacho =
|
// All darwin targets use mach-o.
|
||||||
// static_cast<TargetLoweringObjectFileMachO &>(getObjFileLowering());
|
TargetLoweringObjectFileMachO &TLOFMacho =
|
||||||
|
static_cast<TargetLoweringObjectFileMachO &>(getObjFileLowering());
|
||||||
|
|
||||||
// Add the (possibly multiple) personalities to the set of global value
|
// Add the (possibly multiple) personalities to the set of global value
|
||||||
// stubs. Only referenced functions get into the Personalities list.
|
// stubs. Only referenced functions get into the Personalities list.
|
||||||
|
@ -916,8 +917,11 @@ bool X86ATTAsmPrinter::doFinalization(Module &M) {
|
||||||
|
|
||||||
// Output stubs for dynamically-linked functions
|
// Output stubs for dynamically-linked functions
|
||||||
if (!FnStubs.empty()) {
|
if (!FnStubs.empty()) {
|
||||||
SwitchToDataSection("\t.section __IMPORT,__jump_table,symbol_stubs,"
|
const MCSection *TheSection =
|
||||||
"self_modifying_code+pure_instructions,5", 0);
|
TLOFMacho.getMachOSection("\t.section __IMPORT,__jump_table,symbol_stubs,"
|
||||||
|
"self_modifying_code+pure_instructions,5", true,
|
||||||
|
SectionKind::getMetadata());
|
||||||
|
SwitchToSection(TheSection);
|
||||||
for (StringMap<std::string>::iterator I = FnStubs.begin(),
|
for (StringMap<std::string>::iterator I = FnStubs.begin(),
|
||||||
E = FnStubs.end(); I != E; ++I)
|
E = FnStubs.end(); I != E; ++I)
|
||||||
O << I->getKeyData() << ":\n" << "\t.indirect_symbol " << I->second
|
O << I->getKeyData() << ":\n" << "\t.indirect_symbol " << I->second
|
||||||
|
@ -927,8 +931,11 @@ bool X86ATTAsmPrinter::doFinalization(Module &M) {
|
||||||
|
|
||||||
// Output stubs for external and common global variables.
|
// Output stubs for external and common global variables.
|
||||||
if (!GVStubs.empty()) {
|
if (!GVStubs.empty()) {
|
||||||
SwitchToDataSection(
|
const MCSection *TheSection =
|
||||||
"\t.section __IMPORT,__pointers,non_lazy_symbol_pointers");
|
TLOFMacho.getMachOSection("\t.section __IMPORT,__pointers,"
|
||||||
|
"non_lazy_symbol_pointers", true,
|
||||||
|
SectionKind::getMetadata());
|
||||||
|
SwitchToSection(TheSection);
|
||||||
for (StringMap<std::string>::iterator I = GVStubs.begin(),
|
for (StringMap<std::string>::iterator I = GVStubs.begin(),
|
||||||
E = GVStubs.end(); I != E; ++I)
|
E = GVStubs.end(); I != E; ++I)
|
||||||
O << I->getKeyData() << ":\n\t.indirect_symbol "
|
O << I->getKeyData() << ":\n\t.indirect_symbol "
|
||||||
|
@ -963,16 +970,17 @@ bool X86ATTAsmPrinter::doFinalization(Module &M) {
|
||||||
|
|
||||||
|
|
||||||
// Output linker support code for dllexported globals on windows.
|
// Output linker support code for dllexported globals on windows.
|
||||||
if (!DLLExportedGVs.empty()) {
|
if (!DLLExportedGVs.empty() || !DLLExportedFns.empty()) {
|
||||||
SwitchToDataSection(".section .drectve");
|
// dllexport symbols only exist on coff targets.
|
||||||
|
TargetLoweringObjectFileCOFF &TLOFMacho =
|
||||||
|
static_cast<TargetLoweringObjectFileCOFF&>(getObjFileLowering());
|
||||||
|
|
||||||
|
SwitchToSection(TLOFMacho.getCOFFSection(".section .drectve", true,
|
||||||
|
SectionKind::getMetadata()));
|
||||||
|
|
||||||
for (StringSet<>::iterator i = DLLExportedGVs.begin(),
|
for (StringSet<>::iterator i = DLLExportedGVs.begin(),
|
||||||
e = DLLExportedGVs.end(); i != e; ++i)
|
e = DLLExportedGVs.end(); i != e; ++i)
|
||||||
O << "\t.ascii \" -export:" << i->getKeyData() << ",data\"\n";
|
O << "\t.ascii \" -export:" << i->getKeyData() << ",data\"\n";
|
||||||
}
|
|
||||||
|
|
||||||
if (!DLLExportedFns.empty()) {
|
|
||||||
SwitchToDataSection(".section .drectve");
|
|
||||||
|
|
||||||
for (StringSet<>::iterator i = DLLExportedFns.begin(),
|
for (StringSet<>::iterator i = DLLExportedFns.begin(),
|
||||||
e = DLLExportedFns.end();
|
e = DLLExportedFns.end();
|
||||||
|
|
Loading…
Reference in New Issue