diff options
author | Derek Schuff <dschuff@google.com> | 2017-03-14 20:23:22 +0000 |
---|---|---|
committer | Derek Schuff <dschuff@google.com> | 2017-03-14 20:23:22 +0000 |
commit | e2688c432fcffff53d7d356d7530a0b139c16286 (patch) | |
tree | 2b97e836032eaecdaf9f998154ef61ff141975cd /llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp | |
parent | 265ca535ab1c208749c05fbbb2d18ddd0047dd65 (diff) | |
download | bcm5719-llvm-e2688c432fcffff53d7d356d7530a0b139c16286.tar.gz bcm5719-llvm-e2688c432fcffff53d7d356d7530a0b139c16286.zip |
[WebAssembly] Use LEB encoding for value types
Previously we were using the encoded LEB hex values
for the value types. This change uses the decoded
negative value and the LEB encoder to write them out.
Differential Revision: https://reviews.llvm.org/D30847
Patch by Sam Clegg
llvm-svn: 297777
Diffstat (limited to 'llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp')
-rw-r--r-- | llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp index 5a285935e2b..a499cc23a6b 100644 --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp @@ -152,30 +152,20 @@ void WebAssemblyTargetELFStreamer::emitIndirectFunctionType( void WebAssemblyTargetELFStreamer::emitGlobalImport(StringRef name) { } -static unsigned MVT2WasmType(MVT Ty) { - switch (Ty.SimpleTy) { - case MVT::i32: return wasm::WASM_TYPE_I32; - case MVT::i64: return wasm::WASM_TYPE_I64; - case MVT::f32: return wasm::WASM_TYPE_F32; - case MVT::f64: return wasm::WASM_TYPE_F64; - default: llvm_unreachable("unsupported type"); - } -} - void WebAssemblyTargetWasmStreamer::emitParam(MCSymbol *Symbol, ArrayRef<MVT> Types) { - SmallVector<unsigned, 4> Params; + SmallVector<wasm::ValType, 4> Params; for (MVT Ty : Types) - Params.push_back(MVT2WasmType(Ty)); + Params.push_back(WebAssembly::toValType(Ty)); cast<MCSymbolWasm>(Symbol)->setParams(std::move(Params)); } void WebAssemblyTargetWasmStreamer::emitResult(MCSymbol *Symbol, ArrayRef<MVT> Types) { - SmallVector<unsigned, 4> Returns; + SmallVector<wasm::ValType, 4> Returns; for (MVT Ty : Types) - Returns.push_back(MVT2WasmType(Ty)); + Returns.push_back(WebAssembly::toValType(Ty)); cast<MCSymbolWasm>(Symbol)->setReturns(std::move(Returns)); } |