--- /dev/null
+#include <stdio.h>
+#include <assert.h>
+#include <math.h>
+
+/* Test various BFP ops:
+ - load and test
+ - load zero
+*/
+
+#define LOADxxx(insn, initial, type, fmt) \
+ do { \
+ int cc; \
+ type in = initial; \
+ type out = 17; \
+ __asm__ volatile("cr 0,0\n\t /* clear cc */\n\t" \
+ insn " %[r1],%[r2]\n\t" \
+ "ipm %[psw]\n\t" \
+ "srl %[psw],28\n\t" \
+ : [r1]"=f"(out), [psw]"=d"(cc) \
+ : [r2]"f"(in) \
+ : "cc"); \
+ printf(insn " " fmt " -> " fmt " cc = %d\n", in, out, cc); \
+ } while (0)
+
+void lzxr(void)
+{
+ long double value;
+
+ __builtin_memset(&value, 0xff, sizeof value);
+ __asm__ volatile("lzxr %[r1]" : [r1]"=f"(value));
+
+ printf("lzxr --> ");
+ for (unsigned i = 0; i < sizeof(long double); ++i) {
+ if (i % 4 == 0) putchar(' ');
+ unsigned byte = ((char *)&value)[i];
+ printf("%02u", byte);
+ }
+ putchar ('\n');
+}
+
+int main(void)
+{
+ assert(sizeof(long double) == 16);
+
+ printf("LOAD AND TEST short BFP\n");
+ LOADxxx("ltebr", 100.0f, float, "%f");
+ LOADxxx("ltebr", -10.5f, float, "%f");
+ LOADxxx("ltebr", 0.0f, float, "%f");
+ LOADxxx("ltebr", NAN, float, "%f");
+ LOADxxx("ltebr", -NAN, float, "%f");
+ LOADxxx("ltebr", INFINITY, float, "%f");
+ LOADxxx("ltebr", -INFINITY, float, "%f");
+
+ printf("LOAD AND TEST long BFP\n");
+ LOADxxx("ltdbr", 100.0, double, "%f");
+ LOADxxx("ltdbr", -10.5, double, "%f");
+ LOADxxx("ltdbr", 0.0, double, "%f");
+ LOADxxx("ltdbr", NAN, double, "%f");
+ LOADxxx("ltdbr", INFINITY, double, "%f");
+ LOADxxx("ltdbr", -INFINITY, double, "%f");
+
+ printf("LOAD AND TEST extended BFP\n");
+ LOADxxx("ltxbr", 100.0L, long double, "%Lf");
+ LOADxxx("ltxbr", -10.5L, long double, "%Lf");
+ LOADxxx("ltxbr", 0.0L, long double, "%Lf");
+ LOADxxx("ltxbr", NAN, long double, "%Lf");
+ LOADxxx("ltxbr", INFINITY, long double, "%Lf");
+ LOADxxx("ltxbr", -INFINITY, long double, "%Lf");
+
+ putchar('\n');
+ printf("LOAD NEGATIVE short BFP\n");
+ LOADxxx("lnebr", 0.0f, float, "%f");
+ LOADxxx("lnebr", -0.0f, float, "%f");
+ LOADxxx("lnebr", 123.0f, float, "%f");
+ LOADxxx("lnebr", -12.0f, float, "%f");
+ LOADxxx("lnebr", NAN, float, "%f");
+ LOADxxx("lnebr", -NAN, float, "%f");
+ LOADxxx("lnebr", INFINITY, float, "%f");
+ LOADxxx("lnebr", -INFINITY, float, "%f");
+
+ printf("LOAD NEGATIVE long BFP\n");
+ LOADxxx("lndbr", 0.0, double, "%f");
+ LOADxxx("lndbr", -0.0, double, "%f");
+ LOADxxx("lndbr", 123.0, double, "%f");
+ LOADxxx("lndbr", -12.0, double, "%f");
+ LOADxxx("lndbr", NAN, double, "%f");
+ LOADxxx("lndbr", -NAN, double, "%f");
+ LOADxxx("lndbr", INFINITY, double, "%f");
+ LOADxxx("lndbr", -INFINITY, double, "%f");
+
+ printf("LOAD NEGATIVE extended BFP\n");
+ LOADxxx("lnxbr", 0.0L, long double, "%Lf");
+ LOADxxx("lnxbr", -0.0L, long double, "%Lf");
+ LOADxxx("lnxbr", 123.0L, long double, "%Lf");
+ LOADxxx("lnxbr", -12.0L, long double, "%Lf");
+ LOADxxx("lnxbr", NAN, long double, "%Lf");
+ LOADxxx("lnxbr", -NAN, long double, "%Lf");
+ LOADxxx("lnxbr", INFINITY, long double, "%Lf");
+ LOADxxx("lnxbr", -INFINITY, long double, "%Lf");
+
+ putchar('\n');
+ printf("LOAD POSITIVE short BFP\n");
+ LOADxxx("lpebr", 0.0f, float, "%f");
+ LOADxxx("lpebr", -0.0f, float, "%f");
+ LOADxxx("lpebr", 123.0f, float, "%f");
+ LOADxxx("lpebr", -12.0f, float, "%f");
+ LOADxxx("lpebr", NAN, float, "%f");
+ LOADxxx("lpebr", -NAN, float, "%f");
+ LOADxxx("lpebr", INFINITY, float, "%f");
+ LOADxxx("lpebr", -INFINITY, float, "%f");
+
+ printf("LOAD POSITIVE long BFP\n");
+ LOADxxx("lpdbr", 0.0, double, "%f");
+ LOADxxx("lpdbr", -0.0, double, "%f");
+ LOADxxx("lpdbr", 123.0, double, "%f");
+ LOADxxx("lpdbr", -12.0, double, "%f");
+ LOADxxx("lpdbr", NAN, double, "%f");
+ LOADxxx("lpdbr", -NAN, double, "%f");
+ LOADxxx("lpdbr", INFINITY, double, "%f");
+ LOADxxx("lpdbr", -INFINITY, double, "%f");
+
+ printf("LOAD POSITIVE extended BFP\n");
+ LOADxxx("lpxbr", 0.0L, long double, "%Lf");
+ LOADxxx("lpxbr", -0.0L, long double, "%Lf");
+ LOADxxx("lpxbr", 123.0L, long double, "%Lf");
+ LOADxxx("lpxbr", -12.0L, long double, "%Lf");
+ LOADxxx("lpxbr", NAN, long double, "%Lf");
+ LOADxxx("lpxbr", -NAN, long double, "%Lf");
+ LOADxxx("lpxbr", INFINITY, long double, "%Lf");
+ LOADxxx("lpxbr", -INFINITY, long double, "%Lf");
+
+ putchar('\n');
+ printf("LOAD COMPLEMENT short BFP\n");
+ LOADxxx("lcebr", 0.0f, float, "%f");
+ LOADxxx("lcebr", -0.0f, float, "%f");
+ LOADxxx("lcebr", 123.0f, float, "%f");
+ LOADxxx("lcebr", -12.0f, float, "%f");
+ LOADxxx("lcebr", NAN, float, "%f");
+ LOADxxx("lcebr", -NAN, float, "%f");
+ LOADxxx("lcebr", INFINITY, float, "%f");
+ LOADxxx("lcebr", -INFINITY, float, "%f");
+
+ printf("LOAD COMPLEMENT long BFP\n");
+ LOADxxx("lcdbr", 0.0, double, "%f");
+ LOADxxx("lcdbr", -0.0, double, "%f");
+ LOADxxx("lcdbr", 123.0, double, "%f");
+ LOADxxx("lcdbr", -12.0, double, "%f");
+ LOADxxx("lcdbr", NAN, double, "%f");
+ LOADxxx("lcdbr", -NAN, double, "%f");
+ LOADxxx("lcdbr", INFINITY, double, "%f");
+ LOADxxx("lcdbr", -INFINITY, double, "%f");
+
+ printf("LOAD COMPLEMENT extended BFP\n");
+ LOADxxx("lcxbr", 0.0L, long double, "%Lf");
+ LOADxxx("lcxbr", -0.0L, long double, "%Lf");
+ LOADxxx("lcxbr", 123.0L, long double, "%Lf");
+ LOADxxx("lcxbr", -12.0L, long double, "%Lf");
+ LOADxxx("lcxbr", NAN, long double, "%Lf");
+ LOADxxx("lcxbr", -NAN, long double, "%Lf");
+ LOADxxx("lcxbr", INFINITY, long double, "%Lf");
+ LOADxxx("lcxbr", -INFINITY, long double, "%Lf");
+
+ putchar('\n');
+ printf("LOAD ZERO\n");
+ lzxr();
+
+ return 0;
+}
--- /dev/null
+LOAD AND TEST short BFP
+ltebr 100.000000 -> 100.000000 cc = 2
+ltebr -10.500000 -> -10.500000 cc = 1
+ltebr 0.000000 -> 0.000000 cc = 0
+ltebr nan -> nan cc = 3
+ltebr -nan -> -nan cc = 3
+ltebr inf -> inf cc = 2
+ltebr -inf -> -inf cc = 1
+LOAD AND TEST long BFP
+ltdbr 100.000000 -> 100.000000 cc = 2
+ltdbr -10.500000 -> -10.500000 cc = 1
+ltdbr 0.000000 -> 0.000000 cc = 0
+ltdbr nan -> nan cc = 3
+ltdbr inf -> inf cc = 2
+ltdbr -inf -> -inf cc = 1
+LOAD AND TEST extended BFP
+ltxbr 100.000000 -> 100.000000 cc = 2
+ltxbr -10.500000 -> -10.500000 cc = 1
+ltxbr 0.000000 -> 0.000000 cc = 0
+ltxbr nan -> nan cc = 3
+ltxbr inf -> inf cc = 2
+ltxbr -inf -> -inf cc = 1
+
+LOAD NEGATIVE short BFP
+lnebr 0.000000 -> -0.000000 cc = 0
+lnebr -0.000000 -> -0.000000 cc = 0
+lnebr 123.000000 -> -123.000000 cc = 1
+lnebr -12.000000 -> -12.000000 cc = 1
+lnebr nan -> -nan cc = 3
+lnebr -nan -> -nan cc = 3
+lnebr inf -> -inf cc = 1
+lnebr -inf -> -inf cc = 1
+LOAD NEGATIVE long BFP
+lndbr 0.000000 -> -0.000000 cc = 0
+lndbr -0.000000 -> -0.000000 cc = 0
+lndbr 123.000000 -> -123.000000 cc = 1
+lndbr -12.000000 -> -12.000000 cc = 1
+lndbr nan -> -nan cc = 3
+lndbr -nan -> -nan cc = 3
+lndbr inf -> -inf cc = 1
+lndbr -inf -> -inf cc = 1
+LOAD NEGATIVE extended BFP
+lnxbr 0.000000 -> -0.000000 cc = 0
+lnxbr -0.000000 -> -0.000000 cc = 0
+lnxbr 123.000000 -> -123.000000 cc = 1
+lnxbr -12.000000 -> -12.000000 cc = 1
+lnxbr nan -> -nan cc = 3
+lnxbr -nan -> -nan cc = 3
+lnxbr inf -> -inf cc = 1
+lnxbr -inf -> -inf cc = 1
+
+LOAD POSITIVE short BFP
+lpebr 0.000000 -> 0.000000 cc = 0
+lpebr -0.000000 -> 0.000000 cc = 0
+lpebr 123.000000 -> 123.000000 cc = 2
+lpebr -12.000000 -> 12.000000 cc = 2
+lpebr nan -> nan cc = 3
+lpebr -nan -> nan cc = 3
+lpebr inf -> inf cc = 2
+lpebr -inf -> inf cc = 2
+LOAD POSITIVE long BFP
+lpdbr 0.000000 -> 0.000000 cc = 0
+lpdbr -0.000000 -> 0.000000 cc = 0
+lpdbr 123.000000 -> 123.000000 cc = 2
+lpdbr -12.000000 -> 12.000000 cc = 2
+lpdbr nan -> nan cc = 3
+lpdbr -nan -> nan cc = 3
+lpdbr inf -> inf cc = 2
+lpdbr -inf -> inf cc = 2
+LOAD POSITIVE extended BFP
+lpxbr 0.000000 -> 0.000000 cc = 0
+lpxbr -0.000000 -> 0.000000 cc = 0
+lpxbr 123.000000 -> 123.000000 cc = 2
+lpxbr -12.000000 -> 12.000000 cc = 2
+lpxbr nan -> nan cc = 3
+lpxbr -nan -> nan cc = 3
+lpxbr inf -> inf cc = 2
+lpxbr -inf -> inf cc = 2
+
+LOAD COMPLEMENT short BFP
+lcebr 0.000000 -> -0.000000 cc = 0
+lcebr -0.000000 -> 0.000000 cc = 0
+lcebr 123.000000 -> -123.000000 cc = 1
+lcebr -12.000000 -> 12.000000 cc = 2
+lcebr nan -> -nan cc = 3
+lcebr -nan -> nan cc = 3
+lcebr inf -> -inf cc = 1
+lcebr -inf -> inf cc = 2
+LOAD COMPLEMENT long BFP
+lcdbr 0.000000 -> -0.000000 cc = 0
+lcdbr -0.000000 -> 0.000000 cc = 0
+lcdbr 123.000000 -> -123.000000 cc = 1
+lcdbr -12.000000 -> 12.000000 cc = 2
+lcdbr nan -> -nan cc = 3
+lcdbr -nan -> nan cc = 3
+lcdbr inf -> -inf cc = 1
+lcdbr -inf -> inf cc = 2
+LOAD COMPLEMENT extended BFP
+lcxbr 0.000000 -> -0.000000 cc = 0
+lcxbr -0.000000 -> 0.000000 cc = 0
+lcxbr 123.000000 -> -123.000000 cc = 1
+lcxbr -12.000000 -> 12.000000 cc = 2
+lcxbr nan -> -nan cc = 3
+lcxbr -nan -> nan cc = 3
+lcxbr inf -> -inf cc = 1
+lcxbr -inf -> inf cc = 2
+
+LOAD ZERO
+lzxr --> 00000000 00000000 00000000 00000000