On Fri, Apr 1, 2011 at 5:30 PM, Peter Maydell <peter.mayd...@linaro.org> wrote: > Correct the argument and return types for the float<->int conversion helper > functions so that integer arguments and return values are declared as > uint32_t/uint64_t, not float32/float64. This allows us to remove the > hand-rolled functions which were doing bitwise copies between the types > via unions. > > Signed-off-by: Peter Maydell <peter.mayd...@linaro.org> > Reviewed-by: Nathan Froyd <froy...@codesourcery.com> > --- > target-arm/helper.c | 155 > ++++++++++++++++++-------------------------------- > target-arm/helpers.h | 60 ++++++++++---------- > 2 files changed, 85 insertions(+), 130 deletions(-) > > diff --git a/target-arm/helper.c b/target-arm/helper.c > index 78f3d39..6788a4c 100644 > --- a/target-arm/helper.c > +++ b/target-arm/helper.c > @@ -2486,135 +2486,90 @@ DO_VFP_cmp(s, float32) > DO_VFP_cmp(d, float64) > #undef DO_VFP_cmp > > -/* Helper routines to perform bitwise copies between float and int. */ > -static inline float32 vfp_itos(uint32_t i) > -{ > - union { > - uint32_t i; > - float32 s; > - } v; > - > - v.i = i; > - return v.s; > -} > - > -static inline uint32_t vfp_stoi(float32 s) > -{ > - union { > - uint32_t i; > - float32 s; > - } v; > - > - v.s = s; > - return v.i; > -} > - > -static inline float64 vfp_itod(uint64_t i) > -{ > - union { > - uint64_t i; > - float64 d; > - } v; > - > - v.i = i; > - return v.d; > -} > - > -static inline uint64_t vfp_dtoi(float64 d) > -{ > - union { > - uint64_t i; > - float64 d; > - } v; > - > - v.d = d; > - return v.i; > -} > - > /* Integer to float conversion. */ > -float32 VFP_HELPER(uito, s)(float32 x, CPUState *env) > +float32 VFP_HELPER(uito, s)(uint32_t x, CPUState *env)
If you moved these functions to op_helper.c, passing env would not be needed anymore. Another possible optimization is that maybe the softfloat functions could be used directly as helpers if type of fp_status could be changed to something that can be passed in a register, like uint32_t. This would be useful for most targets.