All MCSections are now required to have a SectionKind.
authorChris Lattner <sabre@nondot.org>
Sat, 1 Aug 2009 18:25:49 +0000 (18:25 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 1 Aug 2009 18:25:49 +0000 (18:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77787 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCSection.h
lib/MC/MCSection.cpp
lib/Target/TargetLoweringObjectFile.cpp
tools/llvm-mc/AsmParser.cpp
tools/llvm-mc/llvm-mc.cpp

index 06d7e6af1e0be34e7db0f33f4ec6e5e844ff3433..5eb8559c90a75d3d41c8796bf5df63abb1b3b390 100644 (file)
@@ -31,35 +31,20 @@ namespace llvm {
     MCSection(const MCSection&);      // DO NOT IMPLEMENT
     void operator=(const MCSection&); // DO NOT IMPLEMENT
   protected:
-    MCSection(const StringRef &Name, MCContext &Ctx);
-    // FIXME: HACK.
+    MCSection(const StringRef &Name, SectionKind K, MCContext &Ctx);
     SectionKind Kind;
   public:
     virtual ~MCSection();
 
-    static MCSection *Create(const StringRef &Name, MCContext &Ctx);
+    static MCSection *Create(const StringRef &Name, SectionKind K,
+                             MCContext &Ctx);
     
     const std::string &getName() const { return Name; }
     SectionKind getKind() const { return Kind; }
   };
 
-  /// MCSectionWithKind - This is used by targets that use the SectionKind enum
-  /// to classify their sections.
-  class MCSectionWithKind : public MCSection {
-    MCSectionWithKind(const StringRef &Name, SectionKind K, MCContext &Ctx) 
-      : MCSection(Name, Ctx) {
-      Kind = K;
-    }
-  public:
-    
-    static MCSectionWithKind *Create(const StringRef &Name, SectionKind K,
-                                     MCContext &Ctx);
-
-  };
-  
-  
   
-  typedef MCSectionWithKind MCSectionELF;
+  typedef MCSection MCSectionELF;
   
 } // end namespace llvm
 
index 2a2b0b6fafad9d07e6dc45a41e1008d923c69dc9..006546febb13a200047d6fb36c261eeecb5fe582 100644 (file)
@@ -14,18 +14,15 @@ using namespace llvm;
 MCSection::~MCSection() {
 }
 
-MCSection::MCSection(const StringRef &N, MCContext &Ctx) : Name(N) {
+MCSection::MCSection(const StringRef &N, SectionKind K, MCContext &Ctx)
+  : Name(N), Kind(K) {
   MCSection *&Entry = Ctx.Sections[Name];
   assert(Entry == 0 && "Multiple sections with the same name created");
   Entry = this;
 }
 
-MCSection *MCSection::Create(const StringRef &Name, MCContext &Ctx) {
-  return new (Ctx) MCSection(Name, Ctx);
+MCSection *MCSection::Create(const StringRef &Name, SectionKind K,
+                             MCContext &Ctx) {
+  return new (Ctx) MCSection(Name, K, Ctx);
 }
 
-
-MCSectionWithKind *
-MCSectionWithKind::Create(const StringRef &Name, SectionKind K, MCContext &Ctx){
-  return new (Ctx) MCSectionWithKind(Name, K, Ctx);
-}
index 9ba12bb2184f402c8da157b5a1571fcaea55abd0..025e3f21b7c7f140a5cc7370823aa9098255b789 100644 (file)
@@ -249,7 +249,7 @@ getOrCreateSection(const char *Name, bool isDirective,
   if (MCSection *S = Ctx->GetSection(Name))
     return S;
   SectionKind K = SectionKind::get(Kind, false /*weak*/, !isDirective);
-  return MCSectionWithKind::Create(Name, K, *Ctx);
+  return MCSection::Create(Name, K, *Ctx);
 }
 
 
index 19eaf353272deb78af58c234f8c661f89b2f1bde..46103ad53b632e35f21f700658ee40a5d3ab18c9 100644 (file)
@@ -662,7 +662,7 @@ bool AsmParser::ParseDirectiveDarwinSection() {
   // FIXME: Arch specific.
   MCSection *S = Ctx.GetSection(Section);
   if (S == 0)
-    S = MCSection::Create(Section, Ctx);
+    S = MCSection::Create(Section, SectionKind(), Ctx);
   
   Out.SwitchSection(S);
   return false;
@@ -683,7 +683,7 @@ bool AsmParser::ParseDirectiveSectionSwitch(const char *Section,
   // FIXME: Arch specific.
   MCSection *S = Ctx.GetSection(Section);
   if (S == 0)
-    S = MCSection::Create(Section, Ctx);
+    S = MCSection::Create(Section, SectionKind(), Ctx);
   
   Out.SwitchSection(S);
   return false;
@@ -1074,7 +1074,7 @@ bool AsmParser::ParseDirectiveDarwinZerofill() {
     // FIXME: Arch specific.
     MCSection *S = Ctx.GetSection(Section);
     if (S == 0)
-      S = MCSection::Create(Section, Ctx);
+      S = MCSection::Create(Section, SectionKind(), Ctx);
     
     // Create the zerofill section but no symbol
     Out.EmitZerofill(S);
@@ -1134,7 +1134,7 @@ bool AsmParser::ParseDirectiveDarwinZerofill() {
   // FIXME: Arch specific.
   MCSection *S = Ctx.GetSection(Section);
   if (S == 0)
-    S = MCSection::Create(Section, Ctx);
+    S = MCSection::Create(Section, SectionKind(), Ctx);
   
   // Create the zerofill Symbol with Size and Pow2Alignment
   Out.EmitZerofill(S, Sym, Size, Pow2Alignment);
index 44a8319cd6b003f405435626af917a817027ac29..745a64d62ab361f1a995366c7bf48937aa5b0857 100644 (file)
@@ -191,7 +191,9 @@ static int AssembleInput(const char *ProgName) {
 
   // FIXME: Target hook & command line option for initial section.
   Str.get()->SwitchSection(MCSection::Create("__TEXT,__text,"
-                                             "regular,pure_instructions", Ctx));
+                                             "regular,pure_instructions",
+                                            SectionKind::get(SectionKind::Text),
+                                             Ctx));
 
   AsmParser Parser(SrcMgr, Ctx, *Str.get());
   OwningPtr<TargetAsmParser> TAP(GetTargetAsmParser(ProgName, Parser));