From 63d1eae9a1d130e62a84c9cdaffcee03903e493a Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Thu, 21 Apr 2016 12:17:10 -0400
Subject: [PATCH 12/13] FIXME: make emit_status::x_cur_debug_insn_uid private

---
 gcc/emit-rtl.c | 65 +++++++++++++++++++++++++++++++++++++---------------------
 gcc/function.h | 16 ++++++++++++++-
 2 files changed, 57 insertions(+), 24 deletions(-)

diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index ecd73b1..09228f8 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -175,7 +175,6 @@ struct const_fixed_hasher : ggc_cache_ptr_hash<rtx_def>
 static GTY ((cache)) hash_table<const_fixed_hasher> *const_fixed_htab;
 
 #define cur_insn_uid (crtl->emit.x_cur_insn_uid)
-#define cur_debug_insn_uid (crtl->emit.x_cur_debug_insn_uid)
 #define first_label_num (crtl->emit.x_first_label_num)
 
 static void set_used_decls (tree);
@@ -2569,7 +2568,7 @@ gen_label_rtx (void)
    Used for an inline-procedure after copying the insn chain.  */
 
 void
-set_new_first_and_last_insn (rtx_insn *first, rtx_insn *last)
+emit_status::set_new_first_and_last_insn (rtx_insn *first, rtx_insn *last)
 {
   rtx_insn *insn;
 
@@ -2582,11 +2581,11 @@ set_new_first_and_last_insn (rtx_insn *first, rtx_insn *last)
       int debug_count = 0;
 
       cur_insn_uid = MIN_NONDEBUG_INSN_UID - 1;
-      cur_debug_insn_uid = 0;
+      x_cur_debug_insn_uid = 0;
 
       for (insn = first; insn; insn = NEXT_INSN (insn))
 	if (INSN_UID (insn) < MIN_NONDEBUG_INSN_UID)
-	  cur_debug_insn_uid = MAX (cur_debug_insn_uid, INSN_UID (insn));
+	  x_cur_debug_insn_uid = MAX (x_cur_debug_insn_uid, INSN_UID (insn));
 	else
 	  {
 	    cur_insn_uid = MAX (cur_insn_uid, INSN_UID (insn));
@@ -2595,9 +2594,9 @@ set_new_first_and_last_insn (rtx_insn *first, rtx_insn *last)
 	  }
 
       if (debug_count)
-	cur_debug_insn_uid = MIN_NONDEBUG_INSN_UID + debug_count;
+	x_cur_debug_insn_uid = MIN_NONDEBUG_INSN_UID + debug_count;
       else
-	cur_debug_insn_uid++;
+	x_cur_debug_insn_uid++;
     }
   else
     for (insn = first; insn; insn = NEXT_INSN (insn))
@@ -2605,6 +2604,13 @@ set_new_first_and_last_insn (rtx_insn *first, rtx_insn *last)
 
   cur_insn_uid++;
 }
+
+void
+set_new_first_and_last_insn (rtx_insn *first, rtx_insn *last)
+{
+  crtl->emit.set_new_first_and_last_insn (first, last);
+}
+
 
 /* Go through all the RTL insn bodies and copy any invalid shared
    structure.  This routine should only be called once.  */
@@ -3237,7 +3243,7 @@ get_last_nonnote_insn (void)
    function.  */
 
 int
-get_max_insn_count (void)
+emit_status::get_max_insn_count ()
 {
   int n = cur_insn_uid;
 
@@ -3245,14 +3251,20 @@ get_max_insn_count (void)
      differences due to debug insns, and not be affected by
      -fmin-insn-uid, to avoid excessive table size and to simplify
      debugging of -fcompare-debug failures.  */
-  if (cur_debug_insn_uid > MIN_NONDEBUG_INSN_UID)
-    n -= cur_debug_insn_uid;
+  if (x_cur_debug_insn_uid > MIN_NONDEBUG_INSN_UID)
+    n -= x_cur_debug_insn_uid;
   else
     n -= MIN_NONDEBUG_INSN_UID;
 
   return n;
 }
 
+int
+get_max_insn_count (void)
+{
+  return crtl->emit.get_max_insn_count ();
+}
+
 
 /* Return the next insn.  If it is a SEQUENCE, return the first insn
    of the sequence.  */
@@ -3866,15 +3878,15 @@ make_insn_raw (rtx pattern)
 
 /* Like `make_insn_raw' but make a DEBUG_INSN instead of an insn.  */
 
-static rtx_insn *
-make_debug_insn_raw (rtx pattern)
+rtx_insn *
+emit_status::make_debug_insn_raw (rtx pattern)
 {
   rtx_debug_insn *insn;
 
   insn = as_a <rtx_debug_insn *> (rtx_alloc (DEBUG_INSN));
-  INSN_UID (insn) = cur_debug_insn_uid++;
-  if (cur_debug_insn_uid > MIN_NONDEBUG_INSN_UID)
-    INSN_UID (insn) = cur_insn_uid++;
+  INSN_UID (insn) = x_cur_debug_insn_uid++;
+  if (x_cur_debug_insn_uid > MIN_NONDEBUG_INSN_UID)
+    INSN_UID (insn) = x_cur_insn_uid++;
 
   PATTERN (insn) = pattern;
   INSN_CODE (insn) = -1;
@@ -3885,6 +3897,14 @@ make_debug_insn_raw (rtx pattern)
   return insn;
 }
 
+/* FIXME.  */
+
+static rtx_insn *
+make_debug_insn_raw (rtx pattern)
+{
+  return crtl->emit.make_debug_insn_raw (pattern);
+}
+
 /* Like `make_insn_raw' but make a JUMP_INSN instead of an insn.  */
 
 static rtx_insn *
@@ -5702,23 +5722,22 @@ emit_status::init_emit (void)
   set_first_insn (NULL);
   set_last_insn (NULL);
   if (MIN_NONDEBUG_INSN_UID)
-    cur_insn_uid = MIN_NONDEBUG_INSN_UID;
+    x_cur_insn_uid = MIN_NONDEBUG_INSN_UID;
   else
-    cur_insn_uid = 1;
-  cur_debug_insn_uid = 1;
-  reg_rtx_no = LAST_VIRTUAL_REGISTER + 1;
-  first_label_num = label_num;
+    x_cur_insn_uid = 1;
+  x_cur_debug_insn_uid = 1;
+  x_reg_rtx_no = LAST_VIRTUAL_REGISTER + 1;
+  x_first_label_num = label_num;
   get_current_sequence ()->next = NULL;
 
   /* Init the tables that describe all the pseudo regs.  */
 
-  crtl->emit.regno_pointer_align_length = LAST_VIRTUAL_REGISTER + 101;
+  regno_pointer_align_length = LAST_VIRTUAL_REGISTER + 101;
 
-  crtl->emit.regno_pointer_align
-    = XCNEWVEC (unsigned char, crtl->emit.regno_pointer_align_length);
+  regno_pointer_align = XCNEWVEC (unsigned char, regno_pointer_align_length);
 
   regno_reg_rtx =
-    ggc_cleared_vec_alloc<rtx> (crtl->emit.regno_pointer_align_length);
+    ggc_cleared_vec_alloc<rtx> (regno_pointer_align_length);
 
   /* Put copies of all the hard registers into regno_reg_rtx.  */
   memcpy (regno_reg_rtx,
diff --git a/gcc/function.h b/gcc/function.h
index f7aebcd..87836d1 100644
--- a/gcc/function.h
+++ b/gcc/function.h
@@ -47,16 +47,27 @@ struct GTY(()) emit_status {
 
   rtx_insn *get_last_insn_anywhere ();
 
-  // private:
+  int get_max_insn_count ();
+
+  void set_new_first_and_last_insn (rtx_insn *first, rtx_insn *last);
+
+  rtx_insn *make_debug_insn_raw (rtx pattern);
+
+  //private:
   friend int ::get_max_uid (void);
 
   /* This is reset to LAST_VIRTUAL_REGISTER + 1 at the start of each function.
      After rtl generation, it is 1 plus the largest register number used.  */
   int x_reg_rtx_no;
 
+ public:
   /* Lowest label number in current function.  */
   int x_first_label_num;
 
+ public:
+  /* TODO: field "seq" can almost be made private; only remaining user is in
+     the GC root in gtype-desc.c.  */
+
   /* seq.first and seq.last are the ends of the doubly-linked chain of
      rtl for the current function.  Both are reset to null at the
      start of rtl generation for the function. 
@@ -69,14 +80,17 @@ struct GTY(()) emit_status {
      The main insn-chain is the last element of the chain.  */
   struct sequence_stack seq;
 
+ public:
   /* INSN_UID for next insn emitted.
      Reset to 1 for each function compiled.  */
   int x_cur_insn_uid;
 
+ private:
   /* INSN_UID for next debug insn emitted.  Only used if
      --param min-nondebug-insn-uid=<value> is given with nonzero value.  */
   int x_cur_debug_insn_uid;
 
+ public:
   /* The length of the regno_pointer_align, regno_decl, and x_regno_reg_rtx
      vectors.  Since these vectors are needed during the expansion phase when
      the total number of registers in the function is not yet known, the
-- 
1.8.5.3

