Skip to content

Commit

Permalink
tests/tcg/ppc64[le]: Add tests for vmsumcud and vmsumudm instructions
Browse files Browse the repository at this point in the history
Signed-off-by: Víctor Colombo <[email protected]>
  • Loading branch information
vcoracolombo committed Jan 25, 2022
1 parent 828cd02 commit d98471b
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 3 deletions.
7 changes: 5 additions & 2 deletions tests/tcg/ppc64/Makefile.target
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ PPC64_TESTS=bcdsub non_signalling_xscv
endif
$(PPC64_TESTS): CFLAGS += -mpower8-vector

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

vmsumcud: CFLAGS += -mcpu=power10
run-vmsumcud: QEMU_OPTS+=-cpu POWER10
run-plugin-vmsumcud-with-%: QEMU_OPTS+=-cpu POWER10
else
byte_reverse:
$(call skip-test, "BUILD of $@", "missing compiler support")
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 vmsumcud
endif
byte_reverse: CFLAGS += -mcpu=power10
run-byte_reverse: QEMU_OPTS+=-cpu POWER10
run-plugin-byte_reverse-with-%: QEMU_OPTS+=-cpu POWER10

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

PPC64LE_TESTS += mtfsf
PPC64LE_TESTS += signal_save_restore_xer

Expand Down
47 changes: 47 additions & 0 deletions tests/tcg/ppc64le/vmsumcud.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#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(INSN, A, B, C, EXP) \
do { \
__uint128_t a = A, b = B, c = C; \
__uint128_t t; \
\
asm(INSN " %0, %1, %2, %3" : "=v"(t) : "v"(a), "v"(b), "v"(c));\
\
assert(t == EXP); \
} while (0)

int main(void)
{
struct sigaction action;

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

TEST("vmsumcud", I128(0xffffffffffffffffULL, 0xffffffffffffffffULL),
I128(0xffffffffffffffffULL, 0xffffffffffffffffULL),
I128(0xffffffffffffffffULL, 0xffffffffffffffffULL),
I128(0x0, 0x2));
TEST("vmsumudm", I128(0xffffffffffffffffULL, 0xffffffffffffffffULL),
I128(0xffffffffffffffffULL, 0xffffffffffffffffULL),
I128(0xffffffffffffffffULL, 0xffffffffffffffffULL),
I128(0xfffffffffffffffcULL, 0x1));

TEST("vmsumcud", I128(0x7a5dc79113085e5eULL, 0x85992739e89cd5c5ULL),
I128(0xdf4875aeec5f3e50ULL, 0xb438c5a12aa9859fULL),
I128(0x466a40ee1b83303cULL, 0xf15e03137f41eb8aULL),
I128(0x0, 0x1));
TEST("vmsumudm", I128(0x7a5dc79113085e5eULL, 0x85992739e89cd5c5ULL),
I128(0xdf4875aeec5f3e50ULL, 0xb438c5a12aa9859fULL),
I128(0x466a40ee1b83303cULL, 0xf15e03137f41eb8aULL),
I128(0x0f31e49e57d1bdf8ULL, 0x13c42b548b214b45ULL));

return 0;
}

0 comments on commit d98471b

Please sign in to comment.