Add a way of printing out an arbitrary label name for a section
authorEric Christopher <echristo@gmail.com>
Thu, 13 Dec 2012 03:00:35 +0000 (03:00 +0000)
committerEric Christopher <echristo@gmail.com>
Thu, 13 Dec 2012 03:00:35 +0000 (03:00 +0000)
given the section.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170087 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/Target/NVPTX/NVPTXSection.h

index 21fdb6bd39b8ba9bb55f0143c17b9f5be3dce02f..e5754249e91b5445a0d6c67ae929ff99b05847f2 100644 (file)
@@ -14,6 +14,7 @@
 #ifndef LLVM_MC_MCSECTION_H
 #define LLVM_MC_MCSECTION_H
 
+#include "llvm/ADT/StringRef.h"
 #include "llvm/MC/SectionKind.h"
 #include "llvm/Support/Compiler.h"
 
@@ -49,6 +50,11 @@ namespace llvm {
     virtual void PrintSwitchToSection(const MCAsmInfo &MAI,
                                       raw_ostream &OS) const = 0;
 
+    // Convenience routines to get label names for the beginning/end of a
+    // section.
+    virtual std::string getLabelBeginName() const = 0;
+    virtual std::string getLabelEndName() const = 0;
+
     /// isBaseAddressKnownZero - Return true if we know that this section will
     /// get a base address of zero.  In cases where we know that this is true we
     /// can emit section offsets as direct references to avoid a subtraction
index 83bc63e652033b9277597e19426760ce01d4e0d4..07c47144cbdc4de27b3da9a756a966e9dc789abb 100644 (file)
@@ -50,6 +50,12 @@ namespace llvm {
     bool ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const;
 
     StringRef getSectionName() const { return SectionName; }
+    virtual std::string getLabelBeginName() const {
+      return SectionName.str() + "_begin";
+    }
+    virtual std::string getLabelEndName() const {
+      return SectionName.str() + "_end";
+    }
     unsigned getCharacteristics() const { return Characteristics; }
     int getSelection () const { return Selection; }
 
index 329c75cb1d7d9479d0f0dcd906cc0f5f7036d0e0..8c31d04639883922526273203d22f378a44bfcf6 100644 (file)
@@ -17,6 +17,8 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/MC/MCSection.h"
 #include "llvm/Support/ELF.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/Debug.h"
 
 namespace llvm {
 
@@ -57,6 +59,13 @@ public:
   bool ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const;
 
   StringRef getSectionName() const { return SectionName; }
+  virtual std::string getLabelBeginName() const {
+    dbgs() << SectionName.data();
+    dbgs() << "_begin" << "\n";
+    return SectionName.str() + "_begin"; }
+  virtual std::string getLabelEndName() const {
+    return SectionName.str() + "_end";
+  }
   unsigned getType() const { return Type; }
   unsigned getFlags() const { return Flags; }
   unsigned getEntrySize() const { return EntrySize; }
index 65ad7961b35fb01a38eda5c648dcc71a2ac5b844..898f5714907fe1b89dda20ddda6923d5c663b45a 100644 (file)
@@ -145,6 +145,14 @@ public:
     return StringRef(SectionName);
   }
 
+  virtual std::string getLabelBeginName() const {
+    return StringRef(getSegmentName().str() + getSectionName().str() + "_begin");
+  }
+
+  virtual std::string getLabelEndName() const {
+    return StringRef(getSegmentName().str() + getSectionName().str() + "_end");
+  }
+
   unsigned getTypeAndAttributes() const { return TypeAndAttributes; }
   unsigned getStubSize() const { return Reserved2; }
 
index 9c832e1b51af0d99c1df566c22e1c800551b27c3..04c2da81714636a85820dcb217a1dbb4ab13d87b 100644 (file)
@@ -38,6 +38,8 @@ public:
   virtual bool isBaseAddressKnownZero() const { return true; }
   virtual bool UseCodeAlign() const { return false; }
   virtual bool isVirtualSection() const { return false; }
+  virtual std::string getLabelBeginName() const { return ""; }
+  virtual std::string getLabelEndName() const { return ""; }
 };
 
 } // end namespace llvm