[cond-optab] Convert crx

Paolo Bonzini bonzini@gnu.org
Thu Mar 26 09:03:00 GMT 2009


This is easy, because crx already uses a cbranch pattern for
everything.  We add cstoresi4 and remove the corresponding dead
code.

2009-03-23  Paolo Bonzini  <bonzini@gnu.org>

        * config/crx/crx.md (cstore<mode>4): New.
        (cmp<mode>, bCOND_internal, b<code>, s<code>): Delete.
	(sCOND_internal): Use ordered_comparison_operator.
	* config/crx/crx.c (crx_compare_op0, crx_compare_op1,
	crx_expand_compare, crx_expand_branch, crx_expand_scond): Delete.
	* config/crx/crx.h (crx_compare_op0, crx_compare_op1): Delete.
	* config/crx/crx-protos.h (crx_expand_compare, crx_expand_branch,
	crx_expand_scond): Delete.

Index: gcc/config/crx/crx.c
===================================================================
--- gcc/config/crx/crx.c	(branch cond-optab)
+++ gcc/config/crx/crx.c	(working copy)
@@ -124,10 +124,6 @@ static enum machine_mode output_memory_r
 /* Table of machine attributes.  */
 const struct attribute_spec crx_attribute_table[];
 
-/* Test and compare insns use these globals to generate branch insns.  */
-rtx crx_compare_op0 = NULL_RTX;
-rtx crx_compare_op1 = NULL_RTX;
-
 /*****************************************************************************/
 /* TARGETM FUNCTION PROTOTYPES						     */
 /*****************************************************************************/
@@ -1217,43 +1213,6 @@ crx_expand_movmem (rtx dstbase, rtx srcb
   return 1;
 }
 
-rtx
-crx_expand_compare (enum rtx_code code, enum machine_mode mode)
-{
-  rtx op0, op1, cc_reg, ret;
-
-  op0 = crx_compare_op0;
-  op1 = crx_compare_op1;
-
-  /* Emit the compare that writes into CC_REGNUM) */
-  cc_reg = gen_rtx_REG (CCmode, CC_REGNUM);
-  ret = gen_rtx_COMPARE (CCmode, op0, op1);
-  emit_insn (gen_rtx_SET (VOIDmode, cc_reg, ret));
-  /* debug_rtx (get_last_insn ()); */
-
-  /* Return the rtx for using the result in CC_REGNUM */
-  return gen_rtx_fmt_ee (code, mode, cc_reg, const0_rtx);
-}
-
-void
-crx_expand_branch (enum rtx_code code, rtx label)
-{
-  rtx tmp = crx_expand_compare (code, VOIDmode);
-  tmp = gen_rtx_IF_THEN_ELSE (VOIDmode, tmp,
-			      gen_rtx_LABEL_REF (VOIDmode, label),
-			      pc_rtx);
-  emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx, tmp));
-  /* debug_rtx (get_last_insn ()); */
-}
-
-void
-crx_expand_scond (enum rtx_code code, rtx dest)
-{
-  rtx tmp = crx_expand_compare (code, GET_MODE (dest));
-  emit_move_insn (dest, tmp);
-  /* debug_rtx (get_last_insn ()); */
-}
-
 static void
 mpushpop_str (char *stringbuffer, const char *mnemonic, char *mask)
 {
Index: gcc/config/crx/crx.h
===================================================================
--- gcc/config/crx/crx.h	(branch cond-optab)
+++ gcc/config/crx/crx.h	(working copy)
@@ -522,11 +522,4 @@ struct cumulative_args
 
 #define FUNCTION_MODE	QImode
 
-/*****************************************************************************/
-/* EXTERNAL DECLARATIONS FOR VARIABLES DEFINED IN CRX.C			     */
-/*****************************************************************************/
-
-extern rtx crx_compare_op0;    /* operand 0 for comparisons */
-extern rtx crx_compare_op1;    /* operand 1 for comparisons */
-
 #endif /* ! GCC_CRX_H */
Index: gcc/config/crx/crx.md
===================================================================
--- gcc/config/crx/crx.md	(branch cond-optab)
+++ gcc/config/crx/crx.md	(working copy)
@@ -535,18 +535,18 @@
   [(set_attr "length" "6")]
 )
 
-;;  Compare Instructions
 
-(define_expand "cmp<mode>"
+;;  Scond Instructions
+
+(define_expand "cstore<mode>4"
   [(set (reg:CC CC_REGNUM)
-	(compare:CC (match_operand:CRXIM 0 "register_operand" "")
-		    (match_operand:CRXIM 1 "nonmemory_operand" "")))]
+	(compare:CC (match_operand:CRXIM 2 "register_operand" "")
+		    (match_operand:CRXIM 3 "nonmemory_operand" "")))
+   (set (match_operand:SI 0 "register_operand")
+	(match_operator:SI 1 "ordered_comparison_operator"
+	[(reg:CC CC_REGNUM) (const_int 0)]))]
+  ""
   ""
-  {
-    crx_compare_op0 = operands[0];
-    crx_compare_op1 = operands[1];
-    DONE;
-  }
 )
 
 (define_insn "cmp<mode>_internal"
@@ -558,48 +570,9 @@
   [(set_attr "length" "2,<lImmArith>")]
 )
 
-;;  Conditional Branch Instructions
-
-(define_expand "b<code>"
-  [(set (pc)
-	(if_then_else (any_cond (reg:CC CC_REGNUM)
-				(const_int 0))
-		      (label_ref (match_operand 0 ""))
-		      (pc)))]
-  ""
-  {
-    crx_expand_branch (<CODE>, operands[0]);
-    DONE;
-  }
-)
-
-(define_insn "bCOND_internal"
-  [(set (pc)
-	(if_then_else (match_operator 0 "comparison_operator"
-			[(reg:CC CC_REGNUM)
-			 (const_int 0)])
-		      (label_ref (match_operand 1 ""))
-		      (pc)))]
-  ""
-  "b%d0\t%l1"
-  [(set_attr "length" "6")]
-)
-
-;;  Scond Instructions
-
-(define_expand "s<code>"
-  [(set (match_operand:SI 0 "register_operand")
-  	(any_cond:SI (reg:CC CC_REGNUM) (const_int 0)))]
-  ""
-  {
-    crx_expand_scond (<CODE>, operands[0]);
-    DONE;
-  }
-)
-
 (define_insn "sCOND_internal"
   [(set (match_operand:SI 0 "register_operand" "=r")
-	(match_operator:SI 1 "comparison_operator"
+	(match_operator:SI 1 "ordered_comparison_operator"
 	  [(reg:CC CC_REGNUM) (const_int 0)]))]
   ""
   "s%d1\t%0"
Index: gcc/config/crx/crx-protos.h
===================================================================
--- gcc/config/crx/crx-protos.h	(branch cond-optab)
+++ gcc/config/crx/crx-protos.h	(working copy)
@@ -62,10 +62,6 @@ extern void crx_print_operand (FILE *, r
 extern void crx_print_operand_address (FILE *, rtx);
 
 /* Misc functions called from crx.md.  */
-extern rtx crx_expand_compare (enum rtx_code, enum machine_mode);
-extern void crx_expand_branch (enum rtx_code, rtx);
-extern void crx_expand_scond (enum rtx_code, rtx);
-
 extern void crx_expand_movmem_single (rtx, rtx, rtx, rtx, rtx, unsigned HOST_WIDE_INT *);
 extern int crx_expand_movmem (rtx, rtx, rtx, rtx);
 #endif /* RTX_CODE */



More information about the Gcc-patches mailing list