From e519726a2d8b39c9837d297c91b092bf452896d1 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Fri, 30 May 2014 15:40:43 -0400
Subject: [PATCH 010/236] Split NEXT_INSN/PREV_INSN into lvalue and rvalue
 forms

gcc/
	* rtl.h (PREV_INSN): Split macro in two: the existing one,
	for rvalues, and...
	(SET_PREV_INSN): New macro, for use as an lvalue.
	(NEXT_INSN, SET_NEXT_INSN): Likewise.

	* caller-save.c (save_call_clobbered_regs): Convert lvalue use of
	PREV_INSN/NEXT_INSN into SET_PREV_INSN/SET_NEXT_INSN.
	* cfgrtl.c (try_redirect_by_replacing_jump): Likewise.
	(fixup_abnormal_edges): Likewise.
	(unlink_insn_chain): Likewise.
	(fixup_reorder_chain): Likewise.
	(cfg_layout_delete_block): Likewise.
	(cfg_layout_merge_blocks): Likewise.
	* combine.c (update_cfg_for_uncondjump): Likewise.
	* emit-rtl.c (link_insn_into_chain): Likewise.
	(remove_insn): Likewise.
	(delete_insns_since): Likewise.
	(reorder_insns_nobb): Likewise.
	(emit_insn_after_1): Likewise.
	* final.c (rest_of_clean_state): Likewise.
	(final_scan_insn): Likewise.
	* gcse.c (can_assign_to_reg_without_clobbers_p): Likewise.
	* haifa-sched.c (concat_note_lists): Likewise.
	(remove_notes): Likewise.
	(restore_other_notes): Likewise.
	(move_insn): Likewise.
	(unlink_bb_notes): Likewise.
	(restore_bb_notes): Likewise.
	* jump.c (delete_for_peephole): Likewise.
	* optabs.c (emit_libcall_block_1): Likewise.
	* reorg.c (emit_delay_sequence): Likewise.
	(fill_simple_delay_slots): Likewise.
	* sel-sched-ir.c (sel_move_insn): Likewise.
	(sel_remove_insn): Likewise.
	(get_bb_note_from_pool): Likewise.
	* sel-sched.c (move_nop_to_previous_block): Likewise.

	* config/bfin/bfin.c (reorder_var_tracking_notes): Likewise.
	* config/c6x/c6x.c (gen_one_bundle): Likewise.
	(c6x_gen_bundles): Likewise.
	(hwloop_optimize): Likewise.
	* config/frv/frv.c (frv_function_prologue): Likewise.
	(frv_register_nop): Likewise.
	* config/ia64/ia64.c (ia64_init_dfa_pre_cycle_insn): Likewise.
	(ia64_reorg): Likewise.
	* config/mep/mep.c (mep_reorg_addcombine): Likewise.
	(mep_make_bundle): Likewise.
	(mep_bundle_insns): Likewise.
	* config/picochip/picochip.c (reorder_var_tracking_notes): Likewise.
	* config/tilegx/tilegx.c (reorder_var_tracking_notes): Likewise.
	* config/tilepro/tilepro.c (reorder_var_tracking_notes): Likewise.

/
	* rtx-classes-status.txt: Add SET_NEXT_INSN, SET_PREV_INSN
---
 gcc/caller-save.c              | 12 +++----
 gcc/cfgrtl.c                   | 76 +++++++++++++++++++++---------------------
 gcc/combine.c                  |  4 +--
 gcc/config/bfin/bfin.c         | 14 ++++----
 gcc/config/c6x/c6x.c           | 42 +++++++++++------------
 gcc/config/frv/frv.c           | 16 ++++-----
 gcc/config/ia64/ia64.c         |  6 ++--
 gcc/config/mep/mep.c           | 36 ++++++++++----------
 gcc/config/picochip/picochip.c | 22 ++++++------
 gcc/config/tilegx/tilegx.c     | 14 ++++----
 gcc/config/tilepro/tilepro.c   | 14 ++++----
 gcc/emit-rtl.c                 | 48 +++++++++++++-------------
 gcc/final.c                    | 16 ++++-----
 gcc/gcse.c                     |  2 +-
 gcc/haifa-sched.c              | 40 +++++++++++-----------
 gcc/jump.c                     |  4 +--
 gcc/optabs.c                   |  4 +--
 gcc/reorg.c                    |  8 ++---
 gcc/rtl.h                      | 11 ++++--
 gcc/sel-sched-ir.c             | 16 ++++-----
 gcc/sel-sched.c                | 12 +++----
 rtx-classes-status.txt         |  1 +
 22 files changed, 213 insertions(+), 205 deletions(-)

diff --git a/gcc/caller-save.c b/gcc/caller-save.c
index 41b3f01..b1ef3a9 100644
--- a/gcc/caller-save.c
+++ b/gcc/caller-save.c
@@ -913,13 +913,13 @@ save_call_clobbered_regs (void)
 		  prev = PREV_INSN (ins);
 		  if (NOTE_P (ins))
 		    {
-		      NEXT_INSN (prev) = NEXT_INSN (ins);
-		      PREV_INSN (NEXT_INSN (ins)) = prev;
-		      PREV_INSN (ins) = insn;
-		      NEXT_INSN (ins) = NEXT_INSN (insn);
-		      NEXT_INSN (insn) = ins;
+		      SET_NEXT_INSN (prev) = NEXT_INSN (ins);
+		      SET_PREV_INSN (NEXT_INSN (ins)) = prev;
+		      SET_PREV_INSN (ins) = insn;
+		      SET_NEXT_INSN (ins) = NEXT_INSN (insn);
+		      SET_NEXT_INSN (insn) = ins;
 		      if (NEXT_INSN (ins))
-			PREV_INSN (NEXT_INSN (ins)) = ins;
+			SET_PREV_INSN (NEXT_INSN (ins)) = ins;
                       if (BB_END (bb) == insn)
 			SET_BB_END (bb) = ins;
 		    }
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index 5f2879e..d386367 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -1061,11 +1061,11 @@ try_redirect_by_replacing_jump (edge e, basic_block target, bool in_cfglayout)
 	      if (BARRIER_P (insn))
 		{
 		  if (PREV_INSN (insn))
-		    NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn);
+		    SET_NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn);
 		  else
 		    SET_BB_FOOTER (src) = NEXT_INSN (insn);
 		  if (NEXT_INSN (insn))
-		    PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn);
+		    SET_PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn);
 		}
 	      if (LABEL_P (insn))
 		break;
@@ -1133,14 +1133,14 @@ try_redirect_by_replacing_jump (edge e, basic_block target, bool in_cfglayout)
 	      update_bb_for_insn_chain (NEXT_INSN (BB_END (src)),
 				        PREV_INSN (barrier), src);
 
-	      NEXT_INSN (PREV_INSN (new_insn)) = NEXT_INSN (new_insn);
-	      PREV_INSN (NEXT_INSN (new_insn)) = PREV_INSN (new_insn);
+	      SET_NEXT_INSN (PREV_INSN (new_insn)) = NEXT_INSN (new_insn);
+	      SET_PREV_INSN (NEXT_INSN (new_insn)) = PREV_INSN (new_insn);
 
-	      NEXT_INSN (new_insn) = barrier;
-	      NEXT_INSN (PREV_INSN (barrier)) = new_insn;
+	      SET_NEXT_INSN (new_insn) = barrier;
+	      SET_NEXT_INSN (PREV_INSN (barrier)) = new_insn;
 
-	      PREV_INSN (new_insn) = PREV_INSN (barrier);
-	      PREV_INSN (barrier) = new_insn;
+	      SET_PREV_INSN (new_insn) = PREV_INSN (barrier);
+	      SET_PREV_INSN (barrier) = new_insn;
 	    }
 	}
     }
@@ -3271,8 +3271,8 @@ fixup_abnormal_edges (void)
 			{
 			  /* We're not deleting it, we're moving it.  */
 			  INSN_DELETED_P (insn) = 0;
-			  PREV_INSN (insn) = NULL_RTX;
-			  NEXT_INSN (insn) = NULL_RTX;
+			  SET_PREV_INSN (insn) = NULL_RTX;
+			  SET_NEXT_INSN (insn) = NULL_RTX;
 
 			  insert_insn_on_edge (insn, e);
 			  inserted = true;
@@ -3303,12 +3303,12 @@ unlink_insn_chain (rtx first, rtx last)
   rtx prevfirst = PREV_INSN (first);
   rtx nextlast = NEXT_INSN (last);
 
-  PREV_INSN (first) = NULL;
-  NEXT_INSN (last) = NULL;
+  SET_PREV_INSN (first) = NULL;
+  SET_NEXT_INSN (last) = NULL;
   if (prevfirst)
-    NEXT_INSN (prevfirst) = nextlast;
+    SET_NEXT_INSN (prevfirst) = nextlast;
   if (nextlast)
-    PREV_INSN (nextlast) = prevfirst;
+    SET_PREV_INSN (nextlast) = prevfirst;
   else
     set_last_insn (prevfirst);
   if (!prevfirst)
@@ -3653,32 +3653,32 @@ fixup_reorder_chain (void)
       if (BB_HEADER (bb))
 	{
 	  if (insn)
-	    NEXT_INSN (insn) = BB_HEADER (bb);
+	    SET_NEXT_INSN (insn) = BB_HEADER (bb);
 	  else
 	    set_first_insn (BB_HEADER (bb));
-	  PREV_INSN (BB_HEADER (bb)) = insn;
+	  SET_PREV_INSN (BB_HEADER (bb)) = insn;
 	  insn = BB_HEADER (bb);
 	  while (NEXT_INSN (insn))
 	    insn = NEXT_INSN (insn);
 	}
       if (insn)
-	NEXT_INSN (insn) = BB_HEAD (bb);
+	SET_NEXT_INSN (insn) = BB_HEAD (bb);
       else
 	set_first_insn (BB_HEAD (bb));
-      PREV_INSN (BB_HEAD (bb)) = insn;
+      SET_PREV_INSN (BB_HEAD (bb)) = insn;
       insn = BB_END (bb);
       if (BB_FOOTER (bb))
 	{
-	  NEXT_INSN (insn) = BB_FOOTER (bb);
-	  PREV_INSN (BB_FOOTER (bb)) = insn;
+	  SET_NEXT_INSN (insn) = BB_FOOTER (bb);
+	  SET_PREV_INSN (BB_FOOTER (bb)) = insn;
 	  while (NEXT_INSN (insn))
 	    insn = NEXT_INSN (insn);
 	}
     }
 
-  NEXT_INSN (insn) = cfg_layout_function_footer;
+  SET_NEXT_INSN (insn) = cfg_layout_function_footer;
   if (cfg_layout_function_footer)
-    PREV_INSN (cfg_layout_function_footer) = insn;
+    SET_PREV_INSN (cfg_layout_function_footer) = insn;
 
   while (NEXT_INSN (insn))
     insn = NEXT_INSN (insn);
@@ -4413,15 +4413,15 @@ cfg_layout_delete_block (basic_block bb)
     {
       next = BB_HEAD (bb);
       if (prev)
-	NEXT_INSN (prev) = BB_HEADER (bb);
+	SET_NEXT_INSN (prev) = BB_HEADER (bb);
       else
 	set_first_insn (BB_HEADER (bb));
-      PREV_INSN (BB_HEADER (bb)) = prev;
+      SET_PREV_INSN (BB_HEADER (bb)) = prev;
       insn = BB_HEADER (bb);
       while (NEXT_INSN (insn))
 	insn = NEXT_INSN (insn);
-      NEXT_INSN (insn) = next;
-      PREV_INSN (next) = insn;
+      SET_NEXT_INSN (insn) = next;
+      SET_PREV_INSN (next) = insn;
     }
   next = NEXT_INSN (BB_END (bb));
   if (BB_FOOTER (bb))
@@ -4432,11 +4432,11 @@ cfg_layout_delete_block (basic_block bb)
 	  if (BARRIER_P (insn))
 	    {
 	      if (PREV_INSN (insn))
-		NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn);
+		SET_NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn);
 	      else
 		SET_BB_FOOTER (bb) = NEXT_INSN (insn);
 	      if (NEXT_INSN (insn))
-		PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn);
+		SET_PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn);
 	    }
 	  if (LABEL_P (insn))
 	    break;
@@ -4445,13 +4445,13 @@ cfg_layout_delete_block (basic_block bb)
       if (BB_FOOTER (bb))
 	{
 	  insn = BB_END (bb);
-	  NEXT_INSN (insn) = BB_FOOTER (bb);
-	  PREV_INSN (BB_FOOTER (bb)) = insn;
+	  SET_NEXT_INSN (insn) = BB_FOOTER (bb);
+	  SET_PREV_INSN (BB_FOOTER (bb)) = insn;
 	  while (NEXT_INSN (insn))
 	    insn = NEXT_INSN (insn);
-	  NEXT_INSN (insn) = next;
+	  SET_NEXT_INSN (insn) = next;
 	  if (next)
-	    PREV_INSN (next) = insn;
+	    SET_PREV_INSN (next) = insn;
 	  else
 	    set_last_insn (insn);
 	}
@@ -4478,9 +4478,9 @@ cfg_layout_delete_block (basic_block bb)
       insn = remaints;
       while (NEXT_INSN (insn))
 	insn = NEXT_INSN (insn);
-      NEXT_INSN (insn) = *to;
+      SET_NEXT_INSN (insn) = *to;
       if (*to)
-	PREV_INSN (*to) = insn;
+	SET_PREV_INSN (*to) = insn;
       *to = remaints;
     }
 }
@@ -4576,8 +4576,8 @@ cfg_layout_merge_blocks (basic_block a, basic_block b)
 
 	  while (NEXT_INSN (last))
 	    last = NEXT_INSN (last);
-	  NEXT_INSN (last) = BB_FOOTER (b);
-	  PREV_INSN (BB_FOOTER (b)) = last;
+	  SET_NEXT_INSN (last) = BB_FOOTER (b);
+	  SET_PREV_INSN (BB_FOOTER (b)) = last;
 	}
       SET_BB_FOOTER (b) = NULL;
     }
@@ -4595,8 +4595,8 @@ cfg_layout_merge_blocks (basic_block a, basic_block b)
  
 	  while (NEXT_INSN (last))
 	    last = NEXT_INSN (last);
-	  NEXT_INSN (last) = BB_FOOTER (a);
-	  PREV_INSN (BB_FOOTER (a)) = last;
+	  SET_NEXT_INSN (last) = BB_FOOTER (a);
+	  SET_PREV_INSN (BB_FOOTER (a)) = last;
 	  SET_BB_FOOTER (a) = BB_HEADER (b);
 	}
       SET_BB_HEADER (b) = NULL;
diff --git a/gcc/combine.c b/gcc/combine.c
index 3cc8f2b..dafacaf 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -2391,11 +2391,11 @@ update_cfg_for_uncondjump (rtx insn)
 	if (BARRIER_P (insn))
 	  {
 	    if (PREV_INSN (insn))
-	      NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn);
+	      SET_NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn);
 	    else
 	      SET_BB_FOOTER (bb) = NEXT_INSN (insn);
 	    if (NEXT_INSN (insn))
-	      PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn);
+	      SET_PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn);
 	  }
 	else if (LABEL_P (insn))
 	  break;
diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c
index 7945de4..b037a46 100644
--- a/gcc/config/bfin/bfin.c
+++ b/gcc/config/bfin/bfin.c
@@ -4057,10 +4057,10 @@ reorder_var_tracking_notes (void)
 		  while (queue)
 		    {
 		      rtx next_queue = PREV_INSN (queue);
-		      PREV_INSN (NEXT_INSN (insn)) = queue;
-		      NEXT_INSN (queue) = NEXT_INSN (insn);
-		      NEXT_INSN (insn) = queue;
-		      PREV_INSN (queue) = insn;
+		      SET_PREV_INSN (NEXT_INSN (insn)) = queue;
+		      SET_NEXT_INSN (queue) = NEXT_INSN (insn);
+		      SET_NEXT_INSN (insn) = queue;
+		      SET_PREV_INSN (queue) = insn;
 		      queue = next_queue;
 		    }
 		  in_bundle = false;
@@ -4073,10 +4073,10 @@ reorder_var_tracking_notes (void)
 	      if (in_bundle)
 		{
 		  rtx prev = PREV_INSN (insn);
-		  PREV_INSN (next) = prev;
-		  NEXT_INSN (prev) = next;
+		  SET_PREV_INSN (next) = prev;
+		  SET_NEXT_INSN (prev) = next;
 
-		  PREV_INSN (insn) = queue;
+		  SET_PREV_INSN (insn) = queue;
 		  queue = insn;
 		}
 	    }
diff --git a/gcc/config/c6x/c6x.c b/gcc/config/c6x/c6x.c
index 2d73cb8..6588d76 100644
--- a/gcc/config/c6x/c6x.c
+++ b/gcc/config/c6x/c6x.c
@@ -4598,7 +4598,7 @@ gen_one_bundle (rtx *slot, int n_filled, int real_first)
   bundle = make_insn_raw (bundle);
   BLOCK_FOR_INSN (bundle) = BLOCK_FOR_INSN (slot[0]);
   INSN_LOCATION (bundle) = INSN_LOCATION (slot[0]);
-  PREV_INSN (bundle) = PREV_INSN (slot[real_first]);
+  SET_PREV_INSN (bundle) = SET_PREV_INSN (slot[real_first]);
 
   t = NULL_RTX;
 
@@ -4606,18 +4606,18 @@ gen_one_bundle (rtx *slot, int n_filled, int real_first)
     {
       rtx insn = slot[i];
       remove_insn (insn);
-      PREV_INSN (insn) = t ? t : PREV_INSN (bundle);
+      SET_PREV_INSN (insn) = t ? t : PREV_INSN (bundle);
       if (t != NULL_RTX)
-	NEXT_INSN (t) = insn;
+	SET_NEXT_INSN (t) = insn;
       t = insn;
       if (i > 0)
 	INSN_LOCATION (slot[i]) = INSN_LOCATION (bundle);
     }
 
-  NEXT_INSN (bundle) = NEXT_INSN (PREV_INSN (bundle));
-  NEXT_INSN (t) = NEXT_INSN (bundle);
-  NEXT_INSN (PREV_INSN (bundle)) = bundle;
-  PREV_INSN (NEXT_INSN (bundle)) = bundle;
+  SET_NEXT_INSN (bundle) = NEXT_INSN (PREV_INSN (bundle));
+  SET_NEXT_INSN (t) = NEXT_INSN (bundle);
+  SET_NEXT_INSN (PREV_INSN (bundle)) = bundle;
+  SET_PREV_INSN (NEXT_INSN (bundle)) = bundle;
 }
 
 /* Move all parallel instructions into SEQUENCEs, so that no subsequent passes
@@ -4709,12 +4709,12 @@ c6x_gen_bundles (void)
 	continue;
       if (NEXT_INSN (last_call) == insn)
 	continue;
-      NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn);
-      PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn);
-      PREV_INSN (insn) = last_call;
-      NEXT_INSN (insn) = NEXT_INSN (last_call);
-      PREV_INSN (NEXT_INSN (insn)) = insn;
-      NEXT_INSN (PREV_INSN (insn)) = insn;
+      SET_NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn);
+      SET_PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn);
+      SET_PREV_INSN (insn) = last_call;
+      SET_NEXT_INSN (insn) = NEXT_INSN (last_call);
+      SET_PREV_INSN (NEXT_INSN (insn)) = insn;
+      SET_NEXT_INSN (PREV_INSN (insn)) = insn;
       last_call = insn;
     }
 }
@@ -5697,8 +5697,8 @@ hwloop_optimize (hwloop_info loop)
      reservations of the instructions contained in it to the corresponding
      instructions from iteration 0, which are the only ones we'll keep.  */
   assign_reservations (BB_HEAD (bb), ss.last_scheduled_insn);
-  PREV_INSN (BB_END (bb)) = ss.last_scheduled_iter0;
-  NEXT_INSN (ss.last_scheduled_iter0) = BB_END (bb);
+  SET_PREV_INSN (BB_END (bb)) = ss.last_scheduled_iter0;
+  SET_NEXT_INSN (ss.last_scheduled_iter0) = BB_END (bb);
   filter_insns_above (bb, sploop_max_uid_iter0);
 
   for (i = 0; i < n_real_insns; i++)
@@ -5820,13 +5820,13 @@ hwloop_optimize (hwloop_info loop)
 
   for (i = 1; i < n_insns; i++)
     {
-      NEXT_INSN (orig_vec[i - 1]) = orig_vec[i];
-      PREV_INSN (orig_vec[i]) = orig_vec[i - 1];
+      SET_NEXT_INSN (orig_vec[i - 1]) = orig_vec[i];
+      SET_PREV_INSN (orig_vec[i]) = orig_vec[i - 1];
     }
-  PREV_INSN (orig_vec[0]) = PREV_INSN (BB_HEAD (bb));
-  NEXT_INSN (PREV_INSN (BB_HEAD (bb))) = orig_vec[0];
-  NEXT_INSN (orig_vec[n_insns - 1]) = NEXT_INSN (BB_END (bb));
-  PREV_INSN (NEXT_INSN (BB_END (bb))) = orig_vec[n_insns - 1];
+  SET_PREV_INSN (orig_vec[0]) = PREV_INSN (BB_HEAD (bb));
+  SET_NEXT_INSN (PREV_INSN (BB_HEAD (bb))) = orig_vec[0];
+  SET_NEXT_INSN (orig_vec[n_insns - 1]) = NEXT_INSN (BB_END (bb));
+  SET_PREV_INSN (NEXT_INSN (BB_END (bb))) = orig_vec[n_insns - 1];
   SET_BB_HEAD (bb) = orig_vec[0];
   SET_BB_END (bb) = orig_vec[n_insns - 1];
  undo_splits:
diff --git a/gcc/config/frv/frv.c b/gcc/config/frv/frv.c
index 2b0a0b2..b7b3185 100644
--- a/gcc/config/frv/frv.c
+++ b/gcc/config/frv/frv.c
@@ -1483,12 +1483,12 @@ frv_function_prologue (FILE *file, HOST_WIDE_INT size ATTRIBUTE_UNUSED)
       if (NEXT_INSN (last_call) == insn)
 	continue;
 
-      NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn);
-      PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn);
-      PREV_INSN (insn) = last_call;
-      NEXT_INSN (insn) = NEXT_INSN (last_call);
-      PREV_INSN (NEXT_INSN (insn)) = insn;
-      NEXT_INSN (PREV_INSN (insn)) = insn;
+      SET_NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn);
+      SET_PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn);
+      SET_PREV_INSN (insn) = last_call;
+      SET_NEXT_INSN (insn) = NEXT_INSN (last_call);
+      SET_PREV_INSN (NEXT_INSN (insn)) = insn;
+      SET_NEXT_INSN (PREV_INSN (insn)) = insn;
       last_call = insn;
     }
 }
@@ -8180,8 +8180,8 @@ static void
 frv_register_nop (rtx nop)
 {
   nop = make_insn_raw (nop);
-  NEXT_INSN (nop) = 0;
-  PREV_INSN (nop) = 0;
+  SET_NEXT_INSN (nop) = 0;
+  SET_PREV_INSN (nop) = 0;
   frv_nops[frv_num_nops++] = nop;
 }
 
diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
index feee157..3b25f2e 100644
--- a/gcc/config/ia64/ia64.c
+++ b/gcc/config/ia64/ia64.c
@@ -9488,10 +9488,10 @@ ia64_init_dfa_pre_cycle_insn (void)
       prev_cycle_state = xmalloc (dfa_state_size);
     }
   dfa_pre_cycle_insn = make_insn_raw (gen_pre_cycle ());
-  PREV_INSN (dfa_pre_cycle_insn) = NEXT_INSN (dfa_pre_cycle_insn) = NULL_RTX;
+  SET_PREV_INSN (dfa_pre_cycle_insn) = SET_NEXT_INSN (dfa_pre_cycle_insn) = NULL_RTX;
   recog_memoized (dfa_pre_cycle_insn);
   dfa_stop_insn = make_insn_raw (gen_insn_group_barrier (GEN_INT (3)));
-  PREV_INSN (dfa_stop_insn) = NEXT_INSN (dfa_stop_insn) = NULL_RTX;
+  SET_PREV_INSN (dfa_stop_insn) = SET_NEXT_INSN (dfa_stop_insn) = NULL_RTX;
   recog_memoized (dfa_stop_insn);
 }
 
@@ -9678,7 +9678,7 @@ ia64_reorg (void)
 
       initiate_bundle_states ();
       ia64_nop = make_insn_raw (gen_nop ());
-      PREV_INSN (ia64_nop) = NEXT_INSN (ia64_nop) = NULL_RTX;
+      SET_PREV_INSN (ia64_nop) = SET_NEXT_INSN (ia64_nop) = NULL_RTX;
       recog_memoized (ia64_nop);
       clocks_length = get_max_uid () + 1;
       stops_p = XCNEWVEC (char, clocks_length);
diff --git a/gcc/config/mep/mep.c b/gcc/config/mep/mep.c
index 107f1fa..544f267 100644
--- a/gcc/config/mep/mep.c
+++ b/gcc/config/mep/mep.c
@@ -5695,9 +5695,9 @@ mep_reorg_addcombine (rtx insns)
 		&& ic + nc > -32768)
 	      {
 		XEXP (SET_SRC (PATTERN (i)), 1) = GEN_INT (ic + nc);
-		NEXT_INSN (i) = NEXT_INSN (n);
+		SET_NEXT_INSN (i) = NEXT_INSN (n);
 		if (NEXT_INSN (i))
-		  PREV_INSN (NEXT_INSN (i)) = i;
+		  SET_PREV_INSN (NEXT_INSN (i)) = i;
 	      }
 	  }
       }
@@ -6812,10 +6812,10 @@ mep_make_bundle (rtx core, rtx cop)
   remove_insn (cop);
 
   /* Set up the links of the insns inside the SEQUENCE.  */
-  PREV_INSN (core) = PREV_INSN (insn);
-  NEXT_INSN (core) = cop;
-  PREV_INSN (cop) = core;
-  NEXT_INSN (cop) = NEXT_INSN (insn);
+  SET_PREV_INSN (core) = PREV_INSN (insn);
+  SET_NEXT_INSN (core) = cop;
+  SET_PREV_INSN (cop) = core;
+  SET_NEXT_INSN (cop) = NEXT_INSN (insn);
 
   /* Set the VLIW flag for the coprocessor instruction.  */
   PUT_MODE (core, VOIDmode);
@@ -6933,13 +6933,13 @@ mep_bundle_insns (rtx insns)
 	      if (NOTE_P (note))
 		{
 		  /* Remove NOTE from here... */
-		  PREV_INSN (NEXT_INSN (note)) = PREV_INSN (note);
-		  NEXT_INSN (PREV_INSN (note)) = NEXT_INSN (note);
+		  SET_PREV_INSN (NEXT_INSN (note)) = PREV_INSN (note);
+		  SET_NEXT_INSN (PREV_INSN (note)) = NEXT_INSN (note);
 		  /* ...and put it in here.  */
-		  NEXT_INSN (note) = first;
-		  PREV_INSN (note) = PREV_INSN (first);
-		  NEXT_INSN (PREV_INSN (note)) = note;
-		  PREV_INSN (NEXT_INSN (note)) = note;
+		  SET_NEXT_INSN (note) = first;
+		  SET_PREV_INSN (note) = PREV_INSN (first);
+		  SET_NEXT_INSN (PREV_INSN (note)) = note;
+		  SET_PREV_INSN (NEXT_INSN (note)) = note;
 		}
 
 	      note = prev;
@@ -7001,17 +7001,17 @@ mep_bundle_insns (rtx insns)
 
 		  /* Remove core insn.  */
 		  if (PREV_INSN (core_insn))
-		    NEXT_INSN (PREV_INSN (core_insn)) = NEXT_INSN (core_insn);
+		    SET_NEXT_INSN (PREV_INSN (core_insn)) = NEXT_INSN (core_insn);
 		  if (NEXT_INSN (core_insn))
-		    PREV_INSN (NEXT_INSN (core_insn)) = PREV_INSN (core_insn);
+		    SET_PREV_INSN (NEXT_INSN (core_insn)) = PREV_INSN (core_insn);
 
 		  /* Re-insert core insn.  */
-		  PREV_INSN (core_insn) = PREV_INSN (insn);
-		  NEXT_INSN (core_insn) = insn;
+		  SET_PREV_INSN (core_insn) = PREV_INSN (insn);
+		  SET_NEXT_INSN (core_insn) = insn;
 
 		  if (PREV_INSN (core_insn))
-		    NEXT_INSN (PREV_INSN (core_insn)) = core_insn;
-		  PREV_INSN (insn) = core_insn;
+		    SET_NEXT_INSN (PREV_INSN (core_insn)) = core_insn;
+		  SET_PREV_INSN (insn) = core_insn;
 
 		  PUT_MODE (core_insn, TImode);
 		  PUT_MODE (insn, VOIDmode);
diff --git a/gcc/config/picochip/picochip.c b/gcc/config/picochip/picochip.c
index 8738564..25802ef 100644
--- a/gcc/config/picochip/picochip.c
+++ b/gcc/config/picochip/picochip.c
@@ -3198,10 +3198,10 @@ reorder_var_tracking_notes (void)
               while (queue)
                 {
                   rtx next_queue = PREV_INSN (queue);
-                  PREV_INSN (NEXT_INSN(insn)) = queue;
-                  NEXT_INSN(queue) = NEXT_INSN(insn);
-                  PREV_INSN(queue) = insn;
-                  NEXT_INSN(insn) = queue;
+                  SET_PREV_INSN (NEXT_INSN(insn)) = queue;
+                  SET_NEXT_INSN(queue) = NEXT_INSN(insn);
+                  SET_PREV_INSN(queue) = insn;
+                  SET_NEXT_INSN(insn) = queue;
                   queue = next_queue;
                 }
               /* There is no more to do for this bb. break*/
@@ -3215,10 +3215,10 @@ reorder_var_tracking_notes (void)
                   while (queue)
                     {
                       rtx next_queue = PREV_INSN (queue);
-                      NEXT_INSN (PREV_INSN(insn)) = queue;
-                      PREV_INSN (queue) = PREV_INSN(insn);
-                      PREV_INSN (insn) = queue;
-                      NEXT_INSN (queue) = insn;
+                      SET_NEXT_INSN (PREV_INSN(insn)) = queue;
+                      SET_PREV_INSN (queue) = PREV_INSN(insn);
+                      SET_PREV_INSN (insn) = queue;
+                      SET_NEXT_INSN (queue) = insn;
                       queue = next_queue;
                     }
                 }
@@ -3226,15 +3226,15 @@ reorder_var_tracking_notes (void)
           else if (NOTE_P (insn))
             {
                rtx prev = PREV_INSN (insn);
-               PREV_INSN (next) = prev;
-               NEXT_INSN (prev) = next;
+               SET_PREV_INSN (next) = prev;
+               SET_NEXT_INSN (prev) = next;
                /* Ignore call_arg notes. They are expected to be just after the
                   call insn. If the call is start of a long VLIW, labels are
                   emitted in the middle of a VLIW, which our assembler can not
                   handle. */
                if (NOTE_KIND (insn) != NOTE_INSN_CALL_ARG_LOCATION)
                  {
-                   PREV_INSN (insn) = queue;
+                   SET_PREV_INSN (insn) = queue;
                    queue = insn;
                  }
             }
diff --git a/gcc/config/tilegx/tilegx.c b/gcc/config/tilegx/tilegx.c
index 70fce93..7c251c7 100644
--- a/gcc/config/tilegx/tilegx.c
+++ b/gcc/config/tilegx/tilegx.c
@@ -4827,10 +4827,10 @@ reorder_var_tracking_notes (void)
 		while (queue)
 		  {
 		    rtx next_queue = PREV_INSN (queue);
-		    PREV_INSN (NEXT_INSN (insn)) = queue;
-		    NEXT_INSN (queue) = NEXT_INSN (insn);
-		    NEXT_INSN (insn) = queue;
-		    PREV_INSN (queue) = insn;
+		    SET_PREV_INSN (NEXT_INSN (insn)) = queue;
+		    SET_NEXT_INSN (queue) = NEXT_INSN (insn);
+		    SET_NEXT_INSN (insn) = queue;
+		    SET_PREV_INSN (queue) = insn;
 		    queue = next_queue;
 		  }
 		in_bundle = false;
@@ -4843,10 +4843,10 @@ reorder_var_tracking_notes (void)
 	    if (in_bundle)
 	      {
 		rtx prev = PREV_INSN (insn);
-		PREV_INSN (next) = prev;
-		NEXT_INSN (prev) = next;
+		SET_PREV_INSN (next) = prev;
+		SET_NEXT_INSN (prev) = next;
 
-		PREV_INSN (insn) = queue;
+		SET_PREV_INSN (insn) = queue;
 		queue = insn;
 	      }
 	  }
diff --git a/gcc/config/tilepro/tilepro.c b/gcc/config/tilepro/tilepro.c
index e89a733..4dd60c5 100644
--- a/gcc/config/tilepro/tilepro.c
+++ b/gcc/config/tilepro/tilepro.c
@@ -4283,10 +4283,10 @@ reorder_var_tracking_notes (void)
 		while (queue)
 		  {
 		    rtx next_queue = PREV_INSN (queue);
-		    PREV_INSN (NEXT_INSN (insn)) = queue;
-		    NEXT_INSN (queue) = NEXT_INSN (insn);
-		    NEXT_INSN (insn) = queue;
-		    PREV_INSN (queue) = insn;
+		    SET_PREV_INSN (NEXT_INSN (insn)) = queue;
+		    SET_NEXT_INSN (queue) = NEXT_INSN (insn);
+		    SET_NEXT_INSN (insn) = queue;
+		    SET_PREV_INSN (queue) = insn;
 		    queue = next_queue;
 		  }
 		in_bundle = false;
@@ -4299,10 +4299,10 @@ reorder_var_tracking_notes (void)
 	    if (in_bundle)
 	      {
 		rtx prev = PREV_INSN (insn);
-		PREV_INSN (next) = prev;
-		NEXT_INSN (prev) = next;
+		SET_PREV_INSN (next) = prev;
+		SET_NEXT_INSN (prev) = next;
 
-		PREV_INSN (insn) = queue;
+		SET_PREV_INSN (insn) = queue;
 		queue = insn;
 	      }
 	  }
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index 2c3d8f7..729e0cc 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -3861,29 +3861,29 @@ make_note_raw (enum insn_note subtype)
 static inline void
 link_insn_into_chain (rtx insn, rtx prev, rtx next)
 {
-  PREV_INSN (insn) = prev;
-  NEXT_INSN (insn) = next;
+  SET_PREV_INSN (insn) = prev;
+  SET_NEXT_INSN (insn) = next;
   if (prev != NULL)
     {
-      NEXT_INSN (prev) = insn;
+      SET_NEXT_INSN (prev) = insn;
       if (NONJUMP_INSN_P (prev) && GET_CODE (PATTERN (prev)) == SEQUENCE)
 	{
 	  rtx sequence = PATTERN (prev);
-	  NEXT_INSN (XVECEXP (sequence, 0, XVECLEN (sequence, 0) - 1)) = insn;
+	  SET_NEXT_INSN (XVECEXP (sequence, 0, XVECLEN (sequence, 0) - 1)) = insn;
 	}
     }
   if (next != NULL)
     {
-      PREV_INSN (next) = insn;
+      SET_PREV_INSN (next) = insn;
       if (NONJUMP_INSN_P (next) && GET_CODE (PATTERN (next)) == SEQUENCE)
-	PREV_INSN (XVECEXP (PATTERN (next), 0, 0)) = insn;
+	SET_PREV_INSN (XVECEXP (PATTERN (next), 0, 0)) = insn;
     }
 
   if (NONJUMP_INSN_P (insn) && GET_CODE (PATTERN (insn)) == SEQUENCE)
     {
       rtx sequence = PATTERN (insn);
-      PREV_INSN (XVECEXP (sequence, 0, 0)) = prev;
-      NEXT_INSN (XVECEXP (sequence, 0, XVECLEN (sequence, 0) - 1)) = next;
+      SET_PREV_INSN (XVECEXP (sequence, 0, 0)) = prev;
+      SET_NEXT_INSN (XVECEXP (sequence, 0, XVECLEN (sequence, 0) - 1)) = next;
     }
 }
 
@@ -4055,17 +4055,17 @@ remove_insn (rtx insn)
 
   if (prev)
     {
-      NEXT_INSN (prev) = next;
+      SET_NEXT_INSN (prev) = next;
       if (NONJUMP_INSN_P (prev) && GET_CODE (PATTERN (prev)) == SEQUENCE)
 	{
 	  rtx sequence = PATTERN (prev);
-	  NEXT_INSN (XVECEXP (sequence, 0, XVECLEN (sequence, 0) - 1)) = next;
+	  SET_NEXT_INSN (XVECEXP (sequence, 0, XVECLEN (sequence, 0) - 1)) = next;
 	}
     }
   else if (get_insns () == insn)
     {
       if (next)
-        PREV_INSN (next) = NULL;
+        SET_PREV_INSN (next) = NULL;
       set_first_insn (next);
     }
   else
@@ -4084,9 +4084,9 @@ remove_insn (rtx insn)
 
   if (next)
     {
-      PREV_INSN (next) = prev;
+      SET_PREV_INSN (next) = prev;
       if (NONJUMP_INSN_P (next) && GET_CODE (PATTERN (next)) == SEQUENCE)
-	PREV_INSN (XVECEXP (PATTERN (next), 0, 0)) = prev;
+	SET_PREV_INSN (XVECEXP (PATTERN (next), 0, 0)) = prev;
     }
   else if (get_last_insn () == insn)
     set_last_insn (prev);
@@ -4152,7 +4152,7 @@ delete_insns_since (rtx from)
   if (from == 0)
     set_first_insn (0);
   else
-    NEXT_INSN (from) = 0;
+    SET_NEXT_INSN (from) = 0;
   set_last_insn (from);
 }
 
@@ -4178,9 +4178,9 @@ reorder_insns_nobb (rtx from, rtx to, rtx after)
 
   /* Splice this bunch out of where it is now.  */
   if (PREV_INSN (from))
-    NEXT_INSN (PREV_INSN (from)) = NEXT_INSN (to);
+    SET_NEXT_INSN (PREV_INSN (from)) = NEXT_INSN (to);
   if (NEXT_INSN (to))
-    PREV_INSN (NEXT_INSN (to)) = PREV_INSN (from);
+    SET_PREV_INSN (NEXT_INSN (to)) = PREV_INSN (from);
   if (get_last_insn () == to)
     set_last_insn (PREV_INSN (from));
   if (get_insns () == from)
@@ -4188,11 +4188,11 @@ reorder_insns_nobb (rtx from, rtx to, rtx after)
 
   /* Make the new neighbors point to it and it to them.  */
   if (NEXT_INSN (after))
-    PREV_INSN (NEXT_INSN (after)) = to;
+    SET_PREV_INSN (NEXT_INSN (after)) = to;
 
-  NEXT_INSN (to) = NEXT_INSN (after);
-  PREV_INSN (from) = after;
-  NEXT_INSN (after) = from;
+  SET_NEXT_INSN (to) = NEXT_INSN (after);
+  SET_PREV_INSN (from) = after;
+  SET_NEXT_INSN (after) = from;
   if (after == get_last_insn ())
     set_last_insn (to);
 }
@@ -4397,11 +4397,11 @@ emit_insn_after_1 (rtx first, rtx after, basic_block bb)
 
   after_after = NEXT_INSN (after);
 
-  NEXT_INSN (after) = first;
-  PREV_INSN (first) = after;
-  NEXT_INSN (last) = after_after;
+  SET_NEXT_INSN (after) = first;
+  SET_PREV_INSN (first) = after;
+  SET_NEXT_INSN (last) = after_after;
   if (after_after)
-    PREV_INSN (after_after) = last;
+    SET_PREV_INSN (after_after) = last;
 
   if (after == get_last_insn ())
     set_last_insn (last);
diff --git a/gcc/final.c b/gcc/final.c
index c32e177..c6339ae 100644
--- a/gcc/final.c
+++ b/gcc/final.c
@@ -2856,12 +2856,12 @@ final_scan_insn (rtx insn, FILE *file, int optimize_p ATTRIBUTE_UNUSED,
 		   when generating a far jump in a delayed branch
 		   sequence.  */
 		note = NEXT_INSN (insn);
-		PREV_INSN (note) = prev;
-		NEXT_INSN (prev) = note;
-		NEXT_INSN (PREV_INSN (next)) = insn;
-		PREV_INSN (insn) = PREV_INSN (next);
-		NEXT_INSN (insn) = next;
-		PREV_INSN (next) = insn;
+		SET_PREV_INSN (note) = prev;
+		SET_NEXT_INSN (prev) = note;
+		SET_NEXT_INSN (PREV_INSN (next)) = insn;
+		SET_PREV_INSN (insn) = PREV_INSN (next);
+		SET_NEXT_INSN (insn) = next;
+		SET_PREV_INSN (next) = insn;
 	      }
 
 	    /* PEEPHOLE might have changed this.  */
@@ -4624,8 +4624,8 @@ rest_of_clean_state (void)
   for (insn = get_insns (); insn; insn = next)
     {
       next = NEXT_INSN (insn);
-      NEXT_INSN (insn) = NULL;
-      PREV_INSN (insn) = NULL;
+      SET_NEXT_INSN (insn) = NULL;
+      SET_PREV_INSN (insn) = NULL;
 
       if (final_output
 	  && (!NOTE_P (insn) ||
diff --git a/gcc/gcse.c b/gcc/gcse.c
index 84a1147..163a529 100644
--- a/gcc/gcse.c
+++ b/gcc/gcse.c
@@ -865,7 +865,7 @@ can_assign_to_reg_without_clobbers_p (rtx x)
 				      gen_rtx_REG (word_mode,
 						   FIRST_PSEUDO_REGISTER * 2),
 				      const0_rtx));
-      NEXT_INSN (test_insn) = PREV_INSN (test_insn) = 0;
+      SET_NEXT_INSN (test_insn) = SET_PREV_INSN (test_insn) = 0;
     }
 
   /* Now make an insn like the one we would make when GCSE'ing and see if
diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c
index b3482e3..59c7fc9 100644
--- a/gcc/haifa-sched.c
+++ b/gcc/haifa-sched.c
@@ -3972,8 +3972,8 @@ concat_note_lists (rtx from_end, rtx *to_endp)
   while (PREV_INSN (from_start) != NULL)
     from_start = PREV_INSN (from_start);
 
-  PREV_INSN (from_start) = *to_endp;
-  NEXT_INSN (*to_endp) = from_start;
+  SET_PREV_INSN (from_start) = *to_endp;
+  SET_NEXT_INSN (*to_endp) = from_start;
   *to_endp = from_end;
 }
 
@@ -4014,10 +4014,10 @@ remove_notes (rtx head, rtx tail)
 	  remove_insn (insn);
 
 	  /* Add the note to list that ends at NOTE_LIST.  */
-	  PREV_INSN (insn) = note_list;
-	  NEXT_INSN (insn) = NULL_RTX;
+	  SET_PREV_INSN (insn) = note_list;
+	  SET_NEXT_INSN (insn) = NULL_RTX;
 	  if (note_list)
-	    NEXT_INSN (note_list) = insn;
+	    SET_NEXT_INSN (note_list) = insn;
 	  note_list = insn;
 	  break;
 	}
@@ -4810,10 +4810,10 @@ restore_other_notes (rtx head, basic_block head_bb)
       /* In the above cycle we've missed this note.  */
       set_block_for_insn (note_head, head_bb);
 
-      PREV_INSN (note_head) = PREV_INSN (head);
-      NEXT_INSN (PREV_INSN (head)) = note_head;
-      PREV_INSN (head) = note_list;
-      NEXT_INSN (note_list) = head;
+      SET_PREV_INSN (note_head) = PREV_INSN (head);
+      SET_NEXT_INSN (PREV_INSN (head)) = note_head;
+      SET_PREV_INSN (head) = note_list;
+      SET_NEXT_INSN (note_list) = head;
 
       if (BLOCK_FOR_INSN (head) != head_bb)
 	SET_BB_END (head_bb) = note_list;
@@ -5239,14 +5239,14 @@ move_insn (rtx insn, rtx last, rtx nt)
       else
 	note = insn;
 
-      NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (note);
-      PREV_INSN (NEXT_INSN (note)) = PREV_INSN (insn);
+      SET_NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (note);
+      SET_PREV_INSN (NEXT_INSN (note)) = PREV_INSN (insn);
 
-      NEXT_INSN (note) = NEXT_INSN (last);
-      PREV_INSN (NEXT_INSN (last)) = note;
+      SET_NEXT_INSN (note) = NEXT_INSN (last);
+      SET_PREV_INSN (NEXT_INSN (last)) = note;
 
-      NEXT_INSN (last) = insn;
-      PREV_INSN (insn) = last;
+      SET_NEXT_INSN (last) = insn;
+      SET_PREV_INSN (insn) = last;
 
       bb = BLOCK_FOR_INSN (last);
 
@@ -8166,8 +8166,8 @@ unlink_bb_notes (basic_block first, basic_block last)
       next = NEXT_INSN (note);
       gcc_assert (prev && next);
 
-      NEXT_INSN (prev) = next;
-      PREV_INSN (next) = prev;
+      SET_NEXT_INSN (prev) = next;
+      SET_PREV_INSN (next) = prev;
 
       bb_header[last->index] = label;
 
@@ -8208,9 +8208,9 @@ restore_bb_notes (basic_block first)
 
       bb_header[first->index] = 0;
 
-      NEXT_INSN (prev) = label;
-      NEXT_INSN (note) = next;
-      PREV_INSN (next) = note;
+      SET_NEXT_INSN (prev) = label;
+      SET_NEXT_INSN (note) = next;
+      SET_PREV_INSN (next) = note;
 
       first = first->next_bb;
     }
diff --git a/gcc/jump.c b/gcc/jump.c
index 9418f65..69263e6 100644
--- a/gcc/jump.c
+++ b/gcc/jump.c
@@ -1404,10 +1404,10 @@ delete_for_peephole (rtx from, rtx to)
 	  /* We don't do this all at once, because we
 	     must preserve all NOTEs.  */
 	  if (prev)
-	    NEXT_INSN (prev) = next;
+	    SET_NEXT_INSN (prev) = next;
 
 	  if (next)
-	    PREV_INSN (next) = prev;
+	    SET_PREV_INSN (next) = prev;
 	}
 
       if (insn == to)
diff --git a/gcc/optabs.c b/gcc/optabs.c
index ca1c194..24fc015 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -3956,12 +3956,12 @@ emit_libcall_block_1 (rtx insns, rtx target, rtx result, rtx equiv,
 	  if (! data.must_stay)
 	    {
 	      if (PREV_INSN (insn))
-		NEXT_INSN (PREV_INSN (insn)) = next;
+		SET_NEXT_INSN (PREV_INSN (insn)) = next;
 	      else
 		insns = next;
 
 	      if (next)
-		PREV_INSN (next) = PREV_INSN (insn);
+		SET_PREV_INSN (next) = PREV_INSN (insn);
 
 	      add_insn (insn);
 	    }
diff --git a/gcc/reorg.c b/gcc/reorg.c
index e4b6d45..75819bc 100644
--- a/gcc/reorg.c
+++ b/gcc/reorg.c
@@ -516,7 +516,7 @@ emit_delay_sequence (rtx insn, rtx list, int length)
      the SEQUENCE.   Remember where we want to emit SEQUENCE in AFTER.  */
   rtx after = PREV_INSN (insn);
   remove_insn (insn);
-  NEXT_INSN (insn) = PREV_INSN (insn) = NULL;
+  SET_NEXT_INSN (insn) = SET_PREV_INSN (insn) = NULL;
 
   /* Build our SEQUENCE and rebuild the insn chain.  */
   int i = 1;
@@ -532,7 +532,7 @@ emit_delay_sequence (rtx insn, rtx list, int length)
 
       /* Unlink insn from its original place, and re-emit it into
 	 the sequence.  */
-      NEXT_INSN (tem) = PREV_INSN (tem) = NULL;
+      SET_NEXT_INSN (tem) = SET_PREV_INSN (tem) = NULL;
       XVECEXP (seq, 0, i) = emit_insn (tem);
 
       /* SPARC assembler, for instance, emit warning when debug info is output
@@ -2015,9 +2015,9 @@ fill_simple_delay_slots (int non_jumps_p)
 	    rtx next = NEXT_INSN (trial);
 	    rtx prev = PREV_INSN (trial);
 	    if (prev)
-	      NEXT_INSN (prev) = next;
+	      SET_NEXT_INSN (prev) = next;
 	    if (next)
-	      PREV_INSN (next) = prev;
+	      SET_PREV_INSN (next) = prev;
 	  }
 	}
 
diff --git a/gcc/rtl.h b/gcc/rtl.h
index 3e37ed0..e08f05b 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -972,8 +972,15 @@ extern void rtl_check_failed_flag (const char *, const_rtx, const char *,
   (RTL_INSN_CHAIN_FLAG_CHECK ("INSN_UID", (INSN))->u2.insn_uid)
 
 /* Chain insns together in sequence.  */
-#define PREV_INSN(INSN)	XEXP (INSN, 0)
-#define NEXT_INSN(INSN)	XEXP (INSN, 1)
+/* For now these are split in two: an rvalue form:
+     PREV_INSN/NEXT_INSN
+   and an lvalue form:
+     SET_NEXT_INSN/SET_PREV_INSN.  */
+
+#define PREV_INSN(INSN)      XEXP ((const_rtx)(INSN), 0)
+#define SET_PREV_INSN(INSN)  XEXP (INSN, 0)
+#define NEXT_INSN(INSN)      XEXP ((const_rtx)(INSN), 1)
+#define SET_NEXT_INSN(INSN)  XEXP (INSN, 1)
 
 #define BLOCK_FOR_INSN(INSN) XBBDEF (INSN, 2)
 
diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c
index 7eccdf9..c1a8a48 100644
--- a/gcc/sel-sched-ir.c
+++ b/gcc/sel-sched-ir.c
@@ -1423,11 +1423,11 @@ sel_move_insn (expr_t expr, int seqno, insn_t after)
 
   /* Assert that in move_op we disconnected this insn properly.  */
   gcc_assert (EXPR_VINSN (INSN_EXPR (insn)) != NULL);
-  PREV_INSN (insn) = after;
-  NEXT_INSN (insn) = next;
+  SET_PREV_INSN (insn) = after;
+  SET_NEXT_INSN (insn) = next;
 
-  NEXT_INSN (after) = insn;
-  PREV_INSN (next) = insn;
+  SET_NEXT_INSN (after) = insn;
+  SET_PREV_INSN (next) = insn;
 
   /* Update links from insn to bb and vice versa.  */
   df_insn_change_bb (insn, bb);
@@ -3947,8 +3947,8 @@ sel_remove_insn (insn_t insn, bool only_disconnect, bool full_tidying)
   /* It is necessary to NULL these fields in case we are going to re-insert
      INSN into the insns stream, as will usually happen in the ONLY_DISCONNECT
      case, but also for NOPs that we will return to the nop pool.  */
-  PREV_INSN (insn) = NULL_RTX;
-  NEXT_INSN (insn) = NULL_RTX;
+  SET_PREV_INSN (insn) = NULL_RTX;
+  SET_NEXT_INSN (insn) = NULL_RTX;
   set_block_for_insn (insn, NULL);
 
   return tidy_control_flow (bb, full_tidying);
@@ -4990,8 +4990,8 @@ get_bb_note_from_pool (void)
     {
       rtx note = bb_note_pool.pop ();
 
-      PREV_INSN (note) = NULL_RTX;
-      NEXT_INSN (note) = NULL_RTX;
+      SET_PREV_INSN (note) = NULL_RTX;
+      SET_NEXT_INSN (note) = NULL_RTX;
 
       return note;
     }
diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c
index bfbd2fe..1df2da0 100644
--- a/gcc/sel-sched.c
+++ b/gcc/sel-sched.c
@@ -5200,14 +5200,14 @@ move_nop_to_previous_block (insn_t nop, basic_block prev_bb)
   gcc_assert (prev_insn != NULL_RTX
               && PREV_INSN (note) == prev_insn);
 
-  NEXT_INSN (prev_insn) = nop;
-  PREV_INSN (nop) = prev_insn;
+  SET_NEXT_INSN (prev_insn) = nop;
+  SET_PREV_INSN (nop) = prev_insn;
 
-  PREV_INSN (note) = nop;
-  NEXT_INSN (note) = next_insn;
+  SET_PREV_INSN (note) = nop;
+  SET_NEXT_INSN (note) = next_insn;
 
-  NEXT_INSN (nop) = note;
-  PREV_INSN (next_insn) = note;
+  SET_NEXT_INSN (nop) = note;
+  SET_PREV_INSN (next_insn) = note;
 
   SET_BB_END (prev_bb) = nop;
   BLOCK_FOR_INSN (nop) = prev_bb;
diff --git a/rtx-classes-status.txt b/rtx-classes-status.txt
index c1039bc..e57d775 100644
--- a/rtx-classes-status.txt
+++ b/rtx-classes-status.txt
@@ -11,3 +11,4 @@ Phase 6: use extra rtx_def subclasses:             TODO
 TODO: "Scaffolding" to be removed
 =================================
 * SET_BB_HEAD, SET_BB_END, SET_BB_HEADER, SET_BB_FOOTER
+* SET_NEXT_INSN, SET_PREV_INSN
-- 
1.8.5.3

