diff options
21 files changed, 190 insertions, 183 deletions
diff --git a/include/llvm/CodeGen/AsmPrinter.h b/include/llvm/CodeGen/AsmPrinter.h index 6cd2d8ea4f..e3d6074adc 100644 --- a/include/llvm/CodeGen/AsmPrinter.h +++ b/include/llvm/CodeGen/AsmPrinter.h @@ -34,10 +34,10 @@ namespace llvm { class MachineModuleInfo; class MCInst; class MCContext; + class MCSection; class MCStreamer; class DwarfWriter; class Mangler; - class Section; class TargetAsmInfo; class TargetLoweringObjectFile; class Type; @@ -113,7 +113,7 @@ namespace llvm { /// CurrentSection - The current section we are emitting to. This is /// controlled and used by the SwitchSection method. std::string CurrentSection; - const Section* CurrentSection_; + const MCSection *CurrentSection_; /// IsInTextSection - True if the current section we are emitting to is a /// text section. @@ -173,7 +173,7 @@ namespace llvm { /// SwitchToSection - Switch to the specified section of the executable if /// we are not already in it! - void SwitchToSection(const Section* NS); + void SwitchToSection(const MCSection *NS); /// getGlobalLinkName - Returns the asm/link name of of the specified /// global variable. Should be overridden by each target asm printer to diff --git a/include/llvm/MC/MCSection.h b/include/llvm/MC/MCSection.h index 32238586fd..06d7e6af1e 100644 --- a/include/llvm/MC/MCSection.h +++ b/include/llvm/MC/MCSection.h @@ -32,30 +32,35 @@ namespace llvm { void operator=(const MCSection&); // DO NOT IMPLEMENT protected: MCSection(const StringRef &Name, MCContext &Ctx); + // FIXME: HACK. + SectionKind Kind; public: virtual ~MCSection(); static MCSection *Create(const StringRef &Name, MCContext &Ctx); const std::string &getName() const { return Name; } + SectionKind getKind() const { return Kind; } }; /// MCSectionWithKind - This is used by targets that use the SectionKind enum /// to classify their sections. class MCSectionWithKind : public MCSection { - SectionKind Kind; MCSectionWithKind(const StringRef &Name, SectionKind K, MCContext &Ctx) - : MCSection(Name, Ctx), Kind(K) {} + : MCSection(Name, Ctx) { + Kind = K; + } public: static MCSectionWithKind *Create(const StringRef &Name, SectionKind K, MCContext &Ctx); - SectionKind getKind() const { return Kind; } }; + typedef MCSectionWithKind MCSectionELF; + } // end namespace llvm #endif diff --git a/include/llvm/Target/TargetAsmInfo.h b/include/llvm/Target/TargetAsmInfo.h index 97da9ab650..a1bb6aaa1a 100644 --- a/include/llvm/Target/TargetAsmInfo.h +++ b/include/llvm/Target/TargetAsmInfo.h @@ -16,7 +16,6 @@ #ifndef LLVM_TARGET_ASM_INFO_H #define LLVM_TARGET_ASM_INFO_H -#include "llvm/ADT/StringMap.h" #include "llvm/Support/DataTypes.h" #include <string> diff --git a/include/llvm/Target/TargetLoweringObjectFile.h b/include/llvm/Target/TargetLoweringObjectFile.h index 713b545bfd..feecaacfd2 100644 --- a/include/llvm/Target/TargetLoweringObjectFile.h +++ b/include/llvm/Target/TargetLoweringObjectFile.h @@ -15,12 +15,16 @@ #ifndef LLVM_TARGET_TARGETLOWERINGOBJECTFILE_H #define LLVM_TARGET_TARGETLOWERINGOBJECTFILE_H -// FIXME: Switch to MC. -#include "llvm/Target/TargetAsmInfo.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringMap.h" namespace llvm { + class MCSection; class MCContext; - + class GlobalValue; + class Mangler; + class TargetMachine; + /// SectionKind - This is a simple POD value that classifies the properties of /// a section. A global variable is classified into the deepest possible /// classification, and then the target maps them onto their sections based on @@ -199,60 +203,47 @@ public: } }; -class Section { -public: - - std::string Name; - SectionKind Kind; - - explicit Section() { } - Section(const std::string &N, SectionKind K) : Name(N), Kind(K) {} - const std::string &getName() const { return Name; } - SectionKind getKind() const { return Kind; } -}; - class TargetLoweringObjectFile { -private: - mutable StringMap<Section> Sections; + MCContext *Ctx; protected: TargetLoweringObjectFile(); /// TextSection - Section directive for standard text. /// - const Section *TextSection; // Defaults to ".text". + const MCSection *TextSection; // Defaults to ".text". /// DataSection - Section directive for standard data. /// - const Section *DataSection; // Defaults to ".data". + const MCSection *DataSection; // Defaults to ".data". // FIXME: SINK THESE. - const Section *BSSSection_; + const MCSection *BSSSection_; /// ReadOnlySection - This is the directive that is emitted to switch to a /// read-only section for constant data (e.g. data declared const, /// jump tables). - const Section *ReadOnlySection; // Defaults to NULL + const MCSection *ReadOnlySection; // Defaults to NULL /// TLSDataSection - Section directive for Thread Local data. /// - const Section *TLSDataSection; // Defaults to ".tdata". + const MCSection *TLSDataSection; // Defaults to ".tdata". /// TLSBSSSection - Section directive for Thread Local uninitialized data. /// Null if this target doesn't support a BSS section. /// - const Section *TLSBSSSection; // Defaults to ".tbss". + const MCSection *TLSBSSSection; // Defaults to ".tbss". - const Section *CStringSection_; + const MCSection *CStringSection_; public: // FIXME: NONPUB. - const Section *getOrCreateSection(const char *Name, - bool isDirective, - SectionKind::Kind K) const; + const MCSection *getOrCreateSection(const char *Name, + bool isDirective, + SectionKind::Kind K) const; public: virtual ~TargetLoweringObjectFile(); @@ -260,17 +251,19 @@ public: /// Initialize - this method must be called before any actual lowering is /// done. This specifies the current context for codegen, and gives the /// lowering implementations a chance to set up their default sections. - virtual void Initialize(MCContext &Ctx, const TargetMachine &TM) {} + virtual void Initialize(MCContext &ctx, const TargetMachine &TM) { + Ctx = &ctx; + } - const Section *getTextSection() const { return TextSection; } - const Section *getDataSection() const { return DataSection; } + const MCSection *getTextSection() const { return TextSection; } + const MCSection *getDataSection() const { return DataSection; } /// getSectionForMergeableConstant - Given a mergeable constant with the /// specified size and relocation information, return a section that it /// should be placed in. - virtual const Section * + virtual const MCSection * getSectionForMergeableConstant(SectionKind Kind) const; /// getKindForNamedSection - If this target wants to be able to override @@ -285,15 +278,15 @@ public: /// 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 *SectionForGlobal(const GlobalValue *GV, - Mangler *Mang, - const TargetMachine &TM) const; + const MCSection *SectionForGlobal(const GlobalValue *GV, + Mangler *Mang, + const TargetMachine &TM) const; /// getSpecialCasedSectionGlobals - Allow the target to completely override /// section assignment of a global. /// FIXME: ELIMINATE this by making PIC16 implement ADDRESS with /// getFlagsForNamedSection. - virtual const Section * + virtual const MCSection * getSpecialCasedSectionGlobals(const GlobalValue *GV, Mangler *Mang, SectionKind Kind) const { return 0; @@ -307,7 +300,7 @@ public: } protected: - virtual const Section * + virtual const MCSection * SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, const TargetMachine &TM) const; }; @@ -332,7 +325,7 @@ public: /// getSectionForMergeableConstant - Given a mergeable constant with the /// specified size and relocation information, return a section that it /// should be placed in. - virtual const Section * + virtual const MCSection * getSectionForMergeableConstant(SectionKind Kind) const; virtual SectionKind::Kind getKindForNamedSection(const char *Section, @@ -340,40 +333,40 @@ public: void getSectionFlagsAsString(SectionKind Kind, SmallVectorImpl<char> &Str) const; - virtual const Section * + virtual const MCSection * SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, const TargetMachine &TM) const; protected: - const Section *DataRelSection; - const Section *DataRelLocalSection; - const Section *DataRelROSection; - const Section *DataRelROLocalSection; - - const Section *MergeableConst4Section; - const Section *MergeableConst8Section; - const Section *MergeableConst16Section; + const MCSection *DataRelSection; + const MCSection *DataRelLocalSection; + const MCSection *DataRelROSection; + const MCSection *DataRelROLocalSection; + + const MCSection *MergeableConst4Section; + const MCSection *MergeableConst8Section; + const MCSection *MergeableConst16Section; }; class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile { - const Section *TextCoalSection; - const Section *ConstTextCoalSection; - const Section *ConstDataCoalSection; - const Section *ConstDataSection; - const Section *DataCoalSection; - const Section *FourByteConstantSection; - const Section *EightByteConstantSection; - const Section *SixteenByteConstantSection; + const MCSection *TextCoalSection; + const MCSection *ConstTextCoalSection; + const MCSection *ConstDataCoalSection; + const MCSection *ConstDataSection; + const MCSection *DataCoalSection; + const MCSection *FourByteConstantSection; + const MCSection *EightByteConstantSection; + const MCSection *SixteenByteConstantSection; public: virtual void Initialize(MCContext &Ctx, const TargetMachine &TM); - virtual const Section * + virtual const MCSection * SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, const TargetMachine &TM) const; - virtual const Section * + virtual const MCSection * getSectionForMergeableConstant(SectionKind Kind) const; }; @@ -386,7 +379,7 @@ public: virtual void getSectionFlagsAsString(SectionKind Kind, SmallVectorImpl<char> &Str) const; - virtual const Section * + virtual const MCSection * SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, const TargetMachine &TM) const; }; diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 7106c6ade8..178bbaa907 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -23,8 +23,9 @@ #include "llvm/CodeGen/DwarfWriter.h" #include "llvm/Analysis/DebugInfo.h" #include "llvm/MC/MCContext.h" -#include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCInst.h" +#include "llvm/MC/MCSection.h" +#include "llvm/MC/MCStreamer.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" @@ -132,7 +133,7 @@ void AsmPrinter::SwitchToDataSection(const char *NewSection, /// SwitchToSection - Switch to the specified section of the executable if we /// are not already in it! -void AsmPrinter::SwitchToSection(const Section *NS) { +void AsmPrinter::SwitchToSection(const MCSection *NS) { const std::string &NewSection = NS->getName(); // If we're already in this section, we're done. @@ -308,10 +309,10 @@ void AsmPrinter::SetupMachineFunction(MachineFunction &MF) { namespace { // SectionCPs - Keep track the alignment, constpool entries per Section. struct SectionCPs { - const Section *S; + const MCSection *S; unsigned Alignment; SmallVector<unsigned, 4> CPEs; - SectionCPs(const Section *s, unsigned a) : S(s), Alignment(a) {}; + SectionCPs(const MCSection *s, unsigned a) : S(s), Alignment(a) {}; }; } @@ -347,7 +348,8 @@ void AsmPrinter::EmitConstantPool(MachineConstantPool *MCP) { } } - const Section *S =getObjFileLowering().getSectionForMergeableConstant(Kind); + const MCSection *S = + getObjFileLowering().getSectionForMergeableConstant(Kind); // The number of sections are small, just do a linear search from the // last section to the first. @@ -419,7 +421,7 @@ void AsmPrinter::EmitJumpTableInfo(MachineJumpTableInfo *MJTI, const char *JumpTableDataSection = TAI->getJumpTableDataSection(); const Function *F = MF.getFunction(); - const Section *FuncSection = + const MCSection *FuncSection = getObjFileLowering().SectionForGlobal(F, Mang, TM); bool JTInDiffSection = false; diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index afcd44aeb9..873cdc2c5c 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -14,13 +14,14 @@ #include "DwarfDebug.h" #include "llvm/Module.h" #include "llvm/CodeGen/MachineModuleInfo.h" -#include "llvm/Support/Timer.h" -#include "llvm/System/Path.h" +#include "llvm/MC/MCSection.h" #include "llvm/Target/TargetAsmInfo.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetFrameInfo.h" #include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Target/TargetRegisterInfo.h" +#include "llvm/Support/Timer.h" +#include "llvm/System/Path.h" using namespace llvm; static TimerGroup &getDwarfTimerGroup() { @@ -224,7 +225,7 @@ DbgScope::~DbgScope() { DwarfDebug::DwarfDebug(raw_ostream &OS, AsmPrinter *A, const TargetAsmInfo *T) : Dwarf(OS, A, T, "dbg"), ModuleCU(0), AbbreviationsSet(InitAbbreviationsSetSize), Abbreviations(), - ValuesSet(InitValuesSetSize), Values(), StringPool(), SectionMap(), + ValuesSet(InitValuesSetSize), Values(), StringPool(), SectionSourceLines(), didInitial(false), shouldEmit(false), FunctionDbgScope(0), DebugTimer(0) { if (TimePassesIsEnabled) @@ -2132,7 +2133,7 @@ void DwarfDebug::EmitDebugLines() { const std::vector<SrcLineInfo> &LineInfos = SectionSourceLines[j]; if (Asm->isVerbose()) { - const Section* S = SectionMap[j + 1]; + const MCSection *S = SectionMap[j + 1]; O << '\t' << TAI->getCommentString() << " Section" << S->getName() << '\n'; } else { diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h index a4072f5ce9..af76b0b1b1 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -120,7 +120,7 @@ class VISIBILITY_HIDDEN DwarfDebug : public Dwarf { /// SectionMap - Provides a unique id per text section. /// - UniqueVector<const Section*> SectionMap; + UniqueVector<const MCSection*> SectionMap; /// SectionSourceLines - Tracks line numbers per text section. /// diff --git a/lib/CodeGen/ELFWriter.cpp b/lib/CodeGen/ELFWriter.cpp index 230c5ac4be..c7438329e3 100644 --- a/lib/CodeGen/ELFWriter.cpp +++ b/lib/CodeGen/ELFWriter.cpp @@ -43,6 +43,7 @@ #include "llvm/CodeGen/MachineCodeEmitter.h" #include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/MC/MCContext.h" +#include "llvm/MC/MCSection.h" #include "llvm/Target/TargetAsmInfo.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetELFWriterInfo.h" @@ -334,8 +335,8 @@ void ELFWriter::EmitGlobal(const GlobalValue *GV) { TM.getTargetLowering()->getObjFileLowering(); // Get the ELF section where this global belongs from TLOF - const Section *S = TLOF.SectionForGlobal(GV, Mang, TM); - unsigned SectionFlags = getElfSectionFlags(S->getKind()); + const MCSection *S = TLOF.SectionForGlobal(GV, Mang, TM); + unsigned SectionFlags = getElfSectionFlags(((MCSectionELF*)S)->getKind()); // The symbol align should update the section alignment if needed const TargetData *TD = TM.getTargetData(); diff --git a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp index 5feafb4297..eb3984674d 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 f7a38c2a48..c5f24dc02b 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 743ce9f09f..604d1050d4 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 811bb1eaf5..87379a691e 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 feec2fd686..5a2d4d8896 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 336730d2e6..c296954dce 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. un |