]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/MC/MCSectionWasm.h
Update expat to 2.2.6
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / MC / MCSectionWasm.h
1 //===- MCSectionWasm.h - Wasm 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 MCSectionWasm class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_MC_MCSECTIONWASM_H
15 #define LLVM_MC_MCSECTIONWASM_H
16
17 #include "llvm/ADT/Twine.h"
18 #include "llvm/MC/MCSection.h"
19 #include "llvm/MC/MCSymbolWasm.h"
20 #include "llvm/Support/Debug.h"
21 #include "llvm/Support/raw_ostream.h"
22
23 namespace llvm {
24
25 class MCSymbol;
26
27 /// This represents a section on wasm.
28 class MCSectionWasm final : public MCSection {
29 private:
30
31   /// This is the name of the section.  The referenced memory is owned by
32   /// TargetLoweringObjectFileWasm's WasmUniqueMap.
33   StringRef SectionName;
34
35   unsigned UniqueID;
36
37   const MCSymbolWasm *Group;
38
39   // The offset of the MC function/data section in the wasm code/data section.
40   // For data relocations the offset is relative to start of the data payload
41   // itself and does not include the size of the section header.
42   uint64_t SectionOffset;
43
44   // For data sections, this is the offset of the corresponding wasm data
45   // segment
46   uint64_t MemoryOffset;
47
48   friend class MCContext;
49   MCSectionWasm(StringRef Section, SectionKind K, const MCSymbolWasm *group,
50                 unsigned UniqueID, MCSymbol *Begin)
51       : MCSection(SV_Wasm, K, Begin), SectionName(Section), UniqueID(UniqueID),
52         Group(group), SectionOffset(0) {}
53
54   void setSectionName(StringRef Name) { SectionName = Name; }
55
56 public:
57   ~MCSectionWasm();
58
59   /// Decides whether a '.section' directive should be printed before the
60   /// section name
61   bool ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const;
62
63   StringRef getSectionName() const { return SectionName; }
64   const MCSymbolWasm *getGroup() const { return Group; }
65
66   void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
67                             raw_ostream &OS,
68                             const MCExpr *Subsection) const override;
69   bool UseCodeAlign() const override;
70   bool isVirtualSection() const override;
71
72   bool isWasmData() const {
73     return Kind.isGlobalWriteableData() || Kind.isReadOnly();
74   }
75
76   bool isUnique() const { return UniqueID != ~0U; }
77   unsigned getUniqueID() const { return UniqueID; }
78
79   uint64_t getSectionOffset() const { return SectionOffset; }
80   void setSectionOffset(uint64_t Offset) { SectionOffset = Offset; }
81
82   uint32_t getMemoryOffset() const { return MemoryOffset; }
83   void setMemoryOffset(uint32_t Offset) { MemoryOffset = Offset; }
84
85   static bool classof(const MCSection *S) { return S->getVariant() == SV_Wasm; }
86 };
87
88 } // end namespace llvm
89
90 #endif