[llvm-commits] [llvm] r77186 - in /llvm/trunk: include/llvm/Target/ lib/Target/ lib/Target/ARM/ lib/Target/CellSPU/ lib/Target/MSP430/ lib/Target/Mips/ lib/Target/PIC16/ lib/Target/PowerPC/ lib/Target/Sparc/ lib/Target/SystemZ/ lib/Target/X86/ lib/Target/XCore/

Chris Lattner sabre at nondot.org
Sun Jul 26 23:17:17 PDT 2009


Author: lattner
Date: Mon Jul 27 01:17:14 2009
New Revision: 77186

URL: http://llvm.org/viewvc/llvm-project?rev=77186&view=rev
Log:
Eliminate getNamed/getUnnamedSection, adding a new and unified getOrCreateSection
instead.

Modified:
    llvm/trunk/include/llvm/Target/TargetAsmInfo.h
    llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp
    llvm/trunk/lib/Target/CellSPU/SPUTargetAsmInfo.cpp
    llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp
    llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp
    llvm/trunk/lib/Target/MSP430/MSP430TargetAsmInfo.cpp
    llvm/trunk/lib/Target/Mips/MipsTargetAsmInfo.cpp
    llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp
    llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.cpp
    llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp
    llvm/trunk/lib/Target/Sparc/SparcTargetAsmInfo.cpp
    llvm/trunk/lib/Target/SystemZ/SystemZTargetAsmInfo.cpp
    llvm/trunk/lib/Target/TargetAsmInfo.cpp
    llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp
    llvm/trunk/lib/Target/XCore/XCoreTargetAsmInfo.cpp

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

==============================================================================
--- llvm/trunk/include/llvm/Target/TargetAsmInfo.h (original)
+++ llvm/trunk/include/llvm/Target/TargetAsmInfo.h Mon Jul 27 01:17:14 2009
@@ -639,10 +639,9 @@
     explicit TargetAsmInfo(const TargetMachine &TM);
     virtual ~TargetAsmInfo();
 
-    const Section* getNamedSection(const char *Name,
-                                   SectionKind::Kind K) const;
-    const Section* getUnnamedSection(const char *Directive,
-                                     SectionKind::Kind K) const;
+    const Section *getOrCreateSection(const char *Name,
+                                      bool isDirective,
+                                      SectionKind::Kind K) const;
 
     /// Measure the specified inline asm to determine an approximation of its
     /// length.

Modified: llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp?rev=77186&r1=77185&r2=77186&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp Mon Jul 27 01:17:14 2009
@@ -59,7 +59,7 @@
   ARMTargetAsmInfo<ELFTargetAsmInfo>(TM) {
   Subtarget = &TM.getSubtarget<ARMSubtarget>();
 
-  BSSSection_ = getUnnamedSection("\t.bss", SectionKind::BSS);
+  BSSSection_ = getOrCreateSection("\t.bss", true, SectionKind::BSS);
 
   NeedsSet = false;
   HasLEB128 = true;

Modified: llvm/trunk/lib/Target/CellSPU/SPUTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUTargetAsmInfo.cpp?rev=77186&r1=77185&r2=77186&view=diff

==============================================================================
--- llvm/trunk/lib/Target/CellSPU/SPUTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/CellSPU/SPUTargetAsmInfo.cpp Mon Jul 27 01:17:14 2009
@@ -35,7 +35,7 @@
 
   // BSS section needs to be emitted as ".section"
   BSSSection = "\t.section\t.bss";
-  BSSSection_ = getUnnamedSection("\t.section\t.bss", SectionKind::BSS);
+  BSSSection_ = getOrCreateSection("\t.bss", false, SectionKind::BSS);
 
   SupportsDebugInformation = true;
   NeedsSet = true;

Modified: llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp?rev=77186&r1=77185&r2=77186&view=diff

==============================================================================
--- llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp Mon Jul 27 01:17:14 2009
@@ -28,30 +28,30 @@
 DarwinTargetAsmInfo::DarwinTargetAsmInfo(const TargetMachine &TM) 
   : TargetAsmInfo(TM) {
 
-  CStringSection_ = getUnnamedSection("\t.cstring",
-                                      SectionKind::MergeableCString);
-  FourByteConstantSection = getUnnamedSection("\t.literal4\n",
-                                              SectionKind::MergeableConst4);
-  EightByteConstantSection = getUnnamedSection("\t.literal8\n",
-                                               SectionKind::MergeableConst8);
+  CStringSection_ = getOrCreateSection("\t.cstring", true,
+                                       SectionKind::MergeableCString);
+  FourByteConstantSection = getOrCreateSection("\t.literal4\n", true,
+                                               SectionKind::MergeableConst4);
+  EightByteConstantSection = getOrCreateSection("\t.literal8\n", true,
+                                                SectionKind::MergeableConst8);
 
   // Note: 16-byte constant section is subtarget specific and should be provided
   // there, if needed.
   SixteenByteConstantSection = 0;
 
-  ReadOnlySection = getUnnamedSection("\t.const", SectionKind::ReadOnly);
+  ReadOnlySection = getOrCreateSection("\t.const", true, SectionKind::ReadOnly);
 
   TextCoalSection =
-    getNamedSection("\t__TEXT,__textcoal_nt,coalesced,pure_instructions",
-                    SectionKind::Text);
-  ConstTextCoalSection = getNamedSection("\t__TEXT,__const_coal,coalesced",
-                                         SectionKind::Text);
-  ConstDataCoalSection = getNamedSection("\t__DATA,__const_coal,coalesced",
-                                         SectionKind::Text);
-  ConstDataSection = getUnnamedSection("\t.const_data",
-                                       SectionKind::ReadOnlyWithRel);
-  DataCoalSection = getNamedSection("\t__DATA,__datacoal_nt,coalesced",
-                                    SectionKind::DataRel);
+    getOrCreateSection("\t__TEXT,__textcoal_nt,coalesced,pure_instructions",
+                       false, SectionKind::Text);
+  ConstTextCoalSection = getOrCreateSection("\t__TEXT,__const_coal,coalesced",
+                                            false, SectionKind::Text);
+  ConstDataCoalSection = getOrCreateSection("\t__DATA,__const_coal,coalesced",
+                                            false, SectionKind::Text);
+  ConstDataSection = getOrCreateSection("\t.const_data", true,
+                                        SectionKind::ReadOnlyWithRel);
+  DataCoalSection = getOrCreateSection("\t__DATA,__datacoal_nt,coalesced",
+                                       false, SectionKind::DataRel);
     
   
   // Common settings for all Darwin targets.

Modified: llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp?rev=77186&r1=77185&r2=77186&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp Mon Jul 27 01:17:14 2009
@@ -26,25 +26,28 @@
 
 ELFTargetAsmInfo::ELFTargetAsmInfo(const TargetMachine &TM)
   : TargetAsmInfo(TM) {
-
-  ReadOnlySection = getNamedSection("\t.rodata", SectionKind::ReadOnly);
-  TLSDataSection = getNamedSection("\t.tdata", SectionKind::ThreadData);
-  TLSBSSSection = getNamedSection("\t.tbss", SectionKind::ThreadBSS);
-
-  DataRelSection = getNamedSection("\t.data.rel", SectionKind::DataRel);
-  DataRelLocalSection = getNamedSection("\t.data.rel.local",
-                                        SectionKind::DataRelLocal);
-  DataRelROSection = getNamedSection("\t.data.rel.ro",
-                                     SectionKind::ReadOnlyWithRel);
-  DataRelROLocalSection = getNamedSection("\t.data.rel.ro.local",
-                                          SectionKind::ReadOnlyWithRelLocal);
+  ReadOnlySection =
+    getOrCreateSection("\t.rodata", false, SectionKind::ReadOnly);
+  TLSDataSection =
+    getOrCreateSection("\t.tdata", false, SectionKind::ThreadData);
+  TLSBSSSection = getOrCreateSection("\t.tbss", false, SectionKind::ThreadBSS);
+
+  DataRelSection = getOrCreateSection("\t.data.rel", false,
+                                      SectionKind::DataRel);
+  DataRelLocalSection = getOrCreateSection("\t.data.rel.local", false,
+                                           SectionKind::DataRelLocal);
+  DataRelROSection = getOrCreateSection("\t.data.rel.ro", false,
+                                        SectionKind::ReadOnlyWithRel);
+  DataRelROLocalSection =
+    getOrCreateSection("\t.data.rel.ro.local", false,
+                       SectionKind::ReadOnlyWithRelLocal);
     
-  MergeableConst4Section = getNamedSection(".rodata.cst4",
-                                           SectionKind::MergeableConst4);
-  MergeableConst8Section = getNamedSection(".rodata.cst8",
-                                           SectionKind::MergeableConst8);
-  MergeableConst16Section = getNamedSection(".rodata.cst16",
-                                            SectionKind::MergeableConst16);
+  MergeableConst4Section = getOrCreateSection(".rodata.cst4", false,
+                                              SectionKind::MergeableConst4);
+  MergeableConst8Section = getOrCreateSection(".rodata.cst8", false,
+                                              SectionKind::MergeableConst8);
+  MergeableConst16Section = getOrCreateSection(".rodata.cst16", false,
+                                               SectionKind::MergeableConst16);
 }
 
 
@@ -158,7 +161,8 @@
       Align = Size;
 
     std::string Name = getCStringSection() + utostr(Size) + '.' + utostr(Align);
-    return getNamedSection(Name.c_str(), SectionKind::MergeableCString);
+    return getOrCreateSection(Name.c_str(), false,
+                              SectionKind::MergeableCString);
   }
 
   return getReadOnlySection();

Modified: llvm/trunk/lib/Target/MSP430/MSP430TargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430TargetAsmInfo.cpp?rev=77186&r1=77185&r2=77186&view=diff

==============================================================================
--- llvm/trunk/lib/Target/MSP430/MSP430TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/MSP430/MSP430TargetAsmInfo.cpp Mon Jul 27 01:17:14 2009
@@ -18,5 +18,5 @@
   : ELFTargetAsmInfo(TM) {
   AlignmentIsInBytes = false;
     
-  BSSSection_ = getUnnamedSection("\t.bss", SectionKind::BSS);
+  BSSSection_ = getOrCreateSection("\t.bss", true, SectionKind::BSS);
 }

Modified: llvm/trunk/lib/Target/Mips/MipsTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetAsmInfo.cpp?rev=77186&r1=77185&r2=77186&view=diff

==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsTargetAsmInfo.cpp Mon Jul 27 01:17:14 2009
@@ -30,7 +30,7 @@
   BSSSection                  = "\t.section\t.bss";
   CStringSection              = ".rodata.str";
 
-  BSSSection_ = getUnnamedSection("\t.bss", SectionKind::BSS);
+  BSSSection_ = getOrCreateSection("\t.bss", true, SectionKind::BSS);
     
   if (!TM.getSubtarget<MipsSubtarget>().hasABICall())
     JumpTableDirective = "\t.word\t";

Modified: llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp?rev=77186&r1=77185&r2=77186&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp Mon Jul 27 01:17:14 2009
@@ -62,7 +62,7 @@
   const char *codeSection = PAN::getCodeSectionName(CurrentFnName).c_str();
  
   const Section *fCodeSection = 
-    TAI->getNamedSection(codeSection, SectionKind::Text);
+    TAI->getOrCreateSection(codeSection, false, SectionKind::Text);
   // Start the Code Section.
   O <<  "\n";
   SwitchToSection(fCodeSection);
@@ -292,7 +292,7 @@
   const char *SectionName = PAN::getFrameSectionName(CurrentFnName).c_str();
 
   const Section *fPDataSection =
-    TAI->getNamedSection(SectionName, SectionKind::DataRel);
+    TAI->getOrCreateSection(SectionName, false, SectionKind::DataRel);
   SwitchToSection(fPDataSection);
   
   // Emit function frame label

Modified: llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.cpp?rev=77186&r1=77185&r2=77186&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.cpp Mon Jul 27 01:17:14 2009
@@ -37,21 +37,24 @@
   ZeroDirective = NULL;
   AsciiDirective = " dt ";
   AscizDirective = NULL;
-  BSSSection_  = getNamedSection("udata.# UDATA", SectionKind::BSS);
-  ReadOnlySection = getNamedSection("romdata.# ROMDATA", SectionKind::ReadOnly);
-  DataSection = getNamedSection("idata.# IDATA", SectionKind::DataRel);
+  BSSSection_  = getOrCreateSection("udata.# UDATA", false, SectionKind::BSS);
+  ReadOnlySection = getOrCreateSection("romdata.# ROMDATA", false,
+                                       SectionKind::ReadOnly);
+  DataSection = getOrCreateSection("idata.# IDATA", false,SectionKind::DataRel);
   SwitchToSectionDirective = "";
   // Need because otherwise a .text symbol is emitted by DwarfWriter
   // in BeginModule, and gpasm cribbs for that .text symbol.
-  TextSection = getUnnamedSection("", SectionKind::Text);
+  TextSection = getOrCreateSection("", true, SectionKind::Text);
   PIC16Section *ROSection = new PIC16Section(getReadOnlySection());
   ROSections.push_back(ROSection);
     
   // FIXME: I don't know what the classification of these sections really is.
-  ExternalVarDecls = new PIC16Section(getNamedSection("ExternalVarDecls",
-                                                      SectionKind::Metadata));
-  ExternalVarDefs = new PIC16Section(getNamedSection("ExternalVarDefs",
-                                                     SectionKind::Metadata));
+  ExternalVarDecls = new PIC16Section(getOrCreateSection("ExternalVarDecls",
+                                                         false,
+                                                         SectionKind::Metadata));
+  ExternalVarDefs = new PIC16Section(getOrCreateSection("ExternalVarDefs",
+                                                        false,
+                                                        SectionKind::Metadata));
   // Set it to false because we weed to generate c file name and not bc file
   // name.
   HasSingleParameterDotFile = false;
@@ -98,9 +101,9 @@
   // No BSS section spacious enough was found. Crate a new one.
   if (!FoundBSS) {
     std::string name = PAN::getUdataSectionName(BSSSections.size());
-    const Section *NewSection = getNamedSection(name.c_str(),
-                                                // FIXME.
-                                                SectionKind::Metadata);
+    const Section *NewSection = getOrCreateSection(name.c_str(), false,
+                                                   // FIXME.
+                                                   SectionKind::Metadata);
 
     FoundBSS = new PIC16Section(NewSection);
 
@@ -140,9 +143,10 @@
   // No IDATA section spacious enough was found. Crate a new one.
   if (!FoundIDATA) {
     std::string name = PAN::getIdataSectionName(IDATASections.size());
-    const Section *NewSection = getNamedSection(name.c_str(),
-                                                // FIXME.
-                                                SectionKind::Metadata);
+    const Section *NewSection = getOrCreateSection(name.c_str(),
+                                                   false,
+                                                   // FIXME.
+                                                   SectionKind::Metadata);
 
     FoundIDATA = new PIC16Section(NewSection);
 
@@ -175,9 +179,10 @@
 
   // No Auto section was found. Crate a new one.
   if (!FoundAutoSec) {
-    const Section *NewSection = getNamedSection(name.c_str(),
-                                                // FIXME.
-                                                SectionKind::Metadata);
+    const Section *NewSection = getOrCreateSection(name.c_str(),
+                                                   // FIXME.
+                                                   false,
+                                                   SectionKind::Metadata);
 
     FoundAutoSec = new PIC16Section(NewSection);
 
@@ -325,7 +330,8 @@
   
   PIC16Section *NewBSS = FoundBSS;
   if (NewBSS == NULL) {
-    const Section *NewSection = getNamedSection(Name.c_str(), SectionKind::BSS);
+    const Section *NewSection = getOrCreateSection(Name.c_str(),
+                                                   false, SectionKind::BSS);
     NewBSS = new PIC16Section(NewSection);
     BSSSections.push_back(NewBSS);
   }
@@ -376,9 +382,10 @@
 
   PIC16Section *NewIDATASec = FoundIDATASec;
   if (NewIDATASec == NULL) {
-    const Section *NewSection = getNamedSection(Name.c_str(),
-                                                // FIXME:
-                                                SectionKind::Metadata);
+    const Section *NewSection = getOrCreateSection(Name.c_str(),
+                                                   false,
+                                                   // FIXME:
+                                                   SectionKind::Metadata);
     NewIDATASec = new PIC16Section(NewSection);
     IDATASections.push_back(NewIDATASec);
   }
@@ -416,8 +423,9 @@
 
   PIC16Section *NewRomSec = FoundROSec;
   if (NewRomSec == NULL) {
-    const Section *NewSection = getNamedSection(Name.c_str(),
-                                                SectionKind::ReadOnly);
+    const Section *NewSection = getOrCreateSection(Name.c_str(),
+                                                   false,
+                                                   SectionKind::ReadOnly);
     NewRomSec = new PIC16Section(NewSection);
     ROSections.push_back(NewRomSec);
   }

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

==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp Mon Jul 27 01:17:14 2009
@@ -71,7 +71,7 @@
   BSSSection = "\t.section\t\".sbss\",\"aw\", at nobits";
 
   // PPC/Linux normally uses named section for BSS.
-  BSSSection_ = getNamedSection("\t.bss", SectionKind::BSS);
+  BSSSection_ = getOrCreateSection("\t.bss", true, SectionKind::BSS);
 
   // Debug Information
   AbsoluteDebugSectionOffsets = true;

Modified: llvm/trunk/lib/Target/Sparc/SparcTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcTargetAsmInfo.cpp?rev=77186&r1=77185&r2=77186&view=diff

==============================================================================
--- llvm/trunk/lib/Target/Sparc/SparcTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/Sparc/SparcTargetAsmInfo.cpp Mon Jul 27 01:17:14 2009
@@ -27,7 +27,7 @@
   CStringSection=".rodata.str";
 
   // Sparc normally uses named section for BSS.
-  BSSSection_ = getNamedSection("\t.bss", SectionKind::BSS);
+  BSSSection_ = getOrCreateSection("\t.bss", true, SectionKind::BSS);
 }
 
 

Modified: llvm/trunk/lib/Target/SystemZ/SystemZTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZTargetAsmInfo.cpp?rev=77186&r1=77185&r2=77186&view=diff

==============================================================================
--- llvm/trunk/lib/Target/SystemZ/SystemZTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/SystemZ/SystemZTargetAsmInfo.cpp Mon Jul 27 01:17:14 2009
@@ -28,5 +28,5 @@
 
   NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\", at progbits";
     
-  BSSSection_ = getUnnamedSection("\t.bss", SectionKind::BSS);
+  BSSSection_ = getOrCreateSection("\t.bss", true, SectionKind::BSS);
 }

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

==============================================================================
--- llvm/trunk/lib/Target/TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/TargetAsmInfo.cpp Mon Jul 27 01:17:14 2009
@@ -122,8 +122,8 @@
   DwarfEHFrameSection = ".eh_frame";
   DwarfExceptionSection = ".gcc_except_table";
   AsmTransCBE = 0;
-  TextSection = getUnnamedSection("\t.text", SectionKind::Text);
-  DataSection = getUnnamedSection("\t.data", SectionKind::DataRel);
+  TextSection = getOrCreateSection("\t.text", true, SectionKind::Text);
+  DataSection = getOrCreateSection("\t.data", true, SectionKind::DataRel);
 }
 
 TargetAsmInfo::~TargetAsmInfo() {
@@ -314,7 +314,7 @@
     // section and still get the appropriate section flags printed.
     GVKind = getKindForNamedSection(GV->getSection().c_str(), GVKind);
     
-    return getNamedSection(GV->getSection().c_str(), GVKind);
+    return getOrCreateSection(GV->getSection().c_str(), false, GVKind);
   }
 
   // If this global is linkonce/weak and the target handles this by emitting it
@@ -323,7 +323,7 @@
     if (const char *Prefix = getSectionPrefixForUniqueGlobal(Kind)) {
       // FIXME: Use mangler interface (PR4584).
       std::string Name = Prefix+GV->getNameStr();
-      return getNamedSection(Name.c_str(), GVKind);
+      return getOrCreateSection(Name.c_str(), false, GVKind);
     }
   }
   
@@ -364,33 +364,20 @@
 }
 
 
-const Section *TargetAsmInfo::getNamedSection(const char *Name,
-                                              SectionKind::Kind Kind) const {
+const Section *TargetAsmInfo::getOrCreateSection(const char *Name,
+                                                 bool isDirective,
+                                                 SectionKind::Kind Kind) const {
   Section &S = Sections[Name];
 
   // This is newly-created section, set it up properly.
   if (S.Name.empty()) {
-    S.Kind = SectionKind::get(Kind, false /*weak*/, true /*Named*/);
+    S.Kind = SectionKind::get(Kind, false /*weak*/, !isDirective);
     S.Name = Name;
   }
 
   return &S;
 }
 
-const Section*
-TargetAsmInfo::getUnnamedSection(const char *Directive,
-                                 SectionKind::Kind Kind) const {
-  Section& S = Sections[Directive];
-
-  // This is newly-created section, set it up properly.
-  if (S.Name.empty()) {
-    S.Kind = SectionKind::get(Kind, false /*weak*/, false /*Named*/);
-    S.Name = Directive;
-  }
-
-  return &S;
-}
-
 unsigned TargetAsmInfo::getULEB128Size(unsigned Value) {
   unsigned Size = 0;
   do {

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

==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp Mon Jul 27 01:17:14 2009
@@ -57,8 +57,8 @@
     ConstantPoolSection = "\t.const\n";
   // FIXME: Why don't we always use this section?
   if (is64Bit)
-    SixteenByteConstantSection = getUnnamedSection("\t.literal16\n",
-                                                 SectionKind::MergeableConst16);
+    SixteenByteConstantSection = 
+      getOrCreateSection("\t.literal16\n", true, SectionKind::MergeableConst16);
   LCOMMDirective = "\t.lcomm\t";
 
   // Leopard and above support aligned common symbols.
@@ -100,23 +100,20 @@
                                               bool Global) const {
   if (Reason == DwarfEncoding::Functions && Global)
     return (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4);
-  else if (Reason == DwarfEncoding::CodeLabels || !Global)
+  if (Reason == DwarfEncoding::CodeLabels || !Global)
     return DW_EH_PE_pcrel;
-  else
-    return DW_EH_PE_absptr;
+  return DW_EH_PE_absptr;
 }
 
 const char *
-X86DarwinTargetAsmInfo::getEHGlobalPrefix() const
-{
+X86DarwinTargetAsmInfo::getEHGlobalPrefix() const {
   const X86Subtarget* Subtarget = &TM.getSubtarget<X86Subtarget>();
   if (Subtarget->getDarwinVers() > 9)
     return PrivateGlobalPrefix;
-  else
-    return "";
+  return "";
 }
 
-X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM):
+X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM) :
   X86TargetAsmInfo<ELFTargetAsmInfo>(TM) {
 
   CStringSection = ".rodata.str";
@@ -128,7 +125,7 @@
   // Set up DWARF directives
   HasLEB128 = true;  // Target asm supports leb128 directives (little-endian)
 
-  BSSSection_ = getUnnamedSection("\t.bss", SectionKind::BSS);
+  BSSSection_ = getOrCreateSection("\t.bss", true, SectionKind::BSS);
 
   // Debug Information
   AbsoluteDebugSectionOffsets = true;
@@ -314,8 +311,8 @@
 
   AlignmentIsInBytes = true;
 
-  TextSection = getUnnamedSection("_text", SectionKind::Text);
-  DataSection = getUnnamedSection("_data", SectionKind::DataRel);
+  TextSection = getOrCreateSection("_text", true, SectionKind::Text);
+  DataSection = getOrCreateSection("_data", true, SectionKind::DataRel);
 
   JumpTableDataSection = NULL;
   SwitchToSectionDirective = "";

Modified: llvm/trunk/lib/Target/XCore/XCoreTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreTargetAsmInfo.cpp?rev=77186&r1=77185&r2=77186&view=diff

==============================================================================
--- llvm/trunk/lib/Target/XCore/XCoreTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/XCore/XCoreTargetAsmInfo.cpp Mon Jul 27 01:17:14 2009
@@ -24,9 +24,9 @@
 XCoreTargetAsmInfo::XCoreTargetAsmInfo(const XCoreTargetMachine &TM)
   : ELFTargetAsmInfo(TM) {
   SupportsDebugInformation = true;
-  TextSection = getUnnamedSection("\t.text", SectionKind::Text);
-  DataSection = getNamedSection("\t.dp.data", SectionKind::DataRel);
-  BSSSection_  = getNamedSection("\t.dp.bss", SectionKind::BSS);
+  TextSection = getOrCreateSection("\t.text", true, SectionKind::Text);
+  DataSection = getOrCreateSection("\t.dp.data", false, SectionKind::DataRel);
+  BSSSection_ = getOrCreateSection("\t.dp.bss", false, SectionKind::BSS);
 
   // TLS globals are lowered in the backend to arrays indexed by the current
   // thread id. After lowering they require no special handling by the linker
@@ -36,9 +36,11 @@
 
   if (TM.getSubtargetImpl()->isXS1A())
     // FIXME: Why is this writable???
-    ReadOnlySection = getNamedSection("\t.dp.rodata", SectionKind::DataRel);
+    ReadOnlySection = getOrCreateSection("\t.dp.rodata", false,
+                                         SectionKind::DataRel);
   else
-    ReadOnlySection = getNamedSection("\t.cp.rodata", SectionKind::ReadOnly);
+    ReadOnlySection = getOrCreateSection("\t.cp.rodata", false,
+                                         SectionKind::ReadOnly);
   Data16bitsDirective = "\t.short\t";
   Data32bitsDirective = "\t.long\t";
   Data64bitsDirective = 0;





More information about the llvm-commits mailing list