Move flag decoding stuff into special hook
authorAnton Korobeynikov <asl@math.spbu.ru>
Wed, 9 Jul 2008 13:20:07 +0000 (13:20 +0000)
committerAnton Korobeynikov <asl@math.spbu.ru>
Wed, 9 Jul 2008 13:20:07 +0000 (13:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53297 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 13b32e790ed0f3dc26b851cac5dcde0830d660e1..0cd7f8d7a5ebb03a185a6a5b30d97dcac6143978 100644 (file)
@@ -474,6 +474,8 @@ namespace llvm {
     virtual std::string UniqueSectionForGlobal(const GlobalValue* GV,
                                                SectionKind::Kind kind) const;
 
+    virtual std::string PrintSectionFlags(unsigned flags) const { return ""; }
+
     // Accessors.
     //
     const char *getTextSection() const {
index 80156c79c030c9871433e34d3e1de2bcba1b16ce..b34f2d19e39ca9529f96f9e6d3bf5d83aa1727a9 100644 (file)
@@ -411,7 +411,6 @@ std::string X86TargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV,
 
 
 std::string X86TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const {
-  const X86Subtarget *Subtarget = &X86TM->getSubtarget<X86Subtarget>();
   SectionKind::Kind kind = SectionKindForGlobal(GV);
   unsigned flags = SectionFlagsForGlobal(GV, GV->getSection().c_str());
   std::string Name;
@@ -471,44 +470,53 @@ std::string X86TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const {
       assert(0 && "Unsupported global");
   }
 
+  Name += PrintSectionFlags(flags);
+  return Name;
+}
+
+std::string X86TargetAsmInfo::PrintSectionFlags(unsigned flags) const {
+  const X86Subtarget *Subtarget = &X86TM->getSubtarget<X86Subtarget>();
+
+  std::string Flags = "";
+
   // Add all special flags, etc
   switch (Subtarget->TargetType) {
    case X86Subtarget::isELF:
-    Name += ",\"";
+    Flags += ",\"";
 
     if (!(flags & SectionFlags::Debug))
-      Name += 'a';
+      Flags += 'a';
     if (flags & SectionFlags::Code)
-      Name += 'x';
+      Flags += 'x';
     if (flags & SectionFlags::Writeable)
-      Name += 'w';
+      Flags += 'w';
     if (flags & SectionFlags::Mergeable)
-      Name += 'M';
+      Flags += 'M';
     if (flags & SectionFlags::Strings)
-      Name += 'S';
+      Flags += 'S';
     if (flags & SectionFlags::TLS)
-      Name += 'T';
+      Flags += 'T';
 
-    Name += "\"";
+    Flags += "\"";
 
     // FIXME: There can be exceptions here
     if (flags & SectionFlags::BSS)
-      Name += ",@nobits";
+      Flags += ",@nobits";
     else
-      Name += ",@progbits";
+      Flags += ",@progbits";
 
     // FIXME: entity size for mergeable sections
     break;
    case X86Subtarget::isCygwin:
    case X86Subtarget::isMingw:
-    Name += ",\"";
+    Flags += ",\"";
 
     if (flags & SectionFlags::Code)
-      Name += 'x';
+      Flags += 'x';
     if (flags & SectionFlags::Writeable)
-      Name += 'w';
+      Flags += 'w';
 
-    Name += "\"";
+    Flags += "\"";
 
     break;
    case X86Subtarget::isDarwin:
@@ -517,6 +525,5 @@ std::string X86TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const {
     break;
   }
 
-  return Name;
+  return Flags;
 }
-
index 9f9ef3e9af4300dbb39a904bf5524009f9aeea6d..35e7af89862e6644c62512387fa267c62a3114ef 100644 (file)
@@ -30,6 +30,7 @@ namespace llvm {
     virtual std::string SectionForGlobal(const GlobalValue *GV) const;
     virtual std::string UniqueSectionForGlobal(const GlobalValue* GV,
                                                SectionKind::Kind kind) const;
+    virtual std::string PrintSectionFlags(unsigned flags) const;
 
   private:
     const X86TargetMachine* X86TM;