diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2019-09-23 18:15:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-23 18:15:14 -0700 |
commit | 835581f58eb5040656243f7345ebcacf6d7deee5 (patch) | |
tree | d5f8878015be2edcdf3d69306c0a8bc20ecd9bf6 /src/wasm/wasm-binary.cpp | |
parent | fb217c80c6d9c4b52d90571c435fc52dc868df47 (diff) | |
download | binaryen-835581f58eb5040656243f7345ebcacf6d7deee5.tar.gz binaryen-835581f58eb5040656243f7345ebcacf6d7deee5.tar.bz2 binaryen-835581f58eb5040656243f7345ebcacf6d7deee5.zip |
vNxM.load_splat instructions (#2350)
Introduces a new instruction class, `SIMDLoad`. Implements encoding,
decoding, parsing, printing, and interpretation of the load and splat
instructions, including in the C and JS APIs. `v128.load` remains in
the `Load` instruction class for now because the interpreter code
expects a `Load` to be able to load any memory value type.
Diffstat (limited to 'src/wasm/wasm-binary.cpp')
-rw-r--r-- | src/wasm/wasm-binary.cpp | 61 |
1 files changed, 43 insertions, 18 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 7b9d9c624..136301500 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -2340,9 +2340,6 @@ BinaryConsts::ASTNodes WasmBinaryBuilder::readExpression(Expression*& curr) { if (maybeVisitSIMDConst(curr, opcode)) { break; } - if (maybeVisitSIMDLoad(curr, opcode)) { - break; - } if (maybeVisitSIMDStore(curr, opcode)) { break; } @@ -2361,6 +2358,9 @@ BinaryConsts::ASTNodes WasmBinaryBuilder::readExpression(Expression*& curr) { if (maybeVisitSIMDShift(curr, opcode)) { break; } + if (maybeVisitSIMDLoad(curr, opcode)) { + break; + } throwError("invalid code after SIMD prefix: " + std::to_string(opcode)); break; } @@ -4158,21 +4158,6 @@ bool WasmBinaryBuilder::maybeVisitSIMDConst(Expression*& out, uint32_t code) { return true; } -bool WasmBinaryBuilder::maybeVisitSIMDLoad(Expression*& out, uint32_t code) { - if (code != BinaryConsts::V128Load) { - return false; - } - auto* curr = allocator.alloc<Load>(); - curr->type = v128; - curr->bytes = 16; - readMemoryAccess(curr->align, curr->offset); - curr->isAtomic = false; - curr->ptr = popNonVoidExpression(); - curr->finalize(); - out = curr; - return true; -} - bool WasmBinaryBuilder::maybeVisitSIMDStore(Expression*& out, uint32_t code) { if (code != BinaryConsts::V128Store) { return false; @@ -4394,6 +4379,46 @@ bool WasmBinaryBuilder::maybeVisitSIMDShift(Expression*& out, uint32_t code) { return true; } +bool WasmBinaryBuilder::maybeVisitSIMDLoad(Expression*& out, uint32_t code) { + if (code == BinaryConsts::V128Load) { + auto* curr = allocator.alloc<Load>(); + curr->type = v128; + curr->bytes = 16; + readMemoryAccess(curr->align, curr->offset); + curr->isAtomic = false; + curr->ptr = popNonVoidExpression(); + curr->finalize(); + out = curr; + return true; + } + SIMDLoad* curr; + switch (code) { + case BinaryConsts::V8x16LoadSplat: + curr = allocator.alloc<SIMDLoad>(); + curr->op = LoadSplatVec8x16; + break; + case BinaryConsts::V16x8LoadSplat: + curr = allocator.alloc<SIMDLoad>(); + curr->op = LoadSplatVec16x8; + break; + case BinaryConsts::V32x4LoadSplat: + curr = allocator.alloc<SIMDLoad>(); + curr->op = LoadSplatVec32x4; + break; + case BinaryConsts::V64x2LoadSplat: + curr = allocator.alloc<SIMDLoad>(); + curr->op = LoadSplatVec64x2; + break; + default: + return false; + } + readMemoryAccess(curr->align, curr->offset); + curr->ptr = popNonVoidExpression(); + curr->finalize(); + out = curr; + return true; +} + void WasmBinaryBuilder::visitSelect(Select* curr) { if (debug) { std::cerr << "zz node: Select" << std::endl; |