diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2021-01-06 14:36:27 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-06 11:36:27 -0800 |
commit | 3d414652d36aeb27896cc6666ef15db39f245786 (patch) | |
tree | 695c7bc5a3c47dff0330b625f2e61cb040accc6d /src/wasm/wasm-binary.cpp | |
parent | b79661ee03fc74b3f860bf04e6f1019f7b11c722 (diff) | |
download | binaryen-3d414652d36aeb27896cc6666ef15db39f245786.tar.gz binaryen-3d414652d36aeb27896cc6666ef15db39f245786.tar.bz2 binaryen-3d414652d36aeb27896cc6666ef15db39f245786.zip |
Prototype prefetch instructions (#3467)
As proposed in https://github.com/WebAssembly/simd/pull/352, using the opcodes
used in the LLVM and V8 implementations.
Diffstat (limited to 'src/wasm/wasm-binary.cpp')
-rw-r--r-- | src/wasm/wasm-binary.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index e616493af..f3160c461 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -2967,6 +2967,9 @@ BinaryConsts::ASTNodes WasmBinaryBuilder::readExpression(Expression*& curr) { if (maybeVisitSIMDLoadStoreLane(curr, opcode)) { break; } + if (maybeVisitPrefetch(curr, opcode)) { + break; + } throwError("invalid code after SIMD prefix: " + std::to_string(opcode)); break; } @@ -5372,6 +5375,24 @@ bool WasmBinaryBuilder::maybeVisitSIMDLoadStoreLane(Expression*& out, return true; } +bool WasmBinaryBuilder::maybeVisitPrefetch(Expression*& out, uint32_t code) { + PrefetchOp op; + switch (code) { + case BinaryConsts::PrefetchT: + op = PrefetchTemporal; + break; + case BinaryConsts::PrefetchNT: + op = PrefetchNontemporal; + break; + default: + return false; + } + Address align, offset; + readMemoryAccess(align, offset); + out = Builder(wasm).makePrefetch(op, offset, align, popNonVoidExpression()); + return true; +} + void WasmBinaryBuilder::visitSelect(Select* curr, uint8_t code) { BYN_TRACE("zz node: Select, code " << int32_t(code) << std::endl); if (code == BinaryConsts::SelectWithType) { |