sink getOrCreateSection down into all the object file implementations,
authorChris Lattner <sabre@nondot.org>
Sat, 8 Aug 2009 20:14:13 +0000 (20:14 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 8 Aug 2009 20:14:13 +0000 (20:14 +0000)
now that they create *all* the sections.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78494 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/TargetLoweringObjectFile.h
lib/Target/PIC16/PIC16TargetObjectFile.cpp
lib/Target/PIC16/PIC16TargetObjectFile.h
lib/Target/TargetLoweringObjectFile.cpp

index 0972dcde072baa61e68f077d584a8a27a7743260..e9533c4da22977dd84ea2554fbb31a41e6deda09 100644 (file)
@@ -80,12 +80,11 @@ protected:
   const MCSection *DwarfRangesSection;
   const MCSection *DwarfMacroInfoSection;
   
-protected:
-  const MCSection *getOrCreateSection(const char *Name,
-                                      bool isDirective,
-                                      SectionKind K) const;
 public:
   
+  MCContext &getContext() const { return *Ctx; }
+  
+
   virtual ~TargetLoweringObjectFile();
   
   /// Initialize - this method must be called before any actual lowering is
@@ -206,6 +205,11 @@ protected:
   const MCSection *MergeableConst4Section;
   const MCSection *MergeableConst8Section;
   const MCSection *MergeableConst16Section;
+  
+protected:
+  const MCSection *getOrCreateSection(const char *Name,
+                                      bool isDirective,
+                                      SectionKind K) const;
 public:
   /// ELF Constructor - AtIsCommentChar is true if the CommentCharacter from TAI
   /// is "@".
@@ -213,9 +217,8 @@ public:
                               // FIXME: REMOVE AFTER UNIQUING IS FIXED.
                               bool hasCrazyBSS = false)
     : AtIsCommentChar(atIsCommentChar), HasCrazyBSS(hasCrazyBSS) {}
-    
-  virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
   
+  virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
   
   /// getSectionForConstant - Given a constant with the SectionKind, return a
   /// section that it should be placed in.
@@ -247,6 +250,10 @@ class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
   const MCSection *FourByteConstantSection;
   const MCSection *EightByteConstantSection;
   const MCSection *SixteenByteConstantSection;
+protected:
+  const MCSection *getOrCreateSection(const char *Name,
+                                      bool isDirective,
+                                      SectionKind K) const;
 public:
   
   virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
@@ -276,6 +283,10 @@ public:
 
 
 class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
+protected:
+  const MCSection *getOrCreateSection(const char *Name,
+                                      bool isDirective,
+                                      SectionKind K) const;
 public:
   virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
   
index b09ad305c28222a9e462bf7fc50daecd3cc7f161..308e09c100b6b230d6edc12b8bd155de2fae33d6 100644 (file)
 #include "llvm/DerivedTypes.h"
 #include "llvm/Module.h"
 #include "llvm/MC/MCSection.h"
+#include "llvm/MC/MCContext.h"
 using namespace llvm;
 
 PIC16TargetObjectFile::PIC16TargetObjectFile()
   : ExternalVarDecls(0), ExternalVarDefs(0) {
 }
 
+const MCSection *PIC16TargetObjectFile::
+getOrCreateSection(const char *Name, bool isDirective, SectionKind Kind) const {
+  if (MCSection *S = getContext().GetSection(Name))
+    return S;
+  return MCSection::Create(Name, isDirective, Kind, getContext());
+}
+
+
 void PIC16TargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &tm){
   TargetLoweringObjectFile::Initialize(Ctx, tm);
   TM = &tm;
index c2611087b50688cb273d3422527fc99ca49e93f2..b71a7050a71904a0549300a27fe2596243675f02 100644 (file)
@@ -45,6 +45,10 @@ namespace llvm {
   
   class PIC16TargetObjectFile : public TargetLoweringObjectFile {
     const TargetMachine *TM;
+    
+    const MCSection *getOrCreateSection(const char *Name,
+                                        bool isDirective,
+                                        SectionKind K) const;
   public:
     mutable std::vector<PIC16Section*> BSSSections;
     mutable std::vector<PIC16Section*> IDATASections;
index 6aca6da8afef6dad72cdccd49157b4d2e6429c40..e983285f337a1e83bf2000d965b18585f9af8251 100644 (file)
@@ -274,19 +274,18 @@ TargetLoweringObjectFile::getSectionForConstant(SectionKind Kind) const {
 }
 
 
-const MCSection *TargetLoweringObjectFile::
-getOrCreateSection(const char *Name, bool isDirective, SectionKind Kind) const {
-  if (MCSection *S = Ctx->GetSection(Name))
-    return S;
-  return MCSection::Create(Name, isDirective, Kind, *Ctx);
-}
-
-
 
 //===----------------------------------------------------------------------===//
 //                                  ELF
 //===----------------------------------------------------------------------===//
 
+const MCSection *TargetLoweringObjectFileELF::
+getOrCreateSection(const char *Name, bool isDirective, SectionKind Kind) const {
+  if (MCSection *S = getContext().GetSection(Name))
+    return S;
+  return MCSection::Create(Name, isDirective, Kind, getContext());
+}
+
 void TargetLoweringObjectFileELF::Initialize(MCContext &Ctx,
                                              const TargetMachine &TM) {
   TargetLoweringObjectFile::Initialize(Ctx, TM);
@@ -575,6 +574,13 @@ getSectionForConstant(SectionKind Kind) const {
 //                                 MachO
 //===----------------------------------------------------------------------===//
 
+const MCSection *TargetLoweringObjectFileMachO::
+getOrCreateSection(const char *Name, bool isDirective, SectionKind Kind) const {
+  if (MCSection *S = getContext().GetSection(Name))
+    return S;
+  return MCSection::Create(Name, isDirective, Kind, getContext());
+}
+
 const MCSection *TargetLoweringObjectFileMachO::
 getMachOSection(const char *Name, bool isDirective, SectionKind K) {
   // FOR NOW, Just forward.
@@ -788,6 +794,13 @@ shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler *Mang) const {
 //                                  COFF
 //===----------------------------------------------------------------------===//
 
+const MCSection *TargetLoweringObjectFileCOFF::
+getOrCreateSection(const char *Name, bool isDirective, SectionKind Kind) const {
+  if (MCSection *S = getContext().GetSection(Name))
+    return S;
+  return MCSection::Create(Name, isDirective, Kind, getContext());
+}
+
 const MCSection *TargetLoweringObjectFileCOFF::
 getCOFFSection(const char *Name, bool isDirective, SectionKind K) {
   return getOrCreateSection(Name, isDirective, K);