]> granicus.if.org Git - llvm/commitdiff
Only print architecture dependent flags for that architecture.
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 30 Jan 2017 15:38:43 +0000 (15:38 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 30 Jan 2017 15:38:43 +0000 (15:38 +0000)
Different architectures can have different meaning for flags in the
SHF_MASKPROC mask, so we should always check what the architecture use
before checking the flag.

NFC for now, but will allow fixing the value of an xmos flag.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293484 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCSection.h
include/llvm/MC/MCSectionCOFF.h
include/llvm/MC/MCSectionELF.h
include/llvm/MC/MCSectionMachO.h
lib/MC/MCAsmStreamer.cpp
lib/MC/MCSectionCOFF.cpp
lib/MC/MCSectionELF.cpp
lib/MC/MCSectionMachO.cpp
lib/Target/NVPTX/NVPTXSection.h

index d4c31696b40f61fde4ae22d7726c5c58844b2ea6..68d4a7f5509135377c47a5633f2f84bd3612d41f 100644 (file)
@@ -29,6 +29,7 @@ class MCExpr;
 class MCFragment;
 class MCSection;
 class MCSymbol;
+class Triple;
 class raw_ostream;
 
 template <> struct ilist_alloc_traits<MCFragment> {
@@ -169,7 +170,8 @@ public:
 
   void dump();
 
-  virtual void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS,
+  virtual void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
+                                    raw_ostream &OS,
                                     const MCExpr *Subsection) const = 0;
 
   /// Return true if a .align directive should use "optimized nops" to fill
index 7d5f9f7f3cde98bbfc925fa384cb5aca1f713692..914008d4c3d2e8e7729a3fc5d27e87bf323fdc80 100644 (file)
@@ -73,7 +73,8 @@ public:
 
   void setSelection(int Selection) const;
 
-  void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS,
+  void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
+                            raw_ostream &OS,
                             const MCExpr *Subsection) const override;
   bool UseCodeAlign() const override;
   bool isVirtualSection() const override;
index dabd787b0d45f8e4041f6312b201edf718cdaf96..e296de60c77749db8f5216966afb99834c144d5c 100644 (file)
@@ -78,7 +78,8 @@ public:
   void setFlags(unsigned F) { Flags = F; }
   const MCSymbolELF *getGroup() const { return Group; }
 
-  void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS,
+  void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
+                            raw_ostream &OS,
                             const MCExpr *Subsection) const override;
   bool UseCodeAlign() const override;
   bool isVirtualSection() const override;
index 658dfcda7268814e989f7f8091bfa8f3046fbd3d..3bc5408a4f75e204f004928f9153137acf0b7cdd 100644 (file)
@@ -76,7 +76,8 @@ public:
                                            bool      &TAAParsed, // Out.
                                            unsigned  &StubSize); // Out.
 
-  void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS,
+  void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
+                            raw_ostream &OS,
                             const MCExpr *Subsection) const override;
   bool UseCodeAlign() const override;
   bool isVirtualSection() const override;
index 817009a6536385bba09bf27fe586e4ebcb8e75a2..2eae26bdc0c09c1080026e793984d6ab52cce447 100644 (file)
@@ -392,7 +392,9 @@ void MCAsmStreamer::emitExplicitComments() {
 void MCAsmStreamer::ChangeSection(MCSection *Section,
                                   const MCExpr *Subsection) {
   assert(Section && "Cannot switch to a null section!");
-  Section->PrintSwitchToSection(*MAI, OS, Subsection);
+  Section->PrintSwitchToSection(
+      *MAI, getContext().getObjectFileInfo()->getTargetTriple(), OS,
+      Subsection);
 }
 
 void MCAsmStreamer::EmitLabel(MCSymbol *Symbol) {
index f2dd47d81b7e064a5ae7ab3edf95fef48b2e224e..4e2df01c89c272aec147ddfb2385025e943c0fcb 100644 (file)
@@ -37,7 +37,7 @@ void MCSectionCOFF::setSelection(int Selection) const {
   Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT;
 }
 
-void MCSectionCOFF::PrintSwitchToSection(const MCAsmInfo &MAI,
+void MCSectionCOFF::PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
                                          raw_ostream &OS,
                                          const MCExpr *Subsection) const {
 
index 587b28f71b7d9cf3ed1858d60d08b6d475682e0e..422652e5ef50cf80f3e12992c5256c8ae56afcf5 100644 (file)
@@ -53,7 +53,7 @@ static void printName(raw_ostream &OS, StringRef Name) {
   OS << '"';
 }
 
-void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI,
+void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
                                         raw_ostream &OS,
                                         const MCExpr *Subsection) const {
 
@@ -106,12 +106,17 @@ void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI,
     OS << 'T';
 
   // If there are target-specific flags, print them.
-  if (Flags & ELF::XCORE_SHF_CP_SECTION)
-    OS << 'c';
-  if (Flags & ELF::XCORE_SHF_DP_SECTION)
-    OS << 'd';
-  if (Flags & ELF::SHF_ARM_PURECODE)
-    OS << 'y';
+  Triple::ArchType Arch = T.getArch();
+  if (Arch == Triple::xcore) {
+    if (Flags & ELF::XCORE_SHF_CP_SECTION)
+      OS << 'c';
+    if (Flags & ELF::XCORE_SHF_DP_SECTION)
+      OS << 'd';
+  } else if (Arch == Triple::arm || Arch == Triple::armeb ||
+             Arch == Triple::thumb || Arch == Triple::thumbeb) {
+    if (Flags & ELF::SHF_ARM_PURECODE)
+      OS << 'y';
+  }
 
   OS << '"';
 
index c2a772fdbdacd67601fec862914169406d689b7f..974de0fc1f2c2b3ede92fe1f9c79b691d275f3db 100644 (file)
@@ -89,7 +89,7 @@ MCSectionMachO::MCSectionMachO(StringRef Segment, StringRef Section,
   }
 }
 
-void MCSectionMachO::PrintSwitchToSection(const MCAsmInfo &MAI,
+void MCSectionMachO::PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
                                           raw_ostream &OS,
                                           const MCExpr *Subsection) const {
   OS << "\t.section\t" << getSegmentName() << ',' << getSectionName();
index b0472de980fcc07a8be3a24976623573b958dd36..d736eaa41301f83b98cd480bb4a44e4647dc6854 100644 (file)
@@ -31,7 +31,7 @@ public:
 
   /// Override this as NVPTX has its own way of printing switching
   /// to a section.
-  void PrintSwitchToSection(const MCAsmInfo &MAI,
+  void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
                             raw_ostream &OS,
                             const MCExpr *Subsection) const override {}