aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/BinaryFormat/Wasm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/BinaryFormat/Wasm.cpp')
-rw-r--r--llvm/lib/BinaryFormat/Wasm.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/llvm/lib/BinaryFormat/Wasm.cpp b/llvm/lib/BinaryFormat/Wasm.cpp
index 55efe31..babeb12 100644
--- a/llvm/lib/BinaryFormat/Wasm.cpp
+++ b/llvm/lib/BinaryFormat/Wasm.cpp
@@ -8,7 +8,7 @@
#include "llvm/BinaryFormat/Wasm.h"
-std::string llvm::wasm::toString(wasm::WasmSymbolType Type) {
+llvm::StringRef llvm::wasm::toString(wasm::WasmSymbolType Type) {
switch (Type) {
case wasm::WASM_SYMBOL_TYPE_FUNCTION:
return "WASM_SYMBOL_TYPE_FUNCTION";
@@ -26,7 +26,7 @@ std::string llvm::wasm::toString(wasm::WasmSymbolType Type) {
llvm_unreachable("unknown symbol type");
}
-std::string llvm::wasm::relocTypetoString(uint32_t Type) {
+llvm::StringRef llvm::wasm::relocTypetoString(uint32_t Type) {
switch (Type) {
#define WASM_RELOC(NAME, VALUE) \
case VALUE: \
@@ -38,6 +38,31 @@ std::string llvm::wasm::relocTypetoString(uint32_t Type) {
}
}
+llvm::StringRef llvm::wasm::sectionTypeToString(uint32_t Type) {
+#define ECase(X) \
+ case wasm::WASM_SEC_##X: \
+ return #X;
+ switch (Type) {
+ ECase(CUSTOM);
+ ECase(TYPE);
+ ECase(IMPORT);
+ ECase(FUNCTION);
+ ECase(TABLE);
+ ECase(MEMORY);
+ ECase(GLOBAL);
+ ECase(EXPORT);
+ ECase(START);
+ ECase(ELEM);
+ ECase(CODE);
+ ECase(DATA);
+ ECase(DATACOUNT);
+ ECase(TAG);
+ default:
+ llvm_unreachable("unknown section type");
+ }
+#undef ECase
+}
+
bool llvm::wasm::relocTypeHasAddend(uint32_t Type) {
switch (Type) {
case R_WASM_MEMORY_ADDR_LEB: