From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 58853 invoked by alias); 12 Feb 2020 06:58:06 -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 58845 invoked by uid 89); 12 Feb 2020 06:58:05 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: smtp1.axis.com Received: from smtp1.axis.com (HELO smtp1.axis.com) (195.60.68.17) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 12 Feb 2020 06:58:03 +0000 IronPort-SDR: PPb3fVJR2fiIQ8yz3nCaOctlFdTjg2vr23EUO3hpQr9M3nzDkRqOIy5szHCFPtlBrr4QSYU7cn lidGWvOmQM+rZfBQO9W/08fm6I0ioL9NjoI8hAVptTn20F2zTwh6kr7HLGDhv6P143eLh72eOw 2A/AWstlTS6CVTQu/7fRT1lTEdmBqyz5v3htlsPVmT+i7krvCK1SSMu9tqUAREkFxfNYveipJJ 6vaSKm70Bab5jOjfESoG7TtxLPZo1j006EXqzh5lMrm/uLLojLedWrGbCDRX331ngOpP2h9mhD Rrs= Date: Wed, 12 Feb 2020 06:58:00 -0000 Message-ID: <202002120658.01C6w0rx026705@ignucius.se.axis.com> From: Hans-Peter Nilsson To: Subject: [cris-decc0 7/14] cris: Enable *movsi_internal to set condition codes. MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8BIT Return-Path: hp@axis.com X-IsSubscribed: yes X-SW-Source: 2020-02/txt/msg00701.txt.bz2 * config/cris/cris.md ("cc"): Comment on new use. ("cc_enabled"): New attribute. ("enabled"): Make default fall back to cc_enabled. ("setnz", "ccnz", "setnzvc", "ccnzvc", "setcc", "cccc"): New default_subst_attrs. ("setnz_subst", "setnzvc_subst", "setcc_subst"): New default_subst. ("*movsi_internal"): Rename from "*movsi_internal". Correct contents of, and rename attribute "cc" to "cc". Completion of, and first use of, the CRIS-specific parts of the condition-code-setting framework, making use of the define_subst machinery and the cmpelim optimization pass. This round, just moves in SImode. Note the re-use of the cc0 era "cc" attribute (tweaks needed). --- gcc/config/cris/cris.md | 61 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 5 deletions(-) diff --git a/gcc/config/cris/cris.md b/gcc/config/cris/cris.md index 362d63f6d..bee9e9735 100644 --- a/gcc/config/cris/cris.md +++ b/gcc/config/cris/cris.md @@ -117,10 +117,16 @@ (define_attr "slottable" "no,yes,has_slot,has_return_slot" (const_string "no")) ;; We also need attributes to sanely determine the condition code -;; state. - +;; state. This attribute isn't used as-is, just as a template, +;; effectively a dummy except in a substitution setting CRIS_CC0_REGNUM +;; to a specific value. (define_attr "cc" "none,clobber,normal" (const_string "normal")) +;; The attribute "_enabled" is appended to "cc", forming "cc_enabled" to +;; pick out certain alternatives when generating a useful +;; condition-code-setting. See the "enabled" attribute. +(define_attr "cc_enabled" "none,clobber,normal" (const_string "normal")) + ;; At the moment, this attribute is just used to help bb-reorder do its ;; work; the default 0 doesn't help it. Many insns have other lengths, ;; though none are shorter. @@ -147,7 +153,11 @@ (define_delay (eq_attr "slottable" "has_return_slot") (not (match_test "dead_or_set_regno_p (insn, CRIS_SRP_REGNUM)"))) (nil) (nil)]) -(define_attr "enabled" "no,yes" (const_string "yes")) +(define_attr "enabled" "no,yes" + (if_then_else + (eq_attr "cc_enabled" "normal") + (const_string "yes") + (const_string "no"))) ;; Iterator definitions. @@ -225,6 +235,44 @@ (define_code_attr xCC [(eq "CC") (ne "CC") (gtu "CC") (ltu "CC_NZVC") (geu "CC_NZVC") (leu "CC") (lt "CC") (ge "CC") (gt "CC_NZVC") (le "CC_NZVC")]) +;; Substitutions to describe condition-code settings. + +(define_subst_attr "setnz" "setnz_subst" "" "_setnz") +(define_subst_attr "ccnz" "setnz_subst" "" "_enabled") + +(define_subst "setnz_subst" + [(set (match_operand 0) + (match_operand 1)) + (clobber (reg:CC CRIS_CC0_REGNUM))] + "reload_completed" + [(set (reg:CC_NZ CRIS_CC0_REGNUM) + (compare:CC_NZ (match_dup 1) (const_int 0))) + (set (match_operand 0) (match_operand 1))]) + +(define_subst_attr "setnzvc" "setnzvc_subst" "" "_setnzvc") +(define_subst_attr "ccnzvc" "setnzvc_subst" "" "_enabled") + +(define_subst "setnzvc_subst" + [(set (match_operand 0) + (match_operand 1)) + (clobber (reg:CC CRIS_CC0_REGNUM))] + "reload_completed" + [(set (reg:CC_NZVC CRIS_CC0_REGNUM) + (compare:CC_NZVC (match_dup 1) (const_int 0))) + (set (match_operand 0) (match_operand 1))]) + +(define_subst_attr "setcc" "setcc_subst" "" "_setcc") +(define_subst_attr "cccc" "setcc_subst" "" "_enabled") + +(define_subst "setcc_subst" + [(set (match_operand 0) + (match_operand 1)) + (clobber (reg:CC CRIS_CC0_REGNUM))] + "reload_completed" + [(set (reg:CC CRIS_CC0_REGNUM) + (compare:CC (match_dup 1) (const_int 0))) + (set (match_operand 0) (match_operand 1))]) + ;; Operand and operator predicates. (include "predicates.md") @@ -495,7 +543,9 @@ (define_expand "movsi" } }) -(define_insn "*movsi_internal" +;; We provide CC, CC_NZ and CC_NZVC variants, as moves clear V and C +;; and the result is thus usable in a compare against 0. +(define_insn "*movsi_internal" [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r, r,Q>,r,Q>,g,r,r,g,rQ>,x, m,x") @@ -554,7 +604,8 @@ (define_insn "*movsi_internal" } } [(set_attr "slottable" "yes,yes,yes,yes,yes,yes,no,no,no,no,yes,yes,no,no") - (set_attr "cc" "*,*,*,*,*,*,*,*,*,*,none,none,none,none")]) + (set_attr "cc" + "*,*,none,none,*,none,none,*,*,none,none,none,none,none")]) ;; FIXME: See movsi. -- 2.11.0 brgds, H-P