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

Chris Lattner sabre at nondot.org
Fri Jul 24 10:02:18 PDT 2009


Author: lattner
Date: Fri Jul 24 12:02:17 2009
New Revision: 76976

URL: http://llvm.org/viewvc/llvm-project?rev=76976&view=rev
Log:
move ELF-specific code into ELFTargetAsmInfo.

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

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

==============================================================================
--- llvm/trunk/include/llvm/Target/ELFTargetAsmInfo.h (original)
+++ llvm/trunk/include/llvm/Target/ELFTargetAsmInfo.h Fri Jul 24 12:02:17 2009
@@ -31,6 +31,11 @@
     virtual const Section *
     getSectionForMergableConstant(uint64_t Size, unsigned ReloInfo) const;
     
+    /// getFlagsForNamedSection - If this target wants to be able to infer
+    /// section flags based on the name of the section specified for a global
+    /// variable, it can implement this.  This is used on ELF systems so that
+    /// ".tbss" gets the TLS bit set etc.
+    virtual unsigned getFlagsForNamedSection(const char *Section) const;
     
     SectionKind::Kind SectionKindForGlobal(const GlobalValue *GV) const;
     virtual const Section* SelectSectionForGlobal(const GlobalValue *GV) const;

Modified: llvm/trunk/include/llvm/Target/TargetAsmInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetAsmInfo.h?rev=76976&r1=76975&r2=76976&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Target/TargetAsmInfo.h (original)
+++ llvm/trunk/include/llvm/Target/TargetAsmInfo.h Fri Jul 24 12:02:17 2009
@@ -586,7 +586,13 @@
     virtual const char *
     getSectionPrefixForUniqueGlobal(SectionKind::Kind Kind) const;
     
-    
+    /// getFlagsForNamedSection - If this target wants to be able to infer
+    /// section flags based on the name of the section specified for a global
+    /// variable, it can implement this.  This is used on ELF systems so that
+    /// ".tbss" gets the TLS bit set etc.
+    virtual unsigned getFlagsForNamedSection(const char *Section) const {
+      return 0;
+    }
     
     
     /// SectionKindForGlobal - This hook allows the target to select proper

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

==============================================================================
--- llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp Fri Jul 24 12:02:17 2009
@@ -145,6 +145,33 @@
   return getReadOnlySection();  // .rodata
 }
 
+/// getFlagsForNamedSection - If this target wants to be able to infer
+/// section flags based on the name of the section specified for a global
+/// variable, it can implement this.
+unsigned ELFTargetAsmInfo::getFlagsForNamedSection(const char *Name) const {
+  unsigned Flags = 0;
+  if (Name[0] != '.') return 0;
+  
+  // Some lame default implementation based on some magic section names.
+  if (strncmp(Name, ".gnu.linkonce.b.", 16) == 0 ||
+      strncmp(Name, ".llvm.linkonce.b.", 17) == 0 ||
+      strncmp(Name, ".gnu.linkonce.sb.", 17) == 0 ||
+      strncmp(Name, ".llvm.linkonce.sb.", 18) == 0)
+    Flags |= SectionFlags::BSS;
+  else if (strcmp(Name, ".tdata") == 0 ||
+           strncmp(Name, ".tdata.", 7) == 0 ||
+           strncmp(Name, ".gnu.linkonce.td.", 17) == 0 ||
+           strncmp(Name, ".llvm.linkonce.td.", 18) == 0)
+    Flags |= SectionFlags::TLS;
+  else if (strcmp(Name, ".tbss") == 0 ||
+           strncmp(Name, ".tbss.", 6) == 0 ||
+           strncmp(Name, ".gnu.linkonce.tb.", 17) == 0 ||
+           strncmp(Name, ".llvm.linkonce.tb.", 18) == 0)
+    Flags |= SectionFlags::BSS | SectionFlags::TLS;
+  
+  return Flags;
+}
+
 
 const Section*
 ELFTargetAsmInfo::MergeableStringSection(const GlobalVariable *GV) const {

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

==============================================================================
--- llvm/trunk/lib/Target/TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/TargetAsmInfo.cpp Fri Jul 24 12:02:17 2009
@@ -224,30 +224,6 @@
   return Flags;
 }
 
-static unsigned GetSectionFlagsForNamedELFSection(const char *Name) {
-  unsigned Flags = 0;
-  // Some lame default implementation based on some magic section names.
-  if (strncmp(Name, ".gnu.linkonce.b.", 16) == 0 ||
-      strncmp(Name, ".llvm.linkonce.b.", 17) == 0 ||
-      strncmp(Name, ".gnu.linkonce.sb.", 17) == 0 ||
-      strncmp(Name, ".llvm.linkonce.sb.", 18) == 0)
-    Flags |= SectionFlags::BSS;
-  else if (strcmp(Name, ".tdata") == 0 ||
-           strncmp(Name, ".tdata.", 7) == 0 ||
-           strncmp(Name, ".gnu.linkonce.td.", 17) == 0 ||
-           strncmp(Name, ".llvm.linkonce.td.", 18) == 0)
-    Flags |= SectionFlags::TLS;
-  else if (strcmp(Name, ".tbss") == 0 ||
-           strncmp(Name, ".tbss.", 6) == 0 ||
-           strncmp(Name, ".gnu.linkonce.tb.", 17) == 0 ||
-           strncmp(Name, ".llvm.linkonce.tb.", 18) == 0)
-    Flags |= SectionFlags::BSS | SectionFlags::TLS;
-  
-  return Flags;
-}
-
-
-
 SectionKind::Kind
 TargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const {
   // Early exit - functions should be always in text sections.
@@ -298,7 +274,7 @@
     // If the target has magic semantics for certain section names, make sure to
     // pick up the flags.  This allows the user to write things with attribute
     // section and still get the appropriate section flags printed.
-    Flags |= GetSectionFlagsForNamedELFSection(GV->getSection().c_str());
+    Flags |= getFlagsForNamedSection(GV->getSection().c_str());
     
     return getNamedSection(GV->getSection().c_str(), Flags);
   }





More information about the llvm-commits mailing list