gcc/gcc/gimple-pretty-print.c
David Malcolm 538dd0b78f Merger of git branch "gimple-classes-v2-option-3"
gcc/ChangeLog:
	Merger of git branch "gimple-classes-v2-option-3".

	* ChangeLog.gimple-classes: New.

	* coretypes.h (struct gcond): Add forward decl.
	(struct gdebug): Likewise.
	(struct ggoto): Likewise.
	(struct glabel): Likewise.
	(struct gswitch): Likewise.
	(struct gassign): Likewise.
	(struct gasm): Likewise.
	(struct gcall): Likewise.
	(struct gtransaction): Likewise.
	(struct greturn): Likewise.
	(struct gbind): Likewise.
	(struct gcatch): Likewise.
	(struct geh_filter): Likewise.
	(struct geh_mnt): Likewise.
	(struct geh_else): Likewise.
	(struct gresx): Likewise.
	(struct geh_dispatch): Likewise.
	(struct gphi): Likewise.
	(struct gtry): Likewise.
	(struct gomp_atomic_load): Likewise.
	(struct gomp_atomic_store): Likewise.
	(struct gomp_continue): Likewise.
	(struct gomp_critical): Likewise.
	(struct gomp_for): Likewise.
	(struct gomp_parallel): Likewise.
	(struct gomp_task): Likewise.
	(struct gomp_sections): Likewise.
	(struct gomp_single): Likewise.
	(struct gomp_target): Likewise.
	(struct gomp_teams): Likewise.

	* doc/gimple.texi (Class hierarchy of GIMPLE statements): Update
	for renaming of gimple subclasses.

	* gdbhooks.py: Update.

	* gimple-iterator.c (gsi_for_phi): New.
	(gsi_start_phis): Strengthen return type from gimple_stmt_iterator
	to gphi_iterator.
	* gimple-iterator.h (struct gphi_iterator): New subclass of
	gimple_stmt_iterator.
	(gsi_for_phi): New prototype.
	(gsi_start_phis): Strengthen return type from gimple_stmt_iterator
	to gphi_iterator.
	(gsi_next_nonvirtual_phi): Strengthen param from
	gimple_stmt_iterator * to gphi_iterator *, and local "phi" from
	gimple to gphi *.

	* gsstruct.def: Update for renamings of classes.

	* gimple.c (gimple_build_return): Strengthen return type from
	gimple to greturn *.
	(gimple_call_reset_alias_info): Strengthen param to gcall *.
	(gimple_build_call_1): Strengthen return type from gimple to
	gcall *.
	(gimple_build_call_vec): Likewise.
	(gimple_build_call): Likewise.
	(gimple_build_call_valist): Likewise.
	(gimple_build_call_internal_1): Likewise.
	(gimple_build_call_internal): Likewise.
	(gimple_build_call_internal_vec): Likewise.
	(gimple_build_call_from_tree): Likewise.
	(gimple_build_assign_stat): Strengthen return type from gimple to
	gassign *.
	(gimple_build_assign_with_ops): Likewise.
	(gimple_build_assign_with_ops): Likewise.
	(gimple_build_cond): Strengthen return type from gimple to
	gcond *.
	(gimple_build_cond_from_tree): Likewise.
	(gimple_cond_set_condition_from_tree): Require a gcond *.
	(gimple_build_label): Strengthen return type from gimple to
	glabel *.
	(gimple_build_goto): Strengthen return type from gimple to
	ggoto *.
	(gimple_build_bind): Strengthen return type from gimple to
	gbind *.
	(gimple_build_asm_1): Strengthen return type from gimple to
	gasm *.
	(gimple_build_asm_vec): Likewise.
	(gimple_build_catch): Strengthen return type from gimple to
	gcatch *.
	(gimple_build_eh_filter): Strengthen return type from gimple to
	geh_filter *.
	(gimple_build_eh_must_not_throw): Strengthen return type from
	gimple to geh_mnt *.
	(gimple_build_eh_else): Strengthen return type from gimple to
	geh_else *.
	(gimple_build_try): Update for renaming of gimple_statement_try to
	gtry.
	(gimple_build_resx): Strengthen return type from gimple to
	gresx *.
	(gimple_build_switch_nlabels): Strengthen return type from gimple
	to gswitch *.
	(gimple_build_switch): Likewise.
	(gimple_build_eh_dispatch): Strengthen return type from gimple to
	geh_dispatch *.
	(gimple_build_debug_bind_stat): Strengthen return type from gimple
	to gdebug *.
	(gimple_build_debug_source_bind_stat): Strengthen return type from
	gimple to gdebug *.
	(gimple_build_omp_critical): Strengthen return type from gimple to
	gomp_critical *.
	(gimple_build_omp_for): Strengthen return type from gimple to
	gomp_for *.
	(gimple_build_omp_parallel): Strengthen return type from gimple to
	gomp_parallel *.
	(gimple_build_omp_task): Strengthen return type from gimple to
	gomp_task *.
	(gimple_build_omp_continue): Strengthen return type from gimple to
	gomp_continue *.
	(gimple_build_omp_sections): Strengthen return type from gimple to
	gomp_sections *.
	(gimple_build_omp_single): Strengthen return type from gimple to
	gomp_single *.
	(gimple_build_omp_target): Strengthen return type from gimple to
	gomp_target *.
	(gimple_build_omp_teams): Strengthen return type from gimple to
	gomp_teams *.
	(gimple_build_omp_atomic_load): Strengthen return type from gimple
	to gomp_atomic_load *.
	(gimple_build_omp_atomic_store): Strengthen return type from gimple
	to gomp_atomic_store *.
	(gimple_build_transaction): Strengthen return type from gimple
	to gtransaction *.
	(empty_stmt_p): Replace check for GIMPLE_BIND with a dyn_cast.
	(gimple_call_fnspec): Require a const gcall *.
	(gimple_call_arg_flags): Likewise.
	(gimple_call_return_flags): Likewise.
	(gimple_set_bb): Add a checked cast.
	(gimple_copy): Within the cases, add locals of the appropriate
	subclass and use in place of "stmt" and "copy" for typesafety.
	(gimple_has_side_effects): Add a checked cast.
	(gimple_could_trap_p_1): Likewise.
	(gimple_call_copy_skip_args): Require a gcall *, and return one.
	(gimple_asm_clobbers_memory_p): Require a const gasm *.
	(infer_nonnull_range): Replace a check for GIMPLE_RETURN with a
	dyn_cast, introducing local "return_stmt" and using ti in place
	of "stmt".

	* gimple.h (gimple_vec): Eliminate this typedef.
	(struct gimple_statement_call): Rename to...
	(struct gcall): ...this.
	(struct gimple_statement_bind): Rename to...
	(struct gbind): ...this.
	(struct gimple_statement_catch): Rename to...
	(struct gcatch): ...this.
	(struct gimple_statement_eh_filter): Rename to...
	(struct geh_filter): ...this.
	(struct gimple_statement_eh_else): Rename to...
	(struct geh_else): ...this.
	(struct gimple_statement_eh_mnt): Rename to...
	(struct geh_mnt): ...this.
	(struct gimple_statement_phi): Rename to...
	(struct gphi): ...this.
	(struct gimple_statement_resx): Rename to...
	(struct gresx): ...this.
	(struct gimple_statement_eh_dispatch): Rename to...
	(struct geh_dispatch): ...this.
	(struct gimple_statement_try): Rename to...
	(struct gtry): ...this.
	(struct gimple_statement_asm): Rename to...
	(struct gasm): ...this.
	(struct gimple_statement_omp_critical): Rename to...
	(struct gomp_critical): ...this.
	(struct gimple_statement_omp_for): Rename to...
	(struct gomp_for): ...this.
	(struct gimple_statement_omp_parallel): Rename to...
	(struct gomp_parallel): ...this.
	(struct gimple_statement_omp_target): Rename to...
	(struct gomp_target): ...this.
	(struct gimple_statement_omp_task): Rename to...
	(struct gomp_task): ...this.
	(struct gimple_statement_omp_sections): Rename to...
	(struct gomp_sections): ...this.
	(struct gimple_statement_omp_continue): Rename to...
	(struct gomp_continue): ...this.
	(struct gimple_statement_omp_single): Rename to...
	(struct gomp_single): ...this.
	(struct gimple_statement_omp_teams): Rename to...
	(struct gomp_teams): ...this.
	(struct gimple_statement_omp_atomic_load): Rename to...
	(struct gomp_atomic_load): ...this.
	(struct gimple_statement_omp_atomic_store :): Rename to...
	(struct gomp_atomic_store :): ...this.
	(struct gimple_statement_transaction): Rename to...
	(struct gtransaction): ...this.
	(struct gcond): New subclass.
	(struct gdebug): New subclass.
	(struct ggoto): New subclass.
	(struct glabel): New subclass.
	(struct gswitch): New subclass.
	(struct gassign): New subclass.
	(struct greturn): New subclass.
	(is_a_helper <gimple_statement_asm *>::test): Rename to...
	(is_a_helper <gasm *>::test): ...this.
	(is_a_helper <gimple_statement_bind *>::test): Rename to...
	(is_a_helper <gbind *>::test): ...this.
	(is_a_helper <gassign *>::test): New.
	(is_a_helper <gimple_statement_call *>::test): Rename to...
	(is_a_helper <gcall *>::test): ...this.
	(is_a_helper <gimple_statement_catch *>::test): Rename to...
	(is_a_helper <gcatch *>::test): ...this.
	(is_a_helper <gimple_statement_resx *>::test): Rename to...
	(is_a_helper <gresx *>::test): ...this.
	(is_a_helper <gcond *>::test): New.
	(is_a_helper <gdebug *>::test): New.
	(is_a_helper <ggoto *>::test): New.
	(is_a_helper <glabel *>::test): New.
	(is_a_helper <gimple_statement_eh_dispatch *>::test): Rename to...
	(is_a_helper <geh_dispatch *>::test): ...this.
	(is_a_helper <gimple_statement_eh_else *>::test): Rename to...
	(is_a_helper <geh_else *>::test): ...this.
	(is_a_helper <gimple_statement_eh_filter *>::test): Rename to...
	(is_a_helper <geh_filter *>::test): ...this.
	(is_a_helper <gimple_statement_eh_mnt *>::test): Rename to...
	(is_a_helper <geh_mnt *>::test): ...this.
	(is_a_helper <gimple_statement_omp_atomic_load *>::test): Rename to...
	(is_a_helper <gomp_atomic_load *>::test): ...this.
	(is_a_helper <gimple_statement_omp_atomic_store *>::test): Rename to...
	(is_a_helper <gomp_atomic_store *>::test): ...this.
	(is_a_helper <gimple_statement_omp_continue *>::test): Rename to...
	(is_a_helper <gomp_continue *>::test): ...this.
	(is_a_helper <gimple_statement_omp_critical *>::test): Rename to...
	(is_a_helper <gomp_critical *>::test): ...this.
	(is_a_helper <gimple_statement_omp_for *>::test): Rename to...
	(is_a_helper <gomp_for *>::test): ...this.
	(is_a_helper <gimple_statement_omp_parallel *>::test): Rename to...
	(is_a_helper <gomp_parallel *>::test): ...this.
	(is_a_helper <gimple_statement_omp_target *>::test): Rename to...
	(is_a_helper <gomp_target *>::test): ...this.
	(is_a_helper <gimple_statement_omp_sections *>::test): Rename to...
	(is_a_helper <gomp_sections *>::test): ...this.
	(is_a_helper <gimple_statement_omp_single *>::test): Rename to...
	(is_a_helper <gomp_single *>::test): ...this.
	(is_a_helper <gimple_statement_omp_teams *>::test): Rename to...
	(is_a_helper <gomp_teams *>::test): ...this.
	(is_a_helper <gimple_statement_omp_task *>::test): Rename to...
	(is_a_helper <gomp_task *>::test): ...this.
	(is_a_helper <gimple_statement_phi *>::test): Rename to...
	(is_a_helper <gphi *>::test): ...this.
	(is_a_helper <gimple_statement_transaction *>::test): Rename to...
	(is_a_helper <gtransaction *>::test): ...this.
	(is_a_helper <greturn *>::test): New.
	(is_a_helper <gswitch *>::test): New.
	(is_a_helper <gimple_statement_try *>::test): Rename to...
	(is_a_helper <gtry *>::test): ...this.
	(is_a_helper <const gimple_statement_asm *>::test): Rename to...
	(is_a_helper <const gasm *>::test): ...this.
	(is_a_helper <const gimple_statement_bind *>::test): Rename to...
	(is_a_helper <const gbind *>::test): ...this.
	(is_a_helper <const gimple_statement_call *>::test): Rename to...
	(is_a_helper <const gcall *>::test): ...this.
	(is_a_helper <const gimple_statement_catch *>::test): Rename to...
	(is_a_helper <const gcatch *>::test): ...this.
	(is_a_helper <const gimple_statement_resx *>::test): Rename to...
	(is_a_helper <const gresx *>::test): ...this.
	(is_a_helper <const gimple_statement_eh_dispatch *>::test): Rename to...
	(is_a_helper <const geh_dispatch *>::test): ...this.
	(is_a_helper <const gimple_statement_eh_filter *>::test): Rename to...
	(is_a_helper <const geh_filter *>::test): ...this.
	(is_a_helper <const gimple_statement_omp_atomic_load *>::test):
	Rename to...
	(is_a_helper <const gomp_atomic_load *>::test): ...this.
	(is_a_helper <const gimple_statement_omp_atomic_store *>::test):
	Rename to...
	(is_a_helper <const gomp_atomic_store *>::test): ...this.
	(is_a_helper <const gimple_statement_omp_continue *>::test):
	Rename to...
	(is_a_helper <const gomp_continue *>::test): ...this.
	(is_a_helper <const gimple_statement_omp_critical *>::test):
	Rename to...
	(is_a_helper <const gomp_critical *>::test): ...this.
	(is_a_helper <const gimple_statement_omp_for *>::test): Rename to...
	(is_a_helper <const gomp_for *>::test): ...this.
	(is_a_helper <const gimple_statement_omp_parallel *>::test):
	Rename to...
	(is_a_helper <const gomp_parallel *>::test): ...this.
	(is_a_helper <const gimple_statement_omp_target *>::test): Rename to...
	(is_a_helper <const gomp_target *>::test): ...this.
	(is_a_helper <const gimple_statement_omp_sections *>::test):
	Rename to...
	(is_a_helper <const gomp_sections *>::test): ...this.
	(is_a_helper <const gimple_statement_omp_single *>::test): Rename to...
	(is_a_helper <const gomp_single *>::test): ...this.
	(is_a_helper <const gimple_statement_omp_teams *>::test): Rename to...
	(is_a_helper <const gomp_teams *>::test): ...this.
	(is_a_helper <const gimple_statement_omp_task *>::test): Rename to...
	(is_a_helper <const gomp_task *>::test): ...this.
	(is_a_helper <const gimple_statement_phi *>::test): Rename to...
	(is_a_helper <const gphi *>::test): ...this.
	(is_a_helper <const gimple_statement_transaction *>::test): Rename to...
	(is_a_helper <const gtransaction *>::test): ...this.
	(gimple_build_return): Strengthen return type to greturn *.
	(gimple_call_reset_alias_info): Require a gcall *.
	(gimple_build_call_vec): Return a gcall *.
	(gimple_build_call): Likewise.
	(gimple_build_call_valist): Likewise.
	(gimple_build_call_internal): Likewise.
	(gimple_build_call_internal_vec): Likewise.
	(gimple_build_call_from_tree): Likewise.
	(gimple_build_assign_stat): Return a gassign *.
	(gimple_build_assign_with_ops): Likewise.
	(gimple_build_cond): Return a gcond *.
	(gimple_build_cond_from_tree): Likewise.
	(gimple_cond_set_condition_from_tree): Require a gcond *.
	(gimple_build_label): Return a glabel *.
	(gimple_build_goto): Return a ggoto *.
	(gimple_build_bind): Return a gbind *.
	(gimple_build_asm_vec): Return a gasm *.
	(gimple_build_catch): Return a gcatch *.
	(gimple_build_eh_filter): Return a geh_filter *.
	(gimple_build_eh_must_not_throw): Return a geh_mnt *.
	(gimple_build_eh_else): Return a geh_else *.
	(gimple_build_try): Return a gtry *.
	(gimple_build_resx): Return a gresx *.
	(gimple_build_switch_nlabels): Return a gswitch *.
	(gimple_build_switch): Return a gswitch *.
	(gimple_build_eh_dispatch): Return a geh_dispatch *.
	(gimple_build_debug_bind_stat): Return a gdebug *.
	(gimple_build_debug_source_bind_stat): Return a gdebug *.
	(gimple_build_omp_critical): Return a gomp_critical *.
	(gimple_build_omp_for): Return a gomp_for *.
	(gimple_build_omp_parallel): Return a gomp_parallel *.
	(gimple_build_omp_task): Return a gomp_task *.
	(gimple_build_omp_continue): Return a gomp_continue *.
	(gimple_build_omp_sections): Return a gomp_sections *.
	(gimple_build_omp_single): Return a gomp_single *.
	(gimple_build_omp_target): Return a gomp_target *.
	(gimple_build_omp_teams): Return a gomp_teams *.
	(gimple_build_omp_atomic_load): Return a gomp_atomic_load *.
	(gimple_build_omp_atomic_store): Return a gomp_atomic_store *.
	(gimple_build_transaction): Return a gtransaction *.
	(gimple_call_arg_flags): Require a const gcall *.
	(gimple_call_return_flags): Likewise.
	(gimple_call_copy_skip_args): Require and return a gcall *.
	(gimple_asm_clobbers_memory_p): Require a const gasm *.
	(gimple_seq_first_stmt_as_a_bind): New.
	(gimple_assign_nontemporal_move_p): Require a const gassign *
	rather than a const_gimple.
	(gimple_call_internal_fn): Update for renaming to gcall.
	(gimple_call_fntype): Likewise.
	(gimple_call_set_fntype): Require a gcall * rather than a gimple.
	(gimple_call_set_fn): Likewise.
	(gimple_call_set_internal_fn): Likewise.
	(gimple_call_set_chain): Likewise.
	(gimple_call_set_tail): Likewise.
	(gimple_call_tail_p): Likewise.
	(gimple_call_set_return_slot_opt): Likewise.
	(gimple_call_return_slot_opt_p): Likewise.
	(gimple_call_set_from_thunk): Likewise.
	(gimple_call_from_thunk_p): Likewise.
	(gimple_call_set_va_arg_pack): Likewise.
	(gimple_call_va_arg_pack_p): Likewise.
	(gimple_call_set_nothrow): Likewise.
	(gimple_call_nothrow_p): Likewise.
	(gimple_call_set_alloca_for_var): Likewise.
	(gimple_call_alloca_for_var_p): Likewise.
	(gimple_call_use_set): Likewise.
	(gimple_call_clobber_set): Likewise.
	(gimple_call_return_type): Require a const gcall * rather than a
	const_gimple.
	(gimple_call_chain_ptr): Likewise.
	(gimple_call_copy_flags): Require a pair of gcall *.
	(gimple_cond_set_code): Require a gcond * rather than a gimple
	(gimple_cond_set_lhs): Likewise.
	(gimple_cond_set_rhs): Likewise.
	(gimple_cond_set_true_label): Likewise.
	(gimple_cond_set_false_label): Likewise.
	(gimple_cond_make_false): Likewise.
	(gimple_cond_make_true): Likewise.
	(gimple_cond_lhs_ptr): Require a const gcond * rather than a
	const_gimple.
	(gimple_cond_rhs_ptr): Likewise.
	(gimple_cond_true_label): Likewise.
	(gimple_cond_false_label): Likewise.
	(gimple_cond_true_p): Likewise.
	(gimple_cond_false_p): Likewise.
	(gimple_cond_set_condition): Likewise.
	(gimple_label_label): Require a const glabel *.
	(gimple_label_set_label): Require a glabel *.
	(gimple_goto_set_dest): Require a ggoto *.
	(gimple_bind_vars): Require a const gbind *.
	(gimple_bind_block): Likewise.
	(gimple_bind_set_vars): Require a gbind *.
	(gimple_bind_append_vars): Likewise.
	(gimple_bind_body_ptr): Likewise.
	(gimple_bind_body): Likewise.
	(gimple_bind_set_body): Likewise.
	(gimple_bind_add_stmt): Likewise.
	(gimple_bind_add_seq): Likewise.
	(gimple_bind_set_block): Likewise.
	(gimple_asm_ninputs): Require a const gasm *.
	(gimple_asm_noutputs): Likewise.
	(gimple_asm_nclobbers): Likewise.
	(gimple_asm_nlabels): Likewise.
	(gimple_asm_input_op): Likewise.
	(gimple_asm_input_op_ptr): Likewise.
	(gimple_asm_output_op): Likewise.
	(gimple_asm_output_op_ptr): Likewise.
	(gimple_asm_clobber_op): Likewise.
	(gimple_asm_label_op): Likewise.
	(gimple_asm_string): Likewise.
	(gimple_asm_volatile_p): Likewise.
	(gimple_asm_input_p): Likewise.
	(gimple_asm_set_input_op): Require a gasm *.
	(gimple_asm_set_output_op): Likewise.
	(gimple_asm_set_clobber_op): Likewise.
	(gimple_asm_set_label_op): Likewise.
	(gimple_asm_set_volatile): Likewise.
	(gimple_asm_set_input): Likewise.
	(gimple_catch_types): Require a const gcatch *.
	(gimple_catch_types_ptr): Require a gcatch *.
	(gimple_catch_handler_ptr): Likewise.
	(gimple_catch_handler): Likewise.
	(gimple_catch_set_types): Likewise.
	(gimple_catch_set_handler): Likewise.
	(gimple_eh_filter_types): Update for renaming of subclass to
	geh_filter.
	(gimple_eh_filter_types_ptr): Likewise.
	(gimple_eh_filter_failure_ptr): Likewise.
	(gimple_eh_filter_set_types): Require a geh_filter *.
	(gimple_eh_filter_set_failure): Likewise.
	(gimple_eh_must_not_throw_fndecl): Require a geh_mnt *.
	(gimple_eh_must_not_throw_set_fndecl): Likewise.
	(gimple_eh_else_n_body_ptr): Require a geh_else *.
	(gimple_eh_else_n_body): Likewise.
	(gimple_eh_else_e_body_ptr): Likewise.
	(gimple_eh_else_e_body): Likewise.
	(gimple_eh_else_set_n_body): Likewise.
	(gimple_eh_else_set_e_body): Likewise.
	(gimple_try_set_kind): Require a gtry *.
	(gimple_try_set_catch_is_cleanup): Likewise.
	(gimple_try_set_eval): Likewise.
	(gimple_try_set_cleanup): Likewise.
	(gimple_try_eval_ptr): Update for renaming of subclass to gtry.
	(gimple_try_cleanup_ptr): Likewise.
	(gimple_phi_capacity): Update for renaming of subclass to gphi.
	(gimple_phi_num_args): Likewise.
	(gimple_phi_result): Likewise.
	(gimple_phi_result_ptr): Likewise.
	(gimple_phi_arg): Likewise.
	(gimple_phi_set_result): Require a gphi *.
	(gimple_phi_set_arg): Likewise.
	(gimple_phi_arg_def_ptr): Likewise.
	(gimple_phi_arg_edge): Likewise.
	(gimple_phi_arg_location): Likewise.
	(gimple_phi_arg_location_from_edge): Likewise.
	(gimple_phi_arg_set_location): Likewise.
	(gimple_phi_arg_has_location): Likewise.
	(gimple_resx_region): Require a const gresx *.
	(gimple_resx_set_region): Require a gresx *.
	(gimple_eh_dispatch_region): Require a const geh_dispatch *.
	(gimple_eh_dispatch_set_region): Require a geh_dispatch *.
	(gimple_switch_num_labels): Require a const gswitch *.
	(gimple_switch_set_num_labels): Likewise.
	(gimple_switch_index): Likewise.
	(gimple_switch_index_ptr): Likewise.
	(gimple_switch_label): Likewise.
	(gimple_switch_default_label): Likewise.
	(gimple_switch_set_index): Require a gswitch *.
	(gimple_switch_set_label): Likewise.
	(gimple_switch_set_default_label): Likewise.
	(gimple_omp_critical_name): Require a const gomp_critical *.
	(gimple_omp_critical_name_ptr): Require a gomp_critical *.
	(gimple_omp_critical_set_name): Likewise.
	(gimple_omp_for_set_kind): Require a gomp_for *.
	(gimple_omp_for_set_combined_p): Likewise.
	(gimple_omp_for_set_combined_into_p): Likewise.
	(gimple_omp_for_clauses): Update for renaming of subclass to
	gomp_for.
	(gimple_omp_for_clauses_ptr): Likewise.
	(gimple_omp_for_set_clauses): Likewise.
	(gimple_omp_for_collapse): Likewise.
	(gimple_omp_for_index): Likewise.
	(gimple_omp_for_index_ptr): Likewise.
	(gimple_omp_for_set_index): Likewise.
	(gimple_omp_for_initial): Likewise.
	(gimple_omp_for_initial_ptr): Likewise.
	(gimple_omp_for_set_initial): Likewise.
	(gimple_omp_for_final): Likewise.
	(gimple_omp_for_final_ptr): Likewise.
	(gimple_omp_for_set_final): Likewise.
	(gimple_omp_for_incr): Likewise.
	(gimple_omp_for_incr_ptr): Likewise.
	(gimple_omp_for_set_incr): Likewise.
	(gimple_omp_for_pre_body): Likewise.
	(gimple_omp_for_set_pre_body): Likewise.
	(gimple_omp_parallel_clauses): Update for renaming of subclass to
	gomp_parallel.
	(gimple_omp_parallel_clauses_ptr): Require a gomp_parallel *.
	(gimple_omp_parallel_set_clauses): Likewise.
	(gimple_omp_parallel_child_fn_ptr): Likewise.
	(gimple_omp_parallel_set_child_fn): Likewise.
	(gimple_omp_parallel_data_arg_ptr): Likewise.
	(gimple_omp_parallel_set_data_arg): Likewise.
	(gimple_omp_parallel_child_fn): Require a const gomp_parallel *.
	(gimple_omp_parallel_data_arg): Likewise.
	(gimple_omp_task_clauses): Update for renaming of subclass to
	gomp_task.
	(gimple_omp_task_clauses_ptr): Likewise.
	(gimple_omp_task_set_clauses): Likewise.
	(gimple_omp_task_child_fn): Likewise.
	(gimple_omp_task_child_fn_ptr): Likewise.
	(gimple_omp_task_set_child_fn): Likewise.
	(gimple_omp_task_data_arg): Likewise.
	(gimple_omp_task_data_arg_ptr): Likewise.
	(gimple_omp_task_set_data_arg): Likewise.
	(gimple_omp_taskreg_clauses): Whitespace fixes.
	(gimple_omp_taskreg_clauses_ptr): Likewise.
	(gimple_omp_taskreg_set_clauses): Likewise.
	(gimple_omp_taskreg_child_fn): Likewise.
	(gimple_omp_taskreg_child_fn_ptr): Likewise.
	(gimple_omp_taskreg_set_child_fn): Likewise.
	(gimple_omp_taskreg_data_arg): Likewise.
	(gimple_omp_taskreg_data_arg_ptr): Likewise.
	(gimple_omp_taskreg_set_data_arg): Likewise.
	(gimple_omp_task_copy_fn): Update for renaming of subclass to
	gomp_task.
	(gimple_omp_task_copy_fn_ptr): Likewise.
	(gimple_omp_task_set_copy_fn): Likewise.
	(gimple_omp_task_arg_size): Likewise.
	(gimple_omp_task_arg_size_ptr): Likewise.
	(gimple_omp_task_set_arg_size): Likewise.
	(gimple_omp_task_arg_align): Likewise.
	(gimple_omp_task_arg_align_ptr): Likewise.
	(gimple_omp_task_set_arg_align): Likewise.
	(gimple_omp_single_clauses): Update for renaming of subclass to
	gomp_single.
	(gimple_omp_single_clauses_ptr): Likewise.
	(gimple_omp_single_set_clauses): Likewise.
	(gimple_omp_target_clauses): Update for renaming of subclass to
	gomp_target.
	(gimple_omp_target_clauses_ptr): Likewise.
	(gimple_omp_target_set_clauses): Require a gomp_target *.
	(gimple_omp_target_set_kind): Likewise.
	(gimple_omp_target_child_fn_ptr): Likewise.
	(gimple_omp_target_set_child_fn): Likewise.
	(gimple_omp_target_data_arg_ptr): Likewise.
	(gimple_omp_target_set_data_arg): Likewise.
	(gimple_omp_target_child_fn): Require a const gomp_target *.
	(gimple_omp_target_data_arg): Likewise.
	(gimple_omp_teams_clauses): Update for renaming of subclass to
	gomp_teams.
	(gimple_omp_teams_clauses_ptr): Likewise.
	(gimple_omp_teams_set_clauses): Require a gomp_teams *.
	(gimple_omp_sections_clauses): Update for renaming of subclass to
	gomp_sections.
	(gimple_omp_sections_clauses_ptr): Likewise.
	(gimple_omp_sections_set_clauses): Likewise.
	(gimple_omp_sections_control): Likewise.
	(gimple_omp_sections_control_ptr): Likewise.
	(gimple_omp_sections_set_control): Likewise.
	(gimple_omp_for_set_cond): Likewise.
	(gimple_omp_for_cond): Likewise.
	(gimple_omp_atomic_store_set_val): Require a gomp_atomic_store *.
	(gimple_omp_atomic_store_val_ptr): Likewise.
	(gimple_omp_atomic_load_set_lhs): Likewise.
	(gimple_omp_atomic_store_val): Require a const gomp_atomic_store *.
	(gimple_omp_atomic_load_lhs): Likewise.
	(gimple_omp_atomic_load_rhs): Likewise.
	(gimple_omp_atomic_load_lhs_ptr): Require a gomp_atomic_load *.
	(gimple_omp_atomic_load_set_rhs): Likewise.
	(gimple_omp_atomic_load_rhs_ptr): Likewise.
	(gimple_omp_continue_control_def): Require a const gomp_continue *.
	(gimple_omp_continue_control_use): Likewise.
	(gimple_omp_continue_control_def_ptr): Require a gomp_continue *.
	(gimple_omp_continue_set_control_def): Likewise.
	(gimple_omp_continue_control_use_ptr): Likewise.
	(gimple_omp_continue_set_control_use): Likewise.
	(gimple_transaction_body_ptr): Require a gtransaction *.
	(gimple_transaction_body): Likewise.
	(gimple_transaction_label_ptr): Likewise.
	(gimple_transaction_label): Require a const gtransaction *.
	(gimple_transaction_subcode): Likewise.
	(gimple_transaction_set_body): Require a gtransaction *.
	(gimple_transaction_set_label): Likewise.
	(gimple_transaction_set_subcode): Likewise.
	(gimple_return_retval_ptr): Require a const greturn *.
	(gimple_return_retval): Likewise.
	(gimple_return_set_retval): Require a greturn *.
	(gimple_expr_type): Introduce local "call_stmt" and use in place of
	"stmt" for typesafety.

	* asan.c: Use gimple subclasses.
	* auto-profile.c: Likewise.
	* builtins.c: Likewise.
	* builtins.h: Likewise.
	* cfgexpand.c: Likewise.
	* cfgloop.c: Likewise.
	* cfgloopmanip.c: Likewise.
	* cgraph.c: Likewise.
	* cgraph.h: Likewise.
	* cgraphbuild.c: Likewise.
	* cgraphclones.c: Likewise.
	* cgraphunit.c: Likewise.
	* expr.h: Likewise.
	* gimple-builder.c: Likewise.
	* gimple-builder.h: Likewise.
	* gimple-fold.c: Likewise.
	* gimple-low.c: Likewise.
	* gimple-pretty-print.c: Likewise.
	* gimple-ssa-isolate-paths.c: Likewise.
	* gimple-ssa-strength-reduction.c: Likewise.
	* gimple-streamer-in.c: Likewise.
	* gimple-streamer-out.c: Likewise.
	* gimple-walk.c: Likewise.
	* gimplify-me.c: Likewise.
	* gimplify.c: Likewise.
	* gimplify.h: Likewise.
	* graphite-scop-detection.c: Likewise.
	* graphite-sese-to-poly.c: Likewise.
	* internal-fn.c: Likewise.
	* internal-fn.def:: Likewise.
	* internal-fn.h: Likewise.
	* ipa-icf-gimple.c: Likewise.
	* ipa-icf-gimple.h: Likewise.
	* ipa-icf.c: Likewise.
	* ipa-inline-analysis.c: Likewise.
	* ipa-prop.c: Likewise.
	* ipa-prop.h: Likewise.
	* ipa-pure-const.c: Likewise.
	* ipa-split.c: Likewise.
	* lto-streamer-in.c: Likewise.
	* lto-streamer-out.c: Likewise.
	* omp-low.c: Likewise.
	* predict.c: Likewise.
	* sanopt.c: Likewise.
	* sese.c: Likewise.
	* ssa-iterators.h: Likewise.
	* stmt.c: Likewise.
	* trans-mem.c: Likewise.
	* tree-call-cdce.c: Likewise.
	* tree-cfg.c: Likewise.
	* tree-cfg.h: Likewise.
	* tree-cfgcleanup.c: Likewise.
	* tree-chkp.c: Likewise.
	* tree-chkp.h: Likewise.
	* tree-complex.c: Likewise.
	* tree-data-ref.c: Likewise.
	* tree-dfa.c: Likewise.
	* tree-eh.c: Likewise.
	* tree-eh.h: Likewise.
	* tree-emutls.c: Likewise.
	* tree-if-conv.c: Likewise.
	* tree-inline.c: Likewise.
	* tree-inline.h: Likewise.
	* tree-into-ssa.c: Likewise.
	* tree-into-ssa.h: Likewise.
	* tree-loop-distribution.c: Likewise.
	* tree-nrv.c: Likewise.
	* tree-object-size.c: Likewise.
	* tree-outof-ssa.c: Likewise.
	* tree-parloops.c: Likewise.
	* tree-phinodes.c: Likewise.
	* tree-phinodes.h: Likewise.
	* tree-predcom.c: Likewise.
	* tree-profile.c: Likewise.
	* tree-scalar-evolution.c: Likewise.
	* tree-scalar-evolution.h
	* tree-sra.cn_function):
	* tree-ssa-alias.c: Likewise.
	* tree-ssa-alias.h: Likewise.
	* tree-ssa-ccp.c: Likewise.
	* tree-ssa-coalesce.c: Likewise.
	* tree-ssa-copy.c: Likewise.
	* tree-ssa-copyrename.c: Likewise.
	* tree-ssa-dce.c: Likewise.
	* tree-ssa-dom.c: Likewise.
	* tree-ssa-forwprop.c: Likewise.
	* tree-ssa-ifcombine.c: Likewise.
	* tree-ssa-live.c: Likewise.
	* tree-ssa-loop-im.c: Likewise.
	* tree-ssa-loop-ivcanon.c: Likewise.
	* tree-ssa-loop-ivopts.c: Likewise.
	* tree-ssa-loop-manip.c: Likewise.
	* tree-ssa-loop-niter.c: Likewise.
	* tree-ssa-loop-prefetch.c: Likewise.
	* tree-ssa-loop-unswitch.c: Likewise.
	* tree-ssa-math-opts.c: Likewise.
	* tree-ssa-operands.c: Likewise.
	* tree-ssa-phiopt.c: Likewise.
	* tree-ssa-phiprop.c: Likewise.
	* tree-ssa-pre.c: Likewise.
	* tree-ssa-propagate.c: Likewise.
	* tree-ssa-propagate.h: Likewise.
	* tree-ssa-reassoc.c: Likewise.
	* tree-ssa-sccvn.c: Likewise.
	* tree-ssa-sccvn.h: Likewise.
	* tree-ssa-sink.c: Likewise.
	* tree-ssa-strlen.c
	* tree-ssa-structalias.c
	* tree-ssa-tail-merge.c: Likewise.
	* tree-ssa-ter.c: Likewise.
	* tree-ssa-threadedge.c: Likewise.
	* tree-ssa-threadedge.h: Likewise.
	* tree-ssa-threadupdate.c: Likewise.
	* tree-ssa-uncprop.c: Likewise.
	* tree-ssa-uninit.c: Likewise.
	* tree-ssa.c: Likewise.
	* tree-stdarg.c: Likewise.
	* tree-switch-conversion.c: Likewise.
	* tree-tailcall.c: Likewise.
	* tree-vect-data-refs.c: Likewise.
	* tree-vect-generic.c: Likewise.
	* tree-vect-loop-manip.c: Likewise.
	* tree-vect-loop.c: Likewise.
	* tree-vect-patterns.c: Likewise.
	* tree-vect-slp.c: Likewise.
	* tree-vect-stmts.c: Likewise.
	* tree-vectorizer.h: Likewise.
	* tree-vrp.c: Likewise.
	* tree.c: Likewise.
	* ubsan.c: Likewise.
	* value-prof.c: Likewise.
	* value-prof.h: Likewise.
	* vtable-verify.c: Likewise.

gcc/c-family/ChangeLog:
	Merger of git branch "gimple-classes-v2-option-3".
	* ChangeLog.gimple-classes: New.
	* c-gimplify.c (add_block_to_enclosing): Strengthen local "stack"
	from being just a vec<gimple> to a vec<gbind *>.

gcc/java/ChangeLog:
	Merger of git branch "gimple-classes-v2-option-3".
	* ChangeLog.gimple-classes: New.
	* java-gimplify.c (java_gimplify_block): Strengthen local "outer"
	from gimple to gbind *.

From-SVN: r217787
2014-11-19 17:00:54 +00:00

2524 lines
69 KiB
C

/* Pretty formatting of GIMPLE statements and expressions.
Copyright (C) 2001-2014 Free Software Foundation, Inc.
Contributed by Aldy Hernandez <aldyh@redhat.com> and
Diego Novillo <dnovillo@google.com>
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/>. */
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "tree.h"
#include "stringpool.h"
#include "diagnostic.h"
#include "gimple-pretty-print.h"
#include "hashtab.h"
#include "bitmap.h"
#include "predict.h"
#include "vec.h"
#include "hash-set.h"
#include "machmode.h"
#include "hard-reg-set.h"
#include "input.h"
#include "function.h"
#include "basic-block.h"
#include "tree-ssa-alias.h"
#include "internal-fn.h"
#include "tree-eh.h"
#include "gimple-expr.h"
#include "is-a.h"
#include "gimple.h"
#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "hash-map.h"
#include "plugin-api.h"
#include "ipa-ref.h"
#include "cgraph.h"
#include "tree-cfg.h"
#include "tree-ssanames.h"
#include "dumpfile.h" /* for dump_flags */
#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)
#define GIMPLE_NIY do_niy (buffer,gs)
/* Try to print on BUFFER a default message for the unrecognized
gimple statement GS. */
static void
do_niy (pretty_printer *buffer, gimple gs)
{
pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
gimple_code_name[(int) gimple_code (gs)]);
}
/* Emit a newline and SPC indentation spaces to BUFFER. */
static void
newline_and_indent (pretty_printer *buffer, int spc)
{
pp_newline (buffer);
INDENT (spc);
}
/* Print the GIMPLE statement GS on stderr. */
DEBUG_FUNCTION void
debug_gimple_stmt (gimple gs)
{
print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
}
/* Print GIMPLE statement G to FILE using SPC indentation spaces and
FLAGS as in pp_gimple_stmt_1. */
void
print_gimple_stmt (FILE *file, gimple g, int spc, int flags)
{
pretty_printer buffer;
pp_needs_newline (&buffer) = true;
buffer.buffer->stream = file;
pp_gimple_stmt_1 (&buffer, g, spc, flags);
pp_newline_and_flush (&buffer);
}
DEBUG_FUNCTION void
debug (gimple_statement_base &ref)
{
print_gimple_stmt (stderr, &ref, 0, 0);
}
DEBUG_FUNCTION void
debug (gimple_statement_base *ptr)
{
if (ptr)
debug (*ptr);
else
fprintf (stderr, "<nil>\n");
}
/* Print GIMPLE statement G to FILE using SPC indentation spaces and
FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
of the statement. */
void
print_gimple_expr (FILE *file, gimple g, int spc, int flags)
{
flags |= TDF_RHS_ONLY;
pretty_printer buffer;
pp_needs_newline (&buffer) = true;
buffer.buffer->stream = file;
pp_gimple_stmt_1 (&buffer, g, spc, flags);
pp_flush (&buffer);
}
/* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
spaces and FLAGS as in pp_gimple_stmt_1.
The caller is responsible for calling pp_flush on BUFFER to finalize
the pretty printer. */
static void
dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
{
gimple_stmt_iterator i;
for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
{
gimple gs = gsi_stmt (i);
INDENT (spc);
pp_gimple_stmt_1 (buffer, gs, spc, flags);
if (!gsi_one_before_end_p (i))
pp_newline (buffer);
}
}
/* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
FLAGS as in pp_gimple_stmt_1. */
void
print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
{
pretty_printer buffer;
pp_needs_newline (&buffer) = true;
buffer.buffer->stream = file;
dump_gimple_seq (&buffer, seq, spc, flags);
pp_newline_and_flush (&buffer);
}
/* Print the GIMPLE sequence SEQ on stderr. */
DEBUG_FUNCTION void
debug_gimple_seq (gimple_seq seq)
{
print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
}
/* A simple helper to pretty-print some of the gimple tuples in the printf
style. The format modifiers are preceded by '%' and are:
'G' - outputs a string corresponding to the code of the given gimple,
'S' - outputs a gimple_seq with indent of spc + 2,
'T' - outputs the tree t,
'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. */
static void
dump_gimple_fmt (pretty_printer *buffer, int spc, int flags,
const char *fmt, ...)
{
va_list args;
const char *c;
const char *tmp;
va_start (args, fmt);
for (c = fmt; *c; c++)
{
if (*c == '%')
{
gimple_seq seq;
tree t;
gimple g;
switch (*++c)
{
case 'G':
g = va_arg (args, gimple);
tmp = gimple_code_name[gimple_code (g)];
pp_string (buffer, tmp);
break;
case 'S':
seq = va_arg (args, gimple_seq);
pp_newline (buffer);
dump_gimple_seq (buffer, seq, spc + 2, flags);
newline_and_indent (buffer, spc);
break;
case 'T':
t = va_arg (args, tree);
if (t == NULL_TREE)
pp_string (buffer, "NULL");
else
dump_generic_node (buffer, t, spc, flags, false);
break;
case 'd':
pp_decimal_int (buffer, va_arg (args, int));
break;
case 's':
pp_string (buffer, va_arg (args, char *));
break;
case 'n':
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);
break;
case '-':
spc -= 2;
newline_and_indent (buffer, spc);
break;
default:
gcc_unreachable ();
}
}
else
pp_character (buffer, *c);
}
va_end (args);
}
/* Helper for dump_gimple_assign. Print the unary RHS of the
assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
static void
dump_unary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
{
enum tree_code rhs_code = gimple_assign_rhs_code (gs);
tree lhs = gimple_assign_lhs (gs);
tree rhs = gimple_assign_rhs1 (gs);
switch (rhs_code)
{
case VIEW_CONVERT_EXPR:
case ASSERT_EXPR:
dump_generic_node (buffer, rhs, spc, flags, false);
break;
case FIXED_CONVERT_EXPR:
case ADDR_SPACE_CONVERT_EXPR:
case FIX_TRUNC_EXPR:
case FLOAT_EXPR:
CASE_CONVERT:
pp_left_paren (buffer);
dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
pp_string (buffer, ") ");
if (op_prio (rhs) < op_code_prio (rhs_code))
{
pp_left_paren (buffer);
dump_generic_node (buffer, rhs, spc, flags, false);
pp_right_paren (buffer);
}
else
dump_generic_node (buffer, rhs, spc, flags, false);
break;
case PAREN_EXPR:
pp_string (buffer, "((");
dump_generic_node (buffer, rhs, spc, flags, false);
pp_string (buffer, "))");
break;
case ABS_EXPR:
pp_string (buffer, "ABS_EXPR <");
dump_generic_node (buffer, rhs, spc, flags, false);
pp_greater (buffer);
break;
default:
if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
|| TREE_CODE_CLASS (rhs_code) == tcc_constant
|| TREE_CODE_CLASS (rhs_code) == tcc_reference
|| rhs_code == SSA_NAME
|| rhs_code == ADDR_EXPR
|| rhs_code == CONSTRUCTOR)
{
dump_generic_node (buffer, rhs, spc, flags, false);
break;
}
else if (rhs_code == BIT_NOT_EXPR)
pp_complement (buffer);
else if (rhs_code == TRUTH_NOT_EXPR)
pp_exclamation (buffer);
else if (rhs_code == NEGATE_EXPR)
pp_minus (buffer);
else
{
pp_left_bracket (buffer);
pp_string (buffer, get_tree_code_name (rhs_code));
pp_string (buffer, "] ");
}
if (op_prio (rhs) < op_code_prio (rhs_code))
{
pp_left_paren (buffer);
dump_generic_node (buffer, rhs, spc, flags, false);
pp_right_paren (buffer);
}
else
dump_generic_node (buffer, rhs, spc, flags, false);
break;
}
}
/* Helper for dump_gimple_assign. Print the binary RHS of the
assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
static void
dump_binary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
{
const char *p;
enum tree_code code = gimple_assign_rhs_code (gs);
switch (code)
{
case COMPLEX_EXPR:
case MIN_EXPR:
case MAX_EXPR:
case VEC_WIDEN_MULT_HI_EXPR:
case VEC_WIDEN_MULT_LO_EXPR:
case VEC_WIDEN_MULT_EVEN_EXPR:
case VEC_WIDEN_MULT_ODD_EXPR:
case VEC_PACK_TRUNC_EXPR:
case VEC_PACK_SAT_EXPR:
case VEC_PACK_FIX_TRUNC_EXPR:
case VEC_WIDEN_LSHIFT_HI_EXPR:
case VEC_WIDEN_LSHIFT_LO_EXPR:
for (p = get_tree_code_name (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_greater (buffer);
break;
default:
if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
{
pp_left_paren (buffer);
dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
false);
pp_right_paren (buffer);
}
else
dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
pp_space (buffer);
pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
pp_space (buffer);
if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
{
pp_left_paren (buffer);
dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
false);
pp_right_paren (buffer);
}
else
dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
}
}
/* Helper for dump_gimple_assign. Print the ternary RHS of the
assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
static void
dump_ternary_rhs (pretty_printer *buffer, gassign *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 = get_tree_code_name (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_greater (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_greater (buffer);
break;
case SAD_EXPR:
pp_string (buffer, "SAD_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_greater (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_greater (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_greater (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_greater (buffer);
break;
default:
gcc_unreachable ();
}
}
/* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
pp_gimple_stmt_1. */
static void
dump_gimple_assign (pretty_printer *buffer, gassign *gs, int spc, int flags)
{
if (flags & TDF_RAW)
{
tree arg1 = NULL;
tree arg2 = NULL;
tree arg3 = NULL;
switch (gimple_num_ops (gs))
{
case 4:
arg3 = gimple_assign_rhs3 (gs);
case 3:
arg2 = gimple_assign_rhs2 (gs);
case 2:
arg1 = gimple_assign_rhs1 (gs);
break;
default:
gcc_unreachable ();
}
dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
get_tree_code_name (gimple_assign_rhs_code (gs)),
gimple_assign_lhs (gs), arg1, arg2, arg3);
}
else
{
if (!(flags & TDF_RHS_ONLY))
{
dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
pp_space (buffer);
pp_equal (buffer);
if (gimple_assign_nontemporal_move_p (gs))
pp_string (buffer, "{nt}");
if (gimple_has_volatile_ops (gs))
pp_string (buffer, "{v}");
pp_space (buffer);
}
if (gimple_num_ops (gs) == 2)
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))
pp_semicolon (buffer);
}
}
/* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
pp_gimple_stmt_1. */
static void
dump_gimple_return (pretty_printer *buffer, greturn *gs, int spc, int flags)
{
tree t, t2;
t = gimple_return_retval (gs);
t2 = gimple_return_retbnd (gs);
if (flags & TDF_RAW)
dump_gimple_fmt (buffer, spc, flags, "%G <%T %T>", gs, t, t2);
else
{
pp_string (buffer, "return");
if (t)
{
pp_space (buffer);
dump_generic_node (buffer, t, spc, flags, false);
}
if (t2)
{
pp_string (buffer, ", ");
dump_generic_node (buffer, t2, spc, flags, false);
}
pp_semicolon (buffer);
}
}
/* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
dump_gimple_call. */
static void
dump_gimple_call_args (pretty_printer *buffer, gcall *gs, int flags)
{
size_t i;
for (i = 0; i < gimple_call_num_args (gs); i++)
{
dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
if (i < gimple_call_num_args (gs) - 1)
pp_string (buffer, ", ");
}
if (gimple_call_va_arg_pack_p (gs))
{
if (gimple_call_num_args (gs) > 0)
{
pp_comma (buffer);
pp_space (buffer);
}
pp_string (buffer, "__builtin_va_arg_pack ()");
}
}
/* Dump the points-to solution *PT to BUFFER. */
static void
pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
{
if (pt->anything)
{
pp_string (buffer, "anything ");
return;
}
if (pt->nonlocal)
pp_string (buffer, "nonlocal ");
if (pt->escaped)
pp_string (buffer, "escaped ");
if (pt->ipa_escaped)
pp_string (buffer, "unit-escaped ");
if (pt->null)
pp_string (buffer, "null ");
if (pt->vars
&& !bitmap_empty_p (pt->vars))
{
bitmap_iterator bi;
unsigned i;
pp_string (buffer, "{ ");
EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
{
pp_string (buffer, "D.");
pp_decimal_int (buffer, i);
pp_space (buffer);
}
pp_right_brace (buffer);
if (pt->vars_contains_nonlocal
&& pt->vars_contains_escaped_heap)
pp_string (buffer, " (nonlocal, escaped heap)");
else if (pt->vars_contains_nonlocal
&& pt->vars_contains_escaped)
pp_string (buffer, " (nonlocal, escaped)");
else if (pt->vars_contains_nonlocal)
pp_string (buffer, " (nonlocal)");
else if (pt->vars_contains_escaped_heap)
pp_string (buffer, " (escaped heap)");
else if (pt->vars_contains_escaped)
pp_string (buffer, " (escaped)");
}
}
/* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
pp_gimple_stmt_1. */
static void
dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc, int flags)
{
tree lhs = gimple_call_lhs (gs);
tree fn = gimple_call_fn (gs);
if (flags & TDF_ALIAS)
{
struct pt_solution *pt;
pt = gimple_call_use_set (gs);
if (!pt_solution_empty_p (pt))
{
pp_string (buffer, "# USE = ");
pp_points_to_solution (buffer, pt);
newline_and_indent (buffer, spc);
}
pt = gimple_call_clobber_set (gs);
if (!pt_solution_empty_p (pt))
{
pp_string (buffer, "# CLB = ");
pp_points_to_solution (buffer, pt);
newline_and_indent (buffer, spc);
}
}
if (flags & TDF_RAW)
{
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, ", ");
dump_gimple_call_args (buffer, gs, flags);
}
pp_greater (buffer);
}
else
{
if (lhs && !(flags & TDF_RHS_ONLY))
{
dump_generic_node (buffer, lhs, spc, flags, false);
pp_string (buffer, " =");
if (gimple_has_volatile_ops (gs))
pp_string (buffer, "{v}");
pp_space (buffer);
}
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_right_paren (buffer);
if (!(flags & TDF_RHS_ONLY))
pp_semicolon (buffer);
}
if (gimple_call_chain (gs))
{
pp_string (buffer, " [static-chain: ");
dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
pp_right_bracket (buffer);
}
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_right_bracket (buffer);
}
}
/* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
pp_gimple_stmt_1. */
static void
dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc,
int flags)
{
unsigned int i;
GIMPLE_CHECK (gs, GIMPLE_SWITCH);
if (flags & TDF_RAW)
dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
gimple_switch_index (gs));
else
{
pp_string (buffer, "switch (");
dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
pp_string (buffer, ") <");
}
for (i = 0; i < gimple_switch_num_labels (gs); i++)
{
tree case_label = gimple_switch_label (gs, i);
gcc_checking_assert (case_label != NULL_TREE);
dump_generic_node (buffer, case_label, spc, flags, false);
pp_space (buffer);
dump_generic_node (buffer, CASE_LABEL (case_label), spc, flags, false);
if (i < gimple_switch_num_labels (gs) - 1)
pp_string (buffer, ", ");
}
pp_greater (buffer);
}
/* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
pp_gimple_stmt_1. */
static void
dump_gimple_cond (pretty_printer *buffer, gcond *gs, int spc, int flags)
{
if (flags & TDF_RAW)
dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
get_tree_code_name (gimple_cond_code (gs)),
gimple_cond_lhs (gs), gimple_cond_rhs (gs),
gimple_cond_true_label (gs), gimple_cond_false_label (gs));
else
{
if (!(flags & TDF_RHS_ONLY))
pp_string (buffer, "if (");
dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
pp_space (buffer);
pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
pp_space (buffer);
dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
if (!(flags & TDF_RHS_ONLY))
{
pp_right_paren (buffer);
if (gimple_cond_true_label (gs))
{
pp_string (buffer, " goto ");
dump_generic_node (buffer, gimple_cond_true_label (gs),
spc, flags, false);
pp_semicolon (buffer);
}
if (gimple_cond_false_label (gs))
{
pp_string (buffer, " else goto ");
dump_generic_node (buffer, gimple_cond_false_label (gs),
spc, flags, false);
pp_semicolon (buffer);
}
}
}
}
/* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
spaces of indent. FLAGS specifies details to show in the dump (see
TDF_* in dumpfils.h). */
static void
dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc, int flags)
{
tree label = gimple_label_label (gs);
if (flags & TDF_RAW)
dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
else
{
dump_generic_node (buffer, label, spc, flags, false);
pp_colon (buffer);
}
if (DECL_NONLOCAL (label))
pp_string (buffer, " [non-local]");
if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
}
/* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
spaces of indent. FLAGS specifies details to show in the dump (see
TDF_* in dumpfile.h). */
static void
dump_gimple_goto (pretty_printer *buffer, ggoto *gs, int spc, int flags)
{
tree label = gimple_goto_dest (gs);
if (flags & TDF_RAW)
dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
else
dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
}
/* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
spaces of indent. FLAGS specifies details to show in the dump (see
TDF_* in dumpfile.h). */
static void
dump_gimple_bind (pretty_printer *buffer, gbind *gs, int spc, int flags)
{
if (flags & TDF_RAW)
dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
else
pp_left_brace (buffer);
if (!(flags & TDF_SLIM))
{
tree var;
for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
{
newline_and_indent (buffer, 2);
print_declaration (buffer, var, spc, flags);
}
if (gimple_bind_vars (gs))
pp_newline (buffer);
}
pp_newline (buffer);
dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
newline_and_indent (buffer, spc);
if (flags & TDF_RAW)
pp_greater (buffer);
else
pp_right_brace (buffer);
}
/* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
indent. FLAGS specifies details to show in the dump (see TDF_* in
dumpfile.h). */
static void
dump_gimple_try (pretty_printer *buffer, gtry *gs, int spc, int flags)
{
if (flags & TDF_RAW)
{
const char *type;
if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
type = "GIMPLE_TRY_CATCH";
else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
type = "GIMPLE_TRY_FINALLY";
else
type = "UNKNOWN GIMPLE_TRY";
dump_gimple_fmt (buffer, spc, flags,
"%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
gimple_try_eval (gs), gimple_try_cleanup (gs));
}
else
{
pp_string (buffer, "try");
newline_and_indent (buffer, spc + 2);
pp_left_brace (buffer);
pp_newline (buffer);
dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
newline_and_indent (buffer, spc + 2);
pp_right_brace (buffer);
if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
{
newline_and_indent (buffer, spc);
pp_string (buffer, "catch");
newline_and_indent (buffer, spc + 2);
pp_left_brace (buffer);
}
else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
{
newline_and_indent (buffer, spc);
pp_string (buffer, "finally");
newline_and_indent (buffer, spc + 2);
pp_left_brace (buffer);
}
else
pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
pp_newline (buffer);
dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
newline_and_indent (buffer, spc + 2);
pp_right_brace (buffer);
}
}
/* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
indent. FLAGS specifies details to show in the dump (see TDF_* in
dumpfile.h). */
static void
dump_gimple_catch (pretty_printer *buffer, gcatch *gs, int spc, int flags)
{
if (flags & TDF_RAW)
dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
gimple_catch_types (gs), gimple_catch_handler (gs));
else
dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
gimple_catch_types (gs), gimple_catch_handler (gs));
}
/* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
indent. FLAGS specifies details to show in the dump (see TDF_* in
dumpfile.h). */
static void
dump_gimple_eh_filter (pretty_printer *buffer, geh_filter *gs, int spc,
int flags)
{
if (flags & TDF_RAW)
dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
gimple_eh_filter_types (gs),
gimple_eh_filter_failure (gs));
else
dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
gimple_eh_filter_types (gs),
gimple_eh_filter_failure (gs));
}
/* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
static void
dump_gimple_eh_must_not_throw (pretty_printer *buffer,
geh_mnt *gs, int spc, int flags)
{
if (flags & TDF_RAW)
dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
gimple_eh_must_not_throw_fndecl (gs));
else
dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
gimple_eh_must_not_throw_fndecl (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
dumpfile.h). */
static void
dump_gimple_eh_else (pretty_printer *buffer, geh_else *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
dumpfile.h). */
static void
dump_gimple_resx (pretty_printer *buffer, gresx *gs, int spc, int flags)
{
if (flags & TDF_RAW)
dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
gimple_resx_region (gs));
else
dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
}
/* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
static void
dump_gimple_eh_dispatch (pretty_printer *buffer, geh_dispatch *gs, int spc, int flags)
{
if (flags & TDF_RAW)
dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
gimple_eh_dispatch_region (gs));
else
dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
gimple_eh_dispatch_region (gs));
}
/* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
of indent. FLAGS specifies details to show in the dump (see TDF_*
in dumpfile.h). */
static void
dump_gimple_debug (pretty_printer *buffer, gdebug *gs, int spc, int flags)
{
switch (gs->subcode)
{
case GIMPLE_DEBUG_BIND:
if (flags & TDF_RAW)
dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
gimple_debug_bind_get_var (gs),
gimple_debug_bind_get_value (gs));
else
dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
gimple_debug_bind_get_var (gs),
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 ();
}
}
/* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
static void
dump_gimple_omp_for (pretty_printer *buffer, gomp_for *gs, int spc, int flags)
{
size_t i;
if (flags & TDF_RAW)
{
const char *kind;
switch (gimple_omp_for_kind (gs))
{
case GF_OMP_FOR_KIND_FOR:
kind = "";
break;
case GF_OMP_FOR_KIND_SIMD:
kind = " simd";
break;
case GF_OMP_FOR_KIND_CILKSIMD:
kind = " cilksimd";
break;
case GF_OMP_FOR_KIND_DISTRIBUTE:
kind = " distribute";
break;
case GF_OMP_FOR_KIND_CILKFOR:
kind = " _Cilk_for";
break;
default:
gcc_unreachable ();
}
dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
kind, gimple_omp_body (gs));
dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
dump_gimple_fmt (buffer, spc, flags, " >,");
for (i = 0; i < gimple_omp_for_collapse (gs); i++)
dump_gimple_fmt (buffer, spc, flags,
"%+%T, %T, %T, %s, %T,%n",
gimple_omp_for_index (gs, i),
gimple_omp_for_initial (gs, i),
gimple_omp_for_final (gs, i),
get_tree_code_name (gimple_omp_for_cond (gs, i)),
gimple_omp_for_incr (gs, i));
dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
gimple_omp_for_pre_body (gs));
}
else
{
switch (gimple_omp_for_kind (gs))
{
case GF_OMP_FOR_KIND_FOR:
pp_string (buffer, "#pragma omp for");
break;
case GF_OMP_FOR_KIND_SIMD:
pp_string (buffer, "#pragma omp simd");
break;
case GF_OMP_FOR_KIND_CILKSIMD:
pp_string (buffer, "#pragma simd");
break;
case GF_OMP_FOR_KIND_DISTRIBUTE:
pp_string (buffer, "#pragma omp distribute");
break;
case GF_OMP_FOR_KIND_CILKFOR:
break;
default:
gcc_unreachable ();
}
if (gimple_omp_for_kind (gs) != GF_OMP_FOR_KIND_CILKFOR)
dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
for (i = 0; i < gimple_omp_for_collapse (gs); i++)
{
if (i)
spc += 2;
if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
pp_string (buffer, "_Cilk_for (");
else
{
newline_and_indent (buffer, spc);
pp_string (buffer, "for (");
}
dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
flags, false);
pp_string (buffer, " = ");
dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
flags, false);
pp_string (buffer, "; ");
dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
flags, false);
pp_space (buffer);
switch (gimple_omp_for_cond (gs, i))
{
case LT_EXPR:
pp_less (buffer);
break;
case GT_EXPR:
pp_greater (buffer);
break;
case LE_EXPR:
pp_less_equal (buffer);
break;
case GE_EXPR:
pp_greater_equal (buffer);
break;
case NE_EXPR:
pp_string (buffer, "!=");
break;
default:
gcc_unreachable ();
}
pp_space (buffer);
dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
flags, false);
pp_string (buffer, "; ");
dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
flags, false);
pp_string (buffer, " = ");
dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
flags, false);
pp_right_paren (buffer);
}
if (!gimple_seq_empty_p (gimple_omp_body (gs)))
{
if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
newline_and_indent (buffer, spc + 2);
pp_left_brace (buffer);
pp_newline (buffer);
dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
newline_and_indent (buffer, spc + 2);
pp_right_brace (buffer);
}
}
}
/* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
static void
dump_gimple_omp_continue (pretty_printer *buffer, gomp_continue *gs,
int spc, int flags)
{
if (flags & TDF_RAW)
{
dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
gimple_omp_continue_control_def (gs),
gimple_omp_continue_control_use (gs));
}
else
{
pp_string (buffer, "#pragma omp continue (");
dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
spc, flags, false);
pp_comma (buffer);
pp_space (buffer);
dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
spc, flags, false);
pp_right_paren (buffer);
}
}
/* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
static void
dump_gimple_omp_single (pretty_printer *buffer, gomp_single *gs,
int spc, int flags)
{
if (flags & TDF_RAW)
{
dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
gimple_omp_body (gs));
dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
dump_gimple_fmt (buffer, spc, flags, " >");
}
else
{
pp_string (buffer, "#pragma omp single");
dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
if (!gimple_seq_empty_p (gimple_omp_body (gs)))
{
newline_and_indent (buffer, spc + 2);
pp_left_brace (buffer);
pp_newline (buffer);
dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
newline_and_indent (buffer, spc + 2);
pp_right_brace (buffer);
}
}
}
/* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
static void
dump_gimple_omp_target (pretty_printer *buffer, gomp_target *gs,
int spc, int flags)
{
const char *kind;
switch (gimple_omp_target_kind (gs))
{
case GF_OMP_TARGET_KIND_REGION:
kind = "";
break;
case GF_OMP_TARGET_KIND_DATA:
kind = " data";
break;
case GF_OMP_TARGET_KIND_UPDATE:
kind = " update";
break;
default:
gcc_unreachable ();
}
if (flags & TDF_RAW)
{
dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
kind, gimple_omp_body (gs));
dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
dump_gimple_fmt (buffer, spc, flags, " >");
}
else
{
pp_string (buffer, "#pragma omp target");
pp_string (buffer, kind);
dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
if (gimple_omp_target_child_fn (gs))
{
pp_string (buffer, " [child fn: ");
dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
spc, flags, false);
pp_right_bracket (buffer);
}
if (!gimple_seq_empty_p (gimple_omp_body (gs)))
{
newline_and_indent (buffer, spc + 2);
pp_character (buffer, '{');
pp_newline (buffer);
dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
newline_and_indent (buffer, spc + 2);
pp_character (buffer, '}');
}
}
}
/* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
static void
dump_gimple_omp_teams (pretty_printer *buffer, gomp_teams *gs, int spc,
int flags)
{
if (flags & TDF_RAW)
{
dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
gimple_omp_body (gs));
dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
dump_gimple_fmt (buffer, spc, flags, " >");
}
else
{
pp_string (buffer, "#pragma omp teams");
dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
if (!gimple_seq_empty_p (gimple_omp_body (gs)))
{
newline_and_indent (buffer, spc + 2);
pp_character (buffer, '{');
pp_newline (buffer);
dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
newline_and_indent (buffer, spc + 2);
pp_character (buffer, '}');
}
}
}
/* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
static void
dump_gimple_omp_sections (pretty_printer *buffer, gomp_sections *gs,
int spc, int flags)
{
if (flags & TDF_RAW)
{
dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
gimple_omp_body (gs));
dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
dump_gimple_fmt (buffer, spc, flags, " >");
}
else
{
pp_string (buffer, "#pragma omp sections");
if (gimple_omp_sections_control (gs))
{
pp_string (buffer, " <");
dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
flags, false);
pp_greater (buffer);
}
dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
if (!gimple_seq_empty_p (gimple_omp_body (gs)))
{
newline_and_indent (buffer, spc + 2);
pp_left_brace (buffer);
pp_newline (buffer);
dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
newline_and_indent (buffer, spc + 2);
pp_right_brace (buffer);
}
}
}
/* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
pretty_printer BUFFER. */
static void
dump_gimple_omp_block (pretty_printer *buffer, gimple gs, int spc, int flags)
{
if (flags & TDF_RAW)
dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
gimple_omp_body (gs));
else
{
switch (gimple_code (gs))
{
case GIMPLE_OMP_MASTER:
pp_string (buffer, "#pragma omp master");
break;
case GIMPLE_OMP_TASKGROUP:
pp_string (buffer, "#pragma omp taskgroup");
break;
case GIMPLE_OMP_ORDERED:
pp_string (buffer, "#pragma omp ordered");
break;
case GIMPLE_OMP_SECTION:
pp_string (buffer, "#pragma omp section");
break;
default:
gcc_unreachable ();
}
if (!gimple_seq_empty_p (gimple_omp_body (gs)))
{
newline_and_indent (buffer, spc + 2);
pp_left_brace (buffer);
pp_newline (buffer);
dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
newline_and_indent (buffer, spc + 2);
pp_right_brace (buffer);
}
}
}
/* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
static void
dump_gimple_omp_critical (pretty_printer *buffer, gomp_critical *gs,
int spc, int flags)
{
if (flags & TDF_RAW)
dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
gimple_omp_body (gs));
else
{
pp_string (buffer, "#pragma omp critical");
if (gimple_omp_critical_name (gs))
{
pp_string (buffer, " (");
dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
flags, false);
pp_right_paren (buffer);
}
if (!gimple_seq_empty_p (gimple_omp_body (gs)))
{
newline_and_indent (buffer, spc + 2);
pp_left_brace (buffer);
pp_newline (buffer);
dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
newline_and_indent (buffer, spc + 2);
pp_right_brace (buffer);
}
}
}
/* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
static void
dump_gimple_omp_return (pretty_printer *buffer, gimple gs, int spc, int flags)
{
if (flags & TDF_RAW)
{
dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
(int) gimple_omp_return_nowait_p (gs));
if (gimple_omp_return_lhs (gs))
dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
gimple_omp_return_lhs (gs));
else
dump_gimple_fmt (buffer, spc, flags, ">");
}
else
{
pp_string (buffer, "#pragma omp return");
if (gimple_omp_return_nowait_p (gs))
pp_string (buffer, "(nowait)");
if (gimple_omp_return_lhs (gs))
{
pp_string (buffer, " (set ");
dump_generic_node (buffer, gimple_omp_return_lhs (gs),
spc, flags, false);
pp_character (buffer, ')');
}
}
}
/* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
static void
dump_gimple_transaction (pretty_printer *buffer, gtransaction *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 & GTMA_HAS_NO_INSTRUMENTATION)
{
pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
}
if (subcode)
pp_printf (buffer, "0x%x ", subcode);
pp_right_bracket (buffer);
}
}
if (!gimple_seq_empty_p (gimple_transaction_body (gs)))
{
newline_and_indent (buffer, spc + 2);
pp_left_brace (buffer);
pp_newline (buffer);
dump_gimple_seq (buffer, gimple_transaction_body (gs),
spc + 4, flags);
newline_and_indent (buffer, spc + 2);
pp_right_brace (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
dumpfile.h). */
static void
dump_gimple_asm (pretty_printer *buffer, gasm *gs, int spc, int flags)
{
unsigned int i, n, f, fields;
if (flags & TDF_RAW)
{
dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
gimple_asm_string (gs));
n = gimple_asm_noutputs (gs);
if (n)
{
newline_and_indent (buffer, spc + 2);
pp_string (buffer, "OUTPUT: ");
for (i = 0; i < n; i++)
{
dump_generic_node (buffer, gimple_asm_output_op (gs, i),
spc, flags, false);
if (i < n - 1)
pp_string (buffer, ", ");
}
}
n = gimple_asm_ninputs (gs);
if (n)
{
newline_and_indent (buffer, spc + 2);
pp_string (buffer, "INPUT: ");
for (i = 0; i < n; i++)
{
dump_generic_node (buffer, gimple_asm_input_op (gs, i),
spc, flags, false);
if (i < n - 1)
pp_string (buffer, ", ");
}
}
n = gimple_asm_nclobbers (gs);
if (n)
{
newline_and_indent (buffer, spc + 2);
pp_string (buffer, "CLOBBER: ");
for (i = 0; i < n; i++)
{
dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
spc, flags, false);
if (i < n - 1)
pp_string (buffer, ", ");
}
}
n = gimple_asm_nlabels (gs);
if (n)
{
newline_and_indent (buffer, spc + 2);
pp_string (buffer, "LABEL: ");
for (i = 0; i < n; i++)
{
dump_generic_node (buffer, gimple_asm_label_op (gs, i),
spc, flags, false);
if (i < n - 1)
pp_string (buffer, ", ");
}
}
newline_and_indent (buffer, spc);
pp_greater (buffer);
}
else
{
pp_string (buffer, "__asm__");
if (gimple_asm_volatile_p (gs))
pp_string (buffer, " __volatile__");
if (gimple_asm_nlabels (gs))
pp_string (buffer, " goto");
pp_string (buffer, "(\"");
pp_string (buffer, gimple_asm_string (gs));
pp_string (buffer, "\"");
if (gimple_asm_nlabels (gs))
fields = 4;
else if (gimple_asm_nclobbers (gs))
fields = 3;
else if (gimple_asm_ninputs (gs))
fields = 2;
else if (gimple_asm_noutputs (gs))
fields = 1;
else
fields = 0;
for (f = 0; f < fields; ++f)
{
pp_string (buffer, " : ");
switch (f)
{
case 0:
n = gimple_asm_noutputs (gs);
for (i = 0; i < n; i++)
{
dump_generic_node (buffer, gimple_asm_output_op (gs, i),
spc, flags, false);
if (i < n - 1)
pp_string (buffer, ", ");
}
break;
case 1:
n = gimple_asm_ninputs (gs);
for (i = 0; i < n; i++)
{
dump_generic_node (buffer, gimple_asm_input_op (gs, i),
spc, flags, false);
if (i < n - 1)
pp_string (buffer, ", ");
}
break;
case 2:
n = gimple_asm_nclobbers (gs);
for (i = 0; i < n; i++)
{
dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
spc, flags, false);
if (i < n - 1)
pp_string (buffer, ", ");
}
break;
case 3:
n = gimple_asm_nlabels (gs);
for (i = 0; i < n; i++)
{
dump_generic_node (buffer, gimple_asm_label_op (gs, i),
spc, flags, false);
if (i < n - 1)
pp_string (buffer, ", ");
}
break;
default:
gcc_unreachable ();
}
}
pp_string (buffer, ");");
}
}
/* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
SPC spaces of indent. */
static void
dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
{
if (TREE_CODE (node) != SSA_NAME)
return;
if (POINTER_TYPE_P (TREE_TYPE (node))
&& SSA_NAME_PTR_INFO (node))
{
unsigned int align, misalign;
struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
pp_string (buffer, "# PT = ");
pp_points_to_solution (buffer, &pi->pt);
newline_and_indent (buffer, spc);
if (get_ptr_info_alignment (pi, &align, &misalign))
{
pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
newline_and_indent (buffer, spc);
}
}
if (!POINTER_TYPE_P (TREE_TYPE (node))
&& SSA_NAME_RANGE_INFO (node))
{
wide_int min, max, nonzero_bits;
value_range_type range_type = get_range_info (node, &min, &max);
if (range_type == VR_VARYING)
pp_printf (buffer, "# RANGE VR_VARYING");
else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
{
pp_printf (buffer, "# RANGE ");
pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
pp_printf (buffer, ", ");
pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
pp_printf (buffer, "]");
}
nonzero_bits = get_nonzero_bits (node);
if (nonzero_bits != -1)
{
pp_string (buffer, " NONZERO ");
pp_wide_int (buffer, nonzero_bits, UNSIGNED);
}
newline_and_indent (buffer, spc);
}
}
/* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
The caller is responsible for calling pp_flush on BUFFER to finalize
pretty printer. If COMMENT is true, print this after #. */
static void
dump_gimple_phi (pretty_printer *buffer, gphi *phi, int spc, bool comment,
int flags)
{
size_t i;
tree lhs = gimple_phi_result (phi);
if (flags & TDF_ALIAS)
dump_ssaname_info (buffer, lhs, spc);
if (comment)
pp_string (buffer, "# ");
if (flags & TDF_RAW)
dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
gimple_phi_result (phi));
else
{
dump_generic_node (buffer, lhs, spc, flags, false);
pp_string (buffer, " = PHI <");
}
for (i = 0; i < gimple_phi_num_args (phi); i++)
{
if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
dump_location (buffer, gimple_phi_arg_location (phi, i));
dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
false);
pp_left_paren (buffer);
pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
pp_right_paren (buffer);
if (i < gimple_phi_num_args (phi) - 1)
pp_string (buffer, ", ");
}
pp_greater (buffer);
}
/* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
of indent. FLAGS specifies details to show in the dump (see TDF_* in
dumpfile.h). */
static void
dump_gimple_omp_parallel (pretty_printer *buffer, gomp_parallel *gs,
int spc, int flags)
{
if (flags & TDF_RAW)
{
dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
gimple_omp_body (gs));
dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
gimple_omp_parallel_child_fn (gs),
gimple_omp_parallel_data_arg (gs));
}
else
{
gimple_seq body;
pp_string (buffer, "#pragma omp parallel");
dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
if (gimple_omp_parallel_child_fn (gs))
{
pp_string (buffer, " [child fn: ");
dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
spc, flags, false);
pp_string (buffer, " (");
if (gimple_omp_parallel_data_arg (gs))
dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
spc, flags, false);
else
pp_string (buffer, "???");
pp_string (buffer, ")]");
}
body = gimple_omp_body (gs);
if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
{
newline_and_indent (buffer, spc + 2);
pp_left_brace (buffer);
pp_newline (buffer);
dump_gimple_seq (buffer, body, spc + 4, flags);
newline_and_indent (buffer, spc + 2);
pp_right_brace (buffer);
}
else if (body)
{
pp_newline (buffer);
dump_gimple_seq (buffer, body, spc + 2, flags);
}
}
}
/* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
of indent. FLAGS specifies details to show in the dump (see TDF_* in
dumpfile.h). */
static void
dump_gimple_omp_task (pretty_printer *buffer, gomp_task *gs, int spc,
int flags)
{
if (flags & TDF_RAW)
{
dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
gimple_omp_body (gs));
dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
gimple_omp_task_child_fn (gs),
gimple_omp_task_data_arg (gs),
gimple_omp_task_copy_fn (gs),
gimple_omp_task_arg_size (gs),
gimple_omp_task_arg_size (gs));
}
else
{
gimple_seq body;
pp_string (buffer, "#pragma omp task");
dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
if (gimple_omp_task_child_fn (gs))
{
pp_string (buffer, " [child fn: ");
dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
spc, flags, false);
pp_string (buffer, " (");
if (gimple_omp_task_data_arg (gs))
dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
spc, flags, false);
else
pp_string (buffer, "???");
pp_string (buffer, ")]");
}
body = gimple_omp_body (gs);
if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
{
newline_and_indent (buffer, spc + 2);
pp_left_brace (buffer);
pp_newline (buffer);
dump_gimple_seq (buffer, body, spc + 4, flags);
newline_and_indent (buffer, spc + 2);
pp_right_brace (buffer);
}
else if (body)
{
pp_newline (buffer);
dump_gimple_seq (buffer, body, spc + 2, flags);
}
}
}
/* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
in dumpfile.h). */
static void
dump_gimple_omp_atomic_load (pretty_printer *buffer, gomp_atomic_load *gs,
int spc, int flags)
{
if (flags & TDF_RAW)
{
dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
gimple_omp_atomic_load_lhs (gs),
gimple_omp_atomic_load_rhs (gs));
}
else
{
pp_string (buffer, "#pragma omp atomic_load");
if (gimple_omp_atomic_seq_cst_p (gs))
pp_string (buffer, " seq_cst");
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);
pp_space (buffer);
pp_equal (buffer);
pp_space (buffer);
pp_star (buffer);
dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
spc, flags, false);
}
}
/* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
in dumpfile.h). */
static void
dump_gimple_omp_atomic_store (pretty_printer *buffer,
gomp_atomic_store *gs, int spc, int flags)
{
if (flags & TDF_RAW)
{
dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
gimple_omp_atomic_store_val (gs));
}
else
{
pp_string (buffer, "#pragma omp atomic_store ");
if (gimple_omp_atomic_seq_cst_p (gs))
pp_string (buffer, "seq_cst ");
if (gimple_omp_atomic_need_value_p (gs))
pp_string (buffer, "[needed] ");
pp_left_paren (buffer);
dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
spc, flags, false);
pp_right_paren (buffer);
}
}
/* Dump all the memory operands for statement GS. BUFFER, SPC and
FLAGS are as in pp_gimple_stmt_1. */
static void
dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags)
{
tree vdef = gimple_vdef (gs);
tree vuse = gimple_vuse (gs);
if (vdef != NULL_TREE)
{
pp_string (buffer, "# ");
dump_generic_node (buffer, vdef, spc + 2, flags, false);
pp_string (buffer, " = VDEF <");
dump_generic_node (buffer, vuse, spc + 2, flags, false);
pp_greater (buffer);
newline_and_indent (buffer, spc);
}
else if (vuse != NULL_TREE)
{
pp_string (buffer, "# VUSE <");
dump_generic_node (buffer, vuse, spc + 2, flags, false);
pp_greater (buffer);
newline_and_indent (buffer, spc);
}
}
/* Print the gimple statement GS on the pretty printer BUFFER, SPC
spaces of indent. FLAGS specifies details to show in the dump (see
TDF_* in dumpfile.h). The caller is responsible for calling
pp_flush on BUFFER to finalize the pretty printer. */
void
pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
{
if (!gs)
return;
if (flags & TDF_STMTADDR)
pp_printf (buffer, "<&%p> ", (void *) gs);
if ((flags & TDF_LINENO) && gimple_has_location (gs))
dump_location (buffer, gimple_location (gs));
if (flags & TDF_EH)
{
int lp_nr = lookup_stmt_eh_lp (gs);
if (lp_nr > 0)
pp_printf (buffer, "[LP %d] ", lp_nr);
else if (lp_nr < 0)
pp_printf (buffer, "[MNT %d] ", -lp_nr);
}
if ((flags & (TDF_VOPS|TDF_MEMSYMS))
&& gimple_has_mem_ops (gs))
dump_gimple_mem_ops (buffer, gs, spc, flags);
if (gimple_has_lhs (gs)
&& (flags & TDF_ALIAS))
dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
switch (gimple_code (gs))
{
case GIMPLE_ASM:
dump_gimple_asm (buffer, as_a <gasm *> (gs), spc, flags);
break;
case GIMPLE_ASSIGN:
dump_gimple_assign (buffer, as_a <gassign *> (gs), spc, flags);
break;
case GIMPLE_BIND:
dump_gimple_bind (buffer, as_a <gbind *> (gs), spc, flags);
break;
case GIMPLE_CALL:
dump_gimple_call (buffer, as_a <gcall *> (gs), spc, flags);
break;
case GIMPLE_COND:
dump_gimple_cond (buffer, as_a <gcond *> (gs), spc, flags);
break;
case GIMPLE_LABEL:
dump_gimple_label (buffer, as_a <glabel *> (gs), spc, flags);
break;
case GIMPLE_GOTO:
dump_gimple_goto (buffer, as_a <ggoto *> (gs), spc, flags);
break;
case GIMPLE_NOP:
pp_string (buffer, "GIMPLE_NOP");
break;
case GIMPLE_RETURN:
dump_gimple_return (buffer, as_a <greturn *> (gs), spc, flags);
break;
case GIMPLE_SWITCH:
dump_gimple_switch (buffer, as_a <gswitch *> (gs), spc, flags);
break;
case GIMPLE_TRY:
dump_gimple_try (buffer, as_a <gtry *> (gs), spc, flags);
break;
case GIMPLE_PHI:
dump_gimple_phi (buffer, as_a <gphi *> (gs), spc, false, flags);
break;
case GIMPLE_OMP_PARALLEL:
dump_gimple_omp_parallel (buffer, as_a <gomp_parallel *> (gs), spc,
flags);
break;
case GIMPLE_OMP_TASK:
dump_gimple_omp_task (buffer, as_a <gomp_task *> (gs), spc, flags);
break;
case GIMPLE_OMP_ATOMIC_LOAD:
dump_gimple_omp_atomic_load (buffer, as_a <gomp_atomic_load *> (gs),
spc, flags);
break;
case GIMPLE_OMP_ATOMIC_STORE:
dump_gimple_omp_atomic_store (buffer,
as_a <gomp_atomic_store *> (gs),
spc, flags);
break;
case GIMPLE_OMP_FOR:
dump_gimple_omp_for (buffer, as_a <gomp_for *> (gs), spc, flags);
break;
case GIMPLE_OMP_CONTINUE:
dump_gimple_omp_continue (buffer, as_a <gomp_continue *> (gs), spc,
flags);
break;
case GIMPLE_OMP_SINGLE:
dump_gimple_omp_single (buffer, as_a <gomp_single *> (gs), spc,
flags);
break;
case GIMPLE_OMP_TARGET:
dump_gimple_omp_target (buffer, as_a <gomp_target *> (gs), spc,
flags);
break;
case GIMPLE_OMP_TEAMS:
dump_gimple_omp_teams (buffer, as_a <gomp_teams *> (gs), spc,
flags);
break;
case GIMPLE_OMP_RETURN:
dump_gimple_omp_return (buffer, gs, spc, flags);
break;
case GIMPLE_OMP_SECTIONS:
dump_gimple_omp_sections (buffer, as_a <gomp_sections *> (gs),
spc, flags);
break;
case GIMPLE_OMP_SECTIONS_SWITCH:
pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
break;
case GIMPLE_OMP_MASTER:
case GIMPLE_OMP_TASKGROUP:
case GIMPLE_OMP_ORDERED:
case GIMPLE_OMP_SECTION:
dump_gimple_omp_block (buffer, gs, spc, flags);
break;
case GIMPLE_OMP_CRITICAL:
dump_gimple_omp_critical (buffer, as_a <gomp_critical *> (gs), spc,
flags);
break;
case GIMPLE_CATCH:
dump_gimple_catch (buffer, as_a <gcatch *> (gs), spc, flags);
break;
case GIMPLE_EH_FILTER:
dump_gimple_eh_filter (buffer, as_a <geh_filter *> (gs), spc, flags);
break;
case GIMPLE_EH_MUST_NOT_THROW:
dump_gimple_eh_must_not_throw (buffer,
as_a <geh_mnt *> (gs),
spc, flags);
break;
case GIMPLE_EH_ELSE:
dump_gimple_eh_else (buffer, as_a <geh_else *> (gs), spc, flags);
break;
case GIMPLE_RESX:
dump_gimple_resx (buffer, as_a <gresx *> (gs), spc, flags);
break;
case GIMPLE_EH_DISPATCH:
dump_gimple_eh_dispatch (buffer, as_a <geh_dispatch *> (gs), spc,
flags);
break;
case GIMPLE_DEBUG:
dump_gimple_debug (buffer, as_a <gdebug *> (gs), spc, flags);
break;
case GIMPLE_PREDICT:
pp_string (buffer, "// predicted ");
if (gimple_predict_outcome (gs))
pp_string (buffer, "likely by ");
else
pp_string (buffer, "unlikely by ");
pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
pp_string (buffer, " predictor.");
break;
case GIMPLE_TRANSACTION:
dump_gimple_transaction (buffer, as_a <gtransaction *> (gs), spc,
flags);
break;
default:
GIMPLE_NIY;
}
}
/* Dumps header of basic block BB to OUTF indented by INDENT
spaces and details described by flags. */
static void
dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
{
if (flags & TDF_BLOCKS)
{
if (flags & TDF_LINENO)
{
gimple_stmt_iterator gsi;
if (flags & TDF_COMMENT)
fputs (";; ", outf);
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
if (!is_gimple_debug (gsi_stmt (gsi))
&& get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
{
fprintf (outf, "%*sstarting at line %d",
indent, "", get_lineno (gsi_stmt (gsi)));
break;
}
if (bb->discriminator)
fprintf (outf, ", discriminator %i", bb->discriminator);
fputc ('\n', outf);
}
}
else
{
gimple stmt = first_stmt (bb);
if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
fprintf (outf, "%*s<bb %d>:\n", indent, "", bb->index);
}
}
/* Dumps end of basic block BB to buffer BUFFER indented by INDENT
spaces. */
static void
dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
basic_block bb ATTRIBUTE_UNUSED,
int indent ATTRIBUTE_UNUSED,
int flags ATTRIBUTE_UNUSED)
{
/* There is currently no GIMPLE-specific basic block info to dump. */
return;
}
/* Dump PHI nodes of basic block BB to BUFFER with details described
by FLAGS and indented by INDENT spaces. */
static void
dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
{
gphi_iterator i;
for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
{
gphi *phi = i.phi ();
if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
{
INDENT (indent);
dump_gimple_phi (buffer, phi, indent, true, flags);
pp_newline (buffer);
}
}
}
/* Dump jump to basic block BB that is represented implicitly in the cfg
to BUFFER. */
static void
pp_cfg_jump (pretty_printer *buffer, basic_block bb)
{
gimple stmt;
stmt = first_stmt (bb);
pp_string (buffer, "goto <bb ");
pp_decimal_int (buffer, bb->index);
pp_greater (buffer);
if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
{
pp_string (buffer, " (");
dump_generic_node (buffer,
gimple_label_label (as_a <glabel *> (stmt)),
0, 0, false);
pp_right_paren (buffer);
pp_semicolon (buffer);
}
else
pp_semicolon (buffer);
}
/* Dump edges represented implicitly in basic block BB to BUFFER, indented
by INDENT spaces, with details given by FLAGS. */
static void
dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
int flags)
{
edge e;
gimple stmt;
stmt = last_stmt (bb);
if (stmt && gimple_code (stmt) == GIMPLE_COND)
{
edge true_edge, false_edge;
/* When we are emitting the code or changing CFG, it is possible that
the edges are not yet created. When we are using debug_bb in such
a situation, we do not want it to crash. */
if (EDGE_COUNT (bb->succs) != 2)
return;
extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
INDENT (indent + 2);
pp_cfg_jump (buffer, true_edge->dest);
newline_and_indent (buffer, indent);
pp_string (buffer, "else");
newline_and_indent (buffer, indent + 2);
pp_cfg_jump (buffer, false_edge->dest);
pp_newline (buffer);
return;
}
/* If there is a fallthru edge, we may need to add an artificial
goto to the dump. */
e = find_fallthru_edge (bb->succs);
if (e && e->dest != bb->next_bb)
{
INDENT (indent);
if ((flags & TDF_LINENO)
&& e->goto_locus != UNKNOWN_LOCATION)
dump_location (buffer, e->goto_locus);
pp_cfg_jump (buffer, e->dest);
pp_newline (buffer);
}
}
/* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
indented by INDENT spaces. */
static void
gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
int flags)
{
gimple_stmt_iterator gsi;
gimple stmt;
int label_indent = indent - 2;
if (label_indent < 0)
label_indent = 0;
dump_phi_nodes (buffer, bb, indent, flags);
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
{
int curr_indent;
stmt = gsi_stmt (gsi);
curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
INDENT (curr_indent);
pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
pp_newline_and_flush (buffer);
gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
pp_buffer (buffer)->stream, stmt);
}
dump_implicit_edges (buffer, bb, indent, flags);
pp_flush (buffer);
}
/* Dumps basic block BB to FILE with details described by FLAGS and
indented by INDENT spaces. */
void
gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags)
{
dump_gimple_bb_header (file, bb, indent, flags);
if (bb->index >= NUM_FIXED_BLOCKS)
{
pretty_printer buffer;
pp_needs_newline (&buffer) = true;
buffer.buffer->stream = file;
gimple_dump_bb_buff (&buffer, bb, indent, flags);
}
dump_gimple_bb_footer (file, bb, indent, flags);
}
/* Dumps basic block BB to pretty-printer PP with default dump flags and
no indentation, for use as a label of a DOT graph record-node.
??? Should just use gimple_dump_bb_buff here, except that value profiling
histogram dumping doesn't know about pretty-printers. */
void
gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
{
pp_printf (pp, "<bb %d>:\n", bb->index);
pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
gsi_next (&gsi))
{
gphi *phi = gsi.phi ();
if (!virtual_operand_p (gimple_phi_result (phi))
|| (dump_flags & TDF_VOPS))
{
pp_bar (pp);
pp_write_text_to_stream (pp);
pp_string (pp, "# ");
pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
pp_newline (pp);
pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
}
}
for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
gsi_next (&gsi))
{
gimple stmt = gsi_stmt (gsi);
pp_bar (pp);
pp_write_text_to_stream (pp);
pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
pp_newline (pp);
pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
}
dump_implicit_edges (pp, bb, 0, dump_flags);
pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
}