[llvm-commits] [llvm] r77133 - in /llvm/trunk: include/llvm/Target/ELFTargetAsmInfo.h lib/Target/ELFTargetAsmInfo.cpp

Chris Lattner sabre at nondot.org
Sat Jul 25 23:16:33 PDT 2009


Author: lattner
Date: Sun Jul 26 01:16:11 2009
New Revision: 77133

URL: http://llvm.org/viewvc/llvm-project?rev=77133&view=rev
Log:
precreate 4/8/16 byte mergable sections to simplify code.

Modified:
    llvm/trunk/include/llvm/Target/ELFTargetAsmInfo.h
    llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp

Modified: llvm/trunk/include/llvm/Target/ELFTargetAsmInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/ELFTargetAsmInfo.h?rev=77133&r1=77132&r2=77133&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Target/ELFTargetAsmInfo.h (original)
+++ llvm/trunk/include/llvm/Target/ELFTargetAsmInfo.h Sun Jul 26 01:16:11 2009
@@ -43,13 +43,17 @@
                                                   SectionKind Kind) const;
     virtual std::string printSectionFlags(unsigned flags) const;
 
-    const Section* DataRelSection;
-    const Section* DataRelLocalSection;
-    const Section* DataRelROSection;
-    const Section* DataRelROLocalSection;
-    
+    const Section *DataRelSection;
+    const Section *DataRelLocalSection;
+    const Section *DataRelROSection;
+    const Section *DataRelROLocalSection;
+
+    const Section *MergableConst4Section;
+    const Section *MergableConst8Section;
+    const Section *MergableConst16Section;
+
   private:
-    const Section* MergeableStringSection(const GlobalVariable *GV) const;
+    const Section *MergeableStringSection(const GlobalVariable *GV) const;
   };
 }
 

Modified: llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp?rev=77133&r1=77132&r2=77133&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp Sun Jul 26 01:16:11 2009
@@ -43,6 +43,13 @@
                                      SectionFlags::Writable);
   DataRelROLocalSection = getNamedSection("\t.data.rel.ro.local",
                                           SectionFlags::Writable);
+    
+  MergableConst4Section = getNamedSection(".rodata.cst4",
+                  SectionFlags::setEntitySize(SectionFlags::Mergeable, 4));
+  MergableConst8Section = getNamedSection(".rodata.cst8",
+                  SectionFlags::setEntitySize(SectionFlags::Mergeable, 8));
+  MergableConst16Section = getNamedSection(".rodata.cst16",
+                  SectionFlags::setEntitySize(SectionFlags::Mergeable, 16));
 }
 
 
@@ -54,10 +61,15 @@
     return MergeableStringSection(cast<GlobalVariable>(GV));
   
   if (Kind.isMergableConst()) {
-    const Type *Ty = cast<GlobalVariable>(GV)->getInitializer()->getType();
-    const TargetData *TD = TM.getTargetData();
-    return getSectionForMergableConstant(TD->getTypeAllocSize(Ty), 0);
+    if (Kind.isMergableConst4())
+      return MergableConst4Section;
+    if (Kind.isMergableConst8())
+      return MergableConst8Section;
+    if (Kind.isMergableConst16())
+      return MergableConst16Section;
+    return ReadOnlySection;  // .const
   }
+  
   if (Kind.isReadOnly())             return getReadOnlySection();
   
   
@@ -89,21 +101,12 @@
   if (ReloInfo == 1)
     return DataRelROLocalSection;
   
-  
-  const char *SecName = 0;
   switch (Size) {
-  default: break;
-  case 4:  SecName = ".rodata.cst4"; break;
-  case 8:  SecName = ".rodata.cst8"; break;
-  case 16: SecName = ".rodata.cst16"; break;
+  default: return ReadOnlySection;   // .rodata
+  case 4:  return MergableConst4Section;
+  case 8:  return MergableConst8Section;
+  case 16: return MergableConst16Section;
   }
-  
-  if (SecName)
-    return getNamedSection(SecName,
-                           SectionFlags::setEntitySize(SectionFlags::Mergeable,
-                                                       Size));
-  
-  return getReadOnlySection();  // .rodata
 }
 
 /// getFlagsForNamedSection - If this target wants to be able to infer





More information about the llvm-commits mailing list