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

Chris Lattner sabre at nondot.org
Mon Jul 27 09:27:49 PDT 2009


Author: lattner
Date: Mon Jul 27 11:27:32 2009
New Revision: 77198

URL: http://llvm.org/viewvc/llvm-project?rev=77198&view=rev
Log:
inline a method.

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=77198&r1=77197&r2=77198&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Target/ELFTargetAsmInfo.h (original)
+++ llvm/trunk/include/llvm/Target/ELFTargetAsmInfo.h Mon Jul 27 11:27:32 2009
@@ -19,10 +19,8 @@
 
 namespace llvm {
   class GlobalValue;
-  class GlobalVariable;
-  class Type;
 
-  struct ELFTargetAsmInfo: public TargetAsmInfo {
+  struct ELFTargetAsmInfo : public TargetAsmInfo {
     ELFTargetAsmInfo(const TargetMachine &TM);
 
     /// getSectionForMergeableConstant - Given a mergeable constant with the
@@ -49,9 +47,6 @@
     const Section *MergeableConst4Section;
     const Section *MergeableConst8Section;
     const Section *MergeableConst16Section;
-
-  private:
-    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=77198&r1=77197&r2=77198&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp Mon Jul 27 11:27:32 2009
@@ -58,8 +58,30 @@
 ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV,
                                          SectionKind Kind) const {
   if (Kind.isText()) return TextSection;
-  if (Kind.isMergeableCString())
-    return MergeableStringSection(cast<GlobalVariable>(GV));
+  if (Kind.isMergeableCString()) {
+    const TargetData *TD = TM.getTargetData();
+    Constant *C = cast<GlobalVariable>(GV)->getInitializer();
+    const Type *Ty = cast<ArrayType>(C->getType())->getElementType();
+    
+    unsigned Size = TD->getTypeAllocSize(Ty);
+    if (Size <= 16) {
+      assert(getCStringSection() && "Should have string section prefix");
+      
+      // We also need alignment here.
+      // FIXME: this is getting the alignment of the character, not the
+      // alignment of the string!!
+      unsigned Align = TD->getPrefTypeAlignment(Ty);
+      if (Align < Size)
+        Align = Size;
+      
+      std::string Name = getCStringSection() + utostr(Size) + '.' +
+                         utostr(Align);
+      return getOrCreateSection(Name.c_str(), false,
+                                SectionKind::MergeableCString);
+    }
+    
+    return getReadOnlySection();
+  }
   
   if (Kind.isMergeableConst()) {
     if (Kind.isMergeableConst4())
@@ -145,32 +167,6 @@
 }
 
 
-
-const Section*
-ELFTargetAsmInfo::MergeableStringSection(const GlobalVariable *GV) const {
-  const TargetData *TD = TM.getTargetData();
-  Constant *C = cast<GlobalVariable>(GV)->getInitializer();
-  const Type *Ty = cast<ArrayType>(C->getType())->getElementType();
-
-  unsigned Size = TD->getTypeAllocSize(Ty);
-  if (Size <= 16) {
-    assert(getCStringSection() && "Should have string section prefix");
-
-    // We also need alignment here.
-    // FIXME: this is getting the alignment of the character, not the alignment
-    // of the string!!
-    unsigned Align = TD->getPrefTypeAlignment(Ty);
-    if (Align < Size)
-      Align = Size;
-
-    std::string Name = getCStringSection() + utostr(Size) + '.' + utostr(Align);
-    return getOrCreateSection(Name.c_str(), false,
-                              SectionKind::MergeableCString);
-  }
-
-  return getReadOnlySection();
-}
-
 void ELFTargetAsmInfo::getSectionFlagsAsString(SectionKind Kind,
                                              SmallVectorImpl<char> &Str) const {
   Str.push_back(',');





More information about the llvm-commits mailing list