aboutsummaryrefslogtreecommitdiff
path: root/sim/common/sim-fpu.h
diff options
context:
space:
mode:
authorFaraz Shahbazker <fshahbazker@wavecomp.com>2022-02-02 11:17:22 +0100
committerMike Frysinger <vapier@gentoo.org>2022-02-04 19:37:25 -0500
commitbf484e93483776072291c5cad2e289567d74c818 (patch)
treec835425923f43be579228b97ca2b5b0688887e54 /sim/common/sim-fpu.h
parenteb06e60a982e3903161252edf8fb8ae0c018c467 (diff)
downloadfsf-binutils-gdb-bf484e93483776072291c5cad2e289567d74c818.zip
fsf-binutils-gdb-bf484e93483776072291c5cad2e289567d74c818.tar.gz
fsf-binutils-gdb-bf484e93483776072291c5cad2e289567d74c818.tar.bz2
sim: Allow toggling of quiet NaN-bit semantics
IEEE754-1985 specifies the top bit of the mantissa as an indicator of signalling vs. quiet NaN, but does not define the precise semantics. Most architectures treat this bit as indicating quiet NaN, but legacy (pre-R6) MIPS goes the other way and treats it as signalling NaN. This used to be controlled by a macro that was only defined for MIPS. This patch replaces the macro with a variable to track the current semantics of the NaN bit and allows differentiation between older (pre-R6) and and newer MIPS cores. 2022-02-01 Faraz Shahbazker <fshahbazker@wavecomp.com> sim/common/ChangeLog: * sim-fpu.c (_sim_fpu): New. (pack_fpu, unpack_fpu): Allow reversal of quiet NaN semantics. * sim-fpu.h (sim_fpu_state): New struct. (_sim_fpu): New extern. (sim_fpu_quiet_nan_inverted): New define. sim/mips/ChangeLog: * cp1.h (fcsr_NAN2008_mask, fcsr_NAN2008_shift): New. * mips.igen (check_fpu): Select default quiet NaN mode for legacy MIPS. * sim-main.h (SIM_QUIET_NAN_NEGATED): Remove.
Diffstat (limited to 'sim/common/sim-fpu.h')
-rw-r--r--sim/common/sim-fpu.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/sim/common/sim-fpu.h b/sim/common/sim-fpu.h
index 447621b..b0b318c 100644
--- a/sim/common/sim-fpu.h
+++ b/sim/common/sim-fpu.h
@@ -25,6 +25,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#define SIM_FPU_H
+#include <stdbool.h>
+
/* The FPU intermediate type - this object, passed by reference,
should be treated as opaque.
@@ -157,6 +159,17 @@ typedef enum
+/* State used by the FPU.
+
+ FIXME: This state is global, but should be moved to SIM_CPU. */
+
+typedef struct _sim_fpu_state {
+ bool quiet_nan_inverted; /* Toggle quiet NaN semantics. */
+} sim_fpu_state;
+
+
+
+
/* Directly map between a 32/64 bit register and the sim_fpu internal
type.
@@ -375,7 +388,19 @@ enum {
INLINE_SIM_FPU (int) sim_fpu_is (const sim_fpu *l);
INLINE_SIM_FPU (int) sim_fpu_cmp (const sim_fpu *l, const sim_fpu *r);
+/* Global FPU state. */
+
+extern sim_fpu_state _sim_fpu;
+
+
+/* IEEE 754-1985 specifies the top bit of the mantissa as an indicator
+ of signalling vs. quiet NaN, but does not specify the semantics.
+ Most architectures treat this bit as quiet NaN, but legacy (pre-R6)
+ MIPS goes the other way and treats it as signalling. This variable
+ tracks the current semantics of the NaN bit and allows differentiation
+ between pre-R6 and R6 MIPS cores. */
+#define sim_fpu_quiet_nan_inverted _sim_fpu.quiet_nan_inverted
/* A number of useful constants. */