diff options
| author | Sam Clegg <sbc@chromium.org> | 2018-03-01 18:06:39 +0000 |
|---|---|---|
| committer | Sam Clegg <sbc@chromium.org> | 2018-03-01 18:06:39 +0000 |
| commit | 8518e7ded56aab1b9de2b5a8685fb2c647c1044b (patch) | |
| tree | 43f4125802e48e87c1e511a21a5743f9bde92360 /lld/wasm/WriterUtils.cpp | |
| parent | 03e101f1b00d463d3a070a43a7ac8f13db291c37 (diff) | |
| download | bcm5719-llvm-8518e7ded56aab1b9de2b5a8685fb2c647c1044b.tar.gz bcm5719-llvm-8518e7ded56aab1b9de2b5a8685fb2c647c1044b.zip | |
[WebAssembly] Use uint8_t for single byte values to match the spec
Differential Revision: https://reviews.llvm.org/D43922
llvm-svn: 326455
Diffstat (limited to 'lld/wasm/WriterUtils.cpp')
| -rw-r--r-- | lld/wasm/WriterUtils.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/lld/wasm/WriterUtils.cpp b/lld/wasm/WriterUtils.cpp index f77127bd53d..88c3757f8c1 100644 --- a/lld/wasm/WriterUtils.cpp +++ b/lld/wasm/WriterUtils.cpp @@ -19,7 +19,7 @@ using namespace llvm; using namespace llvm::wasm; using namespace lld::wasm; -static const char *valueTypeToString(int32_t Type) { +static const char *valueTypeToString(uint8_t Type) { switch (Type) { case WASM_TYPE_I32: return "i32"; @@ -73,15 +73,14 @@ void wasm::writeU32(raw_ostream &OS, uint32_t Number, const Twine &Msg) { support::endian::Writer<support::little>(OS).write(Number); } -void wasm::writeValueType(raw_ostream &OS, int32_t Type, const Twine &Msg) { - debugWrite(OS.tell(), Msg + "[type: " + valueTypeToString(Type) + "]"); - encodeSLEB128(Type, OS); +void wasm::writeValueType(raw_ostream &OS, uint8_t Type, const Twine &Msg) { + writeU8(OS, Type, Msg + "[type: " + valueTypeToString(Type) + "]"); } void wasm::writeSig(raw_ostream &OS, const WasmSignature &Sig) { - writeSleb128(OS, WASM_TYPE_FUNC, "signature type"); + writeU8(OS, WASM_TYPE_FUNC, "signature type"); writeUleb128(OS, Sig.ParamTypes.size(), "param Count"); - for (int32_t ParamType : Sig.ParamTypes) { + for (uint8_t ParamType : Sig.ParamTypes) { writeValueType(OS, ParamType, "param type"); } if (Sig.ReturnType == WASM_TYPE_NORESULT) { @@ -111,7 +110,7 @@ void wasm::writeInitExpr(raw_ostream &OS, const WasmInitExpr &InitExpr) { } void wasm::writeLimits(raw_ostream &OS, const WasmLimits &Limits) { - writeUleb128(OS, Limits.Flags, "limits flags"); + writeU8(OS, Limits.Flags, "limits flags"); writeUleb128(OS, Limits.Initial, "limits initial"); if (Limits.Flags & WASM_LIMITS_FLAG_HAS_MAX) writeUleb128(OS, Limits.Maximum, "limits max"); @@ -119,7 +118,7 @@ void wasm::writeLimits(raw_ostream &OS, const WasmLimits &Limits) { void wasm::writeGlobalType(raw_ostream &OS, const WasmGlobalType &Type) { writeValueType(OS, Type.Type, "global type"); - writeUleb128(OS, Type.Mutable, "global mutable"); + writeU8(OS, Type.Mutable, "global mutable"); } void wasm::writeGlobal(raw_ostream &OS, const WasmGlobal &Global) { |

