1 //===- MCSectionCOFF.h - COFF 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 MCSectionCOFF class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_MC_MCSECTIONCOFF_H
15 #define LLVM_MC_MCSECTIONCOFF_H
17 #include "llvm/ADT/StringRef.h"
18 #include "llvm/MC/MCSection.h"
23 /// MCSectionCOFF - 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;
28 // FIXME: The following fields should not be mutable, but are for now so
29 // the asm parser can honor the .linkonce directive.
31 /// Characteristics - This is the Characteristics field of a section,
32 /// drawn from the enums below.
33 mutable unsigned Characteristics;
35 /// The COMDAT symbol of this section. Only valid if this is a COMDAT
36 /// section. Two COMDAT sections are merged if they have the same
38 MCSymbol *COMDATSymbol;
40 /// Selection - This is the Selection field for the section symbol, if
41 /// it is a COMDAT section (Characteristics & IMAGE_SCN_LNK_COMDAT) != 0
42 mutable int Selection;
45 friend class MCContext;
46 MCSectionCOFF(StringRef Section, unsigned Characteristics,
47 MCSymbol *COMDATSymbol, int Selection, SectionKind K,
49 : MCSection(SV_COFF, K, Begin), SectionName(Section),
50 Characteristics(Characteristics), COMDATSymbol(COMDATSymbol),
51 Selection(Selection) {
52 assert ((Characteristics & 0x00F00000) == 0 &&
53 "alignment must not be set upon section creation");
55 ~MCSectionCOFF() override;
58 /// ShouldOmitSectionDirective - Decides whether a '.section' directive
59 /// should be printed before the section name
60 bool ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const;
62 StringRef getSectionName() const { return SectionName; }
63 unsigned getCharacteristics() const { return Characteristics; }
64 MCSymbol *getCOMDATSymbol() const { return COMDATSymbol; }
65 int getSelection() const { return Selection; }
67 void setSelection(int Selection) const;
69 void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS,
70 const MCExpr *Subsection) const override;
71 bool UseCodeAlign() const override;
72 bool isVirtualSection() const override;
74 static bool classof(const MCSection *S) {
75 return S->getVariant() == SV_COFF;
79 } // end namespace llvm