1 //===-- llvm/BinaryFormat/Wasm.cpp -------------------------------*- C++-*-===//
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
7 //===----------------------------------------------------------------------===//
9 #include "llvm/BinaryFormat/Wasm.h"
11 std::string
llvm::wasm::toString(wasm::WasmSymbolType 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_DATA
:
18 return "WASM_SYMBOL_TYPE_DATA";
19 case wasm::WASM_SYMBOL_TYPE_SECTION
:
20 return "WASM_SYMBOL_TYPE_SECTION";
21 case wasm::WASM_SYMBOL_TYPE_EVENT
:
22 return "WASM_SYMBOL_TYPE_EVENT";
24 llvm_unreachable("unknown symbol type");
27 std::string
llvm::wasm::relocTypetoString(uint32_t Type
) {
29 #define WASM_RELOC(NAME, VALUE) \
32 #include "llvm/BinaryFormat/WasmRelocs.def"
35 llvm_unreachable("unknown reloc type");
39 bool llvm::wasm::relocTypeHasAddend(uint32_t Type
) {
41 case R_WASM_MEMORY_ADDR_LEB
:
42 case R_WASM_MEMORY_ADDR_SLEB
:
43 case R_WASM_MEMORY_ADDR_REL_SLEB
:
44 case R_WASM_MEMORY_ADDR_I32
:
45 case R_WASM_FUNCTION_OFFSET_I32
:
46 case R_WASM_SECTION_OFFSET_I32
: