Commit 1d786451 authored by Ng Zhi An's avatar Ng Zhi An Committed by Commit Bot

[wasm-simd][cleanup] Consolidate macros for SIMD loads

The load splat, load extend, load zero macros are essentially the same,
consolidate them into a single macro.

Change-Id: Ic812043b37524deb3a9e6ddc223bb95ae77e1d4d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2304715
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Reviewed-by: 's avatarBill Budge <bbudge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68978}
parent 15ca7b94
......@@ -3470,8 +3470,8 @@ WASM_SIMD_TEST(S8x16LoadSplatOffset) {
int8_t* global = r.builder().AddGlobal<int8_t>(kWasmS128);
BUILD(r,
WASM_SET_GLOBAL(
0, WASM_SIMD_LOAD_SPLAT_OFFSET(kExprS8x16LoadSplat, WASM_I32V(0),
U32V_2(offset))),
0, WASM_SIMD_LOAD_OP_OFFSET(kExprS8x16LoadSplat, WASM_I32V(0),
U32V_2(offset))),
WASM_ONE);
// We don't really care about all valid values, so just test for 1.
......@@ -3491,7 +3491,7 @@ void RunLoadSplatTest(ExecutionTier execution_tier, LowerSimd lower_simd,
WasmRunner<int32_t> r(execution_tier, lower_simd);
T* memory = r.builder().AddMemoryElems<T>(kWasmPageSize / sizeof(T));
T* global = r.builder().AddGlobal<T>(kWasmS128);
BUILD(r, WASM_SET_GLOBAL(0, WASM_SIMD_LOAD_SPLAT(op, WASM_I32V(mem_index))),
BUILD(r, WASM_SET_GLOBAL(0, WASM_SIMD_LOAD_OP(op, WASM_I32V(mem_index))),
WASM_ONE);
for (T x : compiler::ValueHelper::GetVector<T>()) {
......@@ -3534,7 +3534,7 @@ void RunLoadExtendTest(ExecutionTier execution_tier, LowerSimd lower_simd,
S* memory = r.builder().AddMemoryElems<S>(kWasmPageSize / sizeof(S));
T* global = r.builder().AddGlobal<T>(kWasmS128);
BUILD(r,
WASM_SET_GLOBAL(0, WASM_SIMD_LOAD_EXTEND_ALIGNMENT(
WASM_SET_GLOBAL(0, WASM_SIMD_LOAD_OP_ALIGNMENT(
op, WASM_I32V(mem_index), alignment)),
WASM_ONE);
......@@ -3556,10 +3556,9 @@ void RunLoadExtendTest(ExecutionTier execution_tier, LowerSimd lower_simd,
S* memory = r.builder().AddMemoryElems<S>(kWasmPageSize / sizeof(S));
T* global = r.builder().AddGlobal<T>(kWasmS128);
constexpr byte offset = sizeof(S);
BUILD(
r,
WASM_SET_GLOBAL(0, WASM_SIMD_LOAD_EXTEND_OFFSET(op, WASM_ZERO, offset)),
WASM_ONE);
BUILD(r,
WASM_SET_GLOBAL(0, WASM_SIMD_LOAD_OP_OFFSET(op, WASM_ZERO, offset)),
WASM_ONE);
// Let max_s be the max_s value for type S, we set up the memory as such:
// memory = [max_s, max_s - 1, ... max_s - (lane_s - 1)].
......@@ -3620,10 +3619,8 @@ void RunLoadZeroTest(ExecutionTier execution_tier, LowerSimd lower_simd,
WasmRunner<int32_t> r(execution_tier, lower_simd);
S* memory = r.builder().AddMemoryElems<S>(kWasmPageSize / sizeof(S));
S* global = r.builder().AddGlobal<S>(kWasmS128);
BUILD(
r,
WASM_SET_GLOBAL(0, WASM_SIMD_LOAD_ZERO_EXTEND(op, WASM_I32V(mem_index))),
WASM_ONE);
BUILD(r, WASM_SET_GLOBAL(0, WASM_SIMD_LOAD_OP(op, WASM_I32V(mem_index))),
WASM_ONE);
S sentinel = S{-1};
r.builder().WriteMemory(&memory[lanes_s], sentinel);
......@@ -3936,9 +3933,9 @@ WASM_EXTRACT_I16x8_TEST(S, UINT16) WASM_EXTRACT_I16x8_TEST(I, INT16)
#undef WASM_SIMD_F64x2_QFMS
#undef WASM_SIMD_F32x4_QFMA
#undef WASM_SIMD_F32x4_QFMS
#undef WASM_SIMD_LOAD_SPLAT
#undef WASM_SIMD_LOAD_EXTEND
#undef WASM_SIMD_LOAD_ZERO_EXTEND
#undef WASM_SIMD_LOAD_OP
#undef WASM_SIMD_LOAD_OP_OFFSET
#undef WASM_SIMD_LOAD_OP_ALIGNMENT
} // namespace test_run_wasm_simd
} // namespace wasm
......
......@@ -862,18 +862,13 @@ inline WasmOpcode LoadStoreOpcodeOf(MachineType type, bool store) {
#define WASM_SIMD_F32x4_QFMA(a, b, c) a, b, c, WASM_SIMD_OP(kExprF32x4Qfma)
#define WASM_SIMD_F32x4_QFMS(a, b, c) a, b, c, WASM_SIMD_OP(kExprF32x4Qfms)
#define WASM_SIMD_LOAD_SPLAT(opcode, index) \
// Like WASM_SIMD_LOAD_MEM but needs the load opcode.
#define WASM_SIMD_LOAD_OP(opcode, index) \
index, WASM_SIMD_OP(opcode), ZERO_ALIGNMENT, ZERO_OFFSET
#define WASM_SIMD_LOAD_SPLAT_OFFSET(opcode, index, offset) \
#define WASM_SIMD_LOAD_OP_OFFSET(opcode, index, offset) \
index, WASM_SIMD_OP(opcode), ZERO_ALIGNMENT, offset
#define WASM_SIMD_LOAD_EXTEND(opcode, index) \
index, WASM_SIMD_OP(opcode), ZERO_ALIGNMENT, ZERO_OFFSET
#define WASM_SIMD_LOAD_EXTEND_OFFSET(opcode, index, offset) \
index, WASM_SIMD_OP(opcode), ZERO_ALIGNMENT, offset
#define WASM_SIMD_LOAD_EXTEND_ALIGNMENT(opcode, index, alignment) \
#define WASM_SIMD_LOAD_OP_ALIGNMENT(opcode, index, alignment) \
index, WASM_SIMD_OP(opcode), alignment, ZERO_OFFSET
#define WASM_SIMD_LOAD_ZERO_EXTEND(opcode, index) \
index, WASM_SIMD_OP(opcode), ZERO_ALIGNMENT, ZERO_OFFSET
//------------------------------------------------------------------------------
// Compilation Hints.
......
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