Commit d05d335e authored by Ng Zhi An's avatar Ng Zhi An Committed by Commit Bot

Fix assembler for sqrtpd

The assembly of sqrtpd when using Sqrtpd macro was wrong, since
Sqrtpd(xmm1, xmm1) will incorrect generated vsqrtpd(xmm1, xmm1, xmm1),
which is nonsensical, since vsqrtpd only takes two operands. The
expected instruction should be vsqrtpd(xmm1, xmm0, xmm1) in terms of the
encoding, which is vsqrtpd(xmm1, xmm1).

So, move sqrtpd and cvtps2dq out into their own macro list, because
they have two operands in their AVX form, unlike the rest of the
instructions in SSE2_INSTRUCTION_LIST.

Also updated disasm and tests to use this new list.

Fixed: v8:10170
Change-Id: Ia9343c9a3ae64596bbc876744556e1dcea2a443b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2032195Reviewed-by: 's avatarDeepti Gandluri <gdeepti@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66088}
parent 90830b59
...@@ -901,6 +901,7 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase { ...@@ -901,6 +901,7 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
SSE_INSTRUCTION_LIST_SS(DECLARE_SSE2_INSTRUCTION) SSE_INSTRUCTION_LIST_SS(DECLARE_SSE2_INSTRUCTION)
SSE2_INSTRUCTION_LIST(DECLARE_SSE2_INSTRUCTION) SSE2_INSTRUCTION_LIST(DECLARE_SSE2_INSTRUCTION)
SSE2_INSTRUCTION_LIST_SD(DECLARE_SSE2_INSTRUCTION) SSE2_INSTRUCTION_LIST_SD(DECLARE_SSE2_INSTRUCTION)
SSE2_UNOP_INSTRUCTION_LIST(DECLARE_SSE2_INSTRUCTION)
#undef DECLARE_SSE2_INSTRUCTION #undef DECLARE_SSE2_INSTRUCTION
void sse2_instr(XMMRegister reg, byte imm8, byte prefix, byte escape, void sse2_instr(XMMRegister reg, byte imm8, byte prefix, byte escape,
...@@ -928,6 +929,17 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase { ...@@ -928,6 +929,17 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
SSE2_INSTRUCTION_LIST(DECLARE_SSE2_AVX_INSTRUCTION) SSE2_INSTRUCTION_LIST(DECLARE_SSE2_AVX_INSTRUCTION)
#undef DECLARE_SSE2_AVX_INSTRUCTION #undef DECLARE_SSE2_AVX_INSTRUCTION
#define DECLARE_SSE2_UNOP_AVX_INSTRUCTION(instruction, prefix, escape, opcode) \
void v##instruction(XMMRegister dst, XMMRegister src) { \
vpd(0x##opcode, dst, xmm0, src); \
} \
void v##instruction(XMMRegister dst, Operand src) { \
vpd(0x##opcode, dst, xmm0, src); \
}
SSE2_UNOP_INSTRUCTION_LIST(DECLARE_SSE2_UNOP_AVX_INSTRUCTION)
#undef DECLARE_SSE2_UNOP_AVX_INSTRUCTION
// SSE3 // SSE3
void lddqu(XMMRegister dst, Operand src); void lddqu(XMMRegister dst, Operand src);
void movddup(XMMRegister dst, Operand src); void movddup(XMMRegister dst, Operand src);
......
...@@ -36,11 +36,9 @@ ...@@ -36,11 +36,9 @@
V(maxss, F3, 0F, 5F) V(maxss, F3, 0F, 5F)
#define SSE2_INSTRUCTION_LIST(V) \ #define SSE2_INSTRUCTION_LIST(V) \
V(sqrtpd, 66, 0F, 51) \
V(andnpd, 66, 0F, 55) \ V(andnpd, 66, 0F, 55) \
V(addpd, 66, 0F, 58) \ V(addpd, 66, 0F, 58) \
V(mulpd, 66, 0F, 59) \ V(mulpd, 66, 0F, 59) \
V(cvtps2dq, 66, 0F, 5B) \
V(subpd, 66, 0F, 5C) \ V(subpd, 66, 0F, 5C) \
V(minpd, 66, 0F, 5D) \ V(minpd, 66, 0F, 5D) \
V(maxpd, 66, 0F, 5F) \ V(maxpd, 66, 0F, 5F) \
...@@ -98,6 +96,11 @@ ...@@ -98,6 +96,11 @@
V(por, 66, 0F, EB) \ V(por, 66, 0F, EB) \
V(pxor, 66, 0F, EF) V(pxor, 66, 0F, EF)
// SSE2 instructions whose AVX version has two operands.
#define SSE2_UNOP_INSTRUCTION_LIST(V) \
V(sqrtpd, 66, 0F, 51) \
V(cvtps2dq, 66, 0F, 5B)
// SSE2 shift instructions with an immediate operand. The last element is the // SSE2 shift instructions with an immediate operand. The last element is the
// extension to the opcode. // extension to the opcode.
#define SSE2_INSTRUCTION_LIST_SHIFT_IMM(V) \ #define SSE2_INSTRUCTION_LIST_SHIFT_IMM(V) \
......
...@@ -1505,6 +1505,15 @@ int DisassemblerX64::AVXInstruction(byte* data) { ...@@ -1505,6 +1505,15 @@ int DisassemblerX64::AVXInstruction(byte* data) {
SSE2_INSTRUCTION_LIST(DECLARE_SSE_AVX_DIS_CASE) SSE2_INSTRUCTION_LIST(DECLARE_SSE_AVX_DIS_CASE)
#undef DECLARE_SSE_AVX_DIS_CASE #undef DECLARE_SSE_AVX_DIS_CASE
#define DECLARE_SSE_UNOP_AVX_DIS_CASE(instruction, notUsed1, notUsed2, opcode) \
case 0x##opcode: { \
AppendToBuffer("v" #instruction " %s,", NameOfXMMRegister(regop)); \
current += PrintRightXMMOperand(current); \
break; \
}
SSE2_UNOP_INSTRUCTION_LIST(DECLARE_SSE_UNOP_AVX_DIS_CASE)
#undef DECLARE_SSE_UNOP_AVX_DIS_CASE
default: default:
UnimplementedInstruction(); UnimplementedInstruction();
} }
......
...@@ -458,6 +458,7 @@ TEST(DisasmX64) { ...@@ -458,6 +458,7 @@ TEST(DisasmX64) {
__ instruction(xmm5, Operand(rdx, 4)); __ instruction(xmm5, Operand(rdx, 4));
SSE2_INSTRUCTION_LIST(EMIT_SSE2_INSTR) SSE2_INSTRUCTION_LIST(EMIT_SSE2_INSTR)
SSE2_UNOP_INSTRUCTION_LIST(EMIT_SSE2_INSTR)
SSE2_INSTRUCTION_LIST_SD(EMIT_SSE2_INSTR) SSE2_INSTRUCTION_LIST_SD(EMIT_SSE2_INSTR)
#undef EMIT_SSE2_INSTR #undef EMIT_SSE2_INSTR
...@@ -744,16 +745,24 @@ TEST(DisasmX64) { ...@@ -744,16 +745,24 @@ TEST(DisasmX64) {
__ v##instruction(xmm10, xmm5, xmm1); \ __ v##instruction(xmm10, xmm5, xmm1); \
__ v##instruction(xmm10, xmm5, Operand(rdx, 4)); __ v##instruction(xmm10, xmm5, Operand(rdx, 4));
SSE2_INSTRUCTION_LIST(EMIT_SSE2_AVXINSTR)
#undef EMIT_SSE2_AVXINSTR
#define EMIT_SSE2_UNOP_AVXINSTR(instruction, notUsed1, notUsed2, notUsed3) \
__ v##instruction(xmm10, xmm1); \
__ v##instruction(xmm10, Operand(rdx, 4));
SSE2_UNOP_INSTRUCTION_LIST(EMIT_SSE2_UNOP_AVXINSTR)
#undef EMIT_SSE2_AVXINSTR
#define EMIT_SSE34_AVXINSTR(instruction, notUsed1, notUsed2, notUsed3, \ #define EMIT_SSE34_AVXINSTR(instruction, notUsed1, notUsed2, notUsed3, \
notUsed4) \ notUsed4) \
__ v##instruction(xmm10, xmm5, xmm1); \ __ v##instruction(xmm10, xmm5, xmm1); \
__ v##instruction(xmm10, xmm5, Operand(rdx, 4)); __ v##instruction(xmm10, xmm5, Operand(rdx, 4));
SSE2_INSTRUCTION_LIST(EMIT_SSE2_AVXINSTR)
SSSE3_INSTRUCTION_LIST(EMIT_SSE34_AVXINSTR) SSSE3_INSTRUCTION_LIST(EMIT_SSE34_AVXINSTR)
SSE4_INSTRUCTION_LIST(EMIT_SSE34_AVXINSTR) SSE4_INSTRUCTION_LIST(EMIT_SSE34_AVXINSTR)
SSE4_2_INSTRUCTION_LIST(EMIT_SSE34_AVXINSTR) SSE4_2_INSTRUCTION_LIST(EMIT_SSE34_AVXINSTR)
#undef EMIT_SSE2_AVXINSTR
#undef EMIT_SSE34_AVXINSTR #undef EMIT_SSE34_AVXINSTR
#define EMIT_SSE4_PMOV_AVXINSTR(instruction, notUsed1, notUsed2, notUsed3, \ #define EMIT_SSE4_PMOV_AVXINSTR(instruction, notUsed1, notUsed2, notUsed3, \
......
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