LLVM 20.0.0git
Wasm.cpp
Go to the documentation of this file.
1//===-- llvm/BinaryFormat/Wasm.cpp -------------------------------*- 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
10
12 switch (Type) {
13 case wasm::WASM_SYMBOL_TYPE_FUNCTION:
14 return "WASM_SYMBOL_TYPE_FUNCTION";
15 case wasm::WASM_SYMBOL_TYPE_GLOBAL:
16 return "WASM_SYMBOL_TYPE_GLOBAL";
17 case wasm::WASM_SYMBOL_TYPE_TABLE:
18 return "WASM_SYMBOL_TYPE_TABLE";
19 case wasm::WASM_SYMBOL_TYPE_DATA:
20 return "WASM_SYMBOL_TYPE_DATA";
21 case wasm::WASM_SYMBOL_TYPE_SECTION:
22 return "WASM_SYMBOL_TYPE_SECTION";
23 case wasm::WASM_SYMBOL_TYPE_TAG:
24 return "WASM_SYMBOL_TYPE_TAG";
25 }
26 llvm_unreachable("unknown symbol type");
27}
28
30 switch (Type) {
31#define WASM_RELOC(NAME, VALUE) \
32 case VALUE: \
33 return #NAME;
34#include "llvm/BinaryFormat/WasmRelocs.def"
35#undef WASM_RELOC
36 default:
37 llvm_unreachable("unknown reloc type");
38 }
39}
40
42#define ECase(X) \
43 case wasm::WASM_SEC_##X: \
44 return #X;
45 switch (Type) {
46 ECase(CUSTOM);
47 ECase(TYPE);
48 ECase(IMPORT);
50 ECase(TABLE);
51 ECase(MEMORY);
53 ECase(EXPORT);
54 ECase(START);
55 ECase(ELEM);
56 ECase(CODE);
57 ECase(DATA);
58 ECase(DATACOUNT);
59 ECase(TAG);
60 default:
61 llvm_unreachable("unknown section type");
62 }
63#undef ECase
64}
65
67 switch (Type) {
68 case R_WASM_MEMORY_ADDR_LEB:
69 case R_WASM_MEMORY_ADDR_LEB64:
70 case R_WASM_MEMORY_ADDR_SLEB:
71 case R_WASM_MEMORY_ADDR_SLEB64:
72 case R_WASM_MEMORY_ADDR_REL_SLEB:
73 case R_WASM_MEMORY_ADDR_REL_SLEB64:
74 case R_WASM_MEMORY_ADDR_I32:
75 case R_WASM_MEMORY_ADDR_I64:
76 case R_WASM_MEMORY_ADDR_TLS_SLEB:
77 case R_WASM_MEMORY_ADDR_TLS_SLEB64:
78 case R_WASM_FUNCTION_OFFSET_I32:
79 case R_WASM_FUNCTION_OFFSET_I64:
80 case R_WASM_SECTION_OFFSET_I32:
81 case R_WASM_MEMORY_ADDR_LOCREL_I32:
82 return true;
83 default:
84 return false;
85 }
86}
#define FUNCTION(NAME, NARG, ROUND_MODE, INTRINSIC)
static constexpr auto TAG
Definition: OpenMPOpt.cpp:184
#define ECase(X)
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
llvm::StringRef toString(WasmSymbolType type)
Definition: Wasm.cpp:11
WasmSymbolType
Definition: Wasm.h:215
bool relocTypeHasAddend(uint32_t type)
Definition: Wasm.cpp:66
llvm::StringRef sectionTypeToString(uint32_t type)
Definition: Wasm.cpp:41
llvm::StringRef relocTypetoString(uint32_t type)
Definition: Wasm.cpp:29