[llvm-commits] [llvm] r78494 - in /llvm/trunk: include/llvm/Target/TargetLoweringObjectFile.h lib/Target/PIC16/PIC16TargetObjectFile.cpp lib/Target/PIC16/PIC16TargetObjectFile.h lib/Target/TargetLoweringObjectFile.cpp

Chris Lattner sabre at nondot.org
Sat Aug 8 13:14:14 PDT 2009


Author: lattner
Date: Sat Aug  8 15:14:13 2009
New Revision: 78494

URL: http://llvm.org/viewvc/llvm-project?rev=78494&view=rev
Log:
sink getOrCreateSection down into all the object file implementations,
now that they create *all* the sections.

Modified:
    llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h
    llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp
    llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h
    llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp

Modified: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h?rev=78494&r1=78493&r2=78494&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h (original)
+++ llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h Sat Aug  8 15:14:13 2009
@@ -80,12 +80,11 @@
   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 @@
   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 @@
                               // 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 @@
   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 @@
 
 
 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);
   

Modified: llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp?rev=78494&r1=78493&r2=78494&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp (original)
+++ llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp Sat Aug  8 15:14:13 2009
@@ -13,12 +13,21 @@
 #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;

Modified: llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h?rev=78494&r1=78493&r2=78494&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h (original)
+++ llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h Sat Aug  8 15:14:13 2009
@@ -45,6 +45,10 @@
   
   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;

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

==============================================================================
--- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original)
+++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Sat Aug  8 15:14:13 2009
@@ -274,19 +274,18 @@
 }
 
 
-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);
@@ -576,6 +575,13 @@
 //===----------------------------------------------------------------------===//
 
 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.
   return getOrCreateSection(Name, isDirective, K);  
@@ -789,6 +795,13 @@
 //===----------------------------------------------------------------------===//
 
 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);
 }





More information about the llvm-commits mailing list