[GSoC-19] Expanding fromfp variants on AArch64

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[GSoC-19] Expanding fromfp variants on AArch64

Tejas Joshi
Hello.
The fromfp/fromfpx variants round to integers with a specified number
of bits, to a specified rounding mode. They come with their own
complications as Joseph had stated in an initial mail and expected to
expand them in AArch64 :

> The fromfp / fromfpx / ufromfp / ufromfpx functions (round to integers
> of a specified number of bits, in a specified rounding mode, with
> specified handling of inexact results) are a case with some other
> complications.  Typically I'd expect them to be expanded inline only (for
> constant arguments or) for constant values of the number of bits and
> rounding mode, if the target machine has an appropriate instruction.  A
> target hook would need adding for a target to specify the FP_INT_* values
> used in libm, since that's an ABI that's defined by libm, not by GCC.
> Then you'd need instruction patterns that might only be supported in
> certain cases.

How can I add a target hook to specify the FP_INT_* values from libm ?
Also as this includes rounding to integers, does it involve any RTL
related complications that we have encountered in FADD ?

Thanks,
Tejas
Reply | Threaded
Open this post in threaded view
|

Re: [GSoC-19] Expanding fromfp variants on AArch64

Joseph Myers
On Mon, 19 Aug 2019, Tejas Joshi wrote:

> How can I add a target hook to specify the FP_INT_* values from libm ?

See target.def.

You'll need a GCC-specific enum (GCC_FP_INT_*, say) that GCC uses
internally, and a hook that maps between that and FP_INT_*.  I'm guessing
that for the likely uses, maybe the hook should map from FP_INT_* to
GCC_FP_INT_* (so it gets used on constant arguments to the built-in
function to say which rounding direction they are in GCC's internal enum).  
It will need to be able to return that a constant doesn't map to a known
rounding mode (not an error, just means that call can't be expanded inline
or optimized to a constant).

Then the relevant macro giving the default for glibc systems should be
defined in config/gnu-user.h (see how it defines e.g.
TARGET_LIBC_HAS_FUNCTION).

> Also as this includes rounding to integers, does it involve any RTL
> related complications that we have encountered in FADD ?

The new RTL would effectively be variants of the fix_trunc and
fixuns_trunc patterns, which can use (fix) and (unsigned_fix) RTL; the new
variants would take an argument in a floating-point mode, returning one in
an integer mode - but with extra information involved about the number of
bits, rounding direction, handling of "inexact".

fix_trunc and fixuns_trunc / (fix) and (unsigned_fix) always use
FP_INT_TOWARDZERO, always use the width of the mode and have unspecified
"inexact" handling for non-integer in-range values (they correspond to C
casts) so are not themselves suitable for implementing the new built-in
functions (but the particular instructions those patterns expand to are
likely to be suitable for certain arguments to certain of the new built-in
functions).

--
Joseph S. Myers
[hidden email]