Skip to content

Commit

Permalink
[wasm-simd][liftoff][ia32][x64] Implement bitmask
Browse files Browse the repository at this point in the history
Implements i8x16 i16x8 i32x4 bitmask.

This was merged into the proposal in
WebAssembly/simd#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: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68090}
  • Loading branch information
ngzhian authored and Commit Bot committed Jun 1, 2020
1 parent c4be24e commit d04b5e4
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/wasm/baseline/arm/liftoff-assembler-arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
15 changes: 15 additions & 0 deletions src/wasm/baseline/arm64/liftoff-assembler-arm64.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>(
Expand Down Expand Up @@ -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>(
Expand Down Expand Up @@ -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>(
Expand Down
18 changes: 18 additions & 0 deletions src/wasm/baseline/ia32/liftoff-assembler-ia32.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions src/wasm/baseline/liftoff-assembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions src/wasm/baseline/liftoff-compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
18 changes: 18 additions & 0 deletions src/wasm/baseline/x64/liftoff-assembler-x64.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit d04b5e4

Please sign in to comment.