From: Ilya Leoshkevich <iii@linux.ibm.com>
To: Richard Henderson <richard.henderson@linaro.org>,
David Hildenbrand <david@redhat.com>,
Thomas Huth <thuth@redhat.com>
Cc: qemu-s390x@nongnu.org, qemu-devel@nongnu.org,
Ilya Leoshkevich <iii@linux.ibm.com>
Subject: [PATCH 09/14] tests/tcg/s390x: Test CLGEBR and CGEBRA
Date: Tue, 18 Jul 2023 23:21:10 +0200 [thread overview]
Message-ID: <20230718213531.117976-10-iii@linux.ibm.com> (raw)
In-Reply-To: <20230718213531.117976-1-iii@linux.ibm.com>
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
next prev parent reply other threads:[~2023-07-18 21:37 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-18 21:21 [PATCH 00/14] target/s390x: Miscellaneous TCG fixes, part 2 Ilya Leoshkevich
2023-07-18 21:21 ` [PATCH 01/14] target/s390x: Make CKSM raise an exception if R2 is odd Ilya Leoshkevich
2023-07-19 8:26 ` David Hildenbrand
2023-07-18 21:21 ` [PATCH 02/14] target/s390x: Fix CLM with M3=0 Ilya Leoshkevich
2023-07-19 8:27 ` David Hildenbrand
2023-07-18 21:21 ` [PATCH 03/14] target/s390x: Fix CONVERT TO LOGICAL/FIXED with out-of-range inputs Ilya Leoshkevich
2023-07-19 8:28 ` David Hildenbrand
2023-07-18 21:21 ` [PATCH 04/14] target/s390x: Fix ICM with M3=0 Ilya Leoshkevich
2023-07-19 8:32 ` David Hildenbrand
2023-07-18 21:21 ` [PATCH 05/14] target/s390x: Make MC raise specification exception when class >= 16 Ilya Leoshkevich
2023-07-19 8:43 ` David Hildenbrand
2023-07-18 21:21 ` [PATCH 06/14] tcg/{i386, s390x}: Add earlyclobber to the op_add2's first output Ilya Leoshkevich
2023-07-18 21:21 ` [PATCH 07/14] target/s390x: Fix assertion failure in VFMIN/VFMAX with reserved type Ilya Leoshkevich
2023-07-19 8:40 ` David Hildenbrand
2023-07-19 9:34 ` Ilya Leoshkevich
2023-07-19 9:44 ` David Hildenbrand
2023-07-18 21:21 ` [PATCH 08/14] tests/tcg/s390x: Test CKSM Ilya Leoshkevich
2023-07-18 21:21 ` Ilya Leoshkevich [this message]
2023-07-18 21:21 ` [PATCH 10/14] tests/tcg/s390x: Test CLM Ilya Leoshkevich
2023-07-18 21:21 ` [PATCH 11/14] tests/tcg/s390x: Test ICM Ilya Leoshkevich
2023-07-18 21:21 ` [PATCH 12/14] tests/tcg/s390x: Test MC Ilya Leoshkevich
2023-07-18 21:21 ` [PATCH 13/14] tests/tcg/s390x: Test STPQ Ilya Leoshkevich
2023-07-18 21:21 ` [PATCH 14/14] tests/tcg/s390x: Test VCKSM Ilya Leoshkevich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230718213531.117976-10-iii@linux.ibm.com \
--to=iii@linux.ibm.com \
--cc=david@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).