Eliminate getNamed/getUnnamedSection, adding a new and unified getOrCreateSection
instead.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77186 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/PIC16/PIC16TargetAsmInfo.cpp b/lib/Target/PIC16/PIC16TargetAsmInfo.cpp
index c855632..5a4387a 100644
--- a/lib/Target/PIC16/PIC16TargetAsmInfo.cpp
+++ b/lib/Target/PIC16/PIC16TargetAsmInfo.cpp
@@ -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);
   }