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; }
#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);
}
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());
}
#define LLVM_TARGET_PIC16_TARGETOBJECTFILE_H
#include "llvm/Target/TargetLoweringObjectFile.h"
+#include "llvm/ADT/StringMap.h"
#include <vector>
#include <string>
};
class PIC16TargetObjectFile : public TargetLoweringObjectFile {
+ /// SectionsByName - Bindings of names to allocated sections.
+ mutable StringMap<MCSectionPIC16*> SectionsByName;
+
const TargetMachine *TM;
const MCSectionPIC16 *getPIC16Section(const char *Name,