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

Chris Lattner sabre at nondot.org
Fri Jul 24 10:13:33 PDT 2009


Author: lattner
Date: Fri Jul 24 12:13:27 2009
New Revision: 76977

URL: http://llvm.org/viewvc/llvm-project?rev=76977&view=rev
Log:
start refactoring pic16 section selection logic.

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

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

==============================================================================
--- llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.cpp Fri Jul 24 12:13:27 2009
@@ -249,13 +249,15 @@
 PIC16TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const {
   // If GV has a sectin name or section address create that section now.
   if (GV->hasSection()) {
-    std::string SectName = GV->getSection();
-    // If address for a variable is specified, get the address and create
-    // section.
-    std::string AddrStr = "Address=";
-    if (SectName.compare(0, AddrStr.length(), AddrStr) == 0) {
-      std::string SectAddr = SectName.substr(AddrStr.length());
-      return CreateSectionForGlobal(GV, SectAddr);
+    if (const GlobalVariable *GVar = cast<GlobalVariable>(GV)) {
+      std::string SectName = GVar->getSection();
+      // If address for a variable is specified, get the address and create
+      // section.
+      std::string AddrStr = "Address=";
+      if (SectName.compare(0, AddrStr.length(), AddrStr) == 0) {
+        std::string SectAddr = SectName.substr(AddrStr.length());
+        return CreateSectionForGlobal(GVar, SectAddr);
+      }
     }
   }
   
@@ -266,13 +268,8 @@
 // Create a new section for global variable. If Addr is given then create
 // section at that address else create by name.
 const Section *
-PIC16TargetAsmInfo::CreateSectionForGlobal(const GlobalValue *GV1,
-                                           std::string Addr) const {
-  const GlobalVariable *GV = dyn_cast<GlobalVariable>(GV1);
-
-  if (!GV)
-    return TargetAsmInfo::SectionForGlobal(GV1);
-
+PIC16TargetAsmInfo::CreateSectionForGlobal(const GlobalVariable *GV,
+                                           const std::string &Addr) const {
   // See if this is an uninitialized global.
   const Constant *C = GV->getInitializer();
   if (C->isNullValue())

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

==============================================================================
--- llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.h (original)
+++ llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.h Fri Jul 24 12:13:27 2009
@@ -75,8 +75,8 @@
     const Section *CreateROSectionForGlobal(const GlobalVariable *GV,
                                             std::string Addr = "") const;
     virtual const Section *SelectSectionForGlobal(const GlobalValue *GV) const;
-    const Section * CreateSectionForGlobal(const GlobalValue *GV,
-                                           std::string Addr = "") const;
+    const Section *CreateSectionForGlobal(const GlobalVariable *GV,
+                                          const std::string &Addr = "") const;
   public:
     void SetSectionForGVs(Module &M);
     const std::vector<PIC16Section*> &getBSSSections() const {





More information about the llvm-commits mailing list