make PIC16 unique its own sections instead of having mcontext do it.
authorChris Lattner <sabre@nondot.org>
Thu, 13 Aug 2009 00:26:52 +0000 (00:26 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 13 Aug 2009 00:26:52 +0000 (00:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78871 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/PIC16/PIC16Section.h
lib/Target/PIC16/PIC16TargetObjectFile.cpp
lib/Target/PIC16/PIC16TargetObjectFile.h

index f69cc2c80731383f167ca251e9ed38e5e2825cd1..0a2d09145c39289d11ca98fad287a28226d51cfa 100644 (file)
@@ -21,8 +21,10 @@ namespace llvm {
   class MCSectionPIC16 : public MCSection {
     std::string Name;
     
-    MCSectionPIC16(const StringRef &name, SectionKind K,
-                   MCContext &Ctx);
+    MCSectionPIC16(const StringRef &name, SectionKind K)
+      : MCSection(K), Name(name) {
+    }
+    
   public:
     
     const std::string &getName() const { return Name; }
index ed1caf225e2f3bcc3e2c9aad61bfae0fd07cd2f0..aa865bfb50965ea6a36f9eec0f80bdb06cd90003 100644 (file)
 #include "llvm/Support/raw_ostream.h"
 using namespace llvm;
 
-MCSectionPIC16::MCSectionPIC16(const StringRef &name, SectionKind K,
-                               MCContext &Ctx) : MCSection(K), Name(name) {
-  Ctx.SetSection(Name, this);
-}
 
 MCSectionPIC16 *MCSectionPIC16::Create(const StringRef &Name, 
                                        SectionKind K, MCContext &Ctx) {
-  return new (Ctx) MCSectionPIC16(Name, K, Ctx);
+  return new (Ctx) MCSectionPIC16(Name, K);
 }
 
 
@@ -43,9 +39,11 @@ PIC16TargetObjectFile::PIC16TargetObjectFile()
 
 const MCSectionPIC16 *PIC16TargetObjectFile::
 getPIC16Section(const char *Name, SectionKind Kind) const {
-  if (MCSection *S = getContext().GetSection(Name))
-    return (MCSectionPIC16*)S;
-  return MCSectionPIC16::Create(Name, Kind, getContext());
+  MCSectionPIC16 *&Entry = SectionsByName[Name];
+  if (Entry)
+    return Entry;
+
+  return Entry = MCSectionPIC16::Create(Name, Kind, getContext());
 }
 
 
index 91415bc7658e3a90fc9e4a552a0c912874ab7736..1c6d9cf3884bc89b7c46dc27725c708b8e4c49fb 100644 (file)
@@ -11,6 +11,7 @@
 #define LLVM_TARGET_PIC16_TARGETOBJECTFILE_H
 
 #include "llvm/Target/TargetLoweringObjectFile.h"
+#include "llvm/ADT/StringMap.h"
 #include <vector>
 #include <string>
 
@@ -46,6 +47,9 @@ namespace llvm {
   };
   
   class PIC16TargetObjectFile : public TargetLoweringObjectFile {
+    /// SectionsByName - Bindings of names to allocated sections.
+    mutable StringMap<MCSectionPIC16*> SectionsByName;
+
     const TargetMachine *TM;
     
     const MCSectionPIC16 *getPIC16Section(const char *Name,