make target-specific TLOF impls (except PIC16) create target-specific
[oota-llvm.git] / include / llvm / MC / MCSection.h
1 //===- MCSection.h - Machine Code Sections ----------------------*- C++ -*-===//
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 // This file declares the MCSection class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_MC_MCSECTION_H
15 #define LLVM_MC_MCSECTION_H
16
17 #include <string>
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/MC/SectionKind.h"
20
21 namespace llvm {
22   class MCContext;
23   
24   /// MCSection - Instances of this class represent a uniqued identifier for a
25   /// section in the current translation unit.  The MCContext class uniques and
26   /// creates these.
27   class MCSection {
28     std::string Name;
29     
30     /// IsDirective - This is true if the section name is a directive, not
31     /// something that should be printed with ".section".
32     ///
33     /// FIXME: This is a hack.  Switch to a semantic view of the section instead
34     /// of a syntactic one.
35     bool IsDirective;
36     
37     MCSection(const MCSection&);      // DO NOT IMPLEMENT
38     void operator=(const MCSection&); // DO NOT IMPLEMENT
39   protected:
40     MCSection(const StringRef &Name, bool IsDirective, SectionKind K,
41               MCContext &Ctx);
42     SectionKind Kind;
43   public:
44     virtual ~MCSection();
45
46     static MCSection *Create(const StringRef &Name, bool IsDirective, 
47                              SectionKind K, MCContext &Ctx);
48     
49     const std::string &getName() const { return Name; }
50     bool isDirective() const { return IsDirective; }
51     
52     SectionKind getKind() const { return Kind; }
53   };
54
55   
56   class MCSectionELF : public MCSection {
57     MCSectionELF(const StringRef &Name, bool IsDirective, SectionKind K,
58                  MCContext &Ctx) : MCSection(Name, IsDirective, K, Ctx) {}
59   public:
60     
61     static MCSectionELF *Create(const StringRef &Name, bool IsDirective, 
62                                 SectionKind K, MCContext &Ctx);
63     
64   };
65
66   class MCSectionMachO : public MCSection {
67     MCSectionMachO(const StringRef &Name, bool IsDirective, SectionKind K,
68                    MCContext &Ctx) : MCSection(Name, IsDirective, K, Ctx) {}
69   public:
70     
71     static MCSectionMachO *Create(const StringRef &Name, bool IsDirective, 
72                                   SectionKind K, MCContext &Ctx);
73   };
74   
75   class MCSectionCOFF : public MCSection {
76     MCSectionCOFF(const StringRef &Name, bool IsDirective, SectionKind K,
77                   MCContext &Ctx) : MCSection(Name, IsDirective, K, Ctx) {}
78   public:
79     
80     static MCSectionCOFF *Create(const StringRef &Name, bool IsDirective, 
81                                    SectionKind K, MCContext &Ctx);
82   };
83   
84 } // end namespace llvm
85
86 #endif