make instcombine only rewrite a chain of computation
[oota-llvm.git] / lib / MC / MCSectionELF.cpp
index 56f803496ace65d59509516d9f30499a0892f757..c6812ed99c4117bac0ea7ae5638b4a9d6bae7b78 100644 (file)
 #include "llvm/MC/MCSectionELF.h"
 #include "llvm/MC/MCContext.h"
 #include "llvm/Support/raw_ostream.h"
-#include "llvm/Target/TargetAsmInfo.h"
+#include "llvm/MC/MCAsmInfo.h"
 
 using namespace llvm;
 
 MCSectionELF *MCSectionELF::
-Create(const StringRef &Section, unsigned Type, unsigned Flags,
-       SectionKind K, bool hasCrazyBSS, bool isExplicit, MCContext &Ctx) {
-  return new 
-    (Ctx) MCSectionELF(Section, Type, Flags, K, hasCrazyBSS, isExplicit);
+Create(StringRef Section, unsigned Type, unsigned Flags,
+       SectionKind K, bool isExplicit, MCContext &Ctx) {
+  return new (Ctx) MCSectionELF(Section, Type, Flags, K, isExplicit);
 }
 
 // ShouldOmitSectionDirective - Decides whether a '.section' directive
 // should be printed before the section name
-bool MCSectionELF::ShouldOmitSectionDirective(const char *Name) const {
+bool MCSectionELF::ShouldOmitSectionDirective(const char *Name,
+                                        const MCAsmInfo &MAI) const {
   
-  // PPC/Linux doesn't support the .bss directive, it needs .section .bss.
   // FIXME: Does .section .bss/.data/.text work everywhere??
-  if ((!HasCrazyBSS && strncmp(Name, ".bss", 4) == 0) || 
-      strncmp(Name, ".text", 5) == 0 || 
-      strncmp(Name, ".data", 5) == 0)
+  if (strcmp(Name, ".text") == 0 ||
+      strcmp(Name, ".data") == 0 ||
+      (strcmp(Name, ".bss") == 0 &&
+       !MAI.usesELFSectionDirectiveForBSS())) 
     return true;
 
   return false;
@@ -44,10 +44,10 @@ bool MCSectionELF::ShouldPrintSectionType(unsigned Ty) const {
   return true;
 }
 
-void MCSectionELF::PrintSwitchToSection(const TargetAsmInfo &TAI,
+void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI,
                                         raw_ostream &OS) const {
-  
-  if (ShouldOmitSectionDirective(SectionName.c_str())) {
+   
+  if (ShouldOmitSectionDirective(SectionName.c_str(), MAI)) {
     OS << '\t' << getSectionName() << '\n';
     return;
   }
@@ -55,7 +55,7 @@ void MCSectionELF::PrintSwitchToSection(const TargetAsmInfo &TAI,
   OS << "\t.section\t" << getSectionName();
   
   // Handle the weird solaris syntax if desired.
-  if (TAI.usesSunStyleELFSectionSwitchSyntax() && 
+  if (MAI.usesSunStyleELFSectionSwitchSyntax() && 
       !(Flags & MCSectionELF::SHF_MERGE)) {
     if (Flags & MCSectionELF::SHF_ALLOC)
       OS << ",#alloc";
@@ -67,7 +67,6 @@ void MCSectionELF::PrintSwitchToSection(const TargetAsmInfo &TAI,
       OS << ",#tls";
   } else {
     OS << ",\"";
-  
     if (Flags & MCSectionELF::SHF_ALLOC)
       OS << 'a';
     if (Flags & MCSectionELF::SHF_EXECINSTR)
@@ -80,14 +79,18 @@ void MCSectionELF::PrintSwitchToSection(const TargetAsmInfo &TAI,
       OS << 'S';
     if (Flags & MCSectionELF::SHF_TLS)
       OS << 'T';
-   
+    
+    // If there are target-specific flags, print them.
+    if (Flags & ~MCSectionELF::TARGET_INDEP_SHF)
+      PrintTargetSpecificSectionFlags(MAI, OS);
+    
     OS << '"';
 
     if (ShouldPrintSectionType(Type)) {
       OS << ',';
    
       // If comment string is '@', e.g. as on ARM - use '%' instead
-      if (TAI.getCommentString()[0] == '@')
+      if (MAI.getCommentString()[0] == '@')
         OS << '%';
       else
         OS << '@';
@@ -121,8 +124,10 @@ void MCSectionELF::PrintSwitchToSection(const TargetAsmInfo &TAI,
   OS << '\n';
 }
 
-// IsCommon - True if this section contains only common symbols
-bool MCSectionELF::IsCommon() const {
+// 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.
+bool MCSectionELF::HasCommonSymbols() const {
   
   if (strncmp(SectionName.c_str(), ".gnu.linkonce.", 14) == 0)
     return true;