]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/print-rtl.c
PR c++/87554 - ICE with extern template and reference member.
[thirdparty/gcc.git] / gcc / print-rtl.c
index 20bdafdb580cd43cb548febe440ce2866052b0bd..fbb108568b3f899c10ce9b7fe12486d0751258d3 100644 (file)
@@ -1,5 +1,5 @@
 /* Print RTL for GCC.
-   Copyright (C) 1987-2017 Free Software Foundation, Inc.
+   Copyright (C) 1987-2019 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -35,11 +35,12 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GENERATOR_FILE
 #include "alias.h"
 #include "tree.h"
-#include "cfg.h"
+#include "basic-block.h"
 #include "print-tree.h"
 #include "flags.h"
 #include "predict.h"
 #include "function.h"
+#include "cfg.h"
 #include "basic-block.h"
 #include "diagnostic.h"
 #include "tree-pretty-print.h"
@@ -179,6 +180,23 @@ print_mem_expr (FILE *outfile, const_tree expr)
 }
 #endif
 
+/* Print X to FILE.  */
+
+static void
+print_poly_int (FILE *file, poly_int64 x)
+{
+  HOST_WIDE_INT const_x;
+  if (x.is_constant (&const_x))
+    fprintf (file, HOST_WIDE_INT_PRINT_DEC, const_x);
+  else
+    {
+      fprintf (file, "[" HOST_WIDE_INT_PRINT_DEC, x.coeffs[0]);
+      for (int i = 1; i < NUM_POLY_INT_COEFFS; ++i)
+       fprintf (file, ", " HOST_WIDE_INT_PRINT_DEC, x.coeffs[i]);
+      fprintf (file, "]");
+    }
+}
+
 /* Subroutine of print_rtx_operand for handling code '0'.
    0 indicates a field for internal use that should not be printed.
    However there are various special cases, such as the third field
@@ -246,7 +264,6 @@ rtx_writer::print_rtx_operand_code_0 (const_rtx in_rtx ATTRIBUTE_UNUSED,
          }
 
        case NOTE_INSN_VAR_LOCATION:
-       case NOTE_INSN_CALL_ARG_LOCATION:
          fputc (' ', m_outfile);
          print_rtx (NOTE_VAR_LOCATION (in_rtx));
          break;
@@ -257,6 +274,17 @@ rtx_writer::print_rtx_operand_code_0 (const_rtx in_rtx ATTRIBUTE_UNUSED,
          fputc ('\t', m_outfile);
          break;
 
+       case NOTE_INSN_BEGIN_STMT:
+       case NOTE_INSN_INLINE_ENTRY:
+#ifndef GENERATOR_FILE
+         {
+           expanded_location xloc
+             = expand_location (NOTE_MARKER_LOCATION (in_rtx));
+           fprintf (m_outfile, " %s:%i", xloc.file, xloc.line);
+         }
+#endif
+         break;
+
        default:
          break;
        }
@@ -335,14 +363,27 @@ rtx_writer::print_rtx_operand_codes_E_and_V (const_rtx in_rtx, int idx)
       m_sawclose = 0;
     }
   fputs (" [", m_outfile);
-  if (NULL != XVEC (in_rtx, idx))
+  if (XVEC (in_rtx, idx) != NULL)
     {
       m_indent += 2;
       if (XVECLEN (in_rtx, idx))
        m_sawclose = 1;
 
       for (int j = 0; j < XVECLEN (in_rtx, idx); j++)
-       print_rtx (XVECEXP (in_rtx, idx, j));
+       {
+         int j1;
+
+         print_rtx (XVECEXP (in_rtx, idx, j));
+         for (j1 = j + 1; j1 < XVECLEN (in_rtx, idx); j1++)
+           if (XVECEXP (in_rtx, idx, j) != XVECEXP (in_rtx, idx, j1))
+             break;
+
+         if (j1 != j + 1)
+           {
+             fprintf (m_outfile, " repeated x%i", j1 - j);
+             j = j1 - 1;
+           }
+       }
 
       m_indent -= 2;
     }
@@ -370,7 +411,8 @@ rtx_writer::print_rtx_operand_code_i (const_rtx in_rtx, int idx)
       if (INSN_HAS_LOCATION (in_insn))
        {
          expanded_location xloc = insn_location (in_insn);
-         fprintf (m_outfile, " \"%s\":%i", xloc.file, xloc.line);
+         fprintf (m_outfile, " \"%s\":%i:%i", xloc.file, xloc.line,
+                  xloc.column);
        }
 #endif
     }
@@ -498,9 +540,11 @@ rtx_writer::print_rtx_operand_code_r (const_rtx in_rtx)
       if (REG_EXPR (in_rtx))
        print_mem_expr (m_outfile, REG_EXPR (in_rtx));
 
-      if (REG_OFFSET (in_rtx))
-       fprintf (m_outfile, "+" HOST_WIDE_INT_PRINT_DEC,
-                REG_OFFSET (in_rtx));
+      if (maybe_ne (REG_OFFSET (in_rtx), 0))
+       {
+         fprintf (m_outfile, "+");
+         print_poly_int (m_outfile, REG_OFFSET (in_rtx));
+       }
       fputs (" ]", m_outfile);
     }
   if (regno != ORIGINAL_REGNO (in_rtx))
@@ -608,6 +652,11 @@ rtx_writer::print_rtx_operand (const_rtx in_rtx, int idx)
       print_rtx_operand_code_i (in_rtx, idx);
       break;
 
+    case 'p':
+      fprintf (m_outfile, " ");
+      print_poly_int (m_outfile, SUBREG_BYTE (in_rtx));
+      break;
+
     case 'r':
       print_rtx_operand_code_r (in_rtx);
       break;
@@ -864,10 +913,16 @@ rtx_writer::print_rtx (const_rtx in_rtx)
        fputc (' ', m_outfile);
 
       if (MEM_OFFSET_KNOWN_P (in_rtx))
-       fprintf (m_outfile, "+" HOST_WIDE_INT_PRINT_DEC, MEM_OFFSET (in_rtx));
+       {
+         fprintf (m_outfile, "+");
+         print_poly_int (m_outfile, MEM_OFFSET (in_rtx));
+       }
 
       if (MEM_SIZE_KNOWN_P (in_rtx))
-       fprintf (m_outfile, " S" HOST_WIDE_INT_PRINT_DEC, MEM_SIZE (in_rtx));
+       {
+         fprintf (m_outfile, " S");
+         print_poly_int (m_outfile, MEM_SIZE (in_rtx));
+       }
 
       if (MEM_ALIGN (in_rtx) != 1)
        fprintf (m_outfile, " A%u", MEM_ALIGN (in_rtx));
@@ -897,6 +952,17 @@ rtx_writer::print_rtx (const_rtx in_rtx)
       fprintf (m_outfile, " ");
       cwi_output_hex (m_outfile, in_rtx);
       break;
+
+    case CONST_POLY_INT:
+      fprintf (m_outfile, " [");
+      print_dec (CONST_POLY_INT_COEFFS (in_rtx)[0], m_outfile, SIGNED);
+      for (unsigned int i = 1; i < NUM_POLY_INT_COEFFS; ++i)
+       {
+         fprintf (m_outfile, ", ");
+         print_dec (CONST_POLY_INT_COEFFS (in_rtx)[i], m_outfile, SIGNED);
+       }
+      fprintf (m_outfile, "]");
+      break;
 #endif
 
     case CODE_LABEL:
@@ -966,6 +1032,23 @@ debug (const rtx_def *ptr)
     fprintf (stderr, "<nil>\n");
 }
 
+/* Like debug_rtx but with no newline, as debug_helper will add one.
+
+   Note: No debug_slim(rtx_insn *) variant implemented, as this
+   function can serve for both rtx and rtx_insn.  */
+
+static void
+debug_slim (const_rtx x)
+{
+  rtx_writer w (stderr, 0, false, false, NULL);
+  w.print_rtx (x);
+}
+
+DEFINE_DEBUG_VEC (rtx_def *)
+DEFINE_DEBUG_VEC (rtx_insn *)
+DEFINE_DEBUG_HASH_SET (rtx_def *)
+DEFINE_DEBUG_HASH_SET (rtx_insn *)
+
 /* Count of rtx's to print with debug_rtx_list.
    This global exists because gdb user defined commands have no arguments.  */
 
@@ -1282,7 +1365,7 @@ print_exp (pretty_printer *pp, const_rtx x, int verbose)
       op[1] = XEXP (x, 1);
       break;
     case NOT:
-      st[0] = "!";
+      st[0] = "~";
       op[0] = XEXP (x, 0);
       break;
     case AND:
@@ -1567,6 +1650,17 @@ print_value (pretty_printer *pp, const_rtx x, int verbose)
       }
       break;
 
+    case CONST_POLY_INT:
+      pp_left_bracket (pp);
+      pp_wide_int (pp, CONST_POLY_INT_COEFFS (x)[0], SIGNED);
+      for (unsigned int i = 1; i < NUM_POLY_INT_COEFFS; ++i)
+       {
+         pp_string (pp, ", ");
+         pp_wide_int (pp, CONST_POLY_INT_COEFFS (x)[i], SIGNED);
+       }
+      pp_right_bracket (pp);
+      break;
+
     case CONST_DOUBLE:
       if (FLOAT_MODE_P (GET_MODE (x)))
        {
@@ -1613,7 +1707,8 @@ print_value (pretty_printer *pp, const_rtx x, int verbose)
       break;
     case SUBREG:
       print_value (pp, SUBREG_REG (x), verbose);
-      pp_printf (pp, "#%d", SUBREG_BYTE (x));
+      pp_printf (pp, "#");
+      pp_wide_integer (pp, SUBREG_BYTE (x));
       break;
     case SCRATCH:
     case CC0:
@@ -1661,6 +1756,7 @@ print_pattern (pretty_printer *pp, const_rtx x, int verbose)
       print_exp (pp, x, verbose);
       break;
     case CLOBBER:
+    case CLOBBER_HIGH:
     case USE:
       pp_printf (pp, "%s ", GET_RTX_NAME (GET_CODE (x)));
       print_value (pp, XEXP (x, 0), verbose);
@@ -1790,12 +1886,30 @@ print_insn (pretty_printer *pp, const rtx_insn *x, int verbose)
 
     case DEBUG_INSN:
       {
+       if (DEBUG_MARKER_INSN_P (x))
+         {
+           switch (INSN_DEBUG_MARKER_KIND (x))
+             {
+             case NOTE_INSN_BEGIN_STMT:
+               pp_string (pp, "debug begin stmt marker");
+               break;
+
+             case NOTE_INSN_INLINE_ENTRY:
+               pp_string (pp, "debug inline entry marker");
+               break;
+
+             default:
+               gcc_unreachable ();
+             }
+           break;
+         }
+
        const char *name = "?";
+       char idbuf[32];
 
        if (DECL_P (INSN_VAR_LOCATION_DECL (x)))
          {
            tree id = DECL_NAME (INSN_VAR_LOCATION_DECL (x));
-           char idbuf[32];
            if (id)
              name = IDENTIFIER_POINTER (id);
            else if (TREE_CODE (INSN_VAR_LOCATION_DECL (x))
@@ -1870,7 +1984,6 @@ print_insn (pretty_printer *pp, const rtx_insn *x, int verbose)
            break;
 
          case NOTE_INSN_VAR_LOCATION:
-         case NOTE_INSN_CALL_ARG_LOCATION:
            pp_left_brace (pp);
            print_pattern (pp, NOTE_VAR_LOCATION (x), verbose);
            pp_right_brace (pp);