From 3823b9483b835569c702e089b2d8b94b0b29f3b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Colombo?= Date: Tue, 25 Jan 2022 09:11:43 -0300 Subject: [PATCH] tests/tcg/ppc64[le]: Add tests for vmsumcud and vmsumudm instructions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: VĂ­ctor Colombo --- tests/tcg/ppc64/Makefile.target | 14 ++++++++-- tests/tcg/ppc64le/Makefile.target | 6 ++++- tests/tcg/ppc64le/vmsumcud.c | 45 +++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 tests/tcg/ppc64le/vmsumcud.c diff --git a/tests/tcg/ppc64/Makefile.target b/tests/tcg/ppc64/Makefile.target index 0368007028c9..633f1e6eb5b0 100644 --- a/tests/tcg/ppc64/Makefile.target +++ b/tests/tcg/ppc64/Makefile.target @@ -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") @@ -22,6 +25,13 @@ 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") + +vmsumcud: + $(call skip-test, "BUILD of $@", "missing compiler support") +run-vmsumcud: + $(call skip-test, "RUN of vmsumcud", "not built") +run-plugin-vmsumcud-with-%: + $(call skip-test, "RUN of vmsumcud ($*)", "not built") endif PPC64_TESTS += signal_save_restore_xer diff --git a/tests/tcg/ppc64le/Makefile.target b/tests/tcg/ppc64le/Makefile.target index 480ff0898d7e..8640c9aba32f 100644 --- a/tests/tcg/ppc64le/Makefile.target +++ b/tests/tcg/ppc64le/Makefile.target @@ -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 diff --git a/tests/tcg/ppc64le/vmsumcud.c b/tests/tcg/ppc64le/vmsumcud.c new file mode 100644 index 000000000000..9ca1a323f382 --- /dev/null +++ b/tests/tcg/ppc64le/vmsumcud.c @@ -0,0 +1,45 @@ +#include +#include +#include +#include +#include + +#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; +}