qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Ilya Leoshkevich <iii@linux.ibm.com>
Subject: [PULL 08/16] tests/tcg/s390x: Test CLGEBR and CGEBRA
Date: Mon, 24 Jul 2023 18:53:41 +0200	[thread overview]
Message-ID: <20230724165349.55714-9-thuth@redhat.com> (raw)
In-Reply-To: <20230724165349.55714-1-thuth@redhat.com>

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



  parent reply	other threads:[~2023-07-24 16:56 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-24 16:53 [PULL 00/16] s390x fixes Thomas Huth
2023-07-24 16:53 ` [PULL 01/16] target/s390x: Make CKSM raise an exception if R2 is odd Thomas Huth
2023-07-24 16:53 ` [PULL 02/16] target/s390x: Fix CLM with M3=0 Thomas Huth
2023-07-24 16:53 ` [PULL 03/16] target/s390x: Fix CONVERT TO LOGICAL/FIXED with out-of-range inputs Thomas Huth
2023-07-24 16:53 ` [PULL 04/16] target/s390x: Fix ICM with M3=0 Thomas Huth
2023-07-24 16:53 ` [PULL 05/16] target/s390x: Make MC raise specification exception when class >= 16 Thomas Huth
2023-07-24 16:53 ` [PULL 06/16] target/s390x: Fix assertion failure in VFMIN/VFMAX with type 13 Thomas Huth
2023-07-24 16:53 ` [PULL 07/16] tests/tcg/s390x: Test CKSM Thomas Huth
2023-07-24 16:53 ` Thomas Huth [this message]
2023-07-24 16:53 ` [PULL 09/16] tests/tcg/s390x: Test CLM Thomas Huth
2023-07-24 16:53 ` [PULL 10/16] tests/tcg/s390x: Test ICM Thomas Huth
2023-07-24 16:53 ` [PULL 11/16] tests/tcg/s390x: Test MC Thomas Huth
2023-07-24 16:53 ` [PULL 12/16] tests/tcg/s390x: Test STPQ Thomas Huth
2023-07-24 16:53 ` [PULL 13/16] tests/tcg/s390x: Test VCKSM Thomas Huth
2023-07-24 16:53 ` [PULL 14/16] tests/avocado/migration: Remove the malfunctioning s390x tests Thomas Huth
2023-07-24 16:53 ` [PULL 15/16] target/loongarch: Fix the CSRRD CPUID instruction on big endian hosts Thomas Huth
2023-07-24 16:53 ` [PULL 16/16] tests/avocado/machine_s390_ccw_virtio: Skip the flaky virtio-gpu test by default Thomas Huth
2023-07-25 11:44 ` [PULL 00/16] s390x fixes Peter Maydell

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=20230724165349.55714-9-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=iii@linux.ibm.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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).