Provide convenient helpers
authorAnton Korobeynikov <asl@math.spbu.ru>
Thu, 7 Aug 2008 09:51:54 +0000 (09:51 +0000)
committerAnton Korobeynikov <asl@math.spbu.ru>
Thu, 7 Aug 2008 09:51:54 +0000 (09:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54451 91177308-0d34-0410-b5e6-96231b3b80d8

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

index e20a6c8995bcbd529804faf3186883a6fdce3c9e..04e91cb38120948bd805bddc0246e0c5b22d7402 100644 (file)
@@ -45,6 +45,18 @@ namespace llvm {
       ThreadData,       ///< Initialized TLS data objects
       ThreadBSS         ///< Uninitialized TLS data objects
     };
+
+    static inline bool isReadOnly(Kind K) {
+      return (K == SectionKind::ROData ||
+              K == SectionKind::RODataMergeConst ||
+              K == SectionKind::RODataMergeStr ||
+              K == SectionKind::SmallROData);
+    }
+
+    static inline bool isBSS(Kind K) {
+      return (K == SectionKind::BSS ||
+              K == SectionKind::SmallBSS);
+    }
   }
 
   namespace SectionFlags {
index 10b1d843f9975d8694415468d8564725f6817b0b..04edd0d4b537c8031f08910dbae4ab9e922f2a71 100644 (file)
@@ -61,7 +61,7 @@ SectionKindForGlobal(const GlobalValue *GV) const {
   if (Subtarget->hasABICall())
     return K;
 
-  if (K != SectionKind::Data && K != SectionKind::BSS && 
+  if (K != SectionKind::Data && K != SectionKind::BSS &&
       K != SectionKind::RODataMergeConst)
     return K;
 
@@ -69,7 +69,7 @@ SectionKindForGlobal(const GlobalValue *GV) const {
     const TargetData *TD = ETM->getTargetData();
     unsigned Size = TD->getABITypeSize(GV->getType()->getElementType());
     unsigned Threshold = Subtarget->getSSectionThreshold();
-     
+
     if (Size > 0 && Size <= Threshold) {
       if (K == SectionKind::BSS)
         return SectionKind::SmallBSS;
index eb74836aec328227076a8d4d922e6953d17e1edd..9bc0b4055e3370bdddb54e18c58a8c19a3884139 100644 (file)
@@ -306,15 +306,9 @@ TargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
   } else {
     if (Kind == SectionKind::Text)
       return getTextSection_();
-    else if ((Kind == SectionKind::BSS ||
-              Kind == SectionKind::SmallBSS) &&
-             getBSSSection_())
+    else if (isBSS(Kind) && getBSSSection_())
       return getBSSSection_();
-    else if (getReadOnlySection_() &&
-             (Kind == SectionKind::ROData ||
-              Kind == SectionKind::RODataMergeConst ||
-              Kind == SectionKind::RODataMergeStr ||
-              Kind == SectionKind::SmallROData))
+    else if (getReadOnlySection_() && SectionKind::isReadOnly(Kind))
       return getReadOnlySection_();
   }