[v2,2/5] PRU: Simplify machine description

Message ID 20200503161204.18245-3-dimitar@dinux.eu
State New
Headers show
Series
  • Updates for PRU backend
Related show

Commit Message

Dimitar Dimitrov May 3, 2020, 4:12 p.m.
Use the new @insn syntax for simpler gen_* invocation.

gcc/ChangeLog:

2020-05-03  Dimitar Dimitrov  <dimitar@dinux.eu>

	* config/pru/pru.c (pru_emit_doloop): Use new gen_doloop_end_internal
	and gen_doloop_begin_internal.
	(pru_reorg_loop): Use gen_pruloop with mode.
	* config/pru/pru.md: Use new @insn syntax.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>

---
 gcc/config/pru/pru.c  | 44 +++++++++++++------------------------------
 gcc/config/pru/pru.md |  6 +++---
 2 files changed, 16 insertions(+), 34 deletions(-)

-- 
2.20.1

Patch

diff --git a/gcc/config/pru/pru.c b/gcc/config/pru/pru.c
index e20b41c6d1f..45b18ed6fe4 100644
--- a/gcc/config/pru/pru.c
+++ b/gcc/config/pru/pru.c
@@ -2345,26 +2345,14 @@  pru_emit_doloop (rtx *operands, int is_end)
 
   tag = GEN_INT (cfun->machine->doloop_tags - 1);
   machine_mode opmode = GET_MODE (operands[0]);
+  gcc_assert (opmode == HImode || opmode == SImode);
+
   if (is_end)
-    {
-      if (opmode == HImode)
-	emit_jump_insn (gen_doloop_end_internalhi (operands[0],
-						   operands[1], tag));
-      else if (opmode == SImode)
-	emit_jump_insn (gen_doloop_end_internalsi (operands[0],
-						   operands[1], tag));
-      else
-	gcc_unreachable ();
-    }
+    emit_jump_insn (gen_doloop_end_internal (opmode, operands[0],
+					     operands[1], tag));
   else
-    {
-      if (opmode == HImode)
-	emit_insn (gen_doloop_begin_internalhi (operands[0], operands[0], tag));
-      else if (opmode == SImode)
-	emit_insn (gen_doloop_begin_internalsi (operands[0], operands[0], tag));
-      else
-	gcc_unreachable ();
-    }
+    emit_insn (gen_doloop_begin_internal (opmode, operands[0],
+					  operands[0], tag));
 }
 
 
@@ -2607,6 +2595,7 @@  pru_reorg_loop (rtx_insn *insns)
 	/* Case (1) or (2).  */
 	rtx_code_label *repeat_label;
 	rtx label_ref;
+	rtx loop_rtx;
 
 	/* Create a new label for the repeat insn.  */
 	repeat_label = gen_label_rtx ();
@@ -2616,23 +2605,16 @@  pru_reorg_loop (rtx_insn *insns)
 	   will utilize an internal for the PRU core LOOP register.  */
 	label_ref = gen_rtx_LABEL_REF (VOIDmode, repeat_label);
 	machine_mode loop_mode = GET_MODE (loop->begin->loop_count);
-	if (loop_mode == HImode)
-	  emit_insn_before (gen_pruloophi (loop->begin->loop_count, label_ref),
-			    loop->begin->insn);
-	else if (loop_mode == SImode)
-	  {
-	    rtx loop_rtx = gen_pruloopsi (loop->begin->loop_count, label_ref);
-	    emit_insn_before (loop_rtx, loop->begin->insn);
-	  }
-	else if (loop_mode == VOIDmode)
+	if (loop_mode == VOIDmode)
 	  {
 	    gcc_assert (CONST_INT_P (loop->begin->loop_count));
 	    gcc_assert (UBYTE_INT ( INTVAL (loop->begin->loop_count)));
-	    rtx loop_rtx = gen_pruloopsi (loop->begin->loop_count, label_ref);
-	    emit_insn_before (loop_rtx, loop->begin->insn);
+	    loop_mode = SImode;
 	  }
-	else
-	  gcc_unreachable ();
+	gcc_assert (loop_mode == HImode || loop_mode == SImode);
+	loop_rtx = gen_pruloop (loop_mode, loop->begin->loop_count, label_ref);
+	emit_insn_before (loop_rtx, loop->begin->insn);
+
 	delete_insn (loop->begin->insn);
 
 	/* Insert the repeat label before the first doloop_end.
diff --git a/gcc/config/pru/pru.md b/gcc/config/pru/pru.md
index 67624e2aac0..2f1bc21f025 100644
--- a/gcc/config/pru/pru.md
+++ b/gcc/config/pru/pru.md
@@ -887,7 +887,7 @@  (define_insn "cbranch_qbbx_<BIT_TEST:code><EQS0:mode><EQS1:mode><EQD:mode>4"
 ;; This insn is volatile because we'd like it to stay in its original
 ;; position, just before the loop header.  If it stays there, we might
 ;; be able to convert it into a "loop" insn.
-(define_insn "doloop_begin_internal<mode>"
+(define_insn "@doloop_begin_internal<mode>"
   [(set (match_operand:HISI 0 "register_operand" "=r")
 	(unspec_volatile:HISI
 	 [(match_operand:HISI 1 "reg_or_ubyte_operand" "rI")
@@ -909,7 +909,7 @@  (define_expand "doloop_begin"
 ; Note: "JUMP_INSNs and CALL_INSNs are not allowed to have any output
 ; reloads;".  Hence this insn must be prepared for a counter that is
 ; not a register.
-(define_insn "doloop_end_internal<mode>"
+(define_insn "@doloop_end_internal<mode>"
   [(set (pc)
 	(if_then_else (ne (match_operand:HISI 0 "nonimmediate_operand" "+r,*m")
 			  (const_int 1))
@@ -951,7 +951,7 @@  (define_expand "doloop_end"
   DONE;
 })
 
-(define_insn "pruloop<mode>"
+(define_insn "@pruloop<mode>"
   [(set (reg:HISI LOOPCNTR_REGNUM)
 	(unspec:HISI [(match_operand:HISI 0 "reg_or_ubyte_operand" "rI")
 		    (label_ref (match_operand 1))]