qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 05/10] target/tricore: Implement ftohp insn


From: Richard Henderson
Subject: Re: [PATCH 05/10] target/tricore: Implement ftohp insn
Date: Sat, 26 Aug 2023 21:55:05 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0

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.

+    set_float_detect_tininess(true, &env->fp_status);

s/true/float_tininess_before_rounding/


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]