mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-23 05:05:36 +00:00
softfloat: Name compare relation enum
Give the previously unnamed enum a typedef name. Use it in the prototypes of compare functions. Use it to hold the results of the compare functions. Backports commit 71bfd65c5fcd72f8af2735905415c7ce4220f6dc from qemu
This commit is contained in:
parent
8adc704058
commit
d960523cbd
|
@ -2810,8 +2810,8 @@ MINMAX(64, maxnummag, false, true, true)
|
||||||
#undef MINMAX
|
#undef MINMAX
|
||||||
|
|
||||||
/* Floating point compare */
|
/* Floating point compare */
|
||||||
static int compare_floats(FloatParts a, FloatParts b, bool is_quiet,
|
static FloatRelation compare_floats(FloatParts a, FloatParts b, bool is_quiet,
|
||||||
float_status *s)
|
float_status *s)
|
||||||
{
|
{
|
||||||
if (is_nan(a.cls) || is_nan(b.cls)) {
|
if (is_nan(a.cls) || is_nan(b.cls)) {
|
||||||
if (!is_quiet ||
|
if (!is_quiet ||
|
||||||
|
@ -2882,17 +2882,17 @@ COMPARE(soft_f64_compare, QEMU_SOFTFLOAT_ATTR, 64)
|
||||||
|
|
||||||
#undef COMPARE
|
#undef COMPARE
|
||||||
|
|
||||||
int float16_compare(float16 a, float16 b, float_status *s)
|
FloatRelation float16_compare(float16 a, float16 b, float_status *s)
|
||||||
{
|
{
|
||||||
return soft_f16_compare(a, b, false, s);
|
return soft_f16_compare(a, b, false, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
int float16_compare_quiet(float16 a, float16 b, float_status *s)
|
FloatRelation float16_compare_quiet(float16 a, float16 b, float_status *s)
|
||||||
{
|
{
|
||||||
return soft_f16_compare(a, b, true, s);
|
return soft_f16_compare(a, b, true, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int QEMU_FLATTEN
|
static FloatRelation QEMU_FLATTEN
|
||||||
f32_compare(float32 xa, float32 xb, bool is_quiet, float_status *s)
|
f32_compare(float32 xa, float32 xb, bool is_quiet, float_status *s)
|
||||||
{
|
{
|
||||||
union_float32 ua, ub;
|
union_float32 ua, ub;
|
||||||
|
@ -2921,17 +2921,17 @@ f32_compare(float32 xa, float32 xb, bool is_quiet, float_status *s)
|
||||||
return soft_f32_compare(ua.s, ub.s, is_quiet, s);
|
return soft_f32_compare(ua.s, ub.s, is_quiet, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
int float32_compare(float32 a, float32 b, float_status *s)
|
FloatRelation float32_compare(float32 a, float32 b, float_status *s)
|
||||||
{
|
{
|
||||||
return f32_compare(a, b, false, s);
|
return f32_compare(a, b, false, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
int float32_compare_quiet(float32 a, float32 b, float_status *s)
|
FloatRelation float32_compare_quiet(float32 a, float32 b, float_status *s)
|
||||||
{
|
{
|
||||||
return f32_compare(a, b, true, s);
|
return f32_compare(a, b, true, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int QEMU_FLATTEN
|
static FloatRelation QEMU_FLATTEN
|
||||||
f64_compare(float64 xa, float64 xb, bool is_quiet, float_status *s)
|
f64_compare(float64 xa, float64 xb, bool is_quiet, float_status *s)
|
||||||
{
|
{
|
||||||
union_float64 ua, ub;
|
union_float64 ua, ub;
|
||||||
|
@ -2960,12 +2960,12 @@ f64_compare(float64 xa, float64 xb, bool is_quiet, float_status *s)
|
||||||
return soft_f64_compare(ua.s, ub.s, is_quiet, s);
|
return soft_f64_compare(ua.s, ub.s, is_quiet, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
int float64_compare(float64 a, float64 b, float_status *s)
|
FloatRelation float64_compare(float64 a, float64 b, float_status *s)
|
||||||
{
|
{
|
||||||
return f64_compare(a, b, false, s);
|
return f64_compare(a, b, false, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
int float64_compare_quiet(float64 a, float64 b, float_status *s)
|
FloatRelation float64_compare_quiet(float64 a, float64 b, float_status *s)
|
||||||
{
|
{
|
||||||
return f64_compare(a, b, true, s);
|
return f64_compare(a, b, true, s);
|
||||||
}
|
}
|
||||||
|
@ -7854,8 +7854,9 @@ int float128_unordered_quiet(float128 a, float128 b, float_status *status)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int floatx80_compare_internal(floatx80 a, floatx80 b,
|
static inline FloatRelation
|
||||||
int is_quiet, float_status *status)
|
floatx80_compare_internal(floatx80 a, floatx80 b, bool is_quiet,
|
||||||
|
float_status *status)
|
||||||
{
|
{
|
||||||
bool aSign, bSign;
|
bool aSign, bSign;
|
||||||
|
|
||||||
|
@ -7901,18 +7902,19 @@ static inline int floatx80_compare_internal(floatx80 a, floatx80 b,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int floatx80_compare(floatx80 a, floatx80 b, float_status *status)
|
FloatRelation floatx80_compare(floatx80 a, floatx80 b, float_status *status)
|
||||||
{
|
{
|
||||||
return floatx80_compare_internal(a, b, 0, status);
|
return floatx80_compare_internal(a, b, 0, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
int floatx80_compare_quiet(floatx80 a, floatx80 b, float_status *status)
|
FloatRelation floatx80_compare_quiet(floatx80 a, floatx80 b, float_status *status)
|
||||||
{
|
{
|
||||||
return floatx80_compare_internal(a, b, 1, status);
|
return floatx80_compare_internal(a, b, 1, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int float128_compare_internal(float128 a, float128 b,
|
static inline FloatRelation
|
||||||
int is_quiet, float_status *status)
|
float128_compare_internal(float128 a, float128 b, bool is_quiet,
|
||||||
|
float_status *status)
|
||||||
{
|
{
|
||||||
bool aSign, bSign;
|
bool aSign, bSign;
|
||||||
|
|
||||||
|
@ -7945,12 +7947,13 @@ static inline int float128_compare_internal(float128 a, float128 b,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int float128_compare(float128 a, float128 b, float_status *status)
|
FloatRelation float128_compare(float128 a, float128 b, float_status *status)
|
||||||
{
|
{
|
||||||
return float128_compare_internal(a, b, 0, status);
|
return float128_compare_internal(a, b, 0, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
int float128_compare_quiet(float128 a, float128 b, float_status *status)
|
FloatRelation float128_compare_quiet(float128 a, float128 b,
|
||||||
|
float_status *status)
|
||||||
{
|
{
|
||||||
return float128_compare_internal(a, b, 1, status);
|
return float128_compare_internal(a, b, 1, status);
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,12 +89,12 @@ this code that are retained.
|
||||||
/*----------------------------------------------------------------------------
|
/*----------------------------------------------------------------------------
|
||||||
| Software IEC/IEEE floating-point ordering relations
|
| Software IEC/IEEE floating-point ordering relations
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
enum {
|
typedef enum {
|
||||||
float_relation_less = -1,
|
float_relation_less = -1,
|
||||||
float_relation_equal = 0,
|
float_relation_equal = 0,
|
||||||
float_relation_greater = 1,
|
float_relation_greater = 1,
|
||||||
float_relation_unordered = 2
|
float_relation_unordered = 2
|
||||||
};
|
} FloatRelation;
|
||||||
|
|
||||||
#include "fpu/softfloat-types.h"
|
#include "fpu/softfloat-types.h"
|
||||||
#include "fpu/softfloat-helpers.h"
|
#include "fpu/softfloat-helpers.h"
|
||||||
|
@ -235,8 +235,8 @@ float16 float16_maxnum(float16, float16, float_status *status);
|
||||||
float16 float16_minnummag(float16, float16, float_status *status);
|
float16 float16_minnummag(float16, float16, float_status *status);
|
||||||
float16 float16_maxnummag(float16, float16, float_status *status);
|
float16 float16_maxnummag(float16, float16, float_status *status);
|
||||||
float16 float16_sqrt(float16, float_status *status);
|
float16 float16_sqrt(float16, float_status *status);
|
||||||
int float16_compare(float16, float16, float_status *status);
|
FloatRelation float16_compare(float16, float16, float_status *status);
|
||||||
int float16_compare_quiet(float16, float16, float_status *status);
|
FloatRelation float16_compare_quiet(float16, float16, float_status *status);
|
||||||
|
|
||||||
int float16_is_quiet_nan(float16, float_status *status);
|
int float16_is_quiet_nan(float16, float_status *status);
|
||||||
int float16_is_signaling_nan(float16, float_status *status);
|
int float16_is_signaling_nan(float16, float_status *status);
|
||||||
|
@ -354,8 +354,8 @@ int float32_eq_quiet(float32, float32, float_status *status);
|
||||||
int float32_le_quiet(float32, float32, float_status *status);
|
int float32_le_quiet(float32, float32, float_status *status);
|
||||||
int float32_lt_quiet(float32, float32, float_status *status);
|
int float32_lt_quiet(float32, float32, float_status *status);
|
||||||
int float32_unordered_quiet(float32, float32, float_status *status);
|
int float32_unordered_quiet(float32, float32, float_status *status);
|
||||||
int float32_compare(float32, float32, float_status *status);
|
FloatRelation float32_compare(float32, float32, float_status *status);
|
||||||
int float32_compare_quiet(float32, float32, float_status *status);
|
FloatRelation float32_compare_quiet(float32, float32, float_status *status);
|
||||||
float32 float32_min(float32, float32, float_status *status);
|
float32 float32_min(float32, float32, float_status *status);
|
||||||
float32 float32_max(float32, float32, float_status *status);
|
float32 float32_max(float32, float32, float_status *status);
|
||||||
float32 float32_minnum(float32, float32, float_status *status);
|
float32 float32_minnum(float32, float32, float_status *status);
|
||||||
|
@ -510,8 +510,8 @@ int float64_eq_quiet(float64, float64, float_status *status);
|
||||||
int float64_le_quiet(float64, float64, float_status *status);
|
int float64_le_quiet(float64, float64, float_status *status);
|
||||||
int float64_lt_quiet(float64, float64, float_status *status);
|
int float64_lt_quiet(float64, float64, float_status *status);
|
||||||
int float64_unordered_quiet(float64, float64, float_status *status);
|
int float64_unordered_quiet(float64, float64, float_status *status);
|
||||||
int float64_compare(float64, float64, float_status *status);
|
FloatRelation float64_compare(float64, float64, float_status *status);
|
||||||
int float64_compare_quiet(float64, float64, float_status *status);
|
FloatRelation float64_compare_quiet(float64, float64, float_status *status);
|
||||||
float64 float64_min(float64, float64, float_status *status);
|
float64 float64_min(float64, float64, float_status *status);
|
||||||
float64 float64_max(float64, float64, float_status *status);
|
float64 float64_max(float64, float64, float_status *status);
|
||||||
float64 float64_minnum(float64, float64, float_status *status);
|
float64 float64_minnum(float64, float64, float_status *status);
|
||||||
|
@ -634,8 +634,8 @@ int floatx80_eq_quiet(floatx80, floatx80, float_status *status);
|
||||||
int floatx80_le_quiet(floatx80, floatx80, float_status *status);
|
int floatx80_le_quiet(floatx80, floatx80, float_status *status);
|
||||||
int floatx80_lt_quiet(floatx80, floatx80, float_status *status);
|
int floatx80_lt_quiet(floatx80, floatx80, float_status *status);
|
||||||
int floatx80_unordered_quiet(floatx80, floatx80, float_status *status);
|
int floatx80_unordered_quiet(floatx80, floatx80, float_status *status);
|
||||||
int floatx80_compare(floatx80, floatx80, float_status *status);
|
FloatRelation floatx80_compare(floatx80, floatx80, float_status *status);
|
||||||
int floatx80_compare_quiet(floatx80, floatx80, float_status *status);
|
FloatRelation floatx80_compare_quiet(floatx80, floatx80, float_status *status);
|
||||||
int floatx80_is_quiet_nan(floatx80, float_status *status);
|
int floatx80_is_quiet_nan(floatx80, float_status *status);
|
||||||
int floatx80_is_signaling_nan(floatx80, float_status *status);
|
int floatx80_is_signaling_nan(floatx80, float_status *status);
|
||||||
floatx80 floatx80_silence_nan(floatx80, float_status *status);
|
floatx80 floatx80_silence_nan(floatx80, float_status *status);
|
||||||
|
@ -846,8 +846,8 @@ int float128_eq_quiet(float128, float128, float_status *status);
|
||||||
int float128_le_quiet(float128, float128, float_status *status);
|
int float128_le_quiet(float128, float128, float_status *status);
|
||||||
int float128_lt_quiet(float128, float128, float_status *status);
|
int float128_lt_quiet(float128, float128, float_status *status);
|
||||||
int float128_unordered_quiet(float128, float128, float_status *status);
|
int float128_unordered_quiet(float128, float128, float_status *status);
|
||||||
int float128_compare(float128, float128, float_status *status);
|
FloatRelation float128_compare(float128, float128, float_status *status);
|
||||||
int float128_compare_quiet(float128, float128, float_status *status);
|
FloatRelation float128_compare_quiet(float128, float128, float_status *status);
|
||||||
int float128_is_quiet_nan(float128, float_status *status);
|
int float128_is_quiet_nan(float128, float_status *status);
|
||||||
int float128_is_signaling_nan(float128, float_status *status);
|
int float128_is_signaling_nan(float128, float_status *status);
|
||||||
float128 float128_silence_nan(float128, float_status *status);
|
float128 float128_silence_nan(float128, float_status *status);
|
||||||
|
|
|
@ -284,7 +284,7 @@ float64 VFP_HELPER(sqrt, d)(float64 a, CPUARMState *env)
|
||||||
return float64_sqrt(a, &env->vfp.fp_status);
|
return float64_sqrt(a, &env->vfp.fp_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void softfloat_to_vfp_compare(CPUARMState *env, int cmp)
|
static void softfloat_to_vfp_compare(CPUARMState *env, FloatRelation cmp)
|
||||||
{
|
{
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
switch (cmp) {
|
switch (cmp) {
|
||||||
|
|
|
@ -386,7 +386,7 @@ static const int fcom_ccval[4] = {0x0100, 0x4000, 0x0000, 0x4500};
|
||||||
|
|
||||||
void helper_fcom_ST0_FT0(CPUX86State *env)
|
void helper_fcom_ST0_FT0(CPUX86State *env)
|
||||||
{
|
{
|
||||||
int ret;
|
FloatRelation ret;
|
||||||
|
|
||||||
ret = floatx80_compare(ST0, FT0, &env->fp_status);
|
ret = floatx80_compare(ST0, FT0, &env->fp_status);
|
||||||
env->fpus = (env->fpus & ~0x4500) | fcom_ccval[ret + 1];
|
env->fpus = (env->fpus & ~0x4500) | fcom_ccval[ret + 1];
|
||||||
|
@ -394,7 +394,7 @@ void helper_fcom_ST0_FT0(CPUX86State *env)
|
||||||
|
|
||||||
void helper_fucom_ST0_FT0(CPUX86State *env)
|
void helper_fucom_ST0_FT0(CPUX86State *env)
|
||||||
{
|
{
|
||||||
int ret;
|
FloatRelation ret;
|
||||||
|
|
||||||
ret = floatx80_compare_quiet(ST0, FT0, &env->fp_status);
|
ret = floatx80_compare_quiet(ST0, FT0, &env->fp_status);
|
||||||
env->fpus = (env->fpus & ~0x4500) | fcom_ccval[ret + 1];
|
env->fpus = (env->fpus & ~0x4500) | fcom_ccval[ret + 1];
|
||||||
|
@ -405,7 +405,7 @@ static const int fcomi_ccval[4] = {CC_C, CC_Z, 0, CC_Z | CC_P | CC_C};
|
||||||
void helper_fcomi_ST0_FT0(CPUX86State *env)
|
void helper_fcomi_ST0_FT0(CPUX86State *env)
|
||||||
{
|
{
|
||||||
int eflags;
|
int eflags;
|
||||||
int ret;
|
FloatRelation ret;
|
||||||
|
|
||||||
ret = floatx80_compare(ST0, FT0, &env->fp_status);
|
ret = floatx80_compare(ST0, FT0, &env->fp_status);
|
||||||
eflags = cpu_cc_compute_all(env, CC_OP);
|
eflags = cpu_cc_compute_all(env, CC_OP);
|
||||||
|
@ -416,7 +416,7 @@ void helper_fcomi_ST0_FT0(CPUX86State *env)
|
||||||
void helper_fucomi_ST0_FT0(CPUX86State *env)
|
void helper_fucomi_ST0_FT0(CPUX86State *env)
|
||||||
{
|
{
|
||||||
int eflags;
|
int eflags;
|
||||||
int ret;
|
FloatRelation ret;
|
||||||
|
|
||||||
ret = floatx80_compare_quiet(ST0, FT0, &env->fp_status);
|
ret = floatx80_compare_quiet(ST0, FT0, &env->fp_status);
|
||||||
eflags = cpu_cc_compute_all(env, CC_OP);
|
eflags = cpu_cc_compute_all(env, CC_OP);
|
||||||
|
|
|
@ -1031,7 +1031,7 @@ static const int comis_eflags[4] = {CC_C, CC_Z, 0, CC_Z | CC_P | CC_C};
|
||||||
|
|
||||||
void helper_ucomiss(CPUX86State *env, Reg *d, Reg *s)
|
void helper_ucomiss(CPUX86State *env, Reg *d, Reg *s)
|
||||||
{
|
{
|
||||||
int ret;
|
FloatRelation ret;
|
||||||
float32 s0, s1;
|
float32 s0, s1;
|
||||||
|
|
||||||
s0 = d->ZMM_S(0);
|
s0 = d->ZMM_S(0);
|
||||||
|
@ -1042,7 +1042,7 @@ void helper_ucomiss(CPUX86State *env, Reg *d, Reg *s)
|
||||||
|
|
||||||
void helper_comiss(CPUX86State *env, Reg *d, Reg *s)
|
void helper_comiss(CPUX86State *env, Reg *d, Reg *s)
|
||||||
{
|
{
|
||||||
int ret;
|
FloatRelation ret;
|
||||||
float32 s0, s1;
|
float32 s0, s1;
|
||||||
|
|
||||||
s0 = d->ZMM_S(0);
|
s0 = d->ZMM_S(0);
|
||||||
|
@ -1053,7 +1053,7 @@ void helper_comiss(CPUX86State *env, Reg *d, Reg *s)
|
||||||
|
|
||||||
void helper_ucomisd(CPUX86State *env, Reg *d, Reg *s)
|
void helper_ucomisd(CPUX86State *env, Reg *d, Reg *s)
|
||||||
{
|
{
|
||||||
int ret;
|
FloatRelation ret;
|
||||||
float64 d0, d1;
|
float64 d0, d1;
|
||||||
|
|
||||||
d0 = d->ZMM_D(0);
|
d0 = d->ZMM_D(0);
|
||||||
|
@ -1064,7 +1064,7 @@ void helper_ucomisd(CPUX86State *env, Reg *d, Reg *s)
|
||||||
|
|
||||||
void helper_comisd(CPUX86State *env, Reg *d, Reg *s)
|
void helper_comisd(CPUX86State *env, Reg *d, Reg *s)
|
||||||
{
|
{
|
||||||
int ret;
|
FloatRelation ret;
|
||||||
float64 d0, d1;
|
float64 d0, d1;
|
||||||
|
|
||||||
d0 = d->ZMM_D(0);
|
d0 = d->ZMM_D(0);
|
||||||
|
|
|
@ -264,7 +264,7 @@ void helper_fsqrtq(CPUSPARCState *env)
|
||||||
#define GEN_FCMP(name, size, reg1, reg2, FS, E) \
|
#define GEN_FCMP(name, size, reg1, reg2, FS, E) \
|
||||||
target_ulong glue(helper_, name) (CPUSPARCState *env) \
|
target_ulong glue(helper_, name) (CPUSPARCState *env) \
|
||||||
{ \
|
{ \
|
||||||
int ret; \
|
FloatRelation ret; \
|
||||||
target_ulong fsr; \
|
target_ulong fsr; \
|
||||||
if (E) { \
|
if (E) { \
|
||||||
ret = glue(size, _compare)(reg1, reg2, &env->fp_status); \
|
ret = glue(size, _compare)(reg1, reg2, &env->fp_status); \
|
||||||
|
@ -295,7 +295,7 @@ void helper_fsqrtq(CPUSPARCState *env)
|
||||||
#define GEN_FCMP_T(name, size, FS, E) \
|
#define GEN_FCMP_T(name, size, FS, E) \
|
||||||
target_ulong glue(helper_, name)(CPUSPARCState *env, size src1, size src2)\
|
target_ulong glue(helper_, name)(CPUSPARCState *env, size src1, size src2)\
|
||||||
{ \
|
{ \
|
||||||
int ret; \
|
FloatRelation ret; \
|
||||||
target_ulong fsr; \
|
target_ulong fsr; \
|
||||||
if (E) { \
|
if (E) { \
|
||||||
ret = glue(size, _compare)(src1, src2, &env->fp_status); \
|
ret = glue(size, _compare)(src1, src2, &env->fp_status); \
|
||||||
|
|
Loading…
Reference in a new issue