Add default section name resolution routine
authorAnton Korobeynikov <asl@math.spbu.ru>
Wed, 9 Jul 2008 13:18:02 +0000 (13:18 +0000)
committerAnton Korobeynikov <asl@math.spbu.ru>
Wed, 9 Jul 2008 13:18:02 +0000 (13:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53292 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/TargetAsmInfo.h
lib/Target/TargetAsmInfo.cpp

index 7af2c03aa63035840099752979b80e0913e44c35..3f7dbc7206db403fd24b12656aefc0e41b11c4eb 100644 (file)
@@ -471,6 +471,10 @@ namespace llvm {
     SectionFlagsForGlobal(const GlobalValue *GV = NULL,
                           const char* name = NULL) const;
 
+    /// SectionForGlobal - This hooks returns proper section name for given
+    /// global with all necessary flags and marks.
+    const char* SectionForGlobal(const GlobalValue *GV) const;
+
     // Accessors.
     //
     const char *getTextSection() const {
index 404e152da7b365820da6413d9c9ef156882c3f51..8e34fc30ec58e36c5db1d170abf8ef89f085d55f 100644 (file)
@@ -254,3 +254,15 @@ TargetAsmInfo::SectionFlagsForGlobal(const GlobalValue *GV,
 
   return flags;
 }
+
+const char*
+TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const {
+  SectionKind::Kind kind = SectionKindForGlobal(GV);
+
+  if (kind == SectionKind::Text)
+    return getTextSection();
+  else if (kind == SectionKind::BSS && getBSSSection())
+    return getBSSSection();
+
+  return getDataSection();
+}