Eliminate SectionFlags, just embed a SectionKind into Section
instead and drive things based off of that.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77184 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 082bce5..792db22 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -117,8 +117,8 @@
 
 /// SwitchToSection - Switch to the specified section of the executable if we
 /// are not already in it!
-void AsmPrinter::SwitchToSection(const Section* NS) {
-  const std::string& NewSection = NS->getName();
+void AsmPrinter::SwitchToSection(const Section *NS) {
+  const std::string &NewSection = NS->getName();
 
   // If we're already in this section, we're done.
   if (CurrentSection == NewSection) return;
@@ -135,20 +135,20 @@
     // If section is named we need to switch into it via special '.section'
     // directive and also append funky flags. Otherwise - section name is just
     // some magic assembler directive.
-    if (NS->hasFlag(SectionFlags::Named)) {
-      O << TAI->getSwitchToSectionDirective()
-        << CurrentSection;
-      
+    if (NS->getKind().hasExplicitSection()) {
       SmallString<32> FlagsStr;
-      TAI->getSectionFlags(NS->getFlags(), FlagsStr);
-      O << FlagsStr.c_str();
+      TAI->getSectionFlagsAsString(NS->getKind(), FlagsStr);
+
+      O << TAI->getSwitchToSectionDirective()
+        << CurrentSection
+        << FlagsStr.c_str();
     } else {
       O << CurrentSection;
     }
     O << TAI->getDataSectionStartSuffix() << '\n';
   }
 
-  IsInTextSection = (NS->getFlags() & SectionFlags::Code);
+  IsInTextSection = NS->getKind().isText();
 }
 
 void AsmPrinter::getAnalysisUsage(AnalysisUsage &AU) const {
@@ -404,7 +404,7 @@
   bool JTInDiffSection = false;
   if ((IsPic && !(LoweringInfo && LoweringInfo->usesGlobalOffsetTable())) ||
       !JumpTableDataSection ||
-      FuncSection->hasFlag(SectionFlags::Linkonce)) {
+      FuncSection->getKind().isWeak()) {
     // In PIC mode, we need to emit the jump table to the same section as the
     // function body itself, otherwise the label differences won't make sense.
     // We should also do if the section name is NULL or function is declared in
diff --git a/lib/CodeGen/ELFWriter.cpp b/lib/CodeGen/ELFWriter.cpp
index c0e7b93..c61d421 100644
--- a/lib/CodeGen/ELFWriter.cpp
+++ b/lib/CodeGen/ELFWriter.cpp
@@ -228,18 +228,18 @@
 
 // getElfSectionFlags - Get the ELF Section Header flags based
 // on the flags defined in ELFTargetAsmInfo.
-unsigned ELFWriter::getElfSectionFlags(unsigned Flags) {
+unsigned ELFWriter::getElfSectionFlags(SectionKind Kind) {
   unsigned ElfSectionFlags = ELFSection::SHF_ALLOC;
 
-  if (Flags & SectionFlags::Code)
+  if (Kind.isText())
     ElfSectionFlags |= ELFSection::SHF_EXECINSTR;
-  if (Flags & SectionFlags::Writable)
+  if (Kind.isWriteable())
     ElfSectionFlags |= ELFSection::SHF_WRITE;
-  if (Flags & SectionFlags::Mergeable)
+  if (Kind.isMergeableConst())
     ElfSectionFlags |= ELFSection::SHF_MERGE;
-  if (Flags & SectionFlags::TLS)
+  if (Kind.isThreadLocal())
     ElfSectionFlags |= ELFSection::SHF_TLS;
-  if (Flags & SectionFlags::Strings)
+  if (Kind.isMergeableCString())
     ElfSectionFlags |= ELFSection::SHF_STRINGS;
 
   return ElfSectionFlags;
@@ -293,7 +293,7 @@
 
     // Get ELF section from TAI
     const Section *S = TAI->SectionForGlobal(GV);
-    unsigned SectionFlags = getElfSectionFlags(S->getFlags());
+    unsigned SectionFlags = getElfSectionFlags(S->getKind());
 
     // The symbol align should update the section alignment if needed
     const TargetData *TD = TM.getTargetData();
diff --git a/lib/CodeGen/ELFWriter.h b/lib/CodeGen/ELFWriter.h
index 6f083b92..8dcd970 100644
--- a/lib/CodeGen/ELFWriter.h
+++ b/lib/CodeGen/ELFWriter.h
@@ -34,6 +34,7 @@
   class TargetAsmInfo;
   class TargetELFWriterInfo;
   class raw_ostream;
+  class SectionKind;
 
   typedef std::vector<ELFSym*>::iterator ELFSymIter;
   typedef std::vector<ELFSection*>::iterator ELFSectionIter;
@@ -209,7 +210,7 @@
     unsigned getGlobalELFBinding(const GlobalValue *GV);
     unsigned getGlobalELFType(const GlobalValue *GV);
     unsigned getGlobalELFVisibility(const GlobalValue *GV);
-    unsigned getElfSectionFlags(unsigned Flags);
+    unsigned getElfSectionFlags(SectionKind Kind);
 
     // setGlobalSymLookup - Set global value 'GV' with 'Index' in the lookup map
     void setGlobalSymLookup(const GlobalValue *GV, unsigned Index) {