diff mbox

trivial replacements for SET_INSN_DELETED and BLOCK_FOR_INSN as lhs

Message ID CABu31nPcHNhATj33+VXv8zWe48eqS=rNxwjJJ6M3KazqaCHLVQ@mail.gmail.com
State New
Headers show

Commit Message

Steven Bosscher April 1, 2013, 10:06 p.m. UTC
Hello,

The SET_INSN_DELETED vs. set_insn_deleted thing is just an incomplete cleanup.

Using set_block_for_insn instead of using BLOCK_FOR_INSN is the "proper" way.

So, mechanical replacements. If no-one objects and the usual
bootstrap+testing passes, I'll commit this later this week as obvious.

Ciao!
Steven
* basic-block.h (set_block_for_insn): Remove define.
	* rtl.h (BLOCK_FOR_INSN): Rename define to INSN_BASIC_BLOCK,
	reincarnate as static inline function.
	(set_block_for_insn): Reincarnate as static inline function.
	(SET_INSN_DELETED): Remove define.

	* emit-rtl.c (make_insn_raw): Use set_block_for_insn.
	(make_debug_insn_raw, make_jump_insn_raw, make_call_insn_raw,
	emit_note_before, emit_note_after, emit_jump_table_data,
	emit_note_copy, emit_note): Likewise.
	* cfgrtl.c (compute_bb_for_insn, free_bb_for_insn): Likewise.
	* bb-reorder.c (fix_crossing_unconditional_branches): Likewise.
	(insert_section_boundary_note): Likewise.
	* resource.c (init_resource_info, free_resource_info): Likewise.
	* sel-sched.c (move_nop_to_previous_block): Likewise.
	* config/c6x/c6x.c (gen_one_bundle): Likewise.

	* reload1.c (reload): Use set_insn_deleted instead of SET_INSN_DELETED.
	(delete_dead_insn): Likewise.
	* combine.c (try_combine, distribute_notes): Likewise.
	* lra.c (lra_set_insn_deleted): Likewise.
	* ifcvt.c (cond_exec_process_insns): Likewise.
	* recog.c (split_insn): Likewise.
	* config/pa/pa.c (pa_output_lbranch, pa_output_millicode_call,
	pa_output_call, pa_combine_instructions): Likewise.
	* config/sh/sh.c (split_branches): Likewise.

Comments

Eric Botcazou April 2, 2013, 9:17 a.m. UTC | #1
> Using set_block_for_insn instead of using BLOCK_FOR_INSN is the "proper"
> way.

Yes, but BLOCK_FOR_INSN as accessor around INSN_BASIC_BLOCK is ugly and a bit 
misleading.  Either keep BLOCK_FOR_INSN or make the full change (the number of 
occurrences of BLOCK_FOR_INSN in the back-ends is surprisingly very small).
Steven Bosscher April 2, 2013, 9:31 a.m. UTC | #2
On Tue, Apr 2, 2013 at 11:17 AM, Eric Botcazou wrote:
>> Using set_block_for_insn instead of using BLOCK_FOR_INSN is the "proper"
>> way.
>
> Yes, but BLOCK_FOR_INSN as accessor around INSN_BASIC_BLOCK is ugly and a bit
> misleading.

True, I don't like that bit very much myself, either. But I expected
more resistance for the full change ;-)


>  Either keep BLOCK_FOR_INSN or make the full change (the number of
> occurrences of BLOCK_FOR_INSN in the back-ends is surprisingly very small).

Right. OK if I call it get_block_for_insn() and make the replacements?

Ciao!
Steven
Eric Botcazou April 2, 2013, 9:44 a.m. UTC | #3
> True, I don't like that bit very much myself, either. But I expected
> more resistance for the full change ;-)

Possibly.  You might really want to wait until the end of the week. :-)

> Right. OK if I call it get_block_for_insn() and make the replacements?

get_block_for_insn will break formatting...  just block_for_insn I'd say.
diff mbox

Patch

Index: basic-block.h
===================================================================
--- basic-block.h	(revision 197322)
+++ basic-block.h	(working copy)
@@ -413,8 +413,6 @@  struct GTY(()) control_flow_graph {
 /* The two blocks that are always in the cfg.  */
 #define NUM_FIXED_BLOCKS (2)
 
-#define set_block_for_insn(INSN, BB)  (BLOCK_FOR_INSN (INSN) = BB)
-
 extern void compute_bb_for_insn (void);
 extern unsigned int free_bb_for_insn (void);
 extern void update_bb_for_insn (basic_block);
Index: rtl.h
===================================================================
--- rtl.h	(revision 197322)
+++ rtl.h	(working copy)
@@ -824,8 +824,24 @@  extern void rtl_check_failed_flag (const char *, c
 #define PREV_INSN(INSN)	XEXP (INSN, 1)
 #define NEXT_INSN(INSN)	XEXP (INSN, 2)
 
-#define BLOCK_FOR_INSN(INSN) XBBDEF (INSN, 3)
+/* The basic block for an insn (or note).
+   Should be set/read with set_block_for_insn/BLOCK_FOR_INSN.  */
+#define INSN_BASIC_BLOCK(INSN) XBBDEF (INSN, 3)
 
+/* Helper functions, to make debugging CFG changes easer.
+   BLOCK_FOR_INSN used to be a macro, hence the name in capitals.  */
+static inline void
+set_block_for_insn (rtx insn, basic_block bb)
+{
+  INSN_BASIC_BLOCK (insn) = bb;
+}
+
+static inline basic_block
+BLOCK_FOR_INSN (const_rtx insn)
+{
+  return INSN_BASIC_BLOCK (insn);
+}
+
 /* The body of an insn.  */
 #define PATTERN(INSN)	XEXP (INSN, 4)
 
@@ -946,7 +962,6 @@  extern const char * const reg_note_name[];
 /* Opaque data.  */
 #define NOTE_DATA(INSN)	        RTL_CHECKC1 (INSN, 4, NOTE)
 #define NOTE_DELETED_LABEL_NAME(INSN) XCSTR (INSN, 4, NOTE)
-#define SET_INSN_DELETED(INSN) set_insn_deleted (INSN);
 #define NOTE_BLOCK(INSN)	XCTREE (INSN, 4, NOTE)
 #define NOTE_EH_HANDLER(INSN)	XCINT (INSN, 4, NOTE)
 #define NOTE_BASIC_BLOCK(INSN)	XCBBDEF (INSN, 4, NOTE)
Index: emit-rtl.c
===================================================================
--- emit-rtl.c	(revision 197322)
+++ emit-rtl.c	(working copy)
@@ -3674,7 +3674,7 @@  make_insn_raw (rtx pattern)
   INSN_CODE (insn) = -1;
   REG_NOTES (insn) = NULL;
   INSN_LOCATION (insn) = curr_insn_location ();
-  BLOCK_FOR_INSN (insn) = NULL;
+  set_block_for_insn (insn, NULL);
 
 #ifdef ENABLE_RTL_CHECKING
   if (insn
@@ -3707,7 +3707,7 @@  make_debug_insn_raw (rtx pattern)
   INSN_CODE (insn) = -1;
   REG_NOTES (insn) = NULL;
   INSN_LOCATION (insn) = curr_insn_location ();
-  BLOCK_FOR_INSN (insn) = NULL;
+  set_block_for_insn (insn, NULL);
 
   return insn;
 }
@@ -3727,7 +3727,7 @@  make_jump_insn_raw (rtx pattern)
   REG_NOTES (insn) = NULL;
   JUMP_LABEL (insn) = NULL;
   INSN_LOCATION (insn) = curr_insn_location ();
-  BLOCK_FOR_INSN (insn) = NULL;
+  set_block_for_insn (insn, NULL);
 
   return insn;
 }
@@ -3747,7 +3747,7 @@  make_call_insn_raw (rtx pattern)
   REG_NOTES (insn) = NULL;
   CALL_INSN_FUNCTION_USAGE (insn) = NULL;
   INSN_LOCATION (insn) = curr_insn_location ();
-  BLOCK_FOR_INSN (insn) = NULL;
+  set_block_for_insn (insn, NULL);
 
   return insn;
 }
@@ -4239,7 +4239,7 @@  emit_note_before (enum insn_note subtype, rtx befo
   rtx note = rtx_alloc (NOTE);
   INSN_UID (note) = cur_insn_uid++;
   NOTE_KIND (note) = subtype;
-  BLOCK_FOR_INSN (note) = NULL;
+  set_block_for_insn (note, NULL);
   memset (&NOTE_DATA (note), 0, sizeof (NOTE_DATA (note)));
 
   add_insn_before (note, before, NULL);
@@ -4400,7 +4400,7 @@  emit_note_after (enum insn_note subtype, rtx after
   rtx note = rtx_alloc (NOTE);
   INSN_UID (note) = cur_insn_uid++;
   NOTE_KIND (note) = subtype;
-  BLOCK_FOR_INSN (note) = NULL;
+  set_block_for_insn (note, NULL);
   memset (&NOTE_DATA (note), 0, sizeof (NOTE_DATA (note)));
   add_insn_after (note, after, NULL);
   return note;
@@ -4823,7 +4823,7 @@  emit_jump_table_data (rtx table)
   rtx jump_table_data = rtx_alloc (JUMP_TABLE_DATA);
   INSN_UID (jump_table_data) = cur_insn_uid++;
   PATTERN (jump_table_data) = table;
-  BLOCK_FOR_INSN (jump_table_data) = NULL;
+  set_block_for_insn (jump_table_data, NULL);
   add_insn (jump_table_data);
   return jump_table_data;
 }
@@ -4852,7 +4852,7 @@  emit_note_copy (rtx orig)
   INSN_UID (note) = cur_insn_uid++;
   NOTE_DATA (note) = NOTE_DATA (orig);
   NOTE_KIND (note) = NOTE_KIND (orig);
-  BLOCK_FOR_INSN (note) = NULL;
+  set_block_for_insn (note, NULL);
   add_insn (note);
 
   return note;
@@ -4870,7 +4870,7 @@  emit_note (enum insn_note kind)
   INSN_UID (note) = cur_insn_uid++;
   NOTE_KIND (note) = kind;
   memset (&NOTE_DATA (note), 0, sizeof (NOTE_DATA (note)));
-  BLOCK_FOR_INSN (note) = NULL;
+  set_block_for_insn (note, NULL);
   add_insn (note);
   return note;
 }
Index: cfgrtl.c
===================================================================
--- cfgrtl.c	(revision 197322)
+++ cfgrtl.c	(working copy)
@@ -417,7 +417,7 @@  compute_bb_for_insn (void)
 
       for (insn = BB_HEAD (bb); ; insn = NEXT_INSN (insn))
 	{
-	  BLOCK_FOR_INSN (insn) = bb;
+	  set_block_for_insn (insn, bb);
 	  if (insn == end)
 	    break;
 	}
@@ -432,7 +432,7 @@  free_bb_for_insn (void)
   rtx insn;
   for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
     if (!BARRIER_P (insn))
-      BLOCK_FOR_INSN (insn) = NULL;
+      set_block_for_insn (insn, NULL);
   return 0;
 }
 
Index: bb-reorder.c
===================================================================
--- bb-reorder.c	(revision 197322)
+++ bb-reorder.c	(working copy)
@@ -2034,7 +2034,7 @@  fix_crossing_unconditional_branches (void)
 		   cur_insn = NEXT_INSN (cur_insn))
 		{
 		  if (!BARRIER_P (cur_insn))
-		    BLOCK_FOR_INSN (cur_insn) = cur_bb;
+		    set_block_for_insn (cur_insn, cur_bb);
 		  if (JUMP_P (cur_insn))
 		    jump_insn = cur_insn;
 		}
@@ -2191,7 +2191,7 @@  insert_section_boundary_note (void)
 				       BB_HEAD (bb));
 	  /* ??? This kind of note always lives between basic blocks,
 	     but add_insn_before will set BLOCK_FOR_INSN anyway.  */
-	  BLOCK_FOR_INSN (new_note) = NULL;
+	  set_block_for_insn (new_note, NULL);
 	  break;
 	}
     }
Index: resource.c
===================================================================
--- resource.c	(revision 197322)
+++ resource.c	(working copy)
@@ -1206,7 +1206,7 @@  init_resource_info (rtx epilogue_insn)
   /* Set the BLOCK_FOR_INSN of each label that starts a basic block.  */
   FOR_EACH_BB (bb)
     if (LABEL_P (BB_HEAD (bb)))
-      BLOCK_FOR_INSN (BB_HEAD (bb)) = bb;
+      set_block_for_insn (BB_HEAD (bb), bb);
 }
 
 /* Free up the resources allocated to mark_target_live_regs ().  This
@@ -1245,7 +1245,7 @@  free_resource_info (void)
 
   FOR_EACH_BB (bb)
     if (LABEL_P (BB_HEAD (bb)))
-      BLOCK_FOR_INSN (BB_HEAD (bb)) = NULL;
+      set_block_for_insn (BB_HEAD (bb), NULL);
 }
 
 /* Clear any hashed information that we have stored for INSN.  */
Index: sel-sched.c
===================================================================
--- sel-sched.c	(revision 197322)
+++ sel-sched.c	(working copy)
@@ -5227,7 +5227,7 @@  move_nop_to_previous_block (insn_t nop, basic_bloc
   PREV_INSN (next_insn) = note;
 
   BB_END (prev_bb) = nop;
-  BLOCK_FOR_INSN (nop) = prev_bb;
+  set_block_for_insn (nop, prev_bb);
 }
 
 /* Prepare a place to insert the chosen expression on BND.  */
Index: config/c6x/c6x.c
===================================================================
--- config/c6x/c6x.c	(revision 197322)
+++ config/c6x/c6x.c	(working copy)
@@ -4591,7 +4591,7 @@  gen_one_bundle (rtx *slot, int n_filled, int real_
 
   bundle = gen_rtx_SEQUENCE (VOIDmode, gen_rtvec_v (n_filled, slot));
   bundle = make_insn_raw (bundle);
-  BLOCK_FOR_INSN (bundle) = BLOCK_FOR_INSN (slot[0]);
+  set_block_for_insn (bundle, BLOCK_FOR_INSN (slot[0]));
   INSN_LOCATION (bundle) = INSN_LOCATION (slot[0]);
   PREV_INSN (bundle) = PREV_INSN (slot[real_first]);
 
Index: reload1.c
===================================================================
--- reload1.c	(revision 197322)
+++ reload1.c	(working copy)
@@ -1037,7 +1037,7 @@  reload (rtx first, int global)
 	      else if (reg_set_p (regno_reg_rtx[i], PATTERN (equiv_insn)))
 		delete_dead_insn (equiv_insn);
 	      else
-		SET_INSN_DELETED (equiv_insn);
+		set_insn_deleted (equiv_insn);
 	    }
 	}
     }
@@ -2147,7 +2147,7 @@  delete_dead_insn (rtx insn)
       && ! side_effects_p (SET_SRC (PATTERN (prev))))
     need_dce = 1;
 
-  SET_INSN_DELETED (insn);
+  set_insn_deleted (insn);
 }
 
 /* Modify the home of pseudo-reg I.
Index: combine.c
===================================================================
--- combine.c	(revision 197322)
+++ combine.c	(working copy)
@@ -4078,7 +4078,7 @@  try_combine (rtx i3, rtx i2, rtx i1, rtx i0, int *
 	if (MAY_HAVE_DEBUG_INSNS && i2src)
 	  propagate_for_debug (i2, last_combined_insn, i2dest, i2src,
 			       this_basic_block);
-	SET_INSN_DELETED (i2);
+	set_insn_deleted (i2);
       }
 
     if (i1)
@@ -4088,7 +4088,7 @@  try_combine (rtx i3, rtx i2, rtx i1, rtx i0, int *
 	if (MAY_HAVE_DEBUG_INSNS)
 	  propagate_for_debug (i1, last_combined_insn, i1dest, i1src,
 			       this_basic_block);
-	SET_INSN_DELETED (i1);
+	set_insn_deleted (i1);
       }
 
     if (i0)
@@ -4098,7 +4098,7 @@  try_combine (rtx i3, rtx i2, rtx i1, rtx i0, int *
 	if (MAY_HAVE_DEBUG_INSNS)
 	  propagate_for_debug (i0, last_combined_insn, i0dest, i0src,
 			       this_basic_block);
-	SET_INSN_DELETED (i0);
+	set_insn_deleted (i0);
       }
 
     /* Get death notes for everything that is now used in either I3 or
@@ -13444,7 +13444,7 @@  distribute_notes (rtx notes, rtx from_insn, rtx i3
 					    NULL_RTX, NULL_RTX, NULL_RTX);
 			  distribute_links (LOG_LINKS (tem));
 
-			  SET_INSN_DELETED (tem);
+			  set_insn_deleted (tem);
 			  if (tem == i2)
 			    i2 = NULL_RTX;
 
@@ -13461,7 +13461,7 @@  distribute_notes (rtx notes, rtx from_insn, rtx i3
 						NULL_RTX, NULL_RTX, NULL_RTX);
 			      distribute_links (LOG_LINKS (cc0_setter));
 
-			      SET_INSN_DELETED (cc0_setter);
+			      set_insn_deleted (cc0_setter);
 			      if (cc0_setter == i2)
 				i2 = NULL_RTX;
 			    }
Index: lra.c
===================================================================
--- lra.c	(revision 197322)
+++ lra.c	(working copy)
@@ -219,7 +219,7 @@  void
 lra_set_insn_deleted (rtx insn)
 {
   lra_invalidate_insn_data (insn);
-  SET_INSN_DELETED (insn);
+  set_insn_deleted (insn);
 }
 
 /* Delete an unneeded INSN and any previous insns who sole purpose is
       {
Index: ifcvt.c
===================================================================
--- ifcvt.c	(revision 197322)
+++ ifcvt.c	(working copy)
@@ -327,7 +327,7 @@  cond_exec_process_insns (ce_if_block_t *ce_info AT
 	{
 	  /* ??? Ug.  Actually unlinking the thing is problematic,
 	     given what we'd have to coordinate with our callers.  */
-	  SET_INSN_DELETED (insn);
+	  set_insn_deleted (insn);
 	  goto insn_done;
 	}
 
Index: recog.c
===================================================================
--- recog.c	(revision 197322)
+++ recog.c	(working copy)
@@ -2855,7 +2855,7 @@  split_insn (rtx insn)
     }
 
   /* try_split returns the NOTE that INSN became.  */
-  SET_INSN_DELETED (insn);
+  set_insn_deleted (insn);
 
   /* ??? Coddle to md files that generate subregs in post-reload
      splitters instead of computing the proper hard register.  */
Index: config/pa/pa.c
===================================================================
--- config/pa/pa.c	(revision 197322)
+++ config/pa/pa.c	(working copy)
@@ -6644,7 +6644,7 @@  pa_output_lbranch (rtx dest, rtx insn, int xdelay)
 		       optimize, 0, NULL);
 
       /* Now delete the delay insn.  */
-      SET_INSN_DELETED (NEXT_INSN (insn));
+      set_insn_deleted (NEXT_INSN (insn));
     }
 
   /* Output an insn to save %r1.  The runtime documentation doesn't
@@ -7677,7 +7677,7 @@  pa_output_millicode_call (rtx insn, rtx call_dest)
     output_asm_insn ("nop\n\tb,n %0", xoperands);
 
   /* Delete the jump.  */
-  SET_INSN_DELETED (NEXT_INSN (insn));
+  set_insn_deleted (NEXT_INSN (insn));
 
   return "";
 }
@@ -7826,7 +7826,7 @@  pa_output_call (rtx insn, rtx call_dest, int sibca
 			       optimize, 0, NULL);
 
 	      /* Now delete the delay insn.  */
-	      SET_INSN_DELETED (NEXT_INSN (insn));
+	      set_insn_deleted (NEXT_INSN (insn));
 	      delay_insn_deleted = 1;
 	    }
 
@@ -7876,7 +7876,7 @@  pa_output_call (rtx insn, rtx call_dest, int sibca
 			       NULL);
 
 	      /* Now delete the delay insn.  */
-	      SET_INSN_DELETED (NEXT_INSN (insn));
+	      set_insn_deleted (NEXT_INSN (insn));
 	      delay_insn_deleted = 1;
 	    }
 
@@ -8063,7 +8063,7 @@  pa_output_call (rtx insn, rtx call_dest, int sibca
     output_asm_insn ("b,n %0", xoperands);
 
   /* Delete the jump.  */
-  SET_INSN_DELETED (NEXT_INSN (insn));
+  set_insn_deleted (NEXT_INSN (insn));
 
   return "";
 }
@@ -9258,7 +9258,7 @@  pa_combine_instructions (void)
 					    PATTERN (floater))),
 				anchor);
 
-	      SET_INSN_DELETED (anchor);
+	      set_insn_deleted (anchor);
 
 	      /* Emit a special USE insn for FLOATER, then delete
 		 the floating insn.  */
@@ -9280,7 +9280,7 @@  pa_combine_instructions (void)
 					 anchor);
 
 	      JUMP_LABEL (temp) = JUMP_LABEL (anchor);
-	      SET_INSN_DELETED (anchor);
+	      set_insn_deleted (anchor);
 
 	      /* Emit a special USE insn for FLOATER, then delete
 		 the floating insn.  */
Index: config/sh/sh.c
===================================================================
--- config/sh/sh.c	(revision 197322)
+++ config/sh/sh.c	(working copy)
@@ -6492,7 +6492,7 @@  split_branches (rtx first)
       {
 	/* Shorten_branches would split this instruction again,
 	   so transform it into a note.  */
-	SET_INSN_DELETED (insn);
+	set_insn_deleted (insn);
       }
     else if (JUMP_P (insn))