Re: [PATCH 52/55] rs6000: Debug support

2021-08-03 Thread Segher Boessenkool
On Tue, Jul 27, 2021 at 04:07:22PM -0500, will schmidt wrote:
> On Thu, 2021-06-17 at 10:19 -0500, Bill Schmidt via Gcc-patches wrote:
> > +  else if (type == bool_V16QI_type_node)
> > +return "vbc";
> > +  else if (type == bool_V2DI_type_node)
> > +return "vbll";
> > +  else if (type == bool_V4SI_type_node)
> > +return "vbi";
> > +  else if (type == bool_V8HI_type_node)
> > +return "vbs";
> 
> I'd be strongly tempted to rearrange the order and put V16 after V8 in
> the list.  Similar to the order you previously used in
> rs6000_expand_new_builtin(). Same comment elsewhere.

These are ordered on return value.  It is hard to make some order of all
these disparate things based on the actual type, but the strings is a
neat way out ;-)

(A comment "ordered by return value" would be good to have).

> > +  /*
> >if (TARGET_DEBUG_BUILTIN)
> >  fprintf (stderr, "rs6000_builtin, code = %4d, %s%s\n",
> >  (int)code, name, attr_string);
> > +  */
> 
> Could probably just drop that chunk, instead of commenting it out. 

Or fix up its spacing :-P

> > +  for (int i = 1; i < (int) RS6000_BIF_MAX; i++)

That is an good reason to *not* have the max as enum value, btw: you
need a cast to use it.  Make the max a macro, and then it can include
all casting you need right in there :-)


Segher


Re: [PATCH 52/55] rs6000: Debug support

2021-07-27 Thread will schmidt via Gcc-patches
On Thu, 2021-06-17 at 10:19 -0500, Bill Schmidt via Gcc-patches wrote:
> 2021-04-01  Bill Schmidt  
> 
> gcc/
>   * config/rs6000/rs6000-call.c (rs6000_debug_type): New function.
>   (def_builtin): Change debug formatting for easier parsing and
>   include more information.
>   (rs6000_init_builtins): Add dump of autogenerated builtins.
>   (altivec_init_builtins): Dump __builtin_altivec_mask_for_load for
>   completeness.
> ---
>  gcc/config/rs6000/rs6000-call.c | 193 +++-
>  1 file changed, 189 insertions(+), 4 deletions(-)
> 
> diff --git a/gcc/config/rs6000/rs6000-call.c b/gcc/config/rs6000/rs6000-call.c
> index 54cf014ed23..d28bb14b0bb 100644
> --- a/gcc/config/rs6000/rs6000-call.c
> +++ b/gcc/config/rs6000/rs6000-call.c
> @@ -8880,6 +8880,106 @@ rs6000_gimplify_va_arg (tree valist, tree type, 
> gimple_seq *pre_p,
> 
>  /* Builtins.  */
> 
> +/* Debug utility to translate a type node to a single token.  */
> +static
> +const char *rs6000_debug_type (tree type)
> +{
> +  if (type == void_type_node)
> +return "void";
> +  else if (type == long_integer_type_node)
> +return "long";
> +  else if (type == long_unsigned_type_node)
> +return "ulong";
> +  else if (type == long_long_integer_type_node)
> +return "longlong";
> +  else if (type == long_long_unsigned_type_node)
> +return "ulonglong";
> +  else if (type == bool_V16QI_type_node)
> +return "vbc";
> +  else if (type == bool_V2DI_type_node)
> +return "vbll";
> +  else if (type == bool_V4SI_type_node)
> +return "vbi";
> +  else if (type == bool_V8HI_type_node)
> +return "vbs";

I'd be strongly tempted to rearrange the order and put V16 after V8 in
the list.  Similar to the order you previously used in
rs6000_expand_new_builtin(). Same comment elsewhere.


> +  else if (type == bool_int_type_node)
> +return "bool";
> +  else if (type == dfloat64_type_node)
> +return "_Decimal64";
> +  else if (type == double_type_node)
> +return "double";
> +  else if (type == intDI_type_node)
> +return "sll";
> +  else if (type == intHI_type_node)
> +return "ss";
> +  else if (type == ibm128_float_type_node)
> +return "__ibm128";
> +  else if (type == opaque_V4SI_type_node)
> +return "opaque";
> +  else if (POINTER_TYPE_P (type))
> +return "void*";
> +  else if (type == intQI_type_node || type == char_type_node)
> +return "sc";
> +  else if (type == dfloat32_type_node)
> +return "_Decimal32";
> +  else if (type == float_type_node)
> +return "float";
> +  else if (type == intSI_type_node || type == integer_type_node)
> +return "si";
> +  else if (type == dfloat128_type_node)
> +return "_Decimal128";
> +  else if (type == long_double_type_node)
> +return "longdouble";
> +  else if (type == intTI_type_node)
> +return "sq";
> +  else if (type == unsigned_intDI_type_node)
> +return "ull";
> +  else if (type == unsigned_intHI_type_node)
> +return "us";
> +  else if (type == unsigned_intQI_type_node)
> +return "uc";
> +  else if (type == unsigned_intSI_type_node)
> +return "ui";
> +  else if (type == unsigned_intTI_type_node)
> +return "uq";
> +  else if (type == unsigned_V16QI_type_node)
> +return "vuc";
> +  else if (type == unsigned_V1TI_type_node)
> +return "vuq";
> +  else if (type == unsigned_V2DI_type_node)
> +return "vull";
> +  else if (type == unsigned_V4SI_type_node)
> +return "vui";
> +  else if (type == unsigned_V8HI_type_node)
> +return "vus";
> +  else if (type == V16QI_type_node)
> +return "vsc";
> +  else if (type == V1TI_type_node)
> +return "vsq";
> +  else if (type == V2DF_type_node)
> +return "vd";
> +  else if (type == V2DI_type_node)
> +return "vsll";
> +  else if (type == V4SF_type_node)
> +return "vf";
> +  else if (type == V4SI_type_node)
> +return "vsi";
> +  else if (type == V8HI_type_node)
> +return "vss";
> +  else if (type == pixel_V8HI_type_node)
> +return "vp";
> +  else if (type == pcvoid_type_node)
> +return "voidc*";
> +  else if (type == float128_type_node)
> +return "_Float128";
> +  else if (type == vector_pair_type_node)
> +return "__vector_pair";
> +  else if (type == vector_quad_type_node)
> +return "__vector_quad";
> +  else
> +return "unknown";
> +}
> +

Ok

>  static void
>  def_builtin (const char *name, tree type, enum rs6000_builtins code)
>  {
> @@ -8908,7 +9008,7 @@ def_builtin (const char *name, tree type, enum 
> rs6000_builtins code)
>/* const function, function only depends on the inputs.  */
>TREE_READONLY (t) = 1;
>TREE_NOTHROW (t) = 1;
> -  attr_string = ", const";
> +  attr_string = "= const";
>  }
>else if ((classify & RS6000_BTC_PURE) != 0)
>  {
> @@ -8916,7 +9016,7 @@ def_builtin (const char *name, tree type, enum 
> rs6000_builtins code)
>external state.  */
>DECL_PURE_P (t) = 1;
>TREE_NOTHROW (t) = 1;
> -