Skip to content

Commit

Permalink
add avx10 saturating convert
Browse files Browse the repository at this point in the history
  • Loading branch information
herumi committed Oct 14, 2024
1 parent 5f942b5 commit de32c7e
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 2 deletions.
22 changes: 20 additions & 2 deletions gen/gen_avx512.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ void putX_XM()
{ 0x6B, "vcvtps2iubs", T_MUST_EVEX | T_YMM | T_66 | T_MAP5 | T_EW0 | T_B32 | T_ER_Y | T_ER_Z },
{ 0x68, "vcvttps2ibs", T_MUST_EVEX | T_YMM | T_66 | T_MAP5 | T_EW0 | T_B32 | T_ER_Y | T_ER_Z },
{ 0x6A, "vcvttps2iubs", T_MUST_EVEX | T_YMM | T_66 | T_MAP5 | T_EW0 | T_B32 | T_ER_Y | T_ER_Z },
// 13.10
{ 0x6C, "vcvttps2udqs", T_MUST_EVEX | T_YMM | T_MAP5 | T_EW0 | T_B32 | T_SAE_Y | T_SAE_Z },
};
for (size_t i = 0; i < NUM_OF_ARRAY(tbl); i++) {
const Tbl *p = &tbl[i];
Expand Down Expand Up @@ -687,6 +689,22 @@ void putCvt()
{ 0x7B, "vcvtusi2sh", T_F3 | T_MAP5 | T_MUST_EVEX | T_ER_R | T_M_K, 6 },

{ 0x72, "vcvtneps2bf16", T_MUST_EVEX | T_F3 | T_0F38 | T_EW0 | T_YMM | T_SAE_Z | T_B32, 2 },
// 13.2
{ 0x6D, "vcvttpd2dqs", T_MUST_EVEX | T_YMM | T_MAP5 | T_EW1 | T_B64 | T_SAE_Y | T_SAE_Z, 2 },
// 13.4
{ 0x6C, "vcvttpd2udqs", T_MUST_EVEX | T_YMM | T_MAP5 | T_EW1 | T_B64 | T_SAE_Y | T_SAE_Z, 2 },
// 13.9
{ 0x6D, "vcvttps2qqs", T_MUST_EVEX | T_YMM | T_66 | T_MAP5 | T_EW0 | T_B32 | T_SAE_X | T_SAE_Y | T_N8 | T_N_VL, 1 },
// 13.11
{ 0x6C, "vcvttps2uqqs", T_MUST_EVEX | T_YMM | T_66 | T_MAP5 | T_EW0 | T_B32 | T_SAE_X | T_SAE_Y | T_N8 | T_N_VL, 1 },
// 13.12
{ 0x6D, "vcvttsd2sis", T_MUST_EVEX | T_F2 | T_MAP5 | T_EW0 | T_SAE_X | T_N8, 0 },
// 13.13
{ 0x6C, "vcvttsd2usis", T_MUST_EVEX | T_F2 | T_MAP5 | T_EW0 | T_SAE_X | T_N8, 0 },
// 13.14
{ 0x6D, "vcvttss2sis", T_MUST_EVEX | T_F3 | T_MAP5 | T_EW0 | T_SAE_X | T_N4, 0 },
// 13.15
{ 0x6C, "vcvttss2usis", T_MUST_EVEX | T_F3 | T_MAP5 | T_EW0 | T_SAE_X | T_N4, 0 },
};
for (size_t i = 0; i < NUM_OF_ARRAY(tbl); i++) {
const Tbl& p = tbl[i];
Expand All @@ -695,10 +713,10 @@ void putCvt()
case 0:
printf("void %s(const Reg32e& r, const Operand& op) { uint64_t type = (%s) | (r.isREG(64) ? T_EW1 : T_EW0); opVex(r, &xm0, op, type, 0x%02X); }\n", p.name, s.c_str(), p.code);
break;
case 1:
case 1: // (x, x/m), (y, x/m256), (z, y/m)
printf("void %s(const Xmm& x, const Operand& op) { checkCvt1(x, op); opVex(x, 0, op, %s, 0x%02X); }\n", p.name, s.c_str(), p.code);
break;
case 2:
case 2: // (x, x/m), (x, y/m256), (y, z/m)
printf("void %s(const Xmm& x, const Operand& op) { opCvt2(x, op, %s, 0x%02X); }\n", p.name, s.c_str(), p.code);
break;
case 3:
Expand Down
108 changes: 108 additions & 0 deletions test/avx10/saturation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,111 @@ vcvttps2iubs(zm1, zm2);
vcvttps2iubs(zm1, zm2|T_ru_sae);
vcvttps2iubs(zm1, ptr[rax+128]);
vcvttps2iubs(zm1, ptr_b[rax+128]);
//
vcvttps2udqs(xm1, xm2);
vcvttps2udqs(xm1, ptr[rax+128]);
vcvttps2udqs(xm1, ptr_b[rax+128]);

vcvttps2udqs(ym1, ym2);
vcvttps2udqs(ym1, ym2|T_sae);
vcvttps2udqs(ym1, ptr[rax+128]);
vcvttps2udqs(ym1, ptr_b[rax+128]);

vcvttps2udqs(zm1, zm2);
vcvttps2udqs(zm1, zm2|T_sae);
vcvttps2udqs(zm1, ptr[rax+128]);
vcvttps2udqs(zm1, ptr_b[rax+128]);

//
vcvttpd2dqs(xm1|k1|T_z, xm2);
vcvttpd2dqs(xm1|k1|T_z, xword [rax+128]);
vcvttpd2dqs(xm1|k1|T_z, xword_b[rax+128]);

vcvttpd2dqs(xm1|k1|T_z, ym2);
vcvttpd2dqs(xm1|k1|T_z, ym2|T_sae);
vcvttpd2dqs(xm1|k1|T_z, yword [rax+128]);
vcvttpd2dqs(xm1|k1|T_z, yword_b[rax+128]);

vcvttpd2dqs(ym1|k1|T_z, zm2);
vcvttpd2dqs(ym1|k1|T_z, zm2|T_sae);
vcvttpd2dqs(ym1|k1|T_z, zword [rax+128]);
vcvttpd2dqs(ym1|k1|T_z, zword_b[rax+128]);

//
vcvttpd2udqs(xm1|k1|T_z, xm2);
vcvttpd2udqs(xm1|k1|T_z, xword [rax+128]);
vcvttpd2udqs(xm1|k1|T_z, xword_b[rax+128]);

vcvttpd2udqs(xm1|k1|T_z, ym2);
vcvttpd2udqs(xm1|k1|T_z, ym2|T_sae);
vcvttpd2udqs(xm1|k1|T_z, yword [rax+128]);
vcvttpd2udqs(xm1|k1|T_z, yword_b[rax+128]);

vcvttpd2udqs(ym1|k1|T_z, zm2);
vcvttpd2udqs(ym1|k1|T_z, zm2|T_sae);
vcvttpd2udqs(ym1|k1|T_z, zword [rax+128]);
vcvttpd2udqs(ym1|k1|T_z, zword_b[rax+128]);
//
vcvttps2qqs(xm1|k1|T_z, xm2);
vcvttps2qqs(xm1|k1|T_z, ptr [rax+128]);
vcvttps2qqs(xm1|k1|T_z, ptr_b[rax+128]);

vcvttps2qqs(ym1|k1|T_z, xm2);
vcvttps2qqs(ym1|k1|T_z, xm2|T_sae);
vcvttps2qqs(ym1|k1|T_z, ptr [rax+128]);
vcvttps2qqs(ym1|k1|T_z, ptr_b[rax+128]);

vcvttps2qqs(zm1, ym2);
vcvttps2qqs(zm1|k1|T_z, ym2);
vcvttps2qqs(zm1|k1|T_z|T_sae, ym2);
vcvttps2qqs(zm1|k1|T_z, ptr [rax+128]);
vcvttps2qqs(zm1|k1|T_z, ptr_b[rax+128]);

//
vcvttps2uqqs(xm1|k1|T_z, xm2);
vcvttps2uqqs(xm1|k1|T_z, ptr [rax+128]);
vcvttps2uqqs(xm1|k1|T_z, ptr_b[rax+128]);

vcvttps2uqqs(ym1|k1|T_z, xm2);
vcvttps2uqqs(ym1|k1|T_z, xm2|T_sae);
vcvttps2uqqs(ym1|k1|T_z, ptr [rax+128]);
vcvttps2uqqs(ym1|k1|T_z, ptr_b[rax+128]);

vcvttps2uqqs(zm1, ym2);
vcvttps2uqqs(zm1|k1|T_z, ym2);
vcvttps2uqqs(zm1|k1|T_z|T_sae, ym2);
vcvttps2uqqs(zm1|k1|T_z, ptr [rax+128]);
vcvttps2uqqs(zm1|k1|T_z, ptr_b[rax+128]);

//
vcvttsd2sis(eax, xm1);
vcvttsd2sis(eax, xm1|T_sae);
vcvttsd2sis(eax, ptr[rax+128]);

vcvttsd2sis(r30, xm1);
vcvttsd2sis(r30, xm1|T_sae);
vcvttsd2sis(r30, ptr[rax+128]);
//
vcvttsd2usis(eax, xm1);
vcvttsd2usis(eax, xm1|T_sae);
vcvttsd2usis(eax, ptr[rax+128]);

vcvttsd2usis(r30, xm1);
vcvttsd2usis(r30, xm1|T_sae);
vcvttsd2usis(r30, ptr[rax+128]);
//
vcvttss2sis(eax, xm1);
vcvttss2sis(eax, xm1|T_sae);
vcvttss2sis(eax, ptr[rax+128]);

vcvttss2sis(r30, xm1);
vcvttss2sis(r30, xm1|T_sae);
vcvttss2sis(r30, ptr[rax+128]);
//
vcvttss2usis(eax, xm1);
vcvttss2usis(eax, xm1|T_sae);
vcvttss2usis(eax, ptr[rax+128]);

vcvttss2usis(r30, xm1);
vcvttss2usis(r30, xm1|T_sae);
vcvttss2usis(r30, ptr[rax+128]);
9 changes: 9 additions & 0 deletions xbyak/xbyak_mnemonic.h
Original file line number Diff line number Diff line change
Expand Up @@ -2243,9 +2243,11 @@ void vcvtss2sh(const Xmm& x1, const Xmm& x2, const Operand& op) { opAVX_X_X_XM(x
void vcvtss2usi(const Reg32e& r, const Operand& op) { uint64_t type = (T_N4|T_F3|T_0F|T_ER_X|T_MUST_EVEX) | (r.isREG(64) ? T_EW1 : T_EW0); opVex(r, &xm0, op, type, 0x79); }
void vcvttnebf162ibs(const Xmm& x, const Operand& op) { opAVX_X_XM_IMM(x, op, T_F2|T_MAP5|T_EW0|T_YMM|T_MUST_EVEX|T_B16, 0x68); }
void vcvttnebf162iubs(const Xmm& x, const Operand& op) { opAVX_X_XM_IMM(x, op, T_F2|T_MAP5|T_EW0|T_YMM|T_MUST_EVEX|T_B16, 0x6A); }
void vcvttpd2dqs(const Xmm& x, const Operand& op) { opCvt2(x, op, T_MAP5|T_EW1|T_YMM|T_SAE_Y|T_SAE_Z|T_MUST_EVEX|T_B64, 0x6D); }
void vcvttpd2qq(const Xmm& x, const Operand& op) { opAVX_X_XM_IMM(x, op, T_66|T_0F|T_EW1|T_YMM|T_SAE_Z|T_MUST_EVEX|T_B64, 0x7A); }
void vcvttpd2qqs(const Xmm& x, const Operand& op) { opAVX_X_XM_IMM(x, op, T_66|T_MAP5|T_EW1|T_YMM|T_SAE_Y|T_SAE_Z|T_MUST_EVEX|T_B64, 0x6D); }
void vcvttpd2udq(const Xmm& x, const Operand& op) { opCvt2(x, op, T_0F|T_EW1|T_YMM|T_SAE_Z|T_MUST_EVEX|T_B64, 0x78); }
void vcvttpd2udqs(const Xmm& x, const Operand& op) { opCvt2(x, op, T_MAP5|T_EW1|T_YMM|T_SAE_Y|T_SAE_Z|T_MUST_EVEX|T_B64, 0x6C); }
void vcvttpd2uqq(const Xmm& x, const Operand& op) { opAVX_X_XM_IMM(x, op, T_66|T_0F|T_EW1|T_YMM|T_SAE_Z|T_MUST_EVEX|T_B64, 0x78); }
void vcvttpd2uqqs(const Xmm& x, const Operand& op) { opAVX_X_XM_IMM(x, op, T_66|T_MAP5|T_EW1|T_YMM|T_SAE_Y|T_SAE_Z|T_MUST_EVEX|T_B64, 0x6C); }
void vcvttph2dq(const Xmm& x, const Operand& op) { checkCvt1(x, op); opVex(x, 0, op, T_N8|T_N_VL|T_F3|T_MAP5|T_EW0|T_YMM|T_SAE_Y|T_MUST_EVEX|T_B16, 0x5B); }
Expand All @@ -2260,12 +2262,19 @@ void vcvttps2dqs(const Xmm& x, const Operand& op) { opAVX_X_XM_IMM(x, op, T_MAP5
void vcvttps2ibs(const Xmm& x, const Operand& op) { opAVX_X_XM_IMM(x, op, T_66|T_MAP5|T_EW0|T_YMM|T_ER_Y|T_ER_Z|T_MUST_EVEX|T_B32, 0x68); }
void vcvttps2iubs(const Xmm& x, const Operand& op) { opAVX_X_XM_IMM(x, op, T_66|T_MAP5|T_EW0|T_YMM|T_ER_Y|T_ER_Z|T_MUST_EVEX|T_B32, 0x6A); }
void vcvttps2qq(const Xmm& x, const Operand& op) { checkCvt1(x, op); opVex(x, 0, op, T_N8|T_N_VL|T_66|T_0F|T_EW0|T_YMM|T_SAE_Y|T_MUST_EVEX|T_B32, 0x7A); }
void vcvttps2qqs(const Xmm& x, const Operand& op) { checkCvt1(x, op); opVex(x, 0, op, T_N8|T_N_VL|T_66|T_MAP5|T_EW0|T_YMM|T_SAE_X|T_SAE_Y|T_MUST_EVEX|T_B32, 0x6D); }
void vcvttps2udq(const Xmm& x, const Operand& op) { opAVX_X_XM_IMM(x, op, T_0F|T_EW0|T_YMM|T_SAE_Z|T_MUST_EVEX|T_B32, 0x78); }
void vcvttps2udqs(const Xmm& x, const Operand& op) { opAVX_X_XM_IMM(x, op, T_MAP5|T_EW0|T_YMM|T_SAE_Y|T_SAE_Z|T_MUST_EVEX|T_B32, 0x6C); }
void vcvttps2uqq(const Xmm& x, const Operand& op) { checkCvt1(x, op); opVex(x, 0, op, T_N8|T_N_VL|T_66|T_0F|T_EW0|T_YMM|T_SAE_Y|T_MUST_EVEX|T_B32, 0x78); }
void vcvttps2uqqs(const Xmm& x, const Operand& op) { checkCvt1(x, op); opVex(x, 0, op, T_N8|T_N_VL|T_66|T_MAP5|T_EW0|T_YMM|T_SAE_X|T_SAE_Y|T_MUST_EVEX|T_B32, 0x6C); }
void vcvttsd2sis(const Reg32e& r, const Operand& op) { uint64_t type = (T_N8|T_F2|T_MAP5|T_EW0|T_SAE_X|T_MUST_EVEX) | (r.isREG(64) ? T_EW1 : T_EW0); opVex(r, &xm0, op, type, 0x6D); }
void vcvttsd2usi(const Reg32e& r, const Operand& op) { uint64_t type = (T_N8|T_F2|T_0F|T_SAE_X|T_MUST_EVEX) | (r.isREG(64) ? T_EW1 : T_EW0); opVex(r, &xm0, op, type, 0x78); }
void vcvttsd2usis(const Reg32e& r, const Operand& op) { uint64_t type = (T_N8|T_F2|T_MAP5|T_EW0|T_SAE_X|T_MUST_EVEX) | (r.isREG(64) ? T_EW1 : T_EW0); opVex(r, &xm0, op, type, 0x6C); }
void vcvttsh2si(const Reg32e& r, const Operand& op) { uint64_t type = (T_N2|T_F3|T_MAP5|T_EW0|T_SAE_X|T_MUST_EVEX) | (r.isREG(64) ? T_EW1 : T_EW0); opVex(r, &xm0, op, type, 0x2C); }
void vcvttsh2usi(const Reg32e& r, const Operand& op) { uint64_t type = (T_N2|T_F3|T_MAP5|T_EW0|T_SAE_X|T_MUST_EVEX) | (r.isREG(64) ? T_EW1 : T_EW0); opVex(r, &xm0, op, type, 0x78); }
void vcvttss2sis(const Reg32e& r, const Operand& op) { uint64_t type = (T_N4|T_F3|T_MAP5|T_EW0|T_SAE_X|T_MUST_EVEX) | (r.isREG(64) ? T_EW1 : T_EW0); opVex(r, &xm0, op, type, 0x6D); }
void vcvttss2usi(const Reg32e& r, const Operand& op) { uint64_t type = (T_N4|T_F3|T_0F|T_SAE_X|T_MUST_EVEX) | (r.isREG(64) ? T_EW1 : T_EW0); opVex(r, &xm0, op, type, 0x78); }
void vcvttss2usis(const Reg32e& r, const Operand& op) { uint64_t type = (T_N4|T_F3|T_MAP5|T_EW0|T_SAE_X|T_MUST_EVEX) | (r.isREG(64) ? T_EW1 : T_EW0); opVex(r, &xm0, op, type, 0x6C); }
void vcvtudq2pd(const Xmm& x, const Operand& op) { checkCvt1(x, op); opVex(x, 0, op, T_N8|T_N_VL|T_F3|T_0F|T_EW0|T_YMM|T_MUST_EVEX|T_B32, 0x7A); }
void vcvtudq2ph(const Xmm& x, const Operand& op) { checkCvt4(x, op); opCvt(x, op, T_N16|T_N_VL|T_F2|T_MAP5|T_EW0|T_ER_Z|T_MUST_EVEX|T_B32, 0x7A); }
void vcvtudq2ps(const Xmm& x, const Operand& op) { opAVX_X_XM_IMM(x, op, T_F2|T_0F|T_EW0|T_YMM|T_ER_Z|T_MUST_EVEX|T_B32, 0x7A); }
Expand Down

0 comments on commit de32c7e

Please sign in to comment.