7 /* Test "convert from fixed" with universally available rounding modes.
8 Rounding mode is provided via FPC. */
14 rtext(unsigned fpc_round
)
17 case 0: return "[-> near]";
18 case 1: return "[-> zero]";
19 case 2: return "[-> +inf]";
20 case 3: return "[-> -inf]";
26 set_rounding_mode(unsigned mode
)
28 printf("setting FPC rounding mode to %s\n", rtext(mode
));
29 register unsigned r
asm("1") = mode
;
30 __asm__
volatile ( SFPC(1) : : "d"(r
) );
33 void cefbr(unsigned mode
)
35 set_rounding_mode(mode
);
39 __asm__
volatile("cefbr %[r1],%[r2]" : [r1
] "=f"(out
) : [r2
] "d"(i32
));
40 printf("cefbr: %"PRId32
" -> %f\n", i32
, out
);
43 void cegbr(unsigned mode
)
45 set_rounding_mode(mode
);
49 __asm__
volatile("cegbr %[r1],%[r2]" : [r1
] "=f"(out
) : [r2
] "d"(i64
));
50 printf("cegbr: %"PRId64
" -> %f\n", i64
, out
);
53 void cdgbr(unsigned mode
)
55 set_rounding_mode(mode
);
59 __asm__
volatile("cdgbr %[r1],%[r2]" : [r1
] "=f"(out
) : [r2
] "d"(i64
));
60 printf("cegbr: %"PRId64
" -> %f\n", i64
, out
);
70 for (mode
= 0; mode
<= 3; ++mode
) cefbr(mode
);
73 for (mode
= 0; mode
<= 3; ++mode
) cefbr(mode
);
78 for (mode
= 0; mode
<= 3; ++mode
) cegbr(mode
);
81 for (mode
= 0; mode
<= 3; ++mode
) cegbr(mode
);
86 for (mode
= 0; mode
<= 3; ++mode
) cdgbr(mode
);
89 for (mode
= 0; mode
<= 3; ++mode
) cdgbr(mode
);