[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 09/14] tests/tcg/s390x: Test CLGEBR and CGEBRA
From: |
Ilya Leoshkevich |
Subject: |
[PATCH v2 09/14] tests/tcg/s390x: Test CLGEBR and CGEBRA |
Date: |
Wed, 19 Jul 2023 11:44:19 +0200 |
Add a small test to prevent regressions.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
tests/tcg/s390x/Makefile.target | 5 +++++
tests/tcg/s390x/cgebra.c | 32 ++++++++++++++++++++++++++++++++
tests/tcg/s390x/clgebr.c | 32 ++++++++++++++++++++++++++++++++
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/Makefile.target b/tests/tcg/s390x/Makefile.target
index 19fbbc6e531..71bf39b78d3 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
diff --git a/tests/tcg/s390x/cgebra.c b/tests/tcg/s390x/cgebra.c
new file mode 100644
index 00000000000..f91e10d2d3c
--- /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 00000000000..d491899b56e
--- /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;
+}
--
2.41.0
- [PATCH v2 00/14] target/s390x: Miscellaneous TCG fixes, part 2, Ilya Leoshkevich, 2023/07/19
- [PATCH v2 05/14] target/s390x: Make MC raise specification exception when class >= 16, Ilya Leoshkevich, 2023/07/19
- [PATCH v2 02/14] target/s390x: Fix CLM with M3=0, Ilya Leoshkevich, 2023/07/19
- [PATCH v2 03/14] target/s390x: Fix CONVERT TO LOGICAL/FIXED with out-of-range inputs, Ilya Leoshkevich, 2023/07/19
- [PATCH v2 13/14] tests/tcg/s390x: Test STPQ, Ilya Leoshkevich, 2023/07/19
- [PATCH v2 09/14] tests/tcg/s390x: Test CLGEBR and CGEBRA,
Ilya Leoshkevich <=
- [PATCH v2 08/14] tests/tcg/s390x: Test CKSM, Ilya Leoshkevich, 2023/07/19
- [PATCH v2 01/14] target/s390x: Make CKSM raise an exception if R2 is odd, Ilya Leoshkevich, 2023/07/19
- [PATCH v2 04/14] target/s390x: Fix ICM with M3=0, Ilya Leoshkevich, 2023/07/19
- [PATCH v2 14/14] tests/tcg/s390x: Test VCKSM, Ilya Leoshkevich, 2023/07/19
- [PATCH v2 07/14] target/s390x: Fix assertion failure in VFMIN/VFMAX with type 13, Ilya Leoshkevich, 2023/07/19