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