From 0eee5afd0e8e2af48b8ba7ed39ab55114d589776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= Date: Thu, 8 Mar 2018 09:54:21 -0500 Subject: [PATCH] target/*/cpu.h: remove softfloat.h As cpu.h is another typically widely included file which doesn't need full access to the softfloat API we can remove the includes from here as well. Where they do need types it's typically for float_status and the rounding modes so we move that to softfloat-types.h as well. As a result of not having softfloat in every cpu.h call we now need to add it to various helpers that do need the full softfloat.h definitions. Backports commit 24f91e81b65fcdd0552d1f0fcb0ea7cfe3829c19 from qemu --- qemu/include/fpu/softfloat-types.h | 64 ++++++++++++++++++++++++++++++ qemu/include/fpu/softfloat.h | 53 ------------------------- qemu/target/arm/cpu.c | 1 + qemu/target/arm/cpu.h | 2 - qemu/target/arm/helper-a64.c | 1 + qemu/target/arm/helper.c | 1 + qemu/target/arm/neon_helper.c | 1 + qemu/target/i386/cpu.h | 4 -- qemu/target/i386/fpu_helper.c | 1 + qemu/target/m68k/cpu.c | 2 +- qemu/target/m68k/cpu.h | 2 - qemu/target/m68k/fpu_helper.c | 1 + qemu/target/m68k/helper.c | 1 + qemu/target/m68k/translate.c | 1 + qemu/target/sparc/cpu.h | 2 - qemu/target/sparc/fop_helper.c | 1 + 16 files changed, 74 insertions(+), 64 deletions(-) diff --git a/qemu/include/fpu/softfloat-types.h b/qemu/include/fpu/softfloat-types.h index 8210a94e..6cac63fe 100644 --- a/qemu/include/fpu/softfloat-types.h +++ b/qemu/include/fpu/softfloat-types.h @@ -84,6 +84,12 @@ this code that are retained. * Software IEC/IEEE floating-point types. */ +/* This 'flag' type must be able to hold at least 0 and 1. It should + * probably be replaced with 'bool' but the uses would need to be audited + * to check that they weren't accidentally relying on it being a larger type. + */ +typedef uint8_t flag; + typedef uint16_t float16; typedef uint32_t float32; typedef uint64_t float64; @@ -112,4 +118,62 @@ typedef struct { #define make_float128(high_, low_) ((float128) { .high = high_, .low = low_ }) #define make_float128_init(high_, low_) { .high = high_, .low = low_ } +/* + * Software IEC/IEEE floating-point underflow tininess-detection mode. + */ + +enum { + float_tininess_after_rounding = 0, + float_tininess_before_rounding = 1 +}; + +/* + *Software IEC/IEEE floating-point rounding mode. + */ + +enum { + float_round_nearest_even = 0, + float_round_down = 1, + float_round_up = 2, + float_round_to_zero = 3, + float_round_ties_away = 4, + /* Not an IEEE rounding mode: round to the closest odd mantissa value */ + float_round_to_odd = 5, +}; + +/* + * Software IEC/IEEE floating-point exception flags. + */ + +enum { + float_flag_invalid = 1, + float_flag_divbyzero = 4, + float_flag_overflow = 8, + float_flag_underflow = 16, + float_flag_inexact = 32, + float_flag_input_denormal = 64, + float_flag_output_denormal = 128 +}; + + +/* + * Floating Point Status. Individual architectures may maintain + * several versions of float_status for different functions. The + * correct status for the operation is then passed by reference to + * most of the softfloat functions. + */ + +typedef struct float_status { + signed char float_detect_tininess; + signed char float_rounding_mode; + uint8_t float_exception_flags; + signed char floatx80_rounding_precision; + /* should denormalised results go to zero and set the inexact flag? */ + flag flush_to_zero; + /* should denormalised inputs go to zero and set the input_denormal flag? */ + flag flush_inputs_to_zero; + flag default_nan_mode; + flag snan_bit_is_one; +} float_status; + #endif /* SOFTFLOAT_TYPES_H */ diff --git a/qemu/include/fpu/softfloat.h b/qemu/include/fpu/softfloat.h index 03d164cd..ab9ae929 100644 --- a/qemu/include/fpu/softfloat.h +++ b/qemu/include/fpu/softfloat.h @@ -90,12 +90,6 @@ this code that are retained. #include "config-host.h" #include "qemu/osdep.h" -/* This 'flag' type must be able to hold at least 0 and 1. It should - * probably be replaced with 'bool' but the uses would need to be audited - * to check that they weren't accidentally relying on it being a larger type. - */ -typedef uint8_t flag; - #define LIT64( a ) a##LL /*---------------------------------------------------------------------------- @@ -110,53 +104,6 @@ enum { #include "fpu/softfloat-types.h" -/*---------------------------------------------------------------------------- -| Software IEC/IEEE floating-point underflow tininess-detection mode. -*----------------------------------------------------------------------------*/ -enum { - float_tininess_after_rounding = 0, - float_tininess_before_rounding = 1 -}; - -/*---------------------------------------------------------------------------- -| Software IEC/IEEE floating-point rounding mode. -*----------------------------------------------------------------------------*/ -enum { - float_round_nearest_even = 0, - float_round_down = 1, - float_round_up = 2, - float_round_to_zero = 3, - float_round_ties_away = 4, - /* Not an IEEE rounding mode: round to the closest odd mantissa value */ - float_round_to_odd = 5, -}; - -/*---------------------------------------------------------------------------- -| Software IEC/IEEE floating-point exception flags. -*----------------------------------------------------------------------------*/ -enum { - float_flag_invalid = 1, - float_flag_divbyzero = 4, - float_flag_overflow = 8, - float_flag_underflow = 16, - float_flag_inexact = 32, - float_flag_input_denormal = 64, - float_flag_output_denormal = 128 -}; - -typedef struct float_status { - signed char float_detect_tininess; - signed char float_rounding_mode; - uint8_t float_exception_flags; - signed char floatx80_rounding_precision; - /* should denormalised results go to zero and set the inexact flag? */ - flag flush_to_zero; - /* should denormalised inputs go to zero and set the input_denormal flag? */ - flag flush_inputs_to_zero; - flag default_nan_mode; - flag snan_bit_is_one; -} float_status; - static inline void set_float_detect_tininess(int val, float_status *status) { status->float_detect_tininess = val; diff --git a/qemu/target/arm/cpu.c b/qemu/target/arm/cpu.c index 66a18edb..f0edc034 100644 --- a/qemu/target/arm/cpu.c +++ b/qemu/target/arm/cpu.c @@ -27,6 +27,7 @@ #include "qapi/qmp/qerror.h" #include "hw/arm/arm.h" #include "sysemu/sysemu.h" +#include "fpu/softfloat.h" #include "uc_priv.h" diff --git a/qemu/target/arm/cpu.h b/qemu/target/arm/cpu.h index 1c0b89e5..3ce1c194 100644 --- a/qemu/target/arm/cpu.h +++ b/qemu/target/arm/cpu.h @@ -43,8 +43,6 @@ #include "cpu-qom.h" #include "exec/cpu-defs.h" -#include "fpu/softfloat.h" - #define EXCP_UDEF 1 /* undefined instruction */ #define EXCP_SWI 2 /* software interrupt */ #define EXCP_PREFETCH_ABORT 3 diff --git a/qemu/target/arm/helper-a64.c b/qemu/target/arm/helper-a64.c index f5ae40e9..28d3f6c3 100644 --- a/qemu/target/arm/helper-a64.c +++ b/qemu/target/arm/helper-a64.c @@ -30,6 +30,7 @@ #include "exec/cpu_ldst.h" #include "qemu/int128.h" #include "tcg.h" +#include "fpu/softfloat.h" /* C2.4.7 Multiply and divide */ /* special cases for 0 and LLONG_MIN are mandated by the standard */ diff --git a/qemu/target/arm/helper.c b/qemu/target/arm/helper.c index fdd94c1d..0499a399 100644 --- a/qemu/target/arm/helper.c +++ b/qemu/target/arm/helper.c @@ -9,6 +9,7 @@ #include "exec/exec-all.h" #include "exec/cpu_ldst.h" #include "arm_ldst.h" +#include "fpu/softfloat.h" #ifndef CONFIG_USER_ONLY /* Cacheability and shareability attributes for a memory access */ diff --git a/qemu/target/arm/neon_helper.c b/qemu/target/arm/neon_helper.c index a9bea04a..945b4291 100644 --- a/qemu/target/arm/neon_helper.c +++ b/qemu/target/arm/neon_helper.c @@ -11,6 +11,7 @@ #include "cpu.h" #include "exec/exec-all.h" #include "exec/helper-proto.h" +#include "fpu/softfloat.h" #define SIGNBIT (uint32_t)0x80000000 #define SIGNBIT64 ((uint64_t)1 << 63) diff --git a/qemu/target/i386/cpu.h b/qemu/target/i386/cpu.h index 990f3ec5..6d0e5fab 100644 --- a/qemu/target/i386/cpu.h +++ b/qemu/target/i386/cpu.h @@ -52,10 +52,6 @@ #include "exec/cpu-defs.h" -#ifdef CONFIG_TCG -#include "fpu/softfloat.h" -#endif - #define R_EAX 0 #define R_ECX 1 #define R_EDX 2 diff --git a/qemu/target/i386/fpu_helper.c b/qemu/target/i386/fpu_helper.c index eb3114e6..90a97231 100644 --- a/qemu/target/i386/fpu_helper.c +++ b/qemu/target/i386/fpu_helper.c @@ -24,6 +24,7 @@ #include "qemu/host-utils.h" #include "exec/exec-all.h" #include "exec/cpu_ldst.h" +#include "fpu/softfloat.h" #define FPU_RC_MASK 0xc00 #define FPU_RC_NEAR 0x000 diff --git a/qemu/target/m68k/cpu.c b/qemu/target/m68k/cpu.c index 67f3af55..0f0c075f 100644 --- a/qemu/target/m68k/cpu.c +++ b/qemu/target/m68k/cpu.c @@ -24,7 +24,7 @@ #include "cpu.h" #include "qemu-common.h" #include "exec/exec-all.h" - +#include "fpu/softfloat.h" static void m68k_cpu_set_pc(CPUState *cs, vaddr value) { diff --git a/qemu/target/m68k/cpu.h b/qemu/target/m68k/cpu.h index 731eca75..dd8a99bb 100644 --- a/qemu/target/m68k/cpu.h +++ b/qemu/target/m68k/cpu.h @@ -30,8 +30,6 @@ #include "cpu-qom.h" #include "exec/cpu-defs.h" -#include "fpu/softfloat.h" - #define OS_BYTE 0 #define OS_WORD 1 #define OS_LONG 2 diff --git a/qemu/target/m68k/fpu_helper.c b/qemu/target/m68k/fpu_helper.c index a7c537c3..4805ca39 100644 --- a/qemu/target/m68k/fpu_helper.c +++ b/qemu/target/m68k/fpu_helper.c @@ -23,6 +23,7 @@ #include "exec/helper-proto.h" #include "exec/exec-all.h" #include "exec/cpu_ldst.h" +#include "fpu/softfloat.h" /* Undefined offsets may be different on various FPU. * On 68040 they return 0.0 (floatx80_zero) diff --git a/qemu/target/m68k/helper.c b/qemu/target/m68k/helper.c index 5c0f82da..b84b4dd5 100644 --- a/qemu/target/m68k/helper.c +++ b/qemu/target/m68k/helper.c @@ -23,6 +23,7 @@ #include "exec/exec-all.h" #include "exec/helper-proto.h" +#include "fpu/softfloat.h" #define SIGNBIT (1u << 31) diff --git a/qemu/target/m68k/translate.c b/qemu/target/m68k/translate.c index 99a5f979..895d9e0e 100644 --- a/qemu/target/m68k/translate.c +++ b/qemu/target/m68k/translate.c @@ -30,6 +30,7 @@ #include "exec/helper-gen.h" #include "exec/gen-icount.h" +#include "fpu/softfloat.h" //#define DEBUG_DISPATCH 1 diff --git a/qemu/target/sparc/cpu.h b/qemu/target/sparc/cpu.h index ef038b2c..40e73eef 100644 --- a/qemu/target/sparc/cpu.h +++ b/qemu/target/sparc/cpu.h @@ -30,8 +30,6 @@ #include "exec/cpu-defs.h" -#include "fpu/softfloat.h" - /*#define EXCP_INTERRUPT 0x100*/ /* trap definitions */ diff --git a/qemu/target/sparc/fop_helper.c b/qemu/target/sparc/fop_helper.c index 85e9d15c..1c40b99f 100644 --- a/qemu/target/sparc/fop_helper.c +++ b/qemu/target/sparc/fop_helper.c @@ -21,6 +21,7 @@ #include "cpu.h" #include "exec/exec-all.h" #include "exec/helper-proto.h" +#include "fpu/softfloat.h" #define QT0 (env->qt0) #define QT1 (env->qt1)