On 8/27/23 00:09, Bastian Koppelmann wrote:
On Sat, Aug 26, 2023 at 09:55:05PM -0700, Richard Henderson wrote:
On 8/26/23 09:02, Bastian Koppelmann wrote:
+uint32_t helper_ftohp(CPUTriCoreState *env, uint32_t arg)
+{
+ float32 f_arg = make_float32(arg);
+ uint32_t result = 0;
+ int32_t flags = 0;
+
+ if (float32_is_infinity(f_arg)) {
+ if (float32_is_neg(f_arg)) {
+ return HP_NEG_INFINITY;
+ } else {
+ return HP_POS_INFINITY;
+ }
+ } else if (float32_is_any_nan(f_arg)) {
+ if (float32_is_signaling_nan(f_arg, &env->fp_status)) {
+ flags |= float_flag_invalid;
+ }
+ result = float16_set_sign(result, arg >> 31);
+ result = deposit32(result, 10, 5, 0x1f);
+ result = deposit32(result, 8, 2, extract32(arg, 21, 2));
+ result = deposit32(result, 0, 8, extract32(arg, 0, 8));
+ if (extract32(result, 0, 10) == 0) {
+ result |= (1 << 8);
+ }
+ } else {
+ set_flush_to_zero(0, &env->fp_status);
+ result = float32_to_float16(f_arg, true, &env->fp_status);
+ set_flush_to_zero(1, &env->fp_status);
+ flags = f_get_excp_flags(env);
+ }
All of this is standard behaviour. All you need is the final else case.
Unfortunately not quite. For NANs the top 2 and lower 8 output mantissa bits
need to be
set to the top 2 and lower 8 input mantissa bits respectively. This behaviour is
unique to ftohp and hptof, so I don't think we should specialize it in
parts64_default_nan().
Ah, whereas softfloat grabs the top 10 mantissa bits.
This could use a comment to that effect.
Certainly you don't need to special case infinity though.
r~