Add interface for section override. Use this for Sparc, since it should use named...
authorAnton Korobeynikov <asl@math.spbu.ru>
Sat, 16 Aug 2008 12:58:12 +0000 (12:58 +0000)
committerAnton Korobeynikov <asl@math.spbu.ru>
Sat, 16 Aug 2008 12:58:12 +0000 (12:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54844 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/TargetAsmInfo.h
lib/Target/Sparc/SparcTargetAsmInfo.cpp
lib/Target/TargetAsmInfo.cpp

index c346d0ed9870cd415e28c24d7dfa06a3121733ea..ff2491e7ab322dc689e2734c0c7195fa2c2a71ef 100644 (file)
@@ -520,9 +520,11 @@ namespace llvm {
     virtual ~TargetAsmInfo();
 
     const Section* getNamedSection(const char *Name,
     virtual ~TargetAsmInfo();
 
     const Section* getNamedSection(const char *Name,
-                                   unsigned Flags = SectionFlags::None) const;
+                                   unsigned Flags = SectionFlags::None,
+                                   bool Override = false) const;
     const Section* getUnnamedSection(const char *Directive,
     const Section* getUnnamedSection(const char *Directive,
-                                     unsigned Flags = SectionFlags::None) const;
+                                     unsigned Flags = SectionFlags::None,
+                                     bool Override = false) const;
 
     /// Measure the specified inline asm to determine an approximation of its
     /// length.
 
     /// Measure the specified inline asm to determine an approximation of its
     /// length.
index afa5327d952572be2cdf2dad7d2aaa2765bbeae7..c13d45ceec7cf9ad209dc450cfe69b6f898388fb 100644 (file)
@@ -25,6 +25,11 @@ SparcELFTargetAsmInfo::SparcELFTargetAsmInfo(const TargetMachine &TM):
   ConstantPoolSection = "\t.section \".rodata\",#alloc\n";
   COMMDirectiveTakesAlignment = true;
   CStringSection=".rodata.str";
   ConstantPoolSection = "\t.section \".rodata\",#alloc\n";
   COMMDirectiveTakesAlignment = true;
   CStringSection=".rodata.str";
+
+  // Sparc normally uses named section for BSS.
+  BSSSection_  = getNamedSection("\t.bss",
+                                 SectionFlags::Writeable | SectionFlags::BSS,
+                                 /* Override */ true);
 }
 
 std::string SparcELFTargetAsmInfo::printSectionFlags(unsigned flags) const {
 }
 
 std::string SparcELFTargetAsmInfo::printSectionFlags(unsigned flags) const {
index cc0745f680a25d8dc4c2ad5a1fa722329918f438..6baebd0ffe767236bda39befc4bd79d02bdf90dc 100644 (file)
@@ -352,11 +352,12 @@ TargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV,
 }
 
 const Section*
 }
 
 const Section*
-TargetAsmInfo::getNamedSection(const char *Name, unsigned Flags) const {
+TargetAsmInfo::getNamedSection(const char *Name, unsigned Flags,
+                               bool Override) const {
   Section& S = Sections[Name];
 
   // This is newly-created section, set it up properly.
   Section& S = Sections[Name];
 
   // This is newly-created section, set it up properly.
-  if (S.Flags == SectionFlags::Invalid) {
+  if (S.Flags == SectionFlags::Invalid || Override) {
     S.Flags = Flags | SectionFlags::Named;
     S.Name = Name;
   }
     S.Flags = Flags | SectionFlags::Named;
     S.Name = Name;
   }
@@ -365,11 +366,12 @@ TargetAsmInfo::getNamedSection(const char *Name, unsigned Flags) const {
 }
 
 const Section*
 }
 
 const Section*
-TargetAsmInfo::getUnnamedSection(const char *Directive, unsigned Flags) const {
+TargetAsmInfo::getUnnamedSection(const char *Directive, unsigned Flags,
+                                 bool Override) const {
   Section& S = Sections[Directive];
 
   // This is newly-created section, set it up properly.
   Section& S = Sections[Directive];
 
   // This is newly-created section, set it up properly.
-  if (S.Flags == SectionFlags::Invalid) {
+  if (S.Flags == SectionFlags::Invalid || Override) {
     S.Flags = Flags & ~SectionFlags::Named;
     S.Name = Directive;
   }
     S.Flags = Flags & ~SectionFlags::Named;
     S.Name = Directive;
   }