[llvm-commits] [llvm] r78317 - in /llvm/trunk/lib/Target/PIC16: PIC16AsmPrinter.cpp PIC16AsmPrinter.h PIC16TargetObjectFile.cpp PIC16TargetObjectFile.h

Chris Lattner sabre at nondot.org
Thu Aug 6 09:27:28 PDT 2009


Author: lattner
Date: Thu Aug  6 11:27:28 2009
New Revision: 78317

URL: http://llvm.org/viewvc/llvm-project?rev=78317&view=rev
Log:
go through PIC16TargetObjectFile to make sections instead of 
creating them directly in the pic16 asmprinter.

Modified:
    llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp
    llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.h
    llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp
    llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h

Modified: llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp?rev=78317&r1=78316&r2=78317&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp Thu Aug  6 11:27:28 2009
@@ -68,12 +68,8 @@
   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 @@
   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

Modified: llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.h?rev=78317&r1=78316&r2=78317&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.h (original)
+++ llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.h Thu Aug  6 11:27:28 2009
@@ -37,6 +37,10 @@
     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);

Modified: llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp?rev=78317&r1=78316&r2=78317&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp (original)
+++ llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp Thu Aug  6 11:27:28 2009
@@ -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 @@
                                       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 {

Modified: llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h?rev=78317&r1=78316&r2=78317&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h (original)
+++ llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h Thu Aug  6 11:27:28 2009
@@ -64,10 +64,16 @@
     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;
 





More information about the llvm-commits mailing list