summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/asmjit/test/asmjit_test_compiler_x86.cpp
diff options
context:
space:
mode:
author 987123879113 <63495610+987123879113@users.noreply.github.com>2025-01-14 00:44:16 +0900
committer GitHub <noreply@github.com>2025-01-14 02:44:16 +1100
commitaa5cd150b3e159d342b7bb0778f7517fe5c4ed1a (patch)
treebca15924bf754254052364067778850c49922701 /3rdparty/asmjit/test/asmjit_test_compiler_x86.cpp
parent4dab319804dc2a81769937acafc486ffc750b61d (diff)
cpu/drcbearm64.cpp: Added a 64-bit ARMv8 (AArch64) DRC back-end. (#13162)
* cpu/uml.cpp: Removed unused vector type. * 3rdparty/asmjit: Update asmjit to latest upstream. * cpu/drcbex64.cpp: Fixed crash with LOG_HASHJMPS enabled (stack needs to be 16-byte aligned before calling debug_log_hashjmp_fail).
Diffstat (limited to '3rdparty/asmjit/test/asmjit_test_compiler_x86.cpp')
-rw-r--r--3rdparty/asmjit/test/asmjit_test_compiler_x86.cpp1353
1 files changed, 761 insertions, 592 deletions
diff --git a/3rdparty/asmjit/test/asmjit_test_compiler_x86.cpp b/3rdparty/asmjit/test/asmjit_test_compiler_x86.cpp
index 54442efb915..9ff6d893855 100644
--- a/3rdparty/asmjit/test/asmjit_test_compiler_x86.cpp
+++ b/3rdparty/asmjit/test/asmjit_test_compiler_x86.cpp
@@ -1047,15 +1047,516 @@ public:
}
};
-// x86::Compiler - X86Test_AllocImul1
+// x86::Compiler - X86Test_AllocInt8
+// =================================
+
+class X86Test_AllocInt8 : public X86TestCase {
+public:
+ X86Test_AllocInt8() : X86TestCase("AllocInt8") {}
+
+ static void add(TestApp& app) {
+ app.add(new X86Test_AllocInt8());
+ }
+
+ virtual void compile(x86::Compiler& cc) {
+ x86::Gp x = cc.newInt8("x");
+ x86::Gp y = cc.newInt32("y");
+
+ FuncNode* funcNode = cc.addFunc(FuncSignature::build<int, int8_t>());
+ funcNode->setArg(0, x);
+
+ cc.movsx(y, x);
+
+ cc.ret(y);
+ cc.endFunc();
+ }
+
+ virtual bool run(void* _func, String& result, String& expect) {
+ typedef int (*Func)(int8_t);
+ Func func = ptr_as_func<Func>(_func);
+
+ int resultRet = func(int8_t(-13));
+ int expectRet = -13;
+
+ result.assignFormat("ret=%d", resultRet);
+ expect.assignFormat("ret=%d", expectRet);
+
+ return result == expect;
+ }
+};
+
+// x86::Compiler - X86Test_AllocUnhandledArg
+// =========================================
+
+class X86Test_AllocUnhandledArg : public X86TestCase {
+public:
+ X86Test_AllocUnhandledArg() : X86TestCase("AllocUnhandledArg") {}
+
+ static void add(TestApp& app) {
+ app.add(new X86Test_AllocUnhandledArg());
+ }
+
+ virtual void compile(x86::Compiler& cc) {
+ x86::Gp x = cc.newInt32("x");
+
+ FuncNode* funcNode = cc.addFunc(FuncSignature::build<int, int, int, int>());
+ funcNode->setArg(2, x);
+
+ cc.ret(x);
+ cc.endFunc();
+ }
+
+ virtual bool run(void* _func, String& result, String& expect) {
+ typedef int (*Func)(int, int, int);
+ Func func = ptr_as_func<Func>(_func);
+
+ int resultRet = func(42, 155, 199);
+ int expectRet = 199;
+
+ result.assignFormat("ret={%d}", resultRet);
+ expect.assignFormat("ret={%d}", expectRet);
+
+ return result == expect;
+ }
+};
+
+// x86::Compiler - X86Test_AllocArgsIntPtr
+// =======================================
+
+class X86Test_AllocArgsIntPtr : public X86TestCase {
+public:
+ X86Test_AllocArgsIntPtr() : X86TestCase("AllocArgsIntPtr") {}
+
+ static void add(TestApp& app) {
+ app.add(new X86Test_AllocArgsIntPtr());
+ }
+
+ virtual void compile(x86::Compiler& cc) {
+ FuncNode* funcNode = cc.addFunc(FuncSignature::build<void, void*, void*, void*, void*, void*, void*, void*, void*>());
+ x86::Gp var[8];
+
+ for (uint32_t i = 0; i < 8; i++) {
+ var[i] = cc.newIntPtr("var%u", i);
+ funcNode->setArg(i, var[i]);
+ }
+
+ for (uint32_t i = 0; i < 8; i++) {
+ cc.add(var[i], int(i + 1));
+ }
+
+ // Move some data into buffer provided by arguments so we can verify if it
+ // really works without looking into assembler output.
+ for (uint32_t i = 0; i < 8; i++) {
+ cc.add(x86::byte_ptr(var[i]), int(i + 1));
+ }
+
+ cc.endFunc();
+ }
+
+ virtual bool run(void* _func, String& result, String& expect) {
+ typedef void (*Func)(void*, void*, void*, void*, void*, void*, void*, void*);
+ Func func = ptr_as_func<Func>(_func);
+
+ uint8_t resultBuf[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ uint8_t expectBuf[9] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
+
+ func(resultBuf, resultBuf, resultBuf, resultBuf,
+ resultBuf, resultBuf, resultBuf, resultBuf);
+
+ result.assignFormat("buf={%d, %d, %d, %d, %d, %d, %d, %d, %d}",
+ resultBuf[0], resultBuf[1], resultBuf[2], resultBuf[3],
+ resultBuf[4], resultBuf[5], resultBuf[6], resultBuf[7],
+ resultBuf[8]);
+ expect.assignFormat("buf={%d, %d, %d, %d, %d, %d, %d, %d, %d}",
+ expectBuf[0], expectBuf[1], expectBuf[2], expectBuf[3],
+ expectBuf[4], expectBuf[5], expectBuf[6], expectBuf[7],
+ expectBuf[8]);
+
+ return result == expect;
+ }
+};
+
+// x86::Compiler - X86Test_AllocArgsFloat
+// ======================================
+
+class X86Test_AllocArgsFloat : public X86TestCase {
+public:
+ X86Test_AllocArgsFloat() : X86TestCase("AllocArgsFloat") {}
+
+ static void add(TestApp& app) {
+ app.add(new X86Test_AllocArgsFloat());
+ }
+
+ virtual void compile(x86::Compiler& cc) {
+ FuncNode* funcNode = cc.addFunc(FuncSignature::build<void, float, float, float, float, float, float, float, void*>());
+
+ x86::Gp p = cc.newIntPtr("p");
+ x86::Xmm xv[7];
+
+ for (uint32_t i = 0; i < 7; i++) {
+ xv[i] = cc.newXmmSs("xv%u", i);
+ funcNode->setArg(i, xv[i]);
+ }
+
+ funcNode->setArg(7, p);
+
+ cc.addss(xv[0], xv[1]);
+ cc.addss(xv[0], xv[2]);
+ cc.addss(xv[0], xv[3]);
+ cc.addss(xv[0], xv[4]);
+ cc.addss(xv[0], xv[5]);
+ cc.addss(xv[0], xv[6]);
+
+ cc.movss(x86::ptr(p), xv[0]);
+ cc.endFunc();
+ }
+
+ virtual bool run(void* _func, String& result, String& expect) {
+ typedef void (*Func)(float, float, float, float, float, float, float, float*);
+ Func func = ptr_as_func<Func>(_func);
+
+ float resultRet = 0;
+ float expectRet = 1.0f + 2.0f + 3.0f + 4.0f + 5.0f + 6.0f + 7.0f;
+
+ func(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, &resultRet);
+
+ result.assignFormat("ret={%g}", resultRet);
+ expect.assignFormat("ret={%g}", expectRet);
+
+ return result == expect;
+ }
+};
+
+// x86::Compiler - X86Test_AllocArgsDouble
+// =======================================
+
+class X86Test_AllocArgsDouble : public X86TestCase {
+public:
+ X86Test_AllocArgsDouble() : X86TestCase("AllocArgsDouble") {}
+
+ static void add(TestApp& app) {
+ app.add(new X86Test_AllocArgsDouble());
+ }
+
+ virtual void compile(x86::Compiler& cc) {
+ FuncNode* funcNode = cc.addFunc(FuncSignature::build<void, double, double, double, double, double, double, double, void*>());
+
+ x86::Gp p = cc.newIntPtr("p");
+ x86::Xmm xv[7];
+
+ for (uint32_t i = 0; i < 7; i++) {
+ xv[i] = cc.newXmmSd("xv%u", i);
+ funcNode->setArg(i, xv[i]);
+ }
+
+ funcNode->setArg(7, p);
+
+ cc.addsd(xv[0], xv[1]);
+ cc.addsd(xv[0], xv[2]);
+ cc.addsd(xv[0], xv[3]);
+ cc.addsd(xv[0], xv[4]);
+ cc.addsd(xv[0], xv[5]);
+ cc.addsd(xv[0], xv[6]);
+
+ cc.movsd(x86::ptr(p), xv[0]);
+ cc.endFunc();
+ }
+
+ virtual bool run(void* _func, String& result, String& expect) {
+ typedef void (*Func)(double, double, double, double, double, double, double, double*);
+ Func func = ptr_as_func<Func>(_func);
+
+ double resultRet = 0;
+ double expectRet = 1.0 + 2.0 + 3.0 + 4.0 + 5.0 + 6.0 + 7.0;
+
+ func(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, &resultRet);
+
+ result.assignFormat("ret={%g}", resultRet);
+ expect.assignFormat("ret={%g}", expectRet);
+
+ return result == expect;
+ }
+};
+
+// x86::Compiler - X86Test_AllocArgsVec
+// ====================================
+
+#if ASMJIT_ARCH_X86
+class X86Test_AllocArgsVec : public X86TestCase {
+public:
+ X86Test_AllocArgsVec() : X86TestCase("AllocArgsVec") {}
+
+ static void add(TestApp& app) {
+ // Not supported on Windows.
+#ifndef _WIN32
+ app.add(new X86Test_AllocArgsVec());
+#else
+ DebugUtils::unused(app);
+#endif
+ }
+
+ virtual void compile(x86::Compiler& cc) {
+ x86::Xmm a = cc.newXmm("aXmm");
+ x86::Xmm b = cc.newXmm("bXmm");
+
+ FuncNode* funcNode = cc.addFunc(FuncSignature::build<x86::Xmm, x86::Xmm, x86::Xmm>());
+ funcNode->setArg(0, a);
+ funcNode->setArg(1, b);
+
+ cc.paddb(a, b);
+ cc.ret(a);
+
+ cc.endFunc();
+ }
+
+ virtual bool run(void* _func, String& result, String& expect) {
+ typedef __m128i (*Func)(__m128i, __m128i);
+ Func func = ptr_as_func<Func>(_func);
+
+ uint8_t aData[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
+ uint8_t bData[16] = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
+
+ uint8_t rData[16] {};
+ uint8_t eData[16] = { 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15 };
+
+ __m128i aVec = _mm_loadu_si128(reinterpret_cast<const __m128i*>(aData));
+ __m128i bVec = _mm_loadu_si128(reinterpret_cast<const __m128i*>(bData));
+
+ __m128i rVec = func(aVec, bVec);
+ _mm_storeu_si128(reinterpret_cast<__m128i*>(rData), rVec);
+
+ result.appendHex(rData, 16);
+ expect.appendHex(eData, 16);
+
+ return result == expect;
+ }
+};
+#endif // ASMJIT_ARCH_X86
+
+// x86::Compiler - X86Test_AllocRetFloat1
+// ======================================
+
+class X86Test_AllocRetFloat1 : public X86TestCase {
+public:
+ X86Test_AllocRetFloat1() : X86TestCase("AllocRetFloat1") {}
+
+ static void add(TestApp& app) {
+ app.add(new X86Test_AllocRetFloat1());
+ }
+
+ virtual void compile(x86::Compiler& cc) {
+ x86::Xmm x = cc.newXmmSs("x");
+
+ FuncNode* funcNode = cc.addFunc(FuncSignature::build<float, float>());
+ funcNode->setArg(0, x);
+
+ cc.ret(x);
+ cc.endFunc();
+ }
+
+ virtual bool run(void* _func, String& result, String& expect) {
+ typedef float (*Func)(float);
+ Func func = ptr_as_func<Func>(_func);
+
+ float resultRet = func(42.0f);
+ float expectRet = 42.0f;
+
+ result.assignFormat("ret={%g}", resultRet);
+ expect.assignFormat("ret={%g}", expectRet);
+
+ return result == expect;
+ }
+};
+
+// x86::Compiler - X86Test_AllocRetFloat2
+// ======================================
+
+class X86Test_AllocRetFloat2 : public X86TestCase {
+public:
+ X86Test_AllocRetFloat2() : X86TestCase("AllocRetFloat2") {}
+
+ static void add(TestApp& app) {
+ app.add(new X86Test_AllocRetFloat2());
+ }
+
+ virtual void compile(x86::Compiler& cc) {
+ x86::Xmm x = cc.newXmmSs("x");
+ x86::Xmm y = cc.newXmmSs("y");
+
+ FuncNode* funcNode = cc.addFunc(FuncSignature::build<float, float, float>());
+ funcNode->setArg(0, x);
+ funcNode->setArg(1, y);
+
+ cc.addss(x, y);
+ cc.ret(x);
+
+ cc.endFunc();
+ }
+
+ virtual bool run(void* _func, String& result, String& expect) {
+ typedef float (*Func)(float, float);
+ Func func = ptr_as_func<Func>(_func);
+
+ float resultRet = func(1.0f, 2.0f);
+ float expectRet = 1.0f + 2.0f;
+
+ result.assignFormat("ret={%g}", resultRet);
+ expect.assignFormat("ret={%g}", expectRet);
+
+ return result == expect;
+ }
+};
+
+// x86::Compiler - X86Test_AllocRetDouble1
+// =======================================
+
+class X86Test_AllocRetDouble1 : public X86TestCase {
+public:
+ X86Test_AllocRetDouble1() : X86TestCase("AllocRetDouble1") {}
+
+ static void add(TestApp& app) {
+ app.add(new X86Test_AllocRetDouble1());
+ }
+
+ virtual void compile(x86::Compiler& cc) {
+ x86::Xmm x = cc.newXmmSd("x");
+
+ FuncNode* funcNode = cc.addFunc(FuncSignature::build<double, double>());
+ funcNode->setArg(0, x);
+
+ cc.ret(x);
+ cc.endFunc();
+ }
+
+ virtual bool run(void* _func, String& result, String& expect) {
+ typedef double (*Func)(double);
+ Func func = ptr_as_func<Func>(_func);
+
+ double resultRet = func(42.0);
+ double expectRet = 42.0;
+
+ result.assignFormat("ret={%g}", resultRet);
+ expect.assignFormat("ret={%g}", expectRet);
+
+ return result == expect;
+ }
+};
+
+// x86::Compiler - X86Test_AllocRetDouble2
+// =======================================
+
+class X86Test_AllocRetDouble2 : public X86TestCase {
+public:
+ X86Test_AllocRetDouble2() : X86TestCase("AllocRetDouble2") {}
+
+ static void add(TestApp& app) {
+ app.add(new X86Test_AllocRetDouble2());
+ }
+
+ virtual void compile(x86::Compiler& cc) {
+ x86::Xmm x = cc.newXmmSd("x");
+ x86::Xmm y = cc.newXmmSd("y");
+
+ FuncNode* funcNode = cc.addFunc(FuncSignature::build<double, double, double>());
+ funcNode->setArg(0, x);
+ funcNode->setArg(1, y);
+
+ cc.addsd(x, y);
+ cc.ret(x);
+
+ cc.endFunc();
+ }
+
+ virtual bool run(void* _func, String& result, String& expect) {
+ typedef double (*Func)(double, double);
+ Func func = ptr_as_func<Func>(_func);
+
+ double resultRet = func(1.0, 2.0);
+ double expectRet = 1.0 + 2.0;
+
+ result.assignFormat("ret={%g}", resultRet);
+ expect.assignFormat("ret={%g}", expectRet);
+
+ return result == expect;
+ }
+};
+
+// x86::Compiler - X86Test_AllocStack
// ==================================
-class X86Test_AllocImul1 : public X86TestCase {
+class X86Test_AllocStack : public X86TestCase {
public:
- X86Test_AllocImul1() : X86TestCase("AllocImul1") {}
+ X86Test_AllocStack() : X86TestCase("AllocStack") {}
+
+ enum { kSize = 256 };
static void add(TestApp& app) {
- app.add(new X86Test_AllocImul1());
+ app.add(new X86Test_AllocStack());
+ }
+
+ virtual void compile(x86::Compiler& cc) {
+ cc.addFunc(FuncSignature::build<int>());
+
+ x86::Mem stack = cc.newStack(kSize, 1);
+ stack.setSize(1);
+
+ x86::Gp i = cc.newIntPtr("i");
+ x86::Gp a = cc.newInt32("a");
+ x86::Gp b = cc.newInt32("b");
+
+ Label L_1 = cc.newLabel();
+ Label L_2 = cc.newLabel();
+
+ // Fill stack by sequence [0, 1, 2, 3 ... 255].
+ cc.xor_(i, i);
+
+ x86::Mem stackWithIndex = stack.clone();
+ stackWithIndex.setIndex(i, 0);
+
+ cc.bind(L_1);
+ cc.mov(stackWithIndex, i.r8());
+ cc.inc(i);
+ cc.cmp(i, 255);
+ cc.jle(L_1);
+
+ // Sum sequence in stack.
+ cc.xor_(i, i);
+ cc.xor_(a, a);
+
+ cc.bind(L_2);
+ cc.movzx(b, stackWithIndex);
+ cc.add(a, b);
+ cc.inc(i);
+ cc.cmp(i, 255);
+ cc.jle(L_2);
+
+ cc.ret(a);
+ cc.endFunc();
+ }
+
+ virtual bool run(void* _func, String& result, String& expect) {
+ typedef int (*Func)(void);
+ Func func = ptr_as_func<Func>(_func);
+
+ int resultRet = func();
+ int expectRet = 32640;
+
+ result.assignInt(resultRet);
+ expect.assignInt(expectRet);
+
+ return result == expect;
+ }
+};
+
+// x86::Compiler - X86Test_Imul1
+// =============================
+
+class X86Test_Imul1 : public X86TestCase {
+public:
+ X86Test_Imul1() : X86TestCase("Imul1") {}
+
+ static void add(TestApp& app) {
+ app.add(new X86Test_Imul1());
}
virtual void compile(x86::Compiler& cc) {
@@ -1100,15 +1601,15 @@ public:
}
};
-// x86::Compiler - X86Test_AllocImul2
-// ==================================
+// x86::Compiler - X86Test_Imul2
+// =============================
-class X86Test_AllocImul2 : public X86TestCase {
+class X86Test_Imul2 : public X86TestCase {
public:
- X86Test_AllocImul2() : X86TestCase("AllocImul2") {}
+ X86Test_Imul2() : X86TestCase("Imul2") {}
static void add(TestApp& app) {
- app.add(new X86Test_AllocImul2());
+ app.add(new X86Test_Imul2());
}
virtual void compile(x86::Compiler& cc) {
@@ -1152,15 +1653,15 @@ public:
}
};
-// x86::Compiler - X86Test_AllocIdiv1
-// ==================================
+// x86::Compiler - X86Test_Idiv1
+// =============================
-class X86Test_AllocIdiv1 : public X86TestCase {
+class X86Test_Idiv1 : public X86TestCase {
public:
- X86Test_AllocIdiv1() : X86TestCase("AllocIdiv1") {}
+ X86Test_Idiv1() : X86TestCase("Idiv1") {}
static void add(TestApp& app) {
- app.add(new X86Test_AllocIdiv1());
+ app.add(new X86Test_Idiv1());
}
virtual void compile(x86::Compiler& cc) {
@@ -1196,15 +1697,15 @@ public:
}
};
-// x86::Compiler - X86Test_AllocSetz
-// =================================
+// x86::Compiler - X86Test_Setz
+// ============================
-class X86Test_AllocSetz : public X86TestCase {
+class X86Test_Setz : public X86TestCase {
public:
- X86Test_AllocSetz() : X86TestCase("AllocSetz") {}
+ X86Test_Setz() : X86TestCase("Setz") {}
static void add(TestApp& app) {
- app.add(new X86Test_AllocSetz());
+ app.add(new X86Test_Setz());
}
virtual void compile(x86::Compiler& cc) {
@@ -1245,15 +1746,15 @@ public:
}
};
-// x86::Compiler - X86Test_AllocShlRor
-// ===================================
+// x86::Compiler - X86Test_ShlRor
+// ==============================
-class X86Test_AllocShlRor : public X86TestCase {
+class X86Test_ShlRor : public X86TestCase {
public:
- X86Test_AllocShlRor() : X86TestCase("AllocShlRor") {}
+ X86Test_ShlRor() : X86TestCase("ShlRor") {}
static void add(TestApp& app) {
- app.add(new X86Test_AllocShlRor());
+ app.add(new X86Test_ShlRor());
}
virtual void compile(x86::Compiler& cc) {
@@ -1292,17 +1793,17 @@ public:
}
};
-// x86::Compiler - X86Test_AllocGpbLo
-// ==================================
+// x86::Compiler - X86Test_GpbLo
+// =============================
-class X86Test_AllocGpbLo1 : public X86TestCase {
+class X86Test_GpbLo1 : public X86TestCase {
public:
- X86Test_AllocGpbLo1() : X86TestCase("AllocGpbLo1") {}
+ X86Test_GpbLo1() : X86TestCase("GpbLo1") {}
enum : uint32_t { kCount = 32 };
static void add(TestApp& app) {
- app.add(new X86Test_AllocGpbLo1());
+ app.add(new X86Test_GpbLo1());
}
virtual void compile(x86::Compiler& cc) {
@@ -1377,15 +1878,15 @@ public:
}
};
-// x86::Compiler - X86Test_AllocGpbLo2
-// ===================================
+// x86::Compiler - X86Test_GpbLo2
+// ==============================
-class X86Test_AllocGpbLo2 : public X86TestCase {
+class X86Test_GpbLo2 : public X86TestCase {
public:
- X86Test_AllocGpbLo2() : X86TestCase("AllocGpbLo2") {}
+ X86Test_GpbLo2() : X86TestCase("GpbLo2") {}
static void add(TestApp& app) {
- app.add(new X86Test_AllocGpbLo2());
+ app.add(new X86Test_GpbLo2());
}
virtual void compile(x86::Compiler& cc) {
@@ -1413,15 +1914,15 @@ public:
}
};
-// x86::Compiler - X86Test_AllocRepMovsb
-// =====================================
+// x86::Compiler - X86Test_RepMovsb
+// ================================
-class X86Test_AllocRepMovsb : public X86TestCase {
+class X86Test_RepMovsb : public X86TestCase {
public:
- X86Test_AllocRepMovsb() : X86TestCase("AllocRepMovsb") {}
+ X86Test_RepMovsb() : X86TestCase("RepMovsb") {}
static void add(TestApp& app) {
- app.add(new X86Test_AllocRepMovsb());
+ app.add(new X86Test_RepMovsb());
}
virtual void compile(x86::Compiler& cc) {
@@ -1453,15 +1954,15 @@ public:
}
};
-// x86::Compiler - X86Test_AllocIfElse1
-// ====================================
+// x86::Compiler - X86Test_IfElse1
+// ===============================
-class X86Test_AllocIfElse1 : public X86TestCase {
+class X86Test_IfElse1 : public X86TestCase {
public:
- X86Test_AllocIfElse1() : X86TestCase("AllocIfElse1") {}
+ X86Test_IfElse1() : X86TestCase("IfElse1") {}
static void add(TestApp& app) {
- app.add(new X86Test_AllocIfElse1());
+ app.add(new X86Test_IfElse1());
}
virtual void compile(x86::Compiler& cc) {
@@ -1503,15 +2004,15 @@ public:
}
};
-// x86::Compiler - X86Test_AllocIfElse2
-// ====================================
+// x86::Compiler - X86Test_IfElse2
+// ===============================
-class X86Test_AllocIfElse2 : public X86TestCase {
+class X86Test_IfElse2 : public X86TestCase {
public:
- X86Test_AllocIfElse2() : X86TestCase("AllocIfElse2") {}
+ X86Test_IfElse2() : X86TestCase("IfElse2") {}
static void add(TestApp& app) {
- app.add(new X86Test_AllocIfElse2());
+ app.add(new X86Test_IfElse2());
}
virtual void compile(x86::Compiler& cc) {
@@ -1562,15 +2063,15 @@ public:
}
};
-// x86::Compiler - X86Test_AllocIfElse3
-// ====================================
+// x86::Compiler - X86Test_IfElse3
+// ===============================
-class X86Test_AllocIfElse3 : public X86TestCase {
+class X86Test_IfElse3 : public X86TestCase {
public:
- X86Test_AllocIfElse3() : X86TestCase("AllocIfElse3") {}
+ X86Test_IfElse3() : X86TestCase("IfElse3") {}
static void add(TestApp& app) {
- app.add(new X86Test_AllocIfElse3());
+ app.add(new X86Test_IfElse3());
}
virtual void compile(x86::Compiler& cc) {
@@ -1621,15 +2122,15 @@ public:
}
};
-// x86::Compiler - X86Test_AllocIfElse4
-// ====================================
+// x86::Compiler - X86Test_IfElse4
+// ===============================
-class X86Test_AllocIfElse4 : public X86TestCase {
+class X86Test_IfElse4 : public X86TestCase {
public:
- X86Test_AllocIfElse4() : X86TestCase("AllocIfElse4") {}
+ X86Test_IfElse4() : X86TestCase("IfElse4") {}
static void add(TestApp& app) {
- app.add(new X86Test_AllocIfElse4());
+ app.add(new X86Test_IfElse4());
}
virtual void compile(x86::Compiler& cc) {
@@ -1684,518 +2185,17 @@ public:
}
};
-// x86::Compiler - X86Test_AllocInt8
-// =================================
-
-class X86Test_AllocInt8 : public X86TestCase {
-public:
- X86Test_AllocInt8() : X86TestCase("AllocInt8") {}
-
- static void add(TestApp& app) {
- app.add(new X86Test_AllocInt8());
- }
-
- virtual void compile(x86::Compiler& cc) {
- x86::Gp x = cc.newInt8("x");
- x86::Gp y = cc.newInt32("y");
-
- FuncNode* funcNode = cc.addFunc(FuncSignature::build<int, int8_t>());
- funcNode->setArg(0, x);
-
- cc.movsx(y, x);
-
- cc.ret(y);
- cc.endFunc();
- }
-
- virtual bool run(void* _func, String& result, String& expect) {
- typedef int (*Func)(int8_t);
- Func func = ptr_as_func<Func>(_func);
-
- int resultRet = func(int8_t(-13));
- int expectRet = -13;
-
- result.assignFormat("ret=%d", resultRet);
- expect.assignFormat("ret=%d", expectRet);
-
- return result == expect;
- }
-};
-
-// x86::Compiler - X86Test_AllocUnhandledArg
-// =========================================
-
-class X86Test_AllocUnhandledArg : public X86TestCase {
-public:
- X86Test_AllocUnhandledArg() : X86TestCase("AllocUnhandledArg") {}
-
- static void add(TestApp& app) {
- app.add(new X86Test_AllocUnhandledArg());
- }
-
- virtual void compile(x86::Compiler& cc) {
- x86::Gp x = cc.newInt32("x");
-
- FuncNode* funcNode = cc.addFunc(FuncSignature::build<int, int, int, int>());
- funcNode->setArg(2, x);
-
- cc.ret(x);
- cc.endFunc();
- }
-
- virtual bool run(void* _func, String& result, String& expect) {
- typedef int (*Func)(int, int, int);
- Func func = ptr_as_func<Func>(_func);
-
- int resultRet = func(42, 155, 199);
- int expectRet = 199;
-
- result.assignFormat("ret={%d}", resultRet);
- expect.assignFormat("ret={%d}", expectRet);
-
- return result == expect;
- }
-};
-
-// x86::Compiler - X86Test_AllocArgsIntPtr
-// =======================================
-
-class X86Test_AllocArgsIntPtr : public X86TestCase {
-public:
- X86Test_AllocArgsIntPtr() : X86TestCase("AllocArgsIntPtr") {}
-
- static void add(TestApp& app) {
- app.add(new X86Test_AllocArgsIntPtr());
- }
-
- virtual void compile(x86::Compiler& cc) {
- FuncNode* funcNode = cc.addFunc(FuncSignature::build<void, void*, void*, void*, void*, void*, void*, void*, void*>());
- x86::Gp var[8];
-
- for (uint32_t i = 0; i < 8; i++) {
- var[i] = cc.newIntPtr("var%u", i);
- funcNode->setArg(i, var[i]);
- }
-
- for (uint32_t i = 0; i < 8; i++) {
- cc.add(var[i], int(i + 1));
- }
-
- // Move some data into buffer provided by arguments so we can verify if it
- // really works without looking into assembler output.
- for (uint32_t i = 0; i < 8; i++) {
- cc.add(x86::byte_ptr(var[i]), int(i + 1));
- }
-
- cc.endFunc();
- }
-
- virtual bool run(void* _func, String& result, String& expect) {
- typedef void (*Func)(void*, void*, void*, void*, void*, void*, void*, void*);
- Func func = ptr_as_func<Func>(_func);
-
- uint8_t resultBuf[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- uint8_t expectBuf[9] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
-
- func(resultBuf, resultBuf, resultBuf, resultBuf,
- resultBuf, resultBuf, resultBuf, resultBuf);
-
- result.assignFormat("buf={%d, %d, %d, %d, %d, %d, %d, %d, %d}",
- resultBuf[0], resultBuf[1], resultBuf[2], resultBuf[3],
- resultBuf[4], resultBuf[5], resultBuf[6], resultBuf[7],
- resultBuf[8]);
- expect.assignFormat("buf={%d, %d, %d, %d, %d, %d, %d, %d, %d}",
- expectBuf[0], expectBuf[1], expectBuf[2], expectBuf[3],
- expectBuf[4], expectBuf[5], expectBuf[6], expectBuf[7],
- expectBuf[8]);
-
- return result == expect;
- }
-};
-
-// x86::Compiler - X86Test_AllocArgsFloat
-// ======================================
-
-class X86Test_AllocArgsFloat : public X86TestCase {
-public:
- X86Test_AllocArgsFloat() : X86TestCase("AllocArgsFloat") {}
-
- static void add(TestApp& app) {
- app.add(new X86Test_AllocArgsFloat());
- }
-
- virtual void compile(x86::Compiler& cc) {
- FuncNode* funcNode = cc.addFunc(FuncSignature::build<void, float, float, float, float, float, float, float, void*>());
-
- x86::Gp p = cc.newIntPtr("p");
- x86::Xmm xv[7];
-
- for (uint32_t i = 0; i < 7; i++) {
- xv[i] = cc.newXmmSs("xv%u", i);
- funcNode->setArg(i, xv[i]);
- }
-
- funcNode->setArg(7, p);
-
- cc.addss(xv[0], xv[1]);
- cc.addss(xv[0], xv[2]);
- cc.addss(xv[0], xv[3]);
- cc.addss(xv[0], xv[4]);
- cc.addss(xv[0], xv[5]);
- cc.addss(xv[0], xv[6]);
-
- cc.movss(x86::ptr(p), xv[0]);
- cc.endFunc();
- }
-
- virtual bool run(void* _func, String& result, String& expect) {
- typedef void (*Func)(float, float, float, float, float, float, float, float*);
- Func func = ptr_as_func<Func>(_func);
-
- float resultRet = 0;
- float expectRet = 1.0f + 2.0f + 3.0f + 4.0f + 5.0f + 6.0f + 7.0f;
-
- func(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, &resultRet);
-
- result.assignFormat("ret={%g}", resultRet);
- expect.assignFormat("ret={%g}", expectRet);
-
- return result == expect;
- }
-};
-
-// x86::Compiler - X86Test_AllocArgsDouble
-// =======================================
-
-class X86Test_AllocArgsDouble : public X86TestCase {
-public:
- X86Test_AllocArgsDouble() : X86TestCase("AllocArgsDouble") {}
-
- static void add(TestApp& app) {
- app.add(new X86Test_AllocArgsDouble());
- }
-
- virtual void compile(x86::Compiler& cc) {
- FuncNode* funcNode = cc.addFunc(FuncSignature::build<void, double, double, double, double, double, double, double, void*>());
-
- x86::Gp p = cc.newIntPtr("p");
- x86::Xmm xv[7];
-
- for (uint32_t i = 0; i < 7; i++) {
- xv[i] = cc.newXmmSd("xv%u", i);
- funcNode->setArg(i, xv[i]);
- }
-
- funcNode->setArg(7, p);
-
- cc.addsd(xv[0], xv[1]);
- cc.addsd(xv[0], xv[2]);
- cc.addsd(xv[0], xv[3]);
- cc.addsd(xv[0], xv[4]);
- cc.addsd(xv[0], xv[5]);
- cc.addsd(xv[0], xv[6]);
-
- cc.movsd(x86::ptr(p), xv[0]);
- cc.endFunc();
- }
-
- virtual bool run(void* _func, String& result, String& expect) {
- typedef void (*Func)(double, double, double, double, double, double, double, double*);
- Func func = ptr_as_func<Func>(_func);
-
- double resultRet = 0;
- double expectRet = 1.0 + 2.0 + 3.0 + 4.0 + 5.0 + 6.0 + 7.0;
-
- func(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, &resultRet);
-
- result.assignFormat("ret={%g}", resultRet);
- expect.assignFormat("ret={%g}", expectRet);
-
- return result == expect;
- }
-};
-
-// x86::Compiler - X86Test_AllocArgsVec
-// ====================================
-
-#if ASMJIT_ARCH_X86
-class X86Test_AllocArgsVec : public X86TestCase {
-public:
- X86Test_AllocArgsVec() : X86TestCase("AllocArgsVec") {}
-
- static void add(TestApp& app) {
- // Not supported on Windows.
-#ifndef _WIN32
- app.add(new X86Test_AllocArgsVec());
-#else
- DebugUtils::unused(app);
-#endif
- }
-
- virtual void compile(x86::Compiler& cc) {
- x86::Xmm a = cc.newXmm("aXmm");
- x86::Xmm b = cc.newXmm("bXmm");
-
- FuncNode* funcNode = cc.addFunc(FuncSignature::build<x86::Xmm, x86::Xmm, x86::Xmm>());
- funcNode->setArg(0, a);
- funcNode->setArg(1, b);
-
- cc.paddb(a, b);
- cc.ret(a);
-
- cc.endFunc();
- }
-
- virtual bool run(void* _func, String& result, String& expect) {
- typedef __m128i (*Func)(__m128i, __m128i);
- Func func = ptr_as_func<Func>(_func);
-
- uint8_t aData[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
- uint8_t bData[16] = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
-
- uint8_t rData[16] {};
- uint8_t eData[16] = { 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15 };
-
- __m128i aVec = _mm_loadu_si128(reinterpret_cast<const __m128i*>(aData));
- __m128i bVec = _mm_loadu_si128(reinterpret_cast<const __m128i*>(bData));
-
- __m128i rVec = func(aVec, bVec);
- _mm_storeu_si128(reinterpret_cast<__m128i*>(rData), rVec);
-
- result.appendHex(rData, 16);
- expect.appendHex(eData, 16);
-
- return result == expect;
- }
-};
-#endif // ASMJIT_ARCH_X86
-
-// x86::Compiler - X86Test_AllocRetFloat1
-// ======================================
-
-class X86Test_AllocRetFloat1 : public X86TestCase {
-public:
- X86Test_AllocRetFloat1() : X86TestCase("AllocRetFloat1") {}
-
- static void add(TestApp& app) {
- app.add(new X86Test_AllocRetFloat1());
- }
-
- virtual void compile(x86::Compiler& cc) {
- x86::Xmm x = cc.newXmmSs("x");
-
- FuncNode* funcNode = cc.addFunc(FuncSignature::build<float, float>());
- funcNode->setArg(0, x);
-
- cc.ret(x);
- cc.endFunc();
- }
-
- virtual bool run(void* _func, String& result, String& expect) {
- typedef float (*Func)(float);
- Func func = ptr_as_func<Func>(_func);
-
- float resultRet = func(42.0f);
- float expectRet = 42.0f;
-
- result.assignFormat("ret={%g}", resultRet);
- expect.assignFormat("ret={%g}", expectRet);
-
- return result == expect;
- }
-};
-
-// x86::Compiler - X86Test_AllocRetFloat2
-// ======================================
-
-class X86Test_AllocRetFloat2 : public X86TestCase {
-public:
- X86Test_AllocRetFloat2() : X86TestCase("AllocRetFloat2") {}
-
- static void add(TestApp& app) {
- app.add(new X86Test_AllocRetFloat2());
- }
-
- virtual void compile(x86::Compiler& cc) {
- x86::Xmm x = cc.newXmmSs("x");
- x86::Xmm y = cc.newXmmSs("y");
-
- FuncNode* funcNode = cc.addFunc(FuncSignature::build<float, float, float>());
- funcNode->setArg(0, x);
- funcNode->setArg(1, y);
-
- cc.addss(x, y);
- cc.ret(x);
-
- cc.endFunc();
- }
-
- virtual bool run(void* _func, String& result, String& expect) {
- typedef float (*Func)(float, float);
- Func func = ptr_as_func<Func>(_func);
-
- float resultRet = func(1.0f, 2.0f);
- float expectRet = 1.0f + 2.0f;
-
- result.assignFormat("ret={%g}", resultRet);
- expect.assignFormat("ret={%g}", expectRet);
-
- return result == expect;
- }
-};
-
-// x86::Compiler - X86Test_AllocRetDouble1
-// =======================================
-
-class X86Test_AllocRetDouble1 : public X86TestCase {
-public:
- X86Test_AllocRetDouble1() : X86TestCase("AllocRetDouble1") {}
-
- static void add(TestApp& app) {
- app.add(new X86Test_AllocRetDouble1());
- }
-
- virtual void compile(x86::Compiler& cc) {
- x86::Xmm x = cc.newXmmSd("x");
-
- FuncNode* funcNode = cc.addFunc(FuncSignature::build<double, double>());
- funcNode->setArg(0, x);
-
- cc.ret(x);
- cc.endFunc();
- }
-
- virtual bool run(void* _func, String& result, String& expect) {
- typedef double (*Func)(double);
- Func func = ptr_as_func<Func>(_func);
-
- double resultRet = func(42.0);
- double expectRet = 42.0;
-
- result.assignFormat("ret={%g}", resultRet);
- expect.assignFormat("ret={%g}", expectRet);
-
- return result == expect;
- }
-};
-
-// x86::Compiler - X86Test_AllocRetDouble2
-// =======================================
-
-class X86Test_AllocRetDouble2 : public X86TestCase {
-public:
- X86Test_AllocRetDouble2() : X86TestCase("AllocRetDouble2") {}
-
- static void add(TestApp& app) {
- app.add(new X86Test_AllocRetDouble2());
- }
-
- virtual void compile(x86::Compiler& cc) {
- x86::Xmm x = cc.newXmmSd("x");
- x86::Xmm y = cc.newXmmSd("y");
-
- FuncNode* funcNode = cc.addFunc(FuncSignature::build<double, double, double>());
- funcNode->setArg(0, x);
- funcNode->setArg(1, y);
-
- cc.addsd(x, y);
- cc.ret(x);
-
- cc.endFunc();
- }
-
- virtual bool run(void* _func, String& result, String& expect) {
- typedef double (*Func)(double, double);
- Func func = ptr_as_func<Func>(_func);
-
- double resultRet = func(1.0, 2.0);
- double expectRet = 1.0 + 2.0;
-
- result.assignFormat("ret={%g}", resultRet);
- expect.assignFormat("ret={%g}", expectRet);
-
- return result == expect;
- }
-};
-
-// x86::Compiler - X86Test_AllocStack
-// ==================================
-
-class X86Test_AllocStack : public X86TestCase {
-public:
- X86Test_AllocStack() : X86TestCase("AllocStack") {}
-
- enum { kSize = 256 };
-
- static void add(TestApp& app) {
- app.add(new X86Test_AllocStack());
- }
-
- virtual void compile(x86::Compiler& cc) {
- cc.addFunc(FuncSignature::build<int>());
-
- x86::Mem stack = cc.newStack(kSize, 1);
- stack.setSize(1);
-
- x86::Gp i = cc.newIntPtr("i");
- x86::Gp a = cc.newInt32("a");
- x86::Gp b = cc.newInt32("b");
-
- Label L_1 = cc.newLabel();
- Label L_2 = cc.newLabel();
-
- // Fill stack by sequence [0, 1, 2, 3 ... 255].
- cc.xor_(i, i);
-
- x86::Mem stackWithIndex = stack.clone();
- stackWithIndex.setIndex(i, 0);
-
- cc.bind(L_1);
- cc.mov(stackWithIndex, i.r8());
- cc.inc(i);
- cc.cmp(i, 255);
- cc.jle(L_1);
-
- // Sum sequence in stack.
- cc.xor_(i, i);
- cc.xor_(a, a);
-
- cc.bind(L_2);
- cc.movzx(b, stackWithIndex);
- cc.add(a, b);
- cc.inc(i);
- cc.cmp(i, 255);
- cc.jle(L_2);
-
- cc.ret(a);
- cc.endFunc();
- }
-
- virtual bool run(void* _func, String& result, String& expect) {
- typedef int (*Func)(void);
- Func func = ptr_as_func<Func>(_func);
-
- int resultRet = func();
- int expectRet = 32640;
-
- result.assignInt(resultRet);
- expect.assignInt(expectRet);
-
- return result == expect;
- }
-};
-
-// x86::Compiler - X86Test_AllocMemcpy
-// ===================================
+// x86::Compiler - X86Test_Memcpy
+// ==============================
-class X86Test_AllocMemcpy : public X86TestCase {
+class X86Test_Memcpy : public X86TestCase {
public:
- X86Test_AllocMemcpy() : X86TestCase("AllocMemcpy") {}
+ X86Test_Memcpy() : X86TestCase("Memcpy") {}
enum { kCount = 32 };
static void add(TestApp& app) {
- app.add(new X86Test_AllocMemcpy());
+ app.add(new X86Test_Memcpy());
}
virtual void compile(x86::Compiler& cc) {
@@ -2266,15 +2266,15 @@ public:
}
};
-// x86::Compiler - X86Test_AllocExtraBlock
-// =======================================
+// x86::Compiler - X86Test_ExtraBlock
+// ==================================
-class X86Test_AllocExtraBlock : public X86TestCase {
+class X86Test_ExtraBlock : public X86TestCase {
public:
- X86Test_AllocExtraBlock() : X86TestCase("AllocExtraBlock") {}
+ X86Test_ExtraBlock() : X86TestCase("ExtraBlock") {}
static void add(TestApp& app) {
- app.add(new X86Test_AllocExtraBlock());
+ app.add(new X86Test_ExtraBlock());
}
virtual void compile(x86::Compiler& cc) {
@@ -2328,17 +2328,17 @@ public:
}
};
-// x86::Compiler - X86Test_AllocAlphaBlend
-// =======================================
+// x86::Compiler - X86Test_AlphaBlend
+// ==================================
-class X86Test_AllocAlphaBlend : public X86TestCase {
+class X86Test_AlphaBlend : public X86TestCase {
public:
- X86Test_AllocAlphaBlend() : X86TestCase("AllocAlphaBlend") {}
+ X86Test_AlphaBlend() : X86TestCase("AlphaBlend") {}
enum { kCount = 17 };
static void add(TestApp& app) {
- app.add(new X86Test_AllocAlphaBlend());
+ app.add(new X86Test_AlphaBlend());
}
static uint32_t blendSrcOver(uint32_t d, uint32_t s) {
@@ -2406,6 +2406,117 @@ public:
}
};
+// x86::Compiler - X86Test_AVX512_KK
+// =================================
+
+class X86Test_AVX512_KK : public X86TestCase {
+public:
+ X86Test_AVX512_KK() : X86TestCase("AVX512_KK") {}
+
+ static void add(TestApp& app) {
+ const CpuInfo& cpuInfo = CpuInfo::host();
+
+ if (cpuInfo.features().x86().hasAVX512_F()) {
+ app.add(new X86Test_AVX512_KK());
+ }
+ }
+
+ virtual void compile(x86::Compiler& cc) {
+ FuncNode* funcNode = cc.addFunc(FuncSignature::build<uint32_t, const void*, const void*, uint32_t>());
+
+ x86::Gp a = cc.newIntPtr("a");
+ x86::Gp b = cc.newIntPtr("b");
+ x86::Gp pred = cc.newInt32("pred");
+ x86::Gp result = cc.newInt32("result");
+
+ x86::Vec va = cc.newZmm("va");
+ x86::Vec vb = cc.newZmm("vb");
+ x86::KReg kIn = cc.newKd("k_in");
+ x86::KReg kOut = cc.newKd("k_out");
+
+ funcNode->setArg(0, a);
+ funcNode->setArg(1, b);
+ funcNode->setArg(2, pred);
+
+ cc.vmovdqu32(va, x86::ptr(a));
+ cc.vmovdqu32(vb, x86::ptr(b));
+ cc.kmovd(kIn, pred);
+ cc.k(kIn).vpcmpeqd(kOut, va, vb);
+ cc.kmovd(result, kOut);
+ cc.ret(result);
+ cc.endFunc();
+ }
+
+ virtual bool run(void* _func, String& result, String& expect) {
+ typedef uint32_t (*Func)(const void*, const void*, uint32_t prevK);
+ Func func = ptr_as_func<Func>(_func);
+
+ static const uint32_t srcA[16] = { 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1 };
+ static const uint32_t srcB[16] = { 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1 };
+
+ uint32_t ret = func(srcA, srcB, 0xF0F0);
+
+ result.assignFormat("0x%08X", ret);
+ expect.assignFormat("0x%08X", 0xA040u);
+
+ return result == expect;
+ }
+};
+
+// x86::Compiler - X86Test_AVX512_TernLog
+// ======================================
+
+class X86Test_AVX512_TernLog : public X86TestCase {
+public:
+ X86Test_AVX512_TernLog() : X86TestCase("AVX512_TernLog") {}
+
+ static void add(TestApp& app) {
+ const CpuInfo& cpuInfo = CpuInfo::host();
+
+ if (cpuInfo.features().x86().hasAVX512_F()) {
+ app.add(new X86Test_AVX512_TernLog());
+ }
+ }
+
+ virtual void compile(x86::Compiler& cc) {
+ FuncNode* funcNode = cc.addFunc(FuncSignature::build<void, void*>());
+
+ x86::Gp out = cc.newIntPtr("outPtr");
+ x86::Vec vec = cc.newZmm("vec");
+
+ funcNode->setArg(0, out);
+
+ cc.vpternlogd(vec, vec, vec, 0xFFu);
+ cc.vmovdqu8(x86::ptr(out), vec);
+ cc.endFunc();
+ }
+
+ virtual bool run(void* _func, String& result, String& expect) {
+ typedef void (*Func)(void*);
+ Func func = ptr_as_func<Func>(_func);
+
+ uint32_t out[16];
+ func(out);
+
+ result.assign("{");
+ expect.assign("{");
+
+ for (uint32_t i = 0; i < 16; i++) {
+ if (i) {
+ result.append(", ");
+ expect.append(", ");
+ }
+ result.appendFormat("0x%08X", out[i]);
+ expect.appendFormat("0x%08X", 0xFFFFFFFFu);
+ }
+
+ result.append("}");
+ expect.append("}");
+
+ return result == expect;
+ }
+};
+
// x86::Compiler - X86Test_FuncArgInt8
// ===================================
@@ -4024,8 +4135,9 @@ public:
static void add(TestApp& app) {
const CpuInfo& cpuInfo = CpuInfo::host();
- if (cpuInfo.features().x86().hasAVX2() && sizeof(void*) == 8)
+ if (cpuInfo.features().x86().hasAVX2() && sizeof(void*) == 8) {
app.add(new X86Test_FuncCallAVXClobber());
+ }
}
virtual void compile(x86::Compiler& cc) {
@@ -4132,6 +4244,60 @@ public:
}
};
+// x86::Compiler - X86Test_VecToScalar
+// ===================================
+
+class X86Test_VecToScalar : public X86TestCase {
+public:
+ static constexpr uint32_t kVecCount = 64;
+
+ X86Test_VecToScalar() : X86TestCase("VecToScalar") {}
+
+ static void add(TestApp& app) {
+ app.add(new X86Test_VecToScalar());
+ }
+
+ virtual void compile(x86::Compiler& cc) {
+ FuncNode* func = cc.addFunc(FuncSignature::build<uint32_t, uint32_t>());
+
+ x86::Gp x = cc.newInt32("x");
+ x86::Gp t = cc.newInt32("t");
+ x86::Xmm v[kVecCount];
+
+ func->setArg(0, x);
+
+ for (size_t i = 0; i < kVecCount; i++) {
+ v[i] = cc.newXmm("v%d", i);
+ if (i != 0)
+ cc.add(x, 1);
+ cc.movd(v[i], x);
+ }
+
+ cc.xor_(x, x);
+
+ for (size_t i = 0; i < kVecCount; i++) {
+ cc.movd(t, v[i]);
+ cc.add(x, t);
+ }
+
+ cc.ret(x);
+ cc.endFunc();
+ }
+
+ virtual bool run(void* _func, String& result, String& expect) {
+ typedef uint32_t (*Func)(uint32_t);
+ Func func = ptr_as_func<Func>(_func);
+
+ uint32_t resultRet = func(1);
+ uint32_t expectRet = 2080; // 1 + 2 + 3 + ... + 64
+
+ result.assignFormat("ret=%d", resultRet);
+ expect.assignFormat("ret=%d", expectRet);
+
+ return result == expect;
+ }
+};
+
// x86::Compiler - X86Test_MiscLocalConstPool
// ==========================================
@@ -4445,22 +4611,10 @@ void compiler_add_x86_tests(TestApp& app) {
app.addT<X86Test_JumpTable3>();
app.addT<X86Test_JumpTable4>();
- // Alloc tests.
+ // Alloc and instruction tests.
app.addT<X86Test_AllocBase>();
app.addT<X86Test_AllocMany1>();
app.addT<X86Test_AllocMany2>();
- app.addT<X86Test_AllocImul1>();
- app.addT<X86Test_AllocImul2>();
- app.addT<X86Test_AllocIdiv1>();
- app.addT<X86Test_AllocSetz>();
- app.addT<X86Test_AllocShlRor>();
- app.addT<X86Test_AllocGpbLo1>();
- app.addT<X86Test_AllocGpbLo2>();
- app.addT<X86Test_AllocRepMovsb>();
- app.addT<X86Test_AllocIfElse1>();
- app.addT<X86Test_AllocIfElse2>();
- app.addT<X86Test_AllocIfElse3>();
- app.addT<X86Test_AllocIfElse4>();
app.addT<X86Test_AllocInt8>();
app.addT<X86Test_AllocUnhandledArg>();
app.addT<X86Test_AllocArgsIntPtr>();
@@ -4474,9 +4628,23 @@ void compiler_add_x86_tests(TestApp& app) {
app.addT<X86Test_AllocRetDouble1>();
app.addT<X86Test_AllocRetDouble2>();
app.addT<X86Test_AllocStack>();
- app.addT<X86Test_AllocMemcpy>();
- app.addT<X86Test_AllocExtraBlock>();
- app.addT<X86Test_AllocAlphaBlend>();
+ app.addT<X86Test_Imul1>();
+ app.addT<X86Test_Imul2>();
+ app.addT<X86Test_Idiv1>();
+ app.addT<X86Test_Setz>();
+ app.addT<X86Test_ShlRor>();
+ app.addT<X86Test_GpbLo1>();
+ app.addT<X86Test_GpbLo2>();
+ app.addT<X86Test_RepMovsb>();
+ app.addT<X86Test_IfElse1>();
+ app.addT<X86Test_IfElse2>();
+ app.addT<X86Test_IfElse3>();
+ app.addT<X86Test_IfElse4>();
+ app.addT<X86Test_Memcpy>();
+ app.addT<X86Test_ExtraBlock>();
+ app.addT<X86Test_AlphaBlend>();
+ app.addT<X86Test_AVX512_KK>();
+ app.addT<X86Test_AVX512_TernLog>();
// Function arguments handling tests.
app.addT<X86Test_FuncArgInt8>();
@@ -4512,6 +4680,7 @@ void compiler_add_x86_tests(TestApp& app) {
app.addT<X86Test_FuncCallAVXClobber>();
// Miscellaneous tests.
+ app.addT<X86Test_VecToScalar>();
app.addT<X86Test_MiscLocalConstPool>();
app.addT<X86Test_MiscGlobalConstPool>();
app.addT<X86Test_MiscMultiRet>();