2020-04-22 20:25:57 +01:00
|
|
|
#define XBYAK_NO_OP_NAMES
|
|
|
|
#include <xbyak/xbyak_util.h>
|
|
|
|
|
|
|
|
#ifdef XBYAK32
|
|
|
|
#error "this sample is for only 64-bit mode"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
using namespace Xbyak::util;
|
|
|
|
|
|
|
|
struct Code : public Xbyak::CodeGenerator {
|
|
|
|
void gen1()
|
|
|
|
{
|
|
|
|
StackFrame sf(this, 1);
|
|
|
|
mov(rax, sf.p[0]);
|
|
|
|
}
|
|
|
|
void gen2()
|
|
|
|
{
|
|
|
|
StackFrame sf(this, 2);
|
|
|
|
lea(rax, ptr [sf.p[0] + sf.p[1]]);
|
|
|
|
}
|
|
|
|
void gen3()
|
|
|
|
{
|
|
|
|
StackFrame sf(this, 3);
|
|
|
|
mov(rax, sf.p[0]);
|
|
|
|
add(rax, sf.p[1]);
|
|
|
|
add(rax, sf.p[2]);
|
|
|
|
}
|
|
|
|
void gen4()
|
|
|
|
{
|
|
|
|
StackFrame sf(this, 4);
|
|
|
|
mov(rax, sf.p[0]);
|
|
|
|
add(rax, sf.p[1]);
|
|
|
|
add(rax, sf.p[2]);
|
|
|
|
add(rax, sf.p[3]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void gen5()
|
|
|
|
{
|
|
|
|
StackFrame sf(this, 4, UseRCX);
|
|
|
|
xor_(rcx, rcx);
|
|
|
|
mov(rax, sf.p[0]);
|
|
|
|
add(rax, sf.p[1]);
|
|
|
|
add(rax, sf.p[2]);
|
|
|
|
add(rax, sf.p[3]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void gen6()
|
|
|
|
{
|
|
|
|
StackFrame sf(this, 4, UseRCX | UseRDX);
|
|
|
|
xor_(rcx, rcx);
|
|
|
|
xor_(rdx, rdx);
|
|
|
|
mov(rax, sf.p[0]);
|
|
|
|
add(rax, sf.p[1]);
|
|
|
|
add(rax, sf.p[2]);
|
|
|
|
add(rax, sf.p[3]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void gen7()
|
|
|
|
{
|
|
|
|
StackFrame sf(this, 3, UseRCX | UseRDX);
|
|
|
|
xor_(rcx, rcx);
|
|
|
|
xor_(rdx, rdx);
|
|
|
|
mov(rax, sf.p[0]);
|
|
|
|
add(rax, sf.p[1]);
|
|
|
|
add(rax, sf.p[2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void gen8()
|
|
|
|
{
|
|
|
|
StackFrame sf(this, 3, 3 | UseRCX | UseRDX);
|
|
|
|
xor_(rcx, rcx);
|
|
|
|
xor_(rdx, rdx);
|
|
|
|
mov(sf.t[0], 1);
|
|
|
|
mov(sf.t[1], 2);
|
|
|
|
mov(sf.t[2], 3);
|
|
|
|
mov(rax, sf.p[0]);
|
|
|
|
add(rax, sf.p[1]);
|
|
|
|
add(rax, sf.p[2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void gen9()
|
|
|
|
{
|
|
|
|
StackFrame sf(this, 3, 3 | UseRCX | UseRDX, 32);
|
|
|
|
xor_(rcx, rcx);
|
|
|
|
xor_(rdx, rdx);
|
|
|
|
mov(sf.t[0], 1);
|
|
|
|
mov(sf.t[1], 2);
|
|
|
|
mov(sf.t[2], 3);
|
|
|
|
mov(rax, sf.p[0]);
|
|
|
|
add(rax, sf.p[1]);
|
|
|
|
add(rax, sf.p[2]);
|
|
|
|
mov(ptr [rsp + 8 * 0], rax);
|
|
|
|
mov(ptr [rsp + 8 * 1], rax);
|
|
|
|
mov(ptr [rsp + 8 * 2], rax);
|
|
|
|
mov(ptr [rsp + 8 * 3], rax);
|
|
|
|
}
|
|
|
|
|
|
|
|
void gen10()
|
|
|
|
{
|
|
|
|
StackFrame sf(this, 4, 8 | UseRCX | UseRDX, 32);
|
|
|
|
xor_(rcx, rcx);
|
|
|
|
xor_(rdx, rdx);
|
|
|
|
for (int i = 0; i < 8; i++) {
|
|
|
|
mov(sf.t[i], i);
|
|
|
|
}
|
|
|
|
mov(rax, sf.p[0]);
|
|
|
|
add(rax, sf.p[1]);
|
|
|
|
add(rax, sf.p[2]);
|
|
|
|
add(rax, sf.p[3]);
|
|
|
|
mov(ptr [rsp + 8 * 0], rax);
|
|
|
|
mov(ptr [rsp + 8 * 1], rax);
|
|
|
|
mov(ptr [rsp + 8 * 2], rax);
|
|
|
|
mov(ptr [rsp + 8 * 3], rax);
|
|
|
|
}
|
|
|
|
|
|
|
|
void gen11()
|
|
|
|
{
|
|
|
|
StackFrame sf(this, 0, UseRCX);
|
|
|
|
xor_(rcx, rcx);
|
|
|
|
mov(rax, 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
void gen12()
|
|
|
|
{
|
|
|
|
StackFrame sf(this, 4, UseRDX);
|
|
|
|
xor_(rdx, rdx);
|
|
|
|
mov(rax, sf.p[0]);
|
|
|
|
add(rax, sf.p[1]);
|
|
|
|
add(rax, sf.p[2]);
|
|
|
|
add(rax, sf.p[3]);
|
|
|
|
}
|
2020-04-22 20:59:14 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
int64_t f(const int64_t a[13]) { return sum-of-a[]; }
|
|
|
|
*/
|
|
|
|
void gen13()
|
|
|
|
{
|
|
|
|
StackFrame sf(this, 1, 13);
|
|
|
|
for (int i = 0; i < 13; i++) {
|
|
|
|
mov(sf.t[i], ptr[sf.p[0] + i * 8]);
|
|
|
|
}
|
|
|
|
mov(rax, sf.t[0]);
|
|
|
|
for (int i = 1; i < 13; i++) {
|
|
|
|
add(rax, sf.t[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
same as gen13
|
|
|
|
*/
|
|
|
|
void gen14()
|
|
|
|
{
|
|
|
|
StackFrame sf(this, 1, 11 | UseRCX | UseRDX);
|
|
|
|
Pack t = sf.t;
|
|
|
|
t.append(rcx);
|
|
|
|
t.append(rdx);
|
|
|
|
for (int i = 0; i < 13; i++) {
|
|
|
|
mov(t[i], ptr[sf.p[0] + i * 8]);
|
|
|
|
}
|
|
|
|
mov(rax, t[0]);
|
|
|
|
for (int i = 1; i < 13; i++) {
|
|
|
|
add(rax, t[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
return (1 << 15) - 1;
|
|
|
|
*/
|
|
|
|
void gen15()
|
|
|
|
{
|
|
|
|
StackFrame sf(this, 0, 14, 8);
|
|
|
|
Pack t = sf.t;
|
|
|
|
t.append(rax);
|
|
|
|
for (int i = 0; i < 15; i++) {
|
|
|
|
mov(t[i], 1 << i);
|
|
|
|
}
|
|
|
|
mov(qword[rsp], 0);
|
|
|
|
for (int i = 0; i < 15; i++) {
|
|
|
|
add(ptr[rsp], t[i]);
|
|
|
|
}
|
|
|
|
mov(rax, ptr[rsp]);
|
|
|
|
}
|
2020-04-22 20:25:57 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Code2 : Xbyak::CodeGenerator {
|
|
|
|
Code2()
|
|
|
|
: Xbyak::CodeGenerator(4096 * 32)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
void gen(int pNum, int tNum, int stackSizeByte)
|
|
|
|
{
|
|
|
|
StackFrame sf(this, pNum, tNum, stackSizeByte);
|
|
|
|
if (tNum & UseRCX) xor_(rcx, rcx);
|
|
|
|
if (tNum & UseRDX) xor_(rdx, rdx);
|
|
|
|
for (int i = 0, n = tNum & ~(UseRCX | UseRDX); i < n; i++) {
|
|
|
|
mov(sf.t[i], 5);
|
|
|
|
}
|
|
|
|
for (int i = 0; i < stackSizeByte; i++) {
|
|
|
|
mov(byte [rsp + i], 0);
|
|
|
|
}
|
|
|
|
mov(rax, 1);
|
|
|
|
for (int i = 0; i < pNum; i++) {
|
|
|
|
add(rax, sf.p[i]);
|
|
|
|
}
|
|
|
|
}
|
2020-04-22 20:59:14 +01:00
|
|
|
void gen2(int pNum, int tNum, int stackSizeByte)
|
|
|
|
{
|
|
|
|
StackFrame sf(this, pNum, tNum, stackSizeByte);
|
|
|
|
mov(rax, rsp);
|
|
|
|
}
|
2020-04-22 20:25:57 +01:00
|
|
|
};
|
|
|
|
|
2020-04-22 20:59:14 +01:00
|
|
|
|
2020-04-22 20:25:57 +01:00
|
|
|
static int errNum = 0;
|
|
|
|
void check(int x, int y)
|
|
|
|
{
|
|
|
|
if (x != y) {
|
|
|
|
printf("err x=%d, y=%d\n", x, y);
|
|
|
|
errNum++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Squashed 'externals/xbyak/' changes from 590c10e37..9357732aa
9357732aa v6.06
b161a3eb7 update changelog
e5453b064 Merge branch 'dev'
2a265d9d9 memfd: keep file descriptor open during allocation lifetime
31ff018ed replace unsigned int with uint32_t in xbyak_util.h
e427b2231 move Type into Cpu
8cf41063b refactoring Cpu
66d62968d add -cpuid to test_util
cf7cb744c add comments
028112949 add detection of clzero
c88007b03 update doc
4cb2e77a9 v6.052
015c27cf6 Merge branch 'dev'
d808f9ecb add test of Cpu::has
b48a7bb1b add operator== to Type
1a90f456c v6.051
96cb1d660 update changelog
1f5a77f56 Merge branch 'dev'
87e14f02a add test with noexception
30144f809 fix error when XBYAK_NO_EXCEPTION is defined
ec15751df Merge branch 'dev'
4831b3fb3 v6.05
9ddf251f3 remove debug code
905b31bab fix typo
72d1ac118 add movdir64b
a6665996b add detection of movdir64b
92ddc6dfd remove Type::operator<<() because it's ambiguous
9cdd40f5e add detection of movdiri
379f8bf37 add movdiri
0ad6db138 fix cldemote test for 32-bit
84ab46bb3 add cldemote to Cpu
a84ddc12d support cldemote
3a6cc626e add clwb
38c40c02e detection of clflushopt
c061ac839 avoid unnecessary replacement in readme.md
095ebbff1 extend Cpu::Type to 128 bit
3ea8e45d3 Merge branch 'dev'
f7bfc2634 v6.041
ab4e52d67 update doc
2bef54399 include intrin.h on mingw
621ed0775 Merge branch 'dev'
4f5893e1e memfd_create: disable for ANDROID_API < 30
684d69db0 Merge branch 'dev'
ea88b6d85 disable warning on mingw
7e8923fa5 add colon
9914216bd Merge branch 'dev'
b335602ff [skip ci] tweak doc
25fbb3996 tweak doc
122054dc4 Formatted Supported OS Section
d4fa7e46b Reworked Authors Section
9e4b64a74 Adjusted Spacing
ff9fdb45f Use Github Sponsor Widget
893b31d46 Added Quicklinks
2d2adf78b Added License Badge
335b5941b Formatted Header
70603addf Moved Install / Usage Into Dedicated Files
1659d28fe Moved History Into Dedicated File
fb953284b Merge branch 'dev'
dbd96b277 add news
898c354e6 v6.04
f8e2ad1e9 add waitpkg detection to Cpu
a220fd69a add umwait
64ec053e6 add umonitor
764d54f6f add tpause
c68646e8d remove warning of vc
4e8214ca2 Merge branch 'dev'
360f4b673 test badSSE only for 32-bit mode
a9fddc454 fix typo of readme
250b5dc39 fix typo of readme
c46e92756 Merge branch 'dev'
31b7cd350 v6.03
a2f9ed085 rename isValidXMm to isValidSSE
2bc8fcbd3 add tests to badSSE
6de93fb88 add baseSSE test
e2eda384c update doc
71a7b1773 fix condition to throw error for SSE instructions when using XMM16-XMM31
615b665cc sample/memfd shows /proc/self/maps
2861517f2 add memfd sample
507b0285e apt update at first
452c07f77 typedef for no-MmapAllocator
8af6e2026 minimize diff
0af3b5d07 Allocator: take optional name parameter and use it with memfd
a67e24505 Merge branch 'dev'
b3892c15e Merge pull request #138 from Tachi107/make-cxx-cpp-ld-flags
b4eddaced build(make): honour CXXFLAGS, CPPFLAGS and LDFLAGS
fbe60e590 test generates only a.asm
0a4a7571d Merge branch 'patch-1' of https://github.com/Tachi107/xbyak into Tachi107-patch-1
55b9f131b build(make): fix clean target in test/Makefile
7aef3ff54 Merge branch 'dev'
82e0deb8a v6.02
4d9906a94 fix condition to throw error for invalid displacements
c79311a51 fix test_util.cpp
9b2c175b3 Merge branch 'dev'
06d797e33 Allow parallel feature checks
2a85bba3f Merge branch 'dev'
8d5af80a6 v6.01
df39606fe update doc
08f11817c supprt retf
1abfc3465 support call(mem, T_FAR)
fb158f901 support jmp(mem, T_FAR)
9be47ceb2 Merge branch 'lioncash-hlt' into dev
3162eb16f add test of hlt
bb55725a9 xbyak: Add hlt opcode function
47cf85fdb fix conflict
b29e471ea build(meson): fix CMake Config file include dir
2cc21925f delete the sentences translated into Japanese from COPYRIGHT
dca3930de remove tabs
cecd204a5 Merge pull request #129 from Tachi107/meson-cmake-config
345de8a54 build(meson): generate CMake package config files
e831805cc revert change of the type of Pack::util::operator[]
fc9d953e5 util::Pack has not pointer but instance of Reg64
0868c54a9 use _WIN32 instead of _MSC_VER for mingw64
894a1b14a use original uint8_t
dfc079ca1 add cstrs of Xbyak::util::Pack for 11 or 12 args
06e8f531f Merge branch 'Tachi107-meson' into dev
ef90b6bd2 Makefile updates the version of meson.build
0000938f5 build: add Meson support This allows Meson users to use xbyak more easly, while it also provides a pkg-config file generator, useful to Linux distributions
757e4063f v6.00
b3489f548 add vcvtusi2sh
16d9898ab add vcvtsi2sh
cfc03cb8f unify T_66, T_F3, T_F2 flags
02fa7057d add vcvttph2qq
4e72a9dc4 add vcvttsh2usi
05d08e05b add vcvttsh2si
621e6548c add vcvtsh2usi
34abda5c5 extend vcvtps2ph
facd622b2 add vcvtw2ph
270af1cb2 add vcvtuw2ph
17dc697cd add vcvttph2w
62f022aea vcvttph2uw
836346bfd add vcvtph2w
300edb37b add vcvtph2uw
737904b5a add vcvtuqq2ph
52b2ebf18 add vcvtqq2ph
6761f1e05 add vcvtpd2ph
03f95b7e3 add vcvtudq2ph
64430b2bb add vcvtps2phx
88e426aa4 add vcvtdq2ph
bf28a94a5 add vcvttph2uqq
4c4e665d3 add vcvtph2uqq
2b0099b63 add vcvtph2qq
3ff69a474 add vcvtph2pd
678b52956 add vcvttph2udq
72a5717e4 add vcvttph2dq
524d52bf6 add vcvtph2udq
d1cf4db97 add vcvtph2psx
fccd2c49b add vcvtph2dq
6530f4099 refactor gen-cvt
c51e16156 tweak
ed9f6c72a add vcvtsh2si
ac1407bd1 add vcvtss2sh
2958a19bb add vcvtsh2ss
10d683303 add vcvtsh2sd
3920c950c add vcvtsd2sh
9a1b73932 add vmovw
d86e4882f vmovsh xmm, addr
61f85a204 add vmovsh
847166cef add tests of vgetmant{ph,sh}
c11a21cf4 add vgetmantph
55ab361f0 add tests of vgetexp{ph,sh}
8653f4152 add vgetexpsh
697eeb627 add vgetexpph
ee920a991 add vfpclasssh
7aed436e6 add vfpclassph
56dca14e4 v5.997
b3b1e4e3c fix vrndscale* to support {sae}
681077eb1 add vrndscalesh
2f14eae85 add vrndscaleph
f96870a44 add vreducesh
043c94ae9 add vreduceph
37bf3bb49 add vscalefsh
c16f91c59 add vscalefph
61ad45935 add vsqrtsh
e00b508d5 add vsqrtph
52765d54f add vrsqrtsh
2ec6a7ab4 add vrsqrtph
b1ff7891d add vrcpph, vrcpsh
4f543ca0e add vucomish
412b95f02 add vf{,c}mulcph
9fc53baed add vf{,c}maddcph
0098ce98d add vf{,n}m{sub,add}sh
849dffb10 add vfmadd, vfnmadd, vfnmsub for avx512-fp16
eadb93d0b add vfmsubaddcph
9b8802cba add vfmaddsub{132,213,231}ph
ab9481b4c add vcomish
cd036ea17 fix vcmpsh
b494b321a vcmpsh supports ptr_b
eb2d63c83 vcmpph uses T_B16
a480b3dd9 v5.996
16d18b1d4 fix v{add,sub,mul,...}{sd,ss} to support T_rd_sae etc.
66c6ca1ab support vaddsh with T_rd_sae
6333ec099 add m16bcst
84053c8e7 add vcmpph
5df23d263 move FP16 to AVX-512
d5c7336f8 fix disp scaling of v{add,sub,mul,div,max,min}sh
ebf29542d add vaddsh test
f29689d02 add test of vaddph
2c4b6ac16 add v{add,sub,mul,div,min,max}{ph,sh}
edf3c2f6f remove mask for mmm
2c561aad6 add T_MAP5 and T_MAP6
acd360c38 add Cpu::tAVX512_FP16
1554f479c remove unused flags(tSSE4a and tSSE5) of Cpu
c313a8758 update CMakeLists.txt version
740b39e24 Merge pull request #122 from abouvier/cmake
10a1e5759 v5.995
0a557a099 rename XBYAK_MEMFD_CREATE to XBYAK_USE_MEMFD
0ad9b9bbe Merge branch 'captain5050-master' into dev
c7bb66383 fix for mac and enable it if XBYAK_MEMFD_CREATE is defined
c1e6569f1 fix cmake config files
ccd4130ec Name mmap pages on Linux with memfd_create
2fb843c32 v5.994
413a66b44 add alias of vcmpXX{ps,pd,ss,sd} for mask register
6f4f76890 v5.993
19043cb9a add test for gather/scatter
b5acb1d1c gather test does not generate bad combination of regs
67ec1674a check restriction of gather/scatter regs
ea9814f4f check bad reg combination of gather
a34850b2d add endbr32 and endbr64
git-subtree-dir: externals/xbyak
git-subtree-split: 9357732aa2aa3cf97809027596dfa5c61d1515b2
2022-06-05 13:31:49 +01:00
|
|
|
void verify(const uint8_t *f, int pNum)
|
2020-04-22 20:25:57 +01:00
|
|
|
{
|
|
|
|
switch (pNum) {
|
|
|
|
case 0:
|
2020-04-22 20:59:14 +01:00
|
|
|
check(1, reinterpret_cast<int (*)()>(f)());
|
2020-04-22 20:25:57 +01:00
|
|
|
return;
|
|
|
|
case 1:
|
2020-04-22 20:59:14 +01:00
|
|
|
check(11, reinterpret_cast<int (*)(int)>(f)(10));
|
2020-04-22 20:25:57 +01:00
|
|
|
return;
|
|
|
|
case 2:
|
2020-04-22 20:59:14 +01:00
|
|
|
check(111, reinterpret_cast<int (*)(int, int)>(f)(10, 100));
|
2020-04-22 20:25:57 +01:00
|
|
|
return;
|
|
|
|
case 3:
|
2020-04-22 20:59:14 +01:00
|
|
|
check(1111, reinterpret_cast<int (*)(int, int, int)>(f)(10, 100, 1000));
|
2020-04-22 20:25:57 +01:00
|
|
|
return;
|
|
|
|
case 4:
|
2020-04-22 20:59:14 +01:00
|
|
|
check(11111, reinterpret_cast<int (*)(int, int, int, int)>(f)(10, 100, 1000, 10000));
|
2020-04-22 20:25:57 +01:00
|
|
|
return;
|
|
|
|
default:
|
|
|
|
printf("ERR pNum=%d\n", pNum);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void testAll()
|
|
|
|
{
|
|
|
|
Code2 code;
|
|
|
|
for (int stackSize = 0; stackSize < 32; stackSize += 7) {
|
|
|
|
for (int pNum = 0; pNum < 4; pNum++) {
|
|
|
|
for (int mode = 0; mode < 4; mode++) {
|
|
|
|
int maxNum = 0;
|
|
|
|
int opt = 0;
|
|
|
|
if (mode == 0) {
|
|
|
|
maxNum = 10;
|
|
|
|
} else if (mode == 1) {
|
|
|
|
maxNum = 9;
|
|
|
|
opt = UseRCX;
|
|
|
|
} else if (mode == 2) {
|
|
|
|
maxNum = 9;
|
|
|
|
opt = UseRDX;
|
|
|
|
} else {
|
|
|
|
maxNum = 8;
|
|
|
|
opt = UseRCX | UseRDX;
|
|
|
|
}
|
|
|
|
for (int tNum = 0; tNum < maxNum; tNum++) {
|
|
|
|
// printf("pNum=%d, tNum=%d, stackSize=%d\n", pNum, tNum | opt, stackSize);
|
Squashed 'externals/xbyak/' changes from 590c10e37..9357732aa
9357732aa v6.06
b161a3eb7 update changelog
e5453b064 Merge branch 'dev'
2a265d9d9 memfd: keep file descriptor open during allocation lifetime
31ff018ed replace unsigned int with uint32_t in xbyak_util.h
e427b2231 move Type into Cpu
8cf41063b refactoring Cpu
66d62968d add -cpuid to test_util
cf7cb744c add comments
028112949 add detection of clzero
c88007b03 update doc
4cb2e77a9 v6.052
015c27cf6 Merge branch 'dev'
d808f9ecb add test of Cpu::has
b48a7bb1b add operator== to Type
1a90f456c v6.051
96cb1d660 update changelog
1f5a77f56 Merge branch 'dev'
87e14f02a add test with noexception
30144f809 fix error when XBYAK_NO_EXCEPTION is defined
ec15751df Merge branch 'dev'
4831b3fb3 v6.05
9ddf251f3 remove debug code
905b31bab fix typo
72d1ac118 add movdir64b
a6665996b add detection of movdir64b
92ddc6dfd remove Type::operator<<() because it's ambiguous
9cdd40f5e add detection of movdiri
379f8bf37 add movdiri
0ad6db138 fix cldemote test for 32-bit
84ab46bb3 add cldemote to Cpu
a84ddc12d support cldemote
3a6cc626e add clwb
38c40c02e detection of clflushopt
c061ac839 avoid unnecessary replacement in readme.md
095ebbff1 extend Cpu::Type to 128 bit
3ea8e45d3 Merge branch 'dev'
f7bfc2634 v6.041
ab4e52d67 update doc
2bef54399 include intrin.h on mingw
621ed0775 Merge branch 'dev'
4f5893e1e memfd_create: disable for ANDROID_API < 30
684d69db0 Merge branch 'dev'
ea88b6d85 disable warning on mingw
7e8923fa5 add colon
9914216bd Merge branch 'dev'
b335602ff [skip ci] tweak doc
25fbb3996 tweak doc
122054dc4 Formatted Supported OS Section
d4fa7e46b Reworked Authors Section
9e4b64a74 Adjusted Spacing
ff9fdb45f Use Github Sponsor Widget
893b31d46 Added Quicklinks
2d2adf78b Added License Badge
335b5941b Formatted Header
70603addf Moved Install / Usage Into Dedicated Files
1659d28fe Moved History Into Dedicated File
fb953284b Merge branch 'dev'
dbd96b277 add news
898c354e6 v6.04
f8e2ad1e9 add waitpkg detection to Cpu
a220fd69a add umwait
64ec053e6 add umonitor
764d54f6f add tpause
c68646e8d remove warning of vc
4e8214ca2 Merge branch 'dev'
360f4b673 test badSSE only for 32-bit mode
a9fddc454 fix typo of readme
250b5dc39 fix typo of readme
c46e92756 Merge branch 'dev'
31b7cd350 v6.03
a2f9ed085 rename isValidXMm to isValidSSE
2bc8fcbd3 add tests to badSSE
6de93fb88 add baseSSE test
e2eda384c update doc
71a7b1773 fix condition to throw error for SSE instructions when using XMM16-XMM31
615b665cc sample/memfd shows /proc/self/maps
2861517f2 add memfd sample
507b0285e apt update at first
452c07f77 typedef for no-MmapAllocator
8af6e2026 minimize diff
0af3b5d07 Allocator: take optional name parameter and use it with memfd
a67e24505 Merge branch 'dev'
b3892c15e Merge pull request #138 from Tachi107/make-cxx-cpp-ld-flags
b4eddaced build(make): honour CXXFLAGS, CPPFLAGS and LDFLAGS
fbe60e590 test generates only a.asm
0a4a7571d Merge branch 'patch-1' of https://github.com/Tachi107/xbyak into Tachi107-patch-1
55b9f131b build(make): fix clean target in test/Makefile
7aef3ff54 Merge branch 'dev'
82e0deb8a v6.02
4d9906a94 fix condition to throw error for invalid displacements
c79311a51 fix test_util.cpp
9b2c175b3 Merge branch 'dev'
06d797e33 Allow parallel feature checks
2a85bba3f Merge branch 'dev'
8d5af80a6 v6.01
df39606fe update doc
08f11817c supprt retf
1abfc3465 support call(mem, T_FAR)
fb158f901 support jmp(mem, T_FAR)
9be47ceb2 Merge branch 'lioncash-hlt' into dev
3162eb16f add test of hlt
bb55725a9 xbyak: Add hlt opcode function
47cf85fdb fix conflict
b29e471ea build(meson): fix CMake Config file include dir
2cc21925f delete the sentences translated into Japanese from COPYRIGHT
dca3930de remove tabs
cecd204a5 Merge pull request #129 from Tachi107/meson-cmake-config
345de8a54 build(meson): generate CMake package config files
e831805cc revert change of the type of Pack::util::operator[]
fc9d953e5 util::Pack has not pointer but instance of Reg64
0868c54a9 use _WIN32 instead of _MSC_VER for mingw64
894a1b14a use original uint8_t
dfc079ca1 add cstrs of Xbyak::util::Pack for 11 or 12 args
06e8f531f Merge branch 'Tachi107-meson' into dev
ef90b6bd2 Makefile updates the version of meson.build
0000938f5 build: add Meson support This allows Meson users to use xbyak more easly, while it also provides a pkg-config file generator, useful to Linux distributions
757e4063f v6.00
b3489f548 add vcvtusi2sh
16d9898ab add vcvtsi2sh
cfc03cb8f unify T_66, T_F3, T_F2 flags
02fa7057d add vcvttph2qq
4e72a9dc4 add vcvttsh2usi
05d08e05b add vcvttsh2si
621e6548c add vcvtsh2usi
34abda5c5 extend vcvtps2ph
facd622b2 add vcvtw2ph
270af1cb2 add vcvtuw2ph
17dc697cd add vcvttph2w
62f022aea vcvttph2uw
836346bfd add vcvtph2w
300edb37b add vcvtph2uw
737904b5a add vcvtuqq2ph
52b2ebf18 add vcvtqq2ph
6761f1e05 add vcvtpd2ph
03f95b7e3 add vcvtudq2ph
64430b2bb add vcvtps2phx
88e426aa4 add vcvtdq2ph
bf28a94a5 add vcvttph2uqq
4c4e665d3 add vcvtph2uqq
2b0099b63 add vcvtph2qq
3ff69a474 add vcvtph2pd
678b52956 add vcvttph2udq
72a5717e4 add vcvttph2dq
524d52bf6 add vcvtph2udq
d1cf4db97 add vcvtph2psx
fccd2c49b add vcvtph2dq
6530f4099 refactor gen-cvt
c51e16156 tweak
ed9f6c72a add vcvtsh2si
ac1407bd1 add vcvtss2sh
2958a19bb add vcvtsh2ss
10d683303 add vcvtsh2sd
3920c950c add vcvtsd2sh
9a1b73932 add vmovw
d86e4882f vmovsh xmm, addr
61f85a204 add vmovsh
847166cef add tests of vgetmant{ph,sh}
c11a21cf4 add vgetmantph
55ab361f0 add tests of vgetexp{ph,sh}
8653f4152 add vgetexpsh
697eeb627 add vgetexpph
ee920a991 add vfpclasssh
7aed436e6 add vfpclassph
56dca14e4 v5.997
b3b1e4e3c fix vrndscale* to support {sae}
681077eb1 add vrndscalesh
2f14eae85 add vrndscaleph
f96870a44 add vreducesh
043c94ae9 add vreduceph
37bf3bb49 add vscalefsh
c16f91c59 add vscalefph
61ad45935 add vsqrtsh
e00b508d5 add vsqrtph
52765d54f add vrsqrtsh
2ec6a7ab4 add vrsqrtph
b1ff7891d add vrcpph, vrcpsh
4f543ca0e add vucomish
412b95f02 add vf{,c}mulcph
9fc53baed add vf{,c}maddcph
0098ce98d add vf{,n}m{sub,add}sh
849dffb10 add vfmadd, vfnmadd, vfnmsub for avx512-fp16
eadb93d0b add vfmsubaddcph
9b8802cba add vfmaddsub{132,213,231}ph
ab9481b4c add vcomish
cd036ea17 fix vcmpsh
b494b321a vcmpsh supports ptr_b
eb2d63c83 vcmpph uses T_B16
a480b3dd9 v5.996
16d18b1d4 fix v{add,sub,mul,...}{sd,ss} to support T_rd_sae etc.
66c6ca1ab support vaddsh with T_rd_sae
6333ec099 add m16bcst
84053c8e7 add vcmpph
5df23d263 move FP16 to AVX-512
d5c7336f8 fix disp scaling of v{add,sub,mul,div,max,min}sh
ebf29542d add vaddsh test
f29689d02 add test of vaddph
2c4b6ac16 add v{add,sub,mul,div,min,max}{ph,sh}
edf3c2f6f remove mask for mmm
2c561aad6 add T_MAP5 and T_MAP6
acd360c38 add Cpu::tAVX512_FP16
1554f479c remove unused flags(tSSE4a and tSSE5) of Cpu
c313a8758 update CMakeLists.txt version
740b39e24 Merge pull request #122 from abouvier/cmake
10a1e5759 v5.995
0a557a099 rename XBYAK_MEMFD_CREATE to XBYAK_USE_MEMFD
0ad9b9bbe Merge branch 'captain5050-master' into dev
c7bb66383 fix for mac and enable it if XBYAK_MEMFD_CREATE is defined
c1e6569f1 fix cmake config files
ccd4130ec Name mmap pages on Linux with memfd_create
2fb843c32 v5.994
413a66b44 add alias of vcmpXX{ps,pd,ss,sd} for mask register
6f4f76890 v5.993
19043cb9a add test for gather/scatter
b5acb1d1c gather test does not generate bad combination of regs
67ec1674a check restriction of gather/scatter regs
ea9814f4f check bad reg combination of gather
a34850b2d add endbr32 and endbr64
git-subtree-dir: externals/xbyak
git-subtree-split: 9357732aa2aa3cf97809027596dfa5c61d1515b2
2022-06-05 13:31:49 +01:00
|
|
|
const uint8_t *f = code.getCurr();
|
2020-04-22 20:25:57 +01:00
|
|
|
code.gen(pNum, tNum | opt, stackSize);
|
|
|
|
verify(f, pNum);
|
2020-04-22 20:59:14 +01:00
|
|
|
/*
|
|
|
|
check rsp is 16-byte aligned if stackSize > 0
|
|
|
|
*/
|
|
|
|
if (stackSize > 0) {
|
|
|
|
Code2 c2;
|
|
|
|
c2.gen2(pNum, tNum | opt, stackSize);
|
|
|
|
uint64_t addr = c2.getCode<uint64_t (*)()>()();
|
|
|
|
check(addr % 16, 0);
|
|
|
|
}
|
2020-04-22 20:25:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void testPartial()
|
|
|
|
{
|
|
|
|
Code code;
|
|
|
|
int (*f1)(int) = code.getCurr<int (*)(int)>();
|
|
|
|
code.gen1();
|
|
|
|
check(5, f1(5));
|
|
|
|
|
|
|
|
int (*f2)(int, int) = code.getCurr<int (*)(int, int)>();
|
|
|
|
code.gen2();
|
|
|
|
check(9, f2(3, 6));
|
|
|
|
|
|
|
|
int (*f3)(int, int, int) = code.getCurr<int (*)(int, int, int)>();
|
|
|
|
code.gen3();
|
|
|
|
check(14, f3(1, 4, 9));
|
|
|
|
|
|
|
|
int (*f4)(int, int, int, int) = code.getCurr<int (*)(int, int, int, int)>();
|
|
|
|
code.gen4();
|
|
|
|
check(30, f4(1, 4, 9, 16));
|
|
|
|
|
|
|
|
int (*f5)(int, int, int, int) = code.getCurr<int (*)(int, int, int, int)>();
|
|
|
|
code.gen5();
|
|
|
|
check(23, f5(2, 5, 7, 9));
|
|
|
|
|
|
|
|
int (*f6)(int, int, int, int) = code.getCurr<int (*)(int, int, int, int)>();
|
|
|
|
code.gen6();
|
|
|
|
check(18, f6(3, 4, 5, 6));
|
|
|
|
|
|
|
|
int (*f7)(int, int, int) = code.getCurr<int (*)(int, int, int)>();
|
|
|
|
code.gen7();
|
|
|
|
check(12, f7(3, 4, 5));
|
|
|
|
|
|
|
|
int (*f8)(int, int, int) = code.getCurr<int (*)(int, int, int)>();
|
|
|
|
code.gen8();
|
|
|
|
check(23, f8(5, 8, 10));
|
|
|
|
|
|
|
|
int (*f9)(int, int, int) = code.getCurr<int (*)(int, int, int)>();
|
|
|
|
code.gen9();
|
|
|
|
check(60, f9(10, 20, 30));
|
|
|
|
|
|
|
|
int (*f10)(int, int, int, int) = code.getCurr<int (*)(int, int, int, int)>();
|
|
|
|
code.gen10();
|
|
|
|
check(100, f10(10, 20, 30, 40));
|
|
|
|
|
|
|
|
int (*f11)() = code.getCurr<int (*)()>();
|
|
|
|
code.gen11();
|
|
|
|
check(3, f11());
|
|
|
|
|
|
|
|
int (*f12)(int, int, int, int) = code.getCurr<int (*)(int, int, int, int)>();
|
|
|
|
code.gen12();
|
|
|
|
check(24, f12(3, 5, 7, 9));
|
2020-04-22 20:59:14 +01:00
|
|
|
|
|
|
|
{
|
|
|
|
int64_t tbl[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 };
|
|
|
|
int64_t (*f13)(const int64_t*) = code.getCurr<int64_t (*)(const int64_t*)>();
|
|
|
|
code.gen13();
|
|
|
|
check(91, f13(tbl));
|
|
|
|
|
|
|
|
int64_t (*f14)(const int64_t*) = code.getCurr<int64_t (*)(const int64_t*)>();
|
|
|
|
code.gen14();
|
|
|
|
check(91, f14(tbl));
|
|
|
|
}
|
|
|
|
int (*f15)() = code.getCurr<int (*)()>();
|
|
|
|
code.gen15();
|
|
|
|
check((1 << 15) - 1, f15());
|
2020-04-22 20:25:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void put(const Xbyak::util::Pack& p)
|
|
|
|
{
|
|
|
|
for (size_t i = 0, n = p.size(); i < n; i++) {
|
|
|
|
printf("%s ", p[i].toString());
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void verifyPack(const Xbyak::util::Pack& p, const int *tbl, size_t tblNum)
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < tblNum; i++) {
|
|
|
|
check(p[i].getIdx(), tbl[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void testPack()
|
|
|
|
{
|
|
|
|
const int N = 10;
|
|
|
|
Xbyak::Reg64 regTbl[N];
|
|
|
|
for (int i = 0; i < N; i++) {
|
|
|
|
regTbl[i] = Xbyak::Reg64(i);
|
|
|
|
}
|
|
|
|
Xbyak::util::Pack p(regTbl, N);
|
|
|
|
const struct {
|
|
|
|
int pos;
|
|
|
|
int num;
|
|
|
|
int tbl[10];
|
|
|
|
} tbl[] = {
|
|
|
|
{ 0, 10, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } },
|
|
|
|
{ 1, 9, { 1, 2, 3, 4, 5, 6, 7, 8, 9 } },
|
|
|
|
{ 2, 8, { 2, 3, 4, 5, 6, 7, 8, 9 } },
|
|
|
|
{ 3, 7, { 3, 4, 5, 6, 7, 8, 9 } },
|
|
|
|
{ 4, 6, { 4, 5, 6, 7, 8, 9 } },
|
|
|
|
{ 5, 5, { 5, 6, 7, 8, 9 } },
|
|
|
|
{ 6, 4, { 6, 7, 8, 9 } },
|
|
|
|
{ 7, 3, { 7, 8, 9 } },
|
|
|
|
{ 8, 2, { 8, 9 } },
|
|
|
|
{ 9, 1, { 9 } },
|
|
|
|
{ 3, 5, { 3, 4, 5, 6, 7 } },
|
|
|
|
};
|
|
|
|
for (size_t i = 0; i < sizeof(tbl) / sizeof(*tbl); i++) {
|
|
|
|
const int pos = tbl[i].pos;
|
|
|
|
const int num = tbl[i].num;
|
|
|
|
verifyPack(p.sub(pos, num), tbl[i].tbl, num);
|
|
|
|
if (pos + num == N) {
|
|
|
|
verifyPack(p.sub(pos), tbl[i].tbl, num);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int main()
|
|
|
|
try
|
|
|
|
{
|
|
|
|
testAll();
|
|
|
|
|
|
|
|
testPartial();
|
|
|
|
testPack();
|
|
|
|
printf("errNum=%d\n", errNum);
|
|
|
|
} catch (std::exception& e) {
|
|
|
|
printf("err %s\n", e.what());
|
|
|
|
return 1;
|
|
|
|
} catch (...) {
|
|
|
|
puts("ERR");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|