OSDN Git Service

tests/tcg/ppc64le: tests for brh/brw/brd
authorMatheus Ferst <matheus.ferst@eldorado.org.br>
Wed, 12 May 2021 10:20:47 +0000 (11:20 +0100)
committerAlex Bennée <alex.bennee@linaro.org>
Tue, 18 May 2021 08:36:21 +0000 (09:36 +0100)
Tests for Byte-Reverse Halfword, Word and Doubleword

Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
Tested-by: Fabiano Rosas <farosas@linux.ibm.com>
[AJB: tweak to make rules for skip/plugins]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20210423205757.1752480-3-matheus.ferst@eldorado.org.br>
Message-Id: <20210512102051.12134-28-alex.bennee@linaro.org>

tests/tcg/ppc64/Makefile.target
tests/tcg/ppc64le/Makefile.target
tests/tcg/ppc64le/byte_reverse.c [new file with mode: 0644]

index 0c6a458..a6a4dda 100644 (file)
@@ -10,4 +10,17 @@ PPC64_TESTS=bcdsub
 endif
 bcdsub: CFLAGS += -mpower8-vector
 
+PPC64_TESTS += byte_reverse
+ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_POWER10),)
+run-byte_reverse: QEMU_OPTS+=-cpu POWER10
+run-plugin-byte_reverse-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")
+endif
+
 TESTS += $(PPC64_TESTS)
index 1acfcff..c0c14ff 100644 (file)
@@ -9,4 +9,17 @@ PPC64LE_TESTS=bcdsub
 endif
 bcdsub: CFLAGS += -mpower8-vector
 
+PPC64LE_TESTS += byte_reverse
+ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_POWER10),)
+run-byte_reverse: QEMU_OPTS+=-cpu POWER10
+run-plugin-byte_reverse-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")
+endif
+
 TESTS += $(PPC64LE_TESTS)
diff --git a/tests/tcg/ppc64le/byte_reverse.c b/tests/tcg/ppc64le/byte_reverse.c
new file mode 100644 (file)
index 0000000..53b76fc
--- /dev/null
@@ -0,0 +1,21 @@
+#include <assert.h>
+
+int main(void)
+{
+    unsigned long var;
+
+    var = 0xFEDCBA9876543210;
+    asm("brh %0, %0" : "+r"(var));
+    assert(var == 0xDCFE98BA54761032);
+
+    var = 0xFEDCBA9876543210;
+    asm("brw %0, %0" : "+r"(var));
+    assert(var == 0x98BADCFE10325476);
+
+    var = 0xFEDCBA9876543210;
+    asm("brd %0, %0" : "+r"(var));
+    assert(var == 0x1032547698BADCFE);
+
+    return 0;
+}
+