sim: Add partial support for IEEE 754-2008

2022-02-01  Faraz Shahbazker  <fshahbazker@wavecomp.com>

sim/common/ChangeLog:
	* sim-fpu.c (sim_fpu_minmax_nan): New.
	(sim_fpu_max): Add variant behaviour for IEEE 754-2008.
	(sim_fpu_min): Likewise.
	(sim_fpu_is_un, sim_fpu_is_or): New.
	(sim_fpu_un, sim_fpu_or): New.
	(sim_fpu_is_ieee754_2008, sim_fpu_is_ieee754_1985): New.
	(sim_fpu_set_mode): New.
	(sim_fpu_classify): New.
	* sim-fpu.h (sim_fpu_minmax_nan): New declaration.
	(sim_fpu_un, sim_fpu_or): New declarations.
	(sim_fpu_is_un, sim_fpu_is_or): New declarations.
	(sim_fpu_mode): New enum.
	[sim_fpu_state](current_mode): New field.
	(sim_fpu_current_mode): New define.
	(sim_fpu_is_ieee754_2008): New declaration.
	(sim_fpu_is_ieee754_1985): New declaration.
	(sim_fpu_set_mode): New declaration.
	(sim_fpu_classify): New declaration.
This commit is contained in:
Faraz Shahbazker
2022-02-02 11:17:24 +01:00
committed by Mike Frysinger
parent b6af5f3a74
commit fc3c199fac
2 changed files with 131 additions and 5 deletions

View File

@@ -163,8 +163,15 @@ typedef enum
FIXME: This state is global, but should be moved to SIM_CPU. */
typedef enum
{
sim_fpu_ieee754_1985,
sim_fpu_ieee754_2008,
} sim_fpu_mode;
typedef struct _sim_fpu_state {
bool quiet_nan_inverted; /* Toggle quiet NaN semantics. */
sim_fpu_mode current_mode;
} sim_fpu_state;
@@ -268,6 +275,8 @@ INLINE_SIM_FPU (int) sim_fpu_sqrt (sim_fpu *f,
INLINE_SIM_FPU (int) sim_fpu_op_nan (sim_fpu *f,
const sim_fpu *l, const sim_fpu *r);
INLINE_SIM_FPU (int) sim_fpu_minmax_nan (sim_fpu *f,
const sim_fpu *l, const sim_fpu *r);
@@ -318,7 +327,8 @@ INLINE_SIM_FPU (double) sim_fpu_2d (const sim_fpu *d);
/* INLINE_SIM_FPU (void) sim_fpu_f2 (sim_fpu *f, float s); */
INLINE_SIM_FPU (void) sim_fpu_d2 (sim_fpu *f, double d);
/* IEEE754-2008 classifiction function. */
INLINE_SIM_FPU (int) sim_fpu_classify (const sim_fpu *f);
/* Specific number classes.
@@ -367,7 +377,20 @@ INLINE_SIM_FPU (int) sim_fpu_is_ne (const sim_fpu *l, const sim_fpu *r);
INLINE_SIM_FPU (int) sim_fpu_is_ge (const sim_fpu *l, const sim_fpu *r);
INLINE_SIM_FPU (int) sim_fpu_is_gt (const sim_fpu *l, const sim_fpu *r);
/* Unordered/ordered comparison operators. */
INLINE_SIM_FPU (int) sim_fpu_un (int *is, const sim_fpu *l, const sim_fpu *r);
INLINE_SIM_FPU (int) sim_fpu_or (int *is, const sim_fpu *l, const sim_fpu *r);
INLINE_SIM_FPU (int) sim_fpu_is_un (const sim_fpu *l, const sim_fpu *r);
INLINE_SIM_FPU (int) sim_fpu_is_or (const sim_fpu *l, const sim_fpu *r);
/* Changes the behaviour of the library to IEEE754-2008 or IEEE754-1985.
The default for the library is IEEE754-1985. */
INLINE_SIM_FPU (bool) sim_fpu_is_ieee754_1985 (void);
INLINE_SIM_FPU (bool) sim_fpu_is_ieee754_2008 (void);
INLINE_SIM_FPU (void) sim_fpu_set_mode (const sim_fpu_mode m);
/* General number class and comparison operators.
@@ -411,6 +434,7 @@ extern sim_fpu_state _sim_fpu;
between pre-R6 and R6 MIPS cores. */
#define sim_fpu_quiet_nan_inverted _sim_fpu.quiet_nan_inverted
#define sim_fpu_current_mode _sim_fpu.current_mode
/* A number of useful constants. */