diff options
author | Chris Lattner <sabre@nondot.org> | 2009-07-28 03:13:23 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-07-28 03:13:23 +0000 |
commit | f0144127b98425d214e59e4a1a4b342b78e3642b (patch) | |
tree | cfcb5bc95b5b8060f71ee1b251f0f3e93fbfff2a /lib/Target/PowerPC | |
parent | 7988aff079c54583d7f4d0011ffcfa3d62ff6a85 (diff) | |
download | external_llvm-f0144127b98425d214e59e4a1a4b342b78e3642b.zip external_llvm-f0144127b98425d214e59e4a1a4b342b78e3642b.tar.gz external_llvm-f0144127b98425d214e59e4a1a4b342b78e3642b.tar.bz2 |
Rip all of the global variable lowering logic out of TargetAsmInfo. Since
it is highly specific to the object file that will be generated in the end,
this introduces a new TargetLoweringObjectFile interface that is implemented
for each of ELF/MachO/COFF/Alpha/PIC16 and XCore.
Though still is still a brutal and ugly refactoring, this is a major step
towards goodness.
This patch also:
1. fixes a bunch of dangling pointer problems in the PIC16 backend.
2. disables the TargetLowering copy ctor which PIC16 was accidentally using.
3. gets us closer to xcore having its own crazy target section flags and
pic16 not having to shadow sections with its own objects.
4. fixes wierdness where ELF targets would set CStringSection but not
CStringSection_. Factor the code better.
5. fixes some bugs in string lowering on ELF targets.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77294 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PowerPC')
-rw-r--r-- | lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp | 15 | ||||
-rw-r--r-- | lib/Target/PowerPC/PPCISelLowering.cpp | 10 | ||||
-rw-r--r-- | lib/Target/PowerPC/PPCTargetAsmInfo.cpp | 3 |
3 files changed, 17 insertions, 11 deletions
diff --git a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp index bc0a794..a1b0780 100644 --- a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp +++ b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp @@ -40,6 +40,7 @@ #include "llvm/Support/Compiler.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Target/TargetAsmInfo.h" +#include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetOptions.h" @@ -590,7 +591,7 @@ bool PPCLinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF) { // Print out labels for the function. const Function *F = MF.getFunction(); - SwitchToSection(TAI->SectionForGlobal(F)); + SwitchToSection(getObjFileLowering().SectionForGlobal(F, TM)); switch (F->getLinkage()) { default: llvm_unreachable("Unknown linkage type!"); @@ -639,7 +640,7 @@ bool PPCLinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF) { // Print out jump tables referenced by the function. EmitJumpTableInfo(MF.getJumpTableInfo(), MF); - SwitchToSection(TAI->SectionForGlobal(F)); + SwitchToSection(getObjFileLowering().SectionForGlobal(F, TM)); // Emit post-function debug information. DW->EndFunction(&MF); @@ -681,7 +682,7 @@ void PPCLinuxAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) { unsigned Size = TD->getTypeAllocSize(Type); unsigned Align = TD->getPreferredAlignmentLog(GVar); - SwitchToSection(TAI->SectionForGlobal(GVar)); + SwitchToSection(getObjFileLowering().SectionForGlobal(GVar, TM)); if (C->isNullValue() && /* FIXME: Verify correct */ !GVar->hasSection() && @@ -762,7 +763,7 @@ bool PPCDarwinAsmPrinter::runOnMachineFunction(MachineFunction &MF) { // Print out labels for the function. const Function *F = MF.getFunction(); - SwitchToSection(TAI->SectionForGlobal(F)); + SwitchToSection(getObjFileLowering().SectionForGlobal(F, TM)); switch (F->getLinkage()) { default: llvm_unreachable("Unknown linkage type!"); @@ -861,7 +862,7 @@ bool PPCDarwinAsmPrinter::doInitialization(Module &M) { SwitchToTextSection("\t.section __TEXT,__symbol_stub1,symbol_stubs," "pure_instructions,16"); } - SwitchToSection(TAI->getTextSection()); + SwitchToSection(getObjFileLowering().getTextSection()); return Result; } @@ -891,7 +892,7 @@ void PPCDarwinAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) { unsigned Size = TD->getTypeAllocSize(Type); unsigned Align = TD->getPreferredAlignmentLog(GVar); - const Section *TheSection = TAI->SectionForGlobal(GVar); + const Section *TheSection = getObjFileLowering().SectionForGlobal(GVar, TM); SwitchToSection(TheSection); if (C->isNullValue() && /* FIXME: Verify correct */ @@ -1051,7 +1052,7 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) { } if (!HiddenGVStubs.empty()) { - SwitchToSection(TAI->getDataSection()); + SwitchToSection(getObjFileLowering().getDataSection()); EmitAlignment(isPPC64 ? 3 : 2); for (StringMap<std::string>::iterator I = HiddenGVStubs.begin(), E = HiddenGVStubs.end(); I != E; ++I) { diff --git a/lib/Target/PowerPC/PPCISelLowering.cpp b/lib/Target/PowerPC/PPCISelLowering.cpp index 8beddd6..fa1989b 100644 --- a/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/lib/Target/PowerPC/PPCISelLowering.cpp @@ -31,6 +31,7 @@ #include "llvm/Intrinsics.h" #include "llvm/Support/MathExtras.h" #include "llvm/Target/TargetOptions.h" +#include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" @@ -56,8 +57,15 @@ static cl::opt<bool> EnablePPCPreinc("enable-ppc-preinc", cl::desc("enable preincrement load/store generation on PPC (experimental)"), cl::Hidden); +static TargetLoweringObjectFile *CreateTLOF(const PPCTargetMachine &TM) { + if (TM.getSubtargetImpl()->isDarwin()) + return new TargetLoweringObjectFileMachO(); + return new TargetLoweringObjectFileELF(false, true); +} + + PPCTargetLowering::PPCTargetLowering(PPCTargetMachine &TM) - : TargetLowering(TM), PPCSubTarget(*TM.getSubtargetImpl()) { + : TargetLowering(TM, CreateTLOF(TM)), PPCSubTarget(*TM.getSubtargetImpl()) { setPow2DivIsCheap(); diff --git a/lib/Target/PowerPC/PPCTargetAsmInfo.cpp b/lib/Target/PowerPC/PPCTargetAsmInfo.cpp index a56f965..5ddd120 100644 --- a/lib/Target/PowerPC/PPCTargetAsmInfo.cpp +++ b/lib/Target/PowerPC/PPCTargetAsmInfo.cpp @@ -70,9 +70,6 @@ PPCLinuxTargetAsmInfo::PPCLinuxTargetAsmInfo(const PPCTargetMachine &TM) : WeakRefDirective = "\t.weak\t"; BSSSection = "\t.section\t\".sbss\",\"aw\",@nobits"; - // PPC/Linux normally uses named section for BSS. - BSSSection_ = getOrCreateSection("\t.bss", true, SectionKind::BSS); - // Debug Information AbsoluteDebugSectionOffsets = true; SupportsDebugInformation = true; |