summaryrefslogtreecommitdiff
path: root/target/m68k/fpu_helper.c
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2020-11-21 09:33:36 -0800
committerRichard Henderson <richard.henderson@linaro.org>2021-06-03 14:04:02 -0700
commit8da5f1dbb0d7b97686d54584c70b55cb05f89007 (patch)
tree2c3dbd392b0c18e9397a145e4832a46317146c18 /target/m68k/fpu_helper.c
parentd6e1f0cd59a59a27a2b109600653e57917cc9594 (diff)
downloadqemu-8da5f1dbb0d7b97686d54584c70b55cb05f89007.zip
softfloat: Introduce Floatx80RoundPrec
Use an enumeration instead of raw 32/64/80 values. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'target/m68k/fpu_helper.c')
-rw-r--r--target/m68k/fpu_helper.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/target/m68k/fpu_helper.c b/target/m68k/fpu_helper.c
index 797000e748..fdc4937e29 100644
--- a/target/m68k/fpu_helper.c
+++ b/target/m68k/fpu_helper.c
@@ -94,13 +94,13 @@ static void m68k_restore_precision_mode(CPUM68KState *env)
{
switch (env->fpcr & FPCR_PREC_MASK) {
case FPCR_PREC_X: /* extended */
- set_floatx80_rounding_precision(80, &env->fp_status);
+ set_floatx80_rounding_precision(floatx80_precision_x, &env->fp_status);
break;
case FPCR_PREC_S: /* single */
- set_floatx80_rounding_precision(32, &env->fp_status);
+ set_floatx80_rounding_precision(floatx80_precision_s, &env->fp_status);
break;
case FPCR_PREC_D: /* double */
- set_floatx80_rounding_precision(64, &env->fp_status);
+ set_floatx80_rounding_precision(floatx80_precision_d, &env->fp_status);
break;
case FPCR_PREC_U: /* undefined */
default:
@@ -111,9 +111,9 @@ static void m68k_restore_precision_mode(CPUM68KState *env)
static void cf_restore_precision_mode(CPUM68KState *env)
{
if (env->fpcr & FPCR_PREC_S) { /* single */
- set_floatx80_rounding_precision(32, &env->fp_status);
+ set_floatx80_rounding_precision(floatx80_precision_s, &env->fp_status);
} else { /* double */
- set_floatx80_rounding_precision(64, &env->fp_status);
+ set_floatx80_rounding_precision(floatx80_precision_d, &env->fp_status);
}
}
@@ -166,8 +166,8 @@ void HELPER(set_fpcr)(CPUM68KState *env, uint32_t val)
#define PREC_BEGIN(prec) \
do { \
- int old; \
- old = get_floatx80_rounding_precision(&env->fp_status); \
+ FloatX80RoundPrec old = \
+ get_floatx80_rounding_precision(&env->fp_status); \
set_floatx80_rounding_precision(prec, &env->fp_status) \
#define PREC_END() \
@@ -176,14 +176,14 @@ void HELPER(set_fpcr)(CPUM68KState *env, uint32_t val)
void HELPER(fsround)(CPUM68KState *env, FPReg *res, FPReg *val)
{
- PREC_BEGIN(32);
+ PREC_BEGIN(floatx80_precision_s);
res->d = floatx80_round(val->d, &env->fp_status);
PREC_END();
}
void HELPER(fdround)(CPUM68KState *env, FPReg *res, FPReg *val)
{
- PREC_BEGIN(64);
+ PREC_BEGIN(floatx80_precision_d);
res->d = floatx80_round(val->d, &env->fp_status);
PREC_END();
}
@@ -195,14 +195,14 @@ void HELPER(fsqrt)(CPUM68KState *env, FPReg *res, FPReg *val)
void HELPER(fssqrt)(CPUM68KState *env, FPReg *res, FPReg *val)
{
- PREC_BEGIN(32);
+ PREC_BEGIN(floatx80_precision_s);
res->d = floatx80_sqrt(val->d, &env->fp_status);
PREC_END();
}
void HELPER(fdsqrt)(CPUM68KState *env, FPReg *res, FPReg *val)
{
- PREC_BEGIN(64);
+ PREC_BEGIN(floatx80_precision_d);
res->d = floatx80_sqrt(val->d, &env->fp_status);
PREC_END();
}
@@ -214,14 +214,14 @@ void HELPER(fabs)(CPUM68KState *env, FPReg *res, FPReg *val)
void HELPER(fsabs)(CPUM68KState *env, FPReg *res, FPReg *val)
{
- PREC_BEGIN(32);
+ PREC_BEGIN(floatx80_precision_s);
res->d = floatx80_round(floatx80_abs(val->d), &env->fp_status);
PREC_END();
}
void HELPER(fdabs)(CPUM68KState *env, FPReg *res, FPReg *val)
{
- PREC_BEGIN(64);
+ PREC_BEGIN(floatx80_precision_d);
res->d = floatx80_round(floatx80_abs(val->d), &env->fp_status);
PREC_END();
}
@@ -233,14 +233,14 @@ void HELPER(fneg)(CPUM68KState *env, FPReg *res, FPReg *val)
void HELPER(fsneg)(CPUM68KState *env, FPReg *res, FPReg *val)
{
- PREC_BEGIN(32);
+ PREC_BEGIN(floatx80_precision_s);
res->d = floatx80_round(floatx80_chs(val->d), &env->fp_status);
PREC_END();
}
void HELPER(fdneg)(CPUM68KState *env, FPReg *res, FPReg *val)
{
- PREC_BEGIN(64);
+ PREC_BEGIN(floatx80_precision_d);
res->d = floatx80_round(floatx80_chs(val->d), &env->fp_status);
PREC_END();
}
@@ -252,14 +252,14 @@ void HELPER(fadd)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
void HELPER(fsadd)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
{
- PREC_BEGIN(32);
+ PREC_BEGIN(floatx80_precision_s);
res->d = floatx80_add(val0->d, val1->d, &env->fp_status);
PREC_END();
}
void HELPER(fdadd)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
{
- PREC_BEGIN(64);
+ PREC_BEGIN(floatx80_precision_d);
res->d = floatx80_add(val0->d, val1->d, &env->fp_status);
PREC_END();
}
@@ -271,14 +271,14 @@ void HELPER(fsub)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
void HELPER(fssub)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
{
- PREC_BEGIN(32);
+ PREC_BEGIN(floatx80_precision_s);
res->d = floatx80_sub(val1->d, val0->d, &env->fp_status);
PREC_END();
}
void HELPER(fdsub)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
{
- PREC_BEGIN(64);
+ PREC_BEGIN(floatx80_precision_d);
res->d = floatx80_sub(val1->d, val0->d, &env->fp_status);
PREC_END();
}
@@ -290,14 +290,14 @@ void HELPER(fmul)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
void HELPER(fsmul)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
{
- PREC_BEGIN(32);
+ PREC_BEGIN(floatx80_precision_s);
res->d = floatx80_mul(val0->d, val1->d, &env->fp_status);
PREC_END();
}
void HELPER(fdmul)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
{
- PREC_BEGIN(64);
+ PREC_BEGIN(floatx80_precision_d);
res->d = floatx80_mul(val0->d, val1->d, &env->fp_status);
PREC_END();
}
@@ -307,7 +307,7 @@ void HELPER(fsglmul)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
FloatRoundMode rounding_mode = get_float_rounding_mode(&env->fp_status);
floatx80 a, b;
- PREC_BEGIN(32);
+ PREC_BEGIN(floatx80_precision_s);
set_float_rounding_mode(float_round_to_zero, &env->fp_status);
a = floatx80_round(val0->d, &env->fp_status);
b = floatx80_round(val1->d, &env->fp_status);
@@ -323,14 +323,14 @@ void HELPER(fdiv)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
void HELPER(fsdiv)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
{
- PREC_BEGIN(32);
+ PREC_BEGIN(floatx80_precision_s);
res->d = floatx80_div(val1->d, val0->d, &env->fp_status);
PREC_END();
}
void HELPER(fddiv)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
{
- PREC_BEGIN(64);
+ PREC_BEGIN(floatx80_precision_d);
res->d = floatx80_div(val1->d, val0->d, &env->fp_status);
PREC_END();
}
@@ -340,7 +340,7 @@ void HELPER(fsgldiv)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
FloatRoundMode rounding_mode = get_float_rounding_mode(&env->fp_status);
floatx80 a, b;
- PREC_BEGIN(32);
+ PREC_BEGIN(floatx80_precision_s);
set_float_rounding_mode(float_round_to_zero, &env->fp_status);
a = floatx80_round(val1->d, &env->fp_status);
b = floatx80_round(val0->d, &env->fp_status);