1 //===- MCSection.h - Machine Code Sections ----------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the MCSection class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_MC_MCSECTION_H
15 #define LLVM_MC_MCSECTION_H
17 #include "llvm/ADT/StringRef.h"
18 #include "llvm/MC/SectionKind.h"
19 #include "llvm/Support/Compiler.h"
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.
32 enum SectionVariant { SV_COFF = 0, SV_ELF, SV_MachO };
35 MCSection(const MCSection &) = delete;
36 void operator=(const MCSection &) = delete;
40 /// The alignment requirement of this section.
42 /// The section index in the assemblers section list.
46 MCSection(SectionVariant V, SectionKind K, MCSymbol *Begin)
47 : Begin(Begin), End(nullptr), Alignment(1), Ordinal(~UINT32_C(0)),
48 Variant(V), Kind(K) {}
49 SectionVariant Variant;
55 SectionKind getKind() const { return Kind; }
57 SectionVariant getVariant() const { return Variant; }
59 MCSymbol *getBeginSymbol() { return Begin; }
60 const MCSymbol *getBeginSymbol() const {
61 return const_cast<MCSection *>(this)->getBeginSymbol();
63 void setBeginSymbol(MCSymbol *Sym) {
67 MCSymbol *getEndSymbol(MCContext &Ctx);
68 bool hasEnded() const;
70 unsigned getAlignment() const { return Alignment; }
71 void setAlignment(unsigned Value) { Alignment = Value; }
73 unsigned getOrdinal() const { return Ordinal; }
74 void setOrdinal(unsigned Value) { Ordinal = Value; }
76 virtual void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS,
77 const MCExpr *Subsection) const = 0;
79 /// Return true if a .align directive should use "optimized nops" to fill
81 virtual bool UseCodeAlign() const = 0;
83 /// Check whether this section is "virtual", that is has no actual object
85 virtual bool isVirtualSection() const = 0;
88 } // end namespace llvm