From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 56266 invoked by alias); 6 Jul 2016 19:43:19 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 55703 invoked by uid 89); 6 Jul 2016 19:43:18 -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=PATTERN, 2.5.1, INFO X-HELO: mail-wm0-f49.google.com Received: from mail-wm0-f49.google.com (HELO mail-wm0-f49.google.com) (74.125.82.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 06 Jul 2016 19:43:07 +0000 Received: by mail-wm0-f49.google.com with SMTP id f126so185742320wma.1 for ; Wed, 06 Jul 2016 12:43:07 -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=06eSO96Oz4B8AGOzCWFU2jhIR/30xonWVmv+ERooUoQ=; b=TokV0gXVr2luYHqLeVyqhQQ7IgN8hJKjJAScYka+KM/KSpyO0O1z6no7ViFzAMihyp GiQ+7BQlt2d5TbX+1a7K6mLnDZtWiwe4UHeu++ktjVTcE7JGX+EvpAS/S3yH2IZr6bKm YxOAnYcXK8komdVt55PcyFbkbLNmNx1VnXBwXlweXGorMJBLXrD2jKUYf3AKzfTNHDWI nM8gcwl+xc00Ck9PMjS5AC4febWoaw408fF/clblD4lEBfRxhnwaGQEZYSYzxLxCrjSC TZMypkA9GZAArZVqcyhSl5csaWxi9uxUXxekfXg2QhMqax8hZchcmQOJv+IMW2gi0qRX HWxg== X-Gm-Message-State: ALyK8tJDu5jbSTPI8Fqd+2lt29YD63Iri3kEH94DxOHXvn1mKOH4oCUek3j7aXO4n6fYmQ== X-Received: by 10.28.140.202 with SMTP id o193mr23984990wmd.55.1467834184366; Wed, 06 Jul 2016 12:43:04 -0700 (PDT) Received: from localhost (host81-140-212-11.range81-140.btcentralplus.com. [81.140.212.11]) by smtp.gmail.com with ESMTPSA id cx8sm47704wjb.37.2016.07.06.12.43.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Jul 2016 12:43:03 -0700 (PDT) Date: Wed, 06 Jul 2016 19:43:00 -0000 From: Andrew Burgess To: gcc-patches@gcc.gnu.org, Joern Wolfgang Rennecke , richard.sandiford@arm.com Subject: Re: [PATCH 2/2] gcc/genrecog: Don't warn for missing mode on special predicates Message-ID: <20160706194254.GF10229@embecosm.com> References: <65124582452f1e6ba9f95992684363b0ae5ef0be.1465946922.git.andrew.burgess@embecosm.com> <87bn32tjer.fsf@googlemail.com> <20160630132949.GP8823@embecosm.com> <878txhlrhj.fsf@e105548-lin.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <878txhlrhj.fsf@e105548-lin.cambridge.arm.com> X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] User-Agent: Mutt/1.6.1 (2016-04-27) X-IsSubscribed: yes X-SW-Source: 2016-07/txt/msg00272.txt.bz2 * Richard Sandiford [2016-07-04 09:47:20 +0100]: > Andrew Burgess writes: > > +/* 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; > > Thanks for removing the duplicated error check for unknown predicates. > I think that error gets reported later though, so we should check for > null here: > > return pred && pred->special; > > OK with that change, thanks. Richard, Thanks for the continued reviews. I don't have GCC write access, so I wonder if you would be willing to commit this patch for me please. There's an updated version below that includes the latest change you suggested. Many thanks, Andrew --- [PATCH] 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..056798c 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 != NULL && 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. */ -- 2.5.1