From d73a8e6e25db7546d122a446b60a753b44f4c5dd Mon Sep 17 00:00:00 2001 From: Andreas Arnez Date: Thu, 7 Sep 2023 16:43:25 +0200 Subject: [PATCH] s390x regtest: Rework dfptest The dfptest test case uses `_Decimal*' types, which is currently not supported by Clang. Rework the test to avoid this. --- none/tests/s390x/dfptest.c | 159 +++++++++++++------------------------ 1 file changed, 54 insertions(+), 105 deletions(-) diff --git a/none/tests/s390x/dfptest.c b/none/tests/s390x/dfptest.c index f1b383a7b8..c49fa39b3d 100644 --- a/none/tests/s390x/dfptest.c +++ b/none/tests/s390x/dfptest.c @@ -1,10 +1,6 @@ -#include +#include "dfp_utils.h" #include -/* Following macros adopted from dfp/math.h from libdfp */ -#define DEC_INFINITY __builtin_infd64() -#define DEC_NAN (0.0DF * DEC_INFINITY) - /* Following instructions are tested: test data class tests for _Decimal32 - TDCET @@ -16,110 +12,63 @@ test data group tests for _decimal128 - TDGXT */ -#define TEST_128(opcode, d, n) \ - ({ \ - int match; \ - _Decimal128 f = d; \ - long long num = n; \ - asm volatile(opcode ", %1,0(%2)\n" \ - "ipm %0\n" \ - "srl %0,28\n" \ - : "=d" (match) : "f" (f), "a" (num) : "cc"); \ - match; \ - }) +static const pun_d32 d32_vals[] = { + {0x22400000}, /* +0.0DF */ + {0xa2400000}, /* -0.0DF */ + {0x22400022}, /* +2.2DF */ + {0xa2400022}, /* -2.2DF */ + {0x78000000}, /* DEC_INFINITY */ + {0xf8000000}, /* -DEC_INFINITY */ + {0x7c000000}, /* +DEC_NAN */ + {0xfc000000}, /* -DEC_NAN */ +}; + +static const pun_d64 d64_vals[] = { + {0x2234000000000000}, {0xa234000000000000}, {0x2234000000000022}, + {0xa234000000000022}, {0x7800000000000000}, {0xf800000000000000}, + {0x7c00000000000000}, {0xfc00000000000000}, +}; -#define TEST_64(opcode, d, n) \ - ({ \ - int match; \ - _Decimal64 f = d; \ - long long num = n; \ - asm volatile(opcode ", %1,0(%2)\n" \ - "ipm %0\n" \ - "srl %0,28\n" \ - : "=d" (match) : "f" (f), "a" (num) : "cc"); \ - match; \ - }) +static const pun_d128 d128_vals[] = { + {{0x2207c00000000000, 0x0000000000000000}}, + {{0xa207c00000000000, 0x0000000000000000}}, + {{0x2207c00000000000, 0x0000000000000022}}, + {{0xa207c00000000000, 0x0000000000000022}}, + {{0x7800000000000000, 0x0000000000000000}}, + {{0xf800000000000000, 0x0000000000000000}}, + {{0x7c00000000000000, 0x0000000000000000}}, + {{0xfc00000000000000, 0x0000000000000000}}, +}; -#define TEST_32(opcode, d, n) \ - ({ \ - int match; \ - _Decimal32 f = d; \ - long long num = n; \ - asm volatile(opcode ", %1,0(%2)\n" \ - "ipm %0\n" \ - "srl %0,28\n" \ - : "=d" (match) : "f" (f), "a" (num) : "cc"); \ - match; \ - }) +#define TEST(opcode, ty, n) \ + ({ \ + const long num = n; \ + for (unsigned j = 0; j != sizeof(ty##_vals) / sizeof(ty##_vals[0]); \ + j++) { \ + int cc; \ + asm(".insn rxe, " opcode ", %[dec],0(%[bits])\n\t" \ + "ipm %[cc]\n" \ + "srl %[cc],28" \ + : [cc] "=d"(cc) \ + : [dec] "f"(ty##_vals[j].f), [bits] "a"(num) \ + : "cc"); \ + printf("%d", cc); \ + } \ + }) int main() { - int i; - - /* The right most 12 bits 52:63 of the second operand are set and tested */ - for (i = 0; i < 12; i++) { - /* DFP 128 bit - TDCXT */ - printf("%d", TEST_128(".insn rxe, 0xed0000000058", +0.0DF, 1UL<