Skip to content

Commit

Permalink
Add unpcklps, unpcklpd, unpckhps, and unpckhpd
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-conway committed Aug 27, 2022
1 parent bd6a8c6 commit 5f9cd5a
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 4 deletions.
10 changes: 10 additions & 0 deletions emu/decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,11 @@ __no_instrument DECODER_RET glue(DECODER_NAME, OP_SIZE)(DECODER_ARGS) {
#endif

#if OP_SIZE == 16
case 0x14: TRACEI("unpcklpd xmm, xmm:modrm");
READMODRM; V_OP(unpackl_pd, xmm_modrm_val, xmm_modrm_reg,128); break;
case 0x15: TRACEI("unpckhpd xmm, xmm:modrm");
READMODRM; V_OP(unpackh_pd, xmm_modrm_val, xmm_modrm_reg,128); break;

case 0x2e: TRACEI("ucomisd xmm, xmm:modrm");
READMODRM; V_OP(single_ucomi, xmm_modrm_val, xmm_modrm_reg,64); break;
case 0x2f: TRACEI("comisd xmm, xmm:modrm");
Expand Down Expand Up @@ -428,6 +433,11 @@ __no_instrument DECODER_RET glue(DECODER_NAME, OP_SIZE)(DECODER_ARGS) {
case 0x11: TRACEI("movups xmm, xmm:modrm");
READMODRM; VMOV(xmm_modrm_reg, xmm_modrm_val,128); break;

case 0x14: TRACEI("unpcklps xmm, xmm:modrm");
READMODRM; V_OP(unpackl_ps, xmm_modrm_val, xmm_modrm_reg,128); break;
case 0x15: TRACEI("unpckhps xmm, xmm:modrm");
READMODRM; V_OP(unpackh_ps, xmm_modrm_val, xmm_modrm_reg,128); break;

case 0x2e: TRACEI("ucomiss xmm, xmm:modrm");
READMODRM; V_OP(single_ucomi, xmm_modrm_val, xmm_modrm_reg,32); break;
case 0x2f: TRACEI("comiss xmm, xmm:modrm");
Expand Down
18 changes: 18 additions & 0 deletions emu/vec.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,14 @@ void vec_unpackl_dq64(NO_CPU, const union mm_reg *src, union mm_reg *dst) {
void vec_unpackl_qdq128(NO_CPU, const union xmm_reg *src, union xmm_reg *dst) {
dst->qw[1] = src->qw[0];
}
void vec_unpackl_ps128(NO_CPU, const union xmm_reg *src, union xmm_reg *dst) {
dst->u32[2] = dst->u32[1];
dst->u32[1] = src->u32[0];
dst->u32[3] = src->u32[1];
}
void vec_unpackl_pd128(NO_CPU, const union xmm_reg *src, union xmm_reg *dst) {
dst->f64[1] = src->f64[0];
}
void vec_unpackh_bw128(NO_CPU, const union xmm_reg *src, union xmm_reg *dst) {
for (int i = 0; i < 8; i++) {
dst->u8[2 * i + 0] = dst->u8[i + 8];
Expand All @@ -421,6 +429,16 @@ void vec_unpackh_dq128(NO_CPU, const union xmm_reg *src, union xmm_reg *dst) {
dst->qw[0] = dst->qw[1];
dst->qw[1] = src->qw[1];
}
void vec_unpackh_ps128(NO_CPU, const union xmm_reg *src, union xmm_reg *dst) {
dst->u32[0] = dst->u32[2];
dst->u32[1] = src->u32[2];
dst->u32[2] = dst->u32[3];
dst->u32[3] = src->u32[3];
}
void vec_unpackh_pd128(NO_CPU, const union xmm_reg *src, union xmm_reg *dst) {
dst->f64[0] = dst->f64[1];
dst->f64[1] = src->f64[1];
}

void vec_packss_w128(NO_CPU, const union xmm_reg *src, union xmm_reg *dst) {
dst->u32[0] = (satw(dst->u16[0]) << 0x00) | (satw(dst->u16[1]) << 0x08) |
Expand Down
5 changes: 5 additions & 0 deletions emu/vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,15 @@ void vec_unpackl_w128(NO_CPU, const union xmm_reg *src, union xmm_reg *dst);
void vec_unpackl_dq128(NO_CPU, const union xmm_reg *src, union xmm_reg *dst);
void vec_unpackl_dq64(NO_CPU, const union mm_reg *src, union mm_reg *dst);
void vec_unpackl_qdq128(NO_CPU, const union xmm_reg *src, union xmm_reg *dst);
void vec_unpackl_ps128(NO_CPU, const union xmm_reg *src, union xmm_reg *dst);
void vec_unpackl_pd128(NO_CPU, const union xmm_reg *src, union xmm_reg *dst);
void vec_unpackh_bw128(NO_CPU, const union xmm_reg *src, union xmm_reg *dst);
void vec_unpackh_w128(NO_CPU, const union xmm_reg *src, union xmm_reg *dst);
void vec_unpackh_d128(NO_CPU, const union xmm_reg *src, union xmm_reg *dst);
void vec_unpackh_dq128(NO_CPU, const union xmm_reg *src, union xmm_reg *dst);
void vec_unpackh_ps128(NO_CPU, const union xmm_reg *src, union xmm_reg *dst);
void vec_unpackh_pd128(NO_CPU, const union xmm_reg *src, union xmm_reg *dst);

void vec_shuffle_lw128(NO_CPU, const union xmm_reg *src, union xmm_reg *dst, uint8_t encoding);
void vec_shuffle_hw128(NO_CPU, const union xmm_reg *src, union xmm_reg *dst, uint8_t encoding);
void vec_shuffle_d128(NO_CPU, const union xmm_reg *src, union xmm_reg *dst, uint8_t encoding);
Expand Down
8 changes: 8 additions & 0 deletions tests/e2e/qemu/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4450,6 +4450,14 @@ xorps : a=dc515cff944a58ec456723c698694873 b=41f21efba9e3e1461f297ccd58bad7ab
xorps : a=231be9e8cde7438d007c62c2085427f8 b=c233e9e8c4c9439a0f76255a085427f8 r=e1280000092e00170f0a479800000000
xorpd : a=dc515cff944a58ec456723c698694873 b=41f21efba9e3e1461f297ccd58bad7ab r=9da342043da9b9aa5a4e5f0bc0d39fd8
xorpd : a=231be9e8cde7438d007c62c2085427f8 b=c233e9e8c4c9439a0f76255a085427f8 r=e1280000092e00170f0a479800000000
unpcklps : a=dc515cff944a58ec456723c698694873 b=41f21efba9e3e1461f297ccd58bad7ab r=1f297ccd456723c658bad7ab98694873
unpcklps : a=231be9e8cde7438d007c62c2085427f8 b=c233e9e8c4c9439a0f76255a085427f8 r=0f76255a007c62c2085427f8085427f8
unpcklpd : a=dc515cff944a58ec456723c698694873 b=41f21efba9e3e1461f297ccd58bad7ab r=1f297ccd58bad7ab456723c698694873
unpcklpd : a=231be9e8cde7438d007c62c2085427f8 b=c233e9e8c4c9439a0f76255a085427f8 r=0f76255a085427f8007c62c2085427f8
unpckhps : a=dc515cff944a58ec456723c698694873 b=41f21efba9e3e1461f297ccd58bad7ab r=41f21efbdc515cffa9e3e146944a58ec
unpckhps : a=231be9e8cde7438d007c62c2085427f8 b=c233e9e8c4c9439a0f76255a085427f8 r=c233e9e8231be9e8c4c9439acde7438d
unpckhpd : a=dc515cff944a58ec456723c698694873 b=41f21efba9e3e1461f297ccd58bad7ab r=41f21efba9e3e146dc515cff944a58ec
unpckhpd : a=231be9e8cde7438d007c62c2085427f8 b=c233e9e8c4c9439a0f76255a085427f8 r=c233e9e8c4c9439a231be9e8cde7438d
pshufd : a=dc515cff944a58ec456723c698694873 ib=78 r=456723c6dc515cff944a58ec98694873
pshufd : a=231be9e8cde7438d007c62c2085427f8 ib=78 r=007c62c2231be9e8cde7438d085427f8
pshuflw : a=dc515cff944a58ec456723c698694873 ib=78 r=dc515cff944a58ec9869456723c64873
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/qemu/qemu-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -2545,10 +2545,10 @@ void test_sse(void)
SSE_OP2(xorps);
SSE_OP2(xorpd);

// SSE_OP2(unpcklps);
// SSE_OP2(unpcklpd);
// SSE_OP2(unpckhps);
// SSE_OP2(unpckhpd);
SSE_OP2(unpcklps);
SSE_OP2(unpcklpd);
SSE_OP2(unpckhps);
SSE_OP2(unpckhpd);

// SHUF_OP(shufps, 0x78);
// SHUF_OP(shufpd, 0x02);
Expand Down

0 comments on commit 5f9cd5a

Please sign in to comment.