Skip to content

Commit

Permalink
pdep, pext support apx
Browse files Browse the repository at this point in the history
  • Loading branch information
herumi committed Nov 10, 2023
1 parent 16f1a5d commit 3a85aad
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
4 changes: 2 additions & 2 deletions gen/gen_code.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1734,8 +1734,8 @@ void put()
} tbl[] = {
{ "andn", T_0F38 | T_VEX | T_NF, 0xF2 },
{ "mulx", T_F2 | T_0F38 | T_VEX , 0xF6 },
{ "pdep", T_F2 | T_0F38, 0xF5 },
{ "pext", T_F3 | T_0F38, 0xF5 },
{ "pdep", T_F2 | T_0F38 | T_VEX, 0xF5 },
{ "pext", T_F3 | T_0F38 | T_VEX, 0xF5 },
};
for (size_t i = 0; i < NUM_OF_ARRAY(tbl); i++) {
const Tbl& p = tbl[i];
Expand Down
22 changes: 15 additions & 7 deletions test/apx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,24 +464,32 @@ CYBOZU_TEST_AUTO(andn_etc)
{
andn(rax, rcx, r8); // legacy
andn(rax|T_nf, rcx, r8); // with NF
andn(eax, ecx, r8d); // 32bit
andn(eax, ecx, r17d); // 32bit
andn(r29, r30, r31); // 64bit
andn(r29, r30, ptr [r31+r20*4]);

mulx(rax, rcx, r8);
mulx(eax, ecx, r8d);
mulx(eax, ecx, r17d);
mulx(r29, r30, r31);
mulx(r29, r30, ptr [r31+r20*4]);
pdep(eax, ecx, r17d);
pdep(r29, r30, r31);
pdep(r29, r30, ptr [r31+r20*4]);
pext(eax, ecx, r17d);
pext(r29, r30, r31);
pext(r29, r30, ptr [r31+r20*4]);

}
} c;
const uint8_t tbl[] = {
// andn
0xc4, 0xc2, 0xf0, 0xf2, 0xc0, 0x62, 0xd2, 0xf4, 0x08, 0xf2, 0xc0, 0xc4, 0xc2, 0x70, 0xf2, 0xc0,
0xc4, 0xc2, 0xf0, 0xf2, 0xc0,
0x62, 0xd2, 0xf4, 0x08, 0xf2, 0xc0,
0x62, 0xfa, 0x74, 0x08, 0xf2, 0xc1,
0x62, 0x4a, 0x8c, 0x00, 0xf2, 0xef, 0x62, 0x4a, 0x88, 0x00, 0xf2, 0x2c, 0xa7,

// mulx
0xc4, 0xc2, 0xf3, 0xf6, 0xc0, 0xc4, 0xc2, 0x73, 0xf6, 0xc0, 0x62, 0x4a, 0x8f, 0x00, 0xf6, 0xef,
0x62, 0x4a, 0x8b, 0x00, 0xf6, 0x2c, 0xa7,
0x62, 0xfa, 0x77, 0x08, 0xf6, 0xc1, 0x62, 0x4a, 0x8f, 0x00, 0xf6, 0xef, 0x62, 0x4a, 0x8b, 0x00, 0xf6, 0x2c, 0xa7,
0x62, 0xfa, 0x77, 0x08, 0xf5, 0xc1, 0x62, 0x4a, 0x8f, 0x00, 0xf5, 0xef, 0x62, 0x4a, 0x8b, 0x00, 0xf5, 0x2c, 0xa7,
0x62, 0xfa, 0x76, 0x08, 0xf5, 0xc1, 0x62, 0x4a, 0x8e, 0x00, 0xf5, 0xef, 0x62, 0x4a, 0x8a, 0x00, 0xf5, 0x2c, 0xa7,
};
const size_t n = sizeof(tbl);
CYBOZU_TEST_EQUAL(c.getSize(), n);
Expand Down
4 changes: 2 additions & 2 deletions xbyak/xbyak_mnemonic.h
Original file line number Diff line number Diff line change
Expand Up @@ -616,8 +616,8 @@ void pcmpgtq(const Xmm& xmm, const Operand& op) { opSSE(xmm, op, T_66 | T_0F38,
void pcmpgtw(const Mmx& mmx, const Operand& op) { opMMX(mmx, op, 0x65); }
void pcmpistri(const Xmm& xmm, const Operand& op, uint8_t imm) { opSSE(xmm, op, T_66|T_0F3A, 0x63, isXMM_XMMorMEM, imm); }
void pcmpistrm(const Xmm& xmm, const Operand& op, uint8_t imm) { opSSE(xmm, op, T_66|T_0F3A, 0x62, isXMM_XMMorMEM, imm); }
void pdep(const Reg& r1, const Reg32e& r2, const Operand& op) { opRRO(r1, r2, op, T_F2|T_0F38, 0xf5); }
void pext(const Reg& r1, const Reg32e& r2, const Operand& op) { opRRO(r1, r2, op, T_F3|T_0F38, 0xf5); }
void pdep(const Reg& r1, const Reg32e& r2, const Operand& op) { opRRO(r1, r2, op, T_VEX|T_F2|T_0F38, 0xf5); }
void pext(const Reg& r1, const Reg32e& r2, const Operand& op) { opRRO(r1, r2, op, T_VEX|T_F3|T_0F38, 0xf5); }
void pextrb(const Operand& op, const Xmm& xmm, uint8_t imm) { opExt(op, xmm, 0x14, imm); }
void pextrd(const Operand& op, const Xmm& xmm, uint8_t imm) { opExt(op, xmm, 0x16, imm); }
void pextrw(const Operand& op, const Mmx& xmm, uint8_t imm) { opExt(op, xmm, 0x15, imm, true); }
Expand Down

0 comments on commit 3a85aad

Please sign in to comment.