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

Anton Korobeynikov asl at math.spbu.ru
Wed Jul 9 06:21:49 PDT 2008


Author: asl
Date: Wed Jul  9 08:21:49 2008
New Revision: 53302

URL: http://llvm.org/viewvc/llvm-project?rev=53302&view=rev
Log:
Split PrintSectionFlags

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

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

==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp Wed Jul  9 08:21:49 2008
@@ -313,6 +313,35 @@
   }
 }
 
+std::string X86ELFTargetAsmInfo::PrintSectionFlags(unsigned flags) const {
+  std::string Flags = ",\"";
+
+  if (!(flags & SectionFlags::Debug))
+    Flags += 'a';
+  if (flags & SectionFlags::Code)
+    Flags += 'x';
+  if (flags & SectionFlags::Writeable)
+    Flags += 'w';
+  if (flags & SectionFlags::Mergeable)
+    Flags += 'M';
+  if (flags & SectionFlags::Strings)
+    Flags += 'S';
+  if (flags & SectionFlags::TLS)
+    Flags += 'T';
+
+  Flags += "\"";
+
+  // FIXME: There can be exceptions here
+  if (flags & SectionFlags::BSS)
+    Flags += ", at nobits";
+  else
+    Flags += ", at progbits";
+
+  // FIXME: entity size for mergeable sections
+
+  return Flags;
+}
+
 X86COFFTargetAsmInfo::X86COFFTargetAsmInfo(const X86TargetMachine &TM):
   X86TargetAsmInfo(TM) {
   GlobalPrefix = "_";
@@ -345,32 +374,6 @@
   DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"dr\"";
 }
 
-X86WinTargetAsmInfo::X86WinTargetAsmInfo(const X86TargetMachine &TM):
-  X86TargetAsmInfo(TM) {
-  GlobalPrefix = "_";
-  CommentString = ";";
-
-  PrivateGlobalPrefix = "$";
-  AlignDirective = "\talign\t";
-  ZeroDirective = "\tdb\t";
-  ZeroDirectiveSuffix = " dup(0)";
-  AsciiDirective = "\tdb\t";
-  AscizDirective = 0;
-  Data8bitsDirective = "\tdb\t";
-  Data16bitsDirective = "\tdw\t";
-  Data32bitsDirective = "\tdd\t";
-  Data64bitsDirective = "\tdq\t";
-  HasDotTypeDotSizeDirective = false;
-
-  TextSection = "_text";
-  DataSection = "_data";
-  JumpTableDataSection = NULL;
-  SwitchToSectionDirective = "";
-  TextSectionStartSuffix = "\tsegment 'CODE'";
-  DataSectionStartSuffix = "\tsegment 'DATA'";
-  SectionEndDirectiveSuffix = "\tends\n";
-}
-
 unsigned
 X86COFFTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
                                             bool Global) const {
@@ -430,6 +433,45 @@
   }
 }
 
+std::string X86COFFTargetAsmInfo::PrintSectionFlags(unsigned flags) const {
+  std::string Flags = ",\"";
+
+  if (flags & SectionFlags::Code)
+    Flags += 'x';
+  if (flags & SectionFlags::Writeable)
+    Flags += 'w';
+
+  Flags += "\"";
+
+  return Flags;
+}
+
+X86WinTargetAsmInfo::X86WinTargetAsmInfo(const X86TargetMachine &TM):
+  X86TargetAsmInfo(TM) {
+  GlobalPrefix = "_";
+  CommentString = ";";
+
+  PrivateGlobalPrefix = "$";
+  AlignDirective = "\talign\t";
+  ZeroDirective = "\tdb\t";
+  ZeroDirectiveSuffix = " dup(0)";
+  AsciiDirective = "\tdb\t";
+  AscizDirective = 0;
+  Data8bitsDirective = "\tdb\t";
+  Data16bitsDirective = "\tdw\t";
+  Data32bitsDirective = "\tdd\t";
+  Data64bitsDirective = "\tdq\t";
+  HasDotTypeDotSizeDirective = false;
+
+  TextSection = "_text";
+  DataSection = "_data";
+  JumpTableDataSection = NULL;
+  SwitchToSectionDirective = "";
+  TextSectionStartSuffix = "\tsegment 'CODE'";
+  DataSectionStartSuffix = "\tsegment 'DATA'";
+  SectionEndDirectiveSuffix = "\tends\n";
+}
+
 std::string X86TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const {
   SectionKind::Kind kind = SectionKindForGlobal(GV);
   unsigned flags = SectionFlagsForGlobal(GV, GV->getSection().c_str());
@@ -493,57 +535,3 @@
   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:
-    Flags += ",\"";
-
-    if (!(flags & SectionFlags::Debug))
-      Flags += 'a';
-    if (flags & SectionFlags::Code)
-      Flags += 'x';
-    if (flags & SectionFlags::Writeable)
-      Flags += 'w';
-    if (flags & SectionFlags::Mergeable)
-      Flags += 'M';
-    if (flags & SectionFlags::Strings)
-      Flags += 'S';
-    if (flags & SectionFlags::TLS)
-      Flags += 'T';
-
-    Flags += "\"";
-
-    // FIXME: There can be exceptions here
-    if (flags & SectionFlags::BSS)
-      Flags += ", at nobits";
-    else
-      Flags += ", at progbits";
-
-    // FIXME: entity size for mergeable sections
-    break;
-   case X86Subtarget::isCygwin:
-   case X86Subtarget::isMingw:
-    Flags += ",\"";
-
-    if (flags & SectionFlags::Code)
-      Flags += 'x';
-    if (flags & SectionFlags::Writeable)
-      Flags += 'w';
-
-    Flags += "\"";
-
-    break;
-   case X86Subtarget::isDarwin:
-    // Darwin does not use any special flags
-   default:
-    break;
-  }
-
-  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=53302&r1=53301&r2=53302&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetAsmInfo.h (original)
+++ llvm/trunk/lib/Target/X86/X86TargetAsmInfo.h Wed Jul  9 08:21:49 2008
@@ -26,7 +26,6 @@
 
     virtual bool ExpandInlineAsm(CallInst *CI) const;
     virtual std::string SectionForGlobal(const GlobalValue *GV) const;
-    virtual std::string PrintSectionFlags(unsigned flags) const;
 
   private:
     bool LowerToBSwap(CallInst *CI) const;
@@ -46,6 +45,7 @@
     explicit X86ELFTargetAsmInfo(const X86TargetMachine &TM);
     virtual unsigned PreferredEHDataFormat(DwarfEncoding::Target Reason,
                                            bool Global) const;
+    virtual std::string PrintSectionFlags(unsigned flags) const;
   };
 
   struct X86COFFTargetAsmInfo : public X86TargetAsmInfo {
@@ -54,6 +54,7 @@
                                            bool Global) const;
     virtual std::string UniqueSectionForGlobal(const GlobalValue* GV,
                                                SectionKind::Kind kind) const;
+    virtual std::string PrintSectionFlags(unsigned flags) const;
   };
 
   struct X86WinTargetAsmInfo : public X86TargetAsmInfo {





More information about the llvm-commits mailing list