From b29996eb238cc2a23fbfadf3f02cce83d74ccc5d Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 6 Aug 2009 16:27:28 +0000 Subject: [PATCH] go through PIC16TargetObjectFile to make sections instead of creating them directly in the pic16 asmprinter. llvm-svn: 78317 --- llvm/lib/Target/PIC16/PIC16AsmPrinter.cpp | 13 +++---------- llvm/lib/Target/PIC16/PIC16AsmPrinter.h | 4 ++++ llvm/lib/Target/PIC16/PIC16TargetObjectFile.cpp | 15 +++++++++++++-- llvm/lib/Target/PIC16/PIC16TargetObjectFile.h | 6 ++++++ 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/llvm/lib/Target/PIC16/PIC16AsmPrinter.cpp b/llvm/lib/Target/PIC16/PIC16AsmPrinter.cpp index e98cf41b5400..55ec1fe7d55d 100644 --- a/llvm/lib/Target/PIC16/PIC16AsmPrinter.cpp +++ b/llvm/lib/Target/PIC16/PIC16AsmPrinter.cpp @@ -68,12 +68,8 @@ bool PIC16AsmPrinter::runOnMachineFunction(MachineFunction &MF) { EmitAutos(CurrentFnName); // Now emit the instructions of function in its code section. - std::string T = PAN::getCodeSectionName(CurrentFnName); - const char *codeSection = T.c_str(); - const MCSection *fCodeSection = - getObjFileLowering().getOrCreateSection(codeSection, false, - SectionKind::getText()); + getObjFileLowering().getSectionForFunction(CurrentFnName); // Start the Code Section. O << "\n"; SwitchToSection(fCodeSection); @@ -347,12 +343,9 @@ void PIC16AsmPrinter::EmitFunctionFrame(MachineFunction &MF) { const TargetData *TD = TM.getTargetData(); // Emit the data section name. O << "\n"; - std::string T = PAN::getFrameSectionName(CurrentFnName); - const char *SectionName = T.c_str(); - + const MCSection *fPDataSection = - getObjFileLowering().getOrCreateSection(SectionName, false, - SectionKind::getDataRel()); + getObjFileLowering().getSectionForFunctionFrame(CurrentFnName); SwitchToSection(fPDataSection); // Emit function frame label diff --git a/llvm/lib/Target/PIC16/PIC16AsmPrinter.h b/llvm/lib/Target/PIC16/PIC16AsmPrinter.h index c365b5a30dba..19c490f78fe8 100644 --- a/llvm/lib/Target/PIC16/PIC16AsmPrinter.h +++ b/llvm/lib/Target/PIC16/PIC16AsmPrinter.h @@ -37,6 +37,10 @@ namespace llvm { virtual const char *getPassName() const { return "PIC16 Assembly Printer"; } + + PIC16TargetObjectFile &getObjFileLowering() const { + return (PIC16TargetObjectFile &)AsmPrinter::getObjFileLowering(); + } bool runOnMachineFunction(MachineFunction &F); void printOperand(const MachineInstr *MI, int opNum); diff --git a/llvm/lib/Target/PIC16/PIC16TargetObjectFile.cpp b/llvm/lib/Target/PIC16/PIC16TargetObjectFile.cpp index 7b5d5574e5c8..f15f3321c7ca 100644 --- a/llvm/lib/Target/PIC16/PIC16TargetObjectFile.cpp +++ b/llvm/lib/Target/PIC16/PIC16TargetObjectFile.cpp @@ -16,8 +16,7 @@ using namespace llvm; PIC16TargetObjectFile::PIC16TargetObjectFile() - : ExternalVarDecls(0), ExternalVarDefs(0) -{ + : ExternalVarDecls(0), ExternalVarDefs(0) { } void PIC16TargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &tm){ @@ -47,6 +46,18 @@ void PIC16TargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &tm){ SectionKind::getMetadata())); } +const MCSection *PIC16TargetObjectFile:: +getSectionForFunction(const std::string &FnName) const { + std::string T = PAN::getCodeSectionName(FnName); + return getOrCreateSection(T.c_str(), false, SectionKind::getText()); +} + + +const MCSection *PIC16TargetObjectFile:: +getSectionForFunctionFrame(const std::string &FnName) const { + std::string T = PAN::getFrameSectionName(FnName); + return getOrCreateSection(T.c_str(), false, SectionKind::getDataRel()); +} const MCSection * PIC16TargetObjectFile::getBSSSectionForGlobal(const GlobalVariable *GV) const { diff --git a/llvm/lib/Target/PIC16/PIC16TargetObjectFile.h b/llvm/lib/Target/PIC16/PIC16TargetObjectFile.h index 708c311e28e4..6cc7054e63b5 100644 --- a/llvm/lib/Target/PIC16/PIC16TargetObjectFile.h +++ b/llvm/lib/Target/PIC16/PIC16TargetObjectFile.h @@ -64,10 +64,16 @@ namespace llvm { virtual const MCSection * getSpecialCasedSectionGlobals(const GlobalValue *GV, Mangler *Mang, SectionKind Kind) const; + virtual const MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, const TargetMachine&) const; + + const MCSection *getSectionForFunction(const std::string &FnName) const; + const MCSection *getSectionForFunctionFrame(const std::string &FnName)const; + + private: std::string getSectionNameForSym(const std::string &Sym) const;