LLVM 22.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 friend class MCAsmInfoWasm;
53 MCSectionWasm(StringRef Name, SectionKind K, unsigned SegmentFlags,
54 const MCSymbolWasm *Group, unsigned UniqueID, MCSymbol *Begin)
55 : MCSection(Name, K.isText(), /*IsVirtual=*/false, Begin),
56 UniqueID(UniqueID), Group(Group),
57 IsWasmData(K.isReadOnly() || K.isWriteable()),
58 IsMetadata(K.isMetadata()), SegmentFlags(SegmentFlags) {}
59
60public:
61 const MCSymbolWasm *getGroup() const { return Group; }
62 unsigned getSegmentFlags() const { return SegmentFlags; }
63
64 bool isWasmData() const { return IsWasmData; }
65 bool isMetadata() const { return IsMetadata; }
66
67 bool isUnique() const { return UniqueID != ~0U; }
68 unsigned getUniqueID() const { return UniqueID; }
69
70 uint64_t getSectionOffset() const { return SectionOffset; }
71 void setSectionOffset(uint64_t Offset) { SectionOffset = Offset; }
72
73 uint32_t getSegmentIndex() const { return SegmentIndex; }
74 void setSegmentIndex(uint32_t Index) { SegmentIndex = Index; }
75
76 bool getPassive() const {
78 return IsPassive;
79 }
80 void setPassive(bool V = true) {
82 IsPassive = V;
83 }
84};
85
86} // end namespace llvm
87
88#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
uint32_t getSegmentIndex() const
void setSegmentIndex(uint32_t Index)
void setPassive(bool V=true)
friend class MCContext
bool isUnique() const
bool isWasmData() const
const MCSymbolWasm * getGroup() const
void setSectionOffset(uint64_t Offset)
unsigned getSegmentFlags() const
friend class MCAsmInfoWasm
uint64_t getSectionOffset() const
unsigned getUniqueID() const
bool isMetadata() const
bool getPassive() const
bool isText() const
Definition MCSection.h:566
StringRef Name
Definition MCSection.h:557
MCSection(StringRef Name, bool IsText, bool IsBss, MCSymbol *Begin)
Definition MCSection.cpp:21
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
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:55
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:477