diff mbox

[1/5] Add recog_constrain_insn

Message ID 874mv2bvnt.fsf@e105548-lin.cambridge.arm.com
State New
Headers show

Commit Message

Richard Sandiford Oct. 17, 2014, 2:47 p.m. UTC
This patch just adds a new utility function called recog_constrain_insn,
to go alongside the existing recog_constrain_insn_cached.

Note that the extract_insn in lra.c wasn't used when checking is disabled.
The function just moved on to the next instruction straight away.

Richard


gcc/
	* recog.h (extract_constrain_insn): Declare.
	* recog.c (extract_constrain_insn): New function.
	* lra.c (check_rtl): Use it.
	* postreload.c (reload_cse_simplify_operands): Likewise.
	* reg-stack.c (check_asm_stack_operands): Likewise.
	(subst_asm_stack_regs): Likewise.
	* regcprop.c (copyprop_hardreg_forward_1): Likewise.
	* regrename.c (build_def_use): Likewise.
	* sel-sched.c (get_reg_class): Likewise.
	* config/arm/arm.c (note_invalid_constants): Likewise.
	* config/s390/predicates.md (execute_operation): Likewise.

Comments

Vladimir Makarov Oct. 21, 2014, 2:56 p.m. UTC | #1
On 10/17/2014 10:47 AM, Richard Sandiford wrote:
> This patch just adds a new utility function called recog_constrain_insn,
> to go alongside the existing recog_constrain_insn_cached.
>
> Note that the extract_insn in lra.c wasn't used when checking is disabled.
> The function just moved on to the next instruction straight away.
>

The RA parts are ok for me.   Thanks, Richard.
>
> gcc/
> 	* recog.h (extract_constrain_insn): Declare.
> 	* recog.c (extract_constrain_insn): New function.
> 	* lra.c (check_rtl): Use it.
> 	* postreload.c (reload_cse_simplify_operands): Likewise.
> 	* reg-stack.c (check_asm_stack_operands): Likewise.
> 	(subst_asm_stack_regs): Likewise.
> 	* regcprop.c (copyprop_hardreg_forward_1): Likewise.
> 	* regrename.c (build_def_use): Likewise.
> 	* sel-sched.c (get_reg_class): Likewise.
> 	* config/arm/arm.c (note_invalid_constants): Likewise.
> 	* config/s390/predicates.md (execute_operation): Likewise.
>
>
Jeff Law Oct. 21, 2014, 3:41 p.m. UTC | #2
On 10/17/14 14:47, Richard Sandiford wrote:
> This patch just adds a new utility function called recog_constrain_insn,
> to go alongside the existing recog_constrain_insn_cached.
>
> Note that the extract_insn in lra.c wasn't used when checking is disabled.
> The function just moved on to the next instruction straight away.
>
> Richard
>
>
> gcc/
> 	* recog.h (extract_constrain_insn): Declare.
> 	* recog.c (extract_constrain_insn): New function.
> 	* lra.c (check_rtl): Use it.
> 	* postreload.c (reload_cse_simplify_operands): Likewise.
> 	* reg-stack.c (check_asm_stack_operands): Likewise.
> 	(subst_asm_stack_regs): Likewise.
> 	* regcprop.c (copyprop_hardreg_forward_1): Likewise.
> 	* regrename.c (build_def_use): Likewise.
> 	* sel-sched.c (get_reg_class): Likewise.
> 	* config/arm/arm.c (note_invalid_constants): Likewise.
> 	* config/s390/predicates.md (execute_operation): Likewise.
OK.  I'm going to assume passing "reload_completed" is equivalent to the 
prior code where we passed the constant "1" to constrain_operands.

Jeff
diff mbox

Patch

Index: gcc/recog.h
===================================================================
--- gcc/recog.h	2014-09-18 11:40:31.223690858 +0100
+++ gcc/recog.h	2014-10-17 15:44:50.219398486 +0100
@@ -134,6 +134,7 @@  extern void add_clobbers (rtx, int);
 extern int added_clobbers_hard_reg_p (int);
 extern void insn_extract (rtx_insn *);
 extern void extract_insn (rtx_insn *);
+extern void extract_constrain_insn (rtx_insn *insn);
 extern void extract_constrain_insn_cached (rtx_insn *);
 extern void extract_insn_cached (rtx_insn *);
 extern void preprocess_constraints (int, int, const char **,
Index: gcc/recog.c
===================================================================
--- gcc/recog.c	2014-09-22 08:36:23.889794255 +0100
+++ gcc/recog.c	2014-10-17 15:44:50.219398486 +0100
@@ -2110,6 +2110,17 @@  extract_insn_cached (rtx_insn *insn)
   recog_data.insn = insn;
 }
 
+/* Do uncached extract_insn, constrain_operands and complain about failures.
+   This should be used when extracting a pre-existing constrained instruction
+   if the caller wants to know which alternative was chosen.  */
+void
+extract_constrain_insn (rtx_insn *insn)
+{
+  extract_insn (insn);
+  if (!constrain_operands (reload_completed))
+    fatal_insn_not_found (insn);
+}
+
 /* Do cached extract_insn, constrain_operands and complain about failures.
    Used by insn_attrtab.  */
 void
Index: gcc/lra.c
===================================================================
--- gcc/lra.c	2014-09-26 16:05:57.868394574 +0100
+++ gcc/lra.c	2014-10-17 15:44:50.219398486 +0100
@@ -1919,8 +1919,9 @@  check_rtl (bool final_p)
       {
 	if (final_p)
 	  {
-	    extract_insn (insn);
-	    lra_assert (constrain_operands (1));
+#ifdef ENABLED_CHECKING
+	    extract_constrain_insn (insn);
+#endif
 	    continue;
 	  }
 	/* LRA code is based on assumption that all addresses can be
Index: gcc/postreload.c
===================================================================
--- gcc/postreload.c	2014-08-26 12:09:02.182959856 +0100
+++ gcc/postreload.c	2014-10-17 15:44:50.219398486 +0100
@@ -401,15 +401,11 @@  reload_cse_simplify_operands (rtx_insn *
   /* Array of alternatives, sorted in order of decreasing desirability.  */
   int *alternative_order;
 
-  extract_insn (insn);
+  extract_constrain_insn (insn);
 
   if (recog_data.n_alternatives == 0 || recog_data.n_operands == 0)
     return 0;
 
-  /* Figure out which alternative currently matches.  */
-  if (! constrain_operands (1))
-    fatal_insn_not_found (insn);
-
   alternative_reject = XALLOCAVEC (int, recog_data.n_alternatives);
   alternative_nregs = XALLOCAVEC (int, recog_data.n_alternatives);
   alternative_order = XALLOCAVEC (int, recog_data.n_alternatives);
Index: gcc/reg-stack.c
===================================================================
--- gcc/reg-stack.c	2014-09-18 11:40:31.307689884 +0100
+++ gcc/reg-stack.c	2014-10-17 15:44:50.219398486 +0100
@@ -469,8 +469,7 @@  check_asm_stack_operands (rtx_insn *insn
 
   /* Find out what the constraints require.  If no constraint
      alternative matches, this asm is malformed.  */
-  extract_insn (insn);
-  constrain_operands (1);
+  extract_constrain_insn (insn);
 
   preprocess_constraints (insn);
 
@@ -2016,8 +2015,7 @@  subst_asm_stack_regs (rtx_insn *insn, st
   /* Find out what the constraints required.  If no constraint
      alternative matches, that is a compiler bug: we should have caught
      such an insn in check_asm_stack_operands.  */
-  extract_insn (insn);
-  constrain_operands (1);
+  extract_constrain_insn (insn);
 
   preprocess_constraints (insn);
   const operand_alternative *op_alt = which_op_alt ();
Index: gcc/regcprop.c
===================================================================
--- gcc/regcprop.c	2014-10-13 08:02:41.225135081 +0100
+++ gcc/regcprop.c	2014-10-17 15:44:50.227398391 +0100
@@ -762,9 +762,7 @@  copyprop_hardreg_forward_1 (basic_block
 	}
 
       set = single_set (insn);
-      extract_insn (insn);
-      if (! constrain_operands (1))
-	fatal_insn_not_found (insn);
+      extract_constrain_insn (insn);
       preprocess_constraints (insn);
       const operand_alternative *op_alt = which_op_alt ();
       n_ops = recog_data.n_operands;
@@ -865,9 +863,7 @@  copyprop_hardreg_forward_1 (basic_block
 		}
 	      /* We need to re-extract as validate_change clobbers
 		 recog_data.  */
-	      extract_insn (insn);
-	      if (! constrain_operands (1))
-		fatal_insn_not_found (insn);
+	      extract_constrain_insn (insn);
 	      preprocess_constraints (insn);
 	    }
 
@@ -893,9 +889,7 @@  copyprop_hardreg_forward_1 (basic_block
 		    }
 		  /* We need to re-extract as validate_change clobbers
 		     recog_data.  */
-		  extract_insn (insn);
-		  if (! constrain_operands (1))
-		    fatal_insn_not_found (insn);
+		  extract_constrain_insn (insn);
 		  preprocess_constraints (insn);
 		}
 	    }
Index: gcc/regrename.c
===================================================================
--- gcc/regrename.c	2014-08-26 12:08:57.679011819 +0100
+++ gcc/regrename.c	2014-10-17 15:44:50.227398391 +0100
@@ -1564,9 +1564,7 @@  build_def_use (basic_block bb)
 	     to be marked unrenamable or even cause us to abort the entire
 	     basic block.  */
 
-	  extract_insn (insn);
-	  if (! constrain_operands (1))
-	    fatal_insn_not_found (insn);
+	  extract_constrain_insn (insn);
 	  preprocess_constraints (insn);
 	  const operand_alternative *op_alt = which_op_alt ();
 	  n_ops = recog_data.n_operands;
Index: gcc/sel-sched.c
===================================================================
--- gcc/sel-sched.c	2014-09-18 11:40:31.163691553 +0100
+++ gcc/sel-sched.c	2014-10-17 15:44:50.227398391 +0100
@@ -994,9 +994,7 @@  get_reg_class (rtx_insn *insn)
 {
   int i, n_ops;
 
-  extract_insn (insn);
-  if (! constrain_operands (1))
-    fatal_insn_not_found (insn);
+  extract_constrain_insn (insn);
   preprocess_constraints (insn);
   n_ops = recog_data.n_operands;
 
Index: gcc/config/arm/arm.c
===================================================================
--- gcc/config/arm/arm.c	2014-09-22 08:36:24.541786033 +0100
+++ gcc/config/arm/arm.c	2014-10-17 15:44:50.215398533 +0100
@@ -17022,10 +17022,7 @@  note_invalid_constants (rtx_insn *insn,
 {
   int opno;
 
-  extract_insn (insn);
-
-  if (!constrain_operands (1))
-    fatal_insn_not_found (insn);
+  extract_constrain_insn (insn);
 
   if (recog_data.n_alternatives == 0)
     return;
Index: gcc/config/s390/predicates.md
===================================================================
--- gcc/config/s390/predicates.md	2014-09-12 08:26:02.847292053 +0100
+++ gcc/config/s390/predicates.md	2014-10-17 15:44:50.219398486 +0100
@@ -406,8 +406,7 @@  (define_special_predicate "execute_opera
   if (icode < 0)
     return false;
 
-  extract_insn (insn);
-  constrain_operands (1);
+  extract_constrain_insn (insn);
 
   return which_alternative >= 0;
 })