OSDN Git Service

Fix grammar/spelling.
[pf3gnuchains/gcc-fork.git] / gcc / gimple-pretty-print.c
index 0480f9d..7b29aa6 100644 (file)
@@ -1,6 +1,6 @@
 /* Pretty formatting of GIMPLE statements and expressions.
-   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-   Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+   2011  Free Software Foundation, Inc.
    Contributed by Aldy Hernandez <aldyh@redhat.com> and
    Diego Novillo <dnovillo@google.com>
 
@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-pass.h"
 #include "gimple.h"
 #include "value-prof.h"
+#include "trans-mem.h"
 
 #define INDENT(SPACE)                                                  \
   do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
@@ -81,7 +82,7 @@ newline_and_indent (pretty_printer *buffer, int spc)
 
 /* Print the GIMPLE statement GS on stderr.  */
 
-void
+DEBUG_FUNCTION void
 debug_gimple_stmt (gimple gs)
 {
   print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
@@ -147,7 +148,7 @@ print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
 
 /* Print the GIMPLE sequence SEQ on stderr.  */
 
-void
+DEBUG_FUNCTION void
 debug_gimple_seq (gimple_seq seq)
 {
   print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
@@ -162,6 +163,7 @@ debug_gimple_seq (gimple_seq seq)
      'd' - outputs an int as a decimal,
      's' - outputs a string,
      'n' - outputs a newline,
+     'x' - outputs an int as hexadecimal,
      '+' - increases indent by 2 then outputs a newline,
      '-' - decreases indent by 2 then outputs a newline.   */
 
@@ -216,6 +218,10 @@ dump_gimple_fmt (pretty_printer *buffer, int spc, int flags,
                 newline_and_indent (buffer, spc);
                 break;
 
+             case 'x':
+               pp_scalar (buffer, "%x", va_arg (args, int));
+               break;
+
               case '+':
                 spc += 2;
                 newline_and_indent (buffer, spc);
@@ -339,10 +345,8 @@ dump_binary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
     case VEC_PACK_TRUNC_EXPR:
     case VEC_PACK_SAT_EXPR:
     case VEC_PACK_FIX_TRUNC_EXPR:
-    case VEC_EXTRACT_EVEN_EXPR:
-    case VEC_EXTRACT_ODD_EXPR:
-    case VEC_INTERLEAVE_HIGH_EXPR:
-    case VEC_INTERLEAVE_LOW_EXPR:
+    case VEC_WIDEN_LSHIFT_HI_EXPR:
+    case VEC_WIDEN_LSHIFT_LO_EXPR:
       for (p = tree_code_name [(int) code]; *p; p++)
        pp_character (buffer, TOUPPER (*p));
       pp_string (buffer, " <");
@@ -377,6 +381,90 @@ dump_binary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
     }
 }
 
+/* Helper for dump_gimple_assign.  Print the ternary RHS of the
+   assignment GS.  BUFFER, SPC and FLAGS are as in dump_gimple_stmt.  */
+
+static void
+dump_ternary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
+{
+  const char *p;
+  enum tree_code code = gimple_assign_rhs_code (gs);
+  switch (code)
+    {
+    case WIDEN_MULT_PLUS_EXPR:
+    case WIDEN_MULT_MINUS_EXPR:
+      for (p = tree_code_name [(int) code]; *p; p++)
+       pp_character (buffer, TOUPPER (*p));
+      pp_string (buffer, " <");
+      dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
+      pp_string (buffer, ", ");
+      dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
+      pp_string (buffer, ", ");
+      dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
+      pp_character (buffer, '>');
+      break;
+
+    case FMA_EXPR:
+      dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
+      pp_string (buffer, " * ");
+      dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
+      pp_string (buffer, " + ");
+      dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
+      break;
+
+    case DOT_PROD_EXPR:
+      pp_string (buffer, "DOT_PROD_EXPR <");
+      dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
+      pp_string (buffer, ", ");
+      dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
+      pp_string (buffer, ", ");
+      dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
+      pp_string (buffer, ">");
+      break;
+    
+    case VEC_PERM_EXPR:
+      pp_string (buffer, "VEC_PERM_EXPR <");
+      dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
+      pp_string (buffer, ", ");
+      dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
+      pp_string (buffer, ", ");
+      dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
+      pp_string (buffer, ">");
+      break;
+
+    case REALIGN_LOAD_EXPR:
+      pp_string (buffer, "REALIGN_LOAD <");
+      dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
+      pp_string (buffer, ", ");
+      dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
+      pp_string (buffer, ", ");
+      dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
+      pp_string (buffer, ">");
+      break;
+
+    case COND_EXPR:
+      dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
+      pp_string (buffer, " ? ");
+      dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
+      pp_string (buffer, " : ");
+      dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
+      break;
+
+    case VEC_COND_EXPR:
+      pp_string (buffer, "VEC_COND_EXPR <");
+      dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
+      pp_string (buffer, ", ");
+      dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
+      pp_string (buffer, ", ");
+      dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
+      pp_string (buffer, ">");
+      break;
+
+    default:
+      gcc_unreachable ();
+    }
+}
+
 
 /* Dump the gimple assignment GS.  BUFFER, SPC and FLAGS are as in
    dump_gimple_stmt.  */
@@ -419,6 +507,8 @@ dump_gimple_assign (pretty_printer *buffer, gimple gs, int spc, int flags)
         dump_unary_rhs (buffer, gs, spc, flags);
       else if (gimple_num_ops (gs) == 3)
         dump_binary_rhs (buffer, gs, spc, flags);
+      else if (gimple_num_ops (gs) == 4)
+        dump_ternary_rhs (buffer, gs, spc, flags);
       else
         gcc_unreachable ();
       if (!(flags & TDF_RHS_ONLY))
@@ -504,11 +594,7 @@ pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
       pp_string (buffer, "{ ");
       EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
        {
-         struct tree_decl_minimal in;
-         tree var;
-         in.uid = i;
-         var = (tree) htab_find_with_hash (gimple_referenced_vars (cfun),
-                                           &in, i);
+         tree var = referenced_var_lookup (cfun, i);
          if (var)
            {
              dump_generic_node (buffer, var, 0, dump_flags, false);
@@ -528,8 +614,6 @@ pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
       pp_character (buffer, '}');
       if (pt->vars_contains_global)
        pp_string (buffer, " (glob)");
-      if (pt->vars_contains_restrict)
-       pp_string (buffer, " (restr)");
     }
 }
 
@@ -540,6 +624,7 @@ static void
 dump_gimple_call (pretty_printer *buffer, gimple gs, int spc, int flags)
 {
   tree lhs = gimple_call_lhs (gs);
+  tree fn = gimple_call_fn (gs);
 
   if (flags & TDF_ALIAS)
     {
@@ -562,8 +647,11 @@ dump_gimple_call (pretty_printer *buffer, gimple gs, int spc, int flags)
 
   if (flags & TDF_RAW)
     {
-      dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T",
-                     gs, gimple_call_fn (gs), lhs);
+      if (gimple_call_internal_p (gs))
+       dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
+                        internal_fn_name (gimple_call_internal_fn (gs)), lhs);
+      else
+       dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
       if (gimple_call_num_args (gs) > 0)
         {
           pp_string (buffer, ", ");
@@ -583,7 +671,10 @@ dump_gimple_call (pretty_printer *buffer, gimple gs, int spc, int flags)
 
          pp_space (buffer);
         }
-      print_call_name (buffer, gimple_call_fn (gs), flags);
+      if (gimple_call_internal_p (gs))
+       pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
+      else
+       print_call_name (buffer, fn, flags);
       pp_string (buffer, " (");
       dump_gimple_call_args (buffer, gs, flags);
       pp_character (buffer, ')');
@@ -600,9 +691,62 @@ dump_gimple_call (pretty_printer *buffer, gimple gs, int spc, int flags)
 
   if (gimple_call_return_slot_opt_p (gs))
     pp_string (buffer, " [return slot optimization]");
-
   if (gimple_call_tail_p (gs))
     pp_string (buffer, " [tail call]");
+
+  if (fn == NULL)
+    return;
+
+  /* Dump the arguments of _ITM_beginTransaction sanely.  */
+  if (TREE_CODE (fn) == ADDR_EXPR)
+    fn = TREE_OPERAND (fn, 0);
+  if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
+    pp_string (buffer, " [tm-clone]");
+  if (TREE_CODE (fn) == FUNCTION_DECL
+      && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
+      && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
+      && gimple_call_num_args (gs) > 0)
+    {
+      tree t = gimple_call_arg (gs, 0);
+      unsigned HOST_WIDE_INT props;
+      gcc_assert (TREE_CODE (t) == INTEGER_CST);
+
+      pp_string (buffer, " [ ");
+
+      /* Get the transaction code properties.  */
+      props = TREE_INT_CST_LOW (t);
+
+      if (props & PR_INSTRUMENTEDCODE)
+       pp_string (buffer, "instrumentedCode ");
+      if (props & PR_UNINSTRUMENTEDCODE)
+       pp_string (buffer, "uninstrumentedCode ");
+      if (props & PR_HASNOXMMUPDATE)
+       pp_string (buffer, "hasNoXMMUpdate ");
+      if (props & PR_HASNOABORT)
+       pp_string (buffer, "hasNoAbort ");
+      if (props & PR_HASNOIRREVOCABLE)
+       pp_string (buffer, "hasNoIrrevocable ");
+      if (props & PR_DOESGOIRREVOCABLE)
+       pp_string (buffer, "doesGoIrrevocable ");
+      if (props & PR_HASNOSIMPLEREADS)
+       pp_string (buffer, "hasNoSimpleReads ");
+      if (props & PR_AWBARRIERSOMITTED)
+       pp_string (buffer, "awBarriersOmitted ");
+      if (props & PR_RARBARRIERSOMITTED)
+       pp_string (buffer, "RaRBarriersOmitted ");
+      if (props & PR_UNDOLOGCODE)
+       pp_string (buffer, "undoLogCode ");
+      if (props & PR_PREFERUNINSTRUMENTED)
+       pp_string (buffer, "preferUninstrumented ");
+      if (props & PR_EXCEPTIONBLOCK)
+       pp_string (buffer, "exceptionBlock ");
+      if (props & PR_HASELSE)
+       pp_string (buffer, "hasElse ");
+      if (props & PR_READONLY)
+       pp_string (buffer, "readOnly ");
+
+      pp_string (buffer, "]");
+    }
 }
 
 
@@ -735,7 +879,7 @@ dump_gimple_bind (pretty_printer *buffer, gimple gs, int spc, int flags)
     {
       tree var;
 
-      for (var = gimple_bind_vars (gs); var; var = TREE_CHAIN (var))
+      for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
        {
           newline_and_indent (buffer, 2);
          print_declaration (buffer, var, spc, flags);
@@ -858,6 +1002,24 @@ dump_gimple_eh_must_not_throw (pretty_printer *buffer, gimple gs,
 }
 
 
+/* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
+   indent.  FLAGS specifies details to show in the dump (see TDF_* in
+   tree-pass.h).  */
+
+static void
+dump_gimple_eh_else (pretty_printer *buffer, gimple gs, int spc, int flags)
+{
+  if (flags & TDF_RAW)
+    dump_gimple_fmt (buffer, spc, flags,
+                    "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
+                    gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
+  else
+    dump_gimple_fmt (buffer, spc, flags,
+                   "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
+                    gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
+}
+
+
 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
    indent.  FLAGS specifies details to show in the dump (see TDF_* in
    tree-pass.h).  */
@@ -905,6 +1067,17 @@ dump_gimple_debug (pretty_printer *buffer, gimple gs, int spc, int flags)
                         gimple_debug_bind_get_value (gs));
       break;
 
+    case GIMPLE_DEBUG_SOURCE_BIND:
+      if (flags & TDF_RAW)
+       dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
+                        gimple_debug_source_bind_get_var (gs),
+                        gimple_debug_source_bind_get_value (gs));
+      else
+       dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
+                        gimple_debug_source_bind_get_var (gs),
+                        gimple_debug_source_bind_get_value (gs));
+      break;
+
     default:
       gcc_unreachable ();
     }
@@ -1169,6 +1342,86 @@ dump_gimple_omp_return (pretty_printer *buffer, gimple gs, int spc, int flags)
     }
 }
 
+/* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER.  */
+
+static void
+dump_gimple_transaction (pretty_printer *buffer, gimple gs, int spc, int flags)
+{
+  unsigned subcode = gimple_transaction_subcode (gs);
+
+  if (flags & TDF_RAW)
+    {
+      dump_gimple_fmt (buffer, spc, flags,
+                      "%G [SUBCODE=%x,LABEL=%T] <%+BODY <%S> >",
+                      gs, subcode, gimple_transaction_label (gs),
+                      gimple_transaction_body (gs));
+    }
+  else
+    {
+      if (subcode & GTMA_IS_OUTER)
+       pp_string (buffer, "__transaction_atomic [[outer]]");
+      else if (subcode & GTMA_IS_RELAXED)
+       pp_string (buffer, "__transaction_relaxed");
+      else
+       pp_string (buffer, "__transaction_atomic");
+      subcode &= ~GTMA_DECLARATION_MASK;
+
+      if (subcode || gimple_transaction_label (gs))
+       {
+         pp_string (buffer, "  //");
+         if (gimple_transaction_label (gs))
+           {
+             pp_string (buffer, " LABEL=");
+             dump_generic_node (buffer, gimple_transaction_label (gs),
+                                spc, flags, false);
+           }
+         if (subcode)
+           {
+             pp_string (buffer, " SUBCODE=[ ");
+             if (subcode & GTMA_HAVE_ABORT)
+               {
+                 pp_string (buffer, "GTMA_HAVE_ABORT ");
+                 subcode &= ~GTMA_HAVE_ABORT;
+               }
+             if (subcode & GTMA_HAVE_LOAD)
+               {
+                 pp_string (buffer, "GTMA_HAVE_LOAD ");
+                 subcode &= ~GTMA_HAVE_LOAD;
+               }
+             if (subcode & GTMA_HAVE_STORE)
+               {
+                 pp_string (buffer, "GTMA_HAVE_STORE ");
+                 subcode &= ~GTMA_HAVE_STORE;
+               }
+             if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
+               {
+                 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
+                 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
+               }
+             if (subcode & GTMA_DOES_GO_IRREVOCABLE)
+               {
+                 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
+                 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
+               }
+             if (subcode)
+               pp_printf (buffer, "0x%x ", subcode);
+             pp_string (buffer, "]");
+           }
+       }
+
+      if (!gimple_seq_empty_p (gimple_transaction_body (gs)))
+       {
+         newline_and_indent (buffer, spc + 2);
+         pp_character (buffer, '{');
+         pp_newline (buffer);
+         dump_gimple_seq (buffer, gimple_transaction_body (gs),
+                          spc + 4, flags);
+         newline_and_indent (buffer, spc + 2);
+         pp_character (buffer, '}');
+       }
+    }
+}
+
 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
    indent.  FLAGS specifies details to show in the dump (see TDF_* in
    tree-pass.h).  */
@@ -1337,9 +1590,16 @@ dump_gimple_phi (pretty_printer *buffer, gimple phi, int spc, int flags)
       && POINTER_TYPE_P (TREE_TYPE (lhs))
       && SSA_NAME_PTR_INFO (lhs))
     {
+      struct ptr_info_def *pi = SSA_NAME_PTR_INFO (lhs);
       pp_string (buffer, "PT = ");
-      pp_points_to_solution (buffer, &SSA_NAME_PTR_INFO (lhs)->pt);
+      pp_points_to_solution (buffer, &pi->pt);
       newline_and_indent (buffer, spc);
+      if (pi->align != 1)
+       {
+         pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u",
+                    pi->align, pi->misalign);
+         newline_and_indent (buffer, spc);
+       }
       pp_string (buffer, "# ");
     }
 
@@ -1509,6 +1769,8 @@ dump_gimple_omp_atomic_load (pretty_printer *buffer, gimple gs, int spc,
   else
     {
       pp_string (buffer, "#pragma omp atomic_load");
+      if (gimple_omp_atomic_need_value_p (gs))
+       pp_string (buffer, " [needed]");
       newline_and_indent (buffer, spc + 2);
       dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
                         spc, flags, false);
@@ -1536,7 +1798,10 @@ dump_gimple_omp_atomic_store (pretty_printer *buffer, gimple gs, int spc,
     }
   else
     {
-      pp_string (buffer, "#pragma omp atomic_store (");
+      pp_string (buffer, "#pragma omp atomic_store ");
+      if (gimple_omp_atomic_need_value_p (gs))
+       pp_string (buffer, "[needed] ");
+      pp_character (buffer, '(');
       dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
                         spc, flags, false);
       pp_character (buffer, ')');
@@ -1624,9 +1889,16 @@ dump_gimple_stmt (pretty_printer *buffer, gimple gs, int spc, int flags)
          && POINTER_TYPE_P (TREE_TYPE (lhs))
          && SSA_NAME_PTR_INFO (lhs))
        {
+         struct ptr_info_def *pi = SSA_NAME_PTR_INFO (lhs);
          pp_string (buffer, "# PT = ");
-         pp_points_to_solution (buffer, &SSA_NAME_PTR_INFO (lhs)->pt);
+         pp_points_to_solution (buffer, &pi->pt);
          newline_and_indent (buffer, spc);
+         if (pi->align != 1)
+           {
+             pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u",
+                        pi->align, pi->misalign);
+             newline_and_indent (buffer, spc);
+           }
        }
     }
 
@@ -1743,6 +2015,10 @@ dump_gimple_stmt (pretty_printer *buffer, gimple gs, int spc, int flags)
       dump_gimple_eh_must_not_throw (buffer, gs, spc, flags);
       break;
 
+    case GIMPLE_EH_ELSE:
+      dump_gimple_eh_else (buffer, gs, spc, flags);
+      break;
+
     case GIMPLE_RESX:
       dump_gimple_resx (buffer, gs, spc, flags);
       break;
@@ -1765,6 +2041,10 @@ dump_gimple_stmt (pretty_printer *buffer, gimple gs, int spc, int flags)
       pp_string (buffer, " predictor.");
       break;
 
+    case GIMPLE_TRANSACTION:
+      dump_gimple_transaction (buffer, gs, spc, flags);
+      break;
+
     default:
       GIMPLE_NIY;
     }
@@ -1852,7 +2132,8 @@ dump_bb_header (pretty_printer *buffer, basic_block bb, int indent, int flags)
        }
     }
   pp_write_text_to_stream (buffer);
-  check_bb_profile (bb, buffer->buffer->stream);
+  if (cfun)
+    check_bb_profile (bb, buffer->buffer->stream);
 }
 
 
@@ -1938,7 +2219,6 @@ dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
                     int flags)
 {
   edge e;
-  edge_iterator ei;
   gimple stmt;
 
   stmt = last_stmt (bb);
@@ -1966,9 +2246,7 @@ dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
 
   /* If there is a fallthru edge, we may need to add an artificial
      goto to the dump.  */
-  FOR_EACH_EDGE (e, ei, bb->succs)
-    if (e->flags & EDGE_FALLTHRU)
-      break;
+  e = find_fallthru_edge (bb->succs);
 
   if (e && e->dest != bb->next_bb)
     {