From 3d414652d36aeb27896cc6666ef15db39f245786 Mon Sep 17 00:00:00 2001 From: Thomas Lively <7121787+tlively@users.noreply.github.com> Date: Wed, 6 Jan 2021 14:36:27 -0500 Subject: Prototype prefetch instructions (#3467) As proposed in https://github.com/WebAssembly/simd/pull/352, using the opcodes used in the LLVM and V8 implementations. --- src/wasm/wasm-binary.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/wasm/wasm-binary.cpp') 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) { -- cgit v1.2.3