]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cris: Enable *movsi_internal to set condition codes.
authorHans-Peter Nilsson <hp@axis.com>
Thu, 30 Jan 2020 07:34:31 +0000 (08:34 +0100)
committerHans-Peter Nilsson <hp@axis.com>
Sat, 9 May 2020 01:54:10 +0000 (03:54 +0200)
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<setcc><setnz><setnzvc>"): Rename from
"*movsi_internal".  Correct contents of, and rename attribute
"cc" to "cc<cccc><ccnz><ccnzvc>".

gcc/ChangeLog
gcc/config/cris/cris.md

index 31241541b6742aec0532dea8d15423b0eb9b79c6..3fa24c7dd8b05f3dcc8bc4db735541927ab88fd7 100644 (file)
        depending on CC_NZmode vs. CCmode.
        ("*s<nzvccond:code><mode>"): Simlar from "*s<ocond:code>", 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<setcc><setnz><setnzvc>"): Rename from
+       "*movsi_internal".  Correct contents of, and rename attribute
+       "cc" to "cc<cccc><ccnz><ccnzvc>".
 
 2020-05-08  Vladimir Makarov  <vmakarov@redhat.com>
 
index 362d63f6dc5b3d77cb3b4d1f0f4f34013e3ef475..bee9e9735d02d9c6cb1905a23df9266bfcd3674f 100644 (file)
   (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.
        (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")))
 \f
 ;; Iterator definitions.
 
                       (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")
      }
 })
 
-(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<setcc><setnz><setnzvc>"
   [(set
     (match_operand:SI 0 "nonimmediate_operand"
                      "=r,r, r,Q>,r,Q>,g,r,r,g,rQ>,x,  m,x")
     }
 }
   [(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<cccc><ccnz><ccnzvc>"
+            "*,*,none,none,*,none,none,*,*,none,none,none,none,none")])
 \f
 ;; FIXME: See movsi.