Skip to content

Commit c07f01c

Browse files
committed
tests/tcg/ppc64[le]: Add tests for xvcvbf16spn and xvcvspbf16
Signed-off-by: Víctor Colombo <[email protected]>
1 parent 828cd02 commit c07f01c

File tree

3 files changed

+69
-3
lines changed

3 files changed

+69
-3
lines changed

tests/tcg/ppc64/Makefile.target

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,28 @@ PPC64_TESTS=bcdsub non_signalling_xscv
1010
endif
1111
$(PPC64_TESTS): CFLAGS += -mpower8-vector
1212

13-
PPC64_TESTS += byte_reverse
14-
PPC64_TESTS += mtfsf
13+
PPC64_TESTS += byte_reverse mtfsf xvcvspbf16
1514
ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_POWER10),)
1615
run-byte_reverse: QEMU_OPTS+=-cpu POWER10
1716
run-plugin-byte_reverse-with-%: QEMU_OPTS+=-cpu POWER10
17+
18+
xvcvspbf16: CFLAGS += -mcpu=power10
19+
run-xvcvspbf16: QEMU_OPTS+=-cpu POWER10
20+
run-plugin-xvcvspbf16-with-%: QEMU_OPTS+=-cpu POWER10
1821
else
1922
byte_reverse:
2023
$(call skip-test, "BUILD of $@", "missing compiler support")
2124
run-byte_reverse:
2225
$(call skip-test, "RUN of byte_reverse", "not built")
2326
run-plugin-byte_reverse-with-%:
2427
$(call skip-test, "RUN of byte_reverse ($*)", "not built")
28+
29+
xvcvspbf16:
30+
$(call skip-test, "BUILD of $@", "missing compiler support")
31+
run-xvcvspbf16:
32+
$(call skip-test, "RUN of xvcvspbf16", "not built")
33+
run-plugin-xvcvspbf16-with-%:
34+
$(call skip-test, "RUN of xvcvspbf16 ($*)", "not built")
2535
endif
2636

2737
PPC64_TESTS += signal_save_restore_xer

tests/tcg/ppc64le/Makefile.target

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@ endif
1010
$(PPC64LE_TESTS): CFLAGS += -mpower8-vector
1111

1212
ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_POWER10),)
13-
PPC64LE_TESTS += byte_reverse
13+
PPC64LE_TESTS += byte_reverse xvcvspbf16
1414
endif
1515
byte_reverse: CFLAGS += -mcpu=power10
1616
run-byte_reverse: QEMU_OPTS+=-cpu POWER10
1717
run-plugin-byte_reverse-with-%: QEMU_OPTS+=-cpu POWER10
1818

19+
xvcvspbf16: CFLAGS += -mcpu=power10
20+
run-xvcvspbf16: QEMU_OPTS+=-cpu POWER10
21+
run-plugin-xvcvspbf16-with-%: QEMU_OPTS+=-cpu POWER10
22+
1923
PPC64LE_TESTS += mtfsf
2024
PPC64LE_TESTS += signal_save_restore_xer
2125

tests/tcg/ppc64le/xvcvspbf16.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#include <assert.h>
2+
#include <limits.h>
3+
#include <unistd.h>
4+
#include <signal.h>
5+
#include <stdint.h>
6+
7+
#define I128(a, b) ((__int128)(a) << 64 | (b))
8+
9+
#define TEST_XVCVBF16SPN(B, EXP) \
10+
do { \
11+
__uint128_t b = B; \
12+
__uint128_t t; \
13+
\
14+
asm("xvcvbf16spn %0, %1\n\t" : "=wa"(t) : "wa"(b)); \
15+
\
16+
assert(t == EXP); \
17+
} while (0)
18+
19+
#define TEST_XVCVSPBF16(B, EXP) \
20+
do { \
21+
__uint128_t b = B; \
22+
__uint128_t t; \
23+
\
24+
asm("xvcvspbf16 %0, %1\n\t" : "=wa"(t) : "wa"(b)); \
25+
/* TODO: when implementation is fixed, check fpscr */ \
26+
\
27+
assert(t == EXP); \
28+
} while (0)
29+
30+
int main(void)
31+
{
32+
struct sigaction action;
33+
34+
action.sa_handler = _exit;
35+
sigaction(SIGABRT, &action, NULL);
36+
37+
TEST_XVCVBF16SPN(I128(0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL),
38+
I128(0xFFFF0000FFFF0000ULL, 0xFFFF0000FFFF0000ULL));
39+
TEST_XVCVBF16SPN(I128(0x4094E5B530214B78ULL, 0x7FFF000040490FDBULL),
40+
I128(0xE5B500004B780000ULL, 0x000000000FDB0000ULL));
41+
42+
TEST_XVCVSPBF16(I128(0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL),
43+
I128(0x0000FFFF0000FFFFULL, 0x0000FFFF0000FFFFULL));
44+
TEST_XVCVSPBF16(I128(0x4000921FB54442D1ULL, 0x8469898CC51701B8ULL),
45+
I128(0x000040010000B544ULL, 0x0000846A0000C517ULL));
46+
/* Test NaN */
47+
TEST_XVCVSPBF16(I128(0x7FA0000000000000ULL, 0x7FA07FA000007FA0ULL),
48+
I128(0x00007FE000000000ULL, 0x00007FE000000000ULL));
49+
50+
51+
return 0;
52+
}

0 commit comments

Comments
 (0)