This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[cond-optab] Convert stormy16


This is also quite simple, just a little churn from removing the
xstormy16_compare_op* variables.

Paolo

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

	* config/stormy16/stormy16-protos.h (xstormy16_emit_cbranch):
	Add two arguments.
	* config/stormy16/stormy16.h (xstormy16_compare_op0,
	xstormy16_compare_op1): Delete.
	* config/stormy16/stormy16.c (xstormy16_compare_op0,
	xstormy16_compare_op1): Delete.
	(xstormy16_emit_cbranch): Get op0/op1 from the new arguments.
	Adjust calls.
	* config/stormy16/stormy16.md (cbranchsi4, cbranchhi4): New.
	(cmphi, cmpsi, bCC): Remove.

Index: gcc/config/stormy16/stormy16-protos.h
===================================================================
--- gcc/config/stormy16/stormy16-protos.h	(branch cond-optab)
+++ gcc/config/stormy16/stormy16-protos.h	(working copy)
@@ -48,7 +48,7 @@ extern rtx xstormy16_function_value (con
 #endif
 
 #ifdef RTX_CODE
-extern void xstormy16_emit_cbranch (enum rtx_code, rtx);
+extern void xstormy16_emit_cbranch (enum rtx_code, rtx, rtx, rtx);
 extern char *xstormy16_output_cbranch_hi (rtx, const char *, int, rtx);
 extern char *xstormy16_output_cbranch_si (rtx, const char *, int, rtx);
 extern int xstormy16_mode_dependent_address_p (rtx);
Index: gcc/config/stormy16/stormy16.c
===================================================================
--- gcc/config/stormy16/stormy16.c	(branch cond-optab)
+++ gcc/config/stormy16/stormy16.c	(working copy)
@@ -61,11 +61,6 @@ static bool xstormy16_rtx_costs (rtx, in
 static int xstormy16_address_cost (rtx, bool);
 static bool xstormy16_return_in_memory (const_tree, const_tree);
 
-/* Define the information needed to generate branch and scc insns.  This is
-   stored from the compare operation.  */
-struct rtx_def * xstormy16_compare_op0;
-struct rtx_def * xstormy16_compare_op1;
-
 static GTY(()) section *bss100_section;
 
 /* Compute a (partial) cost for rtx X.  Return true if the complete
@@ -139,10 +134,8 @@ xstormy16_address_cost (rtx x, bool spee
 /* Emit a branch of kind CODE to location LOC.  */
 
 void
-xstormy16_emit_cbranch (enum rtx_code code, rtx loc)
+xstormy16_emit_cbranch (enum rtx_code code, rtx op0, rtx op1, rtx loc)
 {
-  rtx op0 = xstormy16_compare_op0;
-  rtx op1 = xstormy16_compare_op1;
   rtx condition_rtx, loc_ref, branch, cy_clobber;
   rtvec vec;
   enum machine_mode mode;
@@ -159,10 +152,10 @@ xstormy16_emit_cbranch (enum rtx_code co
 
       if (gt_p)
 	lab = gen_label_rtx ();
-      xstormy16_emit_cbranch (unsigned_p ? LTU : LT, gt_p ? lab : loc);
+      xstormy16_emit_cbranch (unsigned_p ? LTU : LT, op0, op1, gt_p ? lab : loc);
       /* This should be generated as a comparison against the temporary
 	 created by the previous insn, but reload can't handle that.  */
-      xstormy16_emit_cbranch (gt_p ? NE : EQ, loc);
+      xstormy16_emit_cbranch (gt_p ? NE : EQ, op0, op1, loc);
       if (gt_p)
 	emit_label (lab);
       return;
@@ -171,6 +164,7 @@ xstormy16_emit_cbranch (enum rtx_code co
 	   && (code == NE || code == EQ)
 	   && op1 != const0_rtx)
     {
+      rtx op0_word, op1_word;
       rtx lab = NULL_RTX;
       int num_words = GET_MODE_BITSIZE (mode) / BITS_PER_WORD;
       int i;
@@ -180,17 +174,17 @@ xstormy16_emit_cbranch (enum rtx_code co
 
       for (i = 0; i < num_words - 1; i++)
 	{
-	  xstormy16_compare_op0 = simplify_gen_subreg (word_mode, op0, mode,
-						      i * UNITS_PER_WORD);
-	  xstormy16_compare_op1 = simplify_gen_subreg (word_mode, op1, mode,
-						      i * UNITS_PER_WORD);
-	  xstormy16_emit_cbranch (NE, code == EQ ? lab : loc);
+	  op0_word = simplify_gen_subreg (word_mode, op0, mode,
+					  i * UNITS_PER_WORD);
+	  op1_word = simplify_gen_subreg (word_mode, op1, mode,
+					  i * UNITS_PER_WORD);
+	  xstormy16_emit_cbranch (NE, op0_word, op1_word, code == EQ ? lab : loc);
 	}
-      xstormy16_compare_op0 = simplify_gen_subreg (word_mode, op0, mode,
-						  i * UNITS_PER_WORD);
-      xstormy16_compare_op1 = simplify_gen_subreg (word_mode, op1, mode,
-						  i * UNITS_PER_WORD);
-      xstormy16_emit_cbranch (code, loc);
+      op0_word = simplify_gen_subreg (word_mode, op0, mode,
+				      i * UNITS_PER_WORD);
+      op1_word = simplify_gen_subreg (word_mode, op1, mode,
+				      i * UNITS_PER_WORD);
+      xstormy16_emit_cbranch (code, op0_word, op1_word, loc);
 
       if (code == EQ)
 	emit_label (lab);
Index: gcc/config/stormy16/stormy16.h
===================================================================
--- gcc/config/stormy16/stormy16.h	(branch cond-optab)
+++ gcc/config/stormy16/stormy16.h	(working copy)
@@ -803,11 +803,4 @@ do  {						\
    is responsible for updating the value of MORE (typically by (MORE)--).  */
 /* #define MD_SCHED_VARIABLE_ISSUE (FILE, VERBOSE, INSN, MORE) */
 
-
-/* Define the information needed to generate branch and scc insns.  This is
-   stored from the compare operation.  Note that we can't use "rtx" here
-   since it hasn't been defined!  */
-
-extern struct rtx_def *xstormy16_compare_op0, *xstormy16_compare_op1;
-
 /* End of xstormy16.h */
Index: gcc/config/stormy16/stormy16.md
===================================================================
--- gcc/config/stormy16/stormy16.md	(branch cond-optab)
+++ gcc/config/stormy16/stormy16.md	(working copy)
@@ -736,40 +736,7 @@
 				    operands[0], operands[2], operands[3]);"
   [(set_attr "length" "6,10")
    (set_attr "psw_operand" "clobber,clobber")])
-
-;; ::::::::::::::::::::
-;; ::
-;; :: Comparisons
-;; ::
-;; ::::::::::::::::::::
-
-;; Note, we store the operands in the comparison insns, and use them later
-;; when generating the branch or scc operation.
-
-;; First the routines called by the machine independent part of the compiler
-(define_expand "cmphi"
-  [(set (cc0)
-        (compare (match_operand:HI 0 "register_operand" "")
-  		 (match_operand:HI 1 "nonmemory_operand" "")))]
-  ""
-  {
-    xstormy16_compare_op0 = operands[0];
-    xstormy16_compare_op1 = operands[1];
-    DONE;
-  })
 
-; There are no real SImode comparisons, but some can be emulated
-; by performing a SImode subtract and looking at the condition flags.
-(define_expand "cmpsi"
-  [(set (cc0)
-        (compare (match_operand:SI 0 "register_operand" "")
-  		 (match_operand:SI 1 "nonmemory_operand" "")))]
-  ""
-  {
-    xstormy16_compare_op0 = operands[0];
-    xstormy16_compare_op1 = operands[1];
-    DONE;
-  })
 
 ;; ::::::::::::::::::::
 ;; ::
@@ -777,55 +744,35 @@
 ;; ::
 ;; ::::::::::::::::::::
 
-(define_expand "beq"
-  [(use (match_operand 0 "" ""))]
-  ""
-  { xstormy16_emit_cbranch (EQ, operands[0]); DONE; })
-
-(define_expand "bne"
-  [(use (match_operand 0 "" ""))]
-  ""
-  { xstormy16_emit_cbranch (NE, operands[0]); DONE; })
-
-(define_expand "bge"
-  [(use (match_operand 0 "" ""))]
-  ""
-  { xstormy16_emit_cbranch (GE, operands[0]); DONE; })
-
-(define_expand "bgt"
-  [(use (match_operand 0 "" ""))]
-  ""
-  { xstormy16_emit_cbranch (GT, operands[0]); DONE; })
-
-(define_expand "ble"
-  [(use (match_operand 0 "" ""))]
-  ""
-  { xstormy16_emit_cbranch (LE, operands[0]); DONE; })
-
-(define_expand "blt"
-  [(use (match_operand 0 "" ""))]
-  ""
-  { xstormy16_emit_cbranch (LT, operands[0]); DONE; })
-
-(define_expand "bgeu"
-  [(use (match_operand 0 "" ""))]
-  ""
-  { xstormy16_emit_cbranch (GEU, operands[0]); DONE; })
-
-(define_expand "bgtu"
-  [(use (match_operand 0 "" ""))]
-  ""
-  { xstormy16_emit_cbranch (GTU, operands[0]); DONE; })
-
-(define_expand "bleu"
-  [(use (match_operand 0 "" ""))]
+(define_expand "cbranchhi4"
+  [(set (pc)
+	(if_then_else (match_operator 0 "comparison_operator"
+				      [(match_operand:HI 1 "register_operand" "")
+				       (match_operand:HI 2 "nonmemory_operand" "")])
+		      (label_ref (match_operand 3 "" ""))
+		      (pc)))
+   (clobber (reg:BI CARRY_REG))]
   ""
-  { xstormy16_emit_cbranch (LEU, operands[0]); DONE; })
+  {
+  xstormy16_emit_cbranch (GET_CODE (operands[0]), operands[1], operands[2],
+			  operands[3]);
+  DONE;
+})
 
-(define_expand "bltu"
-  [(use (match_operand 0 "" ""))]
+(define_expand "cbranchsi4"
+  [(set (pc)
+	(if_then_else (match_operator 0 "comparison_operator"
+				      [(match_operand:SI 1 "register_operand" "")
+				       (match_operand:SI 2 "nonmemory_operand" "")])
+		      (label_ref (match_operand 3 "" ""))
+		      (pc)))
+   (clobber (reg:BI CARRY_REG))]
   ""
-  { xstormy16_emit_cbranch (LTU, operands[0]); DONE; })
+  {
+  xstormy16_emit_cbranch (GET_CODE (operands[0]), operands[1], operands[2],
+			  operands[3]);
+  DONE;
+})
 
 (define_insn "cbranchhi"
   [(set (pc)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]