On Fri, Aug 07, 2020 at 08:35:52PM +0000, Bert Tenjy via Gcc-patches wrote:
> The document describing POWER Architecture Vector Function interface is
> tentatively at: 
> https://sourceware.org/glibc/wiki/Homepage?action=AttachFile&do=view&target=powerarchvectfuncabi.html

Doesn't exist.

> +  if (TARGET_VSX)
> +    {
> +      clonei->vecsize_mangle = 'b';
> +      ret = 1;
> +    }
> +  clonei->mask_mode = VOIDmode;
> +  switch (clonei->vecsize_mangle)
> +    {
> +    case 'b':
> +      clonei->vecsize_int = 128;
> +      clonei->vecsize_float = 128;
> +      break;
> +    case 'c':
> +      clonei->vecsize_int = 128;
> +      clonei->vecsize_float = 128;

So what is this 'c' case here for?

> +      break;
> +    default:
> +      gcc_unreachable ();

If (!TARGET_VSX), this will abort (as you only set vecsize_mangle to 'b'
if TARGET_VSX, otherwise nothing sets it (so it remains 0).

The way this works is that the caller calls the target hook with 0
as last argument, and the hook either returns 0 (means not supported at
all), or returns number of supported variants and provides the first one.
If more than one are supported, the caller will keep iterating on those.
E.g. on x86, we support 4 modes (b, c, d, e) for exported functions and
for non-exported ones just choose a single one based on the ISA, because in
that case it is not a matter of ABI.

For PowerPC, if all you want to support is b which requires VSX, then the
right thing is for !TREE_PUBLIC functions return 0 if !TARGET_VSX and
otherwise set vecsize_mangle to 'b' and in the end return 1, for exported
functions always set it to 'b' (and in the end return 1).
Then ensure that the 'b' variants of function definitions get target ("vsx")
attribute added if !TARGET_VSX.

That way, e.g. on powerpc64 big endian, the declare simd variants will be
provided for exported functions, but code will only use them if the caller
is TARGET_VSX compiled.

        Jakub

Reply via email to