LLVM  3.7.0
MCSectionCOFF.h
Go to the documentation of this file.
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 #include "llvm/Support/COFF.h"
20 
21 namespace llvm {
22 class MCSymbol;
23 
24 /// MCSectionCOFF - This represents a section on Windows
25  class MCSectionCOFF : public MCSection {
26  // The memory for this string is stored in the same MCContext as *this.
27  StringRef SectionName;
28 
29  // FIXME: The following fields should not be mutable, but are for now so
30  // the asm parser can honor the .linkonce directive.
31 
32  /// Characteristics - This is the Characteristics field of a section,
33  /// drawn from the enums below.
34  mutable unsigned Characteristics;
35 
36  /// The COMDAT symbol of this section. Only valid if this is a COMDAT
37  /// section. Two COMDAT sections are merged if they have the same
38  /// COMDAT symbol.
39  MCSymbol *COMDATSymbol;
40 
41  /// Selection - This is the Selection field for the section symbol, if
42  /// it is a COMDAT section (Characteristics & IMAGE_SCN_LNK_COMDAT) != 0
43  mutable int Selection;
44 
45  private:
46  friend class MCContext;
48  MCSymbol *COMDATSymbol, int Selection, SectionKind K,
49  MCSymbol *Begin)
50  : MCSection(SV_COFF, K, Begin), SectionName(Section),
51  Characteristics(Characteristics), COMDATSymbol(COMDATSymbol),
52  Selection(Selection) {
53  assert ((Characteristics & 0x00F00000) == 0 &&
54  "alignment must not be set upon section creation");
55  }
56  ~MCSectionCOFF() override;
57 
58  public:
59  /// ShouldOmitSectionDirective - Decides whether a '.section' directive
60  /// should be printed before the section name
61  bool ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const;
62 
63  StringRef getSectionName() const { return SectionName; }
64  unsigned getCharacteristics() const { return Characteristics; }
65  MCSymbol *getCOMDATSymbol() const { return COMDATSymbol; }
66  int getSelection() const { return Selection; }
67 
68  void setSelection(int Selection) const;
69 
70  void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS,
71  const MCExpr *Subsection) const override;
72  bool UseCodeAlign() const override;
73  bool isVirtualSection() const override;
74 
75  static bool classof(const MCSection *S) {
76  return S->getVariant() == SV_COFF;
77  }
78  };
79 
80 } // end namespace llvm
81 
82 #endif
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:48
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:39
SectionVariant getVariant() const
Definition: MCSection.h:111
void setSelection(int Selection) const
int getSelection() const
Definition: MCSectionCOFF.h:66
MCSectionCOFF - This represents a section on Windows.
Definition: MCSectionCOFF.h:25
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:33
bool isVirtualSection() const override
Check whether this section is "virtual", that is has no actual object file contents.
bool ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const
ShouldOmitSectionDirective - Decides whether a '.section' directive should be printed before the sect...
Context object for machine code objects.
Definition: MCContext.h:48
bool UseCodeAlign() const override
Return true if a .align directive should use "optimized nops" to fill instead of 0s.
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:58
void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS, const MCExpr *Subsection) const override
MCSymbol * getCOMDATSymbol() const
Definition: MCSectionCOFF.h:65
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition: SectionKind.h:28
unsigned getCharacteristics() const
Definition: MCSectionCOFF.h:64
StringRef getSectionName() const
Definition: MCSectionCOFF.h:63
static bool classof(const MCSection *S)
Definition: MCSectionCOFF.h:75
COFFYAML::WeakExternalCharacteristics Characteristics
Definition: COFFYAML.cpp:268
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:38
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:40