/* Pretty formatting of GENERIC trees in C syntax.
- Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
- 2011 Free Software Foundation, Inc.
+ Copyright (C) 2001-2013 Free Software Foundation, Inc.
Adapted from c-pretty-print.c by Diego Novillo <dnovillo@redhat.com>
This file is part of GCC.
#include "coretypes.h"
#include "tm.h"
#include "tree.h"
-#include "output.h"
#include "tree-pretty-print.h"
#include "hashtab.h"
#include "tree-flow.h"
#include "langhooks.h"
#include "tree-iterator.h"
#include "tree-chrec.h"
-#include "tree-pass.h"
+#include "dumpfile.h"
#include "value-prof.h"
#include "predict.h"
}
/* Print tree T, and its successors, on file FILE. FLAGS specifies details
- to show in the dump. See TDF_* in tree-pass.h. */
+ to show in the dump. See TDF_* in dumpfile.h. */
void
print_generic_stmt (FILE *file, tree t, int flags)
{
maybe_init_pretty_print (file);
dump_generic_node (&buffer, t, 0, flags, true);
- pp_flush (&buffer);
+ pp_newline_and_flush (&buffer);
}
/* Print tree T, and its successors, on file FILE. FLAGS specifies details
- to show in the dump. See TDF_* in tree-pass.h. The output is indented by
+ to show in the dump. See TDF_* in dumpfile.h. The output is indented by
INDENT spaces. */
void
for (i = 0; i < indent; i++)
pp_space (&buffer);
dump_generic_node (&buffer, t, indent, flags, true);
- pp_flush (&buffer);
+ pp_newline_and_flush (&buffer);
}
/* Print a single expression T on file FILE. FLAGS specifies details to show
- in the dump. See TDF_* in tree-pass.h. */
+ in the dump. See TDF_* in dumpfile.h. */
void
print_generic_expr (FILE *file, tree t, int flags)
{
maybe_init_pretty_print (file);
dump_generic_node (&buffer, t, 0, flags, false);
+ pp_flush (&buffer);
}
/* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
newline_and_indent (buffer, spc + 2);
}
- if (VEC_length (tree, BLOCK_NONLOCALIZED_VARS (block)) > 0)
+ if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0)
{
unsigned i;
- VEC(tree,gc) *nlv = BLOCK_NONLOCALIZED_VARS (block);
+ vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block);
pp_string (buffer, "NONLOCALIZED_VARS: ");
- FOR_EACH_VEC_ELT (tree, nlv, i, t)
+ FOR_EACH_VEC_ELT (*nlv, i, t)
{
dump_generic_node (buffer, t, 0, flags, false);
pp_string (buffer, " ");
/* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of
indent. FLAGS specifies details to show in the dump (see TDF_* in
- tree-pass.h). If IS_STMT is true, the object printed is considered
+ dumpfile.h). If IS_STMT is true, the object printed is considered
to be a statement and it is terminated by ';' if appropriate. */
int
tree op0, op1;
const char *str;
bool is_expr;
+ enum tree_code code;
if (node == NULL_TREE)
return spc;
if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
dump_location (buffer, EXPR_LOCATION (node));
- switch (TREE_CODE (node))
+ code = TREE_CODE (node);
+ switch (code)
{
case ERROR_MARK:
pp_string (buffer, "<<< error >>>");
}
else if (TREE_CODE (node) == INTEGER_TYPE)
{
- pp_string (buffer, (TYPE_UNSIGNED (node)
- ? "<unnamed-unsigned:"
- : "<unnamed-signed:"));
- pp_decimal_int (buffer, TYPE_PRECISION (node));
- pp_string (buffer, ">");
+ if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
+ pp_string (buffer, (TYPE_UNSIGNED (node)
+ ? "unsigned char"
+ : "signed char"));
+ else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
+ pp_string (buffer, (TYPE_UNSIGNED (node)
+ ? "unsigned short"
+ : "signed short"));
+ else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
+ pp_string (buffer, (TYPE_UNSIGNED (node)
+ ? "unsigned int"
+ : "signed int"));
+ else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
+ pp_string (buffer, (TYPE_UNSIGNED (node)
+ ? "unsigned long"
+ : "signed long"));
+ else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
+ pp_string (buffer, (TYPE_UNSIGNED (node)
+ ? "unsigned long long"
+ : "signed long long"));
+ else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
+ && exact_log2 (TYPE_PRECISION (node)) != -1)
+ {
+ pp_string (buffer, (TYPE_UNSIGNED (node) ? "uint" : "int"));
+ pp_decimal_int (buffer, TYPE_PRECISION (node));
+ pp_string (buffer, "_t");
+ }
+ else
+ {
+ pp_string (buffer, (TYPE_UNSIGNED (node)
+ ? "<unnamed-unsigned:"
+ : "<unnamed-signed:"));
+ pp_decimal_int (buffer, TYPE_PRECISION (node));
+ pp_string (buffer, ">");
+ }
}
else if (TREE_CODE (node) == COMPLEX_TYPE)
{
case VECTOR_CST:
{
- tree elt;
+ unsigned i;
pp_string (buffer, "{ ");
- for (elt = TREE_VECTOR_CST_ELTS (node); elt; elt = TREE_CHAIN (elt))
+ for (i = 0; i < VECTOR_CST_NELTS (node); ++i)
{
- dump_generic_node (buffer, TREE_VALUE (elt), spc, flags, false);
- if (TREE_CHAIN (elt))
+ if (i != 0)
pp_string (buffer, ", ");
+ dump_generic_node (buffer, VECTOR_CST_ELT (node, i),
+ spc, flags, false);
}
pp_string (buffer, " }");
}
}
else if (is_array_init
&& (TREE_CODE (field) != INTEGER_CST
- || !double_int_equal_p (tree_to_double_int (field),
- curidx)))
+ || tree_to_double_int (field) != curidx))
{
pp_character (buffer, '[');
if (TREE_CODE (field) == RANGE_EXPR)
}
}
if (is_array_init)
- curidx = double_int_add (curidx, double_int_one);
+ curidx += double_int_one;
if (val && TREE_CODE (val) == ADDR_EXPR)
if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
val = TREE_OPERAND (val, 0);
dump_decl_name (buffer, val, flags);
else
dump_generic_node (buffer, val, spc, flags, false);
- if (ix != VEC_length (constructor_elt, CONSTRUCTOR_ELTS (node)) - 1)
+ if (ix != vec_safe_length (CONSTRUCTOR_ELTS (node)) - 1)
{
pp_character (buffer, ',');
pp_space (buffer);
false);
pp_space (buffer);
pp_character (buffer, '=');
- if (TREE_CODE (node) == MODIFY_EXPR
- && MOVE_NONTEMPORAL (node))
- pp_string (buffer, "{nt}");
pp_space (buffer);
dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags,
false);
case WIDEN_SUM_EXPR:
case WIDEN_MULT_EXPR:
case MULT_EXPR:
+ case MULT_HIGHPART_EXPR:
case PLUS_EXPR:
case POINTER_PLUS_EXPR:
case MINUS_EXPR:
break;
case SSA_NAME:
- dump_generic_node (buffer, SSA_NAME_VAR (node), spc, flags, false);
+ if (SSA_NAME_IDENTIFIER (node))
+ dump_generic_node (buffer, SSA_NAME_IDENTIFIER (node),
+ spc, flags, false);
pp_string (buffer, "_");
pp_decimal_int (buffer, SSA_NAME_VERSION (node));
if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
break;
case VEC_WIDEN_MULT_HI_EXPR:
- pp_string (buffer, " VEC_WIDEN_MULT_HI_EXPR < ");
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
- pp_string (buffer, ", ");
- dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
- pp_string (buffer, " > ");
- break;
-
case VEC_WIDEN_MULT_LO_EXPR:
- pp_string (buffer, " VEC_WIDEN_MULT_LO_EXPR < ");
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
- pp_string (buffer, ", ");
- dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
- pp_string (buffer, " > ");
- break;
-
+ case VEC_WIDEN_MULT_EVEN_EXPR:
+ case VEC_WIDEN_MULT_ODD_EXPR:
case VEC_WIDEN_LSHIFT_HI_EXPR:
- pp_string (buffer, " VEC_WIDEN_LSHIFT_HI_EXPR < ");
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
- pp_string (buffer, ", ");
- dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
- pp_string (buffer, " > ");
- break;
-
case VEC_WIDEN_LSHIFT_LO_EXPR:
- pp_string (buffer, " VEC_WIDEN_LSHIFT_HI_EXPR < ");
+ pp_character (buffer, ' ');
+ for (str = tree_code_name [code]; *str; str++)
+ pp_character (buffer, TOUPPER (*str));
+ pp_string (buffer, " < ");
dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
pp_string (buffer, ", ");
dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
if (is_stmt && is_expr)
pp_semicolon (buffer);
- /* If we're building a diagnostic, the formatted text will be written
- into BUFFER's stream by the caller; otherwise, write it now. */
- if (!(flags & TDF_DIAGNOSTIC))
- pp_write_text_to_stream (buffer);
-
return spc;
}
case WIDEN_MULT_PLUS_EXPR:
case WIDEN_MULT_MINUS_EXPR:
case MULT_EXPR:
+ case MULT_HIGHPART_EXPR:
case TRUNC_DIV_EXPR:
case CEIL_DIV_EXPR:
case FLOOR_DIV_EXPR:
case WIDEN_MULT_EXPR:
return "w*";
+ case MULT_HIGHPART_EXPR:
+ return "h*";
+
case NEGATE_EXPR:
case MINUS_EXPR:
return "-";