Don't repeat names in comments and don't indent in namespaces. NFC.
[oota-llvm.git] / include / llvm / MC / MCSectionCOFF.h
1 //===- MCSectionCOFF.h - COFF 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 MCSectionCOFF class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_MC_MCSECTIONCOFF_H
15 #define LLVM_MC_MCSECTIONCOFF_H
16
17 #include "llvm/ADT/StringRef.h"
18 #include "llvm/MC/MCSection.h"
19
20 namespace llvm {
21 class MCSymbol;
22
23 /// This represents a section on Windows
24 class MCSectionCOFF : public MCSection {
25   // The memory for this string is stored in the same MCContext as *this.
26   StringRef SectionName;
27
28   // FIXME: The following fields should not be mutable, but are for now so the
29   // asm parser can honor the .linkonce directive.
30
31   /// This is the Characteristics field of a section, drawn from the enums
32   /// below.
33   mutable unsigned Characteristics;
34
35   /// The COMDAT symbol of this section. Only valid if this is a COMDAT section.
36   /// Two COMDAT sections are merged if they have the same COMDAT symbol.
37   MCSymbol *COMDATSymbol;
38
39   /// This is the Selection field for the section symbol, if it is a COMDAT
40   /// section (Characteristics & IMAGE_SCN_LNK_COMDAT) != 0
41   mutable int Selection;
42
43 private:
44   friend class MCContext;
45   MCSectionCOFF(StringRef Section, unsigned Characteristics,
46                 MCSymbol *COMDATSymbol, int Selection, SectionKind K,
47                 MCSymbol *Begin)
48       : MCSection(SV_COFF, K, Begin), SectionName(Section),
49         Characteristics(Characteristics), COMDATSymbol(COMDATSymbol),
50         Selection(Selection) {
51     assert((Characteristics & 0x00F00000) == 0 &&
52            "alignment must not be set upon section creation");
53   }
54   ~MCSectionCOFF() override;
55
56 public:
57   /// Decides whether a '.section' directive should be printed before the
58   /// section name
59   bool ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const;
60
61   StringRef getSectionName() const { return SectionName; }
62   unsigned getCharacteristics() const { return Characteristics; }
63   MCSymbol *getCOMDATSymbol() const { return COMDATSymbol; }
64   int getSelection() const { return Selection; }
65
66   void setSelection(int Selection) const;
67
68   void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS,
69                             const MCExpr *Subsection) const override;
70   bool UseCodeAlign() const override;
71   bool isVirtualSection() const override;
72
73   static bool classof(const MCSection *S) { return S->getVariant() == SV_COFF; }
74 };
75
76 } // end namespace llvm
77
78 #endif