diff options
author | Chris Lattner <sabre@nondot.org> | 2009-08-13 00:26:52 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-08-13 00:26:52 +0000 |
commit | 873bc4ccfd655b417556791a464e6b1c1368b748 (patch) | |
tree | e8422ed8c319b661a1abdd7edc8c800c4f73a068 | |
parent | c9d31524eec562f719d6818508b722b55a787d67 (diff) |
make PIC16 unique its own sections instead of having mcontext do it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78871 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/PIC16/PIC16Section.h | 6 | ||||
-rw-r--r-- | lib/Target/PIC16/PIC16TargetObjectFile.cpp | 14 | ||||
-rw-r--r-- | lib/Target/PIC16/PIC16TargetObjectFile.h | 4 |
3 files changed, 14 insertions, 10 deletions
diff --git a/lib/Target/PIC16/PIC16Section.h b/lib/Target/PIC16/PIC16Section.h index f69cc2c807..0a2d09145c 100644 --- a/lib/Target/PIC16/PIC16Section.h +++ b/lib/Target/PIC16/PIC16Section.h @@ -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; } diff --git a/lib/Target/PIC16/PIC16TargetObjectFile.cpp b/lib/Target/PIC16/PIC16TargetObjectFile.cpp index ed1caf225e..aa865bfb50 100644 --- a/lib/Target/PIC16/PIC16TargetObjectFile.cpp +++ b/lib/Target/PIC16/PIC16TargetObjectFile.cpp @@ -18,14 +18,10 @@ #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()); } diff --git a/lib/Target/PIC16/PIC16TargetObjectFile.h b/lib/Target/PIC16/PIC16TargetObjectFile.h index 91415bc765..1c6d9cf388 100644 --- a/lib/Target/PIC16/PIC16TargetObjectFile.h +++ b/lib/Target/PIC16/PIC16TargetObjectFile.h @@ -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, |