[llvm-commits] [llvm] r78002 - in /llvm/trunk: include/llvm/Target/TargetLoweringObjectFile.h lib/Target/TargetLoweringObjectFile.cpp lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
Chris Lattner
sabre at nondot.org
Mon Aug 3 14:53:27 PDT 2009
Author: lattner
Date: Mon Aug 3 16:53:27 2009
New Revision: 78002
URL: http://llvm.org/viewvc/llvm-project?rev=78002&view=rev
Log:
Eliminate textual section switching from the x86 backend, one
more step towards "semantics sections"
Modified:
llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h
llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp
llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
Modified: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h?rev=78002&r1=78001&r2=78002&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h (original)
+++ llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h Mon Aug 3 16:53:27 2009
@@ -26,7 +26,6 @@
class Mangler;
class TargetMachine;
-
class TargetLoweringObjectFile {
MCContext *Ctx;
protected:
@@ -250,6 +249,11 @@
/// FIXME: REMOVE this (rdar://7071300)
virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
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 @@
virtual const MCSection *
SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
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
Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=78002&r1=78001&r2=78002&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original)
+++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Mon Aug 3 16:53:27 2009
@@ -532,6 +532,14 @@
// 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,
const TargetMachine &TM) {
TargetLoweringObjectFile::Initialize(Ctx, TM);
@@ -733,6 +741,11 @@
// COFF
//===----------------------------------------------------------------------===//
+const MCSection *TargetLoweringObjectFileCOFF::
+getCOFFSection(const char *Name, bool isDirective, SectionKind K) {
+ return getOrCreateSection(Name, isDirective, K);
+}
+
void TargetLoweringObjectFileCOFF::Initialize(MCContext &Ctx,
const TargetMachine &TM) {
TargetLoweringObjectFile::Initialize(Ctx, TM);
Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=78002&r1=78001&r2=78002&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Mon Aug 3 16:53:27 2009
@@ -899,8 +899,9 @@
}
if (Subtarget->isTargetDarwin()) {
- //TargetLoweringObjectFileMachO &TLOFMacho =
- // static_cast<TargetLoweringObjectFileMachO &>(getObjFileLowering());
+ // All darwin targets use mach-o.
+ TargetLoweringObjectFileMachO &TLOFMacho =
+ static_cast<TargetLoweringObjectFileMachO &>(getObjFileLowering());
// Add the (possibly multiple) personalities to the set of global value
// stubs. Only referenced functions get into the Personalities list.
@@ -916,8 +917,11 @@
// Output stubs for dynamically-linked functions
if (!FnStubs.empty()) {
- SwitchToDataSection("\t.section __IMPORT,__jump_table,symbol_stubs,"
- "self_modifying_code+pure_instructions,5", 0);
+ const MCSection *TheSection =
+ 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(),
E = FnStubs.end(); I != E; ++I)
O << I->getKeyData() << ":\n" << "\t.indirect_symbol " << I->second
@@ -927,8 +931,11 @@
// Output stubs for external and common global variables.
if (!GVStubs.empty()) {
- SwitchToDataSection(
- "\t.section __IMPORT,__pointers,non_lazy_symbol_pointers");
+ const MCSection *TheSection =
+ TLOFMacho.getMachOSection("\t.section __IMPORT,__pointers,"
+ "non_lazy_symbol_pointers", true,
+ SectionKind::getMetadata());
+ SwitchToSection(TheSection);
for (StringMap<std::string>::iterator I = GVStubs.begin(),
E = GVStubs.end(); I != E; ++I)
O << I->getKeyData() << ":\n\t.indirect_symbol "
@@ -963,16 +970,17 @@
// Output linker support code for dllexported globals on windows.
- if (!DLLExportedGVs.empty()) {
- SwitchToDataSection(".section .drectve");
+ if (!DLLExportedGVs.empty() || !DLLExportedFns.empty()) {
+ // 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(),
e = DLLExportedGVs.end(); i != e; ++i)
O << "\t.ascii \" -export:" << i->getKeyData() << ",data\"\n";
- }
-
- if (!DLLExportedFns.empty()) {
- SwitchToDataSection(".section .drectve");
for (StringSet<>::iterator i = DLLExportedFns.begin(),
e = DLLExportedFns.end();
More information about the llvm-commits
mailing list