Commit d3ed12b4 authored by Deepti Gandluri's avatar Deepti Gandluri Committed by Commit Bot

Implement haddps for ia32/x64

The haddps instruction is needed to implement wasm SIMD F32x4 horizontal add.

BUG=V8:6020

Change-Id: Ifff78f6c697b46e621f0fd6b7bb1b0e7824a3088
Reviewed-on: https://chromium-review.googlesource.com/820098Reviewed-by: 's avatarBill Budge <bbudge@chromium.org>
Commit-Queue: Deepti Gandluri <gdeepti@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50013}
parent cedec225
......@@ -2426,6 +2426,13 @@ void Assembler::sqrtsd(XMMRegister dst, const Operand& src) {
emit_sse_operand(dst, src);
}
void Assembler::haddps(XMMRegister dst, const Operand& src) {
EnsureSpace ensure_space(this);
EMIT(0xF2);
EMIT(0x0F);
EMIT(0x7C);
emit_sse_operand(dst, src);
}
void Assembler::andpd(XMMRegister dst, XMMRegister src) {
EnsureSpace ensure_space(this);
......
......@@ -1004,6 +1004,8 @@ class Assembler : public AssemblerBase {
void rcpps(XMMRegister dst, XMMRegister src) { rcpps(dst, Operand(src)); }
void rsqrtps(XMMRegister dst, const Operand& src);
void rsqrtps(XMMRegister dst, XMMRegister src) { rsqrtps(dst, Operand(src)); }
void haddps(XMMRegister dst, const Operand& src);
void haddps(XMMRegister dst, XMMRegister src) { haddps(dst, Operand(src)); }
void minps(XMMRegister dst, const Operand& src);
void minps(XMMRegister dst, XMMRegister src) { minps(dst, Operand(src)); }
......
......@@ -2293,6 +2293,9 @@ int DisassemblerIA32::InstructionDecode(v8::internal::Vector<char> out_buffer,
case 0x5F:
mnem = "maxsd";
break;
case 0x7C:
mnem = "haddps";
break;
}
data += 3;
int mod, regop, rm;
......
......@@ -3984,6 +3984,23 @@ void Assembler::sqrtsd(XMMRegister dst, const Operand& src) {
emit_sse_operand(dst, src);
}
void Assembler::haddps(XMMRegister dst, XMMRegister src) {
EnsureSpace ensure_space(this);
emit(0xF2);
emit_optional_rex_32(dst, src);
emit(0x0F);
emit(0x7C);
emit_sse_operand(dst, src);
}
void Assembler::haddps(XMMRegister dst, const Operand& src) {
EnsureSpace ensure_space(this);
emit(0xF2);
emit_optional_rex_32(dst, src);
emit(0x0F);
emit(0x7C);
emit_sse_operand(dst, src);
}
void Assembler::ucomisd(XMMRegister dst, XMMRegister src) {
DCHECK(!IsEnabled(AVX));
......
......@@ -1212,6 +1212,9 @@ class Assembler : public AssemblerBase {
void sqrtsd(XMMRegister dst, XMMRegister src);
void sqrtsd(XMMRegister dst, const Operand& src);
void haddps(XMMRegister dst, XMMRegister src);
void haddps(XMMRegister dst, const Operand& src);
void ucomisd(XMMRegister dst, XMMRegister src);
void ucomisd(XMMRegister dst, const Operand& src);
void cmpltsd(XMMRegister dst, XMMRegister src);
......
......@@ -1971,6 +1971,11 @@ int DisassemblerX64::TwoByteOpcodeInstruction(byte* data) {
get_modrm(*current, &mod, &regop, &rm);
AppendToBuffer("lddqu %s,", NameOfXMMRegister(regop));
current += PrintRightOperand(current);
} else if (opcode == 0x7C) {
int mod, regop, rm;
get_modrm(*current, &mod, &regop, &rm);
AppendToBuffer("haddps %s,", NameOfXMMRegister(regop));
current += PrintRightOperand(current);
} else {
UnimplementedInstruction();
}
......
......@@ -521,6 +521,7 @@ TEST(AssemblerIa32SSE) {
__ mulps(xmm2, xmm1);
__ subps(xmm2, xmm0);
__ divps(xmm2, xmm1);
__ haddps(xmm1, xmm0);
__ cvttss2si(eax, xmm2);
__ ret(0);
}
......
......@@ -908,6 +908,7 @@ TEST(AssemblerX64SSE) {
__ subps(xmm2, xmm0);
__ divps(xmm2, xmm1);
__ cvttss2si(rax, xmm2);
__ haddps(xmm1, xmm0);
__ ret(0);
}
......
......@@ -481,6 +481,8 @@ TEST(DisasmIa320) {
__ maxsd(xmm1, Operand(ebx, ecx, times_4, 10000));
__ ucomisd(xmm0, xmm1);
__ cmpltsd(xmm0, xmm1);
__ haddps(xmm1, xmm0);
__ haddps(xmm1, Operand(ebx, ecx, times_4, 10000));
__ andpd(xmm0, xmm1);
......
......@@ -451,6 +451,8 @@ TEST(DisasmX64) {
__ maxsd(xmm1, xmm0);
__ maxsd(xmm1, Operand(rbx, rcx, times_4, 10000));
__ ucomisd(xmm0, xmm1);
__ haddps(xmm1, xmm0);
__ haddps(xmm1, Operand(rbx, rcx, times_4, 10000));
__ andpd(xmm0, xmm1);
__ andpd(xmm0, Operand(rbx, rcx, times_4, 10000));
......
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