diff options
author | Chris Lattner <sabre@nondot.org> | 2009-07-31 17:42:42 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-07-31 17:42:42 +0000 |
commit | f26e03bc7e30162197641406e37e662a15d80f7e (patch) | |
tree | 2c109dc8f8764abb040f71fe14215b9116d11922 /lib | |
parent | 5defacc6e605f4651c6300237cef8e9bb2eb6d0e (diff) | |
download | llvm-f26e03bc7e30162197641406e37e662a15d80f7e.tar.gz llvm-f26e03bc7e30162197641406e37e662a15d80f7e.tar.bz2 llvm-f26e03bc7e30162197641406e37e662a15d80f7e.tar.xz |
refactor section construction in TLOF to be through an explicit
initialize method, which can be called when an MCContext is available.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77687 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 4 | ||||
-rw-r--r-- | lib/CodeGen/ELFWriter.cpp | 8 | ||||
-rw-r--r-- | lib/CodeGen/ELFWriter.h | 3 | ||||
-rw-r--r-- | lib/Target/ARM/ARMISelLowering.cpp | 2 | ||||
-rw-r--r-- | lib/Target/PowerPC/PPCISelLowering.cpp | 2 | ||||
-rw-r--r-- | lib/Target/TargetLoweringObjectFile.cpp | 13 | ||||
-rw-r--r-- | lib/Target/X86/X86ISelLowering.cpp | 2 |
7 files changed, 24 insertions, 10 deletions
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 441f8057c8..7106c6ade8 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -173,6 +173,10 @@ void AsmPrinter::getAnalysisUsage(AnalysisUsage &AU) const { } bool AsmPrinter::doInitialization(Module &M) { + // Initialize TargetLoweringObjectFile. + const_cast<TargetLoweringObjectFile&>(getObjFileLowering()) + .Initialize(OutContext, TM); + Mang = new Mangler(M, TAI->getGlobalPrefix(), TAI->getPrivateGlobalPrefix(), TAI->getLinkerPrivateGlobalPrefix()); diff --git a/lib/CodeGen/ELFWriter.cpp b/lib/CodeGen/ELFWriter.cpp index bf2d0bd94c..230c5ac4be 100644 --- a/lib/CodeGen/ELFWriter.cpp +++ b/lib/CodeGen/ELFWriter.cpp @@ -42,6 +42,7 @@ #include "llvm/CodeGen/ObjectCodeEmitter.h" #include "llvm/CodeGen/MachineCodeEmitter.h" #include "llvm/CodeGen/MachineConstantPool.h" +#include "llvm/MC/MCContext.h" #include "llvm/Target/TargetAsmInfo.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetELFWriterInfo.h" @@ -73,6 +74,7 @@ ObjectCodeEmitter *llvm::AddELFWriter(PassManagerBase &PM, ELFWriter::ELFWriter(raw_ostream &o, TargetMachine &tm) : MachineFunctionPass(&ID), O(o), TM(tm), + OutContext(*new MCContext()), is64Bit(TM.getTargetData()->getPointerSizeInBits() == 64), isLittleEndian(TM.getTargetData()->isLittleEndian()), ElfHdr(isLittleEndian, is64Bit) { @@ -89,11 +91,17 @@ ELFWriter::ELFWriter(raw_ostream &o, TargetMachine &tm) ELFWriter::~ELFWriter() { delete ElfCE; + delete &OutContext; } // doInitialization - Emit the file header and all of the global variables for // the module to the ELF file. bool ELFWriter::doInitialization(Module &M) { + // Initialize TargetLoweringObjectFile. + const TargetLoweringObjectFile &TLOF = + TM.getTargetLowering()->getObjFileLowering(); + const_cast<TargetLoweringObjectFile&>(TLOF).Initialize(OutContext, TM); + Mang = new Mangler(M); // ELF Header diff --git a/lib/CodeGen/ELFWriter.h b/lib/CodeGen/ELFWriter.h index b8bfa7d2a0..ebcfe35eba 100644 --- a/lib/CodeGen/ELFWriter.h +++ b/lib/CodeGen/ELFWriter.h @@ -35,6 +35,7 @@ namespace llvm { class TargetELFWriterInfo; class raw_ostream; class SectionKind; + class MCContext; typedef std::vector<ELFSym*>::iterator ELFSymIter; typedef std::vector<ELFSection*>::iterator ELFSectionIter; @@ -65,6 +66,8 @@ namespace llvm { /// Target machine description. TargetMachine &TM; + MCContext &OutContext; + /// Target Elf Writer description. const TargetELFWriterInfo *TEW; diff --git a/lib/Target/ARM/ARMISelLowering.cpp b/lib/Target/ARM/ARMISelLowering.cpp index 41ad069252..23e1037baa 100644 --- a/lib/Target/ARM/ARMISelLowering.cpp +++ b/lib/Target/ARM/ARMISelLowering.cpp @@ -106,7 +106,7 @@ void ARMTargetLowering::addQRTypeForNEON(MVT VT) { static TargetLoweringObjectFile *createTLOF(TargetMachine &TM) { if (TM.getSubtarget<ARMSubtarget>().isTargetDarwin()) - return new TargetLoweringObjectFileMachO(TM); + return new TargetLoweringObjectFileMachO(); return new TargetLoweringObjectFileELF(true); } diff --git a/lib/Target/PowerPC/PPCISelLowering.cpp b/lib/Target/PowerPC/PPCISelLowering.cpp index bfe0f6f2b0..9b0dd1f782 100644 --- a/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/lib/Target/PowerPC/PPCISelLowering.cpp @@ -59,7 +59,7 @@ cl::desc("enable preincrement load/store generation on PPC (experimental)"), static TargetLoweringObjectFile *CreateTLOF(const PPCTargetMachine &TM) { if (TM.getSubtargetImpl()->isDarwin()) - return new TargetLoweringObjectFileMachO(TM); + return new TargetLoweringObjectFileMachO(); return new TargetLoweringObjectFileELF(false, true); } diff --git a/lib/Target/TargetLoweringObjectFile.cpp b/lib/Target/TargetLoweringObjectFile.cpp index a42911d92b..caeac30ef8 100644 --- a/lib/Target/TargetLoweringObjectFile.cpp +++ b/lib/Target/TargetLoweringObjectFile.cpp @@ -261,10 +261,8 @@ getOrCreateSection(const char *Name, bool isDirective, // ELF //===----------------------------------------------------------------------===// -TargetLoweringObjectFileELF::TargetLoweringObjectFileELF(bool atIsCommentChar, - bool HasCrazyBSS) - : AtIsCommentChar(atIsCommentChar) { - +void TargetLoweringObjectFileELF::Initialize(MCContext &Ctx, + const TargetMachine &TM) { if (!HasCrazyBSS) BSSSection_ = getOrCreateSection("\t.bss", true, SectionKind::BSS); else @@ -480,8 +478,8 @@ getSectionForMergeableConstant(SectionKind Kind) const { // MachO //===----------------------------------------------------------------------===// -TargetLoweringObjectFileMachO:: -TargetLoweringObjectFileMachO(const TargetMachine &TM) { +void TargetLoweringObjectFileMachO::Initialize(MCContext &Ctx, + const TargetMachine &TM) { TextSection = getOrCreateSection("\t.text", true, SectionKind::Text); DataSection = getOrCreateSection("\t.data", true, SectionKind::DataRel); @@ -592,7 +590,8 @@ getSectionForMergeableConstant(SectionKind Kind) const { // COFF //===----------------------------------------------------------------------===// -TargetLoweringObjectFileCOFF::TargetLoweringObjectFileCOFF() { +void TargetLoweringObjectFileCOFF::Initialize(MCContext &Ctx, + const TargetMachine &TM) { TextSection = getOrCreateSection("\t.text", true, SectionKind::Text); DataSection = getOrCreateSection("\t.data", true, SectionKind::DataRel); } diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index bbc6ba5e16..70b1619425 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -55,7 +55,7 @@ static TargetLoweringObjectFile *createTLOF(X86TargetMachine &TM) { switch (TM.getSubtarget<X86Subtarget>().TargetType) { default: llvm_unreachable("unknown subtarget type"); case X86Subtarget::isDarwin: - return new TargetLoweringObjectFileMachO(TM); + return new TargetLoweringObjectFileMachO(); case X86Subtarget::isELF: return new TargetLoweringObjectFileELF(); case X86Subtarget::isMingw: |