This is an enabling patch, splitting existing macros in two, covering
the rvalue and lvalue uses separately.

Followup patches will replace these with functions, and gradually convert
the types from rtx to rtx_insn *, but we need to do this separately for
the lvalue vs rvalue use-cases, hence this patch.

The plan is to eventually eliminate the split in a further followup patch,
and convert them back to macros, where the underlying fields are of type
rtx_insn *.

gcc/
        * basic-block.h (BB_HEAD): Split macro in two: the existing one,
        for rvalues, and...
        (SET_BB_HEAD): New macro, for use as a lvalue.
        (BB_END, SET_BB_END): Likewise.
        (BB_HEADER, SET_BB_HEADER): Likewise.
        (BB_FOOTER, SET_BB_FOOTER): Likewise.

        * bb-reorder.c (add_labels_and_missing_jumps): Convert lvalue use
        of BB_* macros into SET_BB_* macros.
        (fix_crossing_unconditional_branches): Likewise.
        * caller-save.c (save_call_clobbered_regs): Likewise.
        (insert_one_insn): Likewise.
        * cfgbuild.c (find_bb_boundaries): Likewise.
        * cfgcleanup.c (merge_blocks_move_successor_nojumps): Likewise.
        (outgoing_edges_match): Likewise.
        (try_optimize_cfg): Likewise.
        * cfgexpand.c (expand_gimple_cond): Likewise.
        (expand_gimple_tailcall): Likewise.
        (expand_gimple_basic_block): Likewise.
        (construct_exit_block): Likewise.
        * cfgrtl.c (delete_insn): Likewise.
        (create_basic_block_structure): Likewise.
        (rtl_delete_block): Likewise.
        (rtl_split_block): Likewise.
        (emit_nop_for_unique_locus_between): Likewise.
        (rtl_merge_blocks): Likewise.
        (block_label): Likewise.
        (try_redirect_by_replacing_jump): Likewise.
        (emit_barrier_after_bb): Likewise.
        (fixup_abnormal_edges): Likewise.
        (record_effective_endpoints): Likewise.
        (relink_block_chain): Likewise.
        (fixup_reorder_chain): Likewise.
        (fixup_fallthru_exit_predecessor): Likewise.
        (cfg_layout_duplicate_bb): Likewise.
        (cfg_layout_split_block): Likewise.
        (cfg_layout_delete_block): Likewise.
        (cfg_layout_merge_blocks): Likewise.
        * combine.c (update_cfg_for_uncondjump): Likewise.
        * emit-rtl.c (add_insn_after): Likewise.
        (remove_insn): Likewise.
        (reorder_insns): Likewise.
        (emit_insn_after_1): Likewise.
        * haifa-sched.c (get_ebb_head_tail): Likewise.
        (restore_other_notes): Likewise.
        (move_insn): Likewise.
        (sched_extend_bb): Likewise.
        (fix_jump_move): Likewise.
        * ifcvt.c (noce_process_if_block): Likewise.
        (dead_or_predicable): Likewise.
        * ira.c (update_equiv_regs): Likewise.
        * reg-stack.c (change_stack): Likewise.
        * sel-sched-ir.c (sel_move_insn): Likewise.
        * sel-sched.c (move_nop_to_previous_block): Likewise.

        * config/c6x/c6x.c (hwloop_optimize): Likewise.
        * config/ia64/ia64.c (emit_predicate_relation_info): Likewise.

/
        * rtx-classes-status.txt (TODO): Add SET_BB_HEAD, SET_BB_END,
        SET_BB_HEADER, SET_BB_FOOTER
---
 gcc/basic-block.h      | 15 +++++++---
 gcc/bb-reorder.c       |  4 +--
 gcc/caller-save.c      |  6 ++--
 gcc/cfgbuild.c         |  4 +--
 gcc/cfgcleanup.c       | 14 +++++-----
 gcc/cfgexpand.c        | 22 +++++++--------
 gcc/cfgrtl.c           | 74 +++++++++++++++++++++++++-------------------------
 gcc/combine.c          |  2 +-
 gcc/config/c6x/c6x.c   |  4 +--
 gcc/config/ia64/ia64.c |  6 ++--
 gcc/emit-rtl.c         | 12 ++++----
 gcc/haifa-sched.c      | 18 ++++++------
 gcc/ifcvt.c            |  4 +--
 gcc/ira.c              |  2 +-
 gcc/reg-stack.c        |  2 +-
 gcc/sel-sched-ir.c     |  2 +-
 gcc/sel-sched.c        |  2 +-
 rtx-classes-status.txt |  4 +++
 18 files changed, 104 insertions(+), 93 deletions(-)

diff --git a/gcc/basic-block.h b/gcc/basic-block.h
index 0bf6e87..d27f498 100644
--- a/gcc/basic-block.h
+++ b/gcc/basic-block.h
@@ -368,10 +368,17 @@ struct GTY(()) control_flow_graph {
 
 /* Stuff for recording basic block info.  */
 
-#define BB_HEAD(B)      (B)->il.x.head_
-#define BB_END(B)       (B)->il.x.rtl->end_
-#define BB_HEADER(B)    (B)->il.x.rtl->header_
-#define BB_FOOTER(B)    (B)->il.x.rtl->footer_
+/* These macros are currently split into two:
+   one suitable for reading, and for writing.
+   These will become functions in a follow-up patch.  */
+#define BB_HEAD(B)      (((const_basic_block)B)->il.x.head_)
+#define SET_BB_HEAD(B)  (B)->il.x.head_
+#define BB_END(B)       (((const rtl_bb_info *)(B)->il.x.rtl)->end_)
+#define SET_BB_END(B)   (B)->il.x.rtl->end_
+#define BB_HEADER(B)    (((const rtl_bb_info *)(B)->il.x.rtl)->header_)
+#define SET_BB_HEADER(B) (B)->il.x.rtl->header_
+#define BB_FOOTER(B)    (((const rtl_bb_info *)(B)->il.x.rtl)->footer_)
+#define SET_BB_FOOTER(B) (B)->il.x.rtl->footer_
 
 /* Special block numbers [markers] for entry and exit.
    Neither of them is supposed to hold actual statements.  */
diff --git a/gcc/bb-reorder.c b/gcc/bb-reorder.c
index 61b0cab..2d3e6eb 100644
--- a/gcc/bb-reorder.c
+++ b/gcc/bb-reorder.c
@@ -1757,7 +1757,7 @@ add_labels_and_missing_jumps (vec<edge> crossing_edges)
       gcc_assert (single_succ_p (src));
 
       new_jump = emit_jump_insn_after (gen_jump (label), BB_END (src));
-      BB_END (src) = new_jump;
+      SET_BB_END (src) = new_jump;
       JUMP_LABEL (new_jump) = label;
       LABEL_NUSES (label) += 1;
 
@@ -2188,7 +2188,7 @@ fix_crossing_unconditional_branches (void)
              /* Make BB_END for cur_bb be the jump instruction (NOT the
                 barrier instruction at the end of the sequence...).  */
 
-             BB_END (cur_bb) = jump_insn;
+             SET_BB_END (cur_bb) = jump_insn;
            }
        }
     }
diff --git a/gcc/caller-save.c b/gcc/caller-save.c
index 64fd66c..41b3f01 100644
--- a/gcc/caller-save.c
+++ b/gcc/caller-save.c
@@ -921,7 +921,7 @@ save_call_clobbered_regs (void)
                      if (NEXT_INSN (ins))
                        PREV_INSN (NEXT_INSN (ins)) = ins;
                       if (BB_END (bb) == insn)
-                       BB_END (bb) = ins;
+                       SET_BB_END (bb) = ins;
                    }
                  else
                    gcc_assert (DEBUG_INSN_P (ins));
@@ -1418,7 +1418,7 @@ insert_one_insn (struct insn_chain *chain, int before_p, 
int code, rtx pat)
 
       CLEAR_REG_SET (&new_chain->dead_or_set);
       if (chain->insn == BB_HEAD (BASIC_BLOCK_FOR_FN (cfun, chain->block)))
-       BB_HEAD (BASIC_BLOCK_FOR_FN (cfun, chain->block)) = new_chain->insn;
+       SET_BB_HEAD (BASIC_BLOCK_FOR_FN (cfun, chain->block)) = new_chain->insn;
     }
   else
     {
@@ -1438,7 +1438,7 @@ insert_one_insn (struct insn_chain *chain, int before_p, 
int code, rtx pat)
                   &new_chain->live_throughout);
       CLEAR_REG_SET (&new_chain->dead_or_set);
       if (chain->insn == BB_END (BASIC_BLOCK_FOR_FN (cfun, chain->block)))
-       BB_END (BASIC_BLOCK_FOR_FN (cfun, chain->block)) = new_chain->insn;
+       SET_BB_END (BASIC_BLOCK_FOR_FN (cfun, chain->block)) = new_chain->insn;
     }
   new_chain->block = chain->block;
   new_chain->is_caller_save_insn = 1;
diff --git a/gcc/cfgbuild.c b/gcc/cfgbuild.c
index ae1f114..76d3a99 100644
--- a/gcc/cfgbuild.c
+++ b/gcc/cfgbuild.c
@@ -467,7 +467,7 @@ find_bb_boundaries (basic_block bb)
          fallthru = split_block (bb, PREV_INSN (insn));
          if (flow_transfer_insn)
            {
-             BB_END (bb) = flow_transfer_insn;
+             SET_BB_END (bb) = flow_transfer_insn;
 
              /* Clean up the bb field for the insns between the blocks.  */
              for (x = NEXT_INSN (flow_transfer_insn);
@@ -504,7 +504,7 @@ find_bb_boundaries (basic_block bb)
      ordinary jump, we need to take care and move basic block boundary.  */
   if (flow_transfer_insn)
     {
-      BB_END (bb) = flow_transfer_insn;
+      SET_BB_END (bb) = flow_transfer_insn;
 
       /* Clean up the bb field for the insns that do not belong to BB.  */
       x = flow_transfer_insn;
diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c
index 7c24a6d..b6cb77b 100644
--- a/gcc/cfgcleanup.c
+++ b/gcc/cfgcleanup.c
@@ -726,7 +726,7 @@ merge_blocks_move_successor_nojumps (basic_block a, 
basic_block b)
   if (tablejump_p (BB_END (b), &label, &table)
       && prev_active_insn (label) == BB_END (b))
     {
-      BB_END (b) = table;
+      SET_BB_END (b) = table;
     }
 
   /* There had better have been a barrier there.  Delete it.  */
@@ -739,7 +739,7 @@ merge_blocks_move_successor_nojumps (basic_block a, 
basic_block b)
   reorder_insns_nobb (BB_HEAD (b), BB_END (b), BB_END (a));
 
   /* Restore the real end of b.  */
-  BB_END (b) = real_b_end;
+  SET_BB_END (b) = real_b_end;
 
   if (dump_file)
     fprintf (dump_file, "Moved block %d after %d and merged.\n",
@@ -1723,7 +1723,7 @@ outgoing_edges_match (int mode, basic_block bb1, 
basic_block bb2)
                  rr.r1 = label1;
                  rr.r2 = label2;
                  rr.update_label_nuses = false;
-                 for_each_rtx (&BB_END (bb1), replace_label, &rr);
+                 for_each_rtx (&SET_BB_END (bb1), replace_label, &rr);
 
                  match = (old_insns_match_p (mode, BB_END (bb1), BB_END (bb2))
                           == dir_both);
@@ -1737,7 +1737,7 @@ outgoing_edges_match (int mode, basic_block bb1, 
basic_block bb2)
                     from the instruction is deleted too.  */
                  rr.r1 = label2;
                  rr.r2 = label1;
-                 for_each_rtx (&BB_END (bb1), replace_label, &rr);
+                 for_each_rtx (&SET_BB_END (bb1), replace_label, &rr);
 
                  return match;
                }
@@ -2673,13 +2673,13 @@ try_optimize_cfg (int mode)
                                {
                                  if (BB_FOOTER (b))
                                    {
-                                     BB_FOOTER (e->src) = BB_FOOTER (b);
-                                     BB_FOOTER (b) = NULL;
+                                     SET_BB_FOOTER (e->src) = BB_FOOTER (b);
+                                     SET_BB_FOOTER (b) = NULL;
                                    }
                                  else
                                    {
                                      start_sequence ();
-                                     BB_FOOTER (e->src) = emit_barrier ();
+                                     SET_BB_FOOTER (e->src) = emit_barrier ();
                                      end_sequence ();
                                    }
                                }
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index d124d94..df52c08 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -2158,9 +2158,9 @@ expand_gimple_cond (basic_block bb, gimple stmt)
     set_curr_insn_location (false_edge->goto_locus);
   emit_jump (label_rtx_for_bb (false_edge->dest));
 
-  BB_END (bb) = last;
+  SET_BB_END (bb) = last;
   if (BARRIER_P (BB_END (bb)))
-    BB_END (bb) = PREV_INSN (BB_END (bb));
+    SET_BB_END (bb) = PREV_INSN (BB_END (bb));
   update_bb_for_insn (bb);
 
   new_bb = create_basic_block (NEXT_INSN (last), get_last_insn (), bb);
@@ -2175,7 +2175,7 @@ expand_gimple_cond (basic_block bb, gimple stmt)
   new_edge->probability = REG_BR_PROB_BASE;
   new_edge->count = new_bb->count;
   if (BARRIER_P (BB_END (new_bb)))
-    BB_END (new_bb) = PREV_INSN (BB_END (new_bb));
+    SET_BB_END (new_bb) = PREV_INSN (BB_END (new_bb));
   update_bb_for_insn (new_bb);
 
   maybe_dump_rtl_for_gimple_stmt (stmt, last2);
@@ -3468,7 +3468,7 @@ expand_gimple_tailcall (basic_block bb, gimple stmt, bool 
*can_fallthru)
                 | EDGE_SIBCALL);
   e->probability += probability;
   e->count += count;
-  BB_END (bb) = last;
+  SET_BB_END (bb) = last;
   update_bb_for_insn (bb);
 
   if (NEXT_INSN (last))
@@ -3477,7 +3477,7 @@ expand_gimple_tailcall (basic_block bb, gimple stmt, bool 
*can_fallthru)
 
       last = BB_END (bb);
       if (BARRIER_P (last))
-       BB_END (bb) = PREV_INSN (last);
+       SET_BB_END (bb) = PREV_INSN (last);
     }
 
   maybe_dump_rtl_for_gimple_stmt (stmt, last2);
@@ -4941,15 +4941,15 @@ expand_gimple_basic_block (basic_block bb, bool 
disable_tail_calls)
 
       /* Java emits line number notes in the top of labels.
         ??? Make this go away once line number notes are obsoleted.  */
-      BB_HEAD (bb) = NEXT_INSN (last);
+      SET_BB_HEAD (bb) = NEXT_INSN (last);
       if (NOTE_P (BB_HEAD (bb)))
-       BB_HEAD (bb) = NEXT_INSN (BB_HEAD (bb));
+       SET_BB_HEAD (bb) = NEXT_INSN (BB_HEAD (bb));
       note = emit_note_after (NOTE_INSN_BASIC_BLOCK, BB_HEAD (bb));
 
       maybe_dump_rtl_for_gimple_stmt (stmt, last);
     }
   else
-    note = BB_HEAD (bb) = emit_note (NOTE_INSN_BASIC_BLOCK);
+    note = SET_BB_HEAD (bb) = emit_note (NOTE_INSN_BASIC_BLOCK);
 
   NOTE_BASIC_BLOCK (note) = bb;
 
@@ -5232,7 +5232,7 @@ expand_gimple_basic_block (basic_block bb, bool 
disable_tail_calls)
     last = PREV_INSN (last);
   if (JUMP_TABLE_DATA_P (last))
     last = PREV_INSN (PREV_INSN (last));
-  BB_END (bb) = last;
+  SET_BB_END (bb) = last;
 
   update_bb_for_insn (bb);
 
@@ -5335,7 +5335,7 @@ construct_exit_block (void)
     return;
   /* While emitting the function end we could move end of the last basic
      block.  */
-  BB_END (prev_bb) = orig_end;
+  SET_BB_END (prev_bb) = orig_end;
   while (NEXT_INSN (head) && NOTE_P (NEXT_INSN (head)))
     head = NEXT_INSN (head);
   /* But make sure exit_block starts with RETURN_LABEL, otherwise the
@@ -5347,7 +5347,7 @@ construct_exit_block (void)
       while (NEXT_INSN (head) != return_label)
        {
          if (!NOTE_P (NEXT_INSN (head)))
-           BB_END (prev_bb) = NEXT_INSN (head);
+           SET_BB_END (prev_bb) = NEXT_INSN (head);
          head = NEXT_INSN (head);
        }
     }
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index 49faf2e..026fb48 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -152,9 +152,9 @@ delete_insn (rtx insn)
              && bb == BLOCK_FOR_INSN (bb_note))
            {
              reorder_insns_nobb (insn, insn, bb_note);
-             BB_HEAD (bb) = bb_note;
+             SET_BB_HEAD (bb) = bb_note;
              if (BB_END (bb) == bb_note)
-               BB_END (bb) = insn;
+               SET_BB_END (bb) = insn;
            }
        }
 
@@ -326,8 +326,8 @@ create_basic_block_structure (rtx head, rtx end, rtx 
bb_note, basic_block after)
   if (NEXT_INSN (end) == bb_note)
     end = bb_note;
 
-  BB_HEAD (bb) = head;
-  BB_END (bb) = end;
+  SET_BB_HEAD (bb) = head;
+  SET_BB_END (bb) = end;
   bb->index = last_basic_block_for_fn (cfun)++;
   bb->flags = BB_NEW | BB_RTL;
   link_block (bb, after);
@@ -400,7 +400,7 @@ rtl_delete_block (basic_block b)
   end = get_last_bb_insn (b);
 
   /* Selectively delete the entire chain.  */
-  BB_HEAD (b) = NULL;
+  SET_BB_HEAD (b) = NULL;
   delete_insn_chain (insn, end, true);
 
 
@@ -744,7 +744,7 @@ rtl_split_block (basic_block bb, void *insnp)
   /* Create the new basic block.  */
   new_bb = create_basic_block (NEXT_INSN (insn), BB_END (bb), bb);
   BB_COPY_PARTITION (new_bb, bb);
-  BB_END (bb) = insn;
+  SET_BB_END (bb) = insn;
 
   /* Redirect the outgoing edges.  */
   new_bb->succs = bb->succs;
@@ -803,7 +803,7 @@ emit_nop_for_unique_locus_between (basic_block a, 
basic_block b)
   if (!unique_locus_on_edge_between_p (a, b))
     return;
 
-  BB_END (a) = emit_insn_after_noloc (gen_nop (), BB_END (a), a);
+  SET_BB_END (a) = emit_insn_after_noloc (gen_nop (), BB_END (a), a);
   INSN_LOCATION (BB_END (a)) = EDGE_SUCC (a, 0)->goto_locus;
 }
 
@@ -885,8 +885,8 @@ rtl_merge_blocks (basic_block a, basic_block b)
 
   /* Delete everything marked above as well as crap that might be
      hanging out between the two blocks.  */
-  BB_END (a) = a_end;
-  BB_HEAD (b) = b_empty ? NULL_RTX : b_head;
+  SET_BB_END (a) = a_end;
+  SET_BB_HEAD (b) = b_empty ? NULL_RTX : b_head;
   delete_insn_chain (del_first, del_last, true);
 
   /* When not optimizing and the edge is the only place in RTL which holds
@@ -902,8 +902,8 @@ rtl_merge_blocks (basic_block a, basic_block b)
     {
       update_bb_for_insn_chain (a_end, b_debug_end, a);
 
-      BB_END (a) = b_debug_end;
-      BB_HEAD (b) = NULL_RTX;
+      SET_BB_END (a) = b_debug_end;
+      SET_BB_HEAD (b) = NULL_RTX;
     }
   else if (b_end != b_debug_end)
     {
@@ -915,7 +915,7 @@ rtl_merge_blocks (basic_block a, basic_block b)
        reorder_insns_nobb (NEXT_INSN (a_end), PREV_INSN (b_debug_start),
                            b_debug_end);
       update_bb_for_insn_chain (b_debug_start, b_debug_end, a);
-      BB_END (a) = b_debug_end;
+      SET_BB_END (a) = b_debug_end;
     }
 
   df_bb_delete (b->index);
@@ -980,7 +980,7 @@ block_label (basic_block block)
 
   if (!LABEL_P (BB_HEAD (block)))
     {
-      BB_HEAD (block) = emit_label_before (gen_label_rtx (), BB_HEAD (block));
+      SET_BB_HEAD (block) = emit_label_before (gen_label_rtx (), BB_HEAD 
(block));
     }
 
   return BB_HEAD (block);
@@ -1063,7 +1063,7 @@ try_redirect_by_replacing_jump (edge e, basic_block 
target, bool in_cfglayout)
                  if (PREV_INSN (insn))
                    NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn);
                  else
-                   BB_FOOTER (src) = NEXT_INSN (insn);
+                   SET_BB_FOOTER (src) = NEXT_INSN (insn);
                  if (NEXT_INSN (insn))
                    PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn);
                }
@@ -1448,7 +1448,7 @@ emit_barrier_after_bb (basic_block bb)
   gcc_assert (current_ir_type () == IR_RTL_CFGRTL
               || current_ir_type () == IR_RTL_CFGLAYOUT);
   if (current_ir_type () == IR_RTL_CFGLAYOUT)
-    BB_FOOTER (bb) = unlink_insn_chain (barrier, barrier);
+    SET_BB_FOOTER (bb) = unlink_insn_chain (barrier, barrier);
 }
 
 /* Like force_nonfallthru below, but additionally performs redirection
@@ -3253,7 +3253,7 @@ fixup_abnormal_edges (void)
              e = find_fallthru_edge (bb->succs);
 
              stop = NEXT_INSN (BB_END (bb));
-             BB_END (bb) = insn;
+             SET_BB_END (bb) = insn;
 
              for (insn = NEXT_INSN (insn); insn != stop; insn = next)
                {
@@ -3449,11 +3449,11 @@ record_effective_endpoints (void)
       rtx end;
 
       if (PREV_INSN (BB_HEAD (bb)) && next_insn != BB_HEAD (bb))
-       BB_HEADER (bb) = unlink_insn_chain (next_insn,
-                                             PREV_INSN (BB_HEAD (bb)));
+       SET_BB_HEADER (bb) = unlink_insn_chain (next_insn,
+                                               PREV_INSN (BB_HEAD (bb)));
       end = skip_insns_after_block (bb);
       if (NEXT_INSN (BB_END (bb)) && BB_END (bb) != end)
-       BB_FOOTER (bb) = unlink_insn_chain (NEXT_INSN (BB_END (bb)), end);
+       SET_BB_FOOTER (bb) = unlink_insn_chain (NEXT_INSN (BB_END (bb)), end);
       next_insn = NEXT_INSN (BB_END (bb));
     }
 
@@ -3613,7 +3613,7 @@ relink_block_chain (bool stay_in_cfglayout_mode)
     {
       bb->aux = NULL;
       if (!stay_in_cfglayout_mode)
-       BB_HEADER (bb) = BB_FOOTER (bb) = NULL;
+       SET_BB_HEADER (bb) = SET_BB_FOOTER (bb) = NULL;
     }
 
   /* Maybe reset the original copy tables, they are not valid anymore
@@ -3906,8 +3906,8 @@ fixup_reorder_chain (void)
                }
              nb = split_edge (e);
              if (!INSN_P (BB_END (nb)))
-               BB_END (nb) = emit_insn_after_noloc (gen_nop (), BB_END (nb),
-                                                    nb);
+               SET_BB_END (nb) = emit_insn_after_noloc (gen_nop (), BB_END 
(nb),
+                                                        nb);
              INSN_LOCATION (BB_END (nb)) = e->goto_locus;
 
              /* If there are other incoming edges to the destination block
@@ -3981,8 +3981,8 @@ fixup_fallthru_exit_predecessor (void)
          bb = split_block (bb, NULL)->dest;
          bb->aux = c->aux;
          c->aux = bb;
-         BB_FOOTER (bb) = BB_FOOTER (c);
-         BB_FOOTER (c) = NULL;
+         SET_BB_FOOTER (bb) = BB_FOOTER (c);
+         SET_BB_FOOTER (c) = NULL;
        }
 
       while (c->aux != bb)
@@ -4185,7 +4185,7 @@ cfg_layout_duplicate_bb (basic_block bb)
        insn = NEXT_INSN (insn);
       insn = duplicate_insn_chain (BB_HEADER (bb), insn);
       if (insn)
-       BB_HEADER (new_bb) = unlink_insn_chain (insn, get_last_insn ());
+       SET_BB_HEADER (new_bb) = unlink_insn_chain (insn, get_last_insn ());
     }
 
   if (BB_FOOTER (bb))
@@ -4195,7 +4195,7 @@ cfg_layout_duplicate_bb (basic_block bb)
        insn = NEXT_INSN (insn);
       insn = duplicate_insn_chain (BB_FOOTER (bb), insn);
       if (insn)
-       BB_FOOTER (new_bb) = unlink_insn_chain (insn, get_last_insn ());
+       SET_BB_FOOTER (new_bb) = unlink_insn_chain (insn, get_last_insn ());
     }
 
   return new_bb;
@@ -4303,8 +4303,8 @@ cfg_layout_split_block (basic_block bb, void *insnp)
   rtx insn = (rtx) insnp;
   basic_block new_bb = rtl_split_block (bb, insn);
 
-  BB_FOOTER (new_bb) = BB_FOOTER (bb);
-  BB_FOOTER (bb) = NULL;
+  SET_BB_FOOTER (new_bb) = BB_FOOTER (bb);
+  SET_BB_FOOTER (bb) = NULL;
 
   return new_bb;
 }
@@ -4434,7 +4434,7 @@ cfg_layout_delete_block (basic_block bb)
              if (PREV_INSN (insn))
                NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn);
              else
-               BB_FOOTER (bb) = NEXT_INSN (insn);
+               SET_BB_FOOTER (bb) = NEXT_INSN (insn);
              if (NEXT_INSN (insn))
                PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn);
            }
@@ -4457,7 +4457,7 @@ cfg_layout_delete_block (basic_block bb)
        }
     }
   if (bb->next_bb != EXIT_BLOCK_PTR_FOR_FN (cfun))
-    to = &BB_HEADER (bb->next_bb);
+    to = &SET_BB_HEADER (bb->next_bb);
   else
     to = &cfg_layout_function_footer;
 
@@ -4569,7 +4569,7 @@ cfg_layout_merge_blocks (basic_block a, basic_block b)
   if (BB_FOOTER (b))
     {
       if (!BB_FOOTER (a))
-       BB_FOOTER (a) = BB_FOOTER (b);
+       SET_BB_FOOTER (a) = SET_BB_FOOTER (b);
       else
        {
          rtx last = BB_FOOTER (a);
@@ -4579,7 +4579,7 @@ cfg_layout_merge_blocks (basic_block a, basic_block b)
          NEXT_INSN (last) = BB_FOOTER (b);
          PREV_INSN (BB_FOOTER (b)) = last;
        }
-      BB_FOOTER (b) = NULL;
+      SET_BB_FOOTER (b) = NULL;
     }
 
   /* Move things from b->header before a->footer.
@@ -4588,7 +4588,7 @@ cfg_layout_merge_blocks (basic_block a, basic_block b)
    if (BB_HEADER (b))
      {
       if (! BB_FOOTER (a))
-       BB_FOOTER (a) = BB_HEADER (b);
+       SET_BB_FOOTER (a) = BB_HEADER (b);
       else
        {
          rtx last = BB_HEADER (b);
@@ -4597,9 +4597,9 @@ cfg_layout_merge_blocks (basic_block a, basic_block b)
            last = NEXT_INSN (last);
          NEXT_INSN (last) = BB_FOOTER (a);
          PREV_INSN (BB_FOOTER (a)) = last;
-         BB_FOOTER (a) = BB_HEADER (b);
+         SET_BB_FOOTER (a) = BB_HEADER (b);
        }
-      BB_HEADER (b) = NULL;
+      SET_BB_HEADER (b) = NULL;
     }
 
   /* In the case basic blocks are not adjacent, move them around.  */
@@ -4613,7 +4613,7 @@ cfg_layout_merge_blocks (basic_block a, basic_block b)
   else
     {
       insn = BB_HEAD (b);
-      BB_END (a) = BB_END (b);
+      SET_BB_END (a) = BB_END (b);
     }
 
   /* emit_insn_after_noloc doesn't call df_insn_change_bb.
@@ -4624,7 +4624,7 @@ cfg_layout_merge_blocks (basic_block a, basic_block b)
   if (!NOTE_INSN_BASIC_BLOCK_P (insn))
     insn = NEXT_INSN (insn);
   gcc_assert (NOTE_INSN_BASIC_BLOCK_P (insn));
-  BB_HEAD (b) = BB_END (b) = NULL;
+  SET_BB_HEAD (b) = SET_BB_END (b) = NULL;
   delete_insn (insn);
 
   df_bb_delete (b->index);
diff --git a/gcc/combine.c b/gcc/combine.c
index 72bde7a..3cc8f2b 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -2393,7 +2393,7 @@ update_cfg_for_uncondjump (rtx insn)
            if (PREV_INSN (insn))
              NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn);
            else
-             BB_FOOTER (bb) = NEXT_INSN (insn);
+             SET_BB_FOOTER (bb) = NEXT_INSN (insn);
            if (NEXT_INSN (insn))
              PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn);
          }
diff --git a/gcc/config/c6x/c6x.c b/gcc/config/c6x/c6x.c
index 339da13..2d73cb8 100644
--- a/gcc/config/c6x/c6x.c
+++ b/gcc/config/c6x/c6x.c
@@ -5827,8 +5827,8 @@ hwloop_optimize (hwloop_info loop)
   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];
-  BB_HEAD (bb) = orig_vec[0];
-  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:
   free_delay_pairs ();
   FOR_BB_INSNS (bb, insn)
diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
index 118e5bf..feee157 100644
--- a/gcc/config/ia64/ia64.c
+++ b/gcc/config/ia64/ia64.c
@@ -9617,7 +9617,7 @@ emit_predicate_relation_info (void)
            rtx p = gen_rtx_REG (BImode, r);
            rtx n = emit_insn_after (gen_pred_rel_mutex (p), head);
            if (head == BB_END (bb))
-             BB_END (bb) = n;
+             SET_BB_END (bb) = n;
            head = n;
          }
     }
@@ -9639,9 +9639,9 @@ emit_predicate_relation_info (void)
              rtx b = emit_insn_before (gen_safe_across_calls_all (), insn);
              rtx a = emit_insn_after (gen_safe_across_calls_normal (), insn);
              if (BB_HEAD (bb) == insn)
-               BB_HEAD (bb) = b;
+               SET_BB_HEAD (bb) = b;
              if (BB_END (bb) == insn)
-               BB_END (bb) = a;
+               SET_BB_END (bb) = a;
            }
 
          if (insn == BB_END (bb))
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index 3bf2ff7..2c3d8f7 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -3984,7 +3984,7 @@ add_insn_after (rtx insn, rtx after, basic_block bb)
          /* Avoid clobbering of structure when creating new BB.  */
          && !BARRIER_P (insn)
          && !NOTE_INSN_BASIC_BLOCK_P (insn))
-       BB_END (bb) = insn;
+       SET_BB_END (bb) = insn;
     }
 }
 
@@ -4113,10 +4113,10 @@ remove_insn (rtx insn)
          /* Never ever delete the basic block note without deleting whole
             basic block.  */
          gcc_assert (!NOTE_P (insn));
-         BB_HEAD (bb) = next;
+         SET_BB_HEAD (bb) = next;
        }
       if (BB_END (bb) == insn)
-       BB_END (bb) = prev;
+       SET_BB_END (bb) = prev;
     }
 }
 
@@ -4216,12 +4216,12 @@ reorder_insns (rtx from, rtx to, rtx after)
          && (bb2 = BLOCK_FOR_INSN (from)))
        {
          if (BB_END (bb2) == to)
-           BB_END (bb2) = prev;
+           SET_BB_END (bb2) = prev;
          df_set_bb_dirty (bb2);
        }
 
       if (BB_END (bb) == after)
-       BB_END (bb) = to;
+       SET_BB_END (bb) = to;
 
       for (x = from; x != NEXT_INSN (to); x = NEXT_INSN (x))
        if (!BARRIER_P (x))
@@ -4389,7 +4389,7 @@ emit_insn_after_1 (rtx first, rtx after, basic_block bb)
          df_insn_rescan (last);
        }
       if (BB_END (bb) == after)
-       BB_END (bb) = last;
+       SET_BB_END (bb) = last;
     }
   else
     for (last = first; NEXT_INSN (last); last = NEXT_INSN (last))
diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c
index 0e1800a..b3482e3 100644
--- a/gcc/haifa-sched.c
+++ b/gcc/haifa-sched.c
@@ -4757,7 +4757,7 @@ get_ebb_head_tail (basic_block beg, basic_block end, rtx 
*headp, rtx *tailp)
                reorder_insns_nobb (note, note, end_tail);
 
                if (end_tail == BB_END (end))
-                 BB_END (end) = note;
+                 SET_BB_END (end) = note;
 
                if (BLOCK_FOR_INSN (note) != end)
                  df_insn_change_bb (note, end);
@@ -4816,7 +4816,7 @@ restore_other_notes (rtx head, basic_block head_bb)
       NEXT_INSN (note_list) = head;
 
       if (BLOCK_FOR_INSN (head) != head_bb)
-       BB_END (head_bb) = note_list;
+       SET_BB_END (head_bb) = note_list;
 
       head = note_head;
     }
@@ -5215,7 +5215,7 @@ move_insn (rtx insn, rtx last, rtx nt)
 
          gcc_assert (BLOCK_FOR_INSN (PREV_INSN (insn)) == bb);
 
-         BB_END (bb) = PREV_INSN (insn);
+         SET_BB_END (bb) = PREV_INSN (insn);
        }
 
       gcc_assert (BB_END (bb) != last);
@@ -5264,7 +5264,7 @@ move_insn (rtx insn, rtx last, rtx nt)
 
       /* Update BB_END, if needed.  */
       if (BB_END (bb) == last)
-       BB_END (bb) = insn;
+       SET_BB_END (bb) = insn;
     }
 
   SCHED_GROUP_P (insn) = 0;
@@ -7552,7 +7552,7 @@ sched_extend_bb (void)
       rtx note = emit_note_after (NOTE_INSN_DELETED, end);
       /* Make note appear outside BB.  */
       set_block_for_insn (note, NULL);
-      BB_END (EXIT_BLOCK_PTR_FOR_FN (cfun)->prev_bb) = end;
+      SET_BB_END (EXIT_BLOCK_PTR_FOR_FN (cfun)->prev_bb) = end;
     }
 }
 
@@ -8236,18 +8236,18 @@ fix_jump_move (rtx jump)
 
   if (!NOTE_INSN_BASIC_BLOCK_P (BB_END (jump_bb_next)))
     /* if jump_bb_next is not empty.  */
-    BB_END (jump_bb) = BB_END (jump_bb_next);
+    SET_BB_END (jump_bb) = BB_END (jump_bb_next);
 
   if (BB_END (bb) != PREV_INSN (jump))
     /* Then there are instruction after jump that should be placed
        to jump_bb_next.  */
-    BB_END (jump_bb_next) = BB_END (bb);
+    SET_BB_END (jump_bb_next) = BB_END (bb);
   else
     /* Otherwise jump_bb_next is empty.  */
-    BB_END (jump_bb_next) = NEXT_INSN (BB_HEAD (jump_bb_next));
+    SET_BB_END (jump_bb_next) = NEXT_INSN (BB_HEAD (jump_bb_next));
 
   /* To make assertion in move_insn happy.  */
-  BB_END (bb) = PREV_INSN (jump);
+  SET_BB_END (bb) = PREV_INSN (jump);
 
   update_bb_for_insn (jump_bb_next);
 }
diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index 2ca2278..d27b5fa 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -2594,7 +2594,7 @@ noce_process_if_block (struct noce_if_info *if_info)
          rtx note;
 
          if (else_bb && insn_b == BB_END (else_bb))
-           BB_END (else_bb) = PREV_INSN (insn_b);
+           SET_BB_END (else_bb) = PREV_INSN (insn_b);
          reorder_insns (insn_b, insn_b, PREV_INSN (jump));
 
          /* If there was a REG_EQUAL note, delete it since it may have been
@@ -4359,7 +4359,7 @@ dead_or_predicable (basic_block test_bb, basic_block 
merge_bb,
       rtx insn;
 
       if (end == BB_END (merge_bb))
-       BB_END (merge_bb) = PREV_INSN (head);
+       SET_BB_END (merge_bb) = PREV_INSN (head);
 
       /* PR 21767: when moving insns above a conditional branch, the REG_EQUAL
         notes being moved might become invalid.  */
diff --git a/gcc/ira.c b/gcc/ira.c
index 26d017e..bad6759 100644
--- a/gcc/ira.c
+++ b/gcc/ira.c
@@ -3863,7 +3863,7 @@ update_equiv_regs (void)
                      REG_LIVE_LENGTH (regno) = 2;
 
                      if (insn == BB_HEAD (bb))
-                       BB_HEAD (bb) = PREV_INSN (insn);
+                       SET_BB_HEAD (bb) = PREV_INSN (insn);
 
                      ira_reg_equiv[regno].init_insns
                        = gen_rtx_INSN_LIST (VOIDmode, new_insn, NULL_RTX);
diff --git a/gcc/reg-stack.c b/gcc/reg-stack.c
index 692abc5..e0d5d70 100644
--- a/gcc/reg-stack.c
+++ b/gcc/reg-stack.c
@@ -2600,7 +2600,7 @@ change_stack (rtx insn, stack_ptr old, stack_ptr 
new_stack, enum emit_where wher
     }
 
   if (update_end)
-    BB_END (current_block) = PREV_INSN (insn);
+    SET_BB_END (current_block) = PREV_INSN (insn);
 }
 
 /* Print stack configuration.  */
diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c
index 3cba326..7eccdf9 100644
--- a/gcc/sel-sched-ir.c
+++ b/gcc/sel-sched-ir.c
@@ -1432,7 +1432,7 @@ sel_move_insn (expr_t expr, int seqno, insn_t after)
   /* Update links from insn to bb and vice versa.  */
   df_insn_change_bb (insn, bb);
   if (BB_END (bb) == after)
-    BB_END (bb) = insn;
+    SET_BB_END (bb) = insn;
 
   prepare_insn_expr (insn, seqno);
   return insn;
diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c
index 0c864ac..bfbd2fe 100644
--- a/gcc/sel-sched.c
+++ b/gcc/sel-sched.c
@@ -5209,7 +5209,7 @@ move_nop_to_previous_block (insn_t nop, basic_block 
prev_bb)
   NEXT_INSN (nop) = note;
   PREV_INSN (next_insn) = note;
 
-  BB_END (prev_bb) = nop;
+  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 9971853..c1039bc 100644
--- a/rtx-classes-status.txt
+++ b/rtx-classes-status.txt
@@ -7,3 +7,7 @@ Phase 3: per-file commits within "config" subdirs: TODO
 Phase 4: removal of "scaffolding":                 TODO
 Phase 5: additional rtx_def subclasses:            TODO
 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
-- 
1.8.5.3

Reply via email to