4 #define DO_PRINT_I2D(insn, l, type, round) \
8 printf(#insn " round=%d %ld -> ", 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, 0xffffffff, type, round); \
21 DO_PRINT_I2D(insn, 0x80000000, type, round); \
22 DO_PRINT_I2D(insn, 0x7fffffff, type, round); \
25 #define DO_PRINT_D2I(insn, d, type, round) \
29 printf(#insn " round=%d ", round); \
30 DFP_VAL_PRINT(d, type); \
31 asm(".insn rrf," insn() "0000,%[r1],%[r2],%[m],0\n\t" \
34 : [r1] "+d"(target), [c] "=d"(cc) \
35 : [r2] "f"(d.f), [m] "i"(round) \
37 printf(" -> %ld cc=%d\n", target, cc); \
40 static const pun_d64 d64_vals
[] = {
41 {0xa234000000000011}, /* -1.1DD */
42 {0x2238000000000000}, /* 0.DD */
43 {0x2238000000000001}, /* 1.DD */
44 {0x2234000000000014}, /* 1.4DD */
45 {0x2234000000000015}, /* 1.5DD */
46 {0x2234000000000016}, /* 1.6DD */
47 {0x2244000000000016}, /* 1.6E+4DD */
48 {0x2254000000000016}, /* 1.6E+8DD */
49 {0x2264000000000016}, /* 1.6E+12DD */
50 {0x2284000000000016}, /* 1.6E+20DD */
51 {0x4154000000000016}, /* 1.6E+200DD */
52 {0x2224000000000016}, /* 1.6E-4DD */
53 {0x20bc000000000001}, /* DEC32_MIN */
54 {0x23a000000093fcff}, /* DEC32_MAX */
55 {0x003c000000000001}, /* DEC64_MIN */
56 {0x77fcff3fcff3fcff}, /* DEC64_MAX */
59 static const pun_d128 d128_vals
[] = {
60 {{0xa207c00000000000, 0x0000000000000011}},
61 {{0x2208000000000000, 0x0000000000000000}},
62 {{0x2208000000000000, 0x0000000000000001}},
63 {{0x2207c00000000000, 0x0000000000000014}},
64 {{0x2207c00000000000, 0x0000000000000015}},
65 {{0x2207c00000000000, 0x0000000000000016}},
66 {{0x2208c00000000000, 0x0000000000000016}},
67 {{0x2209c00000000000, 0x0000000000000016}},
68 {{0x220ac00000000000, 0x0000000000000016}},
69 {{0x220cc00000000000, 0x0000000000000016}},
70 {{0x2239c00000000000, 0x0000000000000016}},
71 {{0x2206c00000000000, 0x0000000000000016}},
72 {{0x21f0400000000000, 0x0000000000000001}},
73 {{0x221e800000000000, 0x000000000093fcff}},
74 {{0x21a8400000000000, 0x0000000000000001}},
75 {{0x2264400000000000, 0x0024ff3fcff3fcff}},
78 #define DO_INSN_D2I(insn, round, t) \
80 for (unsigned j = 0; j < sizeof(t##_vals) / sizeof(t##_vals[0]); j++) { \
81 DO_PRINT_D2I(insn, t##_vals[j], pun_##t, round); \
85 #define DO_D2I(round) \
87 DO_INSN_D2I(CGDTRA, round, d64); \
88 DO_INSN_D2I(CGXTRA, round, d128); \
91 #define CGDTRA() "0xb3e1"
92 #define CGXTRA() "0xb3e9"
93 #define CDGTRA() "0xb3f1"
94 #define CXGTRA() "0xb3f9"
98 /* rounding mode is not used for the I64 -> D128 conversion */
99 DO_INSN_I2D(CXGTRA
, 0, pun_d128
);
101 /* Omit rounding mode value 0 and 2 as the current DFP rounding
102 mode is chosen for these values. */
103 DO_INSN_I2D(CDGTRA
, 1, pun_d64
);
106 DO_INSN_I2D(CDGTRA
, 3, pun_d64
);
109 DO_INSN_I2D(CDGTRA
, 4, pun_d64
);
112 DO_INSN_I2D(CDGTRA
, 5, pun_d64
);
115 DO_INSN_I2D(CDGTRA
, 6, pun_d64
);
118 DO_INSN_I2D(CDGTRA
, 7, pun_d64
);
121 DO_INSN_I2D(CDGTRA
, 8, pun_d64
);
124 DO_INSN_I2D(CDGTRA
, 9, pun_d64
);
127 DO_INSN_I2D(CDGTRA
, 10, pun_d64
);
130 DO_INSN_I2D(CDGTRA
, 11, pun_d64
);
133 DO_INSN_I2D(CDGTRA
, 12, pun_d64
);
136 DO_INSN_I2D(CDGTRA
, 13, pun_d64
);
139 DO_INSN_I2D(CDGTRA
, 14, pun_d64
);
142 DO_INSN_I2D(CDGTRA
, 15, pun_d64
);