From patchwork Mon Jun 23 06:56:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhenqiang Chen X-Patchwork-Id: 32320 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f199.google.com (mail-ie0-f199.google.com [209.85.223.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C92982055C for ; Mon, 23 Jun 2014 06:57:21 +0000 (UTC) Received: by mail-ie0-f199.google.com with SMTP id rd18sf42072753iec.2 for ; Sun, 22 Jun 2014 23:57:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mailing-list:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:sender :delivered-to:mime-version:date:message-id:subject:from:to :x-original-sender:x-original-authentication-results:content-type; bh=fl6Q3uhIcJeBXEGGfCSMlNFzAcORc5RsWo/4OSY13mY=; b=aAlbhMuEu41HlN4Q99SViE7pc+yZQJpUuskNZjvHAddfGbZRt7Ji17TFlyQnkIjT3Y 9EBbI8kGJgaPSw6qRK4FwJuuTEfKUGSpgCeO614FYXW2eUbFZtjFOIVMJs50lSk9d0WZ bexyy10GfQyFSQKA/5RsYWsKX55jhrp/9PY57kDQ4AXJfmcQaPRIXwz5ZBCYp5w8rlF4 1OQwKEHsVm/ib7JdvWL4X8QCU6lVS4eg6zPy+gkTBwGqVaR3mlNKRrjWdUESqfcrx/G4 XPPMogM0Vq+29s3BxhVuMAZ8AGKaLhLgDWbnrAxl/CrIaniyEUtjWuDarDtClxJWy/Au lyww== X-Gm-Message-State: ALoCoQlC6UujOBxy9sEZOFFQtxJl8LFjoUtXiPgDbD9CHqEMp9i20AaP1fBmRq/nefrk7MkArorY X-Received: by 10.182.246.7 with SMTP id xs7mr8294610obc.15.1403506641185; Sun, 22 Jun 2014 23:57:21 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.16.173 with SMTP id 42ls1798374qgb.62.gmail; Sun, 22 Jun 2014 23:57:21 -0700 (PDT) X-Received: by 10.221.44.73 with SMTP id uf9mr17816219vcb.9.1403506641105; Sun, 22 Jun 2014 23:57:21 -0700 (PDT) Received: from mail-ve0-x22f.google.com (mail-ve0-x22f.google.com [2607:f8b0:400c:c01::22f]) by mx.google.com with ESMTPS id or9si8500493vcb.81.2014.06.22.23.57.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 22 Jun 2014 23:57:21 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c01::22f as permitted sender) client-ip=2607:f8b0:400c:c01::22f; Received: by mail-ve0-f175.google.com with SMTP id jx11so5647775veb.6 for ; Sun, 22 Jun 2014 23:57:21 -0700 (PDT) X-Received: by 10.221.5.1 with SMTP id oe1mr17802643vcb.10.1403506640991; Sun, 22 Jun 2014 23:57:20 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp109811vcb; Sun, 22 Jun 2014 23:57:20 -0700 (PDT) X-Received: by 10.68.193.100 with SMTP id hn4mr25905859pbc.50.1403506639955; Sun, 22 Jun 2014 23:57:19 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id gq8si20469639pbc.50.2014.06.22.23.57.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Jun 2014 23:57:19 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-370786-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 5645 invoked by alias); 23 Jun 2014 06:57:07 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 5617 invoked by uid 89); 23 Jun 2014 06:57:04 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-lb0-f170.google.com Received: from mail-lb0-f170.google.com (HELO mail-lb0-f170.google.com) (209.85.217.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 23 Jun 2014 06:56:37 +0000 Received: by mail-lb0-f170.google.com with SMTP id 10so3946665lbg.29 for ; Sun, 22 Jun 2014 23:56:33 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.152.6.131 with SMTP id b3mr15812442laa.9.1403506593672; Sun, 22 Jun 2014 23:56:33 -0700 (PDT) Received: by 10.112.13.36 with HTTP; Sun, 22 Jun 2014 23:56:33 -0700 (PDT) Date: Mon, 23 Jun 2014 14:56:33 +0800 Message-ID: Subject: [PATCH, 1/10] two hooks for conditional compare (ccmp) From: Zhenqiang Chen To: "gcc-patches@gcc.gnu.org" X-IsSubscribed: yes X-Original-Sender: zhenqiang.chen@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c01::22f as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 Hi, The patch adds two hooks for backends to generate conditional compare instructions. * gen_ccmp_first is for the first compare. * gen_ccmp_next is for for the following compares. The patch is separated from https://gcc.gnu.org/ml/gcc-patches/2014-02/msg01407.html. And the original discussion about the hooks was in thread: https://gcc.gnu.org/ml/gcc-patches/2013-10/msg02601.html OK for trunk? Thanks! -Zhenqiang ChangeLog: 2014-06-23 Zhenqiang Chen * doc/md.texi (ccmp): Add description about conditional compare instruction pattern. (TARGET_GEN_CCMP_FIRST): Define. (TARGET_GEN_CCMP_NEXT): Define. * doc/tm.texi.in (TARGET_GEN_CCMP_FIRST, TARGET_GEN_CCMP_NEXT): New. * target.def (gen_ccmp_first, gen_ccmp_first): Add two new hooks. (loop_unroll_adjust, diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi index e17ffca..988c288 100644 --- a/gcc/doc/md.texi +++ b/gcc/doc/md.texi @@ -6216,6 +6216,42 @@ A typical @code{ctrap} pattern looks like "@dots{}") @end smallexample +@cindex @code{ccmp} instruction pattern +@item @samp{ccmp} +Conditional compare instruction. Operand 2 and 5 are RTLs which perform +two comparisons. Operand 1 is AND or IOR, which operates on the result of +operand 2 and 5. +It uses recursive method to support more than two compares. e.g. + + CC0 = CMP (a, b); + CC1 = CCMP (NE (CC0, 0), CMP (e, f)); + ... + CCn = CCMP (NE (CCn-1, 0), CMP (...)); + +Two target hooks are used to generate conditional compares. GEN_CCMP_FISRT +is used to generate the first CMP. And GEN_CCMP_NEXT is used to generate the +following CCMPs. Operand 1 is AND or IOR. Operand 3 is the result of +GEN_CCMP_FISRT or a previous GEN_CCMP_NEXT. Operand 2 is NE. +Operand 4, 5 and 6 is another compare expression. + +A typical CCMP pattern looks like + +@smallexample +(define_insn "*ccmp_and_ior" + [(set (match_operand 0 "dominant_cc_register" "") + (compare + (match_operator 1 + (match_operator 2 "comparison_operator" + [(match_operand 3 "dominant_cc_register") + (const_int 0)]) + (match_operator 4 "comparison_operator" + [(match_operand 5 "register_operand") + (match_operand 6 "compare_operand"])) + (const_int 0)))] + "" + "@dots{}") +@end smallexample + @cindex @code{prefetch} instruction pattern @item @samp{prefetch} diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index c272630..93f7c74 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -11021,6 +11021,23 @@ This target hook is required only when the target has several different modes and they have different conditional execution capability, such as ARM. @end deftypefn +@deftypefn {Target Hook} rtx TARGET_GEN_CCMP_FIRST (int @var{code}, rtx @var{op0}, rtx @var{op1}) +This function emits a comparison insn for the first of a sequence of + conditional comparisions. It returns a comparison expression appropriate + for passing to @code{gen_ccmp_next} or to @code{cbranch_optab}. + @code{unsignedp} is used when converting @code{op0} and @code{op1}'s mode. +@end deftypefn + +@deftypefn {Target Hook} rtx TARGET_GEN_CCMP_NEXT (rtx @var{prev}, int @var{cmp_code}, rtx @var{op0}, rtx @var{op1}, int @var{bit_code}) +This function emits a conditional comparison within a sequence of + conditional comparisons. The @code{prev} expression is the result of a + prior call to @code{gen_ccmp_first} or @code{gen_ccmp_next}. It may return + @code{NULL} if the combination of @code{prev} and this comparison is + not supported, otherwise the result must be appropriate for passing to + @code{gen_ccmp_next} or @code{cbranch_optab}. @code{bit_code} + is AND or IOR, which is the op on the two compares. +@end deftypefn + @deftypefn {Target Hook} unsigned TARGET_LOOP_UNROLL_ADJUST (unsigned @var{nunroll}, struct loop *@var{loop}) This target hook returns a new value for the number of times @var{loop} should be unrolled. The parameter @var{nunroll} is the number of times diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index dd72b98..e49f8f5 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -8107,6 +8107,10 @@ build_type_attribute_variant (@var{mdecl}, @hook TARGET_HAVE_CONDITIONAL_EXECUTION +@hook TARGET_GEN_CCMP_FIRST + +@hook TARGET_GEN_CCMP_NEXT + @hook TARGET_LOOP_UNROLL_ADJUST @defmac POWI_MAX_MULTS diff --git a/gcc/target.def b/gcc/target.def index e455211..6bbb907 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -2320,6 +2320,27 @@ modes and they have different conditional execution capability, such as ARM.", bool, (void), default_have_conditional_execution) +DEFHOOK +(gen_ccmp_first, + "This function emits a comparison insn for the first of a sequence of\n\ + conditional comparisions. It returns a comparison expression appropriate\n\ + for passing to @code{gen_ccmp_next} or to @code{cbranch_optab}.\n\ + @code{unsignedp} is used when converting @code{op0} and @code{op1}'s mode.", + rtx, (int code, rtx op0, rtx op1), + NULL) + +DEFHOOK +(gen_ccmp_next, + "This function emits a conditional comparison within a sequence of\n\ + conditional comparisons. The @code{prev} expression is the result of a\n\:q + prior call to @code{gen_ccmp_first} or @code{gen_ccmp_next}. It may return\n\ + @code{NULL} if the combination of @code{prev} and this comparison is\n\ + not supported, otherwise the result must be appropriate for passing to\n\ + @code{gen_ccmp_next} or @code{cbranch_optab}. @code{bit_code}\n\ + is AND or IOR, which is the op on the two compares.", + rtx, (rtx prev, int cmp_code, rtx op0, rtx op1, int bit_code), + NULL) + /* Return a new value for loop unroll size. */ DEFHOOK