diff mbox

[3/5] INSN_LOCATION takes an rtx_insn

Message ID 1410211766-39396-4-git-send-email-dmalcolm@redhat.com
State New
Headers show

Commit Message

David Malcolm Sept. 8, 2014, 9:29 p.m. UTC
gcc/
	* rtl.h (INSN_LOCATION): Strengthen param from const_rtx to
	const rtx_insn *, and from rtx to rtx_insn * for the other
	overloaded variant.
	(RTL_LOCATION): Add a checked cast to rtx_insn * when invoking
	INSN_LOCATION, since we know INSN_P holds.
	(insn_line): Strengthen param from const_rtx to const rtx_insn *.
	(insn_file): Likewise.
	(insn_scope): Likewise.
	(insn_location): Likewise.

	* config/mips/mips.c (mips16_gp_pseudo_reg): Strengthen local
	"insn" from rtx to rtx_insn *, introducing a new local rtx "set"
	for the result of gen_load_const_gp.
	* config/rs6000/rs6000-protos.h (output_call): Strengthen first
	param from rtx to rtx_insn *.
	* config/rs6000/rs6000.c (output_call): Likewise.
	* dwarf2out.c (dwarf2out_var_location): Likewise for local "prev",
	introducing a checked cast to rtx_sequence * and use of the insn
	method.
	* emit-rtl.c (emit_copy_of_insn_after): Strengthen both params
	from rtx to rtx_insn *.
	(insn_scope): Strengthen param from const_rtx to const rtx_insn *.
	(insn_line): Likewise.
	(insn_file): Likewise.
	(insn_location): Likewise.
	* emit-rtl.h (emit_copy_of_insn_after): Strengthen both params
	from rtx to rtx_insn *.
	* print-rtl.c (print_rtx): Introduce local "in_insn" via a checked
	cast, using it for calls to INSN_HAS_LOCATION and insn_location.
	* recog.c (peep2_attempt): Introduce local rtx_insn * "peepinsn"
	via a checked cast.
	* reorg.c (relax_delay_slots): Strengthen locals named "after"
	from rtx to rtx_insn *; use methods of "pat" for type-safety.
---
 gcc/config/mips/mips.c            |  5 ++---
 gcc/config/rs6000/rs6000-protos.h |  2 +-
 gcc/config/rs6000/rs6000.c        |  2 +-
 gcc/dwarf2out.c                   |  5 +++--
 gcc/emit-rtl.c                    | 10 +++++-----
 gcc/emit-rtl.h                    |  2 +-
 gcc/print-rtl.c                   |  6 ++++--
 gcc/recog.c                       |  3 ++-
 gcc/reorg.c                       | 12 ++++++------
 gcc/rtl.h                         | 15 ++++++++-------
 10 files changed, 33 insertions(+), 29 deletions(-)

Comments

Jeff Law Sept. 9, 2014, 2:48 p.m. UTC | #1
On 09/08/14 15:29, David Malcolm wrote:
> gcc/
> 	* rtl.h (INSN_LOCATION): Strengthen param from const_rtx to
> 	const rtx_insn *, and from rtx to rtx_insn * for the other
> 	overloaded variant.
> 	(RTL_LOCATION): Add a checked cast to rtx_insn * when invoking
> 	INSN_LOCATION, since we know INSN_P holds.
> 	(insn_line): Strengthen param from const_rtx to const rtx_insn *.
> 	(insn_file): Likewise.
> 	(insn_scope): Likewise.
> 	(insn_location): Likewise.
>
> 	* config/mips/mips.c (mips16_gp_pseudo_reg): Strengthen local
> 	"insn" from rtx to rtx_insn *, introducing a new local rtx "set"
> 	for the result of gen_load_const_gp.
> 	* config/rs6000/rs6000-protos.h (output_call): Strengthen first
> 	param from rtx to rtx_insn *.
> 	* config/rs6000/rs6000.c (output_call): Likewise.
> 	* dwarf2out.c (dwarf2out_var_location): Likewise for local "prev",
> 	introducing a checked cast to rtx_sequence * and use of the insn
> 	method.
> 	* emit-rtl.c (emit_copy_of_insn_after): Strengthen both params
> 	from rtx to rtx_insn *.
> 	(insn_scope): Strengthen param from const_rtx to const rtx_insn *.
> 	(insn_line): Likewise.
> 	(insn_file): Likewise.
> 	(insn_location): Likewise.
> 	* emit-rtl.h (emit_copy_of_insn_after): Strengthen both params
> 	from rtx to rtx_insn *.
> 	* print-rtl.c (print_rtx): Introduce local "in_insn" via a checked
> 	cast, using it for calls to INSN_HAS_LOCATION and insn_location.
> 	* recog.c (peep2_attempt): Introduce local rtx_insn * "peepinsn"
> 	via a checked cast.
> 	* reorg.c (relax_delay_slots): Strengthen locals named "after"
> 	from rtx to rtx_insn *; use methods of "pat" for type-safety.
OK.
Jeff
diff mbox

Patch

diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index f9713c1..c8d48c4 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -2932,7 +2932,6 @@  mips16_gp_pseudo_reg (void)
 {
   if (cfun->machine->mips16_gp_pseudo_rtx == NULL_RTX)
     {
-      rtx insn;
       rtx_insn *scan;
 
       cfun->machine->mips16_gp_pseudo_rtx = gen_reg_rtx (Pmode);
@@ -2943,8 +2942,8 @@  mips16_gp_pseudo_reg (void)
       while (NEXT_INSN (scan) && !INSN_P (NEXT_INSN (scan)))
 	scan = NEXT_INSN (scan);
 
-      insn = gen_load_const_gp (cfun->machine->mips16_gp_pseudo_rtx);
-      insn = emit_insn_after (insn, scan);
+      rtx set = gen_load_const_gp (cfun->machine->mips16_gp_pseudo_rtx);
+      rtx_insn *insn = emit_insn_after (set, scan);
       INSN_LOCATION (insn) = 0;
 
       pop_topmost_sequence ();
diff --git a/gcc/config/rs6000/rs6000-protos.h b/gcc/config/rs6000/rs6000-protos.h
index b3a1a0a..cf58f46 100644
--- a/gcc/config/rs6000/rs6000-protos.h
+++ b/gcc/config/rs6000/rs6000-protos.h
@@ -211,7 +211,7 @@  extern void (*rs6000_target_modify_macros_ptr) (bool, HOST_WIDE_INT,
 						HOST_WIDE_INT);
 
 #if TARGET_MACHO
-char *output_call (rtx, rtx *, int, int);
+char *output_call (rtx_insn *, rtx *, int, int);
 #endif
 
 #ifdef NO_DOLLAR_IN_LABEL
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 6370304..8afc94e 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -28929,7 +28929,7 @@  get_prev_label (tree function_name)
    CALL_DEST is the routine we are calling.  */
 
 char *
-output_call (rtx insn, rtx *operands, int dest_operand_number,
+output_call (rtx_insn *insn, rtx *operands, int dest_operand_number,
 	     int cookie_operand_number)
 {
   static char buf[256];
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 23a80d8..0d5896c 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -21435,7 +21435,8 @@  dwarf2out_var_location (rtx_insn *loc_note)
     {
       struct call_arg_loc_node *ca_loc
 	= ggc_cleared_alloc<call_arg_loc_node> ();
-      rtx prev = prev_real_insn (loc_note), x;
+      rtx_insn *prev = prev_real_insn (loc_note);
+      rtx x;
       ca_loc->call_arg_loc_note = loc_note;
       ca_loc->next = NULL;
       ca_loc->label = last_label;
@@ -21445,7 +21446,7 @@  dwarf2out_var_location (rtx_insn *loc_note)
 			  && GET_CODE (PATTERN (prev)) == SEQUENCE
 			  && CALL_P (XVECEXP (PATTERN (prev), 0, 0)))));
       if (!CALL_P (prev))
-	prev = XVECEXP (PATTERN (prev), 0, 0);
+	prev = as_a <rtx_sequence *> (PATTERN (prev))->insn (0);
       ca_loc->tail_call_p = SIBLING_CALL_P (prev);
       x = get_call_rtx_from (PATTERN (prev));
       if (x)
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index 0acdd08..34bf271 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -6144,7 +6144,7 @@  init_emit_once (void)
    Care updating of libcall regions if present.  */
 
 rtx_insn *
-emit_copy_of_insn_after (rtx insn, rtx after)
+emit_copy_of_insn_after (rtx_insn *insn, rtx_insn *after)
 {
   rtx_insn *new_rtx;
   rtx link;
@@ -6258,28 +6258,28 @@  curr_insn_location (void)
 
 /* Return lexical scope block insn belongs to.  */
 tree
-insn_scope (const_rtx insn)
+insn_scope (const rtx_insn *insn)
 {
   return LOCATION_BLOCK (INSN_LOCATION (insn));
 }
 
 /* Return line number of the statement that produced this insn.  */
 int
-insn_line (const_rtx insn)
+insn_line (const rtx_insn *insn)
 {
   return LOCATION_LINE (INSN_LOCATION (insn));
 }
 
 /* Return source file of the statement that produced this insn.  */
 const char *
-insn_file (const_rtx insn)
+insn_file (const rtx_insn *insn)
 {
   return LOCATION_FILE (INSN_LOCATION (insn));
 }
 
 /* Return expanded location of the statement that produced this insn.  */
 expanded_location
-insn_location (const_rtx insn)
+insn_location (const rtx_insn *insn)
 {
   return expand_location (INSN_LOCATION (insn));
 }
diff --git a/gcc/emit-rtl.h b/gcc/emit-rtl.h
index d0b1bce..7cba866 100644
--- a/gcc/emit-rtl.h
+++ b/gcc/emit-rtl.h
@@ -66,7 +66,7 @@  extern rtx copy_insn_1 (rtx);
 extern rtx copy_insn (rtx);
 extern rtx_insn *copy_delay_slot_insn (rtx_insn *);
 extern rtx gen_int_mode (HOST_WIDE_INT, enum machine_mode);
-extern rtx_insn *emit_copy_of_insn_after (rtx, rtx);
+extern rtx_insn *emit_copy_of_insn_after (rtx_insn *, rtx_insn *);
 extern void set_reg_attrs_from_value (rtx, rtx);
 extern void set_reg_attrs_for_parm (rtx, rtx);
 extern void set_reg_attrs_for_decl_rtl (tree t, rtx x);
diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c
index 935145b..80ec96e 100644
--- a/gcc/print-rtl.c
+++ b/gcc/print-rtl.c
@@ -392,12 +392,14 @@  print_rtx (const_rtx in_rtx)
 	if (i == 4 && INSN_P (in_rtx))
 	  {
 #ifndef GENERATOR_FILE
+	    const rtx_insn *in_insn = as_a <const rtx_insn *> (in_rtx);
+
 	    /*  Pretty-print insn locations.  Ignore scoping as it is mostly
 		redundant with line number information and do not print anything
 		when there is no location information available.  */
-	    if (INSN_HAS_LOCATION (as_a <const rtx_insn *> (in_rtx)))
+	    if (INSN_HAS_LOCATION (in_insn))
 	      {
-		expanded_location xloc = insn_location (in_rtx);
+		expanded_location xloc = insn_location (in_insn);
 		fprintf (outfile, " %s:%i", xloc.file, xloc.line);
 	      }
 #endif
diff --git a/gcc/recog.c b/gcc/recog.c
index d07a57a..6ccd84e 100644
--- a/gcc/recog.c
+++ b/gcc/recog.c
@@ -3323,9 +3323,10 @@  peep2_attempt (basic_block bb, rtx uncast_insn, int match_len, rtx_insn *attempt
   eh_note = find_reg_note (peep2_insn_data[i].insn, REG_EH_REGION, NULL_RTX);
 
   /* Replace the old sequence with the new.  */
+  rtx_insn *peepinsn = as_a <rtx_insn *> (peep2_insn_data[i].insn);
   last = emit_insn_after_setloc (attempt,
 				 peep2_insn_data[i].insn,
-				 INSN_LOCATION (peep2_insn_data[i].insn));
+				 INSN_LOCATION (peepinsn));
   before_try = PREV_INSN (insn);
   delete_insn_chain (insn, peep2_insn_data[i].insn, false);
 
diff --git a/gcc/reorg.c b/gcc/reorg.c
index 400a20f..18820f0 100644
--- a/gcc/reorg.c
+++ b/gcc/reorg.c
@@ -3297,7 +3297,7 @@  relax_delay_slots (rtx_insn *first)
 	  && JUMP_P (next)
 	  && PATTERN (next) == PATTERN (delay_insn))
 	{
-	  rtx after;
+	  rtx_insn *after;
 	  int i;
 
 	  /* Delete the RETURN and just execute the delay list insns.
@@ -3321,8 +3321,8 @@  relax_delay_slots (rtx_insn *first)
 	  gcc_assert (GET_CODE (pat) == SEQUENCE);
 	  add_insn_after (delay_insn, trial, NULL);
 	  after = delay_insn;
-	  for (i = 1; i < XVECLEN (pat, 0); i++)
-	    after = emit_copy_of_insn_after (XVECEXP (pat, 0, i), after);
+	  for (i = 1; i < pat->len (); i++)
+	    after = emit_copy_of_insn_after (pat->insn (i), after);
 	  delete_scheduled_jump (delay_insn);
 	  continue;
 	}
@@ -3424,7 +3424,7 @@  relax_delay_slots (rtx_insn *first)
 #endif
 	  )
 	{
-	  rtx after;
+	  rtx_insn *after;
 	  int i;
 
 	  /* All this insn does is execute its delay list and jump to the
@@ -3450,8 +3450,8 @@  relax_delay_slots (rtx_insn *first)
 	  gcc_assert (GET_CODE (pat) == SEQUENCE);
 	  add_insn_after (delay_insn, trial, NULL);
 	  after = delay_insn;
-	  for (i = 1; i < XVECLEN (pat, 0); i++)
-	    after = emit_copy_of_insn_after (XVECEXP (pat, 0, i), after);
+	  for (i = 1; i < pat->len (); i++)
+	    after = emit_copy_of_insn_after (pat->insn (i), after);
 	  delete_scheduled_jump (delay_insn);
 	  continue;
 	}
diff --git a/gcc/rtl.h b/gcc/rtl.h
index fae3b5d..0f36c48 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -1369,12 +1369,12 @@  inline rtx& PATTERN (rtx insn)
   return XEXP (insn, 3);
 }
 
-inline unsigned int INSN_LOCATION (const_rtx insn)
+inline unsigned int INSN_LOCATION (const rtx_insn *insn)
 {
   return XUINT (insn, 4);
 }
 
-inline unsigned int& INSN_LOCATION (rtx insn)
+inline unsigned int& INSN_LOCATION (rtx_insn *insn)
 {
   return XUINT (insn, 4);
 }
@@ -1386,7 +1386,8 @@  inline bool INSN_HAS_LOCATION (const rtx_insn *insn)
 
 /* LOCATION of an RTX if relevant.  */
 #define RTL_LOCATION(X) (INSN_P (X) ? \
-			 INSN_LOCATION (X) : UNKNOWN_LOCATION)
+			 INSN_LOCATION (as_a <rtx_insn *> (X)) \
+			 : UNKNOWN_LOCATION)
 
 /* Code number of instruction, from when it was recognized.
    -1 means this instruction has not been recognized yet.  */
@@ -2644,10 +2645,10 @@  extern rtx_insn *next_cc0_user (rtx);
 extern rtx_insn *prev_cc0_setter (rtx);
 
 /* In emit-rtl.c  */
-extern int insn_line (const_rtx);
-extern const char * insn_file (const_rtx);
-extern tree insn_scope (const_rtx);
-extern expanded_location insn_location (const_rtx);
+extern int insn_line (const rtx_insn *);
+extern const char * insn_file (const rtx_insn *);
+extern tree insn_scope (const rtx_insn *);
+extern expanded_location insn_location (const rtx_insn *);
 extern location_t prologue_location, epilogue_location;
 
 /* In jump.c */