From 3325a9cc203932e58b6e85dfefe5feb6e72839a4 Mon Sep 17 00:00:00 2001 From: Thomas Lively <7121787+tlively@users.noreply.github.com> Date: Thu, 13 Dec 2018 17:40:27 -0800 Subject: SIMD (#1820) Implement and test the following functionality for SIMD. - Parsing and printing - Assembling and disassembling - Interpretation - C API - JS API --- src/wasm-builder.h | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) (limited to 'src/wasm-builder.h') diff --git a/src/wasm-builder.h b/src/wasm-builder.h index f36ec7a88..dccefa144 100644 --- a/src/wasm-builder.h +++ b/src/wasm-builder.h @@ -293,6 +293,47 @@ public: ret->finalize(); return ret; } + SIMDExtract* makeSIMDExtract(SIMDExtractOp op, Expression* vec, uint8_t idx) { + auto* ret = allocator.alloc(); + ret->op = op; + ret->vec = vec; + ret->idx = idx; + ret->finalize(); + return ret; + } + SIMDReplace* makeSIMDReplace(SIMDReplaceOp op, Expression* vec, uint8_t idx, Expression* value) { + auto* ret = allocator.alloc(); + ret->op = op; + ret->vec = vec; + ret->idx = idx; + ret->value = value; + ret->finalize(); + return ret; + } + SIMDShuffle* makeSIMDShuffle(Expression* left, Expression* right, const std::array& mask) { + auto* ret = allocator.alloc(); + ret->left = left; + ret->right = right; + ret->mask = mask; + ret->finalize(); + return ret; + } + SIMDBitselect* makeSIMDBitselect(Expression* left, Expression* right, Expression* cond) { + auto* ret = allocator.alloc(); + ret->left = left; + ret->right = right; + ret->cond = cond; + ret->finalize(); + return ret; + } + SIMDShift* makeSIMDShift(SIMDShiftOp op, Expression* vec, Expression* shift) { + auto* ret = allocator.alloc(); + ret->op = op; + ret->vec = vec; + ret->shift = shift; + ret->finalize(); + return ret; + } Const* makeConst(Literal value) { assert(isConcreteType(value.type)); auto* ret = allocator.alloc(); @@ -474,7 +515,12 @@ public: case i64: value = Literal(int64_t(0)); break; case f32: value = Literal(float(0)); break; case f64: value = Literal(double(0)); break; - case v128: assert(false && "v128 not implemented yet"); + case v128: { + std::array bytes; + bytes.fill(0); + value = Literal(bytes.data()); + break; + } case none: return ExpressionManipulator::nop(curr); case unreachable: return ExpressionManipulator::convert(curr); } -- cgit v1.2.3