LLVM 24.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;
23
24/// This represents a section on wasm.
25class MCSectionWasm final : public MCSection {
26 unsigned UniqueID;
27
28 const MCSymbolWasm *Group;
29
30 // The offset of the MC function/data section in the wasm code/data section.
31 // For data relocations the offset is relative to start of the data payload
32 // itself and does not include the size of the section header.
33 uint64_t SectionOffset = 0;
34
35 // For data sections, this is the index of the corresponding wasm data
36 // segment
37 uint32_t SegmentIndex = 0;
38
39 // For data sections, whether to use a passive segment
40 bool IsPassive = false;
41
42 bool IsWasmData;
43
44 bool IsMetadata;
45
46 // For data sections, bitfield of WasmSegmentFlag
47 unsigned SegmentFlags;
48
49 // The storage of Name is owned by MCContext's WasmUniquingMap.
50 friend class MCContext;
51 MCSectionWasm(StringRef Name, SectionKind K, unsigned SegmentFlags,
52 const MCSymbolWasm *Group, unsigned UniqueID, MCSymbol *Begin)
53 : MCSection(Name, K.isText(), /*IsVirtual=*/false, Begin),
54 UniqueID(UniqueID), Group(Group),
55 IsWasmData(K.isReadOnly() || K.isWriteable()),
56 IsMetadata(K.isMetadata()), SegmentFlags(SegmentFlags) {}
57
58public:
59 const MCSymbolWasm *getGroup() const { return Group; }
60 unsigned getSegmentFlags() const { return SegmentFlags; }
61
62 bool isWasmData() const { return IsWasmData; }
63 bool isMetadata() const { return IsMetadata; }
64
65 bool isUnique() const { return UniqueID != ~0U; }
66 unsigned getUniqueID() const { return UniqueID; }
67
68 uint64_t getSectionOffset() const { return SectionOffset; }
69 void setSectionOffset(uint64_t Offset) { SectionOffset = Offset; }
70
71 uint32_t getSegmentIndex() const { return SegmentIndex; }
72 void setSegmentIndex(uint32_t Index) { SegmentIndex = Index; }
73
74 bool getPassive() const {
76 return IsPassive;
77 }
78 void setPassive(bool V = true) {
80 IsPassive = V;
81 }
82};
83
84} // end namespace llvm
85
86#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
uint64_t uint64_t
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
uint64_t getSectionOffset() const
unsigned getUniqueID() const
bool isMetadata() const
bool getPassive() const
bool isText() const
Definition MCSection.h:648
StringRef Name
Definition MCSection.h:639
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
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577