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

[wasm-simd] Implement load_extend in interpreter

Bug: v8:9886
Change-Id: I5ed8ad13a4c92b61cddb8d86ec97e242252a556e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1922231
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Reviewed-by: 's avatarBill Budge <bbudge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65056}
parent 03d23c48
......@@ -2654,6 +2654,30 @@ class ThreadImpl {
return DoSimdLoadSplat<int2, int64_t, int64_t>(
decoder, code, pc, len, MachineRepresentation::kWord64);
}
case kExprI16x8Load8x8S: {
return DoSimdLoadExtend<int8, int16_t, int8_t>(
decoder, code, pc, len, MachineRepresentation::kWord64);
}
case kExprI16x8Load8x8U: {
return DoSimdLoadExtend<int8, uint16_t, uint8_t>(
decoder, code, pc, len, MachineRepresentation::kWord64);
}
case kExprI32x4Load16x4S: {
return DoSimdLoadExtend<int4, int32_t, int16_t>(
decoder, code, pc, len, MachineRepresentation::kWord64);
}
case kExprI32x4Load16x4U: {
return DoSimdLoadExtend<int4, uint32_t, uint16_t>(
decoder, code, pc, len, MachineRepresentation::kWord64);
}
case kExprI64x2Load32x2S: {
return DoSimdLoadExtend<int2, int64_t, int32_t>(
decoder, code, pc, len, MachineRepresentation::kWord64);
}
case kExprI64x2Load32x2U: {
return DoSimdLoadExtend<int2, uint64_t, uint32_t>(
decoder, code, pc, len, MachineRepresentation::kWord64);
}
default:
return false;
}
......@@ -2673,6 +2697,27 @@ class ThreadImpl {
return true;
}
template <typename s_type, typename wide_type, typename narrow_type>
bool DoSimdLoadExtend(Decoder* decoder, InterpreterCode* code, pc_t pc,
int* const len, MachineRepresentation rep) {
static_assert(sizeof(wide_type) == sizeof(narrow_type) * 2,
"size mismatch for wide and narrow types");
if (!ExecuteLoad<uint64_t, uint64_t>(decoder, code, pc, len, rep,
/*prefix_len=*/1)) {
return false;
}
constexpr int lanes = kSimd128Size / sizeof(wide_type);
uint64_t v = Pop().to_u64();
s_type s;
for (int i = 0; i < lanes; i++) {
uint8_t shift = i * (sizeof(narrow_type) * 8);
narrow_type el = static_cast<narrow_type>(v >> shift);
s.val[i] = static_cast<wide_type>(el);
}
Push(WasmValue(Simd128(s)));
return true;
}
// Check if our control stack (frames_) exceeds the limit. Trigger stack
// overflow if it does, and unwinding the current frame.
// Returns true if execution can continue, false if the current activation was
......
......@@ -3307,10 +3307,6 @@ WASM_SIMD_TEST_NO_LOWERING(S64x2LoadSplat) {
template <typename S, typename T>
void RunLoadExtendTest(ExecutionTier execution_tier, LowerSimd lower_simd,
WasmOpcode op) {
if (execution_tier == ExecutionTier::kInterpreter) {
// TODO(zhin): implement for interpreter
return;
}
constexpr int lanes_s = 16 / sizeof(S);
constexpr int lanes_t = 16 / sizeof(T);
constexpr int mem_index = 16; // Load from mem index 16 (bytes).
......
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