Skip to content

Commit

Permalink
add tests of shld/shrd
Browse files Browse the repository at this point in the history
  • Loading branch information
herumi committed Nov 20, 2023
1 parent b01c0ed commit ed5dc35
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions test/apx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -965,3 +965,47 @@ CYBOZU_TEST_AUTO(lzcnt)
CYBOZU_TEST_EQUAL(c.getSize(), n);
CYBOZU_TEST_EQUAL_ARRAY(c.getCode(), tbl, n);
}

CYBOZU_TEST_AUTO(shld)
{
struct Code : Xbyak::CodeGenerator {
Code()
{
shld(rax|T_nf, rcx, cl);
shld(r16, rcx, cl);
shld(r16, rcx, 0x9);
shld(r16|T_nf, rcx, 0x9);
shld(r20, r16, rcx, cl);
shld(r20|T_nf, r16, rcx, cl);
shld(r20, r16, rcx, 0x9);
shld(r20|T_nf, r16, rcx, 0x9);
shld(r20, ptr [r21], rcx, 0x9);

shrd(rax|T_nf, rcx, cl);
shrd(r16, rcx, cl);
shrd(r16, rcx, 0x9);
shrd(r16|T_nf, rcx, 0x9);
shrd(r20, r16, rcx, cl);
shrd(r20|T_nf, r16, rcx, cl);
shrd(r20, r16, rcx, 0x9);
shrd(r20|T_nf, r16, rcx, 0x9);
shrd(r20, ptr [r21], rcx, 0x9);
}
} c;
const uint8_t tbl[] = {
// shld
0x62, 0xf4, 0xfc, 0x0c, 0xa5, 0xc8, 0x62, 0xfc, 0xfc, 0x08, 0xa5, 0xc8, 0x62, 0xfc, 0xfc, 0x08,
0x24, 0xc8, 0x09, 0x62, 0xfc, 0xfc, 0x0c, 0x24, 0xc8, 0x09, 0x62, 0xfc, 0xdc, 0x10, 0xa5, 0xc8,
0x62, 0xfc, 0xdc, 0x14, 0xa5, 0xc8, 0x62, 0xfc, 0xdc, 0x10, 0x24, 0xc8, 0x09, 0x62, 0xfc, 0xdc,
0x14, 0x24, 0xc8, 0x09, 0x62, 0xfc, 0xdc, 0x10, 0x24, 0x4d, 0x00, 0x09,
// shrd
0x62, 0xf4, 0xfc, 0x0c, 0xad, 0xc8, 0x62, 0xfc, 0xfc, 0x08, 0xad, 0xc8, 0x62, 0xfc, 0xfc, 0x08,
0x2c, 0xc8, 0x09, 0x62, 0xfc, 0xfc, 0x0c, 0x2c, 0xc8, 0x09, 0x62, 0xfc, 0xdc, 0x10, 0xad, 0xc8,
0x62, 0xfc, 0xdc, 0x14, 0xad, 0xc8, 0x62, 0xfc, 0xdc, 0x10, 0x2c, 0xc8, 0x09, 0x62, 0xfc, 0xdc,
0x14, 0x2c, 0xc8, 0x09, 0x62, 0xfc, 0xdc, 0x10, 0x2c, 0x4d, 0x00, 0x09,

};
const size_t n = sizeof(tbl);
CYBOZU_TEST_EQUAL(c.getSize(), n);
CYBOZU_TEST_EQUAL_ARRAY(c.getCode(), tbl, n);
}

0 comments on commit ed5dc35

Please sign in to comment.