Create symbols marking the start of a section earlier.
[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 "llvm/ADT/StringRef.h"
18 #include "llvm/MC/SectionKind.h"
19 #include "llvm/Support/Compiler.h"
20
21 namespace llvm {
22 class MCAsmInfo;
23 class MCExpr;
24 class MCSymbol;
25 class raw_ostream;
26
27 /// Instances of this class represent a uniqued identifier for a section in the
28 /// current translation unit.  The MCContext class uniques and creates these.
29 class MCSection {
30 public:
31   enum SectionVariant { SV_COFF = 0, SV_ELF, SV_MachO };
32
33 private:
34   MCSection(const MCSection &) = delete;
35   void operator=(const MCSection &) = delete;
36
37   MCSymbol *Begin;
38
39 protected:
40   MCSection(SectionVariant V, SectionKind K, MCSymbol *Begin)
41       : Begin(Begin), Variant(V), Kind(K) {}
42   SectionVariant Variant;
43   SectionKind Kind;
44
45 public:
46   virtual ~MCSection();
47
48   SectionKind getKind() const { return Kind; }
49
50   SectionVariant getVariant() const { return Variant; }
51
52   MCSymbol *getBeginSymbol() const { return Begin; }
53
54   virtual void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS,
55                                     const MCExpr *Subsection) const = 0;
56
57   /// Return true if a .align directive should use "optimized nops" to fill
58   /// instead of 0s.
59   virtual bool UseCodeAlign() const = 0;
60
61   /// Check whether this section is "virtual", that is has no actual object
62   /// file contents.
63   virtual bool isVirtualSection() const = 0;
64 };
65
66 } // end namespace llvm
67
68 #endif