summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2012-12-13 03:00:35 +0000
committerEric Christopher <echristo@gmail.com>2012-12-13 03:00:35 +0000
commit80882db88f82d78df5ddebe626b59c569749e789 (patch)
tree59bf86c450af44edc24f9b5356cd2346e6b721cf /llvm
parenteae97523817a184326d31aaf8a2ac4278d4ae67f (diff)
downloadbcm5719-llvm-80882db88f82d78df5ddebe626b59c569749e789.tar.gz
bcm5719-llvm-80882db88f82d78df5ddebe626b59c569749e789.zip
Add a way of printing out an arbitrary label name for a section
given the section. llvm-svn: 170087
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/MC/MCSection.h6
-rw-r--r--llvm/include/llvm/MC/MCSectionCOFF.h6
-rw-r--r--llvm/include/llvm/MC/MCSectionELF.h9
-rw-r--r--llvm/include/llvm/MC/MCSectionMachO.h8
-rw-r--r--llvm/lib/Target/NVPTX/NVPTXSection.h2
5 files changed, 31 insertions, 0 deletions
diff --git a/llvm/include/llvm/MC/MCSection.h b/llvm/include/llvm/MC/MCSection.h
index 21fdb6bd39b..e5754249e91 100644
--- a/llvm/include/llvm/MC/MCSection.h
+++ b/llvm/include/llvm/MC/MCSection.h
@@ -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
diff --git a/llvm/include/llvm/MC/MCSectionCOFF.h b/llvm/include/llvm/MC/MCSectionCOFF.h
index 83bc63e6520..07c47144cbd 100644
--- a/llvm/include/llvm/MC/MCSectionCOFF.h
+++ b/llvm/include/llvm/MC/MCSectionCOFF.h
@@ -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; }
diff --git a/llvm/include/llvm/MC/MCSectionELF.h b/llvm/include/llvm/MC/MCSectionELF.h
index 329c75cb1d7..8c31d046398 100644
--- a/llvm/include/llvm/MC/MCSectionELF.h
+++ b/llvm/include/llvm/MC/MCSectionELF.h
@@ -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; }
diff --git a/llvm/include/llvm/MC/MCSectionMachO.h b/llvm/include/llvm/MC/MCSectionMachO.h
index 65ad7961b35..898f5714907 100644
--- a/llvm/include/llvm/MC/MCSectionMachO.h
+++ b/llvm/include/llvm/MC/MCSectionMachO.h
@@ -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; }
diff --git a/llvm/lib/Target/NVPTX/NVPTXSection.h b/llvm/lib/Target/NVPTX/NVPTXSection.h
index 9c832e1b51a..04c2da81714 100644
--- a/llvm/lib/Target/NVPTX/NVPTXSection.h
+++ b/llvm/lib/Target/NVPTX/NVPTXSection.h
@@ -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
OpenPOWER on IntegriCloud