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
This commit is contained in:
Chris Lattner
2009-07-28 03:13:23 +00:00
parent 7988aff079
commit f0144127b9
64 changed files with 1655 additions and 1402 deletions

View File

@@ -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) {