]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
s390: Remove none/tests/s390x/tcxb, add none/tests/s390x/bfp-tdc
authorFlorian Krohm <flo2030@eich-krohm.de>
Mon, 22 Sep 2025 15:31:12 +0000 (15:31 +0000)
committerFlorian Krohm <flo2030@eich-krohm.de>
Mon, 22 Sep 2025 15:31:12 +0000 (15:31 +0000)
tcxb was busted.
Part of fixing https://bugs.kde.org/show_bug.cgi?id=509572

none/tests/s390x/Makefile.am
none/tests/s390x/bfp-tdc.c [new file with mode: 0644]
none/tests/s390x/bfp-tdc.stderr.exp [moved from none/tests/s390x/tcxb.stderr.exp with 100% similarity]
none/tests/s390x/bfp-tdc.stdout.exp [new file with mode: 0644]
none/tests/s390x/bfp-tdc.vgtest [new file with mode: 0644]
none/tests/s390x/tcxb.c [deleted file]
none/tests/s390x/tcxb.stdout.exp [deleted file]
none/tests/s390x/tcxb.vgtest [deleted file]

index c1909da396115041e75d47f0d8b752d714099324..57dbb55db0781e7f91ad8afbddae6e758fc3003a 100644 (file)
@@ -2,14 +2,14 @@ include $(top_srcdir)/Makefile.tool-tests.am
 
 dist_noinst_SCRIPTS = filter_stderr bfp-emit.pl
 
-INSN_TESTS = clc clcle cvb cvd icm lpr tcxb lam_stam xc mvst add sub mul \
+INSN_TESTS = clc clcle cvb cvd icm lpr lam_stam xc mvst add sub mul \
              and or xor insert div srst fold_And16 flogr sub_EI add_EI \
              and_EI or_EI xor_EI insert_EI mul_GE add_GE condloadstore \
              op_exception fgx stck stckf stcke stfle cksm mvcl clcl troo \
              trto trot trtt tr tre cij cgij clij clgij crj cgrj clrj clgrj \
              cs csg cds cdsg cu21 cu21_1 cu24 cu24_1 cu42 cu12 cu12_1 \
              ex_sig ex_clone cu14 cu14_1 cu41 fpconv ecag fpext_warn \
-             rounding-1 rounding-2 rounding-3 rounding-4 rounding-5 bfp-1 \
+             bfp-tdc rounding-1 rounding-2 rounding-3 rounding-4 rounding-5 bfp-1 \
              bfp-2 bfp-3 bfp-4 srnm srnmb comp-1 comp-2 exrl tmll tm stmg \
             ex clst mvc test_fork test_sig rounding-6 rxsbg popcnt \
             high-word traps \
diff --git a/none/tests/s390x/bfp-tdc.c b/none/tests/s390x/bfp-tdc.c
new file mode 100644 (file)
index 0000000..a8b6769
--- /dev/null
@@ -0,0 +1,140 @@
+/* TEST DATA CLASS
+
+   Test for subnormal numbers is missing. I do not know how */
+#include <stdio.h>
+#include <math.h>      // NAN
+#include <float.h>     // DBL_MIN
+#include <assert.h>
+
+#define ZERO_P    (1 << 11)
+#define ZERO_N    (1 << 10)
+#define NORM_P    (1 << 9)
+#define NORM_N    (1 << 8)
+#define SUBNORM_P (1 << 7)
+#define SUBNORM_N (1 << 6)
+#define INF_P     (1 << 5)
+#define INF_N     (1 << 4)
+#define QNAN_P    (1 << 3)
+#define QNAN_N    (1 << 2)
+#define SNAN_P    (1 << 1)
+#define SNAN_N    (1 << 0)
+
+static struct what {
+   unsigned bitno;
+   unsigned mask;
+   const char *str;
+} whatsit[] = {
+   { 63, SNAN_N,    "Signaling Nan with sign bit negative" },
+   { 62, SNAN_P,    "Signaling Nan with sign bit posative" },
+   { 61, QNAN_N,    "Quiet Nan with sign bit negative" },
+   { 60, QNAN_P,    "Quiet Nan with sign bit posative" },
+   { 59, INF_N,     "Infinity with sign bit negative" },
+   { 58, INF_P,     "Infinity with sign bit positive" },
+   { 57, SUBNORM_N, "Subnormal number with sign bit negative" },
+   { 56, SUBNORM_N, "Subnormal number with sign bit positive" },
+   { 55, NORM_N,    "Normal number with sign bit negative" },
+   { 54, NORM_P,    "Normal number with sign bit positive" },
+   { 53, ZERO_N,    "Zero with sign bit negative" },
+   { 52, ZERO_P,    "Zero with sign bit positive" }
+};
+
+#define TDC(insn, type, value, m)                       \
+   ({                                                   \
+      int cc;                                           \
+      type r1 = value;                                  \
+                                                        \
+      __asm__ volatile(#insn " %[r1],0(%[mask])\n\t"    \
+                       "ipm  %[psw]\n\t"                \
+                       "srl  %[psw],28\n\t"             \
+                       : [psw]"+d"(cc)                  \
+                       : [r1]"f"(r1), [mask]"a"(m)   \
+                       : "cc");                         \
+      cc;                                               \
+   })
+
+static void
+do_tceb(float value)
+{
+   for (int i = 0; i < sizeof(whatsit) / sizeof(*whatsit); ++i) {
+      int ccv = TDC(tceb, float, value, whatsit[i].mask);
+      if (ccv == 1)
+         printf("value = %f\t\tcc = %d   %s\n", value, ccv,
+                whatsit[i].str);
+   }
+}
+
+static void
+do_tcdb(double value)
+{
+   for (int i = 0; i < sizeof(whatsit) / sizeof(*whatsit); ++i) {
+      int ccv = TDC(tcdb, double, value, whatsit[i].mask);
+      if (ccv == 1)
+         printf("value = %f\t\tcc = %d   %s\n", value, ccv,
+                whatsit[i].str);
+   }
+}
+
+static void
+do_tcxb(long double value)
+{
+   for (int i = 0; i < sizeof(whatsit) / sizeof(*whatsit); ++i) {
+      int ccv = TDC(tcxb, long double, value, whatsit[i].mask);
+      if (ccv == 1)
+         printf("value = %Lf\t\tcc = %d   %s\n", value, ccv,
+                whatsit[i].str);
+   }
+}
+
+int
+main(void)
+{
+   assert(sizeof(long double) == 16);
+
+   printf("32-bit tests\n");
+   do_tceb(0.0f);
+   do_tceb(-0.0f);
+   do_tceb(3.0f);
+   do_tceb(-3.0f);
+   do_tceb(NAN);
+   do_tceb(-NAN);
+   do_tceb(INFINITY);
+   do_tceb(-INFINITY);
+   do_tceb(__builtin_nansf(""));
+   do_tceb(-__builtin_nansf(""));
+   do_tceb(FLT_MIN / 2);
+   do_tceb(-FLT_MIN / 2);
+
+   printf("\n64-bit tests\n");
+   do_tcdb(0.0);
+   do_tcdb(-0.0);
+   do_tcdb(3.0);
+   do_tcdb(-3.0);
+   do_tcdb(NAN);
+   do_tcdb(-NAN);
+   do_tcdb(INFINITY);
+   do_tcdb(-INFINITY);
+   do_tcdb(__builtin_nans(""));
+   do_tcdb(-__builtin_nans(""));
+   do_tcdb(DBL_MIN / 2);
+   do_tcdb(-DBL_MIN / 2);
+
+   printf("\n128-bit tests\n");
+   do_tcxb(0.0L);
+   do_tcxb(-0.0L);
+   do_tcxb(3.0L);
+   do_tcxb(-3.0L);
+   do_tcxb(NAN);
+   do_tcxb(-NAN);
+   do_tcxb(INFINITY);
+   do_tcxb(-INFINITY);
+   do_tcxb(__builtin_nansl(""));
+   do_tcxb(-__builtin_nansl(""));
+#if 0
+   /* Figuring out subnormal numbers for 128-bit BFP is left as
+      an exercise.. */
+   do_tcdb(LDBL_MIN / 2);
+   do_tcdb(-LDBL_MIN / 2);
+#endif
+
+   return 0;
+}
diff --git a/none/tests/s390x/bfp-tdc.stdout.exp b/none/tests/s390x/bfp-tdc.stdout.exp
new file mode 100644 (file)
index 0000000..032287b
--- /dev/null
@@ -0,0 +1,39 @@
+32-bit tests
+value = 0.000000               cc = 1   Zero with sign bit positive
+value = -0.000000              cc = 1   Zero with sign bit negative
+value = 3.000000               cc = 1   Normal number with sign bit positive
+value = -3.000000              cc = 1   Normal number with sign bit negative
+value = nan            cc = 1   Quiet Nan with sign bit posative
+value = -nan           cc = 1   Quiet Nan with sign bit negative
+value = inf            cc = 1   Infinity with sign bit positive
+value = -inf           cc = 1   Infinity with sign bit negative
+value = nan            cc = 1   Signaling Nan with sign bit posative
+value = -nan           cc = 1   Signaling Nan with sign bit negative
+value = -0.000000              cc = 1   Subnormal number with sign bit negative
+value = -0.000000              cc = 1   Subnormal number with sign bit positive
+
+64-bit tests
+value = 0.000000               cc = 1   Zero with sign bit positive
+value = -0.000000              cc = 1   Zero with sign bit negative
+value = 3.000000               cc = 1   Normal number with sign bit positive
+value = -3.000000              cc = 1   Normal number with sign bit negative
+value = nan            cc = 1   Quiet Nan with sign bit posative
+value = -nan           cc = 1   Quiet Nan with sign bit negative
+value = inf            cc = 1   Infinity with sign bit positive
+value = -inf           cc = 1   Infinity with sign bit negative
+value = nan            cc = 1   Signaling Nan with sign bit posative
+value = -nan           cc = 1   Signaling Nan with sign bit negative
+value = -0.000000              cc = 1   Subnormal number with sign bit negative
+value = -0.000000              cc = 1   Subnormal number with sign bit positive
+
+128-bit tests
+value = 0.000000               cc = 1   Zero with sign bit positive
+value = -0.000000              cc = 1   Zero with sign bit negative
+value = 3.000000               cc = 1   Normal number with sign bit positive
+value = -3.000000              cc = 1   Normal number with sign bit negative
+value = nan            cc = 1   Quiet Nan with sign bit posative
+value = -nan           cc = 1   Quiet Nan with sign bit negative
+value = inf            cc = 1   Infinity with sign bit positive
+value = -inf           cc = 1   Infinity with sign bit negative
+value = nan            cc = 1   Signaling Nan with sign bit posative
+value = -nan           cc = 1   Signaling Nan with sign bit negative
diff --git a/none/tests/s390x/bfp-tdc.vgtest b/none/tests/s390x/bfp-tdc.vgtest
new file mode 100644 (file)
index 0000000..306de25
--- /dev/null
@@ -0,0 +1 @@
+prog: bfp-tdc
diff --git a/none/tests/s390x/tcxb.c b/none/tests/s390x/tcxb.c
deleted file mode 100644 (file)
index 4ff031f..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/* test data class tests for float, double, long double:  TCEB, TCDB, TCXB */
-#include <math.h>
-#include <stdio.h>
-
-static int tcxb(long double f, long long num)
-{
-       int match;
-
-       asm volatile("  tcxb %1,0(%2)\n"
-                       "ipm %0\n"
-                       "srl %0,28\n"
-                       : "=d" (match)
-                       : "f" (f), "a" (num)
-                       : "cc");
-       return match;
-}
-
-static int tcdb(double f, long long num)
-{
-       int match;
-
-       asm volatile("  tcdb %1,0(%2)\n"
-                       "ipm %0\n"
-                       "srl %0,28\n"
-                       : "=d" (match)
-                       : "f" (f), "a" (num)
-                       : "cc");
-       return match;
-}
-
-static int tceb(float f, long long num)
-{
-       int match;
-
-       asm volatile("  tceb %1,0(%2)\n"
-                       "ipm %0\n"
-                       "srl %0,28\n"
-                       : "=d" (match)
-                       : "f" (f), "a" (num)
-                       : "cc");
-       return match;
-}
-
-int main()
-{
-       int i;
-
-       for (i = 0; i < 64; i++) {
-               if (sizeof (long double) == 16) {
-                       /* long double 128 bit */
-                       printf("%d", tcxb(+0.0l,        1UL<<i));
-                       printf("%d", tcxb(-0.0l,        1UL<<i));
-                       printf("%d", tcxb(+2.2l,        1UL<<i));
-                       printf("%d", tcxb(-2.2l,        1UL<<i));
-                       printf("%d", tcxb(+INFINITY,    1UL<<i));
-                       printf("%d", tcxb(-INFINITY,    1UL<<i));
-                       printf("%d", tcxb(+NAN,         1UL<<i));
-                       printf("%d", tcxb(-NAN,         1UL<<i));
-               } else {
-                       /* long double 64 bit */
-                       printf("%d", tcdb(+0.0l,        1UL<<i));
-                       printf("%d", tcdb(-0.0l,        1UL<<i));
-                       printf("%d", tcdb(+2.2l,        1UL<<i));
-                       printf("%d", tcdb(-2.2l,        1UL<<i));
-                       printf("%d", tcdb(+INFINITY,    1UL<<i));
-                       printf("%d", tcdb(-INFINITY,    1UL<<i));
-                       printf("%d", tcdb(+NAN,         1UL<<i));
-                       printf("%d", tcdb(-NAN,         1UL<<i));
-               }
-               /* double 64 bit */
-               printf("%d", tcdb(+0.0,         1UL<<i));
-               printf("%d", tcdb(-0.0,         1UL<<i));
-               printf("%d", tcdb(+2.2,         1UL<<i));
-               printf("%d", tcdb(-2.2,         1UL<<i));
-               printf("%d", tcdb(+INFINITY,    1UL<<i));
-               printf("%d", tcdb(-INFINITY,    1UL<<i));
-               printf("%d", tcdb(+NAN,         1UL<<i));
-               printf("%d", tcdb(-NAN,         1UL<<i));
-
-
-               /* float 32 bit */
-               printf("%d", tceb(+0.0f,        1UL<<i));
-               printf("%d", tceb(-0.0f,        1UL<<i));
-               printf("%d", tceb(+2.2f,        1UL<<i));
-               printf("%d", tceb(-2.2f,        1UL<<i));
-               printf("%d", tceb(+INFINITY,    1UL<<i));
-               printf("%d", tceb(-INFINITY,    1UL<<i));
-               printf("%d", tceb(+NAN,         1UL<<i));
-               printf("%d", tceb(-NAN,         1UL<<i));
-
-               printf("\n");
-
-       }
-       return 0;
-}
diff --git a/none/tests/s390x/tcxb.stdout.exp b/none/tests/s390x/tcxb.stdout.exp
deleted file mode 100644 (file)
index f5bc67c..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-000000000000000000000000
-000000000000000000000000
-000000010000000100000001
-000000100000001000000010
-000001000000010000000100
-000010000000100000001000
-000000000000000000000000
-000000000000000000000000
-000100000001000000010000
-001000000010000000100000
-010000000100000001000000
-100000001000000010000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
-000000000000000000000000
diff --git a/none/tests/s390x/tcxb.vgtest b/none/tests/s390x/tcxb.vgtest
deleted file mode 100644 (file)
index fe7e9ea..0000000
+++ /dev/null
@@ -1 +0,0 @@
-prog: tcxb