diff options
author | Chris Lattner <sabre@nondot.org> | 2009-07-31 18:48:30 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-07-31 18:48:30 +0000 |
commit | e6ad12f8febebcdca8ea6b0e48014786267df1ea (patch) | |
tree | 96993fb5aee8978a97581a0f79f86c61b2e1005f /lib/Target | |
parent | 6e0ffed0fe15bcf041218ebff2a4de33a915aed4 (diff) | |
download | external_llvm-e6ad12f8febebcdca8ea6b0e48014786267df1ea.zip external_llvm-e6ad12f8febebcdca8ea6b0e48014786267df1ea.tar.gz external_llvm-e6ad12f8febebcdca8ea6b0e48014786267df1ea.tar.bz2 |
switch off of 'Section' onto MCSection. We're not properly using
MCSection subclasses yet, but this is a step in the right direction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77708 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
-rw-r--r-- | lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp | 3 | ||||
-rw-r--r-- | lib/Target/Alpha/AlphaISelLowering.cpp | 6 | ||||
-rw-r--r-- | lib/Target/PIC16/PIC16AsmPrinter.cpp | 12 | ||||
-rw-r--r-- | lib/Target/PIC16/PIC16ISelLowering.cpp | 2 | ||||
-rw-r--r-- | lib/Target/PIC16/PIC16TargetObjectFile.cpp | 67 | ||||
-rw-r--r-- | lib/Target/PIC16/PIC16TargetObjectFile.h | 44 | ||||
-rw-r--r-- | lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp | 15 | ||||
-rw-r--r-- | lib/Target/TargetLoweringObjectFile.cpp | 47 | ||||
-rw-r--r-- | lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp | 3 | ||||
-rw-r--r-- | lib/Target/XCore/XCoreISelLowering.cpp | 3 | ||||
-rw-r--r-- | lib/Target/XCore/XCoreTargetObjectFile.cpp | 10 | ||||
-rw-r--r-- | lib/Target/XCore/XCoreTargetObjectFile.h | 3 |
12 files changed, 111 insertions, 104 deletions
diff --git a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp index 5feafb4..eb39846 100644 --- a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp +++ b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp @@ -27,6 +27,7 @@ #include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineJumpTableInfo.h" +#include "llvm/MC/MCSection.h" #include "llvm/Target/TargetAsmInfo.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetLoweringObjectFile.h" @@ -1159,7 +1160,7 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) { if (Subtarget->isTargetELF()) O << "\t.type " << name << ",%object\n"; - const Section *TheSection = + const MCSection *TheSection = getObjFileLowering().SectionForGlobal(GVar, Mang, TM); SwitchToSection(TheSection); diff --git a/lib/Target/Alpha/AlphaISelLowering.cpp b/lib/Target/Alpha/AlphaISelLowering.cpp index f7a38c2..c5f24dc 100644 --- a/lib/Target/Alpha/AlphaISelLowering.cpp +++ b/lib/Target/Alpha/AlphaISelLowering.cpp @@ -31,14 +31,16 @@ #include "llvm/Support/raw_ostream.h" using namespace llvm; - +namespace { class TargetLoweringObjectFileAlpha : public TargetLoweringObjectFile { public: - TargetLoweringObjectFileAlpha() { + void Initialize(MCContext &Ctx, const TargetMachine &TM) { + TargetLoweringObjectFile::Initialize(Ctx, TM); TextSection = getOrCreateSection("_text", true, SectionKind::Text); DataSection = getOrCreateSection("_data", true, SectionKind::DataRel); } }; +} diff --git a/lib/Target/PIC16/PIC16AsmPrinter.cpp b/lib/Target/PIC16/PIC16AsmPrinter.cpp index 743ce9f..604d105 100644 --- a/lib/Target/PIC16/PIC16AsmPrinter.cpp +++ b/lib/Target/PIC16/PIC16AsmPrinter.cpp @@ -18,15 +18,15 @@ #include "llvm/Function.h" #include "llvm/Module.h" #include "llvm/CodeGen/DwarfWriter.h" -#include "llvm/Support/FormattedStream.h" #include "llvm/CodeGen/MachineFrameInfo.h" -#include "llvm/Support/Mangler.h" -#include "llvm/Support/ErrorHandling.h" #include "llvm/CodeGen/DwarfWriter.h" #include "llvm/CodeGen/MachineModuleInfo.h" +#include "llvm/MC/MCSection.h" #include "llvm/Target/TargetRegistry.h" #include "llvm/Target/TargetLoweringObjectFile.h" - +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/FormattedStream.h" +#include "llvm/Support/Mangler.h" using namespace llvm; #include "PIC16GenAsmWriter.inc" @@ -71,7 +71,7 @@ bool PIC16AsmPrinter::runOnMachineFunction(MachineFunction &MF) { std::string T = PAN::getCodeSectionName(CurrentFnName); const char *codeSection = T.c_str(); - const Section *fCodeSection = + const MCSection *fCodeSection = getObjFileLowering().getOrCreateSection(codeSection, false, SectionKind::Text); // Start the Code Section. @@ -348,7 +348,7 @@ void PIC16AsmPrinter::EmitFunctionFrame(MachineFunction &MF) { std::string T = PAN::getFrameSectionName(CurrentFnName); const char *SectionName = T.c_str(); - const Section *fPDataSection = + const MCSection *fPDataSection = getObjFileLowering().getOrCreateSection(SectionName, false, SectionKind::DataRel); SwitchToSection(fPDataSection); diff --git a/lib/Target/PIC16/PIC16ISelLowering.cpp b/lib/Target/PIC16/PIC16ISelLowering.cpp index 811bb1e..87379a6 100644 --- a/lib/Target/PIC16/PIC16ISelLowering.cpp +++ b/lib/Target/PIC16/PIC16ISelLowering.cpp @@ -143,7 +143,7 @@ static const char *getStdLibCallName(unsigned opcode) { // PIC16TargetLowering Constructor. PIC16TargetLowering::PIC16TargetLowering(PIC16TargetMachine &TM) - : TargetLowering(TM, new PIC16TargetObjectFile(TM)), TmpSize(0) { + : TargetLowering(TM, new PIC16TargetObjectFile()), TmpSize(0) { Subtarget = &TM.getSubtarget<PIC16Subtarget>(); diff --git a/lib/Target/PIC16/PIC16TargetObjectFile.cpp b/lib/Target/PIC16/PIC16TargetObjectFile.cpp index feec2fd..5a2d4d8 100644 --- a/lib/Target/PIC16/PIC16TargetObjectFile.cpp +++ b/lib/Target/PIC16/PIC16TargetObjectFile.cpp @@ -12,11 +12,13 @@ #include "PIC16TargetMachine.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" +#include "llvm/MC/MCSection.h" using namespace llvm; - -PIC16TargetObjectFile::PIC16TargetObjectFile(const PIC16TargetMachine &tm) -: TM (tm) { +void PIC16TargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &tm){ + TargetLoweringObjectFile::Initialize(Ctx, tm); + TM = &tm; + BSSSection_ = getOrCreateSection("udata.# UDATA", false, SectionKind::BSS); ReadOnlySection = getOrCreateSection("romdata.# ROMDATA", false, SectionKind::ReadOnly); @@ -26,9 +28,7 @@ PIC16TargetObjectFile::PIC16TargetObjectFile(const PIC16TargetMachine &tm) // in BeginModule, and gpasm cribbs for that .text symbol. TextSection = getOrCreateSection("", true, SectionKind::Text); - - PIC16Section *ROSection = new PIC16Section(ReadOnlySection); - ROSections.push_back(ROSection); + ROSections.push_back(new PIC16Section(ReadOnlySection)); // FIXME: I don't know what the classification of these sections really is. ExternalVarDecls = new PIC16Section(getOrCreateSection("ExternalVarDecls", @@ -40,14 +40,14 @@ PIC16TargetObjectFile::PIC16TargetObjectFile(const PIC16TargetMachine &tm) } -const Section * +const MCSection * PIC16TargetObjectFile::getBSSSectionForGlobal(const GlobalVariable *GV) const { assert(GV->hasInitializer() && "This global doesn't need space"); Constant *C = GV->getInitializer(); assert(C->isNullValue() && "Unitialized globals has non-zero initializer"); // Find how much space this global needs. - const TargetData *TD = TM.getTargetData(); + const TargetData *TD = TM->getTargetData(); const Type *Ty = C->getType(); unsigned ValSize = TD->getTypeAllocSize(Ty); @@ -64,9 +64,9 @@ PIC16TargetObjectFile::getBSSSectionForGlobal(const GlobalVariable *GV) const { // No BSS section spacious enough was found. Crate a new one. if (!FoundBSS) { std::string name = PAN::getUdataSectionName(BSSSections.size()); - const Section *NewSection = getOrCreateSection(name.c_str(), false, - // FIXME. - SectionKind::Metadata); + const MCSection *NewSection = getOrCreateSection(name.c_str(), false, + // FIXME. + SectionKind::Metadata); FoundBSS = new PIC16Section(NewSection); @@ -80,7 +80,7 @@ PIC16TargetObjectFile::getBSSSectionForGlobal(const GlobalVariable *GV) const { return FoundBSS->S_; } -const Section * +const MCSection * PIC16TargetObjectFile::getIDATASectionForGlobal(const GlobalVariable *GV) const{ assert(GV->hasInitializer() && "This global doesn't need space"); Constant *C = GV->getInitializer(); @@ -89,7 +89,7 @@ PIC16TargetObjectFile::getIDATASectionForGlobal(const GlobalVariable *GV) const{ "can split initialized RAM data only"); // Find how much space this global needs. - const TargetData *TD = TM.getTargetData(); + const TargetData *TD = TM->getTargetData(); const Type *Ty = C->getType(); unsigned ValSize = TD->getTypeAllocSize(Ty); @@ -106,8 +106,7 @@ PIC16TargetObjectFile::getIDATASectionForGlobal(const GlobalVariable *GV) const{ // No IDATA section spacious enough was found. Crate a new one. if (!FoundIDATA) { std::string name = PAN::getIdataSectionName(IDATASections.size()); - const Section *NewSection = getOrCreateSection(name.c_str(), - false, + const MCSection *NewSection = getOrCreateSection(name.c_str(), false, // FIXME. SectionKind::Metadata); @@ -125,7 +124,7 @@ PIC16TargetObjectFile::getIDATASectionForGlobal(const GlobalVariable *GV) const{ // Get the section for an automatic variable of a function. // For PIC16 they are globals only with mangled names. -const Section * +const MCSection * PIC16TargetObjectFile::getSectionForAuto(const GlobalVariable *GV) const { const std::string name = PAN::getSectionNameForSym(GV->getName()); @@ -142,10 +141,10 @@ PIC16TargetObjectFile::getSectionForAuto(const GlobalVariable *GV) const { // No Auto section was found. Crate a new one. if (!FoundAutoSec) { - const Section *NewSection = getOrCreateSection(name.c_str(), - // FIXME. - false, - SectionKind::Metadata); + const MCSection *NewSection = getOrCreateSection(name.c_str(), + // FIXME. + false, + SectionKind::Metadata); FoundAutoSec = new PIC16Section(NewSection); @@ -162,7 +161,7 @@ PIC16TargetObjectFile::getSectionForAuto(const GlobalVariable *GV) const { // Override default implementation to put the true globals into // multiple data sections if required. -const Section* +const MCSection * PIC16TargetObjectFile::SelectSectionForGlobal(const GlobalValue *GV1, SectionKind Kind, Mangler *Mang, @@ -224,7 +223,7 @@ PIC16TargetObjectFile::~PIC16TargetObjectFile() { /// getSpecialCasedSectionGlobals - Allow the target to completely override /// section assignment of a global. -const Section * +const MCSection * PIC16TargetObjectFile::getSpecialCasedSectionGlobals(const GlobalValue *GV, Mangler *Mang, SectionKind Kind) const { @@ -250,7 +249,7 @@ PIC16TargetObjectFile::getSpecialCasedSectionGlobals(const GlobalValue *GV, // Create a new section for global variable. If Addr is given then create // section at that address else create by name. -const Section * +const MCSection * PIC16TargetObjectFile::CreateSectionForGlobal(const GlobalVariable *GV, Mangler *Mang, const std::string &Addr) const { @@ -268,11 +267,11 @@ PIC16TargetObjectFile::CreateSectionForGlobal(const GlobalVariable *GV, return CreateROSectionForGlobal(GV, Addr); // Else let the default implementation take care of it. - return TargetLoweringObjectFile::SectionForGlobal(GV, Mang, TM); + return TargetLoweringObjectFile::SectionForGlobal(GV, Mang, *TM); } // Create uninitialized section for a variable. -const Section * +const MCSection * PIC16TargetObjectFile::CreateBSSSectionForGlobal(const GlobalVariable *GV, std::string Addr) const { assert(GV->hasInitializer() && "This global doesn't need space"); @@ -297,8 +296,8 @@ PIC16TargetObjectFile::CreateBSSSectionForGlobal(const GlobalVariable *GV, PIC16Section *NewBSS = FoundBSS; if (NewBSS == NULL) { - const Section *NewSection = getOrCreateSection(Name.c_str(), - false, SectionKind::BSS); + const MCSection *NewSection = getOrCreateSection(Name.c_str(), false, + SectionKind::BSS); NewBSS = new PIC16Section(NewSection); BSSSections.push_back(NewBSS); } @@ -314,14 +313,14 @@ PIC16TargetObjectFile::CreateBSSSectionForGlobal(const GlobalVariable *GV, // Get rom section for a variable. Currently there can be only one rom section // unless a variable explicitly requests a section. -const Section * +const MCSection * PIC16TargetObjectFile::getROSectionForGlobal(const GlobalVariable *GV) const { ROSections[0]->Items.push_back(GV); return ROSections[0]->S_; } // Create initialized data section for a variable. -const Section * +const MCSection * PIC16TargetObjectFile::CreateIDATASectionForGlobal(const GlobalVariable *GV, std::string Addr) const { assert(GV->hasInitializer() && "This global doesn't need space"); @@ -349,8 +348,7 @@ PIC16TargetObjectFile::CreateIDATASectionForGlobal(const GlobalVariable *GV, PIC16Section *NewIDATASec = FoundIDATASec; if (NewIDATASec == NULL) { - const Section *NewSection = getOrCreateSection(Name.c_str(), - false, + const MCSection *NewSection = getOrCreateSection(Name.c_str(), false, // FIXME: SectionKind::Metadata); NewIDATASec = new PIC16Section(NewSection); @@ -365,7 +363,7 @@ PIC16TargetObjectFile::CreateIDATASectionForGlobal(const GlobalVariable *GV, } // Create a section in rom for a variable. -const Section * +const MCSection * PIC16TargetObjectFile::CreateROSectionForGlobal(const GlobalVariable *GV, std::string Addr) const { assert(GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE && @@ -390,9 +388,8 @@ PIC16TargetObjectFile::CreateROSectionForGlobal(const GlobalVariable *GV, PIC16Section *NewRomSec = FoundROSec; if (NewRomSec == NULL) { - const Section *NewSection = getOrCreateSection(Name.c_str(), - false, - SectionKind::ReadOnly); + const MCSection *NewSection = getOrCreateSection(Name.c_str(), false, + SectionKind::ReadOnly); NewRomSec = new PIC16Section(NewSection); ROSections.push_back(NewRomSec); } diff --git a/lib/Target/PIC16/PIC16TargetObjectFile.h b/lib/Target/PIC16/PIC16TargetObjectFile.h index 336730d..c296954 100644 --- a/lib/Target/PIC16/PIC16TargetObjectFile.h +++ b/lib/Target/PIC16/PIC16TargetObjectFile.h @@ -29,12 +29,12 @@ namespace llvm { /// FIXME: Reimplement by inheriting from MCSection. /// struct PIC16Section { - const Section *S_; // Connection to actual Section. + const MCSection *S_; // Connection to actual Section. unsigned Size; // Total size of the objects contained. bool SectionPrinted; std::vector<const GlobalVariable*> Items; - PIC16Section(const Section *s) { + PIC16Section(const MCSection *s) { S_ = s; Size = 0; SectionPrinted = false; @@ -44,7 +44,7 @@ namespace llvm { }; class PIC16TargetObjectFile : public TargetLoweringObjectFile { - const PIC16TargetMachine &TM; + const TargetMachine *TM; public: mutable std::vector<PIC16Section*> BSSSections; mutable std::vector<PIC16Section*> IDATASections; @@ -53,34 +53,36 @@ namespace llvm { mutable PIC16Section *ExternalVarDecls; mutable PIC16Section *ExternalVarDefs; - PIC16TargetObjectFile(const PIC16TargetMachine &TM); ~PIC16TargetObjectFile(); + void Initialize(MCContext &Ctx, const TargetMachine &TM); + + /// getSpecialCasedSectionGlobals - Allow the target to completely override /// section assignment of a global. - virtual const Section * + virtual const MCSection * getSpecialCasedSectionGlobals(const GlobalValue *GV, Mangler *Mang, SectionKind Kind) const; - virtual const Section *SelectSectionForGlobal(const GlobalValue *GV, - SectionKind Kind, - Mangler *Mang, - const TargetMachine&) const; + virtual const MCSection *SelectSectionForGlobal(const GlobalValue *GV, + SectionKind Kind, + Mangler *Mang, + const TargetMachine&) const; private: std::string getSectionNameForSym(const std::string &Sym) const; - const Section *getBSSSectionForGlobal(const GlobalVariable *GV) const; - const Section *getIDATASectionForGlobal(const GlobalVariable *GV) const; - const Section *getSectionForAuto(const GlobalVariable *GV) const; - const Section *CreateBSSSectionForGlobal(const GlobalVariable *GV, - std::string Addr = "") const; - const Section *CreateIDATASectionForGlobal(const GlobalVariable *GV, + const MCSection *getBSSSectionForGlobal(const GlobalVariable *GV) const; + const MCSection *getIDATASectionForGlobal(const GlobalVariable *GV) const; + const MCSection *getSectionForAuto(const GlobalVariable *GV) const; + const MCSection *CreateBSSSectionForGlobal(const GlobalVariable *GV, std::string Addr = "") const; - const Section *getROSectionForGlobal(const GlobalVariable *GV) const; - const Section *CreateROSectionForGlobal(const GlobalVariable *GV, - std::string Addr = "") const; - const Section *CreateSectionForGlobal(const GlobalVariable *GV, - Mangler *Mang, - const std::string &Addr = "") const; + const MCSection *CreateIDATASectionForGlobal(const GlobalVariable *GV, + std::string Addr = "") const; + const MCSection *getROSectionForGlobal(const GlobalVariable *GV) const; + const MCSection *CreateROSectionForGlobal(const GlobalVariable *GV, + std::string Addr = "") const; + const MCSection *CreateSectionForGlobal(const GlobalVariable *GV, + Mangler *Mang, + const std::string &Addr = "") const; public: void SetSectionForGVs(Module &M); const std::vector<PIC16Section*> &getBSSSections() const { diff --git a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp index d01afb6..000c327 100644 --- a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp +++ b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp @@ -32,6 +32,13 @@ #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineInstrBuilder.h" +#include "llvm/MC/MCSection.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" +#include "llvm/Target/TargetRegistry.h" #include "llvm/Support/Mangler.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/CommandLine.h" @@ -39,12 +46,6 @@ #include "llvm/Support/ErrorHandling.h" #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" -#include "llvm/Target/TargetRegistry.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSet.h" @@ -892,7 +893,7 @@ void PPCDarwinAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) { unsigned Size = TD->getTypeAllocSize(Type); unsigned Align = TD->getPreferredAlignmentLog(GVar); - const Section *TheSection = + const MCSection *TheSection = getObjFileLowering().SectionForGlobal(GVar, Mang, TM); SwitchToSection(TheSection); diff --git a/lib/Target/TargetLoweringObjectFile.cpp b/lib/Target/TargetLoweringObjectFile.cpp index caeac30..36fda0b 100644 --- a/lib/Target/TargetLoweringObjectFile.cpp +++ b/lib/Target/TargetLoweringObjectFile.cpp @@ -16,10 +16,12 @@ #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/GlobalVariable.h" -#include "llvm/Support/Mangler.h" +#include "llvm/MC/MCContext.h" +#include "llvm/MC/MCSection.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetOptions.h" +#include "llvm/Support/Mangler.h" #include "llvm/ADT/StringExtras.h" using namespace llvm; @@ -27,7 +29,7 @@ using namespace llvm; // Generic Code //===----------------------------------------------------------------------===// -TargetLoweringObjectFile::TargetLoweringObjectFile() { +TargetLoweringObjectFile::TargetLoweringObjectFile() : Ctx(0) { TextSection = 0; DataSection = 0; BSSSection_ = 0; @@ -176,7 +178,7 @@ static SectionKind::Kind SectionKindForGlobal(const GlobalValue *GV, /// SectionForGlobal - This method computes the appropriate section to emit /// the specified global variable or function definition. This should not /// be passed external (or available externally) globals. -const Section *TargetLoweringObjectFile:: +const MCSection *TargetLoweringObjectFile:: SectionForGlobal(const GlobalValue *GV, Mangler *Mang, const TargetMachine &TM) const { assert(!GV->isDeclaration() && !GV->hasAvailableExternallyLinkage() && @@ -192,7 +194,7 @@ SectionForGlobal(const GlobalValue *GV, Mangler *Mang, if (GV->hasSection()) { // If the target has special section hacks for specifically named globals, // return them now. - if (const Section *TS = getSpecialCasedSectionGlobals(GV, Mang, Kind)) + if (const MCSection *TS = getSpecialCasedSectionGlobals(GV, Mang, Kind)) return TS; // If the target has magic semantics for certain section names, make sure to @@ -209,7 +211,7 @@ SectionForGlobal(const GlobalValue *GV, Mangler *Mang, } // Lame default implementation. Calculate the section name for global. -const Section* +const MCSection * TargetLoweringObjectFile::SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, @@ -231,7 +233,7 @@ TargetLoweringObjectFile::SelectSectionForGlobal(const GlobalValue *GV, /// getSectionForMergableConstant - Given a mergable constant with the /// specified size and relocation information, return a section that it /// should be placed in. -const Section * +const MCSection * TargetLoweringObjectFile:: getSectionForMergeableConstant(SectionKind Kind) const { if (Kind.isReadOnly() && ReadOnlySection != 0) @@ -241,18 +243,13 @@ getSectionForMergeableConstant(SectionKind Kind) const { } -const Section *TargetLoweringObjectFile:: +const MCSection *TargetLoweringObjectFile:: getOrCreateSection(const char *Name, bool isDirective, SectionKind::Kind Kind) const { - Section &S = Sections[Name]; - - // This is newly-created section, set it up properly. - if (S.Name.empty()) { - S.Kind = SectionKind::get(Kind, false /*weak*/, !isDirective); - S.Name = Name; - } - - return &S; + if (MCSection *S = Ctx->GetSection(Name)) + return S; + SectionKind K = SectionKind::get(Kind, false /*weak*/, !isDirective); + return MCSectionWithKind::Create(Name, K, *Ctx); } @@ -263,6 +260,7 @@ getOrCreateSection(const char *Name, bool isDirective, void TargetLoweringObjectFileELF::Initialize(MCContext &Ctx, const TargetMachine &TM) { + TargetLoweringObjectFile::Initialize(Ctx, TM); if (!HasCrazyBSS) BSSSection_ = getOrCreateSection("\t.bss", true, SectionKind::BSS); else @@ -401,7 +399,7 @@ static const char *getSectionPrefixForUniqueGlobal(SectionKind Kind) { return ".gnu.linkonce.d.rel.ro."; } -const Section *TargetLoweringObjectFileELF:: +const MCSection *TargetLoweringObjectFileELF:: SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, const TargetMachine &TM) const { @@ -458,7 +456,7 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, /// getSectionForMergeableConstant - Given a mergeable constant with the /// specified size and relocation information, return a section that it /// should be placed in. -const Section *TargetLoweringObjectFileELF:: +const MCSection *TargetLoweringObjectFileELF:: getSectionForMergeableConstant(SectionKind Kind) const { if (Kind.isMergeableConst4()) return MergeableConst4Section; @@ -480,6 +478,7 @@ getSectionForMergeableConstant(SectionKind Kind) const { void TargetLoweringObjectFileMachO::Initialize(MCContext &Ctx, const TargetMachine &TM) { + TargetLoweringObjectFile::Initialize(Ctx, TM); TextSection = getOrCreateSection("\t.text", true, SectionKind::Text); DataSection = getOrCreateSection("\t.data", true, SectionKind::DataRel); @@ -514,7 +513,7 @@ void TargetLoweringObjectFileMachO::Initialize(MCContext &Ctx, false, SectionKind::DataRel); } -const Section *TargetLoweringObjectFileMachO:: +const MCSection *TargetLoweringObjectFileMachO:: SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, const TargetMachine &TM) const { assert(!Kind.isThreadLocal() && "Darwin doesn't support TLS"); @@ -569,7 +568,7 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, return DataSection; } -const Section * +const MCSection * TargetLoweringObjectFileMachO:: getSectionForMergeableConstant(SectionKind Kind) const { // If this constant requires a relocation, we have to put it in the data @@ -592,6 +591,7 @@ getSectionForMergeableConstant(SectionKind Kind) const { void TargetLoweringObjectFileCOFF::Initialize(MCContext &Ctx, const TargetMachine &TM) { + TargetLoweringObjectFile::Initialize(Ctx, TM); TextSection = getOrCreateSection("\t.text", true, SectionKind::Text); DataSection = getOrCreateSection("\t.data", true, SectionKind::DataRel); } @@ -618,7 +618,7 @@ static const char *getCOFFSectionPrefixForUniqueGlobal(SectionKind Kind) { } -const Section *TargetLoweringObjectFileCOFF:: +const MCSection *TargetLoweringObjectFileCOFF:: SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, const TargetMachine &TM) const { assert(!Kind.isThreadLocal() && "Doesn't support TLS"); @@ -635,9 +635,8 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, if (Kind.isText()) return getTextSection(); - if (Kind.isBSS()) - if (const Section *S = BSSSection_) - return S; + if (Kind.isBSS() && BSSSection_ != 0) + return BSSSection_; if (Kind.isReadOnly() && ReadOnlySection != 0) return ReadOnlySection; diff --git a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp index c7b0e27..a4b36a0 100644 --- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp +++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp @@ -29,6 +29,7 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCInst.h" +#include "llvm/MC/MCSection.h" #include "llvm/MC/MCStreamer.h" #include "llvm/CodeGen/DwarfWriter.h" #include "llvm/CodeGen/MachineJumpTableInfo.h" @@ -783,7 +784,7 @@ void X86ATTAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) { if (Subtarget->isTargetELF()) O << "\t.type\t" << name << ",@object\n"; - const Section *TheSection = + const MCSection *TheSection = getObjFileLowering().SectionForGlobal(GVar, Mang, TM); SwitchToSection(TheSection); diff --git a/lib/Target/XCore/XCoreISelLowering.cpp b/lib/Target/XCore/XCoreISelLowering.cpp index 7873463..24d9f9b 100644 --- a/lib/Target/XCore/XCoreISelLowering.cpp +++ b/lib/Target/XCore/XCoreISelLowering.cpp @@ -56,8 +56,7 @@ getTargetNodeName(unsigned Opcode) const } XCoreTargetLowering::XCoreTargetLowering(XCoreTargetMachine &XTM) - : TargetLowering(XTM, - new XCoreTargetObjectFile(XTM.getSubtargetImpl()->isXS1A())), + : TargetLowering(XTM, new XCoreTargetObjectFile()), TM(XTM), Subtarget(*XTM.getSubtargetImpl()) { diff --git a/lib/Target/XCore/XCoreTargetObjectFile.cpp b/lib/Target/XCore/XCoreTargetObjectFile.cpp index 964ec82..c28a335 100644 --- a/lib/Target/XCore/XCoreTargetObjectFile.cpp +++ b/lib/Target/XCore/XCoreTargetObjectFile.cpp @@ -8,10 +8,14 @@ //===----------------------------------------------------------------------===// #include "XCoreTargetObjectFile.h" +#include "XCoreSubtarget.h" +#include "llvm/Target/TargetMachine.h" using namespace llvm; -XCoreTargetObjectFile::XCoreTargetObjectFile(bool isXS1A) { +void XCoreTargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &TM){ + TargetLoweringObjectFileELF::Initialize(Ctx, TM); + TextSection = getOrCreateSection("\t.text", true, SectionKind::Text); DataSection = getOrCreateSection("\t.dp.data", false, SectionKind::DataRel); BSSSection_ = getOrCreateSection("\t.dp.bss", false, SectionKind::BSS); @@ -22,11 +26,11 @@ XCoreTargetObjectFile::XCoreTargetObjectFile(bool isXS1A) { TLSDataSection = DataSection; TLSBSSSection = BSSSection_; - if (isXS1A) + if (TM.getSubtarget<XCoreSubtarget>().isXS1A()) // FIXME: Why is this writable ("datarel")??? ReadOnlySection = getOrCreateSection("\t.dp.rodata", false, SectionKind::DataRel); else ReadOnlySection = getOrCreateSection("\t.cp.rodata", false, SectionKind::ReadOnly); -} +}
\ No newline at end of file diff --git a/lib/Target/XCore/XCoreTargetObjectFile.h b/lib/Target/XCore/XCoreTargetObjectFile.h index af40e11..7efb990 100644 --- a/lib/Target/XCore/XCoreTargetObjectFile.h +++ b/lib/Target/XCore/XCoreTargetObjectFile.h @@ -16,8 +16,9 @@ namespace llvm { class XCoreTargetObjectFile : public TargetLoweringObjectFileELF { public: - XCoreTargetObjectFile(bool isXS1A); + void Initialize(MCContext &Ctx, const TargetMachine &TM); + // TODO: Classify globals as xcore wishes. }; } // end namespace llvm |