[llvm-commits] [llvm] r77787 - in /llvm/trunk: include/llvm/MC/MCSection.h lib/MC/MCSection.cpp lib/Target/TargetLoweringObjectFile.cpp tools/llvm-mc/AsmParser.cpp tools/llvm-mc/llvm-mc.cpp

Chris Lattner sabre at nondot.org
Sat Aug 1 11:25:49 PDT 2009


Author: lattner
Date: Sat Aug  1 13:25:49 2009
New Revision: 77787

URL: http://llvm.org/viewvc/llvm-project?rev=77787&view=rev
Log:
All MCSections are now required to have a SectionKind.

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

Modified: llvm/trunk/include/llvm/MC/MCSection.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSection.h?rev=77787&r1=77786&r2=77787&view=diff

==============================================================================
--- llvm/trunk/include/llvm/MC/MCSection.h (original)
+++ llvm/trunk/include/llvm/MC/MCSection.h Sat Aug  1 13:25:49 2009
@@ -31,35 +31,20 @@
     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
 

Modified: llvm/trunk/lib/MC/MCSection.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCSection.cpp?rev=77787&r1=77786&r2=77787&view=diff

==============================================================================
--- llvm/trunk/lib/MC/MCSection.cpp (original)
+++ llvm/trunk/lib/MC/MCSection.cpp Sat Aug  1 13:25:49 2009
@@ -14,18 +14,15 @@
 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);
-}

Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=77787&r1=77786&r2=77787&view=diff

==============================================================================
--- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original)
+++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Sat Aug  1 13:25:49 2009
@@ -249,7 +249,7 @@
   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);
 }
 
 

Modified: llvm/trunk/tools/llvm-mc/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.cpp?rev=77787&r1=77786&r2=77787&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-mc/AsmParser.cpp (original)
+++ llvm/trunk/tools/llvm-mc/AsmParser.cpp Sat Aug  1 13:25:49 2009
@@ -662,7 +662,7 @@
   // 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 @@
   // 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 @@
     // 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 @@
   // 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);

Modified: llvm/trunk/tools/llvm-mc/llvm-mc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/llvm-mc.cpp?rev=77787&r1=77786&r2=77787&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-mc/llvm-mc.cpp (original)
+++ llvm/trunk/tools/llvm-mc/llvm-mc.cpp Sat Aug  1 13:25:49 2009
@@ -191,7 +191,9 @@
 
   // 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));





More information about the llvm-commits mailing list