Make EmitIntValue more efficient and more like what we do for leb128. The
[oota-llvm.git] / lib / MC / MCSectionELF.cpp
index 133cad1b32cf4c3527611a6cd604f22f539df822..59568adf7085e6d1d1463db7597b59e4aea37e2a 100644 (file)
@@ -29,14 +29,6 @@ bool MCSectionELF::ShouldOmitSectionDirective(StringRef Name,
   return false;
 }
 
-// ShouldPrintSectionType - Only prints the section type if supported
-bool MCSectionELF::ShouldPrintSectionType(unsigned Ty) const {
-  if (IsExplicit && !(Ty == SHT_NOBITS || Ty == SHT_PROGBITS))
-    return false;
-
-  return true;
-}
-
 void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI,
                                         raw_ostream &OS) const {
    
@@ -84,31 +76,30 @@ void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI,
   
   OS << '"';
 
-  if (ShouldPrintSectionType(Type)) {
-    OS << ',';
-    // If comment string is '@', e.g. as on ARM - use '%' instead
-    if (MAI.getCommentString()[0] == '@')
-      OS << '%';
-    else
-      OS << '@';
-  
-    if (Type == MCSectionELF::SHT_INIT_ARRAY)
-      OS << "init_array";
-    else if (Type == MCSectionELF::SHT_FINI_ARRAY)
-      OS << "fini_array";
-    else if (Type == MCSectionELF::SHT_PREINIT_ARRAY)
-      OS << "preinit_array";
-    else if (Type == MCSectionELF::SHT_NOBITS)
-      OS << "nobits";
-    else if (Type == MCSectionELF::SHT_PROGBITS)
-      OS << "progbits";
-  
-    if (EntrySize) {
-      OS << "," << EntrySize;
-    }
+  OS << ',';
+
+  // If comment string is '@', e.g. as on ARM - use '%' instead
+  if (MAI.getCommentString()[0] == '@')
+    OS << '%';
+  else
+    OS << '@';
+
+  if (Type == MCSectionELF::SHT_INIT_ARRAY)
+    OS << "init_array";
+  else if (Type == MCSectionELF::SHT_FINI_ARRAY)
+    OS << "fini_array";
+  else if (Type == MCSectionELF::SHT_PREINIT_ARRAY)
+    OS << "preinit_array";
+  else if (Type == MCSectionELF::SHT_NOBITS)
+    OS << "nobits";
+  else if (Type == MCSectionELF::SHT_PROGBITS)
+    OS << "progbits";
+
+  if (EntrySize) {
+    assert(Flags & MCSectionELF::SHF_MERGE);
+    OS << "," << EntrySize;
   }
-  
+
   OS << '\n';
 }
 
@@ -116,6 +107,10 @@ bool MCSectionELF::UseCodeAlign() const {
   return getFlags() & MCSectionELF::SHF_EXECINSTR;
 }
 
+bool MCSectionELF::isVirtualSection() const {
+  return getType() == MCSectionELF::SHT_NOBITS;
+}
+
 // HasCommonSymbols - True if this section holds common symbols, this is
 // indicated on the ELF object file by a symbol with SHN_COMMON section 
 // header index.