LLVM  14.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) {
14  return "WASM_SYMBOL_TYPE_FUNCTION";
16  return "WASM_SYMBOL_TYPE_GLOBAL";
18  return "WASM_SYMBOL_TYPE_TABLE";
20  return "WASM_SYMBOL_TYPE_DATA";
22  return "WASM_SYMBOL_TYPE_SECTION";
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  switch (Type) {
43  case R_WASM_MEMORY_ADDR_LEB:
44  case R_WASM_MEMORY_ADDR_LEB64:
45  case R_WASM_MEMORY_ADDR_SLEB:
46  case R_WASM_MEMORY_ADDR_SLEB64:
47  case R_WASM_MEMORY_ADDR_REL_SLEB:
48  case R_WASM_MEMORY_ADDR_REL_SLEB64:
49  case R_WASM_MEMORY_ADDR_I32:
50  case R_WASM_MEMORY_ADDR_I64:
51  case R_WASM_MEMORY_ADDR_TLS_SLEB:
52  case R_WASM_MEMORY_ADDR_TLS_SLEB64:
53  case R_WASM_FUNCTION_OFFSET_I32:
54  case R_WASM_FUNCTION_OFFSET_I64:
55  case R_WASM_SECTION_OFFSET_I32:
56  case R_WASM_MEMORY_ADDR_LOCREL_I32:
57  return true;
58  default:
59  return false;
60  }
61 }
llvm::wasm::WASM_SYMBOL_TYPE_SECTION
@ WASM_SYMBOL_TYPE_SECTION
Definition: Wasm.h:370
llvm::wasm::WASM_SYMBOL_TYPE_TABLE
@ WASM_SYMBOL_TYPE_TABLE
Definition: Wasm.h:372
llvm::wasm::WASM_SYMBOL_TYPE_GLOBAL
@ WASM_SYMBOL_TYPE_GLOBAL
Definition: Wasm.h:369
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::wasm::WASM_SYMBOL_TYPE_FUNCTION
@ WASM_SYMBOL_TYPE_FUNCTION
Definition: Wasm.h:367
llvm::wasm::WASM_SYMBOL_TYPE_TAG
@ WASM_SYMBOL_TYPE_TAG
Definition: Wasm.h:371
llvm::wasm::relocTypetoString
std::string relocTypetoString(uint32_t type)
Definition: Wasm.cpp:29
llvm::wasm::relocTypeHasAddend
bool relocTypeHasAddend(uint32_t type)
Definition: Wasm.cpp:41
llvm::wasm::toString
std::string toString(WasmSymbolType type)
Definition: Wasm.cpp:11
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:136
uint32_t
llvm::wasm::WasmSymbolType
WasmSymbolType
Definition: Wasm.h:366
Wasm.h
llvm::wasm::WASM_SYMBOL_TYPE_DATA
@ WASM_SYMBOL_TYPE_DATA
Definition: Wasm.h:368