]> git.proxmox.com Git - rustc.git/blame - src/llvm/include/llvm/MC/MCSectionCOFF.h
Imported Upstream version 1.0.0+dfsg1
[rustc.git] / src / llvm / include / llvm / MC / MCSectionCOFF.h
CommitLineData
223e47cc
LB
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
970d7e83 17#include "llvm/ADT/StringRef.h"
223e47cc
LB
18#include "llvm/MC/MCSection.h"
19#include "llvm/Support/COFF.h"
223e47cc
LB
20
21namespace llvm {
1a4d82fc 22class MCSymbol;
223e47cc
LB
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
1a4d82fc
JJ
29 // FIXME: The following fields should not be mutable, but are for now so
30 // the asm parser can honor the .linkonce directive.
31
223e47cc 32 /// Characteristics - This is the Characteristics field of a section,
1a4d82fc
JJ
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;
223e47cc
LB
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
1a4d82fc 43 mutable int Selection;
223e47cc
LB
44
45 private:
46 friend class MCContext;
47 MCSectionCOFF(StringRef Section, unsigned Characteristics,
1a4d82fc
JJ
48 MCSymbol *COMDATSymbol, int Selection, SectionKind K)
49 : MCSection(SV_COFF, K), SectionName(Section),
50 Characteristics(Characteristics), COMDATSymbol(COMDATSymbol),
51 Selection(Selection) {
223e47cc
LB
52 assert ((Characteristics & 0x00F00000) == 0 &&
53 "alignment must not be set upon section creation");
54 }
55 ~MCSectionCOFF();
56
57 public:
58 /// ShouldOmitSectionDirective - Decides whether a '.section' directive
59 /// should be printed before the section name
60 bool ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const;
61
62 StringRef getSectionName() const { return SectionName; }
1a4d82fc 63 std::string getLabelBeginName() const override {
970d7e83
LB
64 return SectionName.str() + "_begin";
65 }
1a4d82fc 66 std::string getLabelEndName() const override {
970d7e83
LB
67 return SectionName.str() + "_end";
68 }
223e47cc 69 unsigned getCharacteristics() const { return Characteristics; }
1a4d82fc
JJ
70 MCSymbol *getCOMDATSymbol() const { return COMDATSymbol; }
71 int getSelection() const { return Selection; }
72
73 void setSelection(int Selection) const;
223e47cc 74
1a4d82fc
JJ
75 void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS,
76 const MCExpr *Subsection) const override;
77 bool UseCodeAlign() const override;
78 bool isVirtualSection() const override;
223e47cc
LB
79
80 static bool classof(const MCSection *S) {
81 return S->getVariant() == SV_COFF;
82 }
223e47cc
LB
83 };
84
85} // end namespace llvm
86
87#endif