tcxb was busted.
Part of fixing https://bugs.kde.org/show_bug.cgi?id=509572
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 \
--- /dev/null
+/* 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;
+}
--- /dev/null
+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
--- /dev/null
+prog: bfp-tdc
+++ /dev/null
-/* 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;
-}
+++ /dev/null
-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
+++ /dev/null
-prog: tcxb