LLVM 20.0.0git
WasmObject.h
Go to the documentation of this file.
1//===- WasmObject.h ---------------------------------------------*- 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#ifndef LLVM_LIB_OBJCOPY_WASM_WASMOBJECT_H
10#define LLVM_LIB_OBJCOPY_WASM_WASMOBJECT_H
11
12#include "llvm/ADT/ArrayRef.h"
13#include "llvm/ADT/StringRef.h"
14#include "llvm/Object/Wasm.h"
16#include <vector>
17
18namespace llvm {
19namespace objcopy {
20namespace wasm {
21
22struct Section {
23 // For now, each section is only an opaque binary blob with no distinction
24 // between custom and known sections.
25 uint8_t SectionType;
26 std::optional<uint8_t> HeaderSecSizeEncodingLen;
29};
30
31struct Object {
33 // For now don't discriminate between kinds of sections.
34 std::vector<Section> Sections;
35 bool isRelocatableObject = false;
36
38 std::unique_ptr<MemoryBuffer> &&Content);
39 void removeSections(function_ref<bool(const Section &)> ToRemove);
40
41private:
42 std::vector<std::unique_ptr<MemoryBuffer>> OwnedContents;
43};
44
45} // end namespace wasm
46} // end namespace objcopy
47} // end namespace llvm
48
49#endif // LLVM_LIB_OBJCOPY_WASM_WASMOBJECT_H
ReachingDefAnalysis InstSet & ToRemove
T Content
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
An efficient, type-erasing, non-owning reference to a callable.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
std::vector< Section > Sections
Definition: WasmObject.h:34
llvm::wasm::WasmObjectHeader Header
Definition: WasmObject.h:32
void addSectionWithOwnedContents(Section NewSection, std::unique_ptr< MemoryBuffer > &&Content)
Definition: WasmObject.cpp:21
void removeSections(function_ref< bool(const Section &)> ToRemove)
Definition: WasmObject.cpp:27
ArrayRef< uint8_t > Contents
Definition: WasmObject.h:28
std::optional< uint8_t > HeaderSecSizeEncodingLen
Definition: WasmObject.h:26