mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 19:12:56 +02:00
create sections with MCSection::Create instead of Context->getOrCreateSection.
This is needed to allow polymorphic sections. llvm-svn: 77680
This commit is contained in:
parent
85a3632c7a
commit
610dfdece7
@ -42,12 +42,14 @@ namespace llvm {
|
|||||||
/// objects.
|
/// objects.
|
||||||
BumpPtrAllocator Allocator;
|
BumpPtrAllocator Allocator;
|
||||||
|
|
||||||
|
friend class MCSection;
|
||||||
public:
|
public:
|
||||||
MCContext();
|
MCContext();
|
||||||
~MCContext();
|
~MCContext();
|
||||||
|
|
||||||
/// GetSection - Get or create a new section with the given @param Name.
|
/// GetSection - Look up a section with the given @param Name, returning
|
||||||
MCSection *GetSection(const StringRef &Name);
|
/// null if it doesn't exist.
|
||||||
|
MCSection *GetSection(const StringRef &Name) const;
|
||||||
|
|
||||||
/// CreateSymbol - Create a new symbol with the specified @param Name.
|
/// CreateSymbol - Create a new symbol with the specified @param Name.
|
||||||
///
|
///
|
||||||
|
@ -25,13 +25,13 @@ namespace llvm {
|
|||||||
class MCSection {
|
class MCSection {
|
||||||
std::string Name;
|
std::string Name;
|
||||||
private:
|
private:
|
||||||
friend class MCContext;
|
|
||||||
MCSection(const StringRef &_Name) : Name(_Name) {}
|
|
||||||
|
|
||||||
MCSection(const MCSection&); // DO NOT IMPLEMENT
|
MCSection(const MCSection&); // DO NOT IMPLEMENT
|
||||||
void operator=(const MCSection&); // DO NOT IMPLEMENT
|
void operator=(const MCSection&); // DO NOT IMPLEMENT
|
||||||
|
MCSection(const StringRef &_Name, MCContext &Ctx);
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
static MCSection *Create(const StringRef &_Name, MCContext &Ctx);
|
||||||
|
|
||||||
const std::string &getName() const { return Name; }
|
const std::string &getName() const { return Name; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -14,22 +14,29 @@
|
|||||||
#include "llvm/MC/MCValue.h"
|
#include "llvm/MC/MCValue.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
MCContext::MCContext()
|
MCContext::MCContext() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MCContext::~MCContext() {
|
MCContext::~MCContext() {
|
||||||
}
|
}
|
||||||
|
|
||||||
MCSection *MCContext::GetSection(const StringRef &Name) {
|
MCSection *MCContext::GetSection(const StringRef &Name) const {
|
||||||
MCSection *&Entry = Sections[Name];
|
StringMap<MCSection*>::const_iterator I = Sections.find(Name);
|
||||||
|
return I != Sections.end() ? I->second : 0;
|
||||||
if (!Entry)
|
|
||||||
Entry = new (*this) MCSection(Name);
|
|
||||||
|
|
||||||
return Entry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MCSection::MCSection(const StringRef &_Name, MCContext &Ctx) : Name(_Name) {
|
||||||
|
MCSection *&Entry = Ctx.Sections[Name];
|
||||||
|
assert(Entry == 0 && "Multiple sections with the same name created");
|
||||||
|
Entry = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
MCSection *MCSection::Create(const StringRef &Name, MCContext &Ctx) {
|
||||||
|
return new (Ctx) MCSection(Name, Ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
MCSymbol *MCContext::CreateSymbol(const StringRef &Name) {
|
MCSymbol *MCContext::CreateSymbol(const StringRef &Name) {
|
||||||
assert(Name[0] != '\0' && "Normal symbols cannot be unnamed!");
|
assert(Name[0] != '\0' && "Normal symbols cannot be unnamed!");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user