From patchwork Thu Jun 30 13:29:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 642534 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rgL5v65fWz9sdQ for ; Thu, 30 Jun 2016 23:30:59 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=A8ECqp9m; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:references:mime-version:content-type :in-reply-to; q=dns; s=default; b=ur2UBsjOujDLPa6OibiEvbW0px4e6u Duf27qsxBaqe1fDrM9Bko+fHG3unqCJU/YvhqWJx8XYnbUdAw4XewhEPYjVe8CP6 CXsro8GTEcCEG+4AyLBjnlLUZ4el7xIA58rdYFSj6B+F58/j6439pg1Abt2trtV0 9F91bTOKuOgrU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:references:mime-version:content-type :in-reply-to; s=default; bh=btVisGMQH3ssIZr+W6klLmOEpmE=; b=A8EC qp9mJokPXXCI7VWIxOdmava0sHJ4uwQSmPWRq9eszgOqZEC/jFG9FnEyBvlwet1t xBJlC+TIdhO78aApuvWQsKmrL3jZrlKWI+1gX3z5K0XxFgp3aWcQGJW0z72TMljV WBdZOdf8fw0sne7Ddn95hf/xlDkNAJD34ZUjn2U= Received: (qmail 1389 invoked by alias); 30 Jun 2016 13:30:24 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 846 invoked by uid 89); 30 Jun 2016 13:30:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=match_scratch, voidmode, VOIDmode, 2.4.11 X-HELO: mail-wm0-f42.google.com Received: from mail-wm0-f42.google.com (HELO mail-wm0-f42.google.com) (74.125.82.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 30 Jun 2016 13:30:01 +0000 Received: by mail-wm0-f42.google.com with SMTP id 187so4416692wmz.1 for ; Thu, 30 Jun 2016 06:30:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=J62STbAorKKKDgfb5tVFeYVflf8s+c/mh+4QD9VCoZU=; b=dEg7DJV4WaafjFwVtKUlnQ/qZMWzVvtF37LF5rnfls9dy6MwRuBLKwYSd8XfdCgYWV +BUF+niJlEbLl+RbmrTu5w3P3jbU+UfFXOgu0orWGMLrFF/iJGq3Ssgu9GJYFaZsQIOb iu1cIc4lvA2vapJ3JmzRCUCwnU+o/yJDWBtW+HbtCxhV9ZadW7yin5URu1VOhUqdZTqR 3N+gzPz7ZcG7rIIEll8ntRHZAWU0LGWnRdJgjYJJSfyl36EAARqmZ9Bc7uXiTGovCwsU d12XAsTAxAXJBIL95b6tXu7CpglZ/PuNPfTVb0b29uqdLMj0FbSSbtdZ87DdvdhwTglp rQZQ== X-Gm-Message-State: ALyK8tKMuhSRsGr49pE90h2lWB4+eidnynRY8oEXsrhzXXn78VWQFYEdtJbHEO0hSD0i+g== X-Received: by 10.195.11.131 with SMTP id ei3mr13643781wjd.102.1467293397955; Thu, 30 Jun 2016 06:29:57 -0700 (PDT) Received: from localhost (host81-140-212-11.range81-140.btcentralplus.com. [81.140.212.11]) by smtp.gmail.com with ESMTPSA id cx8sm2671056wjb.37.2016.06.30.06.29.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Jun 2016 06:29:57 -0700 (PDT) Date: Thu, 30 Jun 2016 14:29:49 +0100 From: Andrew Burgess To: gcc-patches@gcc.gnu.org, Joern Wolfgang Rennecke , rdsandiford@googlemail.com Subject: Re: [PATCH 2/2] gcc/genrecog: Don't warn for missing mode on special predicates Message-ID: <20160630132949.GP8823@embecosm.com> References: <65124582452f1e6ba9f95992684363b0ae5ef0be.1465946922.git.andrew.burgess@embecosm.com> <87bn32tjer.fsf@googlemail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87bn32tjer.fsf@googlemail.com> X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] User-Agent: Mutt/1.6.1 (2016-04-27) X-IsSubscribed: yes * Richard Sandiford [2016-06-15 19:07:56 +0100]: > Andrew Burgess 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 > > --- > > 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 for taking the time to review and provide feedback. Sorry it has take a while to get around to this patch again. I've updated the patch inline with your feedback. How's this? Thanks, Andrew --- gcc/genrecog: Don't warn for missing mode on special predicates 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}. In genrecog, when validating a SET pattern, there is already a special case for 'address_operand' which is a special predicate, however, other special predicates fall through to the code which checks for incorrect use of VOIDmode. This commit adds a new function for detecting special predicates, and then generalises the check in validate_pattern so that mode checking is skipped for all special predicates. gcc/ChangeLog: * genrecog.c (special_predicate_operand_p): New function. (predicate_name): Move function. (validate_pattern): Don't warn about missing mode for all define_special_predicate predicates. --- gcc/ChangeLog | 7 +++++++ gcc/genrecog.c | 50 +++++++++++++++++++++++++++++++++++--------------- 2 files changed, 42 insertions(+), 15 deletions(-) diff --git a/gcc/genrecog.c b/gcc/genrecog.c index a9f5a4a..7c56225 100644 --- a/gcc/genrecog.c +++ b/gcc/genrecog.c @@ -463,6 +463,38 @@ constraints_supported_in_insn_p (rtx insn) || GET_CODE (insn) == DEFINE_PEEPHOLE2); } +/* Return the name of the predicate matched by MATCH_RTX. */ + +static const char * +predicate_name (rtx match_rtx) +{ + if (GET_CODE (match_rtx) == MATCH_SCRATCH) + return "scratch_operand"; + else + return XSTR (match_rtx, 1); +} + +/* Return true if OPERAND is a MATCH_OPERAND using a special predicate + function. */ + +static bool +special_predicate_operand_p (rtx operand) +{ + if (GET_CODE (operand) == MATCH_OPERAND) + { + const char *pred_name = predicate_name (operand); + if (pred_name[0] != 0) + { + const struct pred_data *pred; + + pred = lookup_predicate (pred_name); + return pred->special; + } + } + + return false; +} + /* Check for various errors in PATTERN, which is part of INFO. SET is nonnull for a destination, and is the complete set pattern. SET_CODE is '=' for normal sets, and '+' within a context that @@ -651,10 +683,9 @@ validate_pattern (rtx pattern, md_rtx_info *info, rtx set, int set_code) dmode = GET_MODE (dest); smode = GET_MODE (src); - /* 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")) + /* Mode checking is not performed for special predicates. */ + if (special_predicate_operand_p (src) + || special_predicate_operand_p (dest)) ; /* The operands of a SET must have the same mode unless one @@ -3788,17 +3819,6 @@ operator < (const pattern_pos &e1, const pattern_pos &e2) return diff < 0; } -/* Return the name of the predicate matched by MATCH_RTX. */ - -static const char * -predicate_name (rtx match_rtx) -{ - if (GET_CODE (match_rtx) == MATCH_SCRATCH) - return "scratch_operand"; - else - return XSTR (match_rtx, 1); -} - /* Add new decisions to S that check whether the rtx at position POS matches PATTERN. Return the state that is reached in that case. TOP_PATTERN is the overall pattern, as passed to match_pattern_1. */