re PR target/65697 (__atomic memory barriers not strong enough for __sync builtins)
[gcc.git] / gcc / print-rtl.c
index 66d98b10caf12e2ba955cc8ddff13eeb80bda304..36182d349ce40738bf7a7df3214171dd76c4cc1e 100644 (file)
@@ -1,5 +1,5 @@
 /* Print RTL for GCC.
-   Copyright (C) 1987-2014 Free Software Foundation, Inc.
+   Copyright (C) 1987-2015 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -33,13 +33,18 @@ along with GCC; see the file COPYING3.  If not see
 /* These headers all define things which are not available in
    generator programs.  */
 #ifndef GENERATOR_FILE
+#include "alias.h"
+#include "symtab.h"
 #include "tree.h"
 #include "print-tree.h"
 #include "flags.h"
 #include "hard-reg-set.h"
+#include "predict.h"
+#include "function.h"
 #include "basic-block.h"
 #include "diagnostic.h"
 #include "tree-pretty-print.h"
+#include "alloc-pool.h"
 #include "cselib.h"
 #include "dumpfile.h"  /* for dump_flags */
 #include "dwarf2out.h"
@@ -188,7 +193,12 @@ print_rtx (const_rtx in_rtx)
 #endif
 
   if (INSN_CHAIN_CODE_P (GET_CODE (in_rtx)))
-    fprintf (outfile, " %d", INSN_UID (in_rtx));
+    {
+      if (flag_dump_unnumbered)
+       fprintf (outfile, " #");
+      else
+       fprintf (outfile, " %d", INSN_UID (in_rtx));
+    }
 
   /* Get the format string and skip the first elements if we have handled
      them already.  */
@@ -387,12 +397,16 @@ print_rtx (const_rtx in_rtx)
        if (i == 4 && INSN_P (in_rtx))
          {
 #ifndef GENERATOR_FILE
+           const rtx_insn *in_insn = as_a <const rtx_insn *> (in_rtx);
+
            /*  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_LOCATION (in_rtx) && insn_file (in_rtx))
-             fprintf (outfile, " %s:%i", insn_file (in_rtx),
-                      insn_line (in_rtx));
+           if (INSN_HAS_LOCATION (in_insn))
+             {
+               expanded_location xloc = insn_location (in_insn);
+               fprintf (outfile, " %s:%i", xloc.file, xloc.line);
+             }
 #endif
          }
        else if (i == 6 && GET_CODE (in_rtx) == ASM_OPERANDS)
@@ -441,55 +455,12 @@ print_rtx (const_rtx in_rtx)
            int value = XINT (in_rtx, i);
            const char *name;
 
-#ifndef GENERATOR_FILE
-           if (REG_P (in_rtx) && (unsigned) value < FIRST_PSEUDO_REGISTER)
-             fprintf (outfile, " %d %s", value, reg_names[value]);
-           else if (REG_P (in_rtx)
-                    && (unsigned) value <= LAST_VIRTUAL_REGISTER)
-             {
-               if (value == VIRTUAL_INCOMING_ARGS_REGNUM)
-                 fprintf (outfile, " %d virtual-incoming-args", value);
-               else if (value == VIRTUAL_STACK_VARS_REGNUM)
-                 fprintf (outfile, " %d virtual-stack-vars", value);
-               else if (value == VIRTUAL_STACK_DYNAMIC_REGNUM)
-                 fprintf (outfile, " %d virtual-stack-dynamic", value);
-               else if (value == VIRTUAL_OUTGOING_ARGS_REGNUM)
-                 fprintf (outfile, " %d virtual-outgoing-args", value);
-               else if (value == VIRTUAL_CFA_REGNUM)
-                 fprintf (outfile, " %d virtual-cfa", value);
-               else if (value == VIRTUAL_PREFERRED_STACK_BOUNDARY_REGNUM)
-                 fprintf (outfile, " %d virtual-preferred-stack-boundary",
-                          value);
-               else
-                 fprintf (outfile, " %d virtual-reg-%d", value,
-                          value-FIRST_VIRTUAL_REGISTER);
-             }
-           else
-#endif
-             if (flag_dump_unnumbered
-                    && (is_insn || NOTE_P (in_rtx)))
+           if (flag_dump_unnumbered
+               && (is_insn || NOTE_P (in_rtx)))
              fputc ('#', outfile);
            else
              fprintf (outfile, " %d", value);
 
-#ifndef GENERATOR_FILE
-           if (REG_P (in_rtx) && REG_ATTRS (in_rtx))
-             {
-               fputs (" [", outfile);
-               if (ORIGINAL_REGNO (in_rtx) != REGNO (in_rtx))
-                 fprintf (outfile, "orig:%i", ORIGINAL_REGNO (in_rtx));
-               if (REG_EXPR (in_rtx))
-                 print_mem_expr (outfile, REG_EXPR (in_rtx));
-
-               if (REG_OFFSET (in_rtx))
-                 fprintf (outfile, "+" HOST_WIDE_INT_PRINT_DEC,
-                          REG_OFFSET (in_rtx));
-               fputs (" ]", outfile);
-             }
-           if (REG_P (in_rtx) && REGNO (in_rtx) != ORIGINAL_REGNO (in_rtx))
-             fprintf (outfile, " [%d]", ORIGINAL_REGNO (in_rtx));
-#endif
-
            if (is_insn && &INSN_CODE (in_rtx) == &XINT (in_rtx, i)
                && XINT (in_rtx, i) >= 0
                && (name = get_insn_name (XINT (in_rtx, i))) != NULL)
@@ -498,6 +469,58 @@ print_rtx (const_rtx in_rtx)
          }
        break;
 
+      case 'r':
+       {
+         unsigned int regno = REGNO (in_rtx);
+#ifndef GENERATOR_FILE
+         if (regno < FIRST_PSEUDO_REGISTER)
+           fprintf (outfile, " %d %s", regno, reg_names[regno]);
+         else if (regno <= LAST_VIRTUAL_REGISTER)
+           {
+             if (regno == VIRTUAL_INCOMING_ARGS_REGNUM)
+               fprintf (outfile, " %d virtual-incoming-args", regno);
+             else if (regno == VIRTUAL_STACK_VARS_REGNUM)
+               fprintf (outfile, " %d virtual-stack-vars", regno);
+             else if (regno == VIRTUAL_STACK_DYNAMIC_REGNUM)
+               fprintf (outfile, " %d virtual-stack-dynamic", regno);
+             else if (regno == VIRTUAL_OUTGOING_ARGS_REGNUM)
+               fprintf (outfile, " %d virtual-outgoing-args", regno);
+             else if (regno == VIRTUAL_CFA_REGNUM)
+               fprintf (outfile, " %d virtual-cfa", regno);
+             else if (regno == VIRTUAL_PREFERRED_STACK_BOUNDARY_REGNUM)
+               fprintf (outfile, " %d virtual-preferred-stack-boundary",
+                        regno);
+             else
+               fprintf (outfile, " %d virtual-reg-%d", regno,
+                        regno-FIRST_VIRTUAL_REGISTER);
+           }
+         else
+#endif
+           if (flag_dump_unnumbered && is_insn)
+             fputc ('#', outfile);
+           else
+             fprintf (outfile, " %d", regno);
+
+#ifndef GENERATOR_FILE
+         if (REG_ATTRS (in_rtx))
+           {
+             fputs (" [", outfile);
+             if (regno != ORIGINAL_REGNO (in_rtx))
+               fprintf (outfile, "orig:%i", ORIGINAL_REGNO (in_rtx));
+             if (REG_EXPR (in_rtx))
+               print_mem_expr (outfile, REG_EXPR (in_rtx));
+
+             if (REG_OFFSET (in_rtx))
+               fprintf (outfile, "+" HOST_WIDE_INT_PRINT_DEC,
+                        REG_OFFSET (in_rtx));
+             fputs (" ]", outfile);
+           }
+         if (regno != ORIGINAL_REGNO (in_rtx))
+           fprintf (outfile, " [%d]", ORIGINAL_REGNO (in_rtx));
+#endif
+         break;
+       }
+
       /* Print NOTE_INSN names rather than integer codes.  */
 
       case 'n':
@@ -692,14 +715,15 @@ DEBUG_VARIABLE int debug_rtx_count = 0;   /* 0 is treated as equivalent to 1 */
 /* Call this function to print list from X on.
 
    N is a count of the rtx's to print. Positive values print from the specified
-   rtx on.  Negative values print a window around the rtx.
-   EG: -5 prints 2 rtx's on either side (in addition to the specified rtx).  */
+   rtx_insn on.  Negative values print a window around the rtx_insn.
+   EG: -5 prints 2 rtx_insn's on either side (in addition to the specified
+   rtx_insn).  */
 
 DEBUG_FUNCTION void
-debug_rtx_list (const_rtx x, int n)
+debug_rtx_list (const rtx_insn *x, int n)
 {
   int i,count;
-  const_rtx insn;
+  const rtx_insn *insn;
 
   count = n == 0 ? 1 : n < 0 ? -n : n;
 
@@ -720,10 +744,11 @@ debug_rtx_list (const_rtx x, int n)
     }
 }
 
-/* Call this function to print an rtx list from START to END inclusive.  */
+/* Call this function to print an rtx_insn list from START to END
+   inclusive.  */
 
 DEBUG_FUNCTION void
-debug_rtx_range (const_rtx start, const_rtx end)
+debug_rtx_range (const rtx_insn *start, const rtx_insn *end)
 {
   while (1)
     {
@@ -735,12 +760,12 @@ debug_rtx_range (const_rtx start, const_rtx end)
     }
 }
 
-/* Call this function to search an rtx list to find one with insn uid UID,
+/* Call this function to search an rtx_insn list to find one with insn uid UID,
    and then call debug_rtx_list to print it, using DEBUG_RTX_COUNT.
    The found insn is returned to enable further debugging analysis.  */
 
-DEBUG_FUNCTION const_rtx
-debug_rtx_find (const_rtx x, int uid)
+DEBUG_FUNCTION const rtx_insn *
+debug_rtx_find (const rtx_insn *x, int uid)
 {
   while (x != 0 && INSN_UID (x) != uid)
     x = NEXT_INSN (x);
@@ -765,7 +790,7 @@ debug_rtx_find (const_rtx x, int uid)
 void
 print_rtl (FILE *outf, const_rtx rtx_first)
 {
-  const_rtx tmp_rtx;
+  const rtx_insn *tmp_rtx;
 
   outfile = outf;
   sawclose = 0;
@@ -785,7 +810,9 @@ print_rtl (FILE *outf, const_rtx rtx_first)
       case CODE_LABEL:
       case JUMP_TABLE_DATA:
       case BARRIER:
-       for (tmp_rtx = rtx_first; tmp_rtx != 0; tmp_rtx = NEXT_INSN (tmp_rtx))
+       for (tmp_rtx = as_a <const rtx_insn *> (rtx_first);
+            tmp_rtx != 0;
+            tmp_rtx = NEXT_INSN (tmp_rtx))
          {
            fputs (print_rtx_head, outfile);
            print_rtx (tmp_rtx);