libnum: add performance tests for num32

This commit is contained in:
Lephenixnoir 2022-07-24 00:21:56 +01:00
parent 708ba1b017
commit 4238d5853f
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
2 changed files with 80 additions and 1 deletions

View File

@ -38,7 +38,8 @@ endif()
set(PERF_TESTS
test/isel_num8.cpp
test/isel_num16.cpp)
test/isel_num16.cpp
test/isel_num32.cpp)
foreach(testfile IN LISTS PERF_TESTS)
add_test(NAME "${testfile}"

View File

@ -0,0 +1,78 @@
#include <num/num.h>
using namespace num;
extern "C" {
// num32_of_num8: %=2 && [extu.b] && [shll8]
num32 num32_of_num8(num8 x)
{
return num32(x);
}
// num32_of_num16: %=2 && [exts.w] && [shll8]
num32 num32_of_num16(num16 x)
{
return num32(x);
}
// num32_of_num64: %=[xtrct]
num32 num32_of_num64(num64 x)
{
return num32(x);
}
// num32_mul: [dmuls.l] && [xtrct]
num32 num32_mul(num32 x, num32 y)
{
return x * y;
}
// num32_dmul: [dmuls.l]
num64 num32_dmul(num32 x, num32 y)
{
return num32::dmul(x, y);
}
// num32_eq: [bt* || bf*] && [shll16]
bool num32_eq(num32 x, int i)
{
return x == i;
}
// num32_le: ![bt* || bf*]
bool num32_le(num32 x, int i)
{
return x <= i;
}
// num32_gt: ![bt* || bf*]
bool num32_gt(num32 x, int i)
{
return x > i;
}
// num32_le_0: %<=3
bool num32_le_0(num32 x)
{
return x <= num32(0);
}
// num32_ge_0: %<=3
bool num32_ge_0(num32 x)
{
return x >= num32(0);
}
// num32_gt_0: %<=3
bool num32_gt_0(num32 x)
{
return x > num32(0);
}
// num32_lt_0: %<=3
bool num32_lt_0(num32 x)
{
return x < num32(0);
}
} /* extern "C" */