Andrew Burgess <andrew.burg...@embecosm.com> writes:
> In md.texi it says:
>
>   Predicates written with @code{define_special_predicate} do not get any
>   automatic mode checks, and are treated as having special mode handling
>   by @command{genrecog}.
>
> However, in genrecog, when validating a SET pattern, if either the
> source or destination is missing a mode then a warning is given, even if
> there's a predicate defined with define_special_predicate.
>
> This commit silences the warning for special predicates.
>
> gcc/ChangeLog:
>
>       * genrecog.c (validate_pattern): Don't warn about missing mode for
>       define_special_predicate predicates.
> Acked-by: Andrew Burgess <andrew.burg...@embecosm.com>
> ---
>  gcc/ChangeLog  |  5 +++++
>  gcc/genrecog.c | 22 +++++++++++++++++++---
>  2 files changed, 24 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/genrecog.c b/gcc/genrecog.c
> index a9f5a4a..7596552 100644
> --- a/gcc/genrecog.c
> +++ b/gcc/genrecog.c
> @@ -674,9 +674,25 @@ validate_pattern (rtx pattern, md_rtx_info *info, rtx 
> set, int set_code)
>                && !CONST_WIDE_INT_P (src)
>                && GET_CODE (src) != CALL)
>         {
> -         const char *which;
> -         which = (dmode == VOIDmode ? "destination" : "source");
> -         message_at (info->loc, "warning: %s missing a mode?", which);
> +         const char *which_msg;
> +         rtx which;
> +         const char *pred_name;
> +         const struct pred_data *pred;
> +
> +         which_msg = (dmode == VOIDmode ? "destination" : "source");
> +         which = (dmode == VOIDmode ? dest : src);
> +         pred_name = XSTR (which, 1);
> +         if (pred_name[0] != 0)
> +           {
> +             pred = lookup_predicate (pred_name);
> +             if (!pred)
> +               error_at (info->loc, "unknown predicate '%s'", pred_name);
> +           }
> +         else
> +           pred = 0;
> +         if (!pred || !pred->special)
> +           message_at (info->loc, "warning: %s missing a mode?",
> +                       which_msg);

There's no guarantee at this point that "which" is a match_operand.
Also, I think the earlier:

        /* The operands of a SET must have the same mode unless one
           is VOIDmode.  */
        else if (dmode != VOIDmode && smode != VOIDmode && dmode != smode)
          error_at (info->loc, "mode mismatch in set: %smode vs %smode",
                    GET_MODE_NAME (dmode), GET_MODE_NAME (smode));

should be skipped for special predicates too.

How about generalising:

        /* The mode of an ADDRESS_OPERAND is the mode of the memory
           reference, not the mode of the address.  */
        if (GET_CODE (src) == MATCH_OPERAND
            && ! strcmp (XSTR (src, 1), "address_operand"))
          ;

to:

        if (special_predicate_operand_p (src)
            || special_predicate_operand_p (dest))
          ;

with a new special_predicate_operand_p helper?  I don't think we should
duplicate the "unknown predicate" error here; the helper can just return
false for unknown predicates.

Thanks,
Richard

Reply via email to