LLVM 19.0.0git
MCSectionWasm.h
Go to the documentation of this file.
1//===- MCSectionWasm.h - Wasm Machine Code Sections -------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file declares the MCSectionWasm class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_MC_MCSECTIONWASM_H
14#define LLVM_MC_MCSECTIONWASM_H
15
16#include "llvm/MC/MCSection.h"
17
18namespace llvm {
19
20class MCSymbol;
21class MCSymbolWasm;
22class StringRef;
23class raw_ostream;
24
25/// This represents a section on wasm.
26class MCSectionWasm final : public MCSection {
27 unsigned UniqueID;
28
29 const MCSymbolWasm *Group;
30
31 // The offset of the MC function/data section in the wasm code/data section.
32 // For data relocations the offset is relative to start of the data payload
33 // itself and does not include the size of the section header.
34 uint64_t SectionOffset = 0;
35
36 // For data sections, this is the index of the corresponding wasm data
37 // segment
38 uint32_t SegmentIndex = 0;
39
40 // For data sections, whether to use a passive segment
41 bool IsPassive = false;
42
43 bool IsWasmData;
44
45 bool IsMetadata;
46
47 // For data sections, bitfield of WasmSegmentFlag
48 unsigned SegmentFlags;
49
50 // The storage of Name is owned by MCContext's WasmUniquingMap.
51 friend class MCContext;
52 MCSectionWasm(StringRef Name, SectionKind K, unsigned SegmentFlags,
53 const MCSymbolWasm *Group, unsigned UniqueID, MCSymbol *Begin)
54 : MCSection(SV_Wasm, Name, K.isText(), /*IsVirtual=*/false, Begin),
55 UniqueID(UniqueID), Group(Group),
56 IsWasmData(K.isReadOnly() || K.isWriteable()),
57 IsMetadata(K.isMetadata()), SegmentFlags(SegmentFlags) {}
58
59public:
60 /// Decides whether a '.section' directive should be printed before the
61 /// section name
62 bool shouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const;
63
64 const MCSymbolWasm *getGroup() const { return Group; }
65 unsigned getSegmentFlags() const { return SegmentFlags; }
66
67 void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
69 uint32_t Subsection) const override;
70 bool useCodeAlign() const override;
71
72 bool isWasmData() const { return IsWasmData; }
73 bool isMetadata() const { return IsMetadata; }
74
75 bool isUnique() const { return UniqueID != ~0U; }
76 unsigned getUniqueID() const { return UniqueID; }
77
78 uint64_t getSectionOffset() const { return SectionOffset; }
79 void setSectionOffset(uint64_t Offset) { SectionOffset = Offset; }
80
81 uint32_t getSegmentIndex() const { return SegmentIndex; }
82 void setSegmentIndex(uint32_t Index) { SegmentIndex = Index; }
83
84 bool getPassive() const {
86 return IsPassive;
87 }
88 void setPassive(bool V = true) {
90 IsPassive = V;
91 }
92 static bool classof(const MCSection *S) { return S->getVariant() == SV_Wasm; }
93};
94
95} // end namespace llvm
96
97#endif
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
Context object for machine code objects.
Definition: MCContext.h:83
This represents a section on wasm.
Definition: MCSectionWasm.h:26
uint32_t getSegmentIndex() const
Definition: MCSectionWasm.h:81
bool useCodeAlign() const override
Return true if a .align directive should use "optimized nops" to fill instead of 0s.
void setSegmentIndex(uint32_t Index)
Definition: MCSectionWasm.h:82
static bool classof(const MCSection *S)
Definition: MCSectionWasm.h:92
bool shouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const
Decides whether a '.section' directive should be printed before the section name.
void setPassive(bool V=true)
Definition: MCSectionWasm.h:88
void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T, raw_ostream &OS, uint32_t Subsection) const override
bool isUnique() const
Definition: MCSectionWasm.h:75
bool isWasmData() const
Definition: MCSectionWasm.h:72
const MCSymbolWasm * getGroup() const
Definition: MCSectionWasm.h:64
void setSectionOffset(uint64_t Offset)
Definition: MCSectionWasm.h:79
unsigned getSegmentFlags() const
Definition: MCSectionWasm.h:65
uint64_t getSectionOffset() const
Definition: MCSectionWasm.h:78
unsigned getUniqueID() const
Definition: MCSectionWasm.h:76
bool isMetadata() const
Definition: MCSectionWasm.h:73
bool getPassive() const
Definition: MCSectionWasm.h:84
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:36
SectionVariant getVariant() const
Definition: MCSection.h:133
bool isText() const
Definition: MCSection.h:131
StringRef Name
Definition: MCSection.h:119
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition: SectionKind.h:22
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:480