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,7 +3470,7 @@ WASM_SIMD_TEST(S8x16LoadSplatOffset) { ...@@ -3470,7 +3470,7 @@ WASM_SIMD_TEST(S8x16LoadSplatOffset) {
int8_t* global = r.builder().AddGlobal<int8_t>(kWasmS128); int8_t* global = r.builder().AddGlobal<int8_t>(kWasmS128);
BUILD(r, BUILD(r,
WASM_SET_GLOBAL( WASM_SET_GLOBAL(
0, WASM_SIMD_LOAD_SPLAT_OFFSET(kExprS8x16LoadSplat, WASM_I32V(0), 0, WASM_SIMD_LOAD_OP_OFFSET(kExprS8x16LoadSplat, WASM_I32V(0),
U32V_2(offset))), U32V_2(offset))),
WASM_ONE); WASM_ONE);
...@@ -3491,7 +3491,7 @@ void RunLoadSplatTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -3491,7 +3491,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(r, WASM_SET_GLOBAL(0, WASM_SIMD_LOAD_OP(op, WASM_I32V(mem_index))),
WASM_ONE); WASM_ONE);
for (T x : compiler::ValueHelper::GetVector<T>()) { for (T x : compiler::ValueHelper::GetVector<T>()) {
...@@ -3534,7 +3534,7 @@ void RunLoadExtendTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -3534,7 +3534,7 @@ void RunLoadExtendTest(ExecutionTier execution_tier, LowerSimd 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, 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)), op, WASM_I32V(mem_index), alignment)),
WASM_ONE); WASM_ONE);
...@@ -3556,9 +3556,8 @@ void RunLoadExtendTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -3556,9 +3556,8 @@ void RunLoadExtendTest(ExecutionTier execution_tier, LowerSimd 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);
constexpr byte offset = sizeof(S); constexpr byte offset = sizeof(S);
BUILD( BUILD(r,
r, WASM_SET_GLOBAL(0, WASM_SIMD_LOAD_OP_OFFSET(op, WASM_ZERO, offset)),
WASM_SET_GLOBAL(0, WASM_SIMD_LOAD_EXTEND_OFFSET(op, WASM_ZERO, offset)),
WASM_ONE); WASM_ONE);
// Let max_s be the max_s value for type S, we set up the memory as such: // Let max_s be the max_s value for type S, we set up the memory as such:
...@@ -3620,9 +3619,7 @@ void RunLoadZeroTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -3620,9 +3619,7 @@ void RunLoadZeroTest(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));
S* global = r.builder().AddGlobal<S>(kWasmS128); S* global = r.builder().AddGlobal<S>(kWasmS128);
BUILD( BUILD(r, WASM_SET_GLOBAL(0, WASM_SIMD_LOAD_OP(op, WASM_I32V(mem_index))),
r,
WASM_SET_GLOBAL(0, WASM_SIMD_LOAD_ZERO_EXTEND(op, WASM_I32V(mem_index))),
WASM_ONE); WASM_ONE);
S sentinel = S{-1}; S sentinel = S{-1};
...@@ -3936,9 +3933,9 @@ WASM_EXTRACT_I16x8_TEST(S, UINT16) WASM_EXTRACT_I16x8_TEST(I, INT16) ...@@ -3936,9 +3933,9 @@ WASM_EXTRACT_I16x8_TEST(S, UINT16) WASM_EXTRACT_I16x8_TEST(I, INT16)
#undef WASM_SIMD_F64x2_QFMS #undef WASM_SIMD_F64x2_QFMS
#undef WASM_SIMD_F32x4_QFMA #undef WASM_SIMD_F32x4_QFMA
#undef WASM_SIMD_F32x4_QFMS #undef WASM_SIMD_F32x4_QFMS
#undef WASM_SIMD_LOAD_SPLAT #undef WASM_SIMD_LOAD_OP
#undef WASM_SIMD_LOAD_EXTEND #undef WASM_SIMD_LOAD_OP_OFFSET
#undef WASM_SIMD_LOAD_ZERO_EXTEND #undef WASM_SIMD_LOAD_OP_ALIGNMENT
} // namespace test_run_wasm_simd } // namespace test_run_wasm_simd
} // namespace wasm } // namespace wasm
......
...@@ -862,18 +862,13 @@ inline WasmOpcode LoadStoreOpcodeOf(MachineType type, bool store) { ...@@ -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_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_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 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 index, WASM_SIMD_OP(opcode), ZERO_ALIGNMENT, offset
#define WASM_SIMD_LOAD_EXTEND(opcode, index) \ #define WASM_SIMD_LOAD_OP_ALIGNMENT(opcode, index, alignment) \
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) \
index, WASM_SIMD_OP(opcode), alignment, ZERO_OFFSET 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. // 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