From b0861f7a89fdd386d883c48130ab10926a037ffc Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Wed, 30 Jul 2014 14:32:31 -0400
Subject: [PATCH 233/244] FIXME: dwarf trace head and rtx_expr_list::insn (no
 ChangeLog yet)

---
 gcc/dwarf2cfi.c | 29 +++++++++++++++--------------
 gcc/rtl.h       |  9 +++++++++
 2 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/gcc/dwarf2cfi.c b/gcc/dwarf2cfi.c
index 8d69285..4268856 100644
--- a/gcc/dwarf2cfi.c
+++ b/gcc/dwarf2cfi.c
@@ -100,7 +100,7 @@ typedef struct GTY(()) reg_saved_in_data_struct {
 typedef struct
 {
   /* The insn that begins the trace.  */
-  rtx head;
+  rtx_insn *head;
 
   /* The row state at the beginning and end of the trace.  */
   dw_cfi_row *beg_row, *end_row;
@@ -303,7 +303,7 @@ expand_builtin_init_dwarf_reg_sizes (tree address)
 
 
 static dw_trace_info *
-get_trace_info (rtx insn)
+get_trace_info (rtx_insn *insn)
 {
   dw_trace_info dummy;
   dummy.head = insn;
@@ -311,7 +311,7 @@ get_trace_info (rtx insn)
 }
 
 static bool
-save_point_p (rtx insn)
+save_point_p (rtx_insn *insn)
 {
   /* Labels, except those that are really jump tables.  */
   if (LABEL_P (insn))
@@ -2197,7 +2197,7 @@ add_cfis_to_fde (void)
    trace from CUR_TRACE and CUR_ROW.  */
 
 static void
-maybe_record_trace_start (rtx start, rtx origin)
+maybe_record_trace_start (rtx_insn *start, rtx origin)
 {
   dw_trace_info *ti;
   HOST_WIDE_INT args_size;
@@ -2248,7 +2248,7 @@ maybe_record_trace_start (rtx start, rtx origin)
    and non-local goto edges.  */
 
 static void
-maybe_record_trace_start_abnormal (rtx start, rtx origin)
+maybe_record_trace_start_abnormal (rtx_insn *start, rtx origin)
 {
   HOST_WIDE_INT save_args_size, delta;
   dw_cfa_location save_cfa;
@@ -2284,7 +2284,7 @@ maybe_record_trace_start_abnormal (rtx start, rtx origin)
 /* ??? Sadly, this is in large part a duplicate of make_edges.  */
 
 static void
-create_trace_edges (rtx insn)
+create_trace_edges (rtx_insn *insn)
 {
   rtx tmp;
   int i, n;
@@ -2303,14 +2303,14 @@ create_trace_edges (rtx insn)
 	  n = GET_NUM_ELEM (vec);
 	  for (i = 0; i < n; ++i)
 	    {
-	      rtx lab = XEXP (RTVEC_ELT (vec, i), 0);
+	      rtx_insn *lab = as_a <rtx_insn *> (XEXP (RTVEC_ELT (vec, i), 0));
 	      maybe_record_trace_start (lab, insn);
 	    }
 	}
       else if (computed_jump_p (insn))
 	{
 	  for (rtx_expr_list *lab = forced_labels; lab; lab = lab->next ())
-	    maybe_record_trace_start (lab->element (), insn);
+	    maybe_record_trace_start (lab->insn (), insn);
 	}
       else if (returnjump_p (insn))
 	;
@@ -2319,13 +2319,14 @@ create_trace_edges (rtx insn)
 	  n = ASM_OPERANDS_LABEL_LENGTH (tmp);
 	  for (i = 0; i < n; ++i)
 	    {
-	      rtx lab = XEXP (ASM_OPERANDS_LABEL (tmp, i), 0);
+	      rtx_insn *lab =
+		as_a <rtx_insn *> (XEXP (ASM_OPERANDS_LABEL (tmp, i), 0));
 	      maybe_record_trace_start (lab, insn);
 	    }
 	}
       else
 	{
-	  rtx lab = JUMP_LABEL (insn);
+	  rtx_insn *lab = JUMP_LABEL_AS_INSN (insn);
 	  gcc_assert (lab != NULL);
 	  maybe_record_trace_start (lab, insn);
 	}
@@ -2341,7 +2342,7 @@ create_trace_edges (rtx insn)
 	for (rtx_expr_list *lab = nonlocal_goto_handler_labels;
 	     lab;
 	     lab = lab->next ())
-	  maybe_record_trace_start_abnormal (lab->element (), insn);
+	  maybe_record_trace_start_abnormal (lab->insn (), insn);
     }
   else if (rtx_sequence *seq = dyn_cast <rtx_sequence *> (PATTERN (insn)))
     {
@@ -2376,7 +2377,7 @@ scan_insn_after (rtx insn)
 static void
 scan_trace (dw_trace_info *trace)
 {
-  rtx prev, insn = trace->head;
+  rtx_insn *prev, *insn = trace->head;
   dw_cfa_location this_cfa;
 
   if (dump_file)
@@ -2397,7 +2398,7 @@ scan_trace (dw_trace_info *trace)
        insn;
        prev = insn, insn = NEXT_INSN (insn))
     {
-      rtx control;
+      rtx_insn *control;
 
       /* Do everything that happens "before" the insn.  */
       add_cfi_insn = prev;
@@ -2427,7 +2428,7 @@ scan_trace (dw_trace_info *trace)
 	  rtx elt;
 	  int i, n = pat->len ();
 
-	  control = pat->element (0);
+	  control = pat->insn (0);
 	  if (can_throw_internal (control))
 	    notice_eh_throw (control);
 	  dwarf2out_flush_queued_reg_saves ();
diff --git a/gcc/rtl.h b/gcc/rtl.h
index b0aec46..5379e1a 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -414,6 +414,10 @@ public:
 
   /* Get at the underlying rtx.  */
   rtx element () const;
+
+  /* Get at the rtx, casting to rtx_insn *.  */
+  rtx_insn *insn () const;
+
 };
 
 template <>
@@ -1287,6 +1291,11 @@ inline rtx rtx_expr_list::element () const
   return XEXP (this, 0);
 }
 
+inline rtx_insn *rtx_expr_list::insn () const
+{
+  return as_a <rtx_insn *> (XEXP (this, 0));
+}
+
 /* Methods of rtx_insn_list.  */
 
 inline rtx_insn_list *rtx_insn_list::next () const
-- 
1.8.5.3

