FreeBSD: add file descriptor tracking for _umtx_op
[valgrind.git] / none / tests / s390x / dfp-3.c
blobdfc805f0e786a85eb358cf25b2443e7846785fd7
1 #include "dfp_utils.h"
2 #include <stdio.h>
4 /* Test DFP value and exponent comparison for 64/128-bit. */
6 #define COMPARE(opc, v1, v2, type) \
7 { \
8 int cc; \
9 asm(".insn rre," opc "0000,%[r1],%[r2]\n\t" \
10 "ipm %[cc]\n\t" \
11 "srl %[cc],28\n\t" \
12 : [cc] "=d"(cc) \
13 : [r1] "f"(v1.f), [r2] "f"(v2.f) \
14 : "cc"); \
15 DFP_VAL_PRINT(v1, type); \
16 switch (cc) { \
17 case 0: \
18 printf(" == "); \
19 break; \
20 case 1: \
21 printf(" < "); \
22 break; \
23 case 2: \
24 printf(" > "); \
25 break; \
26 case 3: \
27 printf(" <> "); \
28 break; \
29 } \
30 DFP_VAL_PRINT(v2, type); \
31 printf(" (cc == %d)\n", cc); \
34 /* 64-bit decimal constants */
35 static const pun_d64 dd_inf = {0x7800000000000000}; /* infinity */
36 static const pun_d64 dd_nan = {0x7c00000000000000}; /* NaN */
37 static const pun_d64 dd_A = {0x2220000000500005}; /* 5.000005DD */
38 static const pun_d64 dd_B = {0x363c000000000000}; /* 5.E16DD + 5.E-6DD */
40 /* 128-bit decimal constants */
41 static const pun_d128 dl_inf = {{0x7800000000000000, 0x0000000000000000}};
42 static const pun_d128 dl_nan = {{0x7c00000000000000, 0x0000000000000000}};
43 static const pun_d128 dl_A = {{0x2206c00000000000, 0x00000000000a0005}};
44 static const pun_d128 dl_B = {{0x2207c00000000000, 0x0140000000000005}};
46 #define CDTR "0xb3e4"
47 #define CXTR "0xb3ec"
48 #define CEDTR "0xb3f4"
49 #define CEXTR "0xb3fc"
51 int main(void)
53 /* compare 8 bytes DFP value */
54 printf("cdtr:\n");
55 COMPARE(CDTR, dd_A, dd_A, pun_d64);
56 COMPARE(CDTR, dd_A, dd_B, pun_d64);
57 COMPARE(CDTR, dd_B, dd_A, pun_d64);
58 COMPARE(CDTR, dd_inf, dd_nan, pun_d64);
59 COMPARE(CDTR, dd_inf, dd_inf, pun_d64);
60 COMPARE(CDTR, dd_nan, dd_nan, pun_d64);
62 /* compare 16 bytes DFP value */
63 printf("cxtr:\n");
64 COMPARE(CXTR, dl_A, dl_A, pun_d128);
65 COMPARE(CXTR, dl_A, dl_B, pun_d128);
66 COMPARE(CXTR, dl_B, dl_A, pun_d128);
67 COMPARE(CXTR, dl_inf, dl_nan, pun_d128);
68 COMPARE(CXTR, dl_inf, dl_inf, pun_d128);
69 COMPARE(CXTR, dl_nan, dl_nan, pun_d128);
71 /* compare exponents of 8 bytes DFP value */
72 printf("cedtr:\n");
73 COMPARE(CEDTR, dd_A, dd_A, pun_d64);
74 COMPARE(CEDTR, dd_A, dd_B, pun_d64);
75 COMPARE(CEDTR, dd_B, dd_A, pun_d64);
76 COMPARE(CEDTR, dd_inf, dd_nan, pun_d64);
77 COMPARE(CEDTR, dd_inf, dd_inf, pun_d64);
78 COMPARE(CEDTR, dd_nan, dd_nan, pun_d64);
80 /* compare exponents of 16 bytes DFP value */
81 printf("cextr:\n");
82 COMPARE(CEXTR, dl_A, dl_A, pun_d128);
83 COMPARE(CEXTR, dl_A, dl_B, pun_d128);
84 COMPARE(CEXTR, dl_B, dl_A, pun_d128);
85 COMPARE(CEXTR, dl_inf, dl_nan, pun_d128);
86 COMPARE(CEXTR, dl_inf, dl_inf, pun_d128);
87 COMPARE(CEXTR, dl_nan, dl_nan, pun_d128);
89 return 0;