Commit 0e0e1aa8 authored by jing.bao's avatar jing.bao Committed by Commit bot

[ia32] Add cmpps/vcmpps for eq/lt/le/neq

BUG=

Review-Url: https://codereview.chromium.org/2847683002
Cr-Commit-Position: refs/heads/master@{#44955}
parent aed22ad1
...@@ -2277,6 +2277,14 @@ void Assembler::maxps(XMMRegister dst, const Operand& src) { ...@@ -2277,6 +2277,14 @@ void Assembler::maxps(XMMRegister dst, const Operand& src) {
emit_sse_operand(dst, src); emit_sse_operand(dst, src);
} }
void Assembler::cmpps(XMMRegister dst, const Operand& src, int8_t cmp) {
EnsureSpace ensure_space(this);
EMIT(0x0F);
EMIT(0xC2);
emit_sse_operand(dst, src);
EMIT(cmp);
}
void Assembler::sqrtsd(XMMRegister dst, const Operand& src) { void Assembler::sqrtsd(XMMRegister dst, const Operand& src) {
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
EMIT(0xF2); EMIT(0xF2);
...@@ -2795,6 +2803,12 @@ void Assembler::vpd(byte op, XMMRegister dst, XMMRegister src1, ...@@ -2795,6 +2803,12 @@ void Assembler::vpd(byte op, XMMRegister dst, XMMRegister src1,
vinstr(op, dst, src1, src2, k66, k0F, kWIG); vinstr(op, dst, src1, src2, k66, k0F, kWIG);
} }
void Assembler::vcmpps(XMMRegister dst, XMMRegister src1, const Operand& src2,
int8_t cmp) {
vps(0xC2, dst, src1, src2);
EMIT(cmp);
}
void Assembler::vpsllw(XMMRegister dst, XMMRegister src, int8_t imm8) { void Assembler::vpsllw(XMMRegister dst, XMMRegister src, int8_t imm8) {
XMMRegister iop = {6}; XMMRegister iop = {6};
vinstr(0x71, iop, dst, Operand(src), k66, k0F, kWIG); vinstr(0x71, iop, dst, Operand(src), k66, k0F, kWIG);
......
...@@ -986,6 +986,20 @@ class Assembler : public AssemblerBase { ...@@ -986,6 +986,20 @@ class Assembler : public AssemblerBase {
void maxps(XMMRegister dst, const Operand& src); void maxps(XMMRegister dst, const Operand& src);
void maxps(XMMRegister dst, XMMRegister src) { maxps(dst, Operand(src)); } void maxps(XMMRegister dst, XMMRegister src) { maxps(dst, Operand(src)); }
void cmpps(XMMRegister dst, const Operand& src, int8_t cmp);
#define SSE_CMP_P(instr, imm8) \
void instr##ps(XMMRegister dst, XMMRegister src) { \
cmpps(dst, Operand(src), imm8); \
} \
void instr##ps(XMMRegister dst, const Operand& src) { cmpps(dst, src, imm8); }
SSE_CMP_P(cmpeq, 0x0);
SSE_CMP_P(cmplt, 0x1);
SSE_CMP_P(cmple, 0x2);
SSE_CMP_P(cmpneq, 0x4);
#undef SSE_CMP_P
// SSE2 instructions // SSE2 instructions
void cvttss2si(Register dst, const Operand& src); void cvttss2si(Register dst, const Operand& src);
void cvttss2si(Register dst, XMMRegister src) { void cvttss2si(Register dst, XMMRegister src) {
...@@ -1438,6 +1452,23 @@ class Assembler : public AssemblerBase { ...@@ -1438,6 +1452,23 @@ class Assembler : public AssemblerBase {
void vpd(byte op, XMMRegister dst, XMMRegister src1, XMMRegister src2); void vpd(byte op, XMMRegister dst, XMMRegister src1, XMMRegister src2);
void vpd(byte op, XMMRegister dst, XMMRegister src1, const Operand& src2); void vpd(byte op, XMMRegister dst, XMMRegister src1, const Operand& src2);
void vcmpps(XMMRegister dst, XMMRegister src1, const Operand& src2,
int8_t cmp);
#define AVX_CMP_P(instr, imm8) \
void instr##ps(XMMRegister dst, XMMRegister src1, XMMRegister src2) { \
vcmpps(dst, src1, Operand(src2), imm8); \
} \
void instr##ps(XMMRegister dst, XMMRegister src1, const Operand& src2) { \
vcmpps(dst, src1, src2, imm8); \
}
AVX_CMP_P(vcmpeq, 0x0);
AVX_CMP_P(vcmplt, 0x1);
AVX_CMP_P(vcmple, 0x2);
AVX_CMP_P(vcmpneq, 0x4);
#undef AVX_CMP_P
// Other SSE and AVX instructions // Other SSE and AVX instructions
#define DECLARE_SSE2_INSTRUCTION(instruction, prefix, escape, opcode) \ #define DECLARE_SSE2_INSTRUCTION(instruction, prefix, escape, opcode) \
void instruction(XMMRegister dst, XMMRegister src) { \ void instruction(XMMRegister dst, XMMRegister src) { \
......
...@@ -1028,6 +1028,16 @@ int DisassemblerIA32::AVXInstruction(byte* data) { ...@@ -1028,6 +1028,16 @@ int DisassemblerIA32::AVXInstruction(byte* data) {
NameOfXMMRegister(vvvv)); NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current); current += PrintRightXMMOperand(current);
break; break;
case 0xC2: {
const char* const pseudo_op[] = {"eq", "lt", "le", "unord",
"neq", "nlt", "nle", "ord"};
AppendToBuffer("vcmpps %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer(", (%s)", pseudo_op[*current]);
current++;
break;
}
default: default:
UnimplementedInstruction(); UnimplementedInstruction();
} }
...@@ -1569,6 +1579,16 @@ int DisassemblerIA32::InstructionDecode(v8::internal::Vector<char> out_buffer, ...@@ -1569,6 +1579,16 @@ int DisassemblerIA32::InstructionDecode(v8::internal::Vector<char> out_buffer,
NameOfCPURegister(regop), NameOfCPURegister(regop),
NameOfXMMRegister(rm)); NameOfXMMRegister(rm));
data++; data++;
} else if (f0byte == 0xC2) {
data += 2;
int mod, regop, rm;
get_modrm(*data, &mod, &regop, &rm);
const char* const pseudo_op[] = {"eq", "lt", "le", "unord",
"neq", "nlt", "nle", "ord"};
AppendToBuffer("cmpps %s, ", NameOfXMMRegister(regop));
data += PrintRightXMMOperand(data);
AppendToBuffer(", (%s)", pseudo_op[*data]);
data++;
} else if (f0byte== 0xC6) { } else if (f0byte== 0xC6) {
// shufps xmm, xmm/m128, imm8 // shufps xmm, xmm/m128, imm8
data += 2; data += 2;
......
...@@ -429,6 +429,15 @@ TEST(DisasmIa320) { ...@@ -429,6 +429,15 @@ TEST(DisasmIa320) {
__ maxps(xmm1, xmm0); __ maxps(xmm1, xmm0);
__ maxps(xmm1, Operand(ebx, ecx, times_4, 10000)); __ maxps(xmm1, Operand(ebx, ecx, times_4, 10000));
__ cmpeqps(xmm5, xmm1);
__ cmpeqps(xmm5, Operand(ebx, ecx, times_4, 10000));
__ cmpltps(xmm5, xmm1);
__ cmpltps(xmm5, Operand(ebx, ecx, times_4, 10000));
__ cmpleps(xmm5, xmm1);
__ cmpleps(xmm5, Operand(ebx, ecx, times_4, 10000));
__ cmpneqps(xmm5, xmm1);
__ cmpneqps(xmm5, Operand(ebx, ecx, times_4, 10000));
__ ucomiss(xmm0, xmm1); __ ucomiss(xmm0, xmm1);
__ ucomiss(xmm0, Operand(ebx, ecx, times_4, 10000)); __ ucomiss(xmm0, Operand(ebx, ecx, times_4, 10000));
} }
...@@ -567,6 +576,15 @@ TEST(DisasmIa320) { ...@@ -567,6 +576,15 @@ TEST(DisasmIa320) {
__ vmaxps(xmm0, xmm1, xmm2); __ vmaxps(xmm0, xmm1, xmm2);
__ vmaxps(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000)); __ vmaxps(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
__ vcmpeqps(xmm5, xmm4, xmm1);
__ vcmpeqps(xmm5, xmm4, Operand(ebx, ecx, times_4, 10000));
__ vcmpltps(xmm5, xmm4, xmm1);
__ vcmpltps(xmm5, xmm4, Operand(ebx, ecx, times_4, 10000));
__ vcmpleps(xmm5, xmm4, xmm1);
__ vcmpleps(xmm5, xmm4, Operand(ebx, ecx, times_4, 10000));
__ vcmpneqps(xmm5, xmm4, xmm1);
__ vcmpneqps(xmm5, xmm4, Operand(ebx, ecx, times_4, 10000));
__ vandpd(xmm0, xmm1, xmm2); __ vandpd(xmm0, xmm1, xmm2);
__ vandpd(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000)); __ vandpd(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
__ vxorpd(xmm0, xmm1, xmm2); __ vxorpd(xmm0, xmm1, xmm2);
......
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