[llvm-commits] [llvm] r78958 - in /llvm/trunk: include/llvm/MC/MCSectionELF.h include/llvm/Target/TargetAsmInfo.h include/llvm/Target/TargetLoweringObjectFile.h lib/MC/MCSectionELF.cpp lib/Target/PowerPC/PPCISelLowering.cpp lib/Target/PowerPC/PPCTargetAsmInfo.cpp lib/Target/TargetAsmInfo.cpp lib/Target/TargetLoweringObjectFile.cpp test/CodeGen/PowerPC/sections.ll

Bruno Cardoso Lopes bruno.cardoso at gmail.com
Thu Aug 13 16:30:21 PDT 2009


Author: bruno
Date: Thu Aug 13 18:30:21 2009
New Revision: 78958

URL: http://llvm.org/viewvc/llvm-project?rev=78958&view=rev
Log:
Remove HasCrazyBSS and add a flag in TAI to indicate that '.section' 
must be emitted for PowerPC-Linux '.bss' section

Added:
    llvm/trunk/test/CodeGen/PowerPC/sections.ll
Modified:
    llvm/trunk/include/llvm/MC/MCSectionELF.h
    llvm/trunk/include/llvm/Target/TargetAsmInfo.h
    llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h
    llvm/trunk/lib/MC/MCSectionELF.cpp
    llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
    llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp
    llvm/trunk/lib/Target/TargetAsmInfo.cpp
    llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp

Modified: llvm/trunk/include/llvm/MC/MCSectionELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSectionELF.h?rev=78958&r1=78957&r2=78958&view=diff

==============================================================================
--- llvm/trunk/include/llvm/MC/MCSectionELF.h (original)
+++ llvm/trunk/include/llvm/MC/MCSectionELF.h Thu Aug 13 18:30:21 2009
@@ -30,28 +30,24 @@
   /// below.
   unsigned Flags;
 
-  /// HasCrazyBSS - PPC/Linux doesn't support the .bss directive, it 
-  /// needs .section .bss. TODO: replace this with a TAI method.
-  bool HasCrazyBSS;
-
   /// IsExplicit - Indicates that this section comes from globals with an
   /// explicit section specfied.
   bool IsExplicit;
   
   MCSectionELF(const StringRef &Section, unsigned T, unsigned F, 
-               SectionKind K, bool hasCrazyBSS, bool isExplicit)
+               SectionKind K, bool isExplicit)
     : MCSection(K), SectionName(Section.str()), Type(T), Flags(F), 
-      HasCrazyBSS(hasCrazyBSS), IsExplicit(isExplicit) {}
+      IsExplicit(isExplicit) {}
 public:
   
   static MCSectionELF *Create(const StringRef &Section, unsigned Type, 
-                              unsigned Flags, SectionKind K, 
-                              bool hasCrazyBSS, bool isExplicit, 
+                              unsigned Flags, SectionKind K, bool isExplicit,
                               MCContext &Ctx);
 
   /// ShouldOmitSectionDirective - Decides whether a '.section' directive
   /// should be printed before the section name
-  bool ShouldOmitSectionDirective(const char *Name) const;
+  bool ShouldOmitSectionDirective(const char *Name, 
+                                  const TargetAsmInfo &TAI) const;
 
   /// ShouldPrintSectionType - Only prints the section type if supported
   bool ShouldPrintSectionType(unsigned Ty) const;

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

==============================================================================
--- llvm/trunk/include/llvm/Target/TargetAsmInfo.h (original)
+++ llvm/trunk/include/llvm/Target/TargetAsmInfo.h Thu Aug 13 18:30:21 2009
@@ -164,6 +164,11 @@
     /// Style" syntax for section switching ("#alloc,#write" etc) instead of the
     /// normal ELF syntax (,"a,w") in .section directives.
     bool SunStyleELFSectionSwitchSyntax;   // Defaults to false.
+
+    /// UsesELFSectionDirectiveForBSS - This is true if this target uses ELF
+    /// '.section' directive before the '.bss' one. It's used for PPC/Linux 
+    /// which doesn't support the '.bss' directive only.
+    bool UsesELFSectionDirectiveForBSS;  // Defaults to false.
     
     //===--- Alignment Information ----------------------------------------===//
 
@@ -336,6 +341,9 @@
       return SunStyleELFSectionSwitchSyntax;
     }
     
+    bool usesELFSectionDirectiveForBSS() const {
+      return UsesELFSectionDirectiveForBSS;
+    }
 
     // Accessors.
     //

Modified: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h?rev=78958&r1=78957&r2=78958&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h (original)
+++ llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h Thu Aug 13 18:30:21 2009
@@ -183,7 +183,6 @@
   
 
 class TargetLoweringObjectFileELF : public TargetLoweringObjectFile {
-  bool HasCrazyBSS;
   mutable void *UniquingMap;
 protected:
   /// TLSDataSection - Section directive for Thread Local data.
@@ -209,13 +208,9 @@
                                  unsigned Flags, SectionKind Kind,
                                  bool IsExplicit = false) const;
 public:
-  TargetLoweringObjectFileELF(// FIXME: REMOVE AFTER UNIQUING IS FIXED.
-                              bool hasCrazyBSS = false)
-    : HasCrazyBSS(hasCrazyBSS), UniquingMap(0) {}
-  
+  TargetLoweringObjectFileELF() : UniquingMap(0) {}
   ~TargetLoweringObjectFileELF();
   
-  
   virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
   
   /// getSectionForConstant - Given a constant with the SectionKind, return a

Modified: llvm/trunk/lib/MC/MCSectionELF.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCSectionELF.cpp?rev=78958&r1=78957&r2=78958&view=diff

==============================================================================
--- llvm/trunk/lib/MC/MCSectionELF.cpp (original)
+++ llvm/trunk/lib/MC/MCSectionELF.cpp Thu Aug 13 18:30:21 2009
@@ -16,20 +16,21 @@
 
 MCSectionELF *MCSectionELF::
 Create(const StringRef &Section, unsigned Type, unsigned Flags,
-       SectionKind K, bool hasCrazyBSS, bool isExplicit, MCContext &Ctx) {
+       SectionKind K, bool isExplicit, MCContext &Ctx) {
   return new 
-    (Ctx) MCSectionELF(Section, Type, Flags, K, hasCrazyBSS, isExplicit);
+    (Ctx) MCSectionELF(Section, Type, Flags, K, isExplicit);
 }
 
 // ShouldOmitSectionDirective - Decides whether a '.section' directive
 // should be printed before the section name
-bool MCSectionELF::ShouldOmitSectionDirective(const char *Name) const {
+bool MCSectionELF::ShouldOmitSectionDirective(const char *Name,
+                                        const TargetAsmInfo &TAI) const {
   
-  // PPC/Linux doesn't support the .bss directive, it needs .section .bss.
   // FIXME: Does .section .bss/.data/.text work everywhere??
-  if ((!HasCrazyBSS && strncmp(Name, ".bss", 4) == 0) || 
-      strncmp(Name, ".text", 5) == 0 || 
-      strncmp(Name, ".data", 5) == 0)
+  if (strncmp(Name, ".text", 5) == 0 || 
+      strncmp(Name, ".data", 5) == 0 ||
+      (strncmp(Name, ".bss", 4) == 0 && 
+       !TAI.usesELFSectionDirectiveForBSS())) 
     return true;
 
   return false;
@@ -46,8 +47,8 @@
 
 void MCSectionELF::PrintSwitchToSection(const TargetAsmInfo &TAI,
                                         raw_ostream &OS) const {
-  
-  if (ShouldOmitSectionDirective(SectionName.c_str())) {
+   
+  if (ShouldOmitSectionDirective(SectionName.c_str(), TAI)) {
     OS << '\t' << getSectionName() << '\n';
     return;
   }

Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=78958&r1=78957&r2=78958&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Thu Aug 13 18:30:21 2009
@@ -60,7 +60,7 @@
 static TargetLoweringObjectFile *CreateTLOF(const PPCTargetMachine &TM) {
   if (TM.getSubtargetImpl()->isDarwin())
     return new TargetLoweringObjectFileMachO();
-  return new TargetLoweringObjectFileELF(true);
+  return new TargetLoweringObjectFileELF();
 }
 
 

Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp?rev=78958&r1=78957&r2=78958&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp Thu Aug 13 18:30:21 2009
@@ -30,6 +30,9 @@
   PrivateGlobalPrefix = ".L";
   UsedDirective = "\t# .no_dead_strip\t";
   WeakRefDirective = "\t.weak\t";
+  
+  // Uses '.section' before '.bss' directive
+  UsesELFSectionDirectiveForBSS = true;  
 
   // Debug Information
   AbsoluteDebugSectionOffsets = true;

Modified: llvm/trunk/lib/Target/TargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetAsmInfo.cpp?rev=78958&r1=78957&r2=78958&view=diff

==============================================================================
--- llvm/trunk/lib/Target/TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/TargetAsmInfo.cpp Thu Aug 13 18:30:21 2009
@@ -50,6 +50,7 @@
   Data32bitsDirective = "\t.long\t";
   Data64bitsDirective = "\t.quad\t";
   SunStyleELFSectionSwitchSyntax = false;
+  UsesELFSectionDirectiveForBSS = false;
   AlignDirective = "\t.align\t";
   AlignmentIsInBytes = true;
   TextAlignFillValue = 0;

Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=78958&r1=78957&r2=78958&view=diff

==============================================================================
--- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original)
+++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Thu Aug 13 18:30:21 2009
@@ -298,8 +298,8 @@
   const MCSectionELF *&Entry = Map[Section];
   if (Entry) return Entry;
   
-  return Entry = MCSectionELF::Create(Section, Type, Flags, Kind, HasCrazyBSS, 
-                                      IsExplicit, getContext());
+  return Entry = MCSectionELF::Create(Section, Type, Flags, Kind, IsExplicit,
+                                      getContext());
 }
 
 void TargetLoweringObjectFileELF::Initialize(MCContext &Ctx,

Added: llvm/trunk/test/CodeGen/PowerPC/sections.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/sections.ll?rev=78958&view=auto

==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/sections.ll (added)
+++ llvm/trunk/test/CodeGen/PowerPC/sections.ll Thu Aug 13 18:30:21 2009
@@ -0,0 +1,8 @@
+; Test to make sure that bss sections are printed with '.section' directive.
+; RUN: llvm-as < %s | llc -mtriple=powerpc-unknown-linux-gnu | FileCheck %s
+
+ at A = global i32 0
+
+; CHECK:  .section  .bss,"aw", at nobits
+; CHECK:  .global A
+





More information about the llvm-commits mailing list