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

[wasm-simd][liftoff][ia32][x64] Implement bitmask

Implements i8x16 i16x8 i32x4 bitmask.

This was merged into the proposal in
https://github.com/WebAssembly/simd/pull/201/.

Bug: v8:9909,v8:10308
Change-Id: I882f0c2697213cdf593e745112e0897cee252009
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2222607
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68090}
parent c4be24e3
......@@ -2573,6 +2573,11 @@ void LiftoffAssembler::emit_v32x4_alltrue(LiftoffRegister dst,
mov(dst.gp(), Operand(1), LeaveCC, ne);
}
void LiftoffAssembler::emit_i32x4_bitmask(LiftoffRegister dst,
LiftoffRegister src) {
bailout(kSimd, "i32x4_bitmask");
}
void LiftoffAssembler::emit_i32x4_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) {
liftoff::EmitSimdShift<liftoff::kLeft, NeonS32, Neon32>(this, dst, lhs, rhs);
......@@ -2682,6 +2687,11 @@ void LiftoffAssembler::emit_v16x8_alltrue(LiftoffRegister dst,
mov(dst.gp(), Operand(1), LeaveCC, ne);
}
void LiftoffAssembler::emit_i16x8_bitmask(LiftoffRegister dst,
LiftoffRegister src) {
bailout(kSimd, "i16x8_bitmask");
}
void LiftoffAssembler::emit_i16x8_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) {
liftoff::EmitSimdShift<liftoff::kLeft, NeonS16, Neon16>(this, dst, lhs, rhs);
......@@ -2864,6 +2874,11 @@ void LiftoffAssembler::emit_v8x16_alltrue(LiftoffRegister dst,
mov(dst.gp(), Operand(1), LeaveCC, ne);
}
void LiftoffAssembler::emit_i8x16_bitmask(LiftoffRegister dst,
LiftoffRegister src) {
bailout(kSimd, "i8x16_bitmask");
}
void LiftoffAssembler::emit_i8x16_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) {
liftoff::EmitSimdShift<liftoff::kLeft, NeonS8, Neon8>(this, dst, lhs, rhs);
......
......@@ -1513,6 +1513,11 @@ void LiftoffAssembler::emit_v32x4_alltrue(LiftoffRegister dst,
liftoff::EmitAllTrue(this, dst, src, kFormat4S);
}
void LiftoffAssembler::emit_i32x4_bitmask(LiftoffRegister dst,
LiftoffRegister src) {
bailout(kSimd, "i32x4_bitmask");
}
void LiftoffAssembler::emit_i32x4_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) {
liftoff::EmitSimdShift<liftoff::ShiftDirection::kLeft>(
......@@ -1634,6 +1639,11 @@ void LiftoffAssembler::emit_v16x8_alltrue(LiftoffRegister dst,
liftoff::EmitAllTrue(this, dst, src, kFormat8H);
}
void LiftoffAssembler::emit_i16x8_bitmask(LiftoffRegister dst,
LiftoffRegister src) {
bailout(kSimd, "i16x8_bitmask");
}
void LiftoffAssembler::emit_i16x8_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) {
liftoff::EmitSimdShift<liftoff::ShiftDirection::kLeft>(
......@@ -1779,6 +1789,11 @@ void LiftoffAssembler::emit_v8x16_alltrue(LiftoffRegister dst,
liftoff::EmitAllTrue(this, dst, src, kFormat16B);
}
void LiftoffAssembler::emit_i8x16_bitmask(LiftoffRegister dst,
LiftoffRegister src) {
bailout(kSimd, "i8x16_bitmask");
}
void LiftoffAssembler::emit_i8x16_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) {
liftoff::EmitSimdShift<liftoff::ShiftDirection::kLeft>(
......
......@@ -2552,6 +2552,11 @@ void LiftoffAssembler::emit_v8x16_alltrue(LiftoffRegister dst,
liftoff::EmitAllTrue<&TurboAssembler::Pcmpeqb>(this, dst, src);
}
void LiftoffAssembler::emit_i8x16_bitmask(LiftoffRegister dst,
LiftoffRegister src) {
Pmovmskb(dst.gp(), src.fp());
}
void LiftoffAssembler::emit_i8x16_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) {
static constexpr RegClass tmp_rc = reg_class_for(ValueType::kI32);
......@@ -2790,6 +2795,14 @@ void LiftoffAssembler::emit_v16x8_alltrue(LiftoffRegister dst,
liftoff::EmitAllTrue<&TurboAssembler::Pcmpeqw>(this, dst, src);
}
void LiftoffAssembler::emit_i16x8_bitmask(LiftoffRegister dst,
LiftoffRegister src) {
XMMRegister tmp = liftoff::kScratchDoubleReg;
Packsswb(tmp, src.fp());
Pmovmskb(dst.gp(), tmp);
shr(dst.gp(), 8);
}
void LiftoffAssembler::emit_i16x8_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) {
liftoff::EmitSimdShiftOp<&Assembler::vpsllw, &Assembler::psllw, 4>(this, dst,
......@@ -2924,6 +2937,11 @@ void LiftoffAssembler::emit_v32x4_alltrue(LiftoffRegister dst,
liftoff::EmitAllTrue<&TurboAssembler::Pcmpeqd>(this, dst, src);
}
void LiftoffAssembler::emit_i32x4_bitmask(LiftoffRegister dst,
LiftoffRegister src) {
Movmskps(dst.gp(), src.fp());
}
void LiftoffAssembler::emit_i32x4_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) {
liftoff::EmitSimdShiftOp<&Assembler::vpslld, &Assembler::pslld, 5>(this, dst,
......
......@@ -818,6 +818,7 @@ class LiftoffAssembler : public TurboAssembler {
inline void emit_i8x16_neg(LiftoffRegister dst, LiftoffRegister src);
inline void emit_v8x16_anytrue(LiftoffRegister dst, LiftoffRegister src);
inline void emit_v8x16_alltrue(LiftoffRegister dst, LiftoffRegister src);
inline void emit_i8x16_bitmask(LiftoffRegister dst, LiftoffRegister src);
inline void emit_i8x16_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs);
inline void emit_i8x16_shli(LiftoffRegister dst, LiftoffRegister lhs,
......@@ -859,6 +860,7 @@ class LiftoffAssembler : public TurboAssembler {
inline void emit_i16x8_neg(LiftoffRegister dst, LiftoffRegister src);
inline void emit_v16x8_anytrue(LiftoffRegister dst, LiftoffRegister src);
inline void emit_v16x8_alltrue(LiftoffRegister dst, LiftoffRegister src);
inline void emit_i16x8_bitmask(LiftoffRegister dst, LiftoffRegister src);
inline void emit_i16x8_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs);
inline void emit_i16x8_shli(LiftoffRegister dst, LiftoffRegister lhs,
......@@ -900,6 +902,7 @@ class LiftoffAssembler : public TurboAssembler {
inline void emit_i32x4_neg(LiftoffRegister dst, LiftoffRegister src);
inline void emit_v32x4_anytrue(LiftoffRegister dst, LiftoffRegister src);
inline void emit_v32x4_alltrue(LiftoffRegister dst, LiftoffRegister src);
inline void emit_i32x4_bitmask(LiftoffRegister dst, LiftoffRegister src);
inline void emit_i32x4_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs);
inline void emit_i32x4_shli(LiftoffRegister dst, LiftoffRegister lhs,
......
......@@ -2579,6 +2579,8 @@ class LiftoffCompiler {
return EmitUnOp<kS128, kI32>(&LiftoffAssembler::emit_v8x16_anytrue);
case wasm::kExprV8x16AllTrue:
return EmitUnOp<kS128, kI32>(&LiftoffAssembler::emit_v8x16_alltrue);
case wasm::kExprI8x16BitMask:
return EmitUnOp<kS128, kI32>(&LiftoffAssembler::emit_i8x16_bitmask);
case wasm::kExprI8x16Shl:
return EmitSimdShiftOp(&LiftoffAssembler::emit_i8x16_shl,
&LiftoffAssembler::emit_i8x16_shli);
......@@ -2620,6 +2622,8 @@ class LiftoffCompiler {
return EmitUnOp<kS128, kI32>(&LiftoffAssembler::emit_v16x8_anytrue);
case wasm::kExprV16x8AllTrue:
return EmitUnOp<kS128, kI32>(&LiftoffAssembler::emit_v16x8_alltrue);
case wasm::kExprI16x8BitMask:
return EmitUnOp<kS128, kI32>(&LiftoffAssembler::emit_i16x8_bitmask);
case wasm::kExprI16x8Shl:
return EmitSimdShiftOp(&LiftoffAssembler::emit_i16x8_shl,
&LiftoffAssembler::emit_i16x8_shli);
......@@ -2661,6 +2665,8 @@ class LiftoffCompiler {
return EmitUnOp<kS128, kI32>(&LiftoffAssembler::emit_v32x4_anytrue);
case wasm::kExprV32x4AllTrue:
return EmitUnOp<kS128, kI32>(&LiftoffAssembler::emit_v32x4_alltrue);
case wasm::kExprI32x4BitMask:
return EmitUnOp<kS128, kI32>(&LiftoffAssembler::emit_i32x4_bitmask);
case wasm::kExprI32x4Shl:
return EmitSimdShiftOp(&LiftoffAssembler::emit_i32x4_shl,
&LiftoffAssembler::emit_i32x4_shli);
......
......@@ -2591,6 +2591,11 @@ void LiftoffAssembler::emit_v8x16_alltrue(LiftoffRegister dst,
liftoff::EmitAllTrue<&TurboAssembler::Pcmpeqb>(this, dst, src);
}
void LiftoffAssembler::emit_i8x16_bitmask(LiftoffRegister dst,
LiftoffRegister src) {
Pmovmskb(dst.gp(), src.fp());
}
void LiftoffAssembler::emit_i8x16_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) {
static constexpr RegClass tmp_simd_rc = reg_class_for(ValueType::kS128);
......@@ -2830,6 +2835,14 @@ void LiftoffAssembler::emit_v16x8_alltrue(LiftoffRegister dst,
liftoff::EmitAllTrue<&TurboAssembler::Pcmpeqw>(this, dst, src);
}
void LiftoffAssembler::emit_i16x8_bitmask(LiftoffRegister dst,
LiftoffRegister src) {
XMMRegister tmp = kScratchDoubleReg;
Packsswb(tmp, src.fp());
Pmovmskb(dst.gp(), tmp);
shrq(dst.gp(), Immediate(8));
}
void LiftoffAssembler::emit_i16x8_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) {
liftoff::EmitSimdShiftOp<&Assembler::vpsllw, &Assembler::psllw, 4>(this, dst,
......@@ -2964,6 +2977,11 @@ void LiftoffAssembler::emit_v32x4_alltrue(LiftoffRegister dst,
liftoff::EmitAllTrue<&TurboAssembler::Pcmpeqd>(this, dst, src);
}
void LiftoffAssembler::emit_i32x4_bitmask(LiftoffRegister dst,
LiftoffRegister src) {
Movmskps(dst.gp(), src.fp());
}
void LiftoffAssembler::emit_i32x4_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) {
liftoff::EmitSimdShiftOp<&Assembler::vpslld, &Assembler::pslld, 5>(this, dst,
......
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