Commit 445f9ef1 authored by Zhou, Zhiguo's avatar Zhou, Zhiguo Committed by Commit Bot

[wasm-simd][liftoff] Implement neg on x64 and ia32

Bug: v8:9909
Change-Id: I21980ee97e0d2483c064e40cae181297b4d563a1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2107511
Commit-Queue: Zhiguo Zhou <zhiguo.zhou@intel.com>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarZhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67096}
parent bd04ee08
...@@ -1578,6 +1578,11 @@ void LiftoffAssembler::emit_f64x2_replace_lane(LiftoffRegister dst, ...@@ -1578,6 +1578,11 @@ void LiftoffAssembler::emit_f64x2_replace_lane(LiftoffRegister dst,
liftoff::GetSimd128Register(src1), src2.fp(), imm_lane_idx); liftoff::GetSimd128Register(src1), src2.fp(), imm_lane_idx);
} }
void LiftoffAssembler::emit_f64x2_neg(LiftoffRegister dst,
LiftoffRegister src) {
bailout(kSimd, "f64x2neg");
}
void LiftoffAssembler::emit_f64x2_add(LiftoffRegister dst, LiftoffRegister lhs, void LiftoffAssembler::emit_f64x2_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
vadd(dst.low_fp(), lhs.low_fp(), rhs.low_fp()); vadd(dst.low_fp(), lhs.low_fp(), rhs.low_fp());
...@@ -1617,6 +1622,11 @@ void LiftoffAssembler::emit_f32x4_replace_lane(LiftoffRegister dst, ...@@ -1617,6 +1622,11 @@ void LiftoffAssembler::emit_f32x4_replace_lane(LiftoffRegister dst,
liftoff::GetFloatRegister(src2.fp()), imm_lane_idx); liftoff::GetFloatRegister(src2.fp()), imm_lane_idx);
} }
void LiftoffAssembler::emit_f32x4_neg(LiftoffRegister dst,
LiftoffRegister src) {
bailout(kSimd, "f32x4neg");
}
void LiftoffAssembler::emit_f32x4_add(LiftoffRegister dst, LiftoffRegister lhs, void LiftoffAssembler::emit_f32x4_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
vadd(liftoff::GetSimd128Register(dst), liftoff::GetSimd128Register(lhs), vadd(liftoff::GetSimd128Register(dst), liftoff::GetSimd128Register(lhs),
...@@ -1663,6 +1673,11 @@ void LiftoffAssembler::emit_i64x2_replace_lane(LiftoffRegister dst, ...@@ -1663,6 +1673,11 @@ void LiftoffAssembler::emit_i64x2_replace_lane(LiftoffRegister dst,
imm_lane_idx * 2 + 1); imm_lane_idx * 2 + 1);
} }
void LiftoffAssembler::emit_i64x2_neg(LiftoffRegister dst,
LiftoffRegister src) {
bailout(kSimd, "i64x2neg");
}
void LiftoffAssembler::emit_i64x2_add(LiftoffRegister dst, LiftoffRegister lhs, void LiftoffAssembler::emit_i64x2_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
vadd(Neon64, liftoff::GetSimd128Register(dst), vadd(Neon64, liftoff::GetSimd128Register(dst),
...@@ -1739,6 +1754,11 @@ void LiftoffAssembler::emit_i32x4_replace_lane(LiftoffRegister dst, ...@@ -1739,6 +1754,11 @@ void LiftoffAssembler::emit_i32x4_replace_lane(LiftoffRegister dst,
imm_lane_idx); imm_lane_idx);
} }
void LiftoffAssembler::emit_i32x4_neg(LiftoffRegister dst,
LiftoffRegister src) {
bailout(kSimd, "i32x4neg");
}
void LiftoffAssembler::emit_i32x4_add(LiftoffRegister dst, LiftoffRegister lhs, void LiftoffAssembler::emit_i32x4_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
vadd(Neon32, liftoff::GetSimd128Register(dst), vadd(Neon32, liftoff::GetSimd128Register(dst),
...@@ -1790,6 +1810,11 @@ void LiftoffAssembler::emit_i16x8_splat(LiftoffRegister dst, ...@@ -1790,6 +1810,11 @@ void LiftoffAssembler::emit_i16x8_splat(LiftoffRegister dst,
vdup(Neon16, liftoff::GetSimd128Register(dst), src.gp()); vdup(Neon16, liftoff::GetSimd128Register(dst), src.gp());
} }
void LiftoffAssembler::emit_i16x8_neg(LiftoffRegister dst,
LiftoffRegister src) {
bailout(kSimd, "i16x8neg");
}
void LiftoffAssembler::emit_i16x8_add(LiftoffRegister dst, LiftoffRegister lhs, void LiftoffAssembler::emit_i16x8_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
vadd(Neon16, liftoff::GetSimd128Register(dst), vadd(Neon16, liftoff::GetSimd128Register(dst),
...@@ -1899,6 +1924,11 @@ void LiftoffAssembler::emit_i8x16_replace_lane(LiftoffRegister dst, ...@@ -1899,6 +1924,11 @@ void LiftoffAssembler::emit_i8x16_replace_lane(LiftoffRegister dst,
imm_lane_idx); imm_lane_idx);
} }
void LiftoffAssembler::emit_i8x16_neg(LiftoffRegister dst,
LiftoffRegister src) {
bailout(kSimd, "i8x16neg");
}
void LiftoffAssembler::emit_i8x16_add(LiftoffRegister dst, LiftoffRegister lhs, void LiftoffAssembler::emit_i8x16_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
vadd(Neon8, liftoff::GetSimd128Register(dst), vadd(Neon8, liftoff::GetSimd128Register(dst),
......
...@@ -1105,6 +1105,11 @@ void LiftoffAssembler::emit_f64x2_replace_lane(LiftoffRegister dst, ...@@ -1105,6 +1105,11 @@ void LiftoffAssembler::emit_f64x2_replace_lane(LiftoffRegister dst,
Mov(dst.fp().V2D(), imm_lane_idx, src2.fp().V2D(), 0); Mov(dst.fp().V2D(), imm_lane_idx, src2.fp().V2D(), 0);
} }
void LiftoffAssembler::emit_f64x2_neg(LiftoffRegister dst,
LiftoffRegister src) {
bailout(kSimd, "f64x2neg");
}
void LiftoffAssembler::emit_f64x2_add(LiftoffRegister dst, LiftoffRegister lhs, void LiftoffAssembler::emit_f64x2_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
Fadd(dst.fp().V2D(), lhs.fp().V2D(), rhs.fp().V2D()); Fadd(dst.fp().V2D(), lhs.fp().V2D(), rhs.fp().V2D());
...@@ -1141,6 +1146,11 @@ void LiftoffAssembler::emit_f32x4_replace_lane(LiftoffRegister dst, ...@@ -1141,6 +1146,11 @@ void LiftoffAssembler::emit_f32x4_replace_lane(LiftoffRegister dst,
Mov(dst.fp().V4S(), imm_lane_idx, src2.fp().V4S(), 0); Mov(dst.fp().V4S(), imm_lane_idx, src2.fp().V4S(), 0);
} }
void LiftoffAssembler::emit_f32x4_neg(LiftoffRegister dst,
LiftoffRegister src) {
bailout(kSimd, "f32x4neg");
}
void LiftoffAssembler::emit_f32x4_add(LiftoffRegister dst, LiftoffRegister lhs, void LiftoffAssembler::emit_f32x4_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
Fadd(dst.fp().V4S(), lhs.fp().V4S(), rhs.fp().V4S()); Fadd(dst.fp().V4S(), lhs.fp().V4S(), rhs.fp().V4S());
...@@ -1177,6 +1187,11 @@ void LiftoffAssembler::emit_i64x2_replace_lane(LiftoffRegister dst, ...@@ -1177,6 +1187,11 @@ void LiftoffAssembler::emit_i64x2_replace_lane(LiftoffRegister dst,
Mov(dst.fp().V2D(), imm_lane_idx, src2.gp().X()); Mov(dst.fp().V2D(), imm_lane_idx, src2.gp().X());
} }
void LiftoffAssembler::emit_i64x2_neg(LiftoffRegister dst,
LiftoffRegister src) {
bailout(kSimd, "i64x2neg");
}
void LiftoffAssembler::emit_i64x2_add(LiftoffRegister dst, LiftoffRegister lhs, void LiftoffAssembler::emit_i64x2_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
Add(dst.fp().V2D(), lhs.fp().V2D(), rhs.fp().V2D()); Add(dst.fp().V2D(), lhs.fp().V2D(), rhs.fp().V2D());
...@@ -1229,6 +1244,11 @@ void LiftoffAssembler::emit_i32x4_replace_lane(LiftoffRegister dst, ...@@ -1229,6 +1244,11 @@ void LiftoffAssembler::emit_i32x4_replace_lane(LiftoffRegister dst,
Mov(dst.fp().V4S(), imm_lane_idx, src2.gp().W()); Mov(dst.fp().V4S(), imm_lane_idx, src2.gp().W());
} }
void LiftoffAssembler::emit_i32x4_neg(LiftoffRegister dst,
LiftoffRegister src) {
bailout(kSimd, "i32x4neg");
}
void LiftoffAssembler::emit_i32x4_add(LiftoffRegister dst, LiftoffRegister lhs, void LiftoffAssembler::emit_i32x4_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
Add(dst.fp().V4S(), lhs.fp().V4S(), rhs.fp().V4S()); Add(dst.fp().V4S(), lhs.fp().V4S(), rhs.fp().V4S());
...@@ -1295,6 +1315,11 @@ void LiftoffAssembler::emit_i16x8_replace_lane(LiftoffRegister dst, ...@@ -1295,6 +1315,11 @@ void LiftoffAssembler::emit_i16x8_replace_lane(LiftoffRegister dst,
Mov(dst.fp().V8H(), imm_lane_idx, src2.gp().W()); Mov(dst.fp().V8H(), imm_lane_idx, src2.gp().W());
} }
void LiftoffAssembler::emit_i16x8_neg(LiftoffRegister dst,
LiftoffRegister src) {
bailout(kSimd, "i16x8neg");
}
void LiftoffAssembler::emit_i16x8_add(LiftoffRegister dst, LiftoffRegister lhs, void LiftoffAssembler::emit_i16x8_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
Add(dst.fp().V8H(), lhs.fp().V8H(), rhs.fp().V8H()); Add(dst.fp().V8H(), lhs.fp().V8H(), rhs.fp().V8H());
...@@ -1373,6 +1398,11 @@ void LiftoffAssembler::emit_i8x16_replace_lane(LiftoffRegister dst, ...@@ -1373,6 +1398,11 @@ void LiftoffAssembler::emit_i8x16_replace_lane(LiftoffRegister dst,
Mov(dst.fp().V16B(), imm_lane_idx, src2.gp().W()); Mov(dst.fp().V16B(), imm_lane_idx, src2.gp().W());
} }
void LiftoffAssembler::emit_i8x16_neg(LiftoffRegister dst,
LiftoffRegister src) {
bailout(kSimd, "i8x16neg");
}
void LiftoffAssembler::emit_i8x16_add(LiftoffRegister dst, LiftoffRegister lhs, void LiftoffAssembler::emit_i8x16_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
Add(dst.fp().V16B(), lhs.fp().V16B(), rhs.fp().V16B()); Add(dst.fp().V16B(), lhs.fp().V16B(), rhs.fp().V16B());
......
...@@ -2013,6 +2013,17 @@ void LiftoffAssembler::emit_f64x2_splat(LiftoffRegister dst, ...@@ -2013,6 +2013,17 @@ void LiftoffAssembler::emit_f64x2_splat(LiftoffRegister dst,
Movddup(dst.fp(), src.fp()); Movddup(dst.fp(), src.fp());
} }
void LiftoffAssembler::emit_i8x16_neg(LiftoffRegister dst,
LiftoffRegister src) {
if (dst.fp() == src.fp()) {
Pcmpeqd(liftoff::kScratchDoubleReg, liftoff::kScratchDoubleReg);
Psignb(dst.fp(), liftoff::kScratchDoubleReg);
} else {
Pxor(dst.fp(), dst.fp());
Psubb(dst.fp(), src.fp());
}
}
void LiftoffAssembler::emit_i8x16_add(LiftoffRegister dst, LiftoffRegister lhs, void LiftoffAssembler::emit_i8x16_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
liftoff::EmitSimdCommutativeBinOp<&Assembler::vpaddb, &Assembler::paddb>( liftoff::EmitSimdCommutativeBinOp<&Assembler::vpaddb, &Assembler::paddb>(
...@@ -2129,6 +2140,17 @@ void LiftoffAssembler::emit_i8x16_max_u(LiftoffRegister dst, ...@@ -2129,6 +2140,17 @@ void LiftoffAssembler::emit_i8x16_max_u(LiftoffRegister dst,
this, dst, lhs, rhs); this, dst, lhs, rhs);
} }
void LiftoffAssembler::emit_i16x8_neg(LiftoffRegister dst,
LiftoffRegister src) {
if (dst.fp() == src.fp()) {
Pcmpeqd(liftoff::kScratchDoubleReg, liftoff::kScratchDoubleReg);
Psignw(dst.fp(), liftoff::kScratchDoubleReg);
} else {
Pxor(dst.fp(), dst.fp());
Psubw(dst.fp(), src.fp());
}
}
void LiftoffAssembler::emit_i16x8_add(LiftoffRegister dst, LiftoffRegister lhs, void LiftoffAssembler::emit_i16x8_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
liftoff::EmitSimdCommutativeBinOp<&Assembler::vpaddw, &Assembler::paddw>( liftoff::EmitSimdCommutativeBinOp<&Assembler::vpaddw, &Assembler::paddw>(
...@@ -2189,6 +2211,17 @@ void LiftoffAssembler::emit_i16x8_max_u(LiftoffRegister dst, ...@@ -2189,6 +2211,17 @@ void LiftoffAssembler::emit_i16x8_max_u(LiftoffRegister dst,
this, dst, lhs, rhs, base::Optional<CpuFeature>(SSE4_1)); this, dst, lhs, rhs, base::Optional<CpuFeature>(SSE4_1));
} }
void LiftoffAssembler::emit_i32x4_neg(LiftoffRegister dst,
LiftoffRegister src) {
if (dst.fp() == src.fp()) {
Pcmpeqd(liftoff::kScratchDoubleReg, liftoff::kScratchDoubleReg);
Psignd(dst.fp(), liftoff::kScratchDoubleReg);
} else {
Pxor(dst.fp(), dst.fp());
Psubd(dst.fp(), src.fp());
}
}
void LiftoffAssembler::emit_i32x4_add(LiftoffRegister dst, LiftoffRegister lhs, void LiftoffAssembler::emit_i32x4_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
liftoff::EmitSimdCommutativeBinOp<&Assembler::vpaddd, &Assembler::paddd>( liftoff::EmitSimdCommutativeBinOp<&Assembler::vpaddd, &Assembler::paddd>(
...@@ -2235,6 +2268,20 @@ void LiftoffAssembler::emit_i32x4_max_u(LiftoffRegister dst, ...@@ -2235,6 +2268,20 @@ void LiftoffAssembler::emit_i32x4_max_u(LiftoffRegister dst,
this, dst, lhs, rhs, base::Optional<CpuFeature>(SSE4_1)); this, dst, lhs, rhs, base::Optional<CpuFeature>(SSE4_1));
} }
void LiftoffAssembler::emit_i64x2_neg(LiftoffRegister dst,
LiftoffRegister src) {
DoubleRegister reg =
dst.fp() == src.fp() ? liftoff::kScratchDoubleReg : dst.fp();
Pxor(reg, reg);
if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope scope(this, AVX);
vpsubq(dst.fp(), reg, src.fp());
} else {
psubq(reg, src.fp());
if (dst.fp() != reg) movapd(dst.fp(), reg);
}
}
void LiftoffAssembler::emit_i64x2_add(LiftoffRegister dst, LiftoffRegister lhs, void LiftoffAssembler::emit_i64x2_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
liftoff::EmitSimdCommutativeBinOp<&Assembler::vpaddq, &Assembler::paddq>( liftoff::EmitSimdCommutativeBinOp<&Assembler::vpaddq, &Assembler::paddq>(
...@@ -2274,6 +2321,19 @@ void LiftoffAssembler::emit_i64x2_mul(LiftoffRegister dst, LiftoffRegister lhs, ...@@ -2274,6 +2321,19 @@ void LiftoffAssembler::emit_i64x2_mul(LiftoffRegister dst, LiftoffRegister lhs,
Paddq(dst.fp(), dst.fp(), tmp2.fp()); Paddq(dst.fp(), dst.fp(), tmp2.fp());
} }
void LiftoffAssembler::emit_f32x4_neg(LiftoffRegister dst,
LiftoffRegister src) {
if (dst.fp() == src.fp()) {
Pcmpeqd(liftoff::kScratchDoubleReg, liftoff::kScratchDoubleReg);
Pslld(liftoff::kScratchDoubleReg, liftoff::kScratchDoubleReg, 31);
Xorps(dst.fp(), liftoff::kScratchDoubleReg);
} else {
Pcmpeqd(dst.fp(), dst.fp());
Pslld(dst.fp(), dst.fp(), 31);
Xorps(dst.fp(), src.fp());
}
}
void LiftoffAssembler::emit_f32x4_add(LiftoffRegister dst, LiftoffRegister lhs, void LiftoffAssembler::emit_f32x4_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
liftoff::EmitSimdCommutativeBinOp<&Assembler::vaddps, &Assembler::addps>( liftoff::EmitSimdCommutativeBinOp<&Assembler::vaddps, &Assembler::addps>(
...@@ -2292,6 +2352,19 @@ void LiftoffAssembler::emit_f32x4_mul(LiftoffRegister dst, LiftoffRegister lhs, ...@@ -2292,6 +2352,19 @@ void LiftoffAssembler::emit_f32x4_mul(LiftoffRegister dst, LiftoffRegister lhs,
this, dst, lhs, rhs); this, dst, lhs, rhs);
} }
void LiftoffAssembler::emit_f64x2_neg(LiftoffRegister dst,
LiftoffRegister src) {
if (dst.fp() == src.fp()) {
Pcmpeqd(liftoff::kScratchDoubleReg, liftoff::kScratchDoubleReg);
Psllq(liftoff::kScratchDoubleReg, liftoff::kScratchDoubleReg, 63);
Xorpd(dst.fp(), liftoff::kScratchDoubleReg);
} else {
Pcmpeqd(dst.fp(), dst.fp());
Psllq(dst.fp(), dst.fp(), 63);
Xorpd(dst.fp(), src.fp());
}
}
void LiftoffAssembler::emit_f64x2_add(LiftoffRegister dst, LiftoffRegister lhs, void LiftoffAssembler::emit_f64x2_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
liftoff::EmitSimdCommutativeBinOp<&Assembler::vaddpd, &Assembler::addpd>( liftoff::EmitSimdCommutativeBinOp<&Assembler::vaddpd, &Assembler::addpd>(
......
...@@ -721,6 +721,7 @@ class LiftoffAssembler : public TurboAssembler { ...@@ -721,6 +721,7 @@ class LiftoffAssembler : public TurboAssembler {
inline void emit_i64x2_splat(LiftoffRegister dst, LiftoffRegister src); inline void emit_i64x2_splat(LiftoffRegister dst, LiftoffRegister src);
inline void emit_f32x4_splat(LiftoffRegister dst, LiftoffRegister src); inline void emit_f32x4_splat(LiftoffRegister dst, LiftoffRegister src);
inline void emit_f64x2_splat(LiftoffRegister dst, LiftoffRegister src); inline void emit_f64x2_splat(LiftoffRegister dst, LiftoffRegister src);
inline void emit_i8x16_neg(LiftoffRegister dst, LiftoffRegister src);
inline void emit_i8x16_add(LiftoffRegister dst, LiftoffRegister lhs, inline void emit_i8x16_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs); LiftoffRegister rhs);
inline void emit_i8x16_add_saturate_s(LiftoffRegister dst, inline void emit_i8x16_add_saturate_s(LiftoffRegister dst,
...@@ -741,6 +742,7 @@ class LiftoffAssembler : public TurboAssembler { ...@@ -741,6 +742,7 @@ class LiftoffAssembler : public TurboAssembler {
LiftoffRegister rhs); LiftoffRegister rhs);
inline void emit_i8x16_max_u(LiftoffRegister dst, LiftoffRegister lhs, inline void emit_i8x16_max_u(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs); LiftoffRegister rhs);
inline void emit_i16x8_neg(LiftoffRegister dst, LiftoffRegister src);
inline void emit_i16x8_add(LiftoffRegister dst, LiftoffRegister lhs, inline void emit_i16x8_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs); LiftoffRegister rhs);
inline void emit_i16x8_add_saturate_s(LiftoffRegister dst, inline void emit_i16x8_add_saturate_s(LiftoffRegister dst,
...@@ -761,6 +763,7 @@ class LiftoffAssembler : public TurboAssembler { ...@@ -761,6 +763,7 @@ class LiftoffAssembler : public TurboAssembler {
LiftoffRegister rhs); LiftoffRegister rhs);
inline void emit_i16x8_max_u(LiftoffRegister dst, LiftoffRegister lhs, inline void emit_i16x8_max_u(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs); LiftoffRegister rhs);
inline void emit_i32x4_neg(LiftoffRegister dst, LiftoffRegister src);
inline void emit_i32x4_add(LiftoffRegister dst, LiftoffRegister lhs, inline void emit_i32x4_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs); LiftoffRegister rhs);
inline void emit_i32x4_sub(LiftoffRegister dst, LiftoffRegister lhs, inline void emit_i32x4_sub(LiftoffRegister dst, LiftoffRegister lhs,
...@@ -775,18 +778,21 @@ class LiftoffAssembler : public TurboAssembler { ...@@ -775,18 +778,21 @@ class LiftoffAssembler : public TurboAssembler {
LiftoffRegister rhs); LiftoffRegister rhs);
inline void emit_i32x4_max_u(LiftoffRegister dst, LiftoffRegister lhs, inline void emit_i32x4_max_u(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs); LiftoffRegister rhs);
inline void emit_i64x2_neg(LiftoffRegister dst, LiftoffRegister src);
inline void emit_i64x2_add(LiftoffRegister dst, LiftoffRegister lhs, inline void emit_i64x2_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs); LiftoffRegister rhs);
inline void emit_i64x2_sub(LiftoffRegister dst, LiftoffRegister lhs, inline void emit_i64x2_sub(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs); LiftoffRegister rhs);
inline void emit_i64x2_mul(LiftoffRegister dst, LiftoffRegister lhs, inline void emit_i64x2_mul(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs); LiftoffRegister rhs);
inline void emit_f32x4_neg(LiftoffRegister dst, LiftoffRegister src);
inline void emit_f32x4_add(LiftoffRegister dst, LiftoffRegister lhs, inline void emit_f32x4_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs); LiftoffRegister rhs);
inline void emit_f32x4_sub(LiftoffRegister dst, LiftoffRegister lhs, inline void emit_f32x4_sub(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs); LiftoffRegister rhs);
inline void emit_f32x4_mul(LiftoffRegister dst, LiftoffRegister lhs, inline void emit_f32x4_mul(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs); LiftoffRegister rhs);
inline void emit_f64x2_neg(LiftoffRegister dst, LiftoffRegister src);
inline void emit_f64x2_add(LiftoffRegister dst, LiftoffRegister lhs, inline void emit_f64x2_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs); LiftoffRegister rhs);
inline void emit_f64x2_sub(LiftoffRegister dst, LiftoffRegister lhs, inline void emit_f64x2_sub(LiftoffRegister dst, LiftoffRegister lhs,
......
...@@ -2343,6 +2343,8 @@ class LiftoffCompiler { ...@@ -2343,6 +2343,8 @@ class LiftoffCompiler {
return EmitUnOp<kF32, kS128>(&LiftoffAssembler::emit_f32x4_splat); return EmitUnOp<kF32, kS128>(&LiftoffAssembler::emit_f32x4_splat);
case wasm::kExprF64x2Splat: case wasm::kExprF64x2Splat:
return EmitUnOp<kF64, kS128>(&LiftoffAssembler::emit_f64x2_splat); return EmitUnOp<kF64, kS128>(&LiftoffAssembler::emit_f64x2_splat);
case wasm::kExprI8x16Neg:
return EmitUnOp<kS128, kS128>(&LiftoffAssembler::emit_i8x16_neg);
case wasm::kExprI8x16Add: case wasm::kExprI8x16Add:
return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i8x16_add); return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i8x16_add);
case wasm::kExprI8x16AddSaturateS: case wasm::kExprI8x16AddSaturateS:
...@@ -2363,6 +2365,8 @@ class LiftoffCompiler { ...@@ -2363,6 +2365,8 @@ class LiftoffCompiler {
return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i8x16_max_s); return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i8x16_max_s);
case wasm::kExprI8x16MaxU: case wasm::kExprI8x16MaxU:
return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i8x16_max_u); return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i8x16_max_u);
case wasm::kExprI16x8Neg:
return EmitUnOp<kS128, kS128>(&LiftoffAssembler::emit_i16x8_neg);
case wasm::kExprI16x8Add: case wasm::kExprI16x8Add:
return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i16x8_add); return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i16x8_add);
case wasm::kExprI16x8AddSaturateS: case wasm::kExprI16x8AddSaturateS:
...@@ -2383,6 +2387,8 @@ class LiftoffCompiler { ...@@ -2383,6 +2387,8 @@ class LiftoffCompiler {
return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i16x8_max_s); return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i16x8_max_s);
case wasm::kExprI16x8MaxU: case wasm::kExprI16x8MaxU:
return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i16x8_max_u); return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i16x8_max_u);
case wasm::kExprI32x4Neg:
return EmitUnOp<kS128, kS128>(&LiftoffAssembler::emit_i32x4_neg);
case wasm::kExprI32x4Add: case wasm::kExprI32x4Add:
return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i32x4_add); return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i32x4_add);
case wasm::kExprI32x4Sub: case wasm::kExprI32x4Sub:
...@@ -2397,18 +2403,24 @@ class LiftoffCompiler { ...@@ -2397,18 +2403,24 @@ class LiftoffCompiler {
return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i32x4_max_s); return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i32x4_max_s);
case wasm::kExprI32x4MaxU: case wasm::kExprI32x4MaxU:
return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i32x4_max_u); return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i32x4_max_u);
case wasm::kExprI64x2Neg:
return EmitUnOp<kS128, kS128>(&LiftoffAssembler::emit_i64x2_neg);
case wasm::kExprI64x2Add: case wasm::kExprI64x2Add:
return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i64x2_add); return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i64x2_add);
case wasm::kExprI64x2Sub: case wasm::kExprI64x2Sub:
return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i64x2_sub); return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i64x2_sub);
case wasm::kExprI64x2Mul: case wasm::kExprI64x2Mul:
return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i64x2_mul); return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i64x2_mul);
case wasm::kExprF32x4Neg:
return EmitUnOp<kS128, kS128>(&LiftoffAssembler::emit_f32x4_neg);
case wasm::kExprF32x4Add: case wasm::kExprF32x4Add:
return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_f32x4_add); return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_f32x4_add);
case wasm::kExprF32x4Sub: case wasm::kExprF32x4Sub:
return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_f32x4_sub); return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_f32x4_sub);
case wasm::kExprF32x4Mul: case wasm::kExprF32x4Mul:
return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_f32x4_mul); return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_f32x4_mul);
case wasm::kExprF64x2Neg:
return EmitUnOp<kS128, kS128>(&LiftoffAssembler::emit_f64x2_neg);
case wasm::kExprF64x2Add: case wasm::kExprF64x2Add:
return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_f64x2_add); return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_f64x2_add);
case wasm::kExprF64x2Sub: case wasm::kExprF64x2Sub:
......
...@@ -1957,6 +1957,17 @@ void LiftoffAssembler::emit_f64x2_splat(LiftoffRegister dst, ...@@ -1957,6 +1957,17 @@ void LiftoffAssembler::emit_f64x2_splat(LiftoffRegister dst,
Movddup(dst.fp(), src.fp()); Movddup(dst.fp(), src.fp());
} }
void LiftoffAssembler::emit_i8x16_neg(LiftoffRegister dst,
LiftoffRegister src) {
if (dst.fp() == src.fp()) {
Pcmpeqd(kScratchDoubleReg, kScratchDoubleReg);
Psignb(dst.fp(), kScratchDoubleReg);
} else {
Pxor(dst.fp(), dst.fp());
Psubb(dst.fp(), src.fp());
}
}
void LiftoffAssembler::emit_i8x16_add(LiftoffRegister dst, LiftoffRegister lhs, void LiftoffAssembler::emit_i8x16_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
liftoff::EmitSimdCommutativeBinOp<&Assembler::vpaddb, &Assembler::paddb>( liftoff::EmitSimdCommutativeBinOp<&Assembler::vpaddb, &Assembler::paddb>(
...@@ -2073,6 +2084,17 @@ void LiftoffAssembler::emit_i8x16_max_u(LiftoffRegister dst, ...@@ -2073,6 +2084,17 @@ void LiftoffAssembler::emit_i8x16_max_u(LiftoffRegister dst,
this, dst, lhs, rhs); this, dst, lhs, rhs);
} }
void LiftoffAssembler::emit_i16x8_neg(LiftoffRegister dst,
LiftoffRegister src) {
if (dst.fp() == src.fp()) {
Pcmpeqd(kScratchDoubleReg, kScratchDoubleReg);
Psignw(dst.fp(), kScratchDoubleReg);
} else {
Pxor(dst.fp(), dst.fp());
Psubw(dst.fp(), src.fp());
}
}
void LiftoffAssembler::emit_i16x8_add(LiftoffRegister dst, LiftoffRegister lhs, void LiftoffAssembler::emit_i16x8_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
liftoff::EmitSimdCommutativeBinOp<&Assembler::vpaddw, &Assembler::paddw>( liftoff::EmitSimdCommutativeBinOp<&Assembler::vpaddw, &Assembler::paddw>(
...@@ -2133,6 +2155,17 @@ void LiftoffAssembler::emit_i16x8_max_u(LiftoffRegister dst, ...@@ -2133,6 +2155,17 @@ void LiftoffAssembler::emit_i16x8_max_u(LiftoffRegister dst,
this, dst, lhs, rhs, base::Optional<CpuFeature>(SSE4_1)); this, dst, lhs, rhs, base::Optional<CpuFeature>(SSE4_1));
} }
void LiftoffAssembler::emit_i32x4_neg(LiftoffRegister dst,
LiftoffRegister src) {
if (dst.fp() == src.fp()) {
Pcmpeqd(kScratchDoubleReg, kScratchDoubleReg);
Psignd(dst.fp(), kScratchDoubleReg);
} else {
Pxor(dst.fp(), dst.fp());
Psubd(dst.fp(), src.fp());
}
}
void LiftoffAssembler::emit_i32x4_add(LiftoffRegister dst, LiftoffRegister lhs, void LiftoffAssembler::emit_i32x4_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
liftoff::EmitSimdCommutativeBinOp<&Assembler::vpaddd, &Assembler::paddd>( liftoff::EmitSimdCommutativeBinOp<&Assembler::vpaddd, &Assembler::paddd>(
...@@ -2179,6 +2212,19 @@ void LiftoffAssembler::emit_i32x4_max_u(LiftoffRegister dst, ...@@ -2179,6 +2212,19 @@ void LiftoffAssembler::emit_i32x4_max_u(LiftoffRegister dst,
this, dst, lhs, rhs, base::Optional<CpuFeature>(SSE4_1)); this, dst, lhs, rhs, base::Optional<CpuFeature>(SSE4_1));
} }
void LiftoffAssembler::emit_i64x2_neg(LiftoffRegister dst,
LiftoffRegister src) {
DoubleRegister reg = dst.fp() == src.fp() ? kScratchDoubleReg : dst.fp();
Pxor(reg, reg);
if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope scope(this, AVX);
vpsubq(dst.fp(), reg, src.fp());
} else {
psubq(reg, src.fp());
if (dst.fp() != reg) movapd(dst.fp(), reg);
}
}
void LiftoffAssembler::emit_i64x2_add(LiftoffRegister dst, LiftoffRegister lhs, void LiftoffAssembler::emit_i64x2_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
liftoff::EmitSimdCommutativeBinOp<&Assembler::vpaddq, &Assembler::paddq>( liftoff::EmitSimdCommutativeBinOp<&Assembler::vpaddq, &Assembler::paddq>(
...@@ -2218,6 +2264,19 @@ void LiftoffAssembler::emit_i64x2_mul(LiftoffRegister dst, LiftoffRegister lhs, ...@@ -2218,6 +2264,19 @@ void LiftoffAssembler::emit_i64x2_mul(LiftoffRegister dst, LiftoffRegister lhs,
Paddq(dst.fp(), tmp2.fp()); Paddq(dst.fp(), tmp2.fp());
} }
void LiftoffAssembler::emit_f32x4_neg(LiftoffRegister dst,
LiftoffRegister src) {
if (dst.fp() == src.fp()) {
Pcmpeqd(kScratchDoubleReg, kScratchDoubleReg);
Pslld(kScratchDoubleReg, static_cast<byte>(31));
Xorps(dst.fp(), kScratchDoubleReg);
} else {
Pcmpeqd(dst.fp(), dst.fp());
Pslld(dst.fp(), static_cast<byte>(31));
Xorps(dst.fp(), src.fp());
}
}
void LiftoffAssembler::emit_f32x4_add(LiftoffRegister dst, LiftoffRegister lhs, void LiftoffAssembler::emit_f32x4_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
liftoff::EmitSimdCommutativeBinOp<&Assembler::vaddps, &Assembler::addps>( liftoff::EmitSimdCommutativeBinOp<&Assembler::vaddps, &Assembler::addps>(
...@@ -2236,6 +2295,19 @@ void LiftoffAssembler::emit_f32x4_mul(LiftoffRegister dst, LiftoffRegister lhs, ...@@ -2236,6 +2295,19 @@ void LiftoffAssembler::emit_f32x4_mul(LiftoffRegister dst, LiftoffRegister lhs,
this, dst, lhs, rhs); this, dst, lhs, rhs);
} }
void LiftoffAssembler::emit_f64x2_neg(LiftoffRegister dst,
LiftoffRegister src) {
if (dst.fp() == src.fp()) {
Pcmpeqd(kScratchDoubleReg, kScratchDoubleReg);
Psllq(kScratchDoubleReg, static_cast<byte>(63));
Xorpd(dst.fp(), kScratchDoubleReg);
} else {
Pcmpeqd(dst.fp(), dst.fp());
Psllq(dst.fp(), static_cast<byte>(63));
Xorpd(dst.fp(), src.fp());
}
}
void LiftoffAssembler::emit_f64x2_add(LiftoffRegister dst, LiftoffRegister lhs, void LiftoffAssembler::emit_f64x2_add(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
liftoff::EmitSimdCommutativeBinOp<&Assembler::vaddpd, &Assembler::addpd>( liftoff::EmitSimdCommutativeBinOp<&Assembler::vaddpd, &Assembler::addpd>(
......
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