4 #define DO_PRINT_I2D(insn, l, type, round) \
8 printf(#insn " round=%d %d -> ", round, source); \
9 asm(".insn rrf," insn() "0000,%[r1],%[r2],%[m],0" \
11 : [r2] "d"(source), [m] "i"(round)); \
12 DFP_VAL_PRINT(d, type); \
16 #define DO_INSN_I2D(insn, round, type) \
18 DO_PRINT_I2D(insn, 0, type, round); \
19 DO_PRINT_I2D(insn, 1, type, round); \
20 DO_PRINT_I2D(insn, -1, type, round); \
21 DO_PRINT_I2D(insn, -2147483648, type, round); \
22 DO_PRINT_I2D(insn, 0x7fffffff, type, round); \
25 #define DO_PRINT_L2D(insn, l, type, round) \
27 unsigned long source = l; \
29 printf(#insn " round=%d %lu -> ", round, source); \
30 asm(".insn rrf," insn() "0000,%[r1],%[r2],%[m],0" \
32 : [r2] "d"(source), [m] "i"(round)); \
33 DFP_VAL_PRINT(d, type); \
37 #define DO_INSN_L2D(insn, round, type) \
39 DO_PRINT_L2D(insn, 0UL, type, round); \
40 DO_PRINT_L2D(insn, 1UL, type, round); \
41 DO_PRINT_L2D(insn, 0xffffffffUL, type, round); \
42 DO_PRINT_L2D(insn, 0x80000000UL, type, round); \
43 DO_PRINT_L2D(insn, 0x7fffffffUL, type, round); \
44 DO_PRINT_L2D(insn, 0x100000000UL, type, round); \
45 DO_PRINT_L2D(insn, 0xffffffffffffffffUL, type, round); \
46 DO_PRINT_L2D(insn, 0x8000000000000000UL, type, round); \
47 DO_PRINT_L2D(insn, 0x7fffffffffffffffUL, type, round); \
50 #define DO_PRINT_D2I(insn, d, type, round, ity, fmt) \
54 printf(#insn " round=%d ", round); \
55 DFP_VAL_PRINT(d, type); \
56 asm(".insn rrf," insn() "0000,%[r1],%[r2],%[m],0\n\t" \
59 : [r1] "+d"(target), [c] "=d"(cc) \
60 : [r2] "f"(d.f), [m] "i"(round) \
62 printf(" -> " fmt " cc=%d\n", target, cc); \
65 static const pun_d64 d64_vals
[] = {
66 {0xa234000000000011}, /* -1.DD */
67 {0x2238000000000000}, /* 0.DD */
68 {0x2238000000000001}, /* 1.DD */
69 {0x2234000000000014}, /* 1.4DD */
70 {0x2234000000000015}, /* 1.5DD */
71 {0x2234000000000016}, /* 1.6DD */
72 {0x2244000000000016}, /* 1.6E+4DD */
73 {0x2254000000000016}, /* 1.6E+8DD */
74 {0x2264000000000016}, /* 1.6E+12DD */
75 {0x2284000000000016}, /* 1.6E+20DD */
76 {0x4154000000000016}, /* 1.6E+200DD */
77 {0x2224000000000016}, /* 1.6E-4DD */
78 {0x20bc000000000001}, /* DEC32_MIN */
79 {0x23a000000093fcff}, /* DEC32_MAX */
80 {0x003c000000000001}, /* DEC64_MIN */
81 {0x77fcff3fcff3fcff}, /* DEC64_MAX */
84 static const pun_d128 d128_vals
[] = {
85 {{0xa207c00000000000, 0x0000000000000011}},
86 {{0x2208000000000000, 0x0000000000000000}},
87 {{0x2208000000000000, 0x0000000000000001}},
88 {{0x2207c00000000000, 0x0000000000000014}},
89 {{0x2207c00000000000, 0x0000000000000015}},
90 {{0x2207c00000000000, 0x0000000000000016}},
91 {{0x2208c00000000000, 0x0000000000000016}},
92 {{0x2209c00000000000, 0x0000000000000016}},
93 {{0x220ac00000000000, 0x0000000000000016}},
94 {{0x220cc00000000000, 0x0000000000000016}},
95 {{0x2239c00000000000, 0x0000000000000016}},
96 {{0x2206c00000000000, 0x0000000000000016}},
97 {{0x21f0400000000000, 0x0000000000000001}},
98 {{0x221e800000000000, 0x000000000093fcff}},
99 {{0x21a8400000000000, 0x0000000000000001}},
100 {{0x2264400000000000, 0x0024ff3fcff3fcff}},
103 #define DO_INSN_D2I(insn, round, t, ity, fmt) \
105 for (unsigned j = 0; j < sizeof(t##_vals) / sizeof(t##_vals[0]); j++) { \
106 DO_PRINT_D2I(insn, t##_vals[j], pun_##t, round, ity, fmt); \
110 #define CLFDTR() "0xb943"
111 #define CLGDTR() "0xb942"
112 #define CLFXTR() "0xb94b"
113 #define CLGXTR() "0xb94a"
114 #define CFDTR() "0xb941"
115 #define CFXTR() "0xb949"
117 #define CDFTR() "0xb951"
118 #define CXFTR() "0xb959"
119 #define CDLFTR() "0xb953"
120 #define CXLFTR() "0xb95b"
121 #define CDLGTR() "0xb952"
122 #define CXLGTR() "0xb95a"
124 #define DO_D2L(round) \
126 DO_INSN_D2I(CLFDTR, round, d64, unsigned, "%u"); \
127 DO_INSN_D2I(CLGDTR, round, d64, unsigned long, "%lu"); \
128 DO_INSN_D2I(CFDTR, round, d64, int, "%d"); \
129 DO_INSN_D2I(CLFXTR, round, d128, unsigned, "%u"); \
130 DO_INSN_D2I(CLGXTR, round, d128, unsigned long, "%lu"); \
131 DO_INSN_D2I(CFXTR, round, d128, int, "%d"); \
136 /* rounding mode is not used for the following insns */
137 DO_INSN_I2D(CDFTR
, 0, pun_d64
);
138 DO_INSN_I2D(CXFTR
, 0, pun_d128
);
139 DO_INSN_L2D(CDLFTR
, 0, pun_d64
);
140 DO_INSN_L2D(CXLFTR
, 0, pun_d128
);
141 DO_INSN_L2D(CXLGTR
, 0, pun_d128
);
143 /* Omit rounding mode value 0 and 2 as the current DFP rounding
144 mode is chosen for these values. */
145 DO_INSN_L2D(CDLGTR
, 1, pun_d64
);
148 DO_INSN_L2D(CDLGTR
, 3, pun_d64
);
151 DO_INSN_L2D(CDLGTR
, 4, pun_d64
);
154 DO_INSN_L2D(CDLGTR
, 5, pun_d64
);
157 DO_INSN_L2D(CDLGTR
, 6, pun_d64
);
160 DO_INSN_L2D(CDLGTR
, 7, pun_d64
);
163 DO_INSN_L2D(CDLGTR
, 8, pun_d64
);
166 DO_INSN_L2D(CDLGTR
, 9, pun_d64
);
169 DO_INSN_L2D(CDLGTR
, 10, pun_d64
);
172 DO_INSN_L2D(CDLGTR
, 11, pun_d64
);
175 DO_INSN_L2D(CDLGTR
, 12, pun_d64
);
178 DO_INSN_L2D(CDLGTR
, 13, pun_d64
);
181 DO_INSN_L2D(CDLGTR
, 14, pun_d64
);
184 DO_INSN_L2D(CDLGTR
, 15, pun_d64
);