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

Chris Lattner sabre at nondot.org
Tue Jul 21 10:20:34 PDT 2009


Author: lattner
Date: Tue Jul 21 12:20:18 2009
New Revision: 76585

URL: http://llvm.org/viewvc/llvm-project?rev=76585&view=rev
Log:
more random whitespace cleanup, eliminate #define, avoid copying
vectors needlessly, doxygenify comments, improve constness, etc.

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

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

==============================================================================
--- llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp Tue Jul 21 12:20:18 2009
@@ -261,7 +261,7 @@
   std::vector<const GlobalVariable*> Items = PTAI->ExternalVarDefs->Items;
   if (!Items.size()) return;
 
-  O << "\n" <<  TAI->getCommentString() << "Exported Variables - BEGIN" << "\n";
+  O << "\n" << TAI->getCommentString() << "Exported Variables - BEGIN" << "\n";
   for (unsigned j = 0; j < Items.size(); j++) {
     O << TAI->getGlobalDirective() << Mang->getMangledName(Items[j]) << "\n";
   }

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

==============================================================================
--- llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.cpp Tue Jul 21 12:20:18 2009
@@ -73,9 +73,9 @@
 
 const Section *
 PIC16TargetAsmInfo::getBSSSectionForGlobal(const GlobalVariable *GV) const {
-  assert (GV->hasInitializer() && "This global doesn't need space");
+  assert(GV->hasInitializer() && "This global doesn't need space");
   Constant *C = GV->getInitializer();
-  assert (C->isNullValue() && "Unitialized globals has non-zero initializer");
+  assert(C->isNullValue() && "Unitialized globals has non-zero initializer");
 
   // Find how much space this global needs.
   const TargetData *TD = TM.getTargetData();
@@ -93,9 +93,9 @@
   }
 
   // No BSS section spacious enough was found. Crate a new one.
-  if (! FoundBSS) {
+  if (!FoundBSS) {
     std::string name = PAN::getUdataSectionName(BSSSections.size());
-    const Section *NewSection = getNamedSection (name.c_str());
+    const Section *NewSection = getNamedSection(name.c_str());
 
     FoundBSS = new PIC16Section(NewSection);
 
@@ -106,21 +106,16 @@
   // Insert the GV into this BSS.
   FoundBSS->Items.push_back(GV);
   FoundBSS->Size += ValSize;
-
-  // We can't do this here because GV is const .
-  // const std::string SName = FoundBSS->S_->getName();
-  // GV->setSection(SName);
-
   return FoundBSS->S_;
 } 
 
 const Section *
 PIC16TargetAsmInfo::getIDATASectionForGlobal(const GlobalVariable *GV) const {
-  assert (GV->hasInitializer() && "This global doesn't need space");
+  assert(GV->hasInitializer() && "This global doesn't need space");
   Constant *C = GV->getInitializer();
-  assert (!C->isNullValue() && "initialized globals has zero initializer");
-  assert (GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE &&
-          "can split initialized RAM data only");
+  assert(!C->isNullValue() && "initialized globals has zero initializer");
+  assert(GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE &&
+         "can split initialized RAM data only");
 
   // Find how much space this global needs.
   const TargetData *TD = TM.getTargetData();
@@ -131,16 +126,16 @@
   // to the first available section having enough space.
   PIC16Section *FoundIDATA = NULL;
   for (unsigned i = 0; i < IDATASections.size(); i++) {
-    if ( DataBankSize - IDATASections[i]->Size >= ValSize) {
+    if (DataBankSize - IDATASections[i]->Size >= ValSize) {
       FoundIDATA = IDATASections[i]; 
       break;
     }
   }
 
   // No IDATA section spacious enough was found. Crate a new one.
-  if (! FoundIDATA) {
+  if (!FoundIDATA) {
     std::string name = PAN::getIdataSectionName(IDATASections.size());
-    const Section *NewSection = getNamedSection (name.c_str());
+    const Section *NewSection = getNamedSection(name.c_str());
 
     FoundIDATA = new PIC16Section(NewSection);
 
@@ -151,10 +146,6 @@
   // Insert the GV into this IDATA.
   FoundIDATA->Items.push_back(GV);
   FoundIDATA->Size += ValSize;
-
-  // We can't do this here because GV is const .
-  // GV->setSection(FoundIDATA->S->getName());
-
   return FoundIDATA->S_;
 } 
 
@@ -169,15 +160,15 @@
   // to the appropriate section.
   PIC16Section *FoundAutoSec = NULL;
   for (unsigned i = 0; i < AutosSections.size(); i++) {
-    if ( AutosSections[i]->S_->getName() == name) {
+    if (AutosSections[i]->S_->getName() == name) {
       FoundAutoSec = AutosSections[i];
       break;
     }
   }
 
   // No Auto section was found. Crate a new one.
-  if (! FoundAutoSec) {
-    const Section *NewSection = getNamedSection (name.c_str());
+  if (!FoundAutoSec) {
+    const Section *NewSection = getNamedSection(name.c_str());
 
     FoundAutoSec = new PIC16Section(NewSection);
 
@@ -199,7 +190,6 @@
   // We select the section based on the initializer here, so it really
   // has to be a GlobalVariable.
   const GlobalVariable *GV = dyn_cast<GlobalVariable>(GV1); 
-
   if (!GV)
     return TargetAsmInfo::SelectSectionForGlobal(GV1);
 
@@ -209,7 +199,7 @@
     return ExternalVarDecls->S_;
   }
     
-  assert (GV->hasInitializer() && "A def without initializer?");
+  assert(GV->hasInitializer() && "A def without initializer?");
 
   // First, if this is an automatic variable for a function, get the section
   // name for it and return.
@@ -308,9 +298,9 @@
 const Section *
 PIC16TargetAsmInfo::CreateBSSSectionForGlobal(const GlobalVariable *GV,
                                               std::string Addr) const {
-  assert (GV->hasInitializer() && "This global doesn't need space");
-  assert (GV->getInitializer()->isNullValue() &&
-          "Unitialized global has non-zero initializer");
+  assert(GV->hasInitializer() && "This global doesn't need space");
+  assert(GV->getInitializer()->isNullValue() &&
+         "Unitialized global has non-zero initializer");
   std::string Name;
   // If address is given then create a section at that address else create a
   // section by section name specified in GV.
@@ -323,15 +313,14 @@
         break;
       }
     }
-  }
-  else {
+  } else {
     std::string Prefix = GV->getName() + "." + Addr + ".";
     Name = PAN::getUdataSectionName(BSSSections.size(), Prefix) + " " + Addr;
   }
   
   PIC16Section *NewBSS = FoundBSS;
   if (NewBSS == NULL) {
-    const Section *NewSection = getNamedSection (Name.c_str());
+    const Section *NewSection = getNamedSection(Name.c_str());
     NewBSS = new PIC16Section(NewSection);
     BSSSections.push_back(NewBSS);
   }
@@ -357,11 +346,11 @@
 const Section *
 PIC16TargetAsmInfo::CreateIDATASectionForGlobal(const GlobalVariable *GV,
                                                 std::string Addr) const {
-  assert (GV->hasInitializer() && "This global doesn't need space");
-  assert (!GV->getInitializer()->isNullValue() &&
-          "initialized global has zero initializer");
-  assert (GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE &&
-          "can be used for initialized RAM data only");
+  assert(GV->hasInitializer() && "This global doesn't need space");
+  assert(!GV->getInitializer()->isNullValue() &&
+         "initialized global has zero initializer");
+  assert(GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE &&
+         "can be used for initialized RAM data only");
 
   std::string Name;
   // If address is given then create a section at that address else create a
@@ -375,15 +364,14 @@
         break;
       }
     }
-  }
-  else {
+  } else {
     std::string Prefix = GV->getName() + "." + Addr + ".";
     Name = PAN::getIdataSectionName(IDATASections.size(), Prefix) + " " + Addr;
   }
 
   PIC16Section *NewIDATASec = FoundIDATASec;
   if (NewIDATASec == NULL) {
-    const Section *NewSection = getNamedSection (Name.c_str());
+    const Section *NewSection = getNamedSection(Name.c_str());
     NewIDATASec = new PIC16Section(NewSection);
     IDATASections.push_back(NewIDATASec);
   }
@@ -399,8 +387,8 @@
 const Section *
 PIC16TargetAsmInfo::CreateROSectionForGlobal(const GlobalVariable *GV,
                                              std::string Addr) const {
-  assert (GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE &&
-          "can be used for ROM data only");
+  assert(GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE &&
+         "can be used for ROM data only");
 
   std::string Name;
   // If address is given then create a section at that address else create a
@@ -414,15 +402,14 @@
         break;
       }
     }
-  }
-  else {
+  } else {
     std::string Prefix = GV->getName() + "." + Addr + ".";
     Name = PAN::getRomdataSectionName(ROSections.size(), Prefix) + " " + Addr;
   }
 
   PIC16Section *NewRomSec = FoundROSec;
   if (NewRomSec == NULL) {
-    const Section *NewSection = getNamedSection (Name.c_str());
+    const Section *NewSection = getNamedSection(Name.c_str());
     NewRomSec = new PIC16Section(NewSection);
     ROSections.push_back(NewRomSec);
   }

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

==============================================================================
--- llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.h (original)
+++ llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.h Tue Jul 21 12:20:18 2009
@@ -18,28 +18,33 @@
 #include "llvm/Target/TargetAsmInfo.h"
 #include <vector>
 #include "llvm/Module.h"
-#define DataBankSize 80
+
 namespace llvm {
 
+  enum { DataBankSize = 80 };
+
   // Forward declaration.
   class PIC16TargetMachine;
   class GlobalVariable;
 
-  // PIC16 Splits the global data into mulitple udata and idata sections.
-  // Each udata and idata section needs to contain a list of globals that
-  // they contain, in order to avoid scanning over all the global values 
-  // again and printing only those that match the current section. 
-  // Keeping values inside the sections make printing a section much easier.
+  /// PIC16 Splits the global data into mulitple udata and idata sections.
+  /// Each udata and idata section needs to contain a list of globals that
+  /// they contain, in order to avoid scanning over all the global values 
+  /// again and printing only those that match the current section. 
+  /// Keeping values inside the sections make printing a section much easier.
   struct PIC16Section {
-      const Section *S_; // Connection to actual Section.
-      unsigned Size;  // Total size of the objects contained.
-      bool SectionPrinted;
-      std::vector<const GlobalVariable*> Items;
-     
-      PIC16Section (const Section *s) { S_ = s; Size = 0; 
-                                        SectionPrinted = false;}
-      bool isPrinted() { return SectionPrinted ; }
-      void setPrintedStatus(bool status) { SectionPrinted = status ;} 
+    const Section *S_; // Connection to actual Section.
+    unsigned Size;  // Total size of the objects contained.
+    bool SectionPrinted;
+    std::vector<const GlobalVariable*> Items;
+   
+    PIC16Section(const Section *s) {
+      S_ = s;
+      Size = 0;
+      SectionPrinted = false;
+    }
+    bool isPrinted() const { return SectionPrinted; }
+    void setPrintedStatus(bool status) { SectionPrinted = status; } 
   };
       
   struct PIC16TargetAsmInfo : public TargetAsmInfo {
@@ -53,7 +58,7 @@
     mutable PIC16Section *ExternalVarDefs;
     virtual ~PIC16TargetAsmInfo();
 
-    private:
+  private:
     const char *RomData8bitsDirective;
     const char *RomData16bitsDirective;
     const char *RomData32bitsDirective;
@@ -72,21 +77,21 @@
     virtual const Section *SelectSectionForGlobal(const GlobalValue *GV) const;
     const Section * CreateSectionForGlobal(const GlobalValue *GV,
                                            std::string Addr = "") const;
-    public:
+  public:
     void SetSectionForGVs(Module &M);
-    std::vector<PIC16Section *> getBSSSections() const {
+    const std::vector<PIC16Section*> &getBSSSections() const {
       return BSSSections;
     }
-    std::vector<PIC16Section *> getIDATASections()  const {
+    const std::vector<PIC16Section*> &getIDATASections() const {
       return IDATASections;
     }
-    std::vector<PIC16Section *> getAutosSections()  const {
+    const std::vector<PIC16Section*> &getAutosSections() const {
       return AutosSections;
     }
-    std::vector<PIC16Section *> getROSections() const {
+    const std::vector<PIC16Section*> &getROSections() const {
       return ROSections;
     }
-    virtual const Section* SectionForGlobal(const GlobalValue *GV) const;
+    virtual const Section *SectionForGlobal(const GlobalValue *GV) const;
   };
 
 } // namespace llvm





More information about the llvm-commits mailing list