Commit 5af79398 authored by Zhi An Ng's avatar Zhi An Ng Committed by Commit Bot

[wasm-simd][liftoff][x64] Prototype load lane

Prototype load lane instructions on Liftoff, only for x64.

Bug: v8:10975
Change-Id: Ifdf58f08b65762d592e99de91c7c622d2a964a9a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2612335
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarBill Budge <bbudge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71980}
parent 9b057ef1
...@@ -2356,6 +2356,13 @@ void LiftoffAssembler::LoadTransform(LiftoffRegister dst, Register src_addr, ...@@ -2356,6 +2356,13 @@ void LiftoffAssembler::LoadTransform(LiftoffRegister dst, Register src_addr,
} }
} }
void LiftoffAssembler::LoadLane(LiftoffRegister dst, LiftoffRegister src,
Register addr, Register offset_reg,
uintptr_t offset_imm, LoadType type,
uint8_t laneidx, uint32_t* protected_load_pc) {
bailout(kSimd, "loadlane");
}
void LiftoffAssembler::emit_i8x16_swizzle(LiftoffRegister dst, void LiftoffAssembler::emit_i8x16_swizzle(LiftoffRegister dst,
LiftoffRegister lhs, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
......
...@@ -1630,6 +1630,13 @@ void LiftoffAssembler::LoadTransform(LiftoffRegister dst, Register src_addr, ...@@ -1630,6 +1630,13 @@ void LiftoffAssembler::LoadTransform(LiftoffRegister dst, Register src_addr,
} }
} }
void LiftoffAssembler::LoadLane(LiftoffRegister dst, LiftoffRegister src,
Register addr, Register offset_reg,
uintptr_t offset_imm, LoadType type,
uint8_t laneidx, uint32_t* protected_load_pc) {
bailout(kSimd, "loadlane");
}
void LiftoffAssembler::emit_i8x16_swizzle(LiftoffRegister dst, void LiftoffAssembler::emit_i8x16_swizzle(LiftoffRegister dst,
LiftoffRegister lhs, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
......
...@@ -2758,6 +2758,13 @@ void LiftoffAssembler::LoadTransform(LiftoffRegister dst, Register src_addr, ...@@ -2758,6 +2758,13 @@ void LiftoffAssembler::LoadTransform(LiftoffRegister dst, Register src_addr,
} }
} }
void LiftoffAssembler::LoadLane(LiftoffRegister dst, LiftoffRegister src,
Register addr, Register offset_reg,
uintptr_t offset_imm, LoadType type,
uint8_t laneidx, uint32_t* protected_load_pc) {
bailout(kSimd, "loadlane");
}
void LiftoffAssembler::emit_i8x16_shuffle(LiftoffRegister dst, void LiftoffAssembler::emit_i8x16_shuffle(LiftoffRegister dst,
LiftoffRegister lhs, LiftoffRegister lhs,
LiftoffRegister rhs, LiftoffRegister rhs,
......
...@@ -871,6 +871,9 @@ class LiftoffAssembler : public TurboAssembler { ...@@ -871,6 +871,9 @@ class LiftoffAssembler : public TurboAssembler {
Register offset_reg, uintptr_t offset_imm, Register offset_reg, uintptr_t offset_imm,
LoadType type, LoadTransformationKind transform, LoadType type, LoadTransformationKind transform,
uint32_t* protected_load_pc); uint32_t* protected_load_pc);
inline void LoadLane(LiftoffRegister dst, LiftoffRegister src, Register addr,
Register offset_reg, uintptr_t offset_imm, LoadType type,
uint8_t lane, uint32_t* protected_load_pc);
inline void emit_i8x16_shuffle(LiftoffRegister dst, LiftoffRegister lhs, inline void emit_i8x16_shuffle(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs, const uint8_t shuffle[16], LiftoffRegister rhs, const uint8_t shuffle[16],
bool is_swizzle); bool is_swizzle);
......
...@@ -2461,10 +2461,43 @@ class LiftoffCompiler { ...@@ -2461,10 +2461,43 @@ class LiftoffCompiler {
} }
} }
void LoadLane(FullDecoder* decoder, LoadType type, const Value& value, void LoadLane(FullDecoder* decoder, LoadType type, const Value& _value,
const Value& index, const MemoryAccessImmediate<validate>& imm, const Value& _index, const MemoryAccessImmediate<validate>& imm,
const uint8_t laneidx, Value* result) { const uint8_t laneidx, Value* _result) {
unsupported(decoder, kSimd, "simd load lane"); if (!CheckSupportedType(decoder, kWasmS128, "LoadLane")) {
return;
}
LiftoffRegList pinned;
LiftoffRegister value = pinned.set(__ PopToRegister());
Register index = pinned.set(__ PopToRegister()).gp();
if (BoundsCheckMem(decoder, type.size(), imm.offset, index, pinned,
kDontForceCheck)) {
return;
}
uintptr_t offset = imm.offset;
index = AddMemoryMasking(index, &offset, &pinned);
DEBUG_CODE_COMMENT("load lane");
Register addr = __ GetUnusedRegister(kGpReg, pinned).gp();
LOAD_INSTANCE_FIELD(addr, MemoryStart, kSystemPointerSize);
LiftoffRegister result = __ GetUnusedRegister(reg_class_for(kS128), {});
uint32_t protected_load_pc = 0;
__ LoadLane(result, value, addr, index, offset, type, laneidx,
&protected_load_pc);
if (env_->use_trap_handler) {
AddOutOfLineTrap(decoder->position(),
WasmCode::kThrowWasmTrapMemOutOfBounds,
protected_load_pc);
}
__ PushRegister(ValueType::Primitive(kS128), result);
if (FLAG_trace_wasm_memory) {
TraceMemoryOperation(false, type.mem_type().representation(), index,
offset, decoder->position());
}
} }
void StoreMem(FullDecoder* decoder, StoreType type, void StoreMem(FullDecoder* decoder, StoreType type,
......
...@@ -2401,6 +2401,29 @@ void LiftoffAssembler::LoadTransform(LiftoffRegister dst, Register src_addr, ...@@ -2401,6 +2401,29 @@ void LiftoffAssembler::LoadTransform(LiftoffRegister dst, Register src_addr,
} }
} }
void LiftoffAssembler::LoadLane(LiftoffRegister dst, LiftoffRegister src,
Register addr, Register offset_reg,
uintptr_t offset_imm, LoadType type,
uint8_t laneidx, uint32_t* protected_load_pc) {
if (emit_debug_code() && offset_reg != no_reg) {
AssertZeroExtended(offset_reg);
}
Operand src_op = liftoff::GetMemOp(this, addr, offset_reg, offset_imm);
*protected_load_pc = pc_offset();
MachineType mem_type = type.mem_type();
if (mem_type == MachineType::Int8()) {
Pinsrb(dst.fp(), src.fp(), src_op, laneidx);
} else if (mem_type == MachineType::Int16()) {
Pinsrw(dst.fp(), src.fp(), src_op, laneidx);
} else if (mem_type == MachineType::Int32()) {
Pinsrd(dst.fp(), src.fp(), src_op, laneidx);
} else {
DCHECK_EQ(MachineType::Int64(), mem_type);
Pinsrq(dst.fp(), src.fp(), src_op, laneidx);
}
}
void LiftoffAssembler::emit_i8x16_shuffle(LiftoffRegister dst, void LiftoffAssembler::emit_i8x16_shuffle(LiftoffRegister dst,
LiftoffRegister lhs, LiftoffRegister lhs,
LiftoffRegister rhs, LiftoffRegister rhs,
......
...@@ -4009,11 +4009,6 @@ template <typename T> ...@@ -4009,11 +4009,6 @@ template <typename T>
void RunLoadLaneTest(TestExecutionTier execution_tier, LowerSimd lower_simd, void RunLoadLaneTest(TestExecutionTier execution_tier, LowerSimd lower_simd,
WasmOpcode load_op, WasmOpcode splat_op) { WasmOpcode load_op, WasmOpcode splat_op) {
FLAG_SCOPE(wasm_simd_post_mvp); FLAG_SCOPE(wasm_simd_post_mvp);
if (execution_tier == TestExecutionTier::kLiftoff) {
// Not yet implemented.
return;
}
WasmOpcode const_op = WasmOpcode const_op =
splat_op == kExprI64x2Splat ? kExprI64Const : kExprI32Const; splat_op == kExprI64x2Splat ? kExprI64Const : kExprI32Const;
......
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