aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/MC
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-08-08 23:39:42 +0000
committerChris Lattner <sabre@nondot.org>2009-08-08 23:39:42 +0000
commit93b6db3de934a3cfca5586df25184fef4a54c500 (patch)
tree3c32466a689b69726787f2b72bcdaf6a3879df50 /include/llvm/MC
parent8e9ece75db5045ec057efbbdba6550fa0d85e695 (diff)
downloadexternal_llvm-93b6db3de934a3cfca5586df25184fef4a54c500.zip
external_llvm-93b6db3de934a3cfca5586df25184fef4a54c500.tar.gz
external_llvm-93b6db3de934a3cfca5586df25184fef4a54c500.tar.bz2
sink the 'name' and 'isdirective' state out of MCSection into its derived classes.
This totally optimizes PIC16 sections by not having an 'isdirective' bit anymore!! ;-) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78517 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/MC')
-rw-r--r--include/llvm/MC/MCContext.h9
-rw-r--r--include/llvm/MC/MCSection.h58
2 files changed, 48 insertions, 19 deletions
diff --git a/include/llvm/MC/MCContext.h b/include/llvm/MC/MCContext.h
index a8187cc..f0f5e15 100644
--- a/include/llvm/MC/MCContext.h
+++ b/include/llvm/MC/MCContext.h
@@ -41,8 +41,6 @@ namespace llvm {
/// We use a bump pointer allocator to avoid the need to track all allocated
/// objects.
BumpPtrAllocator Allocator;
-
- friend class MCSection;
public:
MCContext();
~MCContext();
@@ -51,6 +49,13 @@ namespace llvm {
/// null if it doesn't exist.
MCSection *GetSection(const StringRef &Name) const;
+
+ void SetSection(const StringRef &Name, MCSection *S) {
+ MCSection *&Entry = Sections[Name];
+ assert(Entry == 0 && "Multiple sections with the same name created");
+ Entry = S;
+ }
+
/// CreateSymbol - Create a new symbol with the specified @param Name.
///
/// @param Name - The symbol name, which must be unique across all symbols.
diff --git a/include/llvm/MC/MCSection.h b/include/llvm/MC/MCSection.h
index 4e5969a..4d50502 100644
--- a/include/llvm/MC/MCSection.h
+++ b/include/llvm/MC/MCSection.h
@@ -27,27 +27,14 @@ namespace llvm {
/// section in the current translation unit. The MCContext class uniques and
/// creates these.
class MCSection {
- std::string Name;
-
- /// IsDirective - This is true if the section name is a directive, not
- /// something that should be printed with ".section".
- ///
- /// FIXME: This is a hack. Switch to a semantic view of the section instead
- /// of a syntactic one.
- bool IsDirective;
-
MCSection(const MCSection&); // DO NOT IMPLEMENT
void operator=(const MCSection&); // DO NOT IMPLEMENT
protected:
- MCSection(const StringRef &Name, bool IsDirective, SectionKind K,
- MCContext &Ctx);
+ MCSection(SectionKind K) : Kind(K) {}
SectionKind Kind;
public:
virtual ~MCSection();
- const std::string &getName() const { return Name; }
- bool isDirective() const { return IsDirective; }
-
SectionKind getKind() const { return Kind; }
virtual void PrintSwitchToSection(const TargetAsmInfo &TAI,
@@ -56,36 +43,73 @@ namespace llvm {
class MCSectionELF : public MCSection {
+ std::string Name;
+
+ /// IsDirective - This is true if the section name is a directive, not
+ /// something that should be printed with ".section".
+ ///
+ /// FIXME: This is a hack. Switch to a semantic view of the section instead
+ /// of a syntactic one.
+ bool IsDirective;
+
MCSectionELF(const StringRef &Name, bool IsDirective, SectionKind K,
- MCContext &Ctx) : MCSection(Name, IsDirective, K, Ctx) {}
+ MCContext &Ctx);
public:
static MCSectionELF *Create(const StringRef &Name, bool IsDirective,
SectionKind K, MCContext &Ctx);
+ const std::string &getName() const { return Name; }
+ bool isDirective() const { return IsDirective; }
+
+
virtual void PrintSwitchToSection(const TargetAsmInfo &TAI,
raw_ostream &OS) const;
};
class MCSectionMachO : public MCSection {
+ std::string Name;
+
+ /// IsDirective - This is true if the section name is a directive, not
+ /// something that should be printed with ".section".
+ ///
+ /// FIXME: This is a hack. Switch to a semantic view of the section instead
+ /// of a syntactic one.
+ bool IsDirective;
+
MCSectionMachO(const StringRef &Name, bool IsDirective, SectionKind K,
- MCContext &Ctx) : MCSection(Name, IsDirective, K, Ctx) {}
+ MCContext &Ctx);
public:
static MCSectionMachO *Create(const StringRef &Name, bool IsDirective,
SectionKind K, MCContext &Ctx);
+ const std::string &getName() const { return Name; }
+ bool isDirective() const { return IsDirective; }
+
virtual void PrintSwitchToSection(const TargetAsmInfo &TAI,
raw_ostream &OS) const;
};
class MCSectionCOFF : public MCSection {
+ std::string Name;
+
+ /// IsDirective - This is true if the section name is a directive, not
+ /// something that should be printed with ".section".
+ ///
+ /// FIXME: This is a hack. Switch to a semantic view of the section instead
+ /// of a syntactic one.
+ bool IsDirective;
+
MCSectionCOFF(const StringRef &Name, bool IsDirective, SectionKind K,
- MCContext &Ctx) : MCSection(Name, IsDirective, K, Ctx) {}
+ MCContext &Ctx);
public:
static MCSectionCOFF *Create(const StringRef &Name, bool IsDirective,
SectionKind K, MCContext &Ctx);
+
+ const std::string &getName() const { return Name; }
+ bool isDirective() const { return IsDirective; }
virtual void PrintSwitchToSection(const TargetAsmInfo &TAI,
raw_ostream &OS) const;