@@ -2558,6 +2558,27 @@ soft_f64_div(float64 a, float64 b, float_status *status)
return float64_round_pack_canonical(pr, status);
}
+static float64 QEMU_SOFTFLOAT_ATTR
+soft_f64_div_excp_en(float64 a, float64 b, int oe_sub, int ue_sum,
+ float_status *status)
+{
+ FloatParts64 pa, pb, *pr;
+
+ float64_unpack_canonical(&pa, a, status);
+ float64_unpack_canonical(&pb, b, status);
+ pr = parts_div(&pa, &pb, status);
+
+ if (unlikely(oe_sub && (pr->exp > 1023))) {
+ pr->exp -= oe_sub;
+ float_raise(float_flag_overflow, status);
+ } else if (unlikely(ue_sum && (pr->exp < -1022))) {
+ pr->exp += ue_sum;
+ float_raise(float_flag_underflow, status);
+ }
+
+ return float64_round_pack_canonical(pr, status);
+}
+
static float hard_f32_div(float a, float b)
{
return a / b;
@@ -2616,6 +2637,15 @@ float64_div(float64 a, float64 b, float_status *s)
f64_div_pre, f64_div_post);
}
+float64 QEMU_FLATTEN
+float64_div_excp_en(float64 a, float64 b, int oe_sub, int ue_sum,
+ float_status *s)
+{
+ return float64_gen2_excp(a, b, oe_sub, ue_sum, s, hard_f64_div,
+ soft_f64_div, soft_f64_div_excp_en, f64_div_pre,
+ f64_div_post);
+}
+
float64 float64r32_div(float64 a, float64 b, float_status *status)
{
FloatParts64 pa, pb, *pr;
@@ -778,6 +778,7 @@ float64 float64_sub_excp_en(float64, float64, int, int, float_status *status);
float64 float64_mul(float64, float64, float_status *status);
float64 float64_mul_excp_en(float64, float64, int, int, float_status *status);
float64 float64_div(float64, float64, float_status *status);
+float64 float64_div_excp_en(float64, float64, int, int, float_status *status);
float64 float64_rem(float64, float64, float_status *status);
float64 float64_muladd(float64, float64, float64, int, float_status *status);
float64 float64_sqrt(float64, float_status *status);
@@ -635,7 +635,10 @@ static void float_invalid_op_div(CPUPPCState *env, int flags,
/* fdiv - fdiv. */
float64 helper_fdiv(CPUPPCState *env, float64 arg1, float64 arg2)
{
- float64 ret = float64_div(arg1, arg2, &env->fp_status);
+ int oe_sub = (FP_OE & env->fpscr) ? 1536 : 0;
+ int ue_sum = (FP_UE & env->fpscr) ? 1536 : 0;
+ float64 ret = float64_div_excp_en(arg1, arg2, oe_sub, ue_sum,
+ &env->fp_status);
int flags = get_float_exception_flags(&env->fp_status);
if (unlikely(flags & float_flag_invalid)) {