From: Hans-Peter Nilsson Date: Thu, 30 Jan 2020 07:34:31 +0000 (+0100) Subject: cris: Enable *movsi_internal to set condition codes. X-Git-Tag: upstream/12.2.0~16726 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a82c9fb3f70ddc750cba82589894d473de48016e;p=platform%2Fupstream%2Fgcc.git cris: Enable *movsi_internal to set condition codes. 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 ("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". --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3124154..3fa24c7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -102,6 +102,15 @@ depending on CC_NZmode vs. CCmode. ("*s"): Simlar from "*s", over NZVCUSE. Remove FIXME. + ("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". 2020-05-08 Vladimir Makarov diff --git a/gcc/config/cris/cris.md b/gcc/config/cris/cris.md index 362d63f..bee9e97 100644 --- a/gcc/config/cris/cris.md +++ b/gcc/config/cris/cris.md @@ -117,10 +117,16 @@ (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 @@ (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 @@ (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_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 @@ } } [(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.