From: Trevor Saunders <[email protected]>

INSN_LOCATION and INSN_HAS_LOCATION already take an rtx_insn *.  Read
the location with location, store it with set_location, and test it
with has_location.


This started to find places that aren't rtx_insn * but now its done, I
wonder if people think it makes sense to switch this to a member? I'd
hope it will eventually help with making the inheritance of rtx_insn on
rtx_def protected rather than public or reorganize the data model
further but that's probably still a ways away.

bootstrapped and regtested on ppc64le-linux-gnu and run through
config-list.mk with the previous patch, ok?

thanks

Trev

gcc/ChangeLog:

        * rtl.h (rtx_insn::location, rtx_insn::set_location,
        rtx_insn::has_location): New functions.  Remove INSN_LOCATION
        and INSN_HAS_LOCATION.
        (RTL_LOCATION): Use location.
        * cfgcleanup.cc: Use location and set_location.
        * cfghooks.cc: Use location and has_location.
        * cfgloop.cc: Use has_location.
        * cfgrtl.cc: Use location, set_location, and has_location.
        * combine.cc: Use location and set_location.
        * compare-elim.cc: Likewise.
        * config/aarch64/aarch64-speculation.cc: Likewise.
        * config/arm/arm.cc: Likewise.
        * config/avr/avr.cc: Likewise.
        * config/bfin/bfin.cc: Likewise.
        * config/bpf/bpf.cc: Use has_location.
        * config/c6x/c6x.cc: Use location and set_location.
        * config/i386/i386-features.cc: Likewise.
        * config/microblaze/microblaze.cc: Likewise.
        * config/mips/mips.cc: Likewise.
        * config/nvptx/nvptx.md: Likewise.
        * config/riscv/riscv-sr.cc: Likewise.
        * config/sh/sh.cc: Likewise.
        * config/sparc/sparc.cc: Likewise.
        * dumpfile.cc: Likewise.
        * emit-rtl.cc: Likewise.
        * except.cc: Likewise.
        * final.cc: Use location and has_location.
        * gcse.cc: Use location and set_location.
        * hierarchical_discriminator.cc: Use location and has_location.
        * ifcvt.cc: Use location and set_location.
        * ira-emit.cc: Likewise.
        * modulo-sched.cc: Use has_location.
        * print-rtl.cc: Likewise.
        * recog.cc: Use location and set_location.
        * reorg.cc: Likewise.
        * var-tracking.cc: Likewise.
        * gdbinit.in: Skip location, set_location, and has_location.

Signed-off-by: Trevor Saunders <[email protected]>
---
 gcc/cfgcleanup.cc                         |  2 +-
 gcc/cfghooks.cc                           |  4 +--
 gcc/cfgloop.cc                            |  8 +++---
 gcc/cfgrtl.cc                             | 24 ++++++++--------
 gcc/combine.cc                            |  4 +--
 gcc/compare-elim.cc                       |  2 +-
 gcc/config/aarch64/aarch64-speculation.cc |  2 +-
 gcc/config/arm/arm.cc                     |  6 ++--
 gcc/config/avr/avr.cc                     |  2 +-
 gcc/config/bfin/bfin.cc                   | 12 ++++----
 gcc/config/bpf/bpf.cc                     |  2 +-
 gcc/config/c6x/c6x.cc                     |  4 +--
 gcc/config/i386/i386-features.cc          |  2 +-
 gcc/config/microblaze/microblaze.cc       |  2 +-
 gcc/config/mips/mips.cc                   |  2 +-
 gcc/config/nvptx/nvptx.md                 |  2 +-
 gcc/config/riscv/riscv-sr.cc              |  2 +-
 gcc/config/sh/sh.cc                       |  4 +--
 gcc/config/sparc/sparc.cc                 |  4 +--
 gcc/dumpfile.cc                           |  2 +-
 gcc/emit-rtl.cc                           | 34 +++++++++++------------
 gcc/except.cc                             |  2 +-
 gcc/final.cc                              |  6 ++--
 gcc/gcse.cc                               |  2 +-
 gcc/gdbinit.in                            |  5 ++--
 gcc/hierarchical_discriminator.cc         | 11 ++++----
 gcc/ifcvt.cc                              | 20 ++++++-------
 gcc/ira-emit.cc                           |  2 +-
 gcc/modulo-sched.cc                       |  2 +-
 gcc/print-rtl.cc                          |  2 +-
 gcc/recog.cc                              |  2 +-
 gcc/reorg.cc                              |  8 +++---
 gcc/rtl.h                                 | 24 +++++++++++-----
 gcc/var-tracking.cc                       |  2 +-
 34 files changed, 113 insertions(+), 101 deletions(-)

diff --git a/gcc/cfgcleanup.cc b/gcc/cfgcleanup.cc
index 0ad7de6420e..f9d071e128d 100644
--- a/gcc/cfgcleanup.cc
+++ b/gcc/cfgcleanup.cc
@@ -462,7 +462,7 @@ try_forward_edges (int mode, basic_block b)
                      if (DEBUG_INSN_P (last))
                        last = prev_nondebug_insn (last);
                      if (last && INSN_P (last))
-                       new_locus = INSN_LOCATION (last);
+                       new_locus = last->location ();
                      else
                        new_locus = UNKNOWN_LOCATION;
 
diff --git a/gcc/cfghooks.cc b/gcc/cfghooks.cc
index d0a24c03191..e4059d83af7 100644
--- a/gcc/cfghooks.cc
+++ b/gcc/cfghooks.cc
@@ -56,8 +56,8 @@ copyid_location_from_bb (basic_block bb)
 
   rtx_insn *insn;
   FOR_BB_INSNS_REVERSE (bb, insn)
-    if (INSN_P (insn) && INSN_HAS_LOCATION (insn))
-      return INSN_LOCATION (insn);
+    if (INSN_P (insn) && insn->has_location ())
+      return insn->location ();
 
   return UNKNOWN_LOCATION;
 }
diff --git a/gcc/cfgloop.cc b/gcc/cfgloop.cc
index ee4ff4a158e..a4106ed2f52 100644
--- a/gcc/cfgloop.cc
+++ b/gcc/cfgloop.cc
@@ -1855,7 +1855,7 @@ get_loop_location (class loop *loop)
     {
       FOR_BB_INSNS_REVERSE (desc->in_edge->src, insn)
         {
-          if (INSN_P (insn) && INSN_HAS_LOCATION (insn))
+         if (INSN_P (insn) && insn->has_location ())
             return insn;
         }
     }
@@ -1865,21 +1865,21 @@ get_loop_location (class loop *loop)
     {
       FOR_BB_INSNS_REVERSE (exit->src, insn)
         {
-          if (INSN_P (insn) && INSN_HAS_LOCATION (insn))
+         if (INSN_P (insn) && insn->has_location ())
             return insn;
         }
     }
   /* Next check the latch, to see if it is non-empty.  */
   FOR_BB_INSNS_REVERSE (loop->latch, insn)
     {
-      if (INSN_P (insn) && INSN_HAS_LOCATION (insn))
+      if (INSN_P (insn) && insn->has_location ())
         return insn;
     }
   /* Finally, if none of the above identifies the loop control branch,
      return the first location in the loop header.  */
   FOR_BB_INSNS (loop->header, insn)
     {
-      if (INSN_P (insn) && INSN_HAS_LOCATION (insn))
+      if (INSN_P (insn) && insn->has_location ())
         return insn;
     }
   /* If all else fails, simply return the current function location.  */
diff --git a/gcc/cfgrtl.cc b/gcc/cfgrtl.cc
index 8714334bc9a..a27175cfe32 100644
--- a/gcc/cfgrtl.cc
+++ b/gcc/cfgrtl.cc
@@ -925,10 +925,10 @@ unique_locus_on_edge_between_p (basic_block a, 
basic_block b)
   /* First scan block A backward.  */
   insn = BB_END (a);
   end = PREV_INSN (BB_HEAD (a));
-  while (insn != end && (!NONDEBUG_INSN_P (insn) || !INSN_HAS_LOCATION (insn)))
+  while (insn != end && (!NONDEBUG_INSN_P (insn) || !insn->has_location ()))
     insn = PREV_INSN (insn);
 
-  if (insn != end && loc_equal (INSN_LOCATION (insn), goto_locus))
+  if (insn != end && loc_equal (insn->location (), goto_locus))
     return false;
 
   /* Then scan block B forward.  */
@@ -939,8 +939,8 @@ unique_locus_on_edge_between_p (basic_block a, basic_block 
b)
       while (insn != end && !NONDEBUG_INSN_P (insn))
        insn = NEXT_INSN (insn);
 
-      if (insn != end && INSN_HAS_LOCATION (insn)
-         && loc_equal (INSN_LOCATION (insn), goto_locus))
+      if (insn != end && insn->has_location ()
+         && loc_equal (insn->location (), goto_locus))
        return false;
     }
 
@@ -957,7 +957,7 @@ emit_nop_for_unique_locus_between (basic_block a, 
basic_block b)
     return;
 
   BB_END (a) = emit_insn_after_noloc (gen_nop (), BB_END (a), a);
-  INSN_LOCATION (BB_END (a)) = EDGE_SUCC (a, 0)->goto_locus;
+  BB_END (a)->set_location (EDGE_SUCC (a, 0)->goto_locus);
 }
 
 /* Blocks A and B are to be merged into a single block A.  The insns
@@ -4344,15 +4344,15 @@ fixup_reorder_chain (void)
              insn = BB_END (e->src);
              end = PREV_INSN (BB_HEAD (e->src));
              while (insn != end
-                    && (!NONDEBUG_INSN_P (insn) || !INSN_HAS_LOCATION (insn)))
+                    && (!NONDEBUG_INSN_P (insn) || !insn->has_location ()))
                insn = PREV_INSN (insn);
              if (insn != end
-                 && loc_equal (INSN_LOCATION (insn), e->goto_locus))
+                 && loc_equal (insn->location (), e->goto_locus))
                continue;
              if (simplejump_p (BB_END (e->src))
-                 && !INSN_HAS_LOCATION (BB_END (e->src)))
+                 && !BB_END (e->src)->has_location ())
                {
-                 INSN_LOCATION (BB_END (e->src)) = e->goto_locus;
+                 BB_END (e->src)->set_location (e->goto_locus);
                  continue;
                }
              dest = e->dest;
@@ -4368,15 +4368,15 @@ fixup_reorder_chain (void)
                  end = NEXT_INSN (BB_END (dest));
                  while (insn != end && !NONDEBUG_INSN_P (insn))
                    insn = NEXT_INSN (insn);
-                 if (insn != end && INSN_HAS_LOCATION (insn)
-                     && loc_equal (INSN_LOCATION (insn), e->goto_locus))
+                 if (insn != end && insn->has_location ()
+                     && loc_equal (insn->location (), e->goto_locus))
                    continue;
                }
              nb = split_edge (e);
              if (!INSN_P (BB_END (nb)))
                BB_END (nb) = emit_insn_after_noloc (gen_nop (), BB_END (nb),
                                                         nb);
-             INSN_LOCATION (BB_END (nb)) = e->goto_locus;
+             BB_END (nb)->set_location (e->goto_locus);
 
              /* If there are other incoming edges to the destination block
                 with the same goto locus, redirect them to the new block as
diff --git a/gcc/combine.cc b/gcc/combine.cc
index f4ef46b15c2..91eaa2cb527 100644
--- a/gcc/combine.cc
+++ b/gcc/combine.cc
@@ -2913,7 +2913,7 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, 
rtx_insn *i0,
         as I2 will not cause a problem.  */
 
       i1 = gen_rtx_INSN (VOIDmode, NULL, i2, BLOCK_FOR_INSN (i2),
-                        XVECEXP (PATTERN (i2), 0, 1), INSN_LOCATION (i2),
+                        XVECEXP (PATTERN (i2), 0, 1), i2->location (),
                         -1, NULL_RTX);
       INSN_UID (i1) = INSN_UID (i2);
 
@@ -2945,7 +2945,7 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, 
rtx_insn *i0,
         as I2 will not cause a problem.  */
 
       i1 = gen_rtx_INSN (VOIDmode, NULL, i2, BLOCK_FOR_INSN (i2),
-                        XVECEXP (PATTERN (i2), 0, 0), INSN_LOCATION (i2),
+                        XVECEXP (PATTERN (i2), 0, 0), i2->location (),
                         -1, NULL_RTX);
       INSN_UID (i1) = INSN_UID (i2);
 
diff --git a/gcc/compare-elim.cc b/gcc/compare-elim.cc
index e4d9d57e313..4dafbb53cda 100644
--- a/gcc/compare-elim.cc
+++ b/gcc/compare-elim.cc
@@ -674,7 +674,7 @@ try_validate_parallel (rtx set_a, rtx set_b)
 
   SET_PREV_INSN (insn) = NULL_RTX;
   SET_NEXT_INSN (insn) = NULL_RTX;
-  INSN_LOCATION (insn) = 0;
+  insn->set_location (0);
   return insn;
 }
 
diff --git a/gcc/config/aarch64/aarch64-speculation.cc 
b/gcc/config/aarch64/aarch64-speculation.cc
index 47dcab3b265..ffd89759e7d 100644
--- a/gcc/config/aarch64/aarch64-speculation.cc
+++ b/gcc/config/aarch64/aarch64-speculation.cc
@@ -405,7 +405,7 @@ aarch64_do_track_speculation ()
                    }
 
                  for (rtx_insn *list = seq; list; list = NEXT_INSN (list))
-                   INSN_LOCATION (list) = INSN_LOCATION (call_insn);
+                   list->set_location (call_insn->location ());
 
                  insert_insn_on_edge (seq, e);
                }
diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index 6a525b65e60..e9c98352ca8 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -8122,7 +8122,7 @@ require_pic_register (rtx pic_reg, bool compute_now)
 
              for (insn = seq; insn; insn = NEXT_INSN (insn))
                if (INSN_P (insn))
-                 INSN_LOCATION (insn) = prologue_location;
+                 insn->set_location (prologue_location);
 
              /* We can be called during expansion of PHI nodes, where
                 we can't yet emit instructions directly in the final
@@ -34511,11 +34511,11 @@ arm_emit_mve_unpredicated_insn_to_seq (rtx_insn* insn)
       default:
        gcc_unreachable ();
     }
-  INSN_LOCATION (new_insn) = INSN_LOCATION (insn);
+  new_insn->set_location (insn->location ());
   if (move)
     {
       new_insn = emit_insn (move);
-      INSN_LOCATION (new_insn) = INSN_LOCATION (insn);
+      new_insn->set_location (insn->location ());
     }
   return true;
 }
diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc
index 9108365e65f..d6434dc77cb 100644
--- a/gcc/config/avr/avr.cc
+++ b/gcc/config/avr/avr.cc
@@ -3066,7 +3066,7 @@ void
 avr_final_prescan_insn (rtx_insn *insn, rtx * /*operands*/,
                        int /*num_operands*/)
 {
-  avr_insn_location = LOCATION_LOCUS (INSN_LOCATION (insn));
+  avr_insn_location = LOCATION_LOCUS (insn->location ());
 
   if (avr_log.rtx_costs)
     {
diff --git a/gcc/config/bfin/bfin.cc b/gcc/config/bfin/bfin.cc
index 300034e2e37..f56beebd77c 100644
--- a/gcc/config/bfin/bfin.cc
+++ b/gcc/config/bfin/bfin.cc
@@ -3966,12 +3966,12 @@ gen_one_bundle (rtx_insn *slot[3])
     }
 
   /* Avoid line number information being printed inside one bundle.  */
-  if (INSN_LOCATION (slot[1])
-      && INSN_LOCATION (slot[1]) != INSN_LOCATION (slot[0]))
-    INSN_LOCATION (slot[1]) = INSN_LOCATION (slot[0]);
-  if (INSN_LOCATION (slot[2])
-      && INSN_LOCATION (slot[2]) != INSN_LOCATION (slot[0]))
-    INSN_LOCATION (slot[2]) = INSN_LOCATION (slot[0]);
+  if (slot[1]->location ()
+      && slot[1]->location () != slot[0]->location ())
+    slot[1]->set_location (slot[0]->location ());
+  if (slot[2]->location ()
+      && slot[2]->location () != slot[0]->location ())
+    slot[2]->set_location (slot[0]->location ());
 
   /* Terminate them with "|| " instead of ";" in the output.  */
   PUT_MODE (slot[0], SImode);
diff --git a/gcc/config/bpf/bpf.cc b/gcc/config/bpf/bpf.cc
index 3ef93938222..d363d8e3f1d 100644
--- a/gcc/config/bpf/bpf.cc
+++ b/gcc/config/bpf/bpf.cc
@@ -1233,7 +1233,7 @@ bpf_output_line_info (FILE *asm_out_file, rtx_insn *insn)
        }
 
 
-      if (!INSN_HAS_LOCATION (insn))
+      if (!insn->has_location ())
        return;
 
       exploc = insn_location (insn);
diff --git a/gcc/config/c6x/c6x.cc b/gcc/config/c6x/c6x.cc
index 985b20f0551..7dc00e73390 100644
--- a/gcc/config/c6x/c6x.cc
+++ b/gcc/config/c6x/c6x.cc
@@ -4592,7 +4592,7 @@ gen_one_bundle (rtx_insn **slot, int n_filled, int 
real_first)
   seq = gen_rtx_SEQUENCE (VOIDmode, gen_rtvec_v (n_filled, slot));
   bundle = make_insn_raw (seq);
   BLOCK_FOR_INSN (bundle) = BLOCK_FOR_INSN (slot[0]);
-  INSN_LOCATION (bundle) = INSN_LOCATION (slot[0]);
+  bundle->set_location (slot[0]->location ());
   SET_PREV_INSN (bundle) = SET_PREV_INSN (slot[real_first]);
 
   t = NULL;
@@ -4606,7 +4606,7 @@ gen_one_bundle (rtx_insn **slot, int n_filled, int 
real_first)
        SET_NEXT_INSN (t) = insn;
       t = insn;
       if (i > 0)
-       INSN_LOCATION (slot[i]) = INSN_LOCATION (bundle);
+       slot[i]->set_location (bundle->location ());
     }
 
   SET_NEXT_INSN (bundle) = NEXT_INSN (PREV_INSN (bundle));
diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
index ee5ad076857..a01fdf12a0a 100644
--- a/gcc/config/i386/i386-features.cc
+++ b/gcc/config/i386/i386-features.cc
@@ -3339,7 +3339,7 @@ rest_of_insert_endbr_and_patchable_area (bool need_endbr,
 
              endbr = gen_nop_endbr ();
              emit_insn_after_setloc (endbr, call_insn,
-                                    INSN_LOCATION (call_insn));
+                                     call_insn->location ());
              continue;
            }
 
diff --git a/gcc/config/microblaze/microblaze.cc 
b/gcc/config/microblaze/microblaze.cc
index 398c8ffa7ea..e2673e4550b 100644
--- a/gcc/config/microblaze/microblaze.cc
+++ b/gcc/config/microblaze/microblaze.cc
@@ -3897,7 +3897,7 @@ insert_wic_for_ilb_runout (rtx_insn *first)
                                     (gen_int_mode (addr_offset, SImode)),
                                     before_4);
                 recog_memoized (insn);
-                INSN_LOCATION (insn) = INSN_LOCATION (before_4);
+               insn->set_location (before_4->location ());
                 INSN_ADDRESSES_NEW (insn, INSN_ADDRESSES (INSN_UID 
(before_4)));
                 return;
               }
diff --git a/gcc/config/mips/mips.cc b/gcc/config/mips/mips.cc
index 2c986faffd7..4d095fd0513 100644
--- a/gcc/config/mips/mips.cc
+++ b/gcc/config/mips/mips.cc
@@ -3412,7 +3412,7 @@ mips16_gp_pseudo_reg (void)
 
       rtx set = gen_load_const_gp (cfun->machine->mips16_gp_pseudo_rtx);
       rtx_insn *insn = emit_insn_after (set, scan);
-      INSN_LOCATION (insn) = 0;
+      insn->set_location (0);
       /* NewABI support hasn't been implement.  NewABI should generate RTL
         sequence instead of ASM sequence directly.  */
       if (mips_current_loadgp_style () == LOADGP_OLDABI)
diff --git a/gcc/config/nvptx/nvptx.md b/gcc/config/nvptx/nvptx.md
index 21731da32ce..775841ca199 100644
--- a/gcc/config/nvptx/nvptx.md
+++ b/gcc/config/nvptx/nvptx.md
@@ -1711,7 +1711,7 @@
       return nvptx_output_fake_ptx_alloca ();
     else
       {
-       sorry_at (INSN_LOCATION (insn),
+       sorry_at (insn->location (),
                  "dynamic stack allocation not supported");
        return "";
       }
diff --git a/gcc/config/riscv/riscv-sr.cc b/gcc/config/riscv/riscv-sr.cc
index cf4514b1302..767b5b23b8b 100644
--- a/gcc/config/riscv/riscv-sr.cc
+++ b/gcc/config/riscv/riscv-sr.cc
@@ -455,7 +455,7 @@ riscv_remove_unneeded_save_restore_calls (void)
   rtx_insn *before_call = PREV_INSN (call);
   remove_insn (call);
   rtx_insn *insn = emit_call_insn_after_setloc (sibcall, before_call,
-                                               INSN_LOCATION (call));
+                                               call->location ());
   REG_NOTES (insn) = REG_NOTES (call);
   CALL_INSN_ABI_ID (insn) = CALL_INSN_ABI_ID (call);
   SIBLING_CALL_P (insn) = 1;
diff --git a/gcc/config/sh/sh.cc b/gcc/config/sh/sh.cc
index 44d90e1719f..fe8094b0664 100644
--- a/gcc/config/sh/sh.cc
+++ b/gcc/config/sh/sh.cc
@@ -5609,7 +5609,7 @@ gen_block_redirect (rtx_insn *jump, int addr, int 
need_block)
         NOTE_INSN_BLOCK_END notes between the indirect_jump_scratch and
         the jump.  */
 
-      INSN_LOCATION (insn) = INSN_LOCATION (jump);
+      insn->set_location (jump->location ());
       INSN_CODE (insn) = CODE_FOR_indirect_jump_scratch;
       return insn;
     }
@@ -12276,7 +12276,7 @@ sh_recog_treg_set_expr (rtx op, machine_mode mode)
   PATTERN (i) = gen_rtx_SET (get_t_reg_rtx (), op);
   INSN_CODE (i) = -1;
   REG_NOTES (i) = NULL;
-  INSN_LOCATION (i) = curr_insn_location ();
+  i->set_location (curr_insn_location ());
   BLOCK_FOR_INSN (i) = NULL;
   SET_PREV_INSN (i) = NULL;
   SET_NEXT_INSN (i) = NULL;
diff --git a/gcc/config/sparc/sparc.cc b/gcc/config/sparc/sparc.cc
index e69d7625310..f3612a2c247 100644
--- a/gcc/config/sparc/sparc.cc
+++ b/gcc/config/sparc/sparc.cc
@@ -6481,7 +6481,7 @@ output_return (rtx_insn *insn)
              PATTERN (delay) = gen_blockage ();
              INSN_CODE (delay) = -1;
              final_scan_insn (delay, asm_out_file, optimize, 0, NULL);
-             INSN_LOCATION (delay) = UNKNOWN_LOCATION;
+             delay->set_location (UNKNOWN_LOCATION);
 
              output_restore (pat);
            }
@@ -6552,7 +6552,7 @@ output_sibcall (rtx_insn *insn, rtx call_operand)
          PATTERN (delay) = gen_blockage ();
          INSN_CODE (delay) = -1;
          final_scan_insn (delay, asm_out_file, optimize, 0, NULL);
-         INSN_LOCATION (delay) = UNKNOWN_LOCATION;
+         delay->set_location (UNKNOWN_LOCATION);
 
          output_restore (pat);
        }
diff --git a/gcc/dumpfile.cc b/gcc/dumpfile.cc
index 994ef3da5ce..acc11c7c3fe 100644
--- a/gcc/dumpfile.cc
+++ b/gcc/dumpfile.cc
@@ -429,7 +429,7 @@ dump_user_location_t::dump_user_location_t (const rtx_insn 
*insn)
       basic_block bb = BLOCK_FOR_INSN (insn);
       if (bb)
        m_count = bb->count;
-      m_loc = INSN_LOCATION (insn);
+      m_loc = insn->location ();
     }
 }
 
diff --git a/gcc/emit-rtl.cc b/gcc/emit-rtl.cc
index 98dd59d1aa2..e42359938d8 100644
--- a/gcc/emit-rtl.cc
+++ b/gcc/emit-rtl.cc
@@ -4170,7 +4170,7 @@ try_split (rtx pat, rtx_insn *trial, int last)
   before = PREV_INSN (trial);
   after = NEXT_INSN (trial);
 
-  emit_insn_after_setloc (seq, trial, INSN_LOCATION (trial));
+  emit_insn_after_setloc (seq, trial, trial->location ());
 
   delete_insn (trial);
 
@@ -4206,7 +4206,7 @@ make_insn_raw (rtx pattern)
   PATTERN (insn) = pattern;
   INSN_CODE (insn) = -1;
   REG_NOTES (insn) = NULL;
-  INSN_LOCATION (insn) = curr_insn_location ();
+  insn->set_location (curr_insn_location ());
   BLOCK_FOR_INSN (insn) = NULL;
 
 #ifdef ENABLE_RTL_CHECKING
@@ -4241,7 +4241,7 @@ make_debug_insn_raw (rtx pattern)
   PATTERN (insn) = pattern;
   INSN_CODE (insn) = -1;
   REG_NOTES (insn) = NULL;
-  INSN_LOCATION (insn) = curr_insn_location ();
+  insn->set_location (curr_insn_location ());
   BLOCK_FOR_INSN (insn) = NULL;
 
   return insn;
@@ -4263,7 +4263,7 @@ make_jump_insn_raw (rtx pattern)
   INSN_CODE (insn) = -1;
   REG_NOTES (insn) = NULL;
   JUMP_LABEL (insn) = NULL;
-  INSN_LOCATION (insn) = curr_insn_location ();
+  insn->set_location (curr_insn_location ());
   BLOCK_FOR_INSN (insn) = NULL;
 
   return insn;
@@ -4286,7 +4286,7 @@ make_call_insn_raw (rtx pattern)
   REG_NOTES (insn) = NULL;
   CALL_INSN_FUNCTION_USAGE (insn) = NULL;
   CALL_INSN_ABI_ID (insn) = 0;
-  INSN_LOCATION (insn) = curr_insn_location ();
+  insn->set_location (curr_insn_location ());
   BLOCK_FOR_INSN (insn) = NULL;
 
   return insn;
@@ -5034,8 +5034,8 @@ emit_pattern_after_setloc (rtx pattern, rtx_insn *after, 
location_t loc,
     {
       if (active_insn_p (after)
          && !JUMP_TABLE_DATA_P (after) /* FIXME */
-         && !INSN_LOCATION (after))
-       INSN_LOCATION (after) = loc;
+         && !after->location ())
+       after->set_location (loc);
       if (after == last)
        break;
       after = NEXT_INSN (after);
@@ -5058,7 +5058,7 @@ emit_pattern_after (rtx pattern, rtx_insn *after, bool 
skip_debug_insns,
       prev = PREV_INSN (prev);
 
   if (INSN_P (prev))
-    return emit_pattern_after_setloc (pattern, after, INSN_LOCATION (prev),
+    return emit_pattern_after_setloc (pattern, after, prev->location (),
                                      make_raw);
   else
     return emit_pattern_after_noloc (pattern, after, NULL, make_raw);
@@ -5147,8 +5147,8 @@ emit_pattern_before_setloc (rtx pattern, rtx_insn 
*before, location_t loc,
     {
       if (active_insn_p (first)
          && !JUMP_TABLE_DATA_P (first) /* FIXME */
-         && !INSN_LOCATION (first))
-       INSN_LOCATION (first) = loc;
+         && !first->location ())
+       first->set_location (loc);
       if (first == last)
        break;
       first = NEXT_INSN (first);
@@ -5172,7 +5172,7 @@ emit_pattern_before (rtx pattern, rtx_insn *before, bool 
skip_debug_insns,
       next = PREV_INSN (next);
 
   if (INSN_P (next))
-    return emit_pattern_before_setloc (pattern, before, INSN_LOCATION (next),
+    return emit_pattern_before_setloc (pattern, before, next->location (),
                                       insnp, make_raw);
   else
     return emit_pattern_before_noloc (pattern, before,
@@ -6700,7 +6700,7 @@ emit_copy_of_insn_after (rtx_insn *insn, rtx_insn *after)
   if (NONDEBUG_INSN_P (insn))
     mark_jump_label (PATTERN (new_rtx), new_rtx, 0);
 
-  INSN_LOCATION (new_rtx) = INSN_LOCATION (insn);
+  new_rtx->set_location (insn->location ());
 
   /* If the old insn is frame related, then so is the new one.  This is
      primarily needed for IA-64 unwind info which marks epilogue insns,
@@ -6782,7 +6782,7 @@ set_insn_locations (rtx_insn *insn, location_t loc)
   while (insn)
     {
       if (INSN_P (insn))
-       INSN_LOCATION (insn) = loc;
+       insn->set_location (loc);
       insn = NEXT_INSN (insn);
     }
 }
@@ -6791,28 +6791,28 @@ set_insn_locations (rtx_insn *insn, location_t loc)
 tree
 insn_scope (const rtx_insn *insn)
 {
-  return LOCATION_BLOCK (INSN_LOCATION (insn));
+  return LOCATION_BLOCK (insn->location ());
 }
 
 /* Return line number of the statement that produced this insn.  */
 int
 insn_line (const rtx_insn *insn)
 {
-  return LOCATION_LINE (INSN_LOCATION (insn));
+  return LOCATION_LINE (insn->location ());
 }
 
 /* Return source file of the statement that produced this insn.  */
 const char *
 insn_file (const rtx_insn *insn)
 {
-  return LOCATION_FILE (INSN_LOCATION (insn));
+  return LOCATION_FILE (insn->location ());
 }
 
 /* Return expanded location of the statement that produced this insn.  */
 expanded_location
 insn_location (const rtx_insn *insn)
 {
-  return expand_location (INSN_LOCATION (insn));
+  return expand_location (insn->location ());
 }
 
 /* Return true if memory model MODEL requires a pre-operation (release-style)
diff --git a/gcc/except.cc b/gcc/except.cc
index a8985ee81e1..22c8ec0dbf0 100644
--- a/gcc/except.cc
+++ b/gcc/except.cc
@@ -944,7 +944,7 @@ emit_to_new_bb_before (rtx_insn *seq, rtx_insn *insn)
   while (next && !NONDEBUG_INSN_P (next))
     next = NEXT_INSN (next);
   if (next)
-    last = emit_insn_before_setloc (seq, insn, INSN_LOCATION (next));
+    last = emit_insn_before_setloc (seq, insn, next->location ());
   else
     last = emit_insn_before (seq, insn);
   if (BARRIER_P (last))
diff --git a/gcc/final.cc b/gcc/final.cc
index e1f46a21f7f..ce501e8f9b0 100644
--- a/gcc/final.cc
+++ b/gcc/final.cc
@@ -1542,7 +1542,7 @@ reemit_insn_block_notes (void)
        }
       if (! this_block)
        {
-         if (INSN_LOCATION (insn) == UNKNOWN_LOCATION)
+         if (insn->location () == UNKNOWN_LOCATION)
            continue;
          else
            this_block = DECL_INITIAL (cfun->decl);
@@ -2978,7 +2978,7 @@ compute_discriminator (location_t loc)
 int
 insn_discriminator (const rtx_insn *insn)
 {
-  return compute_discriminator (INSN_LOCATION (insn));
+  return compute_discriminator (insn->location ());
 }
 
 /* Return whether a source line note needs to be emitted before INSN.
@@ -3007,7 +3007,7 @@ notice_source_line (rtx_insn *insn, bool *is_stmt)
       discriminator = compute_discriminator (loc);
       force_source_line = true;
     }
-  else if (INSN_HAS_LOCATION (insn))
+  else if (insn->has_location ())
     {
       expanded_location xloc = insn_location (insn);
       filename = xloc.file;
diff --git a/gcc/gcse.cc b/gcc/gcse.cc
index 5e68b066995..36fb0f6926b 100644
--- a/gcc/gcse.cc
+++ b/gcc/gcse.cc
@@ -923,7 +923,7 @@ can_assign_to_reg_without_clobbers_p (rtx x, machine_mode 
mode)
                                                   FIRST_PSEUDO_REGISTER * 2),
                                      const0_rtx));
       SET_NEXT_INSN (test_insn) = SET_PREV_INSN (test_insn) = 0;
-      INSN_LOCATION (test_insn) = UNKNOWN_LOCATION;
+      test_insn->set_location (UNKNOWN_LOCATION);
     }
 
   /* Now make an insn like the one we would make when GCSE'ing and see if
diff --git a/gcc/gdbinit.in b/gcc/gdbinit.in
index 08bb4e0536b..d9435864e20 100644
--- a/gcc/gdbinit.in
+++ b/gcc/gdbinit.in
@@ -389,8 +389,9 @@ skip NEXT_INSN
 skip SET_NEXT_INSN
 skip BLOCK_FOR_INSN
 skip PATTERN
-skip INSN_LOCATION
-skip INSN_HAS_LOCATION
+skip rtx_insn::location
+skip rtx_insn::set_location
+skip rtx_insn::has_location
 skip JUMP_LABEL_AS_INSN
 
 # Restore pagination to the previous state.
diff --git a/gcc/hierarchical_discriminator.cc 
b/gcc/hierarchical_discriminator.cc
index 65e1184cae3..2f4ad92b77f 100644
--- a/gcc/hierarchical_discriminator.cc
+++ b/gcc/hierarchical_discriminator.cc
@@ -110,11 +110,12 @@ assign_discriminators_to_bb (basic_block bb,
       rtx_insn *insn;
       FOR_BB_INSNS (bb, insn)
        {
-         if (!INSN_P (insn) || !INSN_HAS_LOCATION (insn))
+         if (!INSN_P (insn) || !insn->has_location ())
            continue;
-         location_t loc = INSN_LOCATION (insn);
-         INSN_LOCATION (insn)
-           = update_location_discriminator (loc, multiplicity_factor, copyid);
+         location_t loc = insn->location ();
+         insn->set_location
+           (update_location_discriminator (loc, multiplicity_factor,
+                                                    copyid));
        }
       return;
     }
@@ -285,7 +286,7 @@ init_copyid_allocator (struct function *fn)
          FOR_BB_INSNS (bb, insn)
            {
              if (INSN_P (insn))
-               record_existing_copyid (INSN_LOCATION (insn), fn);
+               record_existing_copyid (insn->location (), fn);
            }
        }
     }
diff --git a/gcc/ifcvt.cc b/gcc/ifcvt.cc
index eb3a958074d..61034e12409 100644
--- a/gcc/ifcvt.cc
+++ b/gcc/ifcvt.cc
@@ -1331,7 +1331,7 @@ noce_commit_sequence (noce_if_info *if_info, rtx_insn 
*seq,
     return false;
 
   emit_insn_before_setloc (seq, if_info->jump,
-                          INSN_LOCATION (if_info->insn_a));
+                          if_info->insn_a->location ());
   if_info->transform_name = name;
   return true;
 }
@@ -1381,7 +1381,7 @@ noce_try_move (noce_if_info *if_info)
            return false;
 
          emit_insn_before_setloc (seq, if_info->jump,
-                                  INSN_LOCATION (if_info->insn_a));
+                                  if_info->insn_a->location ());
        }
       if_info->transform_name = "noce_try_move";
       return true;
@@ -3142,7 +3142,7 @@ noce_try_minmax (noce_if_info *if_info)
   if (!seq)
     return false;
 
-  emit_insn_before_setloc (seq, if_info->jump, INSN_LOCATION 
(if_info->insn_a));
+  emit_insn_before_setloc (seq, if_info->jump, if_info->insn_a->location ());
   if_info->cond = cond;
   if_info->cond_earliest = earliest;
   if_info->rev_cond = NULL_RTX;
@@ -3311,7 +3311,7 @@ noce_try_abs (noce_if_info *if_info)
   if (!seq)
     return false;
 
-  emit_insn_before_setloc (seq, if_info->jump, INSN_LOCATION 
(if_info->insn_a));
+  emit_insn_before_setloc (seq, if_info->jump, if_info->insn_a->location ());
   if_info->cond = cond;
   if_info->cond_earliest = earliest;
   if_info->rev_cond = NULL_RTX;
@@ -3774,7 +3774,7 @@ noce_try_bitop (noce_if_info *if_info)
        return false;
 
       emit_insn_before_setloc (seq, if_info->jump,
-                              INSN_LOCATION (if_info->insn_a));
+                              if_info->insn_a->location ());
     }
   if_info->transform_name = "noce_try_bitop";
   return true;
@@ -4101,7 +4101,7 @@ noce_convert_multiple_sets (noce_if_info *if_info)
   gcc_assert (!insn_info.is_empty ());
   unsigned then_count = insn_info.length ();
   location_t sequence_location
-    = INSN_LOCATION (insn_info.last ()->unmodified_insn);
+    = insn_info.last ()->unmodified_insn->location ();
 
   auto_delete_vec<noce_multiple_sets_info> else_insn_info;
   auto_vec<unsigned> else_only_indices;
@@ -4320,7 +4320,7 @@ noce_convert_multiple_sets_1 (noce_if_info *if_info, rtx 
cond,
                                          else_insn_info[ii]->target,
                                          else_insn_info[ii]->temporary);
 
-         set_curr_insn_location (INSN_LOCATION (else_insn));
+         set_curr_insn_location (else_insn->location ());
          rtx temporary = copy_to_mode_reg (GET_MODE (target), value);
 
          info->temporary = temporary;
@@ -5135,7 +5135,7 @@ noce_process_if_block (noce_if_info *if_info)
       unshare_all_rtl_in_chain (seq);
       end_sequence ();
 
-      emit_insn_before_setloc (seq, BB_END (test_bb), INSN_LOCATION (insn_a));
+      emit_insn_before_setloc (seq, BB_END (test_bb), insn_a->location ());
     }
 
   /* The original THEN and ELSE blocks may now be removed and the test block
@@ -5389,7 +5389,7 @@ cond_move_process_if_block (noce_if_info *if_info)
       loc_insn = first_active_insn (else_bb);
       gcc_assert (loc_insn);
     }
-  emit_insn_before_setloc (seq, jump, INSN_LOCATION (loc_insn));
+  emit_insn_before_setloc (seq, jump, loc_insn->location ());
 
   noce_finish_if_conversion (if_info);
 
@@ -6119,7 +6119,7 @@ find_cond_trap (basic_block test_bb, edge then_edge, edge 
else_edge)
     return false;
 
   /* Emit the new insns before cond_earliest.  */
-  emit_insn_before_setloc (seq, cond_earliest, INSN_LOCATION (trap));
+  emit_insn_before_setloc (seq, cond_earliest, trap->location ());
 
   /* Delete the trap block if possible.  */
   remove_edge (trap_bb == then_bb ? then_edge : else_edge);
diff --git a/gcc/ira-emit.cc b/gcc/ira-emit.cc
index 7a0dbdb072f..0b79cff8a3e 100644
--- a/gcc/ira-emit.cc
+++ b/gcc/ira-emit.cc
@@ -1006,7 +1006,7 @@ emit_moves (void)
          while (next && !NONDEBUG_INSN_P (next))
            next = NEXT_INSN (next);
          if (next)
-           set_insn_locations (insns, INSN_LOCATION (next));
+           set_insn_locations (insns, next->location ());
          if (tmp == BB_HEAD (bb))
            emit_insn_before (insns, tmp);
          else if (tmp)
diff --git a/gcc/modulo-sched.cc b/gcc/modulo-sched.cc
index f2f41bd5407..c7138d6e732 100644
--- a/gcc/modulo-sched.cc
+++ b/gcc/modulo-sched.cc
@@ -1251,7 +1251,7 @@ loop_single_full_bb_p (class loop *loop)
 static void
 dump_insn_location (rtx_insn *insn)
 {
-  if (dump_file && INSN_HAS_LOCATION (insn))
+  if (dump_file && insn->has_location ())
     {
       expanded_location xloc = insn_location (insn);
       fprintf (dump_file, " %s:%i", xloc.file, xloc.line);
diff --git a/gcc/print-rtl.cc b/gcc/print-rtl.cc
index bb33d2ac8a9..cb457a2b2df 100644
--- a/gcc/print-rtl.cc
+++ b/gcc/print-rtl.cc
@@ -452,7 +452,7 @@ rtx_writer::print_rtx_operand_code_L (const_rtx in_rtx, int 
idx)
       /*  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 (in_insn))
+      if (in_insn->has_location ())
        {
          expanded_location xloc = insn_location (in_insn);
          fprintf (m_outfile, " \"%s\":%i:%i", xloc.file, xloc.line,
diff --git a/gcc/recog.cc b/gcc/recog.cc
index 188ebc37834..f0eeebc1850 100644
--- a/gcc/recog.cc
+++ b/gcc/recog.cc
@@ -4175,7 +4175,7 @@ peep2_attempt (basic_block bb, rtx_insn *insn, int 
match_len, rtx_insn *attempt)
   rtx_insn *peepinsn = peep2_insn_data[i].insn;
   last = emit_insn_after_setloc (attempt,
                                 peep2_insn_data[i].insn,
-                                INSN_LOCATION (peepinsn));
+                                peepinsn->location ());
   if (JUMP_P (peepinsn) && JUMP_P (last))
     set_crossing_jump (last, CROSSING_JUMP_P (peepinsn));
   before_try = PREV_INSN (insn);
diff --git a/gcc/reorg.cc b/gcc/reorg.cc
index 6616e6d150b..719a1eaae90 100644
--- a/gcc/reorg.cc
+++ b/gcc/reorg.cc
@@ -471,7 +471,7 @@ emit_delay_sequence (rtx_insn *insn, const vec<rtx_insn *> 
&list, int length)
   /* If DELAY_INSN has a location, use it for SEQ_INSN.  If DELAY_INSN does
      not have a location, but one of the delayed insns does, we pick up a
      location from there later.  */
-  INSN_LOCATION (seq_insn) = INSN_LOCATION (insn);
+  seq_insn->set_location (insn->location ());
 
   /* Unlink INSN from the insn chain, so that we can put it into
      the SEQUENCE.   Remember where we want to emit SEQUENCE in AFTER.  */
@@ -500,9 +500,9 @@ emit_delay_sequence (rtx_insn *insn, const vec<rtx_insn *> 
&list, int length)
 
       /* SPARC assembler, for instance, emit warning when debug info is output
          into the delay slot.  */
-      if (INSN_LOCATION (tem) && !INSN_LOCATION (seq_insn))
-       INSN_LOCATION (seq_insn) = INSN_LOCATION (tem);
-      INSN_LOCATION (tem) = 0;
+      if (tem->location () && !seq_insn->location ())
+       seq_insn->set_location (tem->location ());
+      tem->set_location (0);
 
       for (note = REG_NOTES (tem); note; note = next)
        {
diff --git a/gcc/rtl.h b/gcc/rtl.h
index 53fa353fb0b..c3f46c6f2e9 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -579,6 +579,13 @@ public:
   /* Mark this insn as not deleted.  */
 
   void set_undeleted () { volatil = false; }
+
+  /* Source location, or UNKNOWN_LOCATION.  */
+  location_t location () const;
+  void set_location (location_t);
+
+  /* True when location () is a real source location.  */
+  bool has_location () const;
 };
 
 /* Subclasses of rtx_insn.  */
@@ -1528,24 +1535,27 @@ inline rtx& PATTERN (rtx insn)
   return XEXP (insn, 3);
 }
 
-inline location_t INSN_LOCATION (const rtx_insn *insn)
+inline location_t
+rtx_insn::location () const
 {
-  return XLOC (insn, 4);
+  return XLOC (this, 4);
 }
 
-inline location_t& INSN_LOCATION (rtx_insn *insn)
+inline void
+rtx_insn::set_location (location_t loc)
 {
-  return XLOC (insn, 4);
+  XLOC (this, 4) = loc;
 }
 
-inline bool INSN_HAS_LOCATION (const rtx_insn *insn)
+inline bool
+rtx_insn::has_location () const
 {
-  return LOCATION_LOCUS (INSN_LOCATION (insn)) != UNKNOWN_LOCATION;
+  return LOCATION_LOCUS (location ()) != UNKNOWN_LOCATION;
 }
 
 /* LOCATION of an RTX if relevant.  */
 #define RTL_LOCATION(X) (INSN_P (X) ? \
-                        INSN_LOCATION (as_a <rtx_insn *> (X)) \
+                        (as_a <rtx_insn *> (X))->location () \
                         : UNKNOWN_LOCATION)
 
 /* Code number of instruction, from when it was recognized.
diff --git a/gcc/var-tracking.cc b/gcc/var-tracking.cc
index 273ca053f92..8439aed6833 100644
--- a/gcc/var-tracking.cc
+++ b/gcc/var-tracking.cc
@@ -10029,7 +10029,7 @@ reemit_marker_as_note (rtx_insn *insn)
        if (cfun->debug_nonbind_markers)
          {
            note = emit_note_before (kind, insn);
-           NOTE_MARKER_LOCATION (note) = INSN_LOCATION (insn);
+           NOTE_MARKER_LOCATION (note) = insn->location ();
          }
        delete_insn (insn);
        return note;
-- 
2.53.0

Reply via email to