blob: ec6078ea37b4da0f30027f72a9d5d01aa21c7e2c [file] [log] [blame]
Chris Lattnered47a042009-07-31 17:02:00 +00001//===- lib/MC/MCSection.cpp - Machine Code Section Representation ---------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "llvm/MC/MCSection.h"
11#include "llvm/MC/MCContext.h"
12using namespace llvm;
13
14MCSection::~MCSection() {
15}
16
Chris Lattner968ff112009-08-01 21:11:14 +000017MCSection::MCSection(const StringRef &N, bool isDirective, SectionKind K,
18 MCContext &Ctx)
19 : Name(N), IsDirective(isDirective), Kind(K) {
Chris Lattnered47a042009-07-31 17:02:00 +000020 MCSection *&Entry = Ctx.Sections[Name];
21 assert(Entry == 0 && "Multiple sections with the same name created");
22 Entry = this;
23}
24
Chris Lattnera1c31b72009-08-08 20:50:49 +000025MCSection *MCSection::
26Create(const StringRef &Name, bool IsDirective, SectionKind K, MCContext &Ctx) {
Chris Lattner968ff112009-08-01 21:11:14 +000027 return new (Ctx) MCSection(Name, IsDirective, K, Ctx);
Chris Lattnered47a042009-07-31 17:02:00 +000028}
29
Chris Lattnera1c31b72009-08-08 20:50:49 +000030
31MCSectionELF *MCSectionELF::
32Create(const StringRef &Name, bool IsDirective, SectionKind K, MCContext &Ctx) {
33 return new (Ctx) MCSectionELF(Name, IsDirective, K, Ctx);
34}
35
36
37MCSectionMachO *MCSectionMachO::
38Create(const StringRef &Name, bool IsDirective, SectionKind K, MCContext &Ctx) {
39 return new (Ctx) MCSectionMachO(Name, IsDirective, K, Ctx);
40}
41
42
Chris Lattner7c599d02009-08-08 20:52:13 +000043MCSectionCOFF *MCSectionCOFF::
Chris Lattnera1c31b72009-08-08 20:50:49 +000044Create(const StringRef &Name, bool IsDirective, SectionKind K, MCContext &Ctx) {
Chris Lattner7c599d02009-08-08 20:52:13 +000045 return new (Ctx) MCSectionCOFF(Name, IsDirective, K, Ctx);
Chris Lattnera1c31b72009-08-08 20:50:49 +000046}
47