Chris Lattner | ed47a04 | 2009-07-31 17:02:00 +0000 | [diff] [blame] | 1 | //===- 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" |
| 12 | using namespace llvm; |
| 13 | |
| 14 | MCSection::~MCSection() { |
| 15 | } |
| 16 | |
Chris Lattner | 968ff11 | 2009-08-01 21:11:14 +0000 | [diff] [blame] | 17 | MCSection::MCSection(const StringRef &N, bool isDirective, SectionKind K, |
| 18 | MCContext &Ctx) |
| 19 | : Name(N), IsDirective(isDirective), Kind(K) { |
Chris Lattner | ed47a04 | 2009-07-31 17:02:00 +0000 | [diff] [blame] | 20 | MCSection *&Entry = Ctx.Sections[Name]; |
| 21 | assert(Entry == 0 && "Multiple sections with the same name created"); |
| 22 | Entry = this; |
| 23 | } |
| 24 | |
Chris Lattner | a1c31b7 | 2009-08-08 20:50:49 +0000 | [diff] [blame] | 25 | MCSection *MCSection:: |
| 26 | Create(const StringRef &Name, bool IsDirective, SectionKind K, MCContext &Ctx) { |
Chris Lattner | 968ff11 | 2009-08-01 21:11:14 +0000 | [diff] [blame] | 27 | return new (Ctx) MCSection(Name, IsDirective, K, Ctx); |
Chris Lattner | ed47a04 | 2009-07-31 17:02:00 +0000 | [diff] [blame] | 28 | } |
| 29 | |
Chris Lattner | a1c31b7 | 2009-08-08 20:50:49 +0000 | [diff] [blame] | 30 | |
| 31 | MCSectionELF *MCSectionELF:: |
| 32 | Create(const StringRef &Name, bool IsDirective, SectionKind K, MCContext &Ctx) { |
| 33 | return new (Ctx) MCSectionELF(Name, IsDirective, K, Ctx); |
| 34 | } |
| 35 | |
| 36 | |
| 37 | MCSectionMachO *MCSectionMachO:: |
| 38 | Create(const StringRef &Name, bool IsDirective, SectionKind K, MCContext &Ctx) { |
| 39 | return new (Ctx) MCSectionMachO(Name, IsDirective, K, Ctx); |
| 40 | } |
| 41 | |
| 42 | |
Chris Lattner | 7c599d0 | 2009-08-08 20:52:13 +0000 | [diff] [blame] | 43 | MCSectionCOFF *MCSectionCOFF:: |
Chris Lattner | a1c31b7 | 2009-08-08 20:50:49 +0000 | [diff] [blame] | 44 | Create(const StringRef &Name, bool IsDirective, SectionKind K, MCContext &Ctx) { |
Chris Lattner | 7c599d0 | 2009-08-08 20:52:13 +0000 | [diff] [blame] | 45 | return new (Ctx) MCSectionCOFF(Name, IsDirective, K, Ctx); |
Chris Lattner | a1c31b7 | 2009-08-08 20:50:49 +0000 | [diff] [blame] | 46 | } |
| 47 | |