untangle a TargetAsmInfo hack where ELFTargetAsmInfo would create a
authorChris Lattner <sabre@nondot.org>
Sun, 26 Jul 2009 19:23:28 +0000 (19:23 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 26 Jul 2009 19:23:28 +0000 (19:23 +0000)
'unnamed' bss section, but some impls would want a named one.  Since
they don't have consistent behavior, just make each target do their
own thing, instead of doing something "sortof common" then having
targets change immutable objects later.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77165 91177308-0d34-0410-b5e6-96231b3b80d8

16 files changed:
include/llvm/Target/ELFTargetAsmInfo.h
include/llvm/Target/TargetAsmInfo.h
lib/Target/ARM/ARMTargetAsmInfo.cpp
lib/Target/CellSPU/SPUTargetAsmInfo.cpp
lib/Target/ELFTargetAsmInfo.cpp
lib/Target/MSP430/MSP430TargetAsmInfo.cpp
lib/Target/MSP430/MSP430TargetAsmInfo.h
lib/Target/Mips/MipsTargetAsmInfo.cpp
lib/Target/Mips/MipsTargetAsmInfo.h
lib/Target/PowerPC/PPCTargetAsmInfo.cpp
lib/Target/Sparc/SparcTargetAsmInfo.cpp
lib/Target/Sparc/SparcTargetAsmInfo.h
lib/Target/SystemZ/SystemZTargetAsmInfo.cpp
lib/Target/SystemZ/SystemZTargetAsmInfo.h
lib/Target/TargetAsmInfo.cpp
lib/Target/X86/X86TargetAsmInfo.cpp

index eb24dd10f71dc127788ecab9cdbf5b36aed80dcd..1b405d6dcac02b68814a7e36a96b9352dd073e14 100644 (file)
@@ -23,7 +23,7 @@ namespace llvm {
   class Type;
 
   struct ELFTargetAsmInfo: public TargetAsmInfo {
-    explicit ELFTargetAsmInfo(const TargetMachine &TM);
+    ELFTargetAsmInfo(const TargetMachine &TM);
 
     /// getSectionForMergeableConstant - Given a mergeable constant with the
     /// specified size and relocation information, return a section that it
index ab28ec12ff4c5a679ae410d56c7a0aec8cb365bd..af3fd22eb6f0ac5a574b19b64e0fce4a1b842a1b 100644 (file)
@@ -254,7 +254,6 @@ namespace llvm {
     explicit Section(unsigned F = SectionFlags::Invalid) : Flags(F) { }
 
   public:
-    
     unsigned getEntitySize() const { return (Flags >> 24) & 0xFF; }
 
     const std::string &getName() const { return Name; }
@@ -679,11 +678,9 @@ namespace llvm {
     virtual ~TargetAsmInfo();
 
     const Section* getNamedSection(const char *Name,
-                                   unsigned Flags = SectionFlags::None,
-                                   bool Override = false) const;
+                                   unsigned Flags = SectionFlags::None) const;
     const Section* getUnnamedSection(const char *Directive,
-                                     unsigned Flags = SectionFlags::None,
-                                     bool Override = false) const;
+                                     unsigned Flags = SectionFlags::None) const;
 
     /// Measure the specified inline asm to determine an approximation of its
     /// length.
index 34c187492fdb5415725fc70b1444920fe6135de6..95f19c89799aaca98cc599e84149a61b7620a541 100644 (file)
@@ -59,6 +59,9 @@ ARMELFTargetAsmInfo::ARMELFTargetAsmInfo(const ARMBaseTargetMachine &TM):
   ARMTargetAsmInfo<ELFTargetAsmInfo>(TM) {
   Subtarget = &TM.getSubtarget<ARMSubtarget>();
 
+  BSSSection_ = getUnnamedSection("\t.bss",
+                                  SectionFlags::Writable | SectionFlags::BSS);
+
   NeedsSet = false;
   HasLEB128 = true;
   AbsoluteDebugSectionOffsets = true;
index 000ba01c869a44dd3cd286b62f3738ba56e6d9fb..c4d354687ffbd862aea073374581679905896909 100644 (file)
@@ -36,8 +36,7 @@ SPULinuxTargetAsmInfo::SPULinuxTargetAsmInfo(const SPUTargetMachine &TM) :
   // BSS section needs to be emitted as ".section"
   BSSSection = "\t.section\t.bss";
   BSSSection_ = getUnnamedSection("\t.section\t.bss",
-                                  SectionFlags::Writable | SectionFlags::BSS,
-                                  true);
+                                  SectionFlags::Writable | SectionFlags::BSS);
 
   SupportsDebugInformation = true;
   NeedsSet = true;
index b64c0b675d9bbb4d461c1714b0891eee21a4fb94..927cb38b1de97e73b49b4135c34cab796d1c993e 100644 (file)
 #include "llvm/Target/ELFTargetAsmInfo.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetData.h"
-
 using namespace llvm;
 
 ELFTargetAsmInfo::ELFTargetAsmInfo(const TargetMachine &TM)
   : TargetAsmInfo(TM) {
 
-  BSSSection_  = getUnnamedSection("\t.bss",
-                                   SectionFlags::Writable | SectionFlags::BSS);
+  BSSSection_ = getUnnamedSection("\t.bss",
+                                  SectionFlags::Writable | SectionFlags::BSS);
   ReadOnlySection = getNamedSection("\t.rodata", SectionFlags::None);
   TLSDataSection = getNamedSection("\t.tdata",
                                    SectionFlags::Writable | SectionFlags::TLS);
index ab181de13f94d4bc3659e3ef566bffc064306bc9..12ae5528e7ef9a0d3fd922cd1b63a5e4661f916d 100644 (file)
 //===----------------------------------------------------------------------===//
 
 #include "MSP430TargetAsmInfo.h"
-#include "MSP430TargetMachine.h"
-
 using namespace llvm;
 
-MSP430TargetAsmInfo::MSP430TargetAsmInfo(const MSP430TargetMachine &TM)
+MSP430TargetAsmInfo::MSP430TargetAsmInfo(const TargetMachine &TM)
   : ELFTargetAsmInfo(TM) {
   AlignmentIsInBytes = false;
+    
+  BSSSection_ = getUnnamedSection("\t.bss",
+                                  SectionFlags::Writable | SectionFlags::BSS);
 }
index b58d5c9c764cdfa37f07619ac52eaece6245b92a..93ed04f1bcbb89c4fdc7c0d31fba5c42aebdc59f 100644 (file)
 #ifndef MSP430TARGETASMINFO_H
 #define MSP430TARGETASMINFO_H
 
-#include "llvm/Target/TargetAsmInfo.h"
 #include "llvm/Target/ELFTargetAsmInfo.h"
 
 namespace llvm {
-
-  // Forward declaration.
-  class MSP430TargetMachine;
-
   struct MSP430TargetAsmInfo : public ELFTargetAsmInfo {
-    explicit MSP430TargetAsmInfo(const MSP430TargetMachine &TM);
+    explicit MSP430TargetAsmInfo(const TargetMachine &TM);
   };
 
 } // namespace llvm
index 4f1d20792694b7c91cf36adad253cddd1bd69c76..4e7d1bdccc8f6593800786b574b66deffa3c7719 100644 (file)
@@ -13,8 +13,6 @@
 
 #include "MipsTargetAsmInfo.h"
 #include "MipsTargetMachine.h"
-#include "llvm/GlobalVariable.h"
-
 using namespace llvm;
 
 MipsTargetAsmInfo::MipsTargetAsmInfo(const MipsTargetMachine &TM)
@@ -32,6 +30,9 @@ MipsTargetAsmInfo::MipsTargetAsmInfo(const MipsTargetMachine &TM)
   BSSSection                  = "\t.section\t.bss";
   CStringSection              = ".rodata.str";
 
+  BSSSection_ = getUnnamedSection("\t.bss",
+                                  SectionFlags::Writable | SectionFlags::BSS);
+    
   if (!TM.getSubtarget<MipsSubtarget>().hasABICall())
     JumpTableDirective = "\t.word\t";
   else
index f70ca527fca3680d24f67a77982fceecd61fcc2a..e3cfadc47ecde80f2b415fd7d5df7c5333d876ad 100644 (file)
 #ifndef MIPSTARGETASMINFO_H
 #define MIPSTARGETASMINFO_H
 
-#include "MipsSubtarget.h"
-#include "llvm/DerivedTypes.h"
-#include "llvm/Target/TargetAsmInfo.h"
-#include "llvm/Target/TargetOptions.h"
 #include "llvm/Target/ELFTargetAsmInfo.h"
 
 namespace llvm {
-
   // Forward declaration.
-  class GlobalValue;
   class MipsTargetMachine;
 
   struct MipsTargetAsmInfo : public ELFTargetAsmInfo {
     explicit MipsTargetAsmInfo(const MipsTargetMachine &TM);
-
-    private:
-      const MipsSubtarget *Subtarget;
   };
 
 } // namespace llvm
index 0a5530e0dbdcd935dd08e1bf265e47bc900adbee..c85dddf1bff7967f9918921e98bf7c6113e8c0f3 100644 (file)
@@ -50,13 +50,11 @@ PPCDarwinTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
 }
 
 const char *
-PPCDarwinTargetAsmInfo::getEHGlobalPrefix() const
-{
+PPCDarwinTargetAsmInfo::getEHGlobalPrefix() const {
   const PPCSubtarget* Subtarget = &TM.getSubtarget<PPCSubtarget>();
   if (Subtarget->getDarwinVers() > 9)
     return PrivateGlobalPrefix;
-  else
-    return "";
+  return "";
 }
 
 PPCLinuxTargetAsmInfo::PPCLinuxTargetAsmInfo(const PPCTargetMachine &TM) :
@@ -74,9 +72,8 @@ PPCLinuxTargetAsmInfo::PPCLinuxTargetAsmInfo(const PPCTargetMachine &TM) :
   BSSSection = "\t.section\t\".sbss\",\"aw\",@nobits";
 
   // PPC/Linux normally uses named section for BSS.
-  BSSSection_  = getNamedSection("\t.bss",
-                                 SectionFlags::Writable | SectionFlags::BSS,
-                                 /* Override */ true);
+  BSSSection_ = getNamedSection("\t.bss",
+                                SectionFlags::Writable | SectionFlags::BSS);
 
   // Debug Information
   AbsoluteDebugSectionOffsets = true;
index 7b9f449436e620c93b5fd3d450a1e85fc0879307..adec722805e2ca63ca43ddc6103ee018a29ed874 100644 (file)
@@ -15,8 +15,8 @@
 #include "llvm/ADT/SmallVector.h"
 using namespace llvm;
 
-SparcELFTargetAsmInfo::SparcELFTargetAsmInfo(const TargetMachine &TM):
-  ELFTargetAsmInfo(TM) {
+SparcELFTargetAsmInfo::SparcELFTargetAsmInfo(const TargetMachine &TM)
+  ELFTargetAsmInfo(TM) {
   Data16bitsDirective = "\t.half\t";
   Data32bitsDirective = "\t.word\t";
   Data64bitsDirective = 0;  // .xword is only supported by V9.
@@ -27,9 +27,8 @@ SparcELFTargetAsmInfo::SparcELFTargetAsmInfo(const TargetMachine &TM):
   CStringSection=".rodata.str";
 
   // Sparc normally uses named section for BSS.
-  BSSSection_  = getNamedSection("\t.bss",
-                                 SectionFlags::Writable | SectionFlags::BSS,
-                                 /* Override */ true);
+  BSSSection_ = getNamedSection("\t.bss",
+                                SectionFlags::Writable | SectionFlags::BSS);
 }
 
 
index 77cf4e9f4d681536c4f3e549184086950201ea15..cf65c1f914e3e64ccc4ee09b9807f3c524360900 100644 (file)
@@ -14,7 +14,6 @@
 #ifndef SPARCTARGETASMINFO_H
 #define SPARCTARGETASMINFO_H
 
-#include "llvm/Target/TargetAsmInfo.h"
 #include "llvm/Target/ELFTargetAsmInfo.h"
 
 namespace llvm {
index 25048b81bc4e49d31977f2bf8b078f12497bb3e9..3040262b6e526ba5e2152f4060b9ba18ef114446 100644 (file)
@@ -27,4 +27,7 @@ SystemZTargetAsmInfo::SystemZTargetAsmInfo(const SystemZTargetMachine &TM)
   PCSymbol = ".";
 
   NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits";
+    
+  BSSSection_ = getUnnamedSection("\t.bss",
+                                  SectionFlags::Writable | SectionFlags::BSS);
 }
index b0a7639eee9e7fb683d07c166492dada8c703021..98b50d4978408cc43b207a3056584328fa655d06 100644 (file)
@@ -14,7 +14,6 @@
 #ifndef SystemZTARGETASMINFO_H
 #define SystemZTARGETASMINFO_H
 
-#include "llvm/Target/TargetAsmInfo.h"
 #include "llvm/Target/ELFTargetAsmInfo.h"
 
 namespace llvm {
index 0052075fea3ea3f50c5261885f1fbc001200eb54..28d6324cbbc0b95a418264ca11666d977d8d1cc3 100644 (file)
@@ -389,12 +389,12 @@ TargetAsmInfo::getSectionForMergeableConstant(SectionKind Kind) const {
 }
 
 
-const Section *TargetAsmInfo::getNamedSection(const char *Name, unsigned Flags,
-                                              bool Override) const {
+const Section *TargetAsmInfo::getNamedSection(const char *Name,
+                                              unsigned Flags) const {
   Section &S = Sections[Name];
 
   // This is newly-created section, set it up properly.
-  if (S.Flags == SectionFlags::Invalid || Override) {
+  if (S.Name.empty()) {
     S.Flags = Flags | SectionFlags::Named;
     S.Name = Name;
   }
@@ -403,12 +403,11 @@ const Section *TargetAsmInfo::getNamedSection(const char *Name, unsigned Flags,
 }
 
 const Section*
-TargetAsmInfo::getUnnamedSection(const char *Directive, unsigned Flags,
-                                 bool Override) const {
+TargetAsmInfo::getUnnamedSection(const char *Directive, unsigned Flags) const {
   Section& S = Sections[Directive];
 
   // This is newly-created section, set it up properly.
-  if (S.Flags == SectionFlags::Invalid || Override) {
+  if (S.Name.empty()) {
     S.Flags = Flags & ~SectionFlags::Named;
     S.Name = Directive;
   }
index b584cb49c3c1ae3070144ea28863fd5d9bd9d491..802d04a6b3c23355fd5abe3fa5d754bdf9a85e37 100644 (file)
@@ -128,6 +128,9 @@ X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM):
   // Set up DWARF directives
   HasLEB128 = true;  // Target asm supports leb128 directives (little-endian)
 
+  BSSSection_ = getUnnamedSection("\t.bss",
+                                  SectionFlags::Writable | SectionFlags::BSS);
+
   // Debug Information
   AbsoluteDebugSectionOffsets = true;
   SupportsDebugInformation = true;