Example #1
0
uint32_t HELPER(ftoi)(float32 v, uint32_t rounding_mode, uint32_t scale)
{
    float_status fp_status = {0};

    set_float_rounding_mode(rounding_mode, &fp_status);
    return float32_to_int32(float32_scalbn(v, scale, &fp_status), &fp_status);
}
Example #2
0
unsigned int PerformFIX(const unsigned int opcode)
{
    FPA11 *fpa11 = GET_FPA11();
    unsigned int Fn = getFm(opcode);

    SetRoundingMode(opcode);

    switch (fpa11->fType[Fn]) {
    case typeSingle:
    {
        writeRegister(getRd(opcode), float32_to_int32(fpa11->fpreg[Fn].fSingle));
    }
    break;

    case typeDouble:
    {
        writeRegister(getRd(opcode), float64_to_int32(fpa11->fpreg[Fn].fDouble));
    }
    break;

#ifdef CONFIG_FPE_NWFPE_XP
    case typeExtended:
    {
        writeRegister(getRd(opcode), floatx80_to_int32(fpa11->fpreg[Fn].fExtended));
    }
    break;
#endif

    default:
        return 0;
    }

    return 1;
}
Example #3
0
/* convert 32-bit float to 32-bit int */
uint32_t HELPER(cfebr)(CPUS390XState *env, uint32_t r1, uint32_t f2,
                       uint32_t m3)
{
    float32 v2 = env->fregs[f2].l.upper;

    set_round_mode(env, m3);
    env->regs[r1] = (env->regs[r1] & 0xffffffff00000000ULL) |
        float32_to_int32(v2, &env->fpu_status);
    return set_cc_nz_f32(v2);
}
Example #4
0
uint32_t helper_fint(CPUMBState *env, uint32_t a)
{
    CPU_FloatU fa;
    uint32_t r;
    int flags;

    set_float_exception_flags(0, &env->fp_status);
    fa.l = a;
    r = float32_to_int32(fa.f, &env->fp_status);
    flags = get_float_exception_flags(&env->fp_status);
    update_fpu_flags(env, flags);

    return r;
}
Example #5
0
uint32_t HELPER(ftoui)(float32 v, uint32_t rounding_mode, uint32_t scale)
{
    float_status fp_status = {0};
    float32 res;

    set_float_rounding_mode(rounding_mode, &fp_status);

    res = float32_scalbn(v, scale, &fp_status);

    if (float32_is_neg(v) && !float32_is_any_nan(v)) {
        return float32_to_int32(res, &fp_status);
    } else {
        return float32_to_uint32(res, &fp_status);
    }
}
Example #6
0
unsigned int PerformFIX(const unsigned int opcode)
{
    FPA11 *fpa11 = GET_FPA11();
    unsigned int Fn = getFm(opcode);
    struct roundingData roundData;

    roundData.mode = SetRoundingMode(opcode);
    roundData.precision = SetRoundingPrecision(opcode);
    roundData.exception = 0;

    switch (fpa11->fType[Fn]) {
    case typeSingle:
        {
            writeRegister(getRd(opcode), float32_to_int32(&roundData, fpa11->fpreg[Fn].fSingle));
        }
        break;

    case typeDouble:
        {
            writeRegister(getRd(opcode), float64_to_int32(&roundData, fpa11->fpreg[Fn].fDouble));
        }
        break;

#ifdef CONFIG_FPE_NWFPE_XP
    case typeExtended:
        {
            writeRegister(getRd(opcode), floatx80_to_int32(&roundData, fpa11->fpreg[Fn].fExtended));
        }
        break;
#endif

    default:
        return 0;
    }

    if (roundData.exception)
        float_raise(roundData.exception);

    return 1;
}