Commit 1d85b5f7 authored by Ng Zhi An's avatar Ng Zhi An Committed by Commit Bot

[x64] Convert pinsrb family of instructions to take uint8_t immediate

It was slightly inconsistent, the sse versions took int8_t, the avx
versions took uint8_t. Consolidate into uint8_t, that allows us to
remove the DCHECK inside of the assembler, and also convert callers to
use uint8_t.

Bug: v8:10933
Change-Id: I125f0d54533b6fde1362e63e96f50fcf2467cac5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2443494Reviewed-by: 's avatarBill Budge <bbudge@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70274}
parent 940d11ec
...@@ -2757,8 +2757,7 @@ void Assembler::movdqu(XMMRegister dst, Operand src) { ...@@ -2757,8 +2757,7 @@ void Assembler::movdqu(XMMRegister dst, Operand src) {
emit_sse_operand(dst, src); emit_sse_operand(dst, src);
} }
void Assembler::pinsrw(XMMRegister dst, Register src, int8_t imm8) { void Assembler::pinsrw(XMMRegister dst, Register src, uint8_t imm8) {
DCHECK(is_uint8(imm8));
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
emit(0x66); emit(0x66);
emit_optional_rex_32(dst, src); emit_optional_rex_32(dst, src);
...@@ -2768,8 +2767,7 @@ void Assembler::pinsrw(XMMRegister dst, Register src, int8_t imm8) { ...@@ -2768,8 +2767,7 @@ void Assembler::pinsrw(XMMRegister dst, Register src, int8_t imm8) {
emit(imm8); emit(imm8);
} }
void Assembler::pinsrw(XMMRegister dst, Operand src, int8_t imm8) { void Assembler::pinsrw(XMMRegister dst, Operand src, uint8_t imm8) {
DCHECK(is_uint8(imm8));
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
emit(0x66); emit(0x66);
emit_optional_rex_32(dst, src); emit_optional_rex_32(dst, src);
...@@ -2791,7 +2789,7 @@ void Assembler::pextrq(Register dst, XMMRegister src, int8_t imm8) { ...@@ -2791,7 +2789,7 @@ void Assembler::pextrq(Register dst, XMMRegister src, int8_t imm8) {
emit(imm8); emit(imm8);
} }
void Assembler::pinsrq(XMMRegister dst, Register src, int8_t imm8) { void Assembler::pinsrq(XMMRegister dst, Register src, uint8_t imm8) {
DCHECK(IsEnabled(SSE4_1)); DCHECK(IsEnabled(SSE4_1));
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
emit(0x66); emit(0x66);
...@@ -2803,9 +2801,8 @@ void Assembler::pinsrq(XMMRegister dst, Register src, int8_t imm8) { ...@@ -2803,9 +2801,8 @@ void Assembler::pinsrq(XMMRegister dst, Register src, int8_t imm8) {
emit(imm8); emit(imm8);
} }
void Assembler::pinsrq(XMMRegister dst, Operand src, int8_t imm8) { void Assembler::pinsrq(XMMRegister dst, Operand src, uint8_t imm8) {
DCHECK(IsEnabled(SSE4_1)); DCHECK(IsEnabled(SSE4_1));
DCHECK(is_uint8(imm8));
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
emit(0x66); emit(0x66);
emit_rex_64(dst, src); emit_rex_64(dst, src);
...@@ -2816,22 +2813,20 @@ void Assembler::pinsrq(XMMRegister dst, Operand src, int8_t imm8) { ...@@ -2816,22 +2813,20 @@ void Assembler::pinsrq(XMMRegister dst, Operand src, int8_t imm8) {
emit(imm8); emit(imm8);
} }
void Assembler::pinsrd(XMMRegister dst, Register src, int8_t imm8) { void Assembler::pinsrd(XMMRegister dst, Register src, uint8_t imm8) {
sse4_instr(dst, src, 0x66, 0x0F, 0x3A, 0x22, imm8); sse4_instr(dst, src, 0x66, 0x0F, 0x3A, 0x22, imm8);
} }
void Assembler::pinsrd(XMMRegister dst, Operand src, int8_t imm8) { void Assembler::pinsrd(XMMRegister dst, Operand src, uint8_t imm8) {
DCHECK(is_uint8(imm8));
sse4_instr(dst, src, 0x66, 0x0F, 0x3A, 0x22); sse4_instr(dst, src, 0x66, 0x0F, 0x3A, 0x22);
emit(imm8); emit(imm8);
} }
void Assembler::pinsrb(XMMRegister dst, Register src, int8_t imm8) { void Assembler::pinsrb(XMMRegister dst, Register src, uint8_t imm8) {
sse4_instr(dst, src, 0x66, 0x0F, 0x3A, 0x20, imm8); sse4_instr(dst, src, 0x66, 0x0F, 0x3A, 0x20, imm8);
} }
void Assembler::pinsrb(XMMRegister dst, Operand src, int8_t imm8) { void Assembler::pinsrb(XMMRegister dst, Operand src, uint8_t imm8) {
DCHECK(is_uint8(imm8));
sse4_instr(dst, src, 0x66, 0x0F, 0x3A, 0x20); sse4_instr(dst, src, 0x66, 0x0F, 0x3A, 0x20);
emit(imm8); emit(imm8);
} }
......
...@@ -1204,14 +1204,14 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase { ...@@ -1204,14 +1204,14 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
void insertps(XMMRegister dst, XMMRegister src, byte imm8); void insertps(XMMRegister dst, XMMRegister src, byte imm8);
void insertps(XMMRegister dst, Operand src, byte imm8); void insertps(XMMRegister dst, Operand src, byte imm8);
void pextrq(Register dst, XMMRegister src, int8_t imm8); void pextrq(Register dst, XMMRegister src, int8_t imm8);
void pinsrb(XMMRegister dst, Register src, int8_t imm8); void pinsrb(XMMRegister dst, Register src, uint8_t imm8);
void pinsrb(XMMRegister dst, Operand src, int8_t imm8); void pinsrb(XMMRegister dst, Operand src, uint8_t imm8);
void pinsrw(XMMRegister dst, Register src, int8_t imm8); void pinsrw(XMMRegister dst, Register src, uint8_t imm8);
void pinsrw(XMMRegister dst, Operand src, int8_t imm8); void pinsrw(XMMRegister dst, Operand src, uint8_t imm8);
void pinsrd(XMMRegister dst, Register src, int8_t imm8); void pinsrd(XMMRegister dst, Register src, uint8_t imm8);
void pinsrd(XMMRegister dst, Operand src, int8_t imm8); void pinsrd(XMMRegister dst, Operand src, uint8_t imm8);
void pinsrq(XMMRegister dst, Register src, int8_t imm8); void pinsrq(XMMRegister dst, Register src, uint8_t imm8);
void pinsrq(XMMRegister dst, Operand src, int8_t imm8); void pinsrq(XMMRegister dst, Operand src, uint8_t imm8);
void roundss(XMMRegister dst, XMMRegister src, RoundingMode mode); void roundss(XMMRegister dst, XMMRegister src, RoundingMode mode);
void roundsd(XMMRegister dst, XMMRegister src, RoundingMode mode); void roundsd(XMMRegister dst, XMMRegister src, RoundingMode mode);
...@@ -1596,12 +1596,12 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase { ...@@ -1596,12 +1596,12 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
vinstr(0x22, dst, src1, src2, k66, k0F3A, kW0); vinstr(0x22, dst, src1, src2, k66, k0F3A, kW0);
emit(imm8); emit(imm8);
} }
void vpinsrq(XMMRegister dst, XMMRegister src1, Register src2, int8_t imm8) { void vpinsrq(XMMRegister dst, XMMRegister src1, Register src2, uint8_t imm8) {
XMMRegister isrc = XMMRegister::from_code(src2.code()); XMMRegister isrc = XMMRegister::from_code(src2.code());
vinstr(0x22, dst, src1, isrc, k66, k0F3A, kW1); vinstr(0x22, dst, src1, isrc, k66, k0F3A, kW1);
emit(imm8); emit(imm8);
} }
void vpinsrq(XMMRegister dst, XMMRegister src1, Operand src2, int8_t imm8) { void vpinsrq(XMMRegister dst, XMMRegister src1, Operand src2, uint8_t imm8) {
vinstr(0x22, dst, src1, src2, k66, k0F3A, kW1); vinstr(0x22, dst, src1, src2, k66, k0F3A, kW1);
emit(imm8); emit(imm8);
} }
......
...@@ -1362,7 +1362,7 @@ void TurboAssembler::Move(XMMRegister dst, uint64_t src) { ...@@ -1362,7 +1362,7 @@ void TurboAssembler::Move(XMMRegister dst, uint64_t src) {
void TurboAssembler::Move(XMMRegister dst, uint64_t high, uint64_t low) { void TurboAssembler::Move(XMMRegister dst, uint64_t high, uint64_t low) {
Move(dst, low); Move(dst, low);
movq(kScratchRegister, high); movq(kScratchRegister, high);
Pinsrq(dst, kScratchRegister, int8_t{1}); Pinsrq(dst, kScratchRegister, uint8_t{1});
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
...@@ -1761,7 +1761,7 @@ void TurboAssembler::Pextrb(Register dst, XMMRegister src, int8_t imm8) { ...@@ -1761,7 +1761,7 @@ void TurboAssembler::Pextrb(Register dst, XMMRegister src, int8_t imm8) {
} }
} }
void TurboAssembler::Pinsrd(XMMRegister dst, Register src, int8_t imm8) { void TurboAssembler::Pinsrd(XMMRegister dst, Register src, uint8_t imm8) {
if (CpuFeatures::IsSupported(AVX)) { if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope scope(this, AVX); CpuFeatureScope scope(this, AVX);
vpinsrd(dst, dst, src, imm8); vpinsrd(dst, dst, src, imm8);
...@@ -1780,7 +1780,7 @@ void TurboAssembler::Pinsrd(XMMRegister dst, Register src, int8_t imm8) { ...@@ -1780,7 +1780,7 @@ void TurboAssembler::Pinsrd(XMMRegister dst, Register src, int8_t imm8) {
} }
} }
void TurboAssembler::Pinsrd(XMMRegister dst, Operand src, int8_t imm8) { void TurboAssembler::Pinsrd(XMMRegister dst, Operand src, uint8_t imm8) {
if (CpuFeatures::IsSupported(AVX)) { if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope scope(this, AVX); CpuFeatureScope scope(this, AVX);
vpinsrd(dst, dst, src, imm8); vpinsrd(dst, dst, src, imm8);
...@@ -1799,7 +1799,7 @@ void TurboAssembler::Pinsrd(XMMRegister dst, Operand src, int8_t imm8) { ...@@ -1799,7 +1799,7 @@ void TurboAssembler::Pinsrd(XMMRegister dst, Operand src, int8_t imm8) {
} }
} }
void TurboAssembler::Pinsrw(XMMRegister dst, Register src, int8_t imm8) { void TurboAssembler::Pinsrw(XMMRegister dst, Register src, uint8_t imm8) {
if (CpuFeatures::IsSupported(AVX)) { if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope scope(this, AVX); CpuFeatureScope scope(this, AVX);
vpinsrw(dst, dst, src, imm8); vpinsrw(dst, dst, src, imm8);
...@@ -1812,7 +1812,7 @@ void TurboAssembler::Pinsrw(XMMRegister dst, Register src, int8_t imm8) { ...@@ -1812,7 +1812,7 @@ void TurboAssembler::Pinsrw(XMMRegister dst, Register src, int8_t imm8) {
} }
} }
void TurboAssembler::Pinsrw(XMMRegister dst, Operand src, int8_t imm8) { void TurboAssembler::Pinsrw(XMMRegister dst, Operand src, uint8_t imm8) {
if (CpuFeatures::IsSupported(AVX)) { if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope scope(this, AVX); CpuFeatureScope scope(this, AVX);
vpinsrw(dst, dst, src, imm8); vpinsrw(dst, dst, src, imm8);
...@@ -1824,7 +1824,7 @@ void TurboAssembler::Pinsrw(XMMRegister dst, Operand src, int8_t imm8) { ...@@ -1824,7 +1824,7 @@ void TurboAssembler::Pinsrw(XMMRegister dst, Operand src, int8_t imm8) {
} }
} }
void TurboAssembler::Pinsrb(XMMRegister dst, Register src, int8_t imm8) { void TurboAssembler::Pinsrb(XMMRegister dst, Register src, uint8_t imm8) {
if (CpuFeatures::IsSupported(AVX)) { if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope scope(this, AVX); CpuFeatureScope scope(this, AVX);
vpinsrb(dst, dst, src, imm8); vpinsrb(dst, dst, src, imm8);
...@@ -1837,7 +1837,7 @@ void TurboAssembler::Pinsrb(XMMRegister dst, Register src, int8_t imm8) { ...@@ -1837,7 +1837,7 @@ void TurboAssembler::Pinsrb(XMMRegister dst, Register src, int8_t imm8) {
} }
} }
void TurboAssembler::Pinsrb(XMMRegister dst, Operand src, int8_t imm8) { void TurboAssembler::Pinsrb(XMMRegister dst, Operand src, uint8_t imm8) {
if (CpuFeatures::IsSupported(AVX)) { if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope scope(this, AVX); CpuFeatureScope scope(this, AVX);
vpinsrb(dst, dst, src, imm8); vpinsrb(dst, dst, src, imm8);
......
...@@ -517,12 +517,12 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase { ...@@ -517,12 +517,12 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
void Pextrd(Register dst, XMMRegister src, int8_t imm8); void Pextrd(Register dst, XMMRegister src, int8_t imm8);
void Pextrw(Register dst, XMMRegister src, int8_t imm8); void Pextrw(Register dst, XMMRegister src, int8_t imm8);
void Pextrb(Register dst, XMMRegister src, int8_t imm8); void Pextrb(Register dst, XMMRegister src, int8_t imm8);
void Pinsrd(XMMRegister dst, Register src, int8_t imm8); void Pinsrd(XMMRegister dst, Register src, uint8_t imm8);
void Pinsrd(XMMRegister dst, Operand src, int8_t imm8); void Pinsrd(XMMRegister dst, Operand src, uint8_t imm8);
void Pinsrw(XMMRegister dst, Register src, int8_t imm8); void Pinsrw(XMMRegister dst, Register src, uint8_t imm8);
void Pinsrw(XMMRegister dst, Operand src, int8_t imm8); void Pinsrw(XMMRegister dst, Operand src, uint8_t imm8);
void Pinsrb(XMMRegister dst, Register src, int8_t imm8); void Pinsrb(XMMRegister dst, Register src, uint8_t imm8);
void Pinsrb(XMMRegister dst, Operand src, int8_t imm8); void Pinsrb(XMMRegister dst, Operand src, uint8_t imm8);
void Psllq(XMMRegister dst, int imm8) { Psllq(dst, static_cast<byte>(imm8)); } void Psllq(XMMRegister dst, int imm8) { Psllq(dst, static_cast<byte>(imm8)); }
void Psllq(XMMRegister dst, byte imm8); void Psllq(XMMRegister dst, byte imm8);
......
...@@ -2342,9 +2342,10 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -2342,9 +2342,10 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
case kX64F64x2ReplaceLane: { case kX64F64x2ReplaceLane: {
if (instr->InputAt(2)->IsFPRegister()) { if (instr->InputAt(2)->IsFPRegister()) {
__ Movq(kScratchRegister, i.InputDoubleRegister(2)); __ Movq(kScratchRegister, i.InputDoubleRegister(2));
__ Pinsrq(i.OutputSimd128Register(), kScratchRegister, i.InputInt8(1)); __ Pinsrq(i.OutputSimd128Register(), kScratchRegister, i.InputUint8(1));
} else { } else {
__ Pinsrq(i.OutputSimd128Register(), i.InputOperand(2), i.InputInt8(1)); __ Pinsrq(i.OutputSimd128Register(), i.InputOperand(2),
i.InputUint8(1));
} }
break; break;
} }
...@@ -2709,9 +2710,10 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -2709,9 +2710,10 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
case kX64I64x2ReplaceLane: { case kX64I64x2ReplaceLane: {
if (HasRegisterInput(instr, 2)) { if (HasRegisterInput(instr, 2)) {
__ Pinsrq(i.OutputSimd128Register(), i.InputRegister(2), __ Pinsrq(i.OutputSimd128Register(), i.InputRegister(2),
i.InputInt8(1)); i.InputUint8(1));
} else { } else {
__ Pinsrq(i.OutputSimd128Register(), i.InputOperand(2), i.InputInt8(1)); __ Pinsrq(i.OutputSimd128Register(), i.InputOperand(2),
i.InputUint8(1));
} }
break; break;
} }
...@@ -2742,12 +2744,12 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -2742,12 +2744,12 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
// lower quadword // lower quadword
__ Pextrq(tmp, src, int8_t{0x0}); __ Pextrq(tmp, src, int8_t{0x0});
__ sarq_cl(tmp); __ sarq_cl(tmp);
__ Pinsrq(dst, tmp, int8_t{0x0}); __ Pinsrq(dst, tmp, uint8_t{0x0});
// upper quadword // upper quadword
__ Pextrq(tmp, src, int8_t{0x1}); __ Pextrq(tmp, src, int8_t{0x1});
__ sarq_cl(tmp); __ sarq_cl(tmp);
__ Pinsrq(dst, tmp, int8_t{0x1}); __ Pinsrq(dst, tmp, uint8_t{0x1});
break; break;
} }
case kX64I64x2Add: { case kX64I64x2Add: {
......
...@@ -2232,11 +2232,11 @@ void EmitI64x2ShrS(LiftoffAssembler* assm, LiftoffRegister dst, ...@@ -2232,11 +2232,11 @@ void EmitI64x2ShrS(LiftoffAssembler* assm, LiftoffRegister dst,
assm->Pextrq(tmp, lhs.fp(), int8_t{0x0}); assm->Pextrq(tmp, lhs.fp(), int8_t{0x0});
assm->sarq_cl(tmp); assm->sarq_cl(tmp);
assm->Pinsrq(dst.fp(), tmp, int8_t{0x0}); assm->Pinsrq(dst.fp(), tmp, uint8_t{0x0});
assm->Pextrq(tmp, lhs.fp(), int8_t{0x1}); assm->Pextrq(tmp, lhs.fp(), int8_t{0x1});
assm->sarq_cl(tmp); assm->sarq_cl(tmp);
assm->Pinsrq(dst.fp(), tmp, int8_t{0x1}); assm->Pinsrq(dst.fp(), tmp, uint8_t{0x1});
// restore rcx. // restore rcx.
if (restore_rcx) { if (restore_rcx) {
...@@ -2349,7 +2349,7 @@ void LiftoffAssembler::emit_i8x16_shuffle(LiftoffRegister dst, ...@@ -2349,7 +2349,7 @@ void LiftoffAssembler::emit_i8x16_shuffle(LiftoffRegister dst,
} }
TurboAssembler::Move(tmp_simd.fp(), mask1[0]); TurboAssembler::Move(tmp_simd.fp(), mask1[0]);
movq(kScratchRegister, mask1[1]); movq(kScratchRegister, mask1[1]);
Pinsrq(tmp_simd.fp(), kScratchRegister, int8_t{1}); Pinsrq(tmp_simd.fp(), kScratchRegister, uint8_t{1});
Pshufb(kScratchDoubleReg, tmp_simd.fp()); Pshufb(kScratchDoubleReg, tmp_simd.fp());
uint64_t mask2[2] = {}; uint64_t mask2[2] = {};
...@@ -2361,7 +2361,7 @@ void LiftoffAssembler::emit_i8x16_shuffle(LiftoffRegister dst, ...@@ -2361,7 +2361,7 @@ void LiftoffAssembler::emit_i8x16_shuffle(LiftoffRegister dst,
} }
TurboAssembler::Move(tmp_simd.fp(), mask2[0]); TurboAssembler::Move(tmp_simd.fp(), mask2[0]);
movq(kScratchRegister, mask2[1]); movq(kScratchRegister, mask2[1]);
Pinsrq(tmp_simd.fp(), kScratchRegister, int8_t{1}); Pinsrq(tmp_simd.fp(), kScratchRegister, uint8_t{1});
if (dst.fp() != rhs.fp()) { if (dst.fp() != rhs.fp()) {
Movups(dst.fp(), rhs.fp()); Movups(dst.fp(), rhs.fp());
...@@ -2659,7 +2659,7 @@ void LiftoffAssembler::emit_s128_const(LiftoffRegister dst, ...@@ -2659,7 +2659,7 @@ void LiftoffAssembler::emit_s128_const(LiftoffRegister dst,
memcpy(vals, imms, sizeof(vals)); memcpy(vals, imms, sizeof(vals));
TurboAssembler::Move(dst.fp(), vals[0]); TurboAssembler::Move(dst.fp(), vals[0]);
movq(kScratchRegister, vals[1]); movq(kScratchRegister, vals[1]);
Pinsrq(dst.fp(), kScratchRegister, int8_t{1}); Pinsrq(dst.fp(), kScratchRegister, uint8_t{1});
} }
void LiftoffAssembler::emit_s128_not(LiftoffRegister dst, LiftoffRegister src) { void LiftoffAssembler::emit_s128_not(LiftoffRegister dst, LiftoffRegister src) {
......
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