[llvm-commits] [llvm] r53297 - in /llvm/trunk: include/llvm/Target/TargetAsmInfo.h lib/Target/X86/X86TargetAsmInfo.cpp lib/Target/X86/X86TargetAsmInfo.h

Anton Korobeynikov asl at math.spbu.ru
Wed Jul 9 06:20:08 PDT 2008


Author: asl
Date: Wed Jul  9 08:20:07 2008
New Revision: 53297

URL: http://llvm.org/viewvc/llvm-project?rev=53297&view=rev
Log:
Move flag decoding stuff into special hook

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

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

==============================================================================
--- llvm/trunk/include/llvm/Target/TargetAsmInfo.h (original)
+++ llvm/trunk/include/llvm/Target/TargetAsmInfo.h Wed Jul  9 08:20:07 2008
@@ -474,6 +474,8 @@
     virtual std::string UniqueSectionForGlobal(const GlobalValue* GV,
                                                SectionKind::Kind kind) const;
 
+    virtual std::string PrintSectionFlags(unsigned flags) const { return ""; }
+
     // Accessors.
     //
     const char *getTextSection() const {

Modified: llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp?rev=53297&r1=53296&r2=53297&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp Wed Jul  9 08:20:07 2008
@@ -411,7 +411,6 @@
 
 
 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 @@
       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 += ", at nobits";
+      Flags += ", at nobits";
     else
-      Name += ", at progbits";
+      Flags += ", at 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 @@
     break;
   }
 
-  return Name;
+  return Flags;
 }
-

Modified: llvm/trunk/lib/Target/X86/X86TargetAsmInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetAsmInfo.h?rev=53297&r1=53296&r2=53297&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetAsmInfo.h (original)
+++ llvm/trunk/lib/Target/X86/X86TargetAsmInfo.h Wed Jul  9 08:20:07 2008
@@ -30,6 +30,7 @@
     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;





More information about the llvm-commits mailing list