GCC Middle and Back End API Reference
tree-pretty-print.c File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "tree.h"
#include "tree-pretty-print.h"
#include "hashtab.h"
#include "gimple.h"
#include "cgraph.h"
#include "langhooks.h"
#include "tree-iterator.h"
#include "tree-chrec.h"
#include "dumpfile.h"
#include "value-prof.h"
#include "predict.h"
#include <new>
Include dependency graph for tree-pretty-print.c:

Macros

#define INDENT(SPACE)
#define NIY   do_niy (buffer, node)

Functions

static const char * op_symbol (const_tree)
static void pretty_print_string (pretty_printer *, const char *)
static void newline_and_indent (pretty_printer *, int)
static void maybe_init_pretty_print (FILE *)
static void print_struct_decl (pretty_printer *, const_tree, int, int)
static void do_niy (pretty_printer *, const_tree)
static void do_niy ()
DEBUG_FUNCTION void debug_generic_expr ()
DEBUG_FUNCTION void debug_generic_stmt ()
DEBUG_FUNCTION void debug_tree_chain ()
void print_generic_decl ()
void print_generic_stmt ()
void print_generic_stmt_indented ()
void print_generic_expr ()
static void dump_decl_name ()
static void dump_function_name ()
static void dump_function_declaration (pretty_printer *buffer, tree node, int spc, int flags)
static void dump_array_domain ()
static void dump_omp_clause ()
void dump_omp_clauses ()
static void dump_location ()
static void dump_block_node ()
int dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags, bool is_stmt)
void print_declaration ()
static void print_struct_decl ()
int op_code_prio ()
int op_prio ()
const char * op_symbol_code ()
static const char * op_symbol ()
void print_call_name ()
static void pretty_print_string ()
static void maybe_init_pretty_print ()
static void newline_and_indent ()
void percent_K_format ()
void pp_tree_identifier ()
void dump_function_header ()
void pp_double_int ()

Variables

static pretty_printer buffer
static int initialized = 0

Macro Definition Documentation

#define INDENT (   SPACE)
Value:
do { \
int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0)
#define NIY   do_niy (buffer, node)

Function Documentation

DEBUG_FUNCTION void debug_generic_expr ( )

Debugging function to print out a generic expression.

Referenced by build_ssa_operands(), and valid_fixed_convert_types_p().

DEBUG_FUNCTION void debug_generic_stmt ( )

Debugging function to print out a generic statement.

References pointer_set_create().

Referenced by verify_gimple_assign_ternary(), and verify_types_in_gimple_min_lval().

DEBUG_FUNCTION void debug_tree_chain ( )

Debugging function to print out a chain of trees .

static void do_niy ( pretty_printer ,
const_tree   
)
static
static void do_niy ( )
static

Try to print something for an unknown tree code.

static void dump_array_domain ( )
static

Dump the domain associated with an array.

static void dump_block_node ( )
static

Dump lexical block BLOCK. BUFFER, SPC and FLAGS are as in dump_generic_node.

References BLOCK_SUPERCONTEXT, dump_generic_node(), newline_and_indent(), and pp_string().

static void dump_decl_name ( )
static

Dump the name of a _DECL node and its DECL_UID if TDF_UID is set in FLAGS.

static void dump_function_declaration ( pretty_printer buffer,
tree  node,
int  spc,
int  flags 
)
static

Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and FLAGS are as in dump_generic_node.

 Print the argument types.   
 Drop the trailing void_type_node if we had any previous argument.   
 Properly dump vararg function types.   
 Avoid printing any arg for unprototyped functions.   

References pp_comma, and pp_space.

void dump_function_header ( )

A helper function that is used to dump function information before the function dump.

static void dump_function_name ( )
static

Like the above, but used for pretty printing function calls.

References error_mark_node, pp_left_paren, pp_space, TYPE_ARG_TYPES, and void_list_node.

int dump_generic_node ( pretty_printer buffer,
tree  node,
int  spc,
int  flags,
bool  is_stmt 
)

Dump the node NODE on the pretty_printer BUFFER, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in dumpfile.h). If IS_STMT is true, the object printed is considered to be a statement and it is terminated by ';' if appropriate.

           Dump the types of INTEGER_CSTs explicitly, for we can't
           infer them and MEM_ATTR caching will share MEM_REFs
           with differently-typed op0s.   
           Released SSA_NAMES have no TREE_TYPE.   
           Same pointer types, but ignoring POINTER_TYPE vs.
           REFERENCE_TYPE.   
           Same value types ignoring qualifiers.   
       Print the innermost component type.   
       Print the dimensions.   
       Print the name of the structure.   
         FIXME: If we eliminate the 'else' above and attempt
         to show the fields for named types, we may get stuck
         following a cycle of pointers to structs.  The alleged
         self-reference check in print_struct_decl will not detect
         cycles involving more than one pointer or struct type.   
         In the case of a pointer, one may want to divide by the
         size of the pointed-to type.  Unfortunately, this not
         straightforward.  The C front-end maps expressions

         (int *) 5
         int *p; (p + 5)

         in such a way that the two INTEGER_CST nodes for "5" have
         different values but identical types.  In the latter
         case, the 5 is multiplied by sizeof (int) in c-common.c
         (pointer_int_sum) to convert it to a byte address, and
         yet the type of the node is left unchanged.  Argh.  What
         is consistent though is that the number value corresponds
         to bytes (UNITS) offset.

         NB: Neither of the following divisors can be trivially
         used to recover the original literal:

         TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
         TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node)))   
     Code copied from print_node.   
         Don't print the declaration of built-in types.   
             The type is a c++ class: all structures have at least
             4 methods.   
                 Dump the types of INTEGER_CSTs explicitly, for we
                 can't infer them and MEM_ATTR caching will share
                 MEM_REFs with differently-typed op0s.   
                 Released SSA_NAMES have no TREE_TYPE.   
                 Same pointer types, but ignoring POINTER_TYPE vs.
                 REFERENCE_TYPE.   
                 Same value types ignoring qualifiers.   
         The lowered cond_exprs should always be printed in full.   
             Output COND_EXPR_THEN.   
             Output COND_EXPR_ELSE.   
     Print parameters.   
     Binary arithmetic and logic expressions.   
       When the operands are expressions with less priority,
       keep semantics of the tree representation.   
       When the operands are expressions with less priority,
       keep semantics of the tree representation.   
     Unary arithmetic and logic expressions.   
     If this is for break or continue, don't bother printing it.   

Referenced by dump_block_node(), dump_gimple_fmt(), dump_gimple_omp_block(), dump_gimple_omp_parallel(), dump_gimple_omp_return(), dump_gimple_omp_teams(), dump_ssaname_info(), print_generic_decl(), and print_generic_stmt().

static void dump_location ( )
static

Dump location LOC to BUFFER.

static void dump_omp_clause ( )
static

Dump OpenMP clause CLAUSE. BUFFER, CLAUSE, SPC and FLAGS are as in dump_generic_node.

Should never happen.

void dump_omp_clauses ( )

Dump the list of OpenMP clauses. BUFFER, SPC and FLAGS are as in dump_generic_node.

References expand_location(), pp_decimal_int, pp_left_bracket, and pp_string().

Referenced by dump_gimple_debug(), dump_gimple_omp_parallel(), and dump_gimple_omp_teams().

static void maybe_init_pretty_print ( FILE *  )
static
static void newline_and_indent ( pretty_printer ,
int   
)
static
static void newline_and_indent ( )
static
int op_code_prio ( )

Return the priority of the operator CODE.

From lowest to highest precedence with either left-to-right (L-R) or right-to-left (R-L) associativity]:

1 [L-R] , 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>= 3 [R-L] ?: 4 [L-R] || 5 [L-R] && 6 [L-R] | 7 [L-R] ^ 8 [L-R] & 9 [L-R] == != 10 [L-R] < <= > >= 11 [L-R] << >> 12 [L-R] + - 13 [L-R] * / % 14 [R-L] ! ~ ++ – + - * & (type) sizeof 15 [L-R] fn() [] -> .

unary +, - and * have higher precedence than the corresponding binary operators.

Special expressions.

     Return an arbitrarily high precedence to avoid surrounding single
     VAR_DECLs in ()s.   
int op_prio ( )

Return the priority of the operator OP.

static const char* op_symbol ( const_tree  )
static

Pretty formatting of GENERIC trees in C syntax. Copyright (C) 2001-2013 Free Software Foundation, Inc. Adapted from c-pretty-print.c by Diego Novillo dnovi.nosp@m.llo@.nosp@m.redha.nosp@m.t.co.nosp@m.m

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/. Local functions, macros and variables.

static const char* op_symbol ( )
static

Return the symbol associated with operator OP.

References pp_string().

const char* op_symbol_code ( )

Return the symbol associated with operator CODE.

void percent_K_format ( )

Handle a K format for TEXT. Separate from default_tree_printer so it can also be used in front ends. K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.

void pp_double_int ( )

Dump double_int D to pretty_printer PP. UNS is true if D is unsigned and false otherwise.

Would "%x%0*x" or "%x%*0x" get zero-padding on all systems?

void pp_tree_identifier ( )

Print the identifier ID to PRETTY-PRINTER.

Referenced by asan_clear_shadow(), and print_generic_expr().

static void pretty_print_string ( pretty_printer ,
const char *   
)
static
static void pretty_print_string ( )
static

Parses the string STR and replaces new-lines by '
', tabs by '', ...

No need to handle \0; the loop terminates on \0.

void print_call_name ( )

Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or the gimple_call_fn of a GIMPLE_CALL.

Fallthru.

void print_declaration ( )

Print the declaration of a variable.

 Print the type and name.   
     Print array's type.   
     Print variable's name.   
     Print the dimensions.   
     Print type declaration.   
     Print variable's name.   
 The initial value of a function serves to determine whether the function
 is declared or defined.  So the following does not apply to function
 nodes.   
     Print the initial value.   

Referenced by dump_gimple_goto().

void print_generic_decl ( )

Prints declaration DECL to the FILE with details specified by FLAGS.

References dump_generic_node(), maybe_init_pretty_print(), and pp_newline_and_flush().

void print_generic_expr ( )

Print a single expression T on file FILE. FLAGS specifies details to show in the dump. See TDF_* in dumpfile.h.

References DECL_ASSEMBLER_NAME, DECL_ASSEMBLER_NAME_SET_P, DECL_NAME, NULL_TREE, pp_tree_identifier(), TDF_ASMNAME, and TDF_UID.

Referenced by add_access_to_work_queue(), aff_combination_constant_multiple_p(), dom_opt_dom_walker::after_dom_children(), analyze_caller_dereference_legality(), analyze_evolution_in_loop(), break_up_subtract_bb(), build_and_add_sum(), build_new_reduction(), calculate_live_on_exit(), cgraph_materialize_clone(), check_array_ref(), compute_builtin_object_size(), compute_scalar_evolution_in_loop(), cond_expr_object_size(), count_formal_params(), create_canonical_iv(), debug_tree(), DFS(), dump_asserts_for(), dump_generic_expr(), dump_gimple_stmt_loc(), dump_live_info(), dump_var_map(), eliminate_avail(), eliminate_redundant_computations(), eliminate_useless_phis(), find_interesting_uses_stmt(), find_replaceable_exprs(), gcd_of_steps_may_divide_p(), get_rank(), get_unary_op(), ifcombine_ifandif(), index_in_adjustments_multiple_times_p(), insert_updated_phi_nodes_for(), instantiate_scev_1(), ipa_get_parm_lattices(), ipa_initialize_node_params(), lookup_avail_expr(), n_iv_cands(), n_iv_uses(), non_rewritable_mem_ref_base(), partition_stack_vars(), prepare_block_for_update(), print_expr_hash_elt(), read_replacements_section(), simplify_binary_expression(), test_for_singularity(), tm_log_emit_stmt(), value_replacement(), verify_expr_location_1(), and visit_copy().

void print_generic_stmt ( )

Print tree T, and its successors, on file FILE. FLAGS specifies details to show in the dump. See TDF_* in dumpfile.h.

References dump_generic_node(), indent, maybe_init_pretty_print(), and pp_space.

Referenced by get_unary_op().

void print_generic_stmt_indented ( )

Print tree T, and its successors, on file FILE. FLAGS specifies details to show in the dump. See TDF_* in dumpfile.h. The output is indented by INDENT spaces.

static void print_struct_decl ( pretty_printer ,
const_tree  ,
int  ,
int   
)
static
static void print_struct_decl ( )
static

Prints a structure: name, fields, and methods. FIXME: Still incomplete.

 Print the name of the structure.   
 Print the contents of the structure.   
 Print the fields of the structure.   
       Avoid to print recursively the structure.   
       FIXME : Not implemented correctly...,
       what about the case when we have a cycle in the contain graph? ...
       Maybe this could be solved by looking at the scope in which the
       structure was declared.   

Variable Documentation

int initialized = 0
static