From 835581f58eb5040656243f7345ebcacf6d7deee5 Mon Sep 17 00:00:00 2001 From: Thomas Lively <7121787+tlively@users.noreply.github.com> Date: Mon, 23 Sep 2019 18:15:14 -0700 Subject: 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. --- src/wasm/wasm-validator.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/wasm/wasm-validator.cpp') diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index e64e2ef73..68002e4d2 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -276,6 +276,7 @@ public: void visitSIMDShuffle(SIMDShuffle* curr); void visitSIMDTernary(SIMDTernary* curr); void visitSIMDShift(SIMDShift* curr); + void visitSIMDLoad(SIMDLoad* curr); void visitMemoryInit(MemoryInit* curr); void visitDataDrop(DataDrop* curr); void visitMemoryCopy(MemoryCopy* curr); @@ -1054,6 +1055,20 @@ void FunctionValidator::visitSIMDShift(SIMDShift* curr) { curr->shift->type, i32, curr, "expected shift amount to have type i32"); } +void FunctionValidator::visitSIMDLoad(SIMDLoad* curr) { + shouldBeTrue( + getModule()->memory.exists, curr, "Memory operations require a memory"); + shouldBeTrue( + getModule()->features.hasSIMD(), curr, "SIMD operation (SIMD is disabled)"); + shouldBeEqualOrFirstIsUnreachable( + curr->type, v128, curr, "load_splat must have type v128"); + shouldBeEqualOrFirstIsUnreachable( + curr->ptr->type, i32, curr, "load_splat address must have type i32"); + Type lane_t = curr->op == LoadSplatVec64x2 ? i64 : i32; + Index bytes = curr->getMemBytes(); + validateAlignment(curr->align, lane_t, bytes, /*isAtomic=*/false, curr); +} + void FunctionValidator::visitMemoryInit(MemoryInit* curr) { shouldBeTrue(getModule()->features.hasBulkMemory(), curr, -- cgit v1.2.3