On Sun, Sep 9, 2012 at 3:06 PM, Peter Maydell <peter.mayd...@linaro.org> wrote: > On 9 September 2012 02:29, Max Filippov <jcmvb...@gmail.com> wrote: >> +uint32_t HELPER(ftoui)(float32 v, uint32_t rounding_mode, uint32_t scale) >> +{ >> + float_status fp_status = {0}; >> + float32 zero = {0}; > > This probably won't compile if you turn on USE_SOFTFLOAT_STRUCT_TYPES
It will, but thanks for the hint, gdbstub breaks with this macro defined. > in softfloat.h. (That's a define intended to assist in avoiding > accidental mixing of the softfloat types with native int/float types.) > > In any case softfloat.h provides a float32_zero which is probably what > you want to use here. > >> + float32 res; >> + >> + set_float_rounding_mode(rounding_mode, &fp_status); >> + >> + res = float32_mul(v, uint32_to_float32(scale, &fp_status), &fp_status); > > Can you use the softflota scalbn function here instead? Sure, had to search for it harder myself... >> + >> + if (float32_compare_quiet(v, zero, &fp_status) == float_relation_less) { >> + return float32_to_int32(res, &fp_status); >> + } else { >> + return float32_to_uint32(res, &fp_status); >> + } > > This looks rather odd...are you sure it's correct? Unfortunately this is what Tensilica ISS does. Doesn't match what ISA specifies and both are a bit counter-intuitive. I've mailed a question to Tensilica guys, will see what they answer. -- Thanks. -- Max