Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tests/tcg/ppc64/Makefile.target
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,28 @@ $(PPC64_TESTS): CFLAGS += -mpower8-vector

PPC64_TESTS += byte_reverse
PPC64_TESTS += mtfsf
PPC64_TESTS += xvtlsbb
ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_POWER10),)
run-byte_reverse: QEMU_OPTS+=-cpu POWER10
run-plugin-byte_reverse-with-%: QEMU_OPTS+=-cpu POWER10

xvtlsbb: CFLAGS += -mcpu=power10
run-xvtlsbb: QEMU_OPTS += -cpu POWER10
run-plugin-xvtlsbb-with-%: QEMU_OPTS += -cpu POWER10
else
byte_reverse:
$(call skip-test, "BUILD of $@", "missing compiler support")
run-byte_reverse:
$(call skip-test, "RUN of byte_reverse", "not built")
run-plugin-byte_reverse-with-%:
$(call skip-test, "RUN of byte_reverse ($*)", "not built")

xvtlsbb:
$(call skip-test, "BUILD of $@", "missing compiler support")
run-xvtlsbb:
$(call skip-test, "RUN of xvtlsbb", "not built")
run-plugin-xvtlsbb-with-%:
$(call skip-test, "RUN of xvtlsbb ($*)", "not built")
endif

PPC64_TESTS += signal_save_restore_xer
Expand Down
6 changes: 5 additions & 1 deletion tests/tcg/ppc64le/Makefile.target
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ endif
$(PPC64LE_TESTS): CFLAGS += -mpower8-vector

ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_POWER10),)
PPC64LE_TESTS += byte_reverse
PPC64LE_TESTS += byte_reverse xvtlsbb
endif
byte_reverse: CFLAGS += -mcpu=power10
run-byte_reverse: QEMU_OPTS+=-cpu POWER10
run-plugin-byte_reverse-with-%: QEMU_OPTS+=-cpu POWER10

xvtlsbb: CFLAGS += -mcpu=power10
run-xvtlsbb: QEMU_OPTS += -cpu POWER10
run-plugin-xvtlsbb-with-%: QEMU_OPTS += -cpu POWER10

PPC64LE_TESTS += mtfsf
PPC64LE_TESTS += signal_save_restore_xer

Expand Down
54 changes: 54 additions & 0 deletions tests/tcg/ppc64le/xvtlsbb.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include <assert.h>
#include <limits.h>
#include <unistd.h>
#include <signal.h>
#include <stdint.h>

#define XSTR(x) #x
#define STR(x) XSTR(x)
#define I128(a, b) ((__int128)(a) << 64 | (b))

#define TEST(H, L, BF, EXP) \
do { \
uint32_t cr; \
__uint128_t xb = I128(H, L); \
\
asm("xvtlsbb %1, %x2\n\t" \
"mfcr %0\n\t" \
: "=r"(cr) \
: "i"(BF), "wa"(xb) \
: "cr" STR(BF)); \
\
cr = (cr >> (4 * (7 - BF))) & 0xf; \
assert(cr == EXP); \
} while (0)

#define TESTN(H, L, EXP) \
do { \
TEST(H, L, 0, EXP); \
TEST(H, L, 1, EXP); \
TEST(H, L, 2, EXP); \
TEST(H, L, 3, EXP); \
TEST(H, L, 4, EXP); \
TEST(H, L, 5, EXP); \
TEST(H, L, 6, EXP); \
TEST(H, L, 7, EXP); \
} while (0)

int main(void)
{
struct sigaction action;

action.sa_handler = _exit;
sigaction(SIGABRT, &action, NULL);

TESTN(0x0000000000000000ULL, 0x0000000000000000ULL, 0b0010);
TESTN(0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, 0b1000);
TESTN(0xEEEEEEEEEEEEEEEEULL, 0xEEEEEEEEEEEEEEEEULL, 0b0010);
TESTN(0x7777777777777777ULL, 0x7777777777777777ULL, 0b1000);
TESTN(0x0000000000000000ULL, 0xFFFFFFFFFFFFFFFFULL, 0b0000);
TESTN(0xFFFFFFFFFFFFFFFFULL, 0x0000000000000000ULL, 0b0000);
TESTN(0x000000000000FFFFULL, 0x000000000000FFFFULL, 0b0000);

return 0;
}