Commit b48b82e7 authored by Ng Zhi An's avatar Ng Zhi An Committed by Commit Bot

[wasm] Fix wasm decoder for multi-byte opcodes

SIMD opcodes consist of the prefix byte, then an LEB128 encoded int. We
were decoding this incorrectly as a fixed uint8. This fixes the decoder
to properly handle multi bytes.

In some cases, the multi byte logic is applied to all prefixed opcodes.
This is not a problem, since for values < 0x80, the LEB encoding is a
single byte, and decodes to the same int. If the prefix opcode has
instructions with index >= 0x80, it would be required to be LEB128
encoded anyway.

There are a bunch of trivial changes to test-run-wasm-simd, to change
the macro from BUILD to BUILD_V, the former only works for single byte
opcodes, the latter is a new template-based macro that correct handles
multi-byte opcodes. The only unchanged test is the shuffle fuzzer test,
which builds its own sequence of bytes without using the BUILD macro.

Bug: v8:10258
Change-Id: Ie7377e899a7eab97ecf28176fd908babc08d0f19
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2118476
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarDeepti Gandluri <gdeepti@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67186}
parent 70b4f28b
...@@ -731,10 +731,8 @@ class LiftoffCompiler { ...@@ -731,10 +731,8 @@ class LiftoffCompiler {
TraceCacheState(decoder); TraceCacheState(decoder);
#ifdef DEBUG #ifdef DEBUG
SLOW_DCHECK(__ ValidateCacheState()); SLOW_DCHECK(__ ValidateCacheState());
if (WasmOpcodes::IsPrefixOpcode(opcode) && if (WasmOpcodes::IsPrefixOpcode(opcode)) {
decoder->pc() + 1 < decoder->end()) { opcode = decoder->read_prefixed_opcode<Decoder::kValidate>(decoder->pc());
byte op_index = *(decoder->pc() + 1);
opcode = static_cast<WasmOpcode>(opcode << 8 | op_index);
} }
DEBUG_CODE_COMMENT(WasmOpcodes::OpcodeName(opcode)); DEBUG_CODE_COMMENT(WasmOpcodes::OpcodeName(opcode));
#endif #endif
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "src/flags/flags.h" #include "src/flags/flags.h"
#include "src/utils/utils.h" #include "src/utils/utils.h"
#include "src/utils/vector.h" #include "src/utils/vector.h"
#include "src/wasm/wasm-opcodes.h"
#include "src/wasm/wasm-result.h" #include "src/wasm/wasm-result.h"
#include "src/zone/zone-containers.h" #include "src/zone/zone-containers.h"
...@@ -126,6 +127,31 @@ class Decoder { ...@@ -126,6 +127,31 @@ class Decoder {
name); name);
} }
// Reads a prefixed-opcode, possibly with variable-length index.
// The length param is set to the number of bytes this index is encoded with.
// For most cases (non variable-length), it will be 1.
template <ValidateFlag validate>
WasmOpcode read_prefixed_opcode(const byte* pc, uint32_t* length = nullptr,
const char* name = "prefixed opcode") {
uint32_t unused_length;
if (length == nullptr) {
length = &unused_length;
}
DCHECK(WasmOpcodes::IsPrefixOpcode(static_cast<WasmOpcode>(*pc)));
uint32_t index;
if (*pc == WasmOpcode::kSimdPrefix) {
// SIMD opcodes can be multiple bytes (when LEB128 encoded).
index = read_u32v<validate>(pc + 1, length, "prefixed opcode index");
// Only support SIMD opcodes that go up to 0xFF (when decoded). Anything
// bigger will need 1 more byte, and the '<< 8' below will be wrong.
DCHECK_LE(index, 0xff);
} else {
index = *(pc + 1);
*length = 1;
}
return static_cast<WasmOpcode>((*pc) << 8 | index);
}
// Reads a 8-bit unsigned integer (byte) and advances {pc_}. // Reads a 8-bit unsigned integer (byte) and advances {pc_}.
uint8_t consume_u8(const char* name = "uint8_t") { uint8_t consume_u8(const char* name = "uint8_t") {
return consume_little_endian<uint8_t>(name); return consume_little_endian<uint8_t>(name);
......
...@@ -1379,31 +1379,30 @@ class WasmDecoder : public Decoder { ...@@ -1379,31 +1379,30 @@ class WasmDecoder : public Decoder {
} }
} }
case kSimdPrefix: { case kSimdPrefix: {
byte simd_index = decoder->read_u8<validate>(pc + 1, "simd_index"); uint32_t length = 0;
WasmOpcode opcode = opcode = decoder->read_prefixed_opcode<validate>(pc, &length);
static_cast<WasmOpcode>(kSimdPrefix << 8 | simd_index);
switch (opcode) { switch (opcode) {
#define DECLARE_OPCODE_CASE(name, opcode, sig) case kExpr##name: #define DECLARE_OPCODE_CASE(name, opcode, sig) case kExpr##name:
FOREACH_SIMD_0_OPERAND_OPCODE(DECLARE_OPCODE_CASE) FOREACH_SIMD_0_OPERAND_OPCODE(DECLARE_OPCODE_CASE)
#undef DECLARE_OPCODE_CASE #undef DECLARE_OPCODE_CASE
return 2; return 1 + length;
#define DECLARE_OPCODE_CASE(name, opcode, sig) case kExpr##name: #define DECLARE_OPCODE_CASE(name, opcode, sig) case kExpr##name:
FOREACH_SIMD_1_OPERAND_OPCODE(DECLARE_OPCODE_CASE) FOREACH_SIMD_1_OPERAND_OPCODE(DECLARE_OPCODE_CASE)
#undef DECLARE_OPCODE_CASE #undef DECLARE_OPCODE_CASE
return 3; return 2 + length;
#define DECLARE_OPCODE_CASE(name, opcode, sig) case kExpr##name: #define DECLARE_OPCODE_CASE(name, opcode, sig) case kExpr##name:
FOREACH_SIMD_MEM_OPCODE(DECLARE_OPCODE_CASE) FOREACH_SIMD_MEM_OPCODE(DECLARE_OPCODE_CASE)
#undef DECLARE_OPCODE_CASE #undef DECLARE_OPCODE_CASE
{ {
MemoryAccessImmediate<validate> imm(decoder, pc + 1, UINT32_MAX); MemoryAccessImmediate<validate> imm(decoder, pc + 1, UINT32_MAX);
return 2 + imm.length; return 1 + length + imm.length;
} }
// Shuffles require a byte per lane, or 16 immediate bytes. // Shuffles require a byte per lane, or 16 immediate bytes.
case kExprS8x16Shuffle: case kExprS8x16Shuffle:
return 2 + kSimd128Size; return 1 + length + kSimd128Size;
default: default:
decoder->error(pc, "invalid SIMD opcode"); decoder->error(pc, "invalid SIMD opcode");
return 2; return 1 + length;
} }
} }
case kAtomicPrefix: { case kAtomicPrefix: {
...@@ -1508,7 +1507,7 @@ class WasmDecoder : public Decoder { ...@@ -1508,7 +1507,7 @@ class WasmDecoder : public Decoder {
case kNumericPrefix: case kNumericPrefix:
case kAtomicPrefix: case kAtomicPrefix:
case kSimdPrefix: { case kSimdPrefix: {
opcode = static_cast<WasmOpcode>(opcode << 8 | *(pc + 1)); opcode = this->read_prefixed_opcode<validate>(pc);
switch (opcode) { switch (opcode) {
FOREACH_SIMD_1_OPERAND_1_PARAM_OPCODE(DECLARE_OPCODE_CASE) FOREACH_SIMD_1_OPERAND_1_PARAM_OPCODE(DECLARE_OPCODE_CASE)
return {1, 1}; return {1, 1};
...@@ -1622,12 +1621,8 @@ class WasmFullDecoder : public WasmDecoder<validate> { ...@@ -1622,12 +1621,8 @@ class WasmFullDecoder : public WasmDecoder<validate> {
if (!WasmOpcodes::IsPrefixOpcode(opcode)) { if (!WasmOpcodes::IsPrefixOpcode(opcode)) {
return WasmOpcodes::OpcodeName(static_cast<WasmOpcode>(opcode)); return WasmOpcodes::OpcodeName(static_cast<WasmOpcode>(opcode));
} }
// We need one more byte. opcode = this->template read_prefixed_opcode<Decoder::kValidate>(pc);
++pc; return WasmOpcodes::OpcodeName(opcode);
if (pc >= this->end_) return "<end>";
byte sub_opcode = *pc;
opcode = static_cast<WasmOpcode>(opcode << 8 | sub_opcode);
return WasmOpcodes::OpcodeName(static_cast<WasmOpcode>(opcode));
} }
inline Zone* zone() const { return zone_; } inline Zone* zone() const { return zone_; }
...@@ -2355,13 +2350,14 @@ class WasmFullDecoder : public WasmDecoder<validate> { ...@@ -2355,13 +2350,14 @@ class WasmFullDecoder : public WasmDecoder<validate> {
} }
case kSimdPrefix: { case kSimdPrefix: {
CHECK_PROTOTYPE_OPCODE(simd); CHECK_PROTOTYPE_OPCODE(simd);
len++; uint32_t length = 0;
byte simd_index = opcode =
this->template read_u8<validate>(this->pc_ + 1, "simd index"); this->template read_prefixed_opcode<validate>(this->pc_, &length);
opcode = static_cast<WasmOpcode>(opcode << 8 | simd_index); len += length;
TRACE_PART(TRACE_INST_FORMAT, startrel(this->pc_), TRACE_PART(TRACE_INST_FORMAT, startrel(this->pc_),
WasmOpcodes::OpcodeName(opcode)); WasmOpcodes::OpcodeName(opcode));
len += DecodeSimdOpcode(opcode); len += DecodeSimdOpcode(opcode, length);
break; break;
} }
case kAtomicPrefix: { case kAtomicPrefix: {
...@@ -2426,7 +2422,8 @@ class WasmFullDecoder : public WasmDecoder<validate> { ...@@ -2426,7 +2422,8 @@ class WasmFullDecoder : public WasmDecoder<validate> {
auto& val = stack_[i]; auto& val = stack_[i];
WasmOpcode opcode = static_cast<WasmOpcode>(*val.pc); WasmOpcode opcode = static_cast<WasmOpcode>(*val.pc);
if (WasmOpcodes::IsPrefixOpcode(opcode)) { if (WasmOpcodes::IsPrefixOpcode(opcode)) {
opcode = static_cast<WasmOpcode>(opcode << 8 | *(val.pc + 1)); opcode = this->template read_prefixed_opcode<Decoder::kNoValidate>(
val.pc);
} }
TRACE_PART(" %c@%d:%s", val.type.short_name(), TRACE_PART(" %c@%d:%s", val.type.short_name(),
static_cast<int>(val.pc - this->start_), static_cast<int>(val.pc - this->start_),
...@@ -2546,9 +2543,11 @@ class WasmFullDecoder : public WasmDecoder<validate> { ...@@ -2546,9 +2543,11 @@ class WasmFullDecoder : public WasmDecoder<validate> {
return imm.length; return imm.length;
} }
int DecodeLoadTransformMem(LoadType type, LoadTransformationKind transform) { int DecodeLoadTransformMem(LoadType type, LoadTransformationKind transform,
uint32_t opcode_length) {
if (!CheckHasMemory()) return 0; if (!CheckHasMemory()) return 0;
MemoryAccessImmediate<validate> imm(this, this->pc_ + 1, type.size_log_2()); MemoryAccessImmediate<validate> imm(this, this->pc_ + opcode_length,
type.size_log_2());
auto index = Pop(0, kWasmI32); auto index = Pop(0, kWasmI32);
auto* result = Push(kWasmS128); auto* result = Push(kWasmS128);
CALL_INTERFACE_IF_REACHABLE(LoadTransform, type, transform, imm, index, CALL_INTERFACE_IF_REACHABLE(LoadTransform, type, transform, imm, index,
...@@ -2686,8 +2685,15 @@ class WasmFullDecoder : public WasmDecoder<validate> { ...@@ -2686,8 +2685,15 @@ class WasmFullDecoder : public WasmDecoder<validate> {
return 16; return 16;
} }
uint32_t DecodeSimdOpcode(WasmOpcode opcode) { uint32_t DecodeSimdOpcode(WasmOpcode opcode, uint32_t opcode_length) {
// opcode_length is the number of bytes that this SIMD-specific opcode takes
// up in the LEB128 encoded form.
uint32_t len = 0; uint32_t len = 0;
// TODO(v8:10258): Most of the decodings below (like SimdExtractLane) should
// take opcode_length as a parameter, since that will determine where the
// immediate is located. However, for most of these instructions, their
// encoded opcodes take up 2 bytes, so they will not be affected by the
// variable-length encoding, and will still work correctly.
switch (opcode) { switch (opcode) {
case kExprF64x2ExtractLane: { case kExprF64x2ExtractLane: {
len = SimdExtractLane(opcode, kWasmF64); len = SimdExtractLane(opcode, kWasmF64);
...@@ -2739,43 +2745,51 @@ class WasmFullDecoder : public WasmDecoder<validate> { ...@@ -2739,43 +2745,51 @@ class WasmFullDecoder : public WasmDecoder<validate> {
break; break;
case kExprS8x16LoadSplat: case kExprS8x16LoadSplat:
len = DecodeLoadTransformMem(LoadType::kI32Load8S, len = DecodeLoadTransformMem(LoadType::kI32Load8S,
LoadTransformationKind::kSplat); LoadTransformationKind::kSplat,
opcode_length);
break; break;
case kExprS16x8LoadSplat: case kExprS16x8LoadSplat:
len = DecodeLoadTransformMem(LoadType::kI32Load16S, len = DecodeLoadTransformMem(LoadType::kI32Load16S,
LoadTransformationKind::kSplat); LoadTransformationKind::kSplat,
opcode_length);
break; break;
case kExprS32x4LoadSplat: case kExprS32x4LoadSplat:
len = DecodeLoadTransformMem(LoadType::kI32Load, len = DecodeLoadTransformMem(
LoadTransformationKind::kSplat); LoadType::kI32Load, LoadTransformationKind::kSplat, opcode_length);
break; break;
case kExprS64x2LoadSplat: case kExprS64x2LoadSplat:
len = DecodeLoadTransformMem(LoadType::kI64Load, len = DecodeLoadTransformMem(
LoadTransformationKind::kSplat); LoadType::kI64Load, LoadTransformationKind::kSplat, opcode_length);
break; break;
case kExprI16x8Load8x8S: case kExprI16x8Load8x8S:
len = DecodeLoadTransformMem(LoadType::kI32Load8S, len = DecodeLoadTransformMem(LoadType::kI32Load8S,
LoadTransformationKind::kExtend); LoadTransformationKind::kExtend,
opcode_length);
break; break;
case kExprI16x8Load8x8U: case kExprI16x8Load8x8U:
len = DecodeLoadTransformMem(LoadType::kI32Load8U, len = DecodeLoadTransformMem(LoadType::kI32Load8U,
LoadTransformationKind::kExtend); LoadTransformationKind::kExtend,
opcode_length);
break; break;
case kExprI32x4Load16x4S: case kExprI32x4Load16x4S:
len = DecodeLoadTransformMem(LoadType::kI32Load16S, len = DecodeLoadTransformMem(LoadType::kI32Load16S,
LoadTransformationKind::kExtend); LoadTransformationKind::kExtend,
opcode_length);
break; break;
case kExprI32x4Load16x4U: case kExprI32x4Load16x4U:
len = DecodeLoadTransformMem(LoadType::kI32Load16U, len = DecodeLoadTransformMem(LoadType::kI32Load16U,
LoadTransformationKind::kExtend); LoadTransformationKind::kExtend,
opcode_length);
break; break;
case kExprI64x2Load32x2S: case kExprI64x2Load32x2S:
len = DecodeLoadTransformMem(LoadType::kI64Load32S, len = DecodeLoadTransformMem(LoadType::kI64Load32S,
LoadTransformationKind::kExtend); LoadTransformationKind::kExtend,
opcode_length);
break; break;
case kExprI64x2Load32x2U: case kExprI64x2Load32x2U:
len = DecodeLoadTransformMem(LoadType::kI64Load32U, len = DecodeLoadTransformMem(LoadType::kI64Load32U,
LoadTransformationKind::kExtend); LoadTransformationKind::kExtend,
opcode_length);
break; break;
default: { default: {
if (!FLAG_wasm_simd_post_mvp && if (!FLAG_wasm_simd_post_mvp &&
......
...@@ -173,9 +173,7 @@ class V8_EXPORT_PRIVATE BytecodeIterator : public NON_EXPORTED_BASE(Decoder) { ...@@ -173,9 +173,7 @@ class V8_EXPORT_PRIVATE BytecodeIterator : public NON_EXPORTED_BASE(Decoder) {
bool has_next() { return pc_ < end_; } bool has_next() { return pc_ < end_; }
WasmOpcode prefixed_opcode() { WasmOpcode prefixed_opcode() {
byte prefix = read_u8<Decoder::kNoValidate>(pc_, "expected prefix"); return read_prefixed_opcode<Decoder::kNoValidate>(pc_);
byte index = read_u8<Decoder::kNoValidate>(pc_ + 1, "expected index");
return static_cast<WasmOpcode>(prefix << 8 | index);
} }
}; };
......
...@@ -1748,7 +1748,7 @@ class ThreadImpl { ...@@ -1748,7 +1748,7 @@ class ThreadImpl {
DoTrap(kTrapUnalignedAccess, pc); DoTrap(kTrapUnalignedAccess, pc);
return false; return false;
} }
*len = 2 + imm.length; *len += imm.length;
return true; return true;
} }
...@@ -1777,7 +1777,7 @@ class ThreadImpl { ...@@ -1777,7 +1777,7 @@ class ThreadImpl {
DoTrap(kTrapUnalignedAccess, pc); DoTrap(kTrapUnalignedAccess, pc);
return false; return false;
} }
*len = 2 + imm.length; *len += imm.length;
return true; return true;
} }
...@@ -2167,7 +2167,7 @@ class ThreadImpl { ...@@ -2167,7 +2167,7 @@ class ThreadImpl {
#undef ATOMIC_STORE_CASE #undef ATOMIC_STORE_CASE
case kExprAtomicFence: case kExprAtomicFence:
std::atomic_thread_fence(std::memory_order_seq_cst); std::atomic_thread_fence(std::memory_order_seq_cst);
*len += 2; *len += 1;
break; break;
case kExprI32AtomicWait: { case kExprI32AtomicWait: {
int32_t val; int32_t val;
...@@ -3038,13 +3038,16 @@ class ThreadImpl { ...@@ -3038,13 +3038,16 @@ class ThreadImpl {
byte orig = code->start[pc]; byte orig = code->start[pc];
WasmOpcode opcode = static_cast<WasmOpcode>(orig); WasmOpcode opcode = static_cast<WasmOpcode>(orig);
if (WasmOpcodes::IsPrefixOpcode(opcode)) { if (WasmOpcodes::IsPrefixOpcode(opcode)) {
opcode = static_cast<WasmOpcode>(opcode << 8 | code->start[pc + 1]); uint32_t length;
opcode = decoder.read_prefixed_opcode<Decoder::kNoValidate>(
&code->start[pc], &length);
len += length;
} }
if (V8_UNLIKELY(orig == kInternalBreakpoint)) { if (V8_UNLIKELY(orig == kInternalBreakpoint)) {
orig = code->orig_start[pc]; orig = code->orig_start[pc];
if (WasmOpcodes::IsPrefixOpcode(static_cast<WasmOpcode>(orig))) { if (WasmOpcodes::IsPrefixOpcode(static_cast<WasmOpcode>(orig))) {
opcode = opcode = decoder.read_prefixed_opcode<Decoder::kNoValidate>(
static_cast<WasmOpcode>(orig << 8 | code->orig_start[pc + 1]); &code->start[pc]);
} }
if (SkipBreakpoint(code, pc)) { if (SkipBreakpoint(code, pc)) {
// skip breakpoint by switching on original code. // skip breakpoint by switching on original code.
...@@ -3647,7 +3650,6 @@ class ThreadImpl { ...@@ -3647,7 +3650,6 @@ class ThreadImpl {
break; break;
} }
case kNumericPrefix: { case kNumericPrefix: {
++len;
if (!ExecuteNumericOp(opcode, &decoder, code, pc, &len)) return; if (!ExecuteNumericOp(opcode, &decoder, code, pc, &len)) return;
break; break;
} }
...@@ -3656,7 +3658,6 @@ class ThreadImpl { ...@@ -3656,7 +3658,6 @@ class ThreadImpl {
break; break;
} }
case kSimdPrefix: { case kSimdPrefix: {
++len;
if (!ExecuteSimdOp(opcode, &decoder, code, pc, &len)) return; if (!ExecuteSimdOp(opcode, &decoder, code, pc, &len)) return;
break; break;
} }
......
...@@ -409,10 +409,9 @@ bool ExpectFused(ExecutionTier tier) { ...@@ -409,10 +409,9 @@ bool ExpectFused(ExecutionTier tier) {
WASM_RETURN1(WASM_ZERO)) WASM_RETURN1(WASM_ZERO))
#define TO_BYTE(val) static_cast<byte>(val) #define TO_BYTE(val) static_cast<byte>(val)
// TODO(v8:10258): We have support for emitting multi-byte opcodes now, so this // TODO(v8:10258): Still need this for shuffle test
// can change to simply, op, once the decoder is fixed to decode multi byte #define WASM_SIMD_OP_BYTE(op) kSimdPrefix, TO_BYTE(op)
// opcodes. #define WASM_SIMD_OP(op) op
#define WASM_SIMD_OP(op) kSimdPrefix, TO_BYTE(op)
#define WASM_SIMD_SPLAT(Type, ...) __VA_ARGS__, WASM_SIMD_OP(kExpr##Type##Splat) #define WASM_SIMD_SPLAT(Type, ...) __VA_ARGS__, WASM_SIMD_OP(kExpr##Type##Splat)
#define WASM_SIMD_UNOP(op, x) x, WASM_SIMD_OP(op) #define WASM_SIMD_UNOP(op, x) x, WASM_SIMD_OP(op)
#define WASM_SIMD_BINOP(op, x, y) x, y, WASM_SIMD_OP(op) #define WASM_SIMD_BINOP(op, x, y) x, y, WASM_SIMD_OP(op)
...@@ -568,7 +567,7 @@ WASM_SIMD_TEST(F32x4Splat) { ...@@ -568,7 +567,7 @@ WASM_SIMD_TEST(F32x4Splat) {
// Set up a global to hold output vector. // Set up a global to hold output vector.
float* g = r.builder().AddGlobal<float>(kWasmS128); float* g = r.builder().AddGlobal<float>(kWasmS128);
byte param1 = 0; byte param1 = 0;
BUILD(r, WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(param1))), BUILD_V(r, WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(param1))),
WASM_ONE); WASM_ONE);
FOR_FLOAT32_INPUTS(x) { FOR_FLOAT32_INPUTS(x) {
...@@ -591,7 +590,7 @@ WASM_SIMD_TEST(F32x4ReplaceLane) { ...@@ -591,7 +590,7 @@ WASM_SIMD_TEST(F32x4ReplaceLane) {
float* g = r.builder().AddGlobal<float>(kWasmS128); float* g = r.builder().AddGlobal<float>(kWasmS128);
// Build function to replace each lane with its (FP) index. // Build function to replace each lane with its (FP) index.
byte temp1 = r.AllocateLocal(kWasmS128); byte temp1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_F32x4_SPLAT(WASM_F32(3.14159f))), BUILD_V(r, WASM_SET_LOCAL(temp1, WASM_SIMD_F32x4_SPLAT(WASM_F32(3.14159f))),
WASM_SET_LOCAL(temp1, WASM_SIMD_F32x4_REPLACE_LANE( WASM_SET_LOCAL(temp1, WASM_SIMD_F32x4_REPLACE_LANE(
0, WASM_GET_LOCAL(temp1), WASM_F32(0.0f))), 0, WASM_GET_LOCAL(temp1), WASM_F32(0.0f))),
WASM_SET_LOCAL(temp1, WASM_SIMD_F32x4_REPLACE_LANE( WASM_SET_LOCAL(temp1, WASM_SIMD_F32x4_REPLACE_LANE(
...@@ -618,7 +617,8 @@ WASM_SIMD_COMPILED_TEST(F32x4ConvertI32x4) { ...@@ -618,7 +617,8 @@ WASM_SIMD_COMPILED_TEST(F32x4ConvertI32x4) {
// Build fn to splat test value, perform conversions, and write the results. // Build fn to splat test value, perform conversions, and write the results.
byte value = 0; byte value = 0;
byte temp1 = r.AllocateLocal(kWasmS128); byte temp1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(value))), BUILD_V(
r, WASM_SET_LOCAL(temp1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(value))),
WASM_SET_GLOBAL( WASM_SET_GLOBAL(
0, WASM_SIMD_UNOP(kExprF32x4SConvertI32x4, WASM_GET_LOCAL(temp1))), 0, WASM_SIMD_UNOP(kExprF32x4SConvertI32x4, WASM_GET_LOCAL(temp1))),
WASM_SET_GLOBAL( WASM_SET_GLOBAL(
...@@ -706,7 +706,8 @@ void RunF32x4UnOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -706,7 +706,8 @@ void RunF32x4UnOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
// Build fn to splat test value, perform unop, and write the result. // Build fn to splat test value, perform unop, and write the result.
byte value = 0; byte value = 0;
byte temp1 = r.AllocateLocal(kWasmS128); byte temp1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(value))), BUILD_V(r,
WASM_SET_LOCAL(temp1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(value))),
WASM_SET_GLOBAL(0, WASM_SIMD_UNOP(opcode, WASM_GET_LOCAL(temp1))), WASM_SET_GLOBAL(0, WASM_SIMD_UNOP(opcode, WASM_GET_LOCAL(temp1))),
WASM_ONE); WASM_ONE);
...@@ -771,7 +772,8 @@ void RunF32x4BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -771,7 +772,8 @@ void RunF32x4BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
byte value1 = 0, value2 = 1; byte value1 = 0, value2 = 1;
byte temp1 = r.AllocateLocal(kWasmS128); byte temp1 = r.AllocateLocal(kWasmS128);
byte temp2 = r.AllocateLocal(kWasmS128); byte temp2 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(value1))), BUILD_V(r,
WASM_SET_LOCAL(temp1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(value1))),
WASM_SET_LOCAL(temp2, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(value2))), WASM_SET_LOCAL(temp2, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(value2))),
WASM_SET_GLOBAL(0, WASM_SIMD_BINOP(opcode, WASM_GET_LOCAL(temp1), WASM_SET_GLOBAL(0, WASM_SIMD_BINOP(opcode, WASM_GET_LOCAL(temp1),
WASM_GET_LOCAL(temp2))), WASM_GET_LOCAL(temp2))),
...@@ -838,7 +840,8 @@ void RunF32x4CompareOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -838,7 +840,8 @@ void RunF32x4CompareOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
byte value1 = 0, value2 = 1; byte value1 = 0, value2 = 1;
byte temp1 = r.AllocateLocal(kWasmS128); byte temp1 = r.AllocateLocal(kWasmS128);
byte temp2 = r.AllocateLocal(kWasmS128); byte temp2 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(value1))), BUILD_V(r,
WASM_SET_LOCAL(temp1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(value1))),
WASM_SET_LOCAL(temp2, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(value2))), WASM_SET_LOCAL(temp2, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(value2))),
WASM_SET_GLOBAL(0, WASM_SIMD_BINOP(opcode, WASM_GET_LOCAL(temp1), WASM_SET_GLOBAL(0, WASM_SIMD_BINOP(opcode, WASM_GET_LOCAL(temp1),
WASM_GET_LOCAL(temp2))), WASM_GET_LOCAL(temp2))),
...@@ -891,7 +894,8 @@ WASM_SIMD_TEST_NO_LOWERING(F32x4Qfma) { ...@@ -891,7 +894,8 @@ WASM_SIMD_TEST_NO_LOWERING(F32x4Qfma) {
float* g = r.builder().AddGlobal<float>(kWasmS128); float* g = r.builder().AddGlobal<float>(kWasmS128);
// Build fn to splat test values, perform compare op, and write the result. // Build fn to splat test values, perform compare op, and write the result.
byte value1 = 0, value2 = 1, value3 = 2; byte value1 = 0, value2 = 1, value3 = 2;
BUILD(r, BUILD_V(
r,
WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_QFMA( WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_QFMA(
WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(value1)), WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(value1)),
WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(value2)), WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(value2)),
...@@ -916,7 +920,8 @@ WASM_SIMD_TEST_NO_LOWERING(F32x4Qfms) { ...@@ -916,7 +920,8 @@ WASM_SIMD_TEST_NO_LOWERING(F32x4Qfms) {
float* g = r.builder().AddGlobal<float>(kWasmS128); float* g = r.builder().AddGlobal<float>(kWasmS128);
// Build fn to splat test values, perform compare op, and write the result. // Build fn to splat test values, perform compare op, and write the result.
byte value1 = 0, value2 = 1, value3 = 2; byte value1 = 0, value2 = 1, value3 = 2;
BUILD(r, BUILD_V(
r,
WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_QFMS( WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_QFMS(
WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(value1)), WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(value1)),
WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(value2)), WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(value2)),
...@@ -957,7 +962,7 @@ WASM_SIMD_TEST_NO_LOWERING(I64x2ExtractLane) { ...@@ -957,7 +962,7 @@ WASM_SIMD_TEST_NO_LOWERING(I64x2ExtractLane) {
WasmRunner<int64_t> r(execution_tier, lower_simd); WasmRunner<int64_t> r(execution_tier, lower_simd);
r.AllocateLocal(kWasmI64); r.AllocateLocal(kWasmI64);
r.AllocateLocal(kWasmS128); r.AllocateLocal(kWasmS128);
BUILD( BUILD_V(
r, r,
WASM_SET_LOCAL(0, WASM_SIMD_I64x2_EXTRACT_LANE( WASM_SET_LOCAL(0, WASM_SIMD_I64x2_EXTRACT_LANE(
0, WASM_SIMD_I64x2_SPLAT(WASM_I64V(0xFFFFFFFFFF)))), 0, WASM_SIMD_I64x2_SPLAT(WASM_I64V(0xFFFFFFFFFF)))),
...@@ -972,7 +977,7 @@ WASM_SIMD_TEST_NO_LOWERING(I64x2ReplaceLane) { ...@@ -972,7 +977,7 @@ WASM_SIMD_TEST_NO_LOWERING(I64x2ReplaceLane) {
int64_t* g = r.builder().AddGlobal<int64_t>(kWasmS128); int64_t* g = r.builder().AddGlobal<int64_t>(kWasmS128);
// Build function to replace each lane with its index. // Build function to replace each lane with its index.
byte temp1 = r.AllocateLocal(kWasmS128); byte temp1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I64x2_SPLAT(WASM_I64V(-1))), BUILD_V(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I64x2_SPLAT(WASM_I64V(-1))),
WASM_SET_LOCAL(temp1, WASM_SIMD_I64x2_REPLACE_LANE( WASM_SET_LOCAL(temp1, WASM_SIMD_I64x2_REPLACE_LANE(
0, WASM_GET_LOCAL(temp1), WASM_I64V(0))), 0, WASM_GET_LOCAL(temp1), WASM_I64V(0))),
WASM_SET_GLOBAL(0, WASM_SIMD_I64x2_REPLACE_LANE( WASM_SET_GLOBAL(0, WASM_SIMD_I64x2_REPLACE_LANE(
...@@ -993,7 +998,8 @@ void RunI64x2UnOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -993,7 +998,8 @@ void RunI64x2UnOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
// Build fn to splat test value, perform unop, and write the result. // Build fn to splat test value, perform unop, and write the result.
byte value = 0; byte value = 0;
byte temp1 = r.AllocateLocal(kWasmS128); byte temp1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I64x2_SPLAT(WASM_GET_LOCAL(value))), BUILD_V(r,
WASM_SET_LOCAL(temp1, WASM_SIMD_I64x2_SPLAT(WASM_GET_LOCAL(value))),
WASM_SET_GLOBAL(0, WASM_SIMD_UNOP(opcode, WASM_GET_LOCAL(temp1))), WASM_SET_GLOBAL(0, WASM_SIMD_UNOP(opcode, WASM_GET_LOCAL(temp1))),
WASM_ONE); WASM_ONE);
...@@ -1022,7 +1028,7 @@ void RunI64x2ShiftOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -1022,7 +1028,7 @@ void RunI64x2ShiftOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
byte value = 0; byte value = 0;
byte simd = r.AllocateLocal(kWasmS128); byte simd = r.AllocateLocal(kWasmS128);
// Shift using an immediate, and shift using a value loaded from memory. // Shift using an immediate, and shift using a value loaded from memory.
BUILD( BUILD_V(
r, WASM_SET_LOCAL(simd, WASM_SIMD_I64x2_SPLAT(WASM_GET_LOCAL(value))), r, WASM_SET_LOCAL(simd, WASM_SIMD_I64x2_SPLAT(WASM_GET_LOCAL(value))),
WASM_SET_GLOBAL(0, WASM_SIMD_SHIFT_OP(opcode, WASM_GET_LOCAL(simd), WASM_SET_GLOBAL(0, WASM_SIMD_SHIFT_OP(opcode, WASM_GET_LOCAL(simd),
WASM_I32V(shift))), WASM_I32V(shift))),
...@@ -1068,7 +1074,8 @@ void RunI64x2BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -1068,7 +1074,8 @@ void RunI64x2BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
byte value1 = 0, value2 = 1; byte value1 = 0, value2 = 1;
byte temp1 = r.AllocateLocal(kWasmS128); byte temp1 = r.AllocateLocal(kWasmS128);
byte temp2 = r.AllocateLocal(kWasmS128); byte temp2 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I64x2_SPLAT(WASM_GET_LOCAL(value1))), BUILD_V(r,
WASM_SET_LOCAL(temp1, WASM_SIMD_I64x2_SPLAT(WASM_GET_LOCAL(value1))),
WASM_SET_LOCAL(temp2, WASM_SIMD_I64x2_SPLAT(WASM_GET_LOCAL(value2))), WASM_SET_LOCAL(temp2, WASM_SIMD_I64x2_SPLAT(WASM_GET_LOCAL(value2))),
WASM_SET_GLOBAL(0, WASM_SIMD_BINOP(opcode, WASM_GET_LOCAL(temp1), WASM_SET_GLOBAL(0, WASM_SIMD_BINOP(opcode, WASM_GET_LOCAL(temp1),
WASM_GET_LOCAL(temp2))), WASM_GET_LOCAL(temp2))),
...@@ -1144,7 +1151,7 @@ WASM_SIMD_TEST_NO_LOWERING(F64x2Splat) { ...@@ -1144,7 +1151,7 @@ WASM_SIMD_TEST_NO_LOWERING(F64x2Splat) {
// Set up a global to hold output vector. // Set up a global to hold output vector.
double* g = r.builder().AddGlobal<double>(kWasmS128); double* g = r.builder().AddGlobal<double>(kWasmS128);
byte param1 = 0; byte param1 = 0;
BUILD(r, WASM_SET_GLOBAL(0, WASM_SIMD_F64x2_SPLAT(WASM_GET_LOCAL(param1))), BUILD_V(r, WASM_SET_GLOBAL(0, WASM_SIMD_F64x2_SPLAT(WASM_GET_LOCAL(param1))),
WASM_ONE); WASM_ONE);
FOR_FLOAT64_INPUTS(x) { FOR_FLOAT64_INPUTS(x) {
...@@ -1166,7 +1173,7 @@ WASM_SIMD_TEST_NO_LOWERING(F64x2ExtractLane) { ...@@ -1166,7 +1173,7 @@ WASM_SIMD_TEST_NO_LOWERING(F64x2ExtractLane) {
byte param1 = 0; byte param1 = 0;
byte temp1 = r.AllocateLocal(kWasmF64); byte temp1 = r.AllocateLocal(kWasmF64);
byte temp2 = r.AllocateLocal(kWasmS128); byte temp2 = r.AllocateLocal(kWasmS128);
BUILD(r, BUILD_V(r,
WASM_SET_LOCAL(temp1, WASM_SET_LOCAL(temp1,
WASM_SIMD_F64x2_EXTRACT_LANE( WASM_SIMD_F64x2_EXTRACT_LANE(
0, WASM_SIMD_F64x2_SPLAT(WASM_GET_LOCAL(param1)))), 0, WASM_SIMD_F64x2_SPLAT(WASM_GET_LOCAL(param1)))),
...@@ -1190,7 +1197,7 @@ WASM_SIMD_TEST_NO_LOWERING(F64x2ReplaceLane) { ...@@ -1190,7 +1197,7 @@ WASM_SIMD_TEST_NO_LOWERING(F64x2ReplaceLane) {
double* g1 = r.builder().AddGlobal<double>(kWasmS128); double* g1 = r.builder().AddGlobal<double>(kWasmS128);
// Build function to replace each lane with its (FP) index. // Build function to replace each lane with its (FP) index.
byte temp1 = r.AllocateLocal(kWasmS128); byte temp1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_F64x2_SPLAT(WASM_F64(1e100))), BUILD_V(r, WASM_SET_LOCAL(temp1, WASM_SIMD_F64x2_SPLAT(WASM_F64(1e100))),
// Replace lane 0. // Replace lane 0.
WASM_SET_GLOBAL(0, WASM_SIMD_F64x2_REPLACE_LANE( WASM_SET_GLOBAL(0, WASM_SIMD_F64x2_REPLACE_LANE(
0, WASM_GET_LOCAL(temp1), WASM_F64(0.0f))), 0, WASM_GET_LOCAL(temp1), WASM_F64(0.0f))),
...@@ -1209,7 +1216,7 @@ WASM_SIMD_TEST_NO_LOWERING(F64x2ReplaceLane) { ...@@ -1209,7 +1216,7 @@ WASM_SIMD_TEST_NO_LOWERING(F64x2ReplaceLane) {
#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_S390X #if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_S390X
WASM_SIMD_TEST_NO_LOWERING(F64x2ExtractLaneWithI64x2) { WASM_SIMD_TEST_NO_LOWERING(F64x2ExtractLaneWithI64x2) {
WasmRunner<int64_t> r(execution_tier, lower_simd); WasmRunner<int64_t> r(execution_tier, lower_simd);
BUILD(r, WASM_IF_ELSE_L( BUILD_V(r, WASM_IF_ELSE_L(
WASM_F64_EQ(WASM_SIMD_F64x2_EXTRACT_LANE( WASM_F64_EQ(WASM_SIMD_F64x2_EXTRACT_LANE(
0, WASM_SIMD_I64x2_SPLAT(WASM_I64V(1e15))), 0, WASM_SIMD_I64x2_SPLAT(WASM_I64V(1e15))),
WASM_F64_REINTERPRET_I64(WASM_I64V(1e15))), WASM_F64_REINTERPRET_I64(WASM_I64V(1e15))),
...@@ -1219,7 +1226,7 @@ WASM_SIMD_TEST_NO_LOWERING(F64x2ExtractLaneWithI64x2) { ...@@ -1219,7 +1226,7 @@ WASM_SIMD_TEST_NO_LOWERING(F64x2ExtractLaneWithI64x2) {
WASM_SIMD_TEST_NO_LOWERING(I64x2ExtractWithF64x2) { WASM_SIMD_TEST_NO_LOWERING(I64x2ExtractWithF64x2) {
WasmRunner<int64_t> r(execution_tier, lower_simd); WasmRunner<int64_t> r(execution_tier, lower_simd);
BUILD(r, WASM_IF_ELSE_L( BUILD_V(r, WASM_IF_ELSE_L(
WASM_I64_EQ(WASM_SIMD_I64x2_EXTRACT_LANE( WASM_I64_EQ(WASM_SIMD_I64x2_EXTRACT_LANE(
0, WASM_SIMD_F64x2_SPLAT(WASM_F64(1e15))), 0, WASM_SIMD_F64x2_SPLAT(WASM_F64(1e15))),
WASM_I64_REINTERPRET_F64(WASM_F64(1e15))), WASM_I64_REINTERPRET_F64(WASM_F64(1e15))),
...@@ -1310,7 +1317,8 @@ void RunF64x2UnOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -1310,7 +1317,8 @@ void RunF64x2UnOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
// Build fn to splat test value, perform unop, and write the result. // Build fn to splat test value, perform unop, and write the result.
byte value = 0; byte value = 0;
byte temp1 = r.AllocateLocal(kWasmS128); byte temp1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_F64x2_SPLAT(WASM_GET_LOCAL(value))), BUILD_V(r,
WASM_SET_LOCAL(temp1, WASM_SIMD_F64x2_SPLAT(WASM_GET_LOCAL(value))),
WASM_SET_GLOBAL(0, WASM_SIMD_UNOP(opcode, WASM_GET_LOCAL(temp1))), WASM_SET_GLOBAL(0, WASM_SIMD_UNOP(opcode, WASM_GET_LOCAL(temp1))),
WASM_ONE); WASM_ONE);
...@@ -1363,7 +1371,8 @@ void RunF64x2BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -1363,7 +1371,8 @@ void RunF64x2BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
byte value1 = 0, value2 = 1; byte value1 = 0, value2 = 1;
byte temp1 = r.AllocateLocal(kWasmS128); byte temp1 = r.AllocateLocal(kWasmS128);
byte temp2 = r.AllocateLocal(kWasmS128); byte temp2 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_F64x2_SPLAT(WASM_GET_LOCAL(value1))), BUILD_V(r,
WASM_SET_LOCAL(temp1, WASM_SIMD_F64x2_SPLAT(WASM_GET_LOCAL(value1))),
WASM_SET_LOCAL(temp2, WASM_SIMD_F64x2_SPLAT(WASM_GET_LOCAL(value2))), WASM_SET_LOCAL(temp2, WASM_SIMD_F64x2_SPLAT(WASM_GET_LOCAL(value2))),
WASM_SET_GLOBAL(0, WASM_SIMD_BINOP(opcode, WASM_GET_LOCAL(temp1), WASM_SET_GLOBAL(0, WASM_SIMD_BINOP(opcode, WASM_GET_LOCAL(temp1),
WASM_GET_LOCAL(temp2))), WASM_GET_LOCAL(temp2))),
...@@ -1428,7 +1437,8 @@ void RunF64x2CompareOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -1428,7 +1437,8 @@ void RunF64x2CompareOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
byte temp2 = r.AllocateLocal(kWasmS128); byte temp2 = r.AllocateLocal(kWasmS128);
// Make the lanes of each temp compare differently: // Make the lanes of each temp compare differently:
// temp1 = y, x and temp2 = y, y. // temp1 = y, x and temp2 = y, y.
BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_F64x2_SPLAT(WASM_GET_LOCAL(value1))), BUILD_V(r,
WASM_SET_LOCAL(temp1, WASM_SIMD_F64x2_SPLAT(WASM_GET_LOCAL(value1))),
WASM_SET_LOCAL(temp1, WASM_SET_LOCAL(temp1,
WASM_SIMD_F64x2_REPLACE_LANE(1, WASM_GET_LOCAL(temp1), WASM_SIMD_F64x2_REPLACE_LANE(1, WASM_GET_LOCAL(temp1),
WASM_GET_LOCAL(value2))), WASM_GET_LOCAL(value2))),
...@@ -1517,7 +1527,8 @@ WASM_SIMD_TEST_NO_LOWERING(F64x2Qfma) { ...@@ -1517,7 +1527,8 @@ WASM_SIMD_TEST_NO_LOWERING(F64x2Qfma) {
double* g = r.builder().AddGlobal<double>(kWasmS128); double* g = r.builder().AddGlobal<double>(kWasmS128);
// Build fn to splat test values, perform compare op, and write the result. // Build fn to splat test values, perform compare op, and write the result.
byte value1 = 0, value2 = 1, value3 = 2; byte value1 = 0, value2 = 1, value3 = 2;
BUILD(r, BUILD_V(
r,
WASM_SET_GLOBAL(0, WASM_SIMD_F64x2_QFMA( WASM_SET_GLOBAL(0, WASM_SIMD_F64x2_QFMA(
WASM_SIMD_F64x2_SPLAT(WASM_GET_LOCAL(value1)), WASM_SIMD_F64x2_SPLAT(WASM_GET_LOCAL(value1)),
WASM_SIMD_F64x2_SPLAT(WASM_GET_LOCAL(value2)), WASM_SIMD_F64x2_SPLAT(WASM_GET_LOCAL(value2)),
...@@ -1542,7 +1553,8 @@ WASM_SIMD_TEST_NO_LOWERING(F64x2Qfms) { ...@@ -1542,7 +1553,8 @@ WASM_SIMD_TEST_NO_LOWERING(F64x2Qfms) {
double* g = r.builder().AddGlobal<double>(kWasmS128); double* g = r.builder().AddGlobal<double>(kWasmS128);
// Build fn to splat test values, perform compare op, and write the result. // Build fn to splat test values, perform compare op, and write the result.
byte value1 = 0, value2 = 1, value3 = 2; byte value1 = 0, value2 = 1, value3 = 2;
BUILD(r, BUILD_V(
r,
WASM_SET_GLOBAL(0, WASM_SIMD_F64x2_QFMS( WASM_SET_GLOBAL(0, WASM_SIMD_F64x2_QFMS(
WASM_SIMD_F64x2_SPLAT(WASM_GET_LOCAL(value1)), WASM_SIMD_F64x2_SPLAT(WASM_GET_LOCAL(value1)),
WASM_SIMD_F64x2_SPLAT(WASM_GET_LOCAL(value2)), WASM_SIMD_F64x2_SPLAT(WASM_GET_LOCAL(value2)),
...@@ -1566,7 +1578,7 @@ WASM_SIMD_TEST(I32x4Splat) { ...@@ -1566,7 +1578,7 @@ WASM_SIMD_TEST(I32x4Splat) {
// Set up a global to hold output vector. // Set up a global to hold output vector.
int32_t* g = r.builder().AddGlobal<int32_t>(kWasmS128); int32_t* g = r.builder().AddGlobal<int32_t>(kWasmS128);
byte param1 = 0; byte param1 = 0;
BUILD(r, WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(param1))), BUILD_V(r, WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(param1))),
WASM_ONE); WASM_ONE);
FOR_INT32_INPUTS(x) { FOR_INT32_INPUTS(x) {
...@@ -1585,7 +1597,7 @@ WASM_SIMD_TEST(I32x4ReplaceLane) { ...@@ -1585,7 +1597,7 @@ WASM_SIMD_TEST(I32x4ReplaceLane) {
int32_t* g = r.builder().AddGlobal<int32_t>(kWasmS128); int32_t* g = r.builder().AddGlobal<int32_t>(kWasmS128);
// Build function to replace each lane with its index. // Build function to replace each lane with its index.
byte temp1 = r.AllocateLocal(kWasmS128); byte temp1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I32x4_SPLAT(WASM_I32V(-1))), BUILD_V(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I32x4_SPLAT(WASM_I32V(-1))),
WASM_SET_LOCAL(temp1, WASM_SIMD_I32x4_REPLACE_LANE( WASM_SET_LOCAL(temp1, WASM_SIMD_I32x4_REPLACE_LANE(
0, WASM_GET_LOCAL(temp1), WASM_I32V(0))), 0, WASM_GET_LOCAL(temp1), WASM_I32V(0))),
WASM_SET_LOCAL(temp1, WASM_SIMD_I32x4_REPLACE_LANE( WASM_SET_LOCAL(temp1, WASM_SIMD_I32x4_REPLACE_LANE(
...@@ -1607,7 +1619,7 @@ WASM_SIMD_TEST(I16x8Splat) { ...@@ -1607,7 +1619,7 @@ WASM_SIMD_TEST(I16x8Splat) {
// Set up a global to hold output vector. // Set up a global to hold output vector.
int16_t* g = r.builder().AddGlobal<int16_t>(kWasmS128); int16_t* g = r.builder().AddGlobal<int16_t>(kWasmS128);
byte param1 = 0; byte param1 = 0;
BUILD(r, WASM_SET_GLOBAL(0, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(param1))), BUILD_V(r, WASM_SET_GLOBAL(0, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(param1))),
WASM_ONE); WASM_ONE);
FOR_INT16_INPUTS(x) { FOR_INT16_INPUTS(x) {
...@@ -1636,7 +1648,7 @@ WASM_SIMD_TEST(I16x8ReplaceLane) { ...@@ -1636,7 +1648,7 @@ WASM_SIMD_TEST(I16x8ReplaceLane) {
int16_t* g = r.builder().AddGlobal<int16_t>(kWasmS128); int16_t* g = r.builder().AddGlobal<int16_t>(kWasmS128);
// Build function to replace each lane with its index. // Build function to replace each lane with its index.
byte temp1 = r.AllocateLocal(kWasmS128); byte temp1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I16x8_SPLAT(WASM_I32V(-1))), BUILD_V(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I16x8_SPLAT(WASM_I32V(-1))),
WASM_SET_LOCAL(temp1, WASM_SIMD_I16x8_REPLACE_LANE( WASM_SET_LOCAL(temp1, WASM_SIMD_I16x8_REPLACE_LANE(
0, WASM_GET_LOCAL(temp1), WASM_I32V(0))), 0, WASM_GET_LOCAL(temp1), WASM_I32V(0))),
WASM_SET_LOCAL(temp1, WASM_SIMD_I16x8_REPLACE_LANE( WASM_SET_LOCAL(temp1, WASM_SIMD_I16x8_REPLACE_LANE(
...@@ -1668,7 +1680,7 @@ WASM_SIMD_TEST_NO_LOWERING(I8x16BitMask) { ...@@ -1668,7 +1680,7 @@ WASM_SIMD_TEST_NO_LOWERING(I8x16BitMask) {
WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd); WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd);
byte value1 = r.AllocateLocal(kWasmS128); byte value1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(value1, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(0))), BUILD_V(r, WASM_SET_LOCAL(value1, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(0))),
WASM_SET_LOCAL(value1, WASM_SIMD_I8x16_REPLACE_LANE( WASM_SET_LOCAL(value1, WASM_SIMD_I8x16_REPLACE_LANE(
0, WASM_GET_LOCAL(value1), WASM_I32V(0))), 0, WASM_GET_LOCAL(value1), WASM_I32V(0))),
WASM_SET_LOCAL(value1, WASM_SIMD_I8x16_REPLACE_LANE( WASM_SET_LOCAL(value1, WASM_SIMD_I8x16_REPLACE_LANE(
...@@ -1688,7 +1700,7 @@ WASM_SIMD_TEST_NO_LOWERING(I16x8BitMask) { ...@@ -1688,7 +1700,7 @@ WASM_SIMD_TEST_NO_LOWERING(I16x8BitMask) {
WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd); WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd);
byte value1 = r.AllocateLocal(kWasmS128); byte value1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(value1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(0))), BUILD_V(r, WASM_SET_LOCAL(value1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(0))),
WASM_SET_LOCAL(value1, WASM_SIMD_I16x8_REPLACE_LANE( WASM_SET_LOCAL(value1, WASM_SIMD_I16x8_REPLACE_LANE(
0, WASM_GET_LOCAL(value1), WASM_I32V(0))), 0, WASM_GET_LOCAL(value1), WASM_I32V(0))),
WASM_SET_LOCAL(value1, WASM_SIMD_I16x8_REPLACE_LANE( WASM_SET_LOCAL(value1, WASM_SIMD_I16x8_REPLACE_LANE(
...@@ -1708,7 +1720,7 @@ WASM_SIMD_TEST_NO_LOWERING(I32x4BitMask) { ...@@ -1708,7 +1720,7 @@ WASM_SIMD_TEST_NO_LOWERING(I32x4BitMask) {
WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd); WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd);
byte value1 = r.AllocateLocal(kWasmS128); byte value1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(value1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(0))), BUILD_V(r, WASM_SET_LOCAL(value1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(0))),
WASM_SET_LOCAL(value1, WASM_SIMD_I32x4_REPLACE_LANE( WASM_SET_LOCAL(value1, WASM_SIMD_I32x4_REPLACE_LANE(
0, WASM_GET_LOCAL(value1), WASM_I32V(0))), 0, WASM_GET_LOCAL(value1), WASM_I32V(0))),
WASM_SET_LOCAL(value1, WASM_SIMD_I32x4_REPLACE_LANE( WASM_SET_LOCAL(value1, WASM_SIMD_I32x4_REPLACE_LANE(
...@@ -1730,7 +1742,7 @@ WASM_SIMD_TEST(I8x16Splat) { ...@@ -1730,7 +1742,7 @@ WASM_SIMD_TEST(I8x16Splat) {
// Set up a global to hold output vector. // Set up a global to hold output vector.
int8_t* g = r.builder().AddGlobal<int8_t>(kWasmS128); int8_t* g = r.builder().AddGlobal<int8_t>(kWasmS128);
byte param1 = 0; byte param1 = 0;
BUILD(r, WASM_SET_GLOBAL(0, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(param1))), BUILD_V(r, WASM_SET_GLOBAL(0, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(param1))),
WASM_ONE); WASM_ONE);
FOR_INT8_INPUTS(x) { FOR_INT8_INPUTS(x) {
...@@ -1759,7 +1771,7 @@ WASM_SIMD_TEST(I8x16ReplaceLane) { ...@@ -1759,7 +1771,7 @@ WASM_SIMD_TEST(I8x16ReplaceLane) {
int8_t* g = r.builder().AddGlobal<int8_t>(kWasmS128); int8_t* g = r.builder().AddGlobal<int8_t>(kWasmS128);
// Build function to replace each lane with its index. // Build function to replace each lane with its index.
byte temp1 = r.AllocateLocal(kWasmS128); byte temp1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I8x16_SPLAT(WASM_I32V(-1))), BUILD_V(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I8x16_SPLAT(WASM_I32V(-1))),
WASM_SET_LOCAL(temp1, WASM_SIMD_I8x16_REPLACE_LANE( WASM_SET_LOCAL(temp1, WASM_SIMD_I8x16_REPLACE_LANE(
0, WASM_GET_LOCAL(temp1), WASM_I32V(0))), 0, WASM_GET_LOCAL(temp1), WASM_I32V(0))),
WASM_SET_LOCAL(temp1, WASM_SIMD_I8x16_REPLACE_LANE( WASM_SET_LOCAL(temp1, WASM_SIMD_I8x16_REPLACE_LANE(
...@@ -1823,7 +1835,8 @@ WASM_SIMD_TEST(I32x4ConvertF32x4) { ...@@ -1823,7 +1835,8 @@ WASM_SIMD_TEST(I32x4ConvertF32x4) {
// Build fn to splat test value, perform conversions, and write the results. // Build fn to splat test value, perform conversions, and write the results.
byte value = 0; byte value = 0;
byte temp1 = r.AllocateLocal(kWasmS128); byte temp1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(value))), BUILD_V(
r, WASM_SET_LOCAL(temp1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(value))),
WASM_SET_GLOBAL( WASM_SET_GLOBAL(
0, WASM_SIMD_UNOP(kExprI32x4SConvertF32x4, WASM_GET_LOCAL(temp1))), 0, WASM_SIMD_UNOP(kExprI32x4SConvertF32x4, WASM_GET_LOCAL(temp1))),
WASM_SET_GLOBAL( WASM_SET_GLOBAL(
...@@ -1853,15 +1866,16 @@ WASM_SIMD_TEST(I32x4ConvertI16x8) { ...@@ -1853,15 +1866,16 @@ WASM_SIMD_TEST(I32x4ConvertI16x8) {
// Build fn to splat test value, perform conversions, and write the results. // Build fn to splat test value, perform conversions, and write the results.
byte value = 0; byte value = 0;
byte temp1 = r.AllocateLocal(kWasmS128); byte temp1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(value))), BUILD_V(
r, WASM_SET_LOCAL(temp1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(value))),
WASM_SET_GLOBAL(0, WASM_SIMD_UNOP(kExprI32x4SConvertI16x8High, WASM_SET_GLOBAL(0, WASM_SIMD_UNOP(kExprI32x4SConvertI16x8High,
WASM_GET_LOCAL(temp1))), WASM_GET_LOCAL(temp1))),
WASM_SET_GLOBAL(1, WASM_SIMD_UNOP(kExprI32x4SConvertI16x8Low, WASM_SET_GLOBAL(
WASM_GET_LOCAL(temp1))), 1, WASM_SIMD_UNOP(kExprI32x4SConvertI16x8Low, WASM_GET_LOCAL(temp1))),
WASM_SET_GLOBAL(2, WASM_SIMD_UNOP(kExprI32x4UConvertI16x8High, WASM_SET_GLOBAL(2, WASM_SIMD_UNOP(kExprI32x4UConvertI16x8High,
WASM_GET_LOCAL(temp1))), WASM_GET_LOCAL(temp1))),
WASM_SET_GLOBAL(3, WASM_SIMD_UNOP(kExprI32x4UConvertI16x8Low, WASM_SET_GLOBAL(
WASM_GET_LOCAL(temp1))), 3, WASM_SIMD_UNOP(kExprI32x4UConvertI16x8Low, WASM_GET_LOCAL(temp1))),
WASM_ONE); WASM_ONE);
FOR_INT16_INPUTS(x) { FOR_INT16_INPUTS(x) {
...@@ -1885,7 +1899,8 @@ void RunI32x4UnOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -1885,7 +1899,8 @@ void RunI32x4UnOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
// Build fn to splat test value, perform unop, and write the result. // Build fn to splat test value, perform unop, and write the result.
byte value = 0; byte value = 0;
byte temp1 = r.AllocateLocal(kWasmS128); byte temp1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(value))), BUILD_V(r,
WASM_SET_LOCAL(temp1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(value))),
WASM_SET_GLOBAL(0, WASM_SIMD_UNOP(opcode, WASM_GET_LOCAL(temp1))), WASM_SET_GLOBAL(0, WASM_SIMD_UNOP(opcode, WASM_GET_LOCAL(temp1))),
WASM_ONE); WASM_ONE);
...@@ -1920,7 +1935,8 @@ void RunI32x4BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -1920,7 +1935,8 @@ void RunI32x4BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
byte value1 = 0, value2 = 1; byte value1 = 0, value2 = 1;
byte temp1 = r.AllocateLocal(kWasmS128); byte temp1 = r.AllocateLocal(kWasmS128);
byte temp2 = r.AllocateLocal(kWasmS128); byte temp2 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(value1))), BUILD_V(r,
WASM_SET_LOCAL(temp1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(value1))),
WASM_SET_LOCAL(temp2, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(value2))), WASM_SET_LOCAL(temp2, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(value2))),
WASM_SET_GLOBAL(0, WASM_SIMD_BINOP(opcode, WASM_GET_LOCAL(temp1), WASM_SET_GLOBAL(0, WASM_SIMD_BINOP(opcode, WASM_GET_LOCAL(temp1),
WASM_GET_LOCAL(temp2))), WASM_GET_LOCAL(temp2))),
...@@ -2040,7 +2056,7 @@ void RunI32x4ShiftOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -2040,7 +2056,7 @@ void RunI32x4ShiftOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
byte value = 0; byte value = 0;
byte simd = r.AllocateLocal(kWasmS128); byte simd = r.AllocateLocal(kWasmS128);
// Shift using an immediate, and shift using a value loaded from memory. // Shift using an immediate, and shift using a value loaded from memory.
BUILD( BUILD_V(
r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(value))), r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(value))),
WASM_SET_GLOBAL(0, WASM_SIMD_SHIFT_OP(opcode, WASM_GET_LOCAL(simd), WASM_SET_GLOBAL(0, WASM_SIMD_SHIFT_OP(opcode, WASM_GET_LOCAL(simd),
WASM_I32V(shift))), WASM_I32V(shift))),
...@@ -2087,15 +2103,16 @@ WASM_SIMD_TEST(I16x8ConvertI8x16) { ...@@ -2087,15 +2103,16 @@ WASM_SIMD_TEST(I16x8ConvertI8x16) {
// Build fn to splat test value, perform conversions, and write the results. // Build fn to splat test value, perform conversions, and write the results.
byte value = 0; byte value = 0;
byte temp1 = r.AllocateLocal(kWasmS128); byte temp1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(value))), BUILD_V(
r, WASM_SET_LOCAL(temp1, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(value))),
WASM_SET_GLOBAL(0, WASM_SIMD_UNOP(kExprI16x8SConvertI8x16High, WASM_SET_GLOBAL(0, WASM_SIMD_UNOP(kExprI16x8SConvertI8x16High,
WASM_GET_LOCAL(temp1))), WASM_GET_LOCAL(temp1))),
WASM_SET_GLOBAL(1, WASM_SIMD_UNOP(kExprI16x8SConvertI8x16Low, WASM_SET_GLOBAL(
WASM_GET_LOCAL(temp1))), 1, WASM_SIMD_UNOP(kExprI16x8SConvertI8x16Low, WASM_GET_LOCAL(temp1))),
WASM_SET_GLOBAL(2, WASM_SIMD_UNOP(kExprI16x8UConvertI8x16High, WASM_SET_GLOBAL(2, WASM_SIMD_UNOP(kExprI16x8UConvertI8x16High,
WASM_GET_LOCAL(temp1))), WASM_GET_LOCAL(temp1))),
WASM_SET_GLOBAL(3, WASM_SIMD_UNOP(kExprI16x8UConvertI8x16Low, WASM_SET_GLOBAL(
WASM_GET_LOCAL(temp1))), 3, WASM_SIMD_UNOP(kExprI16x8UConvertI8x16Low, WASM_GET_LOCAL(temp1))),
WASM_ONE); WASM_ONE);
FOR_INT8_INPUTS(x) { FOR_INT8_INPUTS(x) {
...@@ -2120,7 +2137,8 @@ WASM_SIMD_TEST(I16x8ConvertI32x4) { ...@@ -2120,7 +2137,8 @@ WASM_SIMD_TEST(I16x8ConvertI32x4) {
// Build fn to splat test value, perform conversions, and write the results. // Build fn to splat test value, perform conversions, and write the results.
byte value = 0; byte value = 0;
byte temp1 = r.AllocateLocal(kWasmS128); byte temp1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(value))), BUILD_V(r,
WASM_SET_LOCAL(temp1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(value))),
WASM_SET_GLOBAL( WASM_SET_GLOBAL(
0, WASM_SIMD_BINOP(kExprI16x8SConvertI32x4, WASM_GET_LOCAL(temp1), 0, WASM_SIMD_BINOP(kExprI16x8SConvertI32x4, WASM_GET_LOCAL(temp1),
WASM_GET_LOCAL(temp1))), WASM_GET_LOCAL(temp1))),
...@@ -2148,7 +2166,8 @@ void RunI16x8UnOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -2148,7 +2166,8 @@ void RunI16x8UnOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
// Build fn to splat test value, perform unop, and write the result. // Build fn to splat test value, perform unop, and write the result.
byte value = 0; byte value = 0;
byte temp1 = r.AllocateLocal(kWasmS128); byte temp1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(value))), BUILD_V(r,
WASM_SET_LOCAL(temp1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(value))),
WASM_SET_GLOBAL(0, WASM_SIMD_UNOP(opcode, WASM_GET_LOCAL(temp1))), WASM_SET_GLOBAL(0, WASM_SIMD_UNOP(opcode, WASM_GET_LOCAL(temp1))),
WASM_ONE); WASM_ONE);
...@@ -2180,7 +2199,8 @@ void RunI16x8BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -2180,7 +2199,8 @@ void RunI16x8BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
byte value1 = 0, value2 = 1; byte value1 = 0, value2 = 1;
byte temp1 = r.AllocateLocal(kWasmS128); byte temp1 = r.AllocateLocal(kWasmS128);
byte temp2 = r.AllocateLocal(kWasmS128); byte temp2 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(value1))), BUILD_V(r,
WASM_SET_LOCAL(temp1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(value1))),
WASM_SET_LOCAL(temp2, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(value2))), WASM_SET_LOCAL(temp2, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(value2))),
WASM_SET_GLOBAL(0, WASM_SIMD_BINOP(opcode, WASM_GET_LOCAL(temp1), WASM_SET_GLOBAL(0, WASM_SIMD_BINOP(opcode, WASM_GET_LOCAL(temp1),
WASM_GET_LOCAL(temp2))), WASM_GET_LOCAL(temp2))),
...@@ -2309,7 +2329,7 @@ void RunI16x8ShiftOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -2309,7 +2329,7 @@ void RunI16x8ShiftOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
byte value = 0; byte value = 0;
byte simd = r.AllocateLocal(kWasmS128); byte simd = r.AllocateLocal(kWasmS128);
// Shift using an immediate, and shift using a value loaded from memory. // Shift using an immediate, and shift using a value loaded from memory.
BUILD( BUILD_V(
r, WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(value))), r, WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(value))),
WASM_SET_GLOBAL(0, WASM_SIMD_SHIFT_OP(opcode, WASM_GET_LOCAL(simd), WASM_SET_GLOBAL(0, WASM_SIMD_SHIFT_OP(opcode, WASM_GET_LOCAL(simd),
WASM_I32V(shift))), WASM_I32V(shift))),
...@@ -2353,7 +2373,8 @@ void RunI8x16UnOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -2353,7 +2373,8 @@ void RunI8x16UnOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
// Build fn to splat test value, perform unop, and write the result. // Build fn to splat test value, perform unop, and write the result.
byte value = 0; byte value = 0;
byte temp1 = r.AllocateLocal(kWasmS128); byte temp1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(value))), BUILD_V(r,
WASM_SET_LOCAL(temp1, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(value))),
WASM_SET_GLOBAL(0, WASM_SIMD_UNOP(opcode, WASM_GET_LOCAL(temp1))), WASM_SET_GLOBAL(0, WASM_SIMD_UNOP(opcode, WASM_GET_LOCAL(temp1))),
WASM_ONE); WASM_ONE);
...@@ -2384,7 +2405,8 @@ WASM_SIMD_TEST(I8x16ConvertI16x8) { ...@@ -2384,7 +2405,8 @@ WASM_SIMD_TEST(I8x16ConvertI16x8) {
// Build fn to splat test value, perform conversions, and write the results. // Build fn to splat test value, perform conversions, and write the results.
byte value = 0; byte value = 0;
byte temp1 = r.AllocateLocal(kWasmS128); byte temp1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(value))), BUILD_V(r,
WASM_SET_LOCAL(temp1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(value))),
WASM_SET_GLOBAL( WASM_SET_GLOBAL(
0, WASM_SIMD_BINOP(kExprI8x16SConvertI16x8, WASM_GET_LOCAL(temp1), 0, WASM_SIMD_BINOP(kExprI8x16SConvertI16x8, WASM_GET_LOCAL(temp1),
WASM_GET_LOCAL(temp1))), WASM_GET_LOCAL(temp1))),
...@@ -2414,7 +2436,8 @@ void RunI8x16BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -2414,7 +2436,8 @@ void RunI8x16BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
byte value1 = 0, value2 = 1; byte value1 = 0, value2 = 1;
byte temp1 = r.AllocateLocal(kWasmS128); byte temp1 = r.AllocateLocal(kWasmS128);
byte temp2 = r.AllocateLocal(kWasmS128); byte temp2 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(value1))), BUILD_V(r,
WASM_SET_LOCAL(temp1, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(value1))),
WASM_SET_LOCAL(temp2, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(value2))), WASM_SET_LOCAL(temp2, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(value2))),
WASM_SET_GLOBAL(0, WASM_SIMD_BINOP(opcode, WASM_GET_LOCAL(temp1), WASM_SET_GLOBAL(0, WASM_SIMD_BINOP(opcode, WASM_GET_LOCAL(temp1),
WASM_GET_LOCAL(temp2))), WASM_GET_LOCAL(temp2))),
...@@ -2543,7 +2566,7 @@ void RunI8x16ShiftOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -2543,7 +2566,7 @@ void RunI8x16ShiftOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
byte value = 0; byte value = 0;
byte simd = r.AllocateLocal(kWasmS128); byte simd = r.AllocateLocal(kWasmS128);
// Shift using an immediate, and shift using a value loaded from memory. // Shift using an immediate, and shift using a value loaded from memory.
BUILD( BUILD_V(
r, WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(value))), r, WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(value))),
WASM_SET_GLOBAL(0, WASM_SIMD_SHIFT_OP(opcode, WASM_GET_LOCAL(simd), WASM_SET_GLOBAL(0, WASM_SIMD_SHIFT_OP(opcode, WASM_GET_LOCAL(simd),
WASM_I32V(shift))), WASM_I32V(shift))),
...@@ -2591,7 +2614,7 @@ WASM_SIMD_TEST(I8x16ShrU) { ...@@ -2591,7 +2614,7 @@ WASM_SIMD_TEST(I8x16ShrU) {
byte src2 = r.AllocateLocal(kWasmS128); \ byte src2 = r.AllocateLocal(kWasmS128); \
byte zero = r.AllocateLocal(kWasmS128); \ byte zero = r.AllocateLocal(kWasmS128); \
byte mask = r.AllocateLocal(kWasmS128); \ byte mask = r.AllocateLocal(kWasmS128); \
BUILD(r, \ BUILD_V(r, \
WASM_SET_LOCAL(src1, \ WASM_SET_LOCAL(src1, \
WASM_SIMD_I##format##_SPLAT(WASM_GET_LOCAL(val1))), \ WASM_SIMD_I##format##_SPLAT(WASM_GET_LOCAL(val1))), \
WASM_SET_LOCAL(src2, \ WASM_SET_LOCAL(src2, \
...@@ -2632,7 +2655,8 @@ WASM_SIMD_SELECT_TEST(8x16) ...@@ -2632,7 +2655,8 @@ WASM_SIMD_SELECT_TEST(8x16)
byte src2 = r.AllocateLocal(kWasmS128); \ byte src2 = r.AllocateLocal(kWasmS128); \
byte zero = r.AllocateLocal(kWasmS128); \ byte zero = r.AllocateLocal(kWasmS128); \
byte mask = r.AllocateLocal(kWasmS128); \ byte mask = r.AllocateLocal(kWasmS128); \
BUILD(r, \ BUILD_V( \
r, \
WASM_SET_LOCAL(src1, \ WASM_SET_LOCAL(src1, \
WASM_SIMD_I##format##_SPLAT(WASM_GET_LOCAL(val1))), \ WASM_SIMD_I##format##_SPLAT(WASM_GET_LOCAL(val1))), \
WASM_SET_LOCAL(src2, \ WASM_SET_LOCAL(src2, \
...@@ -2672,13 +2696,13 @@ void RunBinaryLaneOpTest( ...@@ -2672,13 +2696,13 @@ void RunBinaryLaneOpTest(
WriteLittleEndianValue<T>(&src1[i], kElems + i); WriteLittleEndianValue<T>(&src1[i], kElems + i);
} }
if (simd_op == kExprS8x16Shuffle) { if (simd_op == kExprS8x16Shuffle) {
BUILD(r, BUILD_V(r,
WASM_SET_GLOBAL(0, WASM_SIMD_S8x16_SHUFFLE_OP(simd_op, expected, WASM_SET_GLOBAL(0, WASM_SIMD_S8x16_SHUFFLE_OP(simd_op, expected,
WASM_GET_GLOBAL(0), WASM_GET_GLOBAL(0),
WASM_GET_GLOBAL(1))), WASM_GET_GLOBAL(1))),
WASM_ONE); WASM_ONE);
} else { } else {
BUILD(r, BUILD_V(r,
WASM_SET_GLOBAL(0, WASM_SIMD_BINOP(simd_op, WASM_GET_GLOBAL(0), WASM_SET_GLOBAL(0, WASM_SIMD_BINOP(simd_op, WASM_GET_GLOBAL(0),
WASM_GET_GLOBAL(1))), WASM_GET_GLOBAL(1))),
WASM_ONE); WASM_ONE);
...@@ -2914,7 +2938,7 @@ WASM_SIMD_TEST(S8x16Swizzle) { ...@@ -2914,7 +2938,7 @@ WASM_SIMD_TEST(S8x16Swizzle) {
uint8_t* dst = r.builder().AddGlobal<uint8_t>(kWasmS128); uint8_t* dst = r.builder().AddGlobal<uint8_t>(kWasmS128);
uint8_t* src0 = r.builder().AddGlobal<uint8_t>(kWasmS128); uint8_t* src0 = r.builder().AddGlobal<uint8_t>(kWasmS128);
uint8_t* src1 = r.builder().AddGlobal<uint8_t>(kWasmS128); uint8_t* src1 = r.builder().AddGlobal<uint8_t>(kWasmS128);
BUILD( BUILD_V(
r, r,
WASM_SET_GLOBAL(0, WASM_SIMD_BINOP(kExprS8x16Swizzle, WASM_GET_GLOBAL(1), WASM_SET_GLOBAL(0, WASM_SIMD_BINOP(kExprS8x16Swizzle, WASM_GET_GLOBAL(1),
WASM_GET_GLOBAL(2))), WASM_GET_GLOBAL(2))),
...@@ -2962,7 +2986,7 @@ WASM_SIMD_TEST(S8x16ShuffleFuzz) { ...@@ -2962,7 +2986,7 @@ WASM_SIMD_TEST(S8x16ShuffleFuzz) {
} }
void AppendShuffle(const Shuffle& shuffle, std::vector<byte>* buffer) { void AppendShuffle(const Shuffle& shuffle, std::vector<byte>* buffer) {
byte opcode[] = {WASM_SIMD_OP(kExprS8x16Shuffle)}; byte opcode[] = {WASM_SIMD_OP_BYTE(kExprS8x16Shuffle)};
for (size_t i = 0; i < arraysize(opcode); ++i) buffer->push_back(opcode[i]); for (size_t i = 0; i < arraysize(opcode); ++i) buffer->push_back(opcode[i]);
for (size_t i = 0; i < kSimd128Size; ++i) buffer->push_back((shuffle[i])); for (size_t i = 0; i < kSimd128Size; ++i) buffer->push_back((shuffle[i]));
} }
...@@ -3047,30 +3071,31 @@ WASM_SIMD_COMPILED_TEST(S8x16MultiShuffleFuzz) { ...@@ -3047,30 +3071,31 @@ WASM_SIMD_COMPILED_TEST(S8x16MultiShuffleFuzz) {
byte zero = r.AllocateLocal(kWasmS128); \ byte zero = r.AllocateLocal(kWasmS128); \
byte one_one = r.AllocateLocal(kWasmS128); \ byte one_one = r.AllocateLocal(kWasmS128); \
byte reduced = r.AllocateLocal(kWasmI32); \ byte reduced = r.AllocateLocal(kWasmI32); \
BUILD(r, WASM_SET_LOCAL(zero, WASM_SIMD_I##format##_SPLAT(int_type(0))), \ BUILD_V( \
WASM_SET_LOCAL( \ r, WASM_SET_LOCAL(zero, WASM_SIMD_I##format##_SPLAT(int_type(0))), \
reduced, WASM_SIMD_UNOP(kExprS1x##lanes##AnyTrue, \ WASM_SET_LOCAL(reduced, \
WASM_SIMD_UNOP(kExprS1x##lanes##AnyTrue, \
WASM_SIMD_BINOP(kExprI##format##Eq, \ WASM_SIMD_BINOP(kExprI##format##Eq, \
WASM_GET_LOCAL(zero), \ WASM_GET_LOCAL(zero), \
WASM_GET_LOCAL(zero)))), \ WASM_GET_LOCAL(zero)))), \
WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(reduced), WASM_ZERO), \ WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(reduced), WASM_ZERO), \
WASM_RETURN1(WASM_ZERO)), \ WASM_RETURN1(WASM_ZERO)), \
WASM_SET_LOCAL( \ WASM_SET_LOCAL(reduced, \
reduced, WASM_SIMD_UNOP(kExprS1x##lanes##AnyTrue, \ WASM_SIMD_UNOP(kExprS1x##lanes##AnyTrue, \
WASM_SIMD_BINOP(kExprI##format##Ne, \ WASM_SIMD_BINOP(kExprI##format##Ne, \
WASM_GET_LOCAL(zero), \ WASM_GET_LOCAL(zero), \
WASM_GET_LOCAL(zero)))), \ WASM_GET_LOCAL(zero)))), \
WASM_IF(WASM_I32_NE(WASM_GET_LOCAL(reduced), WASM_ZERO), \ WASM_IF(WASM_I32_NE(WASM_GET_LOCAL(reduced), WASM_ZERO), \
WASM_RETURN1(WASM_ZERO)), \ WASM_RETURN1(WASM_ZERO)), \
WASM_SET_LOCAL( \ WASM_SET_LOCAL(reduced, \
reduced, WASM_SIMD_UNOP(kExprS1x##lanes##AllTrue, \ WASM_SIMD_UNOP(kExprS1x##lanes##AllTrue, \
WASM_SIMD_BINOP(kExprI##format##Eq, \ WASM_SIMD_BINOP(kExprI##format##Eq, \
WASM_GET_LOCAL(zero), \ WASM_GET_LOCAL(zero), \
WASM_GET_LOCAL(zero)))), \ WASM_GET_LOCAL(zero)))), \
WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(reduced), WASM_ZERO), \ WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(reduced), WASM_ZERO), \
WASM_RETURN1(WASM_ZERO)), \ WASM_RETURN1(WASM_ZERO)), \
WASM_SET_LOCAL( \ WASM_SET_LOCAL(reduced, \
reduced, WASM_SIMD_UNOP(kExprS1x##lanes##AllTrue, \ WASM_SIMD_UNOP(kExprS1x##lanes##AllTrue, \
WASM_SIMD_BINOP(kExprI##format##Ne, \ WASM_SIMD_BINOP(kExprI##format##Ne, \
WASM_GET_LOCAL(zero), \ WASM_GET_LOCAL(zero), \
WASM_GET_LOCAL(zero)))), \ WASM_GET_LOCAL(zero)))), \
...@@ -3079,29 +3104,29 @@ WASM_SIMD_COMPILED_TEST(S8x16MultiShuffleFuzz) { ...@@ -3079,29 +3104,29 @@ WASM_SIMD_COMPILED_TEST(S8x16MultiShuffleFuzz) {
WASM_SET_LOCAL(one_one, \ WASM_SET_LOCAL(one_one, \
WASM_SIMD_I##format##_REPLACE_LANE( \ WASM_SIMD_I##format##_REPLACE_LANE( \
lanes - 1, WASM_GET_LOCAL(zero), int_type(1))), \ lanes - 1, WASM_GET_LOCAL(zero), int_type(1))), \
WASM_SET_LOCAL( \ WASM_SET_LOCAL(reduced, \
reduced, WASM_SIMD_UNOP(kExprS1x##lanes##AnyTrue, \ WASM_SIMD_UNOP(kExprS1x##lanes##AnyTrue, \
WASM_SIMD_BINOP(kExprI##format##Eq, \ WASM_SIMD_BINOP(kExprI##format##Eq, \
WASM_GET_LOCAL(one_one), \ WASM_GET_LOCAL(one_one), \
WASM_GET_LOCAL(zero)))), \ WASM_GET_LOCAL(zero)))), \
WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(reduced), WASM_ZERO), \ WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(reduced), WASM_ZERO), \
WASM_RETURN1(WASM_ZERO)), \ WASM_RETURN1(WASM_ZERO)), \
WASM_SET_LOCAL( \ WASM_SET_LOCAL(reduced, \
reduced, WASM_SIMD_UNOP(kExprS1x##lanes##AnyTrue, \ WASM_SIMD_UNOP(kExprS1x##lanes##AnyTrue, \
WASM_SIMD_BINOP(kExprI##format##Ne, \ WASM_SIMD_BINOP(kExprI##format##Ne, \
WASM_GET_LOCAL(one_one), \ WASM_GET_LOCAL(one_one), \
WASM_GET_LOCAL(zero)))), \ WASM_GET_LOCAL(zero)))), \
WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(reduced), WASM_ZERO), \ WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(reduced), WASM_ZERO), \
WASM_RETURN1(WASM_ZERO)), \ WASM_RETURN1(WASM_ZERO)), \
WASM_SET_LOCAL( \ WASM_SET_LOCAL(reduced, \
reduced, WASM_SIMD_UNOP(kExprS1x##lanes##AllTrue, \ WASM_SIMD_UNOP(kExprS1x##lanes##AllTrue, \
WASM_SIMD_BINOP(kExprI##format##Eq, \ WASM_SIMD_BINOP(kExprI##format##Eq, \
WASM_GET_LOCAL(one_one), \ WASM_GET_LOCAL(one_one), \
WASM_GET_LOCAL(zero)))), \ WASM_GET_LOCAL(zero)))), \
WASM_IF(WASM_I32_NE(WASM_GET_LOCAL(reduced), WASM_ZERO), \ WASM_IF(WASM_I32_NE(WASM_GET_LOCAL(reduced), WASM_ZERO), \
WASM_RETURN1(WASM_ZERO)), \ WASM_RETURN1(WASM_ZERO)), \
WASM_SET_LOCAL( \ WASM_SET_LOCAL(reduced, \
reduced, WASM_SIMD_UNOP(kExprS1x##lanes##AllTrue, \ WASM_SIMD_UNOP(kExprS1x##lanes##AllTrue, \
WASM_SIMD_BINOP(kExprI##format##Ne, \ WASM_SIMD_BINOP(kExprI##format##Ne, \
WASM_GET_LOCAL(one_one), \ WASM_GET_LOCAL(one_one), \
WASM_GET_LOCAL(zero)))), \ WASM_GET_LOCAL(zero)))), \
...@@ -3120,7 +3145,7 @@ WASM_SIMD_BOOL_REDUCTION_TEST(8x16, 16, WASM_I32V) ...@@ -3120,7 +3145,7 @@ WASM_SIMD_BOOL_REDUCTION_TEST(8x16, 16, WASM_I32V)
WASM_SIMD_TEST(SimdI32x4ExtractWithF32x4) { WASM_SIMD_TEST(SimdI32x4ExtractWithF32x4) {
WasmRunner<int32_t> r(execution_tier, lower_simd); WasmRunner<int32_t> r(execution_tier, lower_simd);
BUILD(r, WASM_IF_ELSE_I( BUILD_V(r, WASM_IF_ELSE_I(
WASM_I32_EQ(WASM_SIMD_I32x4_EXTRACT_LANE( WASM_I32_EQ(WASM_SIMD_I32x4_EXTRACT_LANE(
0, WASM_SIMD_F32x4_SPLAT(WASM_F32(30.5))), 0, WASM_SIMD_F32x4_SPLAT(WASM_F32(30.5))),
WASM_I32_REINTERPRET_F32(WASM_F32(30.5))), WASM_I32_REINTERPRET_F32(WASM_F32(30.5))),
...@@ -3130,8 +3155,8 @@ WASM_SIMD_TEST(SimdI32x4ExtractWithF32x4) { ...@@ -3130,8 +3155,8 @@ WASM_SIMD_TEST(SimdI32x4ExtractWithF32x4) {
WASM_SIMD_TEST(SimdF32x4ExtractWithI32x4) { WASM_SIMD_TEST(SimdF32x4ExtractWithI32x4) {
WasmRunner<int32_t> r(execution_tier, lower_simd); WasmRunner<int32_t> r(execution_tier, lower_simd);
BUILD(r, BUILD_V(r, WASM_IF_ELSE_I(
WASM_IF_ELSE_I(WASM_F32_EQ(WASM_SIMD_F32x4_EXTRACT_LANE( WASM_F32_EQ(WASM_SIMD_F32x4_EXTRACT_LANE(
0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(15))), 0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(15))),
WASM_F32_REINTERPRET_I32(WASM_I32V(15))), WASM_F32_REINTERPRET_I32(WASM_I32V(15))),
WASM_I32V(1), WASM_I32V(0))); WASM_I32V(1), WASM_I32V(0)));
...@@ -3142,7 +3167,7 @@ WASM_SIMD_TEST(SimdF32x4ExtractLane) { ...@@ -3142,7 +3167,7 @@ WASM_SIMD_TEST(SimdF32x4ExtractLane) {
WasmRunner<float> r(execution_tier, lower_simd); WasmRunner<float> r(execution_tier, lower_simd);
r.AllocateLocal(kWasmF32); r.AllocateLocal(kWasmF32);
r.AllocateLocal(kWasmS128); r.AllocateLocal(kWasmS128);
BUILD(r, BUILD_V(r,
WASM_SET_LOCAL(0, WASM_SIMD_F32x4_EXTRACT_LANE( WASM_SET_LOCAL(0, WASM_SIMD_F32x4_EXTRACT_LANE(
0, WASM_SIMD_F32x4_SPLAT(WASM_F32(30.5)))), 0, WASM_SIMD_F32x4_SPLAT(WASM_F32(30.5)))),
WASM_SET_LOCAL(1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(0))), WASM_SET_LOCAL(1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(0))),
...@@ -3156,7 +3181,8 @@ WASM_SIMD_TEST(SimdF32x4AddWithI32x4) { ...@@ -3156,7 +3181,8 @@ WASM_SIMD_TEST(SimdF32x4AddWithI32x4) {
const int kOne = 0x3F800000; const int kOne = 0x3F800000;
const int kTwo = 0x40000000; const int kTwo = 0x40000000;
WasmRunner<int32_t> r(execution_tier, lower_simd); WasmRunner<int32_t> r(execution_tier, lower_simd);
BUILD(r, BUILD_V(
r,
WASM_IF_ELSE_I( WASM_IF_ELSE_I(
WASM_F32_EQ( WASM_F32_EQ(
WASM_SIMD_F32x4_EXTRACT_LANE( WASM_SIMD_F32x4_EXTRACT_LANE(
...@@ -3171,8 +3197,8 @@ WASM_SIMD_TEST(SimdF32x4AddWithI32x4) { ...@@ -3171,8 +3197,8 @@ WASM_SIMD_TEST(SimdF32x4AddWithI32x4) {
WASM_SIMD_TEST(SimdI32x4AddWithF32x4) { WASM_SIMD_TEST(SimdI32x4AddWithF32x4) {
WasmRunner<int32_t> r(execution_tier, lower_simd); WasmRunner<int32_t> r(execution_tier, lower_simd);
BUILD(r, BUILD_V(
WASM_IF_ELSE_I( r, WASM_IF_ELSE_I(
WASM_I32_EQ( WASM_I32_EQ(
WASM_SIMD_I32x4_EXTRACT_LANE( WASM_SIMD_I32x4_EXTRACT_LANE(
0, WASM_SIMD_BINOP(kExprI32x4Add, 0, WASM_SIMD_BINOP(kExprI32x4Add,
...@@ -3187,7 +3213,7 @@ WASM_SIMD_TEST(SimdI32x4AddWithF32x4) { ...@@ -3187,7 +3213,7 @@ WASM_SIMD_TEST(SimdI32x4AddWithF32x4) {
WASM_SIMD_TEST(SimdI32x4Local) { WASM_SIMD_TEST(SimdI32x4Local) {
WasmRunner<int32_t> r(execution_tier, lower_simd); WasmRunner<int32_t> r(execution_tier, lower_simd);
r.AllocateLocal(kWasmS128); r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))), BUILD_V(r, WASM_SET_LOCAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))),
WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_GET_LOCAL(0))); WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_GET_LOCAL(0)));
CHECK_EQ(31, r.Call()); CHECK_EQ(31, r.Call());
...@@ -3197,7 +3223,8 @@ WASM_SIMD_TEST(SimdI32x4SplatFromExtract) { ...@@ -3197,7 +3223,8 @@ WASM_SIMD_TEST(SimdI32x4SplatFromExtract) {
WasmRunner<int32_t> r(execution_tier, lower_simd); WasmRunner<int32_t> r(execution_tier, lower_simd);
r.AllocateLocal(kWasmI32); r.AllocateLocal(kWasmI32);
r.AllocateLocal(kWasmS128); r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(0, WASM_SIMD_I32x4_EXTRACT_LANE( BUILD_V(r,
WASM_SET_LOCAL(0, WASM_SIMD_I32x4_EXTRACT_LANE(
0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(76)))), 0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(76)))),
WASM_SET_LOCAL(1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(0))), WASM_SET_LOCAL(1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(0))),
WASM_SIMD_I32x4_EXTRACT_LANE(1, WASM_GET_LOCAL(1))); WASM_SIMD_I32x4_EXTRACT_LANE(1, WASM_GET_LOCAL(1)));
...@@ -3208,17 +3235,18 @@ WASM_SIMD_TEST(SimdI32x4For) { ...@@ -3208,17 +3235,18 @@ WASM_SIMD_TEST(SimdI32x4For) {
WasmRunner<int32_t> r(execution_tier, lower_simd); WasmRunner<int32_t> r(execution_tier, lower_simd);
r.AllocateLocal(kWasmI32); r.AllocateLocal(kWasmI32);
r.AllocateLocal(kWasmS128); r.AllocateLocal(kWasmS128);
BUILD(r, BUILD_V(
r,
WASM_SET_LOCAL(1, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))), WASM_SET_LOCAL(1, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))),
WASM_SET_LOCAL(1, WASM_SIMD_I32x4_REPLACE_LANE(1, WASM_GET_LOCAL(1), WASM_SET_LOCAL(
WASM_I32V(53))), 1, WASM_SIMD_I32x4_REPLACE_LANE(1, WASM_GET_LOCAL(1), WASM_I32V(53))),
WASM_SET_LOCAL(1, WASM_SIMD_I32x4_REPLACE_LANE(2, WASM_GET_LOCAL(1), WASM_SET_LOCAL(
WASM_I32V(23))), 1, WASM_SIMD_I32x4_REPLACE_LANE(2, WASM_GET_LOCAL(1), WASM_I32V(23))),
WASM_SET_LOCAL(0, WASM_I32V(0)), WASM_SET_LOCAL(0, WASM_I32V(0)),
WASM_LOOP( WASM_LOOP(
WASM_SET_LOCAL( WASM_SET_LOCAL(1,
1, WASM_SIMD_BINOP(kExprI32x4Add, WASM_GET_LOCAL(1), WASM_SIMD_BINOP(kExprI32x4Add, WASM_GET_LOCAL(1),
WASM_SIMD_I32x4_SPLAT(WASM_I32V(1)))), WASM_SIMD_I32x4_SPLAT(WASM_I32V(1)))),
WASM_IF(WASM_I32_NE(WASM_INC_LOCAL(0), WASM_I32V(5)), WASM_BR(1))), WASM_IF(WASM_I32_NE(WASM_INC_LOCAL(0), WASM_I32V(5)), WASM_BR(1))),
WASM_SET_LOCAL(0, WASM_I32V(1)), WASM_SET_LOCAL(0, WASM_I32V(1)),
...@@ -3242,13 +3270,14 @@ WASM_SIMD_TEST(SimdF32x4For) { ...@@ -3242,13 +3270,14 @@ WASM_SIMD_TEST(SimdF32x4For) {
WasmRunner<int32_t> r(execution_tier, lower_simd); WasmRunner<int32_t> r(execution_tier, lower_simd);
r.AllocateLocal(kWasmI32); r.AllocateLocal(kWasmI32);
r.AllocateLocal(kWasmS128); r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(1, WASM_SIMD_F32x4_SPLAT(WASM_F32(21.25))), BUILD_V(
r, WASM_SET_LOCAL(1, WASM_SIMD_F32x4_SPLAT(WASM_F32(21.25))),
WASM_SET_LOCAL(1, WASM_SIMD_F32x4_REPLACE_LANE(3, WASM_GET_LOCAL(1), WASM_SET_LOCAL(1, WASM_SIMD_F32x4_REPLACE_LANE(3, WASM_GET_LOCAL(1),
WASM_F32(19.5))), WASM_F32(19.5))),
WASM_SET_LOCAL(0, WASM_I32V(0)), WASM_SET_LOCAL(0, WASM_I32V(0)),
WASM_LOOP( WASM_LOOP(
WASM_SET_LOCAL( WASM_SET_LOCAL(1,
1, WASM_SIMD_BINOP(kExprF32x4Add, WASM_GET_LOCAL(1), WASM_SIMD_BINOP(kExprF32x4Add, WASM_GET_LOCAL(1),
WASM_SIMD_F32x4_SPLAT(WASM_F32(2.0)))), WASM_SIMD_F32x4_SPLAT(WASM_F32(2.0)))),
WASM_IF(WASM_I32_NE(WASM_INC_LOCAL(0), WASM_I32V(3)), WASM_BR(1))), WASM_IF(WASM_I32_NE(WASM_INC_LOCAL(0), WASM_I32V(3)), WASM_BR(1))),
WASM_SET_LOCAL(0, WASM_I32V(1)), WASM_SET_LOCAL(0, WASM_I32V(1)),
...@@ -3288,7 +3317,7 @@ WASM_SIMD_TEST(SimdI32x4GetGlobal) { ...@@ -3288,7 +3317,7 @@ WASM_SIMD_TEST(SimdI32x4GetGlobal) {
int32_t* global = r.builder().AddGlobal<int32_t>(kWasmS128); int32_t* global = r.builder().AddGlobal<int32_t>(kWasmS128);
SetVectorByLanes(global, {{0, 1, 2, 3}}); SetVectorByLanes(global, {{0, 1, 2, 3}});
r.AllocateLocal(kWasmI32); r.AllocateLocal(kWasmI32);
BUILD( BUILD_V(
r, WASM_SET_LOCAL(1, WASM_I32V(1)), r, WASM_SET_LOCAL(1, WASM_I32V(1)),
WASM_IF(WASM_I32_NE(WASM_I32V(0), WASM_IF(WASM_I32_NE(WASM_I32V(0),
WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_GET_GLOBAL(4))), WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_GET_GLOBAL(4))),
...@@ -3314,7 +3343,7 @@ WASM_SIMD_TEST(SimdI32x4SetGlobal) { ...@@ -3314,7 +3343,7 @@ WASM_SIMD_TEST(SimdI32x4SetGlobal) {
r.builder().AddGlobal<int32_t>(kWasmI32); // purposefully unused r.builder().AddGlobal<int32_t>(kWasmI32); // purposefully unused
r.builder().AddGlobal<int32_t>(kWasmI32); // purposefully unused r.builder().AddGlobal<int32_t>(kWasmI32); // purposefully unused
int32_t* global = r.builder().AddGlobal<int32_t>(kWasmS128); int32_t* global = r.builder().AddGlobal<int32_t>(kWasmS128);
BUILD(r, WASM_SET_GLOBAL(4, WASM_SIMD_I32x4_SPLAT(WASM_I32V(23))), BUILD_V(r, WASM_SET_GLOBAL(4, WASM_SIMD_I32x4_SPLAT(WASM_I32V(23))),
WASM_SET_GLOBAL(4, WASM_SIMD_I32x4_REPLACE_LANE(1, WASM_GET_GLOBAL(4), WASM_SET_GLOBAL(4, WASM_SIMD_I32x4_REPLACE_LANE(1, WASM_GET_GLOBAL(4),
WASM_I32V(34))), WASM_I32V(34))),
WASM_SET_GLOBAL(4, WASM_SIMD_I32x4_REPLACE_LANE(2, WASM_GET_GLOBAL(4), WASM_SET_GLOBAL(4, WASM_SIMD_I32x4_REPLACE_LANE(2, WASM_GET_GLOBAL(4),
...@@ -3334,7 +3363,7 @@ WASM_SIMD_TEST(SimdF32x4GetGlobal) { ...@@ -3334,7 +3363,7 @@ WASM_SIMD_TEST(SimdF32x4GetGlobal) {
float* global = r.builder().AddGlobal<float>(kWasmS128); float* global = r.builder().AddGlobal<float>(kWasmS128);
SetVectorByLanes<float>(global, {{0.0, 1.5, 2.25, 3.5}}); SetVectorByLanes<float>(global, {{0.0, 1.5, 2.25, 3.5}});
r.AllocateLocal(kWasmI32); r.AllocateLocal(kWasmI32);
BUILD( BUILD_V(
r, WASM_SET_LOCAL(1, WASM_I32V(1)), r, WASM_SET_LOCAL(1, WASM_I32V(1)),
WASM_IF(WASM_F32_NE(WASM_F32(0.0), WASM_IF(WASM_F32_NE(WASM_F32(0.0),
WASM_SIMD_F32x4_EXTRACT_LANE(0, WASM_GET_GLOBAL(0))), WASM_SIMD_F32x4_EXTRACT_LANE(0, WASM_GET_GLOBAL(0))),
...@@ -3355,7 +3384,7 @@ WASM_SIMD_TEST(SimdF32x4GetGlobal) { ...@@ -3355,7 +3384,7 @@ WASM_SIMD_TEST(SimdF32x4GetGlobal) {
WASM_SIMD_TEST(SimdF32x4SetGlobal) { WASM_SIMD_TEST(SimdF32x4SetGlobal) {
WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd); WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd);
float* global = r.builder().AddGlobal<float>(kWasmS128); float* global = r.builder().AddGlobal<float>(kWasmS128);
BUILD(r, WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_SPLAT(WASM_F32(13.5))), BUILD_V(r, WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_SPLAT(WASM_F32(13.5))),
WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE(1, WASM_GET_GLOBAL(0), WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE(1, WASM_GET_GLOBAL(0),
WASM_F32(45.5))), WASM_F32(45.5))),
WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE(2, WASM_GET_GLOBAL(0), WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE(2, WASM_GET_GLOBAL(0),
...@@ -3376,7 +3405,8 @@ WASM_SIMD_TEST(SimdLoadStoreLoad) { ...@@ -3376,7 +3405,8 @@ WASM_SIMD_TEST(SimdLoadStoreLoad) {
r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t)); r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t));
// Load memory, store it, then reload it and extract the first lane. Use a // Load memory, store it, then reload it and extract the first lane. Use a
// non-zero offset into the memory of 1 lane (4 bytes) to test indexing. // non-zero offset into the memory of 1 lane (4 bytes) to test indexing.
BUILD(r, WASM_SIMD_STORE_MEM(WASM_I32V(8), WASM_SIMD_LOAD_MEM(WASM_I32V(4))), BUILD_V(r,
WASM_SIMD_STORE_MEM(WASM_I32V(8), WASM_SIMD_LOAD_MEM(WASM_I32V(4))),
WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_SIMD_LOAD_MEM(WASM_I32V(8)))); WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_SIMD_LOAD_MEM(WASM_I32V(8))));
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
...@@ -3394,7 +3424,7 @@ WASM_SIMD_TEST(SimdLoadStoreLoadMemargOffset) { ...@@ -3394,7 +3424,7 @@ WASM_SIMD_TEST(SimdLoadStoreLoadMemargOffset) {
constexpr byte offset_2 = 8; constexpr byte offset_2 = 8;
// Load from memory at offset_1, store to offset_2, load from offset_2, and // Load from memory at offset_1, store to offset_2, load from offset_2, and
// extract first lane. We use non-zero memarg offsets to test offset decoding. // extract first lane. We use non-zero memarg offsets to test offset decoding.
BUILD( BUILD_V(
r, r,
WASM_SIMD_STORE_MEM_OFFSET( WASM_SIMD_STORE_MEM_OFFSET(
offset_2, WASM_ZERO, WASM_SIMD_LOAD_MEM_OFFSET(offset_1, WASM_ZERO)), offset_2, WASM_ZERO, WASM_SIMD_LOAD_MEM_OFFSET(offset_1, WASM_ZERO)),
...@@ -3417,7 +3447,7 @@ void RunLoadSplatTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -3417,7 +3447,7 @@ void RunLoadSplatTest(ExecutionTier execution_tier, LowerSimd lower_simd,
WasmRunner<int32_t> r(execution_tier, lower_simd); WasmRunner<int32_t> r(execution_tier, lower_simd);
T* memory = r.builder().AddMemoryElems<T>(kWasmPageSize / sizeof(T)); T* memory = r.builder().AddMemoryElems<T>(kWasmPageSize / sizeof(T));
T* global = r.builder().AddGlobal<T>(kWasmS128); T* global = r.builder().AddGlobal<T>(kWasmS128);
BUILD(r, WASM_SET_GLOBAL(0, WASM_SIMD_LOAD_SPLAT(op, WASM_I32V(mem_index))), BUILD_V(r, WASM_SET_GLOBAL(0, WASM_SIMD_LOAD_SPLAT(op, WASM_I32V(mem_index))),
WASM_ONE); WASM_ONE);
for (T x : compiler::ValueHelper::GetVector<T>()) { for (T x : compiler::ValueHelper::GetVector<T>()) {
...@@ -3455,7 +3485,8 @@ void RunLoadExtendTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -3455,7 +3485,8 @@ void RunLoadExtendTest(ExecutionTier execution_tier, LowerSimd lower_simd,
WasmRunner<int32_t> r(execution_tier, lower_simd); WasmRunner<int32_t> r(execution_tier, lower_simd);
S* memory = r.builder().AddMemoryElems<S>(kWasmPageSize / sizeof(S)); S* memory = r.builder().AddMemoryElems<S>(kWasmPageSize / sizeof(S));
T* global = r.builder().AddGlobal<T>(kWasmS128); T* global = r.builder().AddGlobal<T>(kWasmS128);
BUILD(r, WASM_SET_GLOBAL(0, WASM_SIMD_LOAD_EXTEND(op, WASM_I32V(mem_index))), BUILD_V(r,
WASM_SET_GLOBAL(0, WASM_SIMD_LOAD_EXTEND(op, WASM_I32V(mem_index))),
WASM_ONE); WASM_ONE);
for (S x : compiler::ValueHelper::GetVector<S>()) { for (S x : compiler::ValueHelper::GetVector<S>()) {
...@@ -3507,7 +3538,7 @@ WASM_SIMD_TEST_NO_LOWERING(I64x2Load32x2S) { ...@@ -3507,7 +3538,7 @@ WASM_SIMD_TEST_NO_LOWERING(I64x2Load32x2S) {
WasmRunner<int32_t, param_type> r(execution_tier, lower_simd); \ WasmRunner<int32_t, param_type> r(execution_tier, lower_simd); \
if (lanes == 2 && lower_simd == kLowerSimd) return; \ if (lanes == 2 && lower_simd == kLowerSimd) return; \
byte simd = r.AllocateLocal(kWasmS128); \ byte simd = r.AllocateLocal(kWasmS128); \
BUILD( \ BUILD_V( \
r, \ r, \
WASM_SET_LOCAL(simd, WASM_SIMD_I##format##_SPLAT(WASM_GET_LOCAL(0))), \ WASM_SET_LOCAL(simd, WASM_SIMD_I##format##_SPLAT(WASM_GET_LOCAL(0))), \
WASM_SIMD_UNOP(kExprS1x##lanes##AnyTrue, WASM_GET_LOCAL(simd))); \ WASM_SIMD_UNOP(kExprS1x##lanes##AnyTrue, WASM_GET_LOCAL(simd))); \
...@@ -3528,7 +3559,7 @@ WASM_SIMD_ANYTRUE_TEST(8x16, 16, 0xff, int32_t) ...@@ -3528,7 +3559,7 @@ WASM_SIMD_ANYTRUE_TEST(8x16, 16, 0xff, int32_t)
WasmRunner<int32_t, param_type> r(execution_tier, lower_simd); \ WasmRunner<int32_t, param_type> r(execution_tier, lower_simd); \
if (lanes == 2 && lower_simd == kLowerSimd) return; \ if (lanes == 2 && lower_simd == kLowerSimd) return; \
byte simd = r.AllocateLocal(kWasmS128); \ byte simd = r.AllocateLocal(kWasmS128); \
BUILD( \ BUILD_V( \
r, \ r, \
WASM_SET_LOCAL(simd, WASM_SIMD_I##format##_SPLAT(WASM_GET_LOCAL(0))), \ WASM_SET_LOCAL(simd, WASM_SIMD_I##format##_SPLAT(WASM_GET_LOCAL(0))), \
WASM_SIMD_UNOP(kExprS1x##lanes##AllTrue, WASM_GET_LOCAL(simd))); \ WASM_SIMD_UNOP(kExprS1x##lanes##AllTrue, WASM_GET_LOCAL(simd))); \
...@@ -3548,10 +3579,10 @@ WASM_SIMD_ALLTRUE_TEST(8x16, 16, 0xff, int32_t) ...@@ -3548,10 +3579,10 @@ WASM_SIMD_ALLTRUE_TEST(8x16, 16, 0xff, int32_t)
WASM_SIMD_TEST(BitSelect) { WASM_SIMD_TEST(BitSelect) {
WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd); WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd);
byte simd = r.AllocateLocal(kWasmS128); byte simd = r.AllocateLocal(kWasmS128);
BUILD(r, BUILD_V(r,
WASM_SET_LOCAL( WASM_SET_LOCAL(simd,
simd, WASM_SIMD_SELECT(
WASM_SIMD_SELECT(32x4, WASM_SIMD_I32x4_SPLAT(WASM_I32V(0x01020304)), 32x4, WASM_SIMD_I32x4_SPLAT(WASM_I32V(0x01020304)),
WASM_SIMD_I32x4_SPLAT(WASM_I32V(0)), WASM_SIMD_I32x4_SPLAT(WASM_I32V(0)),
WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(0)))), WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(0)))),
WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_GET_LOCAL(simd))); WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_GET_LOCAL(simd)));
...@@ -3566,7 +3597,8 @@ void RunI8x16MixedRelationalOpTest(ExecutionTier execution_tier, ...@@ -3566,7 +3597,8 @@ void RunI8x16MixedRelationalOpTest(ExecutionTier execution_tier,
byte temp1 = r.AllocateLocal(kWasmS128); byte temp1 = r.AllocateLocal(kWasmS128);
byte temp2 = r.AllocateLocal(kWasmS128); byte temp2 = r.AllocateLocal(kWasmS128);
byte temp3 = r.AllocateLocal(kWasmS128); byte temp3 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(value1))), BUILD_V(r,
WASM_SET_LOCAL(temp1, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(value1))),
WASM_SET_LOCAL(temp2, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(value2))), WASM_SET_LOCAL(temp2, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(value2))),
WASM_SET_LOCAL(temp3, WASM_SIMD_BINOP(opcode, WASM_GET_LOCAL(temp1), WASM_SET_LOCAL(temp3, WASM_SIMD_BINOP(opcode, WASM_GET_LOCAL(temp1),
WASM_GET_LOCAL(temp2))), WASM_GET_LOCAL(temp2))),
...@@ -3605,7 +3637,8 @@ void RunI16x8MixedRelationalOpTest(ExecutionTier execution_tier, ...@@ -3605,7 +3637,8 @@ void RunI16x8MixedRelationalOpTest(ExecutionTier execution_tier,
byte temp1 = r.AllocateLocal(kWasmS128); byte temp1 = r.AllocateLocal(kWasmS128);
byte temp2 = r.AllocateLocal(kWasmS128); byte temp2 = r.AllocateLocal(kWasmS128);
byte temp3 = r.AllocateLocal(kWasmS128); byte temp3 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(temp1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(value1))), BUILD_V(r,
WASM_SET_LOCAL(temp1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(value1))),
WASM_SET_LOCAL(temp2, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(value2))), WASM_SET_LOCAL(temp2, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(value2))),
WASM_SET_LOCAL(temp3, WASM_SIMD_BINOP(opcode, WASM_GET_LOCAL(temp1), WASM_SET_LOCAL(temp3, WASM_SIMD_BINOP(opcode, WASM_GET_LOCAL(temp1),
WASM_GET_LOCAL(temp2))), WASM_GET_LOCAL(temp2))),
...@@ -3641,13 +3674,14 @@ WASM_SIMD_TEST_NO_LOWERING(I16x8GtUMixed) { ...@@ -3641,13 +3674,14 @@ WASM_SIMD_TEST_NO_LOWERING(I16x8GtUMixed) {
WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd); \ WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd); \
byte int_val = r.AllocateLocal(kWasmI32); \ byte int_val = r.AllocateLocal(kWasmI32); \
byte simd_val = r.AllocateLocal(kWasmS128); \ byte simd_val = r.AllocateLocal(kWasmS128); \
BUILD(r, \ BUILD_V(r, \
WASM_SET_LOCAL(simd_val, \ WASM_SET_LOCAL(simd_val, \
WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(int_val))), \ WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(int_val))), \
WASM_SIMD_CHECK_LANE_U(I16x8, simd_val, I32, int_val, 0), \ WASM_SIMD_CHECK_LANE_U(I16x8, simd_val, I32, int_val, 0), \
WASM_SIMD_CHECK_LANE_U(I16x8, simd_val, I32, int_val, 2), \ WASM_SIMD_CHECK_LANE_U(I16x8, simd_val, I32, int_val, 2), \
WASM_SIMD_CHECK_LANE_U(I16x8, simd_val, I32, int_val, 4), \ WASM_SIMD_CHECK_LANE_U(I16x8, simd_val, I32, int_val, 4), \
WASM_SIMD_CHECK_LANE_U(I16x8, simd_val, I32, int_val, 6), WASM_ONE); \ WASM_SIMD_CHECK_LANE_U(I16x8, simd_val, I32, int_val, 6), \
WASM_ONE); \
FOR_##Type##_INPUTS(x) { CHECK_EQ(1, r.Call(x)); } \ FOR_##Type##_INPUTS(x) { CHECK_EQ(1, r.Call(x)); } \
} }
WASM_EXTRACT_I16x8_TEST(S, UINT16) WASM_EXTRACT_I16x8_TEST(I, INT16) WASM_EXTRACT_I16x8_TEST(S, UINT16) WASM_EXTRACT_I16x8_TEST(I, INT16)
...@@ -3658,7 +3692,7 @@ WASM_EXTRACT_I16x8_TEST(S, UINT16) WASM_EXTRACT_I16x8_TEST(I, INT16) ...@@ -3658,7 +3692,7 @@ WASM_EXTRACT_I16x8_TEST(S, UINT16) WASM_EXTRACT_I16x8_TEST(I, INT16)
WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd); \ WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd); \
byte int_val = r.AllocateLocal(kWasmI32); \ byte int_val = r.AllocateLocal(kWasmI32); \
byte simd_val = r.AllocateLocal(kWasmS128); \ byte simd_val = r.AllocateLocal(kWasmS128); \
BUILD(r, \ BUILD_V(r, \
WASM_SET_LOCAL(simd_val, \ WASM_SET_LOCAL(simd_val, \
WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(int_val))), \ WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(int_val))), \
WASM_SIMD_CHECK_LANE_U(I8x16, simd_val, I32, int_val, 1), \ WASM_SIMD_CHECK_LANE_U(I8x16, simd_val, I32, int_val, 1), \
......
...@@ -47,6 +47,11 @@ void AppendSingle(std::vector<byte>* code, WasmOpcode op) { ...@@ -47,6 +47,11 @@ void AppendSingle(std::vector<byte>* code, WasmOpcode op) {
} }
} }
template <>
void AppendSingle(std::vector<byte>* code, ValueTypeCode op) {
code->push_back(op);
}
TestingModuleBuilder::TestingModuleBuilder( TestingModuleBuilder::TestingModuleBuilder(
Zone* zone, ManuallyImportedJSFunction* maybe_import, ExecutionTier tier, Zone* zone, ManuallyImportedJSFunction* maybe_import, ExecutionTier tier,
RuntimeExceptionSupport exception_support, LowerSimd lower_simd) RuntimeExceptionSupport exception_support, LowerSimd lower_simd)
......
...@@ -86,6 +86,10 @@ void AppendSingle(std::vector<byte>* code, T t) { ...@@ -86,6 +86,10 @@ void AppendSingle(std::vector<byte>* code, T t) {
template <> template <>
void AppendSingle<WasmOpcode>(std::vector<byte>* code, WasmOpcode op); void AppendSingle<WasmOpcode>(std::vector<byte>* code, WasmOpcode op);
// Specialized for ValueTypeCode.
template <>
void AppendSingle<ValueTypeCode>(std::vector<byte>* code, ValueTypeCode op);
template <typename... T> template <typename... T>
void Append(std::vector<byte>* code, T... ts) { void Append(std::vector<byte>* code, T... ts) {
static_assert(sizeof...(ts) == 0, "Base case for appending bytes to code."); static_assert(sizeof...(ts) == 0, "Base case for appending bytes to code.");
......
...@@ -17,7 +17,7 @@ builder.addFunction(undefined, 0 /* sig */) ...@@ -17,7 +17,7 @@ builder.addFunction(undefined, 0 /* sig */)
kExprI32Const, 0x75, // i32.const kExprI32Const, 0x75, // i32.const
kExprI32Const, 0x74, // i32.const kExprI32Const, 0x74, // i32.const
kExprI32Const, 0x18, // i32.const kExprI32Const, 0x18, // i32.const
kSimdPrefix, kExprS8x16LoadSplat, // s8x16.load_splat kSimdPrefix, ...kExprS8x16LoadSplat, // s8x16.load_splat
kExprUnreachable, // unreachable kExprUnreachable, // unreachable
kExprUnreachable, // unreachable kExprUnreachable, // unreachable
kExprI32Const, 0x6f, // i32.const kExprI32Const, 0x6f, // i32.const
......
...@@ -479,7 +479,7 @@ let kExprI16x8ShrS = 0x66; ...@@ -479,7 +479,7 @@ let kExprI16x8ShrS = 0x66;
let kExprS1x4AllTrue = 0x75; let kExprS1x4AllTrue = 0x75;
let kExprI32x4Add = 0x79; let kExprI32x4Add = 0x79;
let kExprF32x4Min = 0x9e; let kExprF32x4Min = 0x9e;
let kExprS8x16LoadSplat = 0xc2; let kExprS8x16LoadSplat = [0xc2, 0x1];
// Compilation hint constants. // Compilation hint constants.
let kCompilationHintStrategyDefault = 0x00; let kCompilationHintStrategyDefault = 0x00;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "src/wasm/leb-helper.h"
#include "test/unittests/test-utils.h" #include "test/unittests/test-utils.h"
#include "src/init/v8.h" #include "src/init/v8.h"
...@@ -3628,6 +3629,20 @@ class WasmOpcodeLengthTest : public TestWithZone { ...@@ -3628,6 +3629,20 @@ class WasmOpcodeLengthTest : public TestWithZone {
EXPECT_EQ(expected, OpcodeLength(code, code + sizeof(code))) EXPECT_EQ(expected, OpcodeLength(code, code + sizeof(code)))
<< PrintOpcodes{code, code + sizeof...(bytes)}; << PrintOpcodes{code, code + sizeof...(bytes)};
} }
// Helper to check for prefixed opcodes, which can have multiple bytes.
void ExpectLengthPrefixed(unsigned operands, WasmOpcode opcode) {
uint8_t prefix = (opcode >> 8) & 0xff;
DCHECK(WasmOpcodes::IsPrefixOpcode(static_cast<WasmOpcode>(prefix)));
uint8_t index = opcode & 0xff;
uint8_t encoded[2] = {0, 0};
uint8_t* p = encoded;
unsigned len = static_cast<unsigned>(LEBHelper::sizeof_u32v(index));
DCHECK_GE(2, len);
LEBHelper::write_u32v(&p, index);
// length of index, + number of operands + prefix bye
ExpectLength(len + operands + 1, prefix, encoded[0], encoded[1]);
}
}; };
TEST_F(WasmOpcodeLengthTest, Statements) { TEST_F(WasmOpcodeLengthTest, Statements) {
...@@ -3754,17 +3769,15 @@ TEST_F(WasmOpcodeLengthTest, SimpleExpressions) { ...@@ -3754,17 +3769,15 @@ TEST_F(WasmOpcodeLengthTest, SimpleExpressions) {
} }
TEST_F(WasmOpcodeLengthTest, SimdExpressions) { TEST_F(WasmOpcodeLengthTest, SimdExpressions) {
#define TEST_SIMD(name, opcode, sig) \ #define TEST_SIMD(name, opcode, sig) ExpectLengthPrefixed(0, kExpr##name);
ExpectLength(2, kSimdPrefix, static_cast<byte>(kExpr##name & 0xFF));
FOREACH_SIMD_0_OPERAND_OPCODE(TEST_SIMD) FOREACH_SIMD_0_OPERAND_OPCODE(TEST_SIMD)
#undef TEST_SIMD #undef TEST_SIMD
#define TEST_SIMD(name, opcode, sig) \ #define TEST_SIMD(name, opcode, sig) ExpectLengthPrefixed(1, kExpr##name);
ExpectLength(3, kSimdPrefix, static_cast<byte>(kExpr##name & 0xFF));
FOREACH_SIMD_1_OPERAND_OPCODE(TEST_SIMD) FOREACH_SIMD_1_OPERAND_OPCODE(TEST_SIMD)
#undef TEST_SIMD #undef TEST_SIMD
ExpectLength(18, kSimdPrefix, static_cast<byte>(kExprS8x16Shuffle & 0xFF)); ExpectLengthPrefixed(16, kExprS8x16Shuffle);
// test for bad simd opcode // test for bad simd opcode, 0xFF is encoded in two bytes.
ExpectLength(2, kSimdPrefix, 0xFF); ExpectLength(3, kSimdPrefix, 0xFF, 0x1);
} }
using TypesOfLocals = ZoneVector<ValueType>; using TypesOfLocals = ZoneVector<ValueType>;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment