[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 08/16] tests/tcg/s390x: Test CLGEBR and CGEBRA
From: |
Thomas Huth |
Subject: |
[PULL 08/16] tests/tcg/s390x: Test CLGEBR and CGEBRA |
Date: |
Mon, 24 Jul 2023 18:53:41 +0200 |
From: Ilya Leoshkevich <iii@linux.ibm.com>
Add a small test to prevent regressions.
Tested-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-Id: <20230724082032.66864-10-iii@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/tcg/s390x/cgebra.c | 32 ++++++++++++++++++++++++++++++++
tests/tcg/s390x/clgebr.c | 32 ++++++++++++++++++++++++++++++++
tests/tcg/s390x/Makefile.target | 5 +++++
3 files changed, 69 insertions(+)
create mode 100644 tests/tcg/s390x/cgebra.c
create mode 100644 tests/tcg/s390x/clgebr.c
diff --git a/tests/tcg/s390x/cgebra.c b/tests/tcg/s390x/cgebra.c
new file mode 100644
index 0000000000..f91e10d2d3
--- /dev/null
+++ b/tests/tcg/s390x/cgebra.c
@@ -0,0 +1,32 @@
+/*
+ * Test the CGEBRA instruction.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#include <assert.h>
+#include <fenv.h>
+#include <stdlib.h>
+
+int main(void)
+{
+ float r2 = 1E+300;
+ long long r1;
+ int cc;
+
+ feclearexcept(FE_ALL_EXCEPT);
+ asm("cgebra %[r1],%[m3],%[r2],%[m4]\n"
+ "ipm %[cc]\n"
+ : [r1] "=r" (r1)
+ , [cc] "=r" (cc)
+ : [m3] "i" (5) /* round toward 0 */
+ , [r2] "f" (r2)
+ , [m4] "i" (8) /* bit 0 is set, but must be ignored; XxC is not set */
+ : "cc");
+ cc >>= 28;
+
+ assert(r1 == 0x7fffffffffffffffLL);
+ assert(cc == 3);
+ assert(fetestexcept(FE_ALL_EXCEPT) == (FE_INVALID | FE_INEXACT));
+
+ return EXIT_SUCCESS;
+}
diff --git a/tests/tcg/s390x/clgebr.c b/tests/tcg/s390x/clgebr.c
new file mode 100644
index 0000000000..d491899b56
--- /dev/null
+++ b/tests/tcg/s390x/clgebr.c
@@ -0,0 +1,32 @@
+/*
+ * Test the CLGEBR instruction.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#include <assert.h>
+#include <fenv.h>
+#include <stdlib.h>
+
+int main(void)
+{
+ float r2 = -1;
+ long long r1;
+ int cc;
+
+ feclearexcept(FE_ALL_EXCEPT);
+ asm("clgebr %[r1],%[m3],%[r2],%[m4]\n"
+ "ipm %[cc]\n"
+ : [r1] "=r" (r1)
+ , [cc] "=r" (cc)
+ : [m3] "i" (5) /* round toward 0 */
+ , [r2] "f" (r2)
+ , [m4] "i" (8) /* bit 0 is set, but must be ignored; XxC is not set */
+ : "cc");
+ cc >>= 28;
+
+ assert(r1 == 0);
+ assert(cc == 3);
+ assert(fetestexcept(FE_ALL_EXCEPT) == (FE_INVALID | FE_INEXACT));
+
+ return EXIT_SUCCESS;
+}
diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target
index 19fbbc6e53..71bf39b78d 100644
--- a/tests/tcg/s390x/Makefile.target
+++ b/tests/tcg/s390x/Makefile.target
@@ -39,12 +39,17 @@ TESTS+=mxdb
TESTS+=epsw
TESTS+=larl
TESTS+=mdeb
+TESTS+=cgebra
+TESTS+=clgebr
cdsg: CFLAGS+=-pthread
cdsg: LDFLAGS+=-pthread
rxsbg: CFLAGS+=-O2
+cgebra: LDFLAGS+=-lm
+clgebr: LDFLAGS+=-lm
+
include $(S390X_SRC)/pgm-specification.mak
$(PGM_SPECIFICATION_TESTS): pgm-specification-user.o
$(PGM_SPECIFICATION_TESTS): LDFLAGS+=pgm-specification-user.o
--
2.39.3
- [PULL 00/16] s390x fixes, Thomas Huth, 2023/07/24
- [PULL 01/16] target/s390x: Make CKSM raise an exception if R2 is odd, Thomas Huth, 2023/07/24
- [PULL 04/16] target/s390x: Fix ICM with M3=0, Thomas Huth, 2023/07/24
- [PULL 05/16] target/s390x: Make MC raise specification exception when class >= 16, Thomas Huth, 2023/07/24
- [PULL 07/16] tests/tcg/s390x: Test CKSM, Thomas Huth, 2023/07/24
- [PULL 11/16] tests/tcg/s390x: Test MC, Thomas Huth, 2023/07/24
- [PULL 08/16] tests/tcg/s390x: Test CLGEBR and CGEBRA,
Thomas Huth <=
- [PULL 06/16] target/s390x: Fix assertion failure in VFMIN/VFMAX with type 13, Thomas Huth, 2023/07/24
- [PULL 12/16] tests/tcg/s390x: Test STPQ, Thomas Huth, 2023/07/24
- [PULL 09/16] tests/tcg/s390x: Test CLM, Thomas Huth, 2023/07/24
- [PULL 13/16] tests/tcg/s390x: Test VCKSM, Thomas Huth, 2023/07/24
- [PULL 03/16] target/s390x: Fix CONVERT TO LOGICAL/FIXED with out-of-range inputs, Thomas Huth, 2023/07/24
- [PULL 10/16] tests/tcg/s390x: Test ICM, Thomas Huth, 2023/07/24
- [PULL 02/16] target/s390x: Fix CLM with M3=0, Thomas Huth, 2023/07/24
- [PULL 16/16] tests/avocado/machine_s390_ccw_virtio: Skip the flaky virtio-gpu test by default, Thomas Huth, 2023/07/24
- [PULL 14/16] tests/avocado/migration: Remove the malfunctioning s390x tests, Thomas Huth, 2023/07/24
- [PULL 15/16] target/loongarch: Fix the CSRRD CPUID instruction on big endian hosts, Thomas Huth, 2023/07/24