softfloat: fix USE_SOFTFLOAT_STRUCT_TYPES compile failures
cover softfloat: fix USE_SOFTFLOAT_STRUCT_TYPES compile failures
This patchset fixes some compilation failures which happen if you try to enable softfloat's USE_SOFTFLOAT_STRUCT_TYPES type-error-debugging switch.
This patchset leaves one error in float16_to_float32, because that is fixed in passing by my half-precision patchset, and I saw no point in deliberately creating a patch conflict.
I've only fixed the problems with core softfloat and the ARM targets; maintainers of other targets can fix their platforms if they think it's worth doing.
Peter Maydell (2):
softfloat: Fix compilation failures with USE_SOFTFLOAT_STRUCT_TYPES linux-user/arm: fix compilation failures using softfloat's struct
types
fpu/softfloat.c | 30 +++++++++++++++--------------- fpu/softfloat.h | 4 ++++ linux-user/arm/nwfpe/fpa11_cpdt.c | 2 +- linux-user/arm/nwfpe/fpopcode.c | 32 ++++++++++++++++---------------- linux-user/signal.c | 4 ++-- 5 files changed, 38 insertions(+), 34 deletions(-)
PATCH 1/2 softfloat: Fix compilation failures with USE_SOFTFLOAT_STRUCT_TYPES
Make softfloat compile with USE_SOFTFLOAT_STRUCT_TYPES defined, by adding and using new macros const_float32() and const_float64() so you can use array initializers in an array of float32/float64 whether the types are bare or wrapped in the structs.
--- fpu/softfloat.c | 30 +++++++++++++++--------------- fpu/softfloat.h | 4 ++++ 2 files changed, 19 insertions(+), 15 deletions(-)
fpu/softfloat.c +15 -15
@@ -2172,21 +2172,21 @@ float32 float32_sqrt( float32 a STATUS_PARAM )static const float64 float32_exp2_coefficients[15 ] = { -make_float64 (0x3ff0000000000000ll ),/* 1 */ -make_float64 (0x3fe0000000000000ll ),/* 2 */ -make_float64 (0x3fc5555555555555ll ),/* 3 */ -make_float64 (0x3fa5555555555555ll ),/* 4 */ -make_float64 (0x3f81111111111111ll ),/* 5 */ -make_float64 (0x3f56c16c16c16c17ll ),/* 6 */ -make_float64 (0x3f2a01a01a01a01all ),/* 7 */ -make_float64 (0x3efa01a01a01a01all ),/* 8 */ -make_float64 (0x3ec71de3a556c734ll ),/* 9 */ -make_float64 (0x3e927e4fb7789f5cll ),/* 10 */ -make_float64 (0x3e5ae64567f544e4ll ),/* 11 */ -make_float64 (0x3e21eed8eff8d898ll ),/* 12 */ -make_float64 (0x3de6124613a86d09ll ),/* 13 */ -make_float64 (0x3da93974a8c07c9dll ),/* 14 */ -make_float64 (0x3d6ae7f3e733b81fll ),/* 15 */ +const_float64 (0x3ff0000000000000ll ),/* 1 */ +const_float64 (0x3fe0000000000000ll ),/* 2 */ +const_float64 (0x3fc5555555555555ll ),/* 3 */ +const_float64 (0x3fa5555555555555ll ),/* 4 */ +const_float64 (0x3f81111111111111ll ),/* 5 */ +const_float64 (0x3f56c16c16c16c17ll ),/* 6 */ +const_float64 (0x3f2a01a01a01a01all ),/* 7 */ +const_float64 (0x3efa01a01a01a01all ),/* 8 */ +const_float64 (0x3ec71de3a556c734ll ),/* 9 */ +const_float64 (0x3e927e4fb7789f5cll ),/* 10 */ +const_float64 (0x3e5ae64567f544e4ll ),/* 11 */ +const_float64 (0x3e21eed8eff8d898ll ),/* 12 */ +const_float64 (0x3de6124613a86d09ll ),/* 13 */ +const_float64 (0x3da93974a8c07c9dll ),/* 14 */ +const_float64 (0x3d6ae7f3e733b81fll ),/* 15 */ }; float32 float32_exp2( float32 a STATUS_PARAM )
fpu/softfloat.h +4 -0
@@ -125,11 +125,13 @@ typedef struct {/* The cast ensures an error if the wrong type is passed. */ #define float32_val (x) (((float32)(x)).v)#define make_float32 (x) __extension__ ({ float32 f32_val = {x}; f32_val; }) +#define const_float32 (x) { x }typedef struct {uint64_t v; }float64 ;#define float64_val (x) (((float64)(x)).v)#define make_float64 (x) __extension__ ({ float64 f64_val = {x}; f64_val; }) +#define const_float64 (x) { x }#else typedef uint32_t float32 ;typedef uint64_t float64 ;
@@ -137,6 +139,8 @@ typedef uint64_t float64;#define float64_val (x) (x)#define make_float32 (x) (x)#define make_float64 (x) (x) +#define const_float32 (x) x +#define const_float64 (x) x#endif #ifdef FLOATX80 typedef struct {
Signature · 1 line
1.7.1
PATCH 2/2 linux-user/arm: fix compilation failures using softfloat's struct types
In reply to Peter MaydellAdd uses of the float32/float64 boxing and unboxing macros so that the ARM linux-user targets will compile with USE_SOFTFLOAT_STRUCT_TYPES enabled.
--- linux-user/arm/nwfpe/fpa11_cpdt.c | 2 +- linux-user/arm/nwfpe/fpopcode.c | 32 ++++++++++++++++---------------- linux-user/signal.c | 4 ++-- 3 files changed, 19 insertions(+), 19 deletions(-)
linux-user/arm/nwfpe/fpa11_cpdt.c +1 -1
@@ -33,7 +33,7 @@ void loadSingle(const unsigned int Fn, target_ulong addr)FPA11 *fpa11 =GET_FPA11 (); fpa11->fType[Fn] = typeSingle;/* FIXME - handle failure of get_user() */ -get_user_u32 (fpa11->fpreg[Fn].fSingle, addr); +get_user_u32 (float32_val (fpa11->fpreg[Fn].fSingle), addr); } static inline
linux-user/arm/nwfpe/fpopcode.c +16 -16
@@ -37,25 +37,25 @@ const floatx80 floatx80Constant[] = { };const float64 float64Constant[] = { -0x0000000000000000ULL ,/* double 0.0 */ -0x3ff0000000000000ULL ,/* double 1.0 */ -0x4000000000000000ULL ,/* double 2.0 */ -0x4008000000000000ULL ,/* double 3.0 */ -0x4010000000000000ULL ,/* double 4.0 */ -0x4014000000000000ULL ,/* double 5.0 */ -0x3fe0000000000000ULL ,/* double 0.5 */ -0x4024000000000000ULL /* double 10.0 */ +const_float64 (0x0000000000000000ULL ),/* double 0.0 */ +const_float64 (0x3ff0000000000000ULL ),/* double 1.0 */ +const_float64 (0x4000000000000000ULL ),/* double 2.0 */ +const_float64 (0x4008000000000000ULL ),/* double 3.0 */ +const_float64 (0x4010000000000000ULL ),/* double 4.0 */ +const_float64 (0x4014000000000000ULL ),/* double 5.0 */ +const_float64 (0x3fe0000000000000ULL ),/* double 0.5 */ +const_float64 (0x4024000000000000ULL )/* double 10.0 */ };const float32 float32Constant[] = { -0x00000000 ,/* single 0.0 */ -0x3f800000 ,/* single 1.0 */ -0x40000000 ,/* single 2.0 */ -0x40400000 ,/* single 3.0 */ -0x40800000 ,/* single 4.0 */ -0x40a00000 ,/* single 5.0 */ -0x3f000000 ,/* single 0.5 */ -0x41200000 /* single 10.0 */ +const_float32 (0x00000000 ),/* single 0.0 */ +const_float32 (0x3f800000 ),/* single 1.0 */ +const_float32 (0x40000000 ),/* single 2.0 */ +const_float32 (0x40400000 ),/* single 3.0 */ +const_float32 (0x40800000 ),/* single 4.0 */ +const_float32 (0x40a00000 ),/* single 5.0 */ +const_float32 (0x3f000000 ),/* single 0.5 */ +const_float32 (0x41200000 )/* single 10.0 */ };unsigned int getRegisterCount (const unsigned int opcode)
linux-user/signal.c +2 -2
@@ -1299,7 +1299,7 @@ static abi_ulong *setup_sigframe_v2_vfp(abi_ulong *regspace, CPUState *env)__put_user (TARGET_VFP_MAGIC , &vfpframe->magic);__put_user (sizeof (*vfpframe), &vfpframe->size);for (i =0 ; i <32 ; i++) { -__put_user (env->vfp.regs[i], &vfpframe->ufp.fpregs[i]); +__put_user (float64_val (env->vfp.regs[i]), &vfpframe->ufp.fpregs[i]); }__put_user (vfp_get_fpscr (env), &vfpframe->ufp.fpscr);__put_user (env->vfp.xregs[ARM_VFP_FPEXC ], &vfpframe->ufp_exc.fpexc);
@@ -1588,7 +1588,7 @@ static abi_ulong *restore_sigframe_v2_vfp(CPUState *env, abi_ulong *regspace)return 0 ; }for (i =0 ; i <32 ; i++) { -__get_user (env->vfp.regs[i], &vfpframe->ufp.fpregs[i]); +__get_user (float64_val (env->vfp.regs[i]), &vfpframe->ufp.fpregs[i]); }__get_user (fpscr, &vfpframe->ufp.fpscr);vfp_set_fpscr (env, fpscr);
Signature · 1 line
1.7.1
Quoted 16 lines · Peter Maydell
This patchset fixes some compilation failures which happen if you try to enable softfloat's
USE_SOFTFLOAT_STRUCT_TYPEStype-error-debugging switch.This patchset leaves one error in
float16_to_float32, because that is fixed in passing by my half-precision patchset, and I saw no point in deliberately creating a patch conflict.I've only fixed the problems with core softfloat and the ARM targets; maintainers of other targets can fix their platforms if they think it's worth doing.
Peter Maydell (2):
softfloat: Fix compilation failures withUSE_SOFTFLOAT_STRUCT_TYPESlinux-user/arm: fix compilation failures using softfloat's struct
types
Quoted 7 lines
fpu/softfloat.c | 30 +++++++++++++++--------------- fpu/softfloat.h | 4 ++++ linux-user/arm/nwfpe/fpa11_cpdt.c | 2 +- linux-user/arm/nwfpe/fpopcode.c | 32 ++++++++++++++++---------------- linux-user/signal.c | 4 ++-- 5 files changed, 38 insertions(+), 34 deletions(-)
Thanks, both applied. I took the liberty to do the same for float16 in the first patch.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net