538dd0b78f
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
787 lines
20 KiB
C
787 lines
20 KiB
C
/* Single entry single exit control flow regions.
|
||
Copyright (C) 2008-2014 Free Software Foundation, Inc.
|
||
Contributed by Jan Sjodin <jan.sjodin@amd.com> and
|
||
Sebastian Pop <sebastian.pop@amd.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 "hash-map.h"
|
||
#include "tree.h"
|
||
#include "tree-pretty-print.h"
|
||
#include "predict.h"
|
||
#include "vec.h"
|
||
#include "hashtab.h"
|
||
#include "hash-set.h"
|
||
#include "machmode.h"
|
||
#include "tm.h"
|
||
#include "hard-reg-set.h"
|
||
#include "input.h"
|
||
#include "function.h"
|
||
#include "dominance.h"
|
||
#include "cfg.h"
|
||
#include "basic-block.h"
|
||
#include "tree-ssa-alias.h"
|
||
#include "internal-fn.h"
|
||
#include "gimple-fold.h"
|
||
#include "tree-eh.h"
|
||
#include "gimple-expr.h"
|
||
#include "is-a.h"
|
||
#include "gimple.h"
|
||
#include "gimplify.h"
|
||
#include "gimple-iterator.h"
|
||
#include "gimplify-me.h"
|
||
#include "gimple-ssa.h"
|
||
#include "tree-cfg.h"
|
||
#include "tree-phinodes.h"
|
||
#include "ssa-iterators.h"
|
||
#include "stringpool.h"
|
||
#include "tree-ssanames.h"
|
||
#include "tree-ssa-loop.h"
|
||
#include "tree-into-ssa.h"
|
||
#include "cfgloop.h"
|
||
#include "tree-chrec.h"
|
||
#include "tree-data-ref.h"
|
||
#include "tree-scalar-evolution.h"
|
||
#include "tree-pass.h"
|
||
#include "value-prof.h"
|
||
#include "sese.h"
|
||
#include "tree-ssa-propagate.h"
|
||
|
||
/* Helper function for debug_rename_map. */
|
||
|
||
bool
|
||
debug_rename_map_1 (tree_node *const &old_name, tree_node *const &expr,
|
||
void *)
|
||
{
|
||
fprintf (stderr, "(");
|
||
print_generic_expr (stderr, old_name, 0);
|
||
fprintf (stderr, ", ");
|
||
print_generic_expr (stderr, expr, 0);
|
||
fprintf (stderr, ")\n");
|
||
return true;
|
||
}
|
||
|
||
|
||
/* Hashtable helpers. */
|
||
|
||
struct rename_map_hasher : default_hashmap_traits
|
||
{
|
||
static inline hashval_t hash (tree);
|
||
};
|
||
|
||
/* Computes a hash function for database element ELT. */
|
||
|
||
inline hashval_t
|
||
rename_map_hasher::hash (tree old_name)
|
||
{
|
||
return SSA_NAME_VERSION (old_name);
|
||
}
|
||
|
||
typedef hash_map<tree, tree, rename_map_hasher> rename_map_type;
|
||
|
||
|
||
/* Print to stderr all the elements of RENAME_MAP. */
|
||
|
||
DEBUG_FUNCTION void
|
||
debug_rename_map (rename_map_type *rename_map)
|
||
{
|
||
rename_map->traverse <void *, debug_rename_map_1> (NULL);
|
||
}
|
||
|
||
|
||
/* Record LOOP as occurring in REGION. */
|
||
|
||
static void
|
||
sese_record_loop (sese region, loop_p loop)
|
||
{
|
||
if (sese_contains_loop (region, loop))
|
||
return;
|
||
|
||
bitmap_set_bit (SESE_LOOPS (region), loop->num);
|
||
SESE_LOOP_NEST (region).safe_push (loop);
|
||
}
|
||
|
||
/* Build the loop nests contained in REGION. Returns true when the
|
||
operation was successful. */
|
||
|
||
void
|
||
build_sese_loop_nests (sese region)
|
||
{
|
||
unsigned i;
|
||
basic_block bb;
|
||
struct loop *loop0, *loop1;
|
||
|
||
FOR_EACH_BB_FN (bb, cfun)
|
||
if (bb_in_sese_p (bb, region))
|
||
{
|
||
struct loop *loop = bb->loop_father;
|
||
|
||
/* Only add loops if they are completely contained in the SCoP. */
|
||
if (loop->header == bb
|
||
&& bb_in_sese_p (loop->latch, region))
|
||
sese_record_loop (region, loop);
|
||
}
|
||
|
||
/* Make sure that the loops in the SESE_LOOP_NEST are ordered. It
|
||
can be the case that an inner loop is inserted before an outer
|
||
loop. To avoid this, semi-sort once. */
|
||
FOR_EACH_VEC_ELT (SESE_LOOP_NEST (region), i, loop0)
|
||
{
|
||
if (SESE_LOOP_NEST (region).length () == i + 1)
|
||
break;
|
||
|
||
loop1 = SESE_LOOP_NEST (region)[i + 1];
|
||
if (loop0->num > loop1->num)
|
||
{
|
||
SESE_LOOP_NEST (region)[i] = loop1;
|
||
SESE_LOOP_NEST (region)[i + 1] = loop0;
|
||
}
|
||
}
|
||
}
|
||
|
||
/* For a USE in BB, if BB is outside REGION, mark the USE in the
|
||
LIVEOUTS set. */
|
||
|
||
static void
|
||
sese_build_liveouts_use (sese region, bitmap liveouts, basic_block bb,
|
||
tree use)
|
||
{
|
||
unsigned ver;
|
||
basic_block def_bb;
|
||
|
||
if (TREE_CODE (use) != SSA_NAME)
|
||
return;
|
||
|
||
ver = SSA_NAME_VERSION (use);
|
||
def_bb = gimple_bb (SSA_NAME_DEF_STMT (use));
|
||
|
||
if (!def_bb
|
||
|| !bb_in_sese_p (def_bb, region)
|
||
|| bb_in_sese_p (bb, region))
|
||
return;
|
||
|
||
bitmap_set_bit (liveouts, ver);
|
||
}
|
||
|
||
/* Marks for rewrite all the SSA_NAMES defined in REGION and that are
|
||
used in BB that is outside of the REGION. */
|
||
|
||
static void
|
||
sese_build_liveouts_bb (sese region, bitmap liveouts, basic_block bb)
|
||
{
|
||
edge e;
|
||
edge_iterator ei;
|
||
ssa_op_iter iter;
|
||
use_operand_p use_p;
|
||
|
||
FOR_EACH_EDGE (e, ei, bb->succs)
|
||
for (gphi_iterator bsi = gsi_start_phis (e->dest); !gsi_end_p (bsi);
|
||
gsi_next (&bsi))
|
||
sese_build_liveouts_use (region, liveouts, bb,
|
||
PHI_ARG_DEF_FROM_EDGE (bsi.phi (), e));
|
||
|
||
for (gimple_stmt_iterator bsi = gsi_start_bb (bb); !gsi_end_p (bsi);
|
||
gsi_next (&bsi))
|
||
{
|
||
gimple stmt = gsi_stmt (bsi);
|
||
|
||
if (is_gimple_debug (stmt))
|
||
continue;
|
||
|
||
FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_ALL_USES)
|
||
sese_build_liveouts_use (region, liveouts, bb, USE_FROM_PTR (use_p));
|
||
}
|
||
}
|
||
|
||
/* For a USE in BB, return true if BB is outside REGION and it's not
|
||
in the LIVEOUTS set. */
|
||
|
||
static bool
|
||
sese_bad_liveouts_use (sese region, bitmap liveouts, basic_block bb,
|
||
tree use)
|
||
{
|
||
unsigned ver;
|
||
basic_block def_bb;
|
||
|
||
if (TREE_CODE (use) != SSA_NAME)
|
||
return false;
|
||
|
||
ver = SSA_NAME_VERSION (use);
|
||
|
||
/* If it's in liveouts, the variable will get a new PHI node, and
|
||
the debug use will be properly adjusted. */
|
||
if (bitmap_bit_p (liveouts, ver))
|
||
return false;
|
||
|
||
def_bb = gimple_bb (SSA_NAME_DEF_STMT (use));
|
||
|
||
if (!def_bb
|
||
|| !bb_in_sese_p (def_bb, region)
|
||
|| bb_in_sese_p (bb, region))
|
||
return false;
|
||
|
||
return true;
|
||
}
|
||
|
||
/* Reset debug stmts that reference SSA_NAMES defined in REGION that
|
||
are not marked as liveouts. */
|
||
|
||
static void
|
||
sese_reset_debug_liveouts_bb (sese region, bitmap liveouts, basic_block bb)
|
||
{
|
||
gimple_stmt_iterator bsi;
|
||
ssa_op_iter iter;
|
||
use_operand_p use_p;
|
||
|
||
for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi))
|
||
{
|
||
gimple stmt = gsi_stmt (bsi);
|
||
|
||
if (!is_gimple_debug (stmt))
|
||
continue;
|
||
|
||
FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_ALL_USES)
|
||
if (sese_bad_liveouts_use (region, liveouts, bb,
|
||
USE_FROM_PTR (use_p)))
|
||
{
|
||
gimple_debug_bind_reset_value (stmt);
|
||
update_stmt (stmt);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
/* Build the LIVEOUTS of REGION: the set of variables defined inside
|
||
and used outside the REGION. */
|
||
|
||
static void
|
||
sese_build_liveouts (sese region, bitmap liveouts)
|
||
{
|
||
basic_block bb;
|
||
|
||
FOR_EACH_BB_FN (bb, cfun)
|
||
sese_build_liveouts_bb (region, liveouts, bb);
|
||
if (MAY_HAVE_DEBUG_STMTS)
|
||
FOR_EACH_BB_FN (bb, cfun)
|
||
sese_reset_debug_liveouts_bb (region, liveouts, bb);
|
||
}
|
||
|
||
/* Builds a new SESE region from edges ENTRY and EXIT. */
|
||
|
||
sese
|
||
new_sese (edge entry, edge exit)
|
||
{
|
||
sese region = XNEW (struct sese_s);
|
||
|
||
SESE_ENTRY (region) = entry;
|
||
SESE_EXIT (region) = exit;
|
||
SESE_LOOPS (region) = BITMAP_ALLOC (NULL);
|
||
SESE_LOOP_NEST (region).create (3);
|
||
SESE_ADD_PARAMS (region) = true;
|
||
SESE_PARAMS (region).create (3);
|
||
|
||
return region;
|
||
}
|
||
|
||
/* Deletes REGION. */
|
||
|
||
void
|
||
free_sese (sese region)
|
||
{
|
||
if (SESE_LOOPS (region))
|
||
SESE_LOOPS (region) = BITMAP_ALLOC (NULL);
|
||
|
||
SESE_PARAMS (region).release ();
|
||
SESE_LOOP_NEST (region).release ();
|
||
|
||
XDELETE (region);
|
||
}
|
||
|
||
/* Add exit phis for USE on EXIT. */
|
||
|
||
static void
|
||
sese_add_exit_phis_edge (basic_block exit, tree use, edge false_e, edge true_e)
|
||
{
|
||
gphi *phi = create_phi_node (NULL_TREE, exit);
|
||
create_new_def_for (use, phi, gimple_phi_result_ptr (phi));
|
||
add_phi_arg (phi, use, false_e, UNKNOWN_LOCATION);
|
||
add_phi_arg (phi, use, true_e, UNKNOWN_LOCATION);
|
||
}
|
||
|
||
/* Insert in the block BB phi nodes for variables defined in REGION
|
||
and used outside the REGION. The code generation moves REGION in
|
||
the else clause of an "if (1)" and generates code in the then
|
||
clause that is at this point empty:
|
||
|
||
| if (1)
|
||
| empty;
|
||
| else
|
||
| REGION;
|
||
*/
|
||
|
||
void
|
||
sese_insert_phis_for_liveouts (sese region, basic_block bb,
|
||
edge false_e, edge true_e)
|
||
{
|
||
unsigned i;
|
||
bitmap_iterator bi;
|
||
bitmap liveouts = BITMAP_ALLOC (NULL);
|
||
|
||
update_ssa (TODO_update_ssa);
|
||
|
||
sese_build_liveouts (region, liveouts);
|
||
EXECUTE_IF_SET_IN_BITMAP (liveouts, 0, i, bi)
|
||
sese_add_exit_phis_edge (bb, ssa_name (i), false_e, true_e);
|
||
BITMAP_FREE (liveouts);
|
||
|
||
update_ssa (TODO_update_ssa);
|
||
}
|
||
|
||
/* Returns the first successor edge of BB with EDGE_TRUE_VALUE flag set. */
|
||
|
||
edge
|
||
get_true_edge_from_guard_bb (basic_block bb)
|
||
{
|
||
edge e;
|
||
edge_iterator ei;
|
||
|
||
FOR_EACH_EDGE (e, ei, bb->succs)
|
||
if (e->flags & EDGE_TRUE_VALUE)
|
||
return e;
|
||
|
||
gcc_unreachable ();
|
||
return NULL;
|
||
}
|
||
|
||
/* Returns the first successor edge of BB with EDGE_TRUE_VALUE flag cleared. */
|
||
|
||
edge
|
||
get_false_edge_from_guard_bb (basic_block bb)
|
||
{
|
||
edge e;
|
||
edge_iterator ei;
|
||
|
||
FOR_EACH_EDGE (e, ei, bb->succs)
|
||
if (!(e->flags & EDGE_TRUE_VALUE))
|
||
return e;
|
||
|
||
gcc_unreachable ();
|
||
return NULL;
|
||
}
|
||
|
||
/* Returns the expression associated to OLD_NAME in RENAME_MAP. */
|
||
|
||
static tree
|
||
get_rename (rename_map_type *rename_map, tree old_name)
|
||
{
|
||
gcc_assert (TREE_CODE (old_name) == SSA_NAME);
|
||
tree *expr = rename_map->get (old_name);
|
||
if (expr)
|
||
return *expr;
|
||
|
||
return NULL_TREE;
|
||
}
|
||
|
||
/* Register in RENAME_MAP the rename tuple (OLD_NAME, EXPR). */
|
||
|
||
static void
|
||
set_rename (rename_map_type *rename_map, tree old_name, tree expr)
|
||
{
|
||
if (old_name == expr)
|
||
return;
|
||
|
||
rename_map->put (old_name, expr);
|
||
}
|
||
|
||
/* Renames the scalar uses of the statement COPY, using the
|
||
substitution map RENAME_MAP, inserting the gimplification code at
|
||
GSI_TGT, for the translation REGION, with the original copied
|
||
statement in LOOP, and using the induction variable renaming map
|
||
IV_MAP. Returns true when something has been renamed. GLOOG_ERROR
|
||
is set when the code generation cannot continue. */
|
||
|
||
static bool
|
||
rename_uses (gimple copy, rename_map_type *rename_map,
|
||
gimple_stmt_iterator *gsi_tgt,
|
||
sese region, loop_p loop, vec<tree> iv_map,
|
||
bool *gloog_error)
|
||
{
|
||
use_operand_p use_p;
|
||
ssa_op_iter op_iter;
|
||
bool changed = false;
|
||
|
||
if (is_gimple_debug (copy))
|
||
{
|
||
if (gimple_debug_bind_p (copy))
|
||
gimple_debug_bind_reset_value (copy);
|
||
else if (gimple_debug_source_bind_p (copy))
|
||
return false;
|
||
else
|
||
gcc_unreachable ();
|
||
|
||
return false;
|
||
}
|
||
|
||
FOR_EACH_SSA_USE_OPERAND (use_p, copy, op_iter, SSA_OP_USE)
|
||
{
|
||
tree old_name = USE_FROM_PTR (use_p);
|
||
tree new_expr, scev;
|
||
gimple_seq stmts;
|
||
|
||
if (TREE_CODE (old_name) != SSA_NAME
|
||
|| SSA_NAME_IS_DEFAULT_DEF (old_name))
|
||
continue;
|
||
|
||
changed = true;
|
||
new_expr = get_rename (rename_map, old_name);
|
||
if (new_expr)
|
||
{
|
||
tree type_old_name = TREE_TYPE (old_name);
|
||
tree type_new_expr = TREE_TYPE (new_expr);
|
||
|
||
if (type_old_name != type_new_expr
|
||
|| TREE_CODE (new_expr) != SSA_NAME)
|
||
{
|
||
tree var = create_tmp_var (type_old_name, "var");
|
||
|
||
if (!useless_type_conversion_p (type_old_name, type_new_expr))
|
||
new_expr = fold_convert (type_old_name, new_expr);
|
||
|
||
new_expr = force_gimple_operand (new_expr, &stmts, true, var);
|
||
gsi_insert_seq_before (gsi_tgt, stmts, GSI_SAME_STMT);
|
||
}
|
||
|
||
replace_exp (use_p, new_expr);
|
||
continue;
|
||
}
|
||
|
||
scev = scalar_evolution_in_region (region, loop, old_name);
|
||
|
||
/* At this point we should know the exact scev for each
|
||
scalar SSA_NAME used in the scop: all the other scalar
|
||
SSA_NAMEs should have been translated out of SSA using
|
||
arrays with one element. */
|
||
if (chrec_contains_undetermined (scev))
|
||
{
|
||
*gloog_error = true;
|
||
new_expr = build_zero_cst (TREE_TYPE (old_name));
|
||
}
|
||
else
|
||
new_expr = chrec_apply_map (scev, iv_map);
|
||
|
||
/* The apply should produce an expression tree containing
|
||
the uses of the new induction variables. We should be
|
||
able to use new_expr instead of the old_name in the newly
|
||
generated loop nest. */
|
||
if (chrec_contains_undetermined (new_expr)
|
||
|| tree_contains_chrecs (new_expr, NULL))
|
||
{
|
||
*gloog_error = true;
|
||
new_expr = build_zero_cst (TREE_TYPE (old_name));
|
||
}
|
||
else
|
||
/* Replace the old_name with the new_expr. */
|
||
new_expr = force_gimple_operand (unshare_expr (new_expr), &stmts,
|
||
true, NULL_TREE);
|
||
|
||
gsi_insert_seq_before (gsi_tgt, stmts, GSI_SAME_STMT);
|
||
replace_exp (use_p, new_expr);
|
||
|
||
if (TREE_CODE (new_expr) == INTEGER_CST
|
||
&& is_gimple_assign (copy))
|
||
{
|
||
tree rhs = gimple_assign_rhs1 (copy);
|
||
|
||
if (TREE_CODE (rhs) == ADDR_EXPR)
|
||
recompute_tree_invariant_for_addr_expr (rhs);
|
||
}
|
||
|
||
set_rename (rename_map, old_name, new_expr);
|
||
}
|
||
|
||
return changed;
|
||
}
|
||
|
||
/* Duplicates the statements of basic block BB into basic block NEW_BB
|
||
and compute the new induction variables according to the IV_MAP.
|
||
GLOOG_ERROR is set when the code generation cannot continue. */
|
||
|
||
static void
|
||
graphite_copy_stmts_from_block (basic_block bb, basic_block new_bb,
|
||
rename_map_type *rename_map,
|
||
vec<tree> iv_map, sese region,
|
||
bool *gloog_error)
|
||
{
|
||
gimple_stmt_iterator gsi, gsi_tgt;
|
||
loop_p loop = bb->loop_father;
|
||
|
||
gsi_tgt = gsi_start_bb (new_bb);
|
||
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
|
||
{
|
||
def_operand_p def_p;
|
||
ssa_op_iter op_iter;
|
||
gimple stmt = gsi_stmt (gsi);
|
||
gimple copy;
|
||
tree lhs;
|
||
|
||
/* Do not copy labels or conditions. */
|
||
if (gimple_code (stmt) == GIMPLE_LABEL
|
||
|| gimple_code (stmt) == GIMPLE_COND)
|
||
continue;
|
||
|
||
/* Do not copy induction variables. */
|
||
if (is_gimple_assign (stmt)
|
||
&& (lhs = gimple_assign_lhs (stmt))
|
||
&& TREE_CODE (lhs) == SSA_NAME
|
||
&& is_gimple_reg (lhs)
|
||
&& scev_analyzable_p (lhs, region))
|
||
continue;
|
||
|
||
/* Create a new copy of STMT and duplicate STMT's virtual
|
||
operands. */
|
||
copy = gimple_copy (stmt);
|
||
gsi_insert_after (&gsi_tgt, copy, GSI_NEW_STMT);
|
||
|
||
maybe_duplicate_eh_stmt (copy, stmt);
|
||
gimple_duplicate_stmt_histograms (cfun, copy, cfun, stmt);
|
||
|
||
/* Create new names for all the definitions created by COPY and
|
||
add replacement mappings for each new name. */
|
||
FOR_EACH_SSA_DEF_OPERAND (def_p, copy, op_iter, SSA_OP_ALL_DEFS)
|
||
{
|
||
tree old_name = DEF_FROM_PTR (def_p);
|
||
tree new_name = create_new_def_for (old_name, copy, def_p);
|
||
set_rename (rename_map, old_name, new_name);
|
||
}
|
||
|
||
if (rename_uses (copy, rename_map, &gsi_tgt, region, loop, iv_map,
|
||
gloog_error))
|
||
{
|
||
gcc_assert (gsi_stmt (gsi_tgt) == copy);
|
||
fold_stmt_inplace (&gsi_tgt);
|
||
}
|
||
|
||
update_stmt (copy);
|
||
}
|
||
}
|
||
|
||
/* Copies BB and includes in the copied BB all the statements that can
|
||
be reached following the use-def chains from the memory accesses,
|
||
and returns the next edge following this new block. GLOOG_ERROR is
|
||
set when the code generation cannot continue. */
|
||
|
||
edge
|
||
copy_bb_and_scalar_dependences (basic_block bb, sese region,
|
||
edge next_e, vec<tree> iv_map,
|
||
bool *gloog_error)
|
||
{
|
||
basic_block new_bb = split_edge (next_e);
|
||
rename_map_type rename_map (10);
|
||
|
||
next_e = single_succ_edge (new_bb);
|
||
graphite_copy_stmts_from_block (bb, new_bb, &rename_map, iv_map, region,
|
||
gloog_error);
|
||
remove_phi_nodes (new_bb);
|
||
|
||
return next_e;
|
||
}
|
||
|
||
/* Returns the outermost loop in SCOP that contains BB. */
|
||
|
||
struct loop *
|
||
outermost_loop_in_sese (sese region, basic_block bb)
|
||
{
|
||
struct loop *nest;
|
||
|
||
nest = bb->loop_father;
|
||
while (loop_outer (nest)
|
||
&& loop_in_sese_p (loop_outer (nest), region))
|
||
nest = loop_outer (nest);
|
||
|
||
return nest;
|
||
}
|
||
|
||
/* Sets the false region of an IF_REGION to REGION. */
|
||
|
||
void
|
||
if_region_set_false_region (ifsese if_region, sese region)
|
||
{
|
||
basic_block condition = if_region_get_condition_block (if_region);
|
||
edge false_edge = get_false_edge_from_guard_bb (condition);
|
||
basic_block dummy = false_edge->dest;
|
||
edge entry_region = SESE_ENTRY (region);
|
||
edge exit_region = SESE_EXIT (region);
|
||
basic_block before_region = entry_region->src;
|
||
basic_block last_in_region = exit_region->src;
|
||
hashval_t hash = htab_hash_pointer (exit_region);
|
||
loop_exit **slot
|
||
= current_loops->exits->find_slot_with_hash (exit_region, hash, NO_INSERT);
|
||
|
||
entry_region->flags = false_edge->flags;
|
||
false_edge->flags = exit_region->flags;
|
||
|
||
redirect_edge_pred (entry_region, condition);
|
||
redirect_edge_pred (exit_region, before_region);
|
||
redirect_edge_pred (false_edge, last_in_region);
|
||
redirect_edge_succ (false_edge, single_succ (dummy));
|
||
delete_basic_block (dummy);
|
||
|
||
exit_region->flags = EDGE_FALLTHRU;
|
||
recompute_all_dominators ();
|
||
|
||
SESE_EXIT (region) = false_edge;
|
||
|
||
free (if_region->false_region);
|
||
if_region->false_region = region;
|
||
|
||
if (slot)
|
||
{
|
||
struct loop_exit *loop_exit = ggc_cleared_alloc<struct loop_exit> ();
|
||
|
||
memcpy (loop_exit, *((struct loop_exit **) slot), sizeof (struct loop_exit));
|
||
current_loops->exits->clear_slot (slot);
|
||
|
||
hashval_t hash = htab_hash_pointer (false_edge);
|
||
slot = current_loops->exits->find_slot_with_hash (false_edge, hash,
|
||
INSERT);
|
||
loop_exit->e = false_edge;
|
||
*slot = loop_exit;
|
||
false_edge->src->loop_father->exits->next = loop_exit;
|
||
}
|
||
}
|
||
|
||
/* Creates an IFSESE with CONDITION on edge ENTRY. */
|
||
|
||
static ifsese
|
||
create_if_region_on_edge (edge entry, tree condition)
|
||
{
|
||
edge e;
|
||
edge_iterator ei;
|
||
sese sese_region = XNEW (struct sese_s);
|
||
sese true_region = XNEW (struct sese_s);
|
||
sese false_region = XNEW (struct sese_s);
|
||
ifsese if_region = XNEW (struct ifsese_s);
|
||
edge exit = create_empty_if_region_on_edge (entry, condition);
|
||
|
||
if_region->region = sese_region;
|
||
if_region->region->entry = entry;
|
||
if_region->region->exit = exit;
|
||
|
||
FOR_EACH_EDGE (e, ei, entry->dest->succs)
|
||
{
|
||
if (e->flags & EDGE_TRUE_VALUE)
|
||
{
|
||
true_region->entry = e;
|
||
true_region->exit = single_succ_edge (e->dest);
|
||
if_region->true_region = true_region;
|
||
}
|
||
else if (e->flags & EDGE_FALSE_VALUE)
|
||
{
|
||
false_region->entry = e;
|
||
false_region->exit = single_succ_edge (e->dest);
|
||
if_region->false_region = false_region;
|
||
}
|
||
}
|
||
|
||
return if_region;
|
||
}
|
||
|
||
/* Moves REGION in a condition expression:
|
||
| if (1)
|
||
| ;
|
||
| else
|
||
| REGION;
|
||
*/
|
||
|
||
ifsese
|
||
move_sese_in_condition (sese region)
|
||
{
|
||
basic_block pred_block = split_edge (SESE_ENTRY (region));
|
||
ifsese if_region;
|
||
|
||
SESE_ENTRY (region) = single_succ_edge (pred_block);
|
||
if_region = create_if_region_on_edge (single_pred_edge (pred_block), integer_one_node);
|
||
if_region_set_false_region (if_region, region);
|
||
|
||
return if_region;
|
||
}
|
||
|
||
/* Replaces the condition of the IF_REGION with CONDITION:
|
||
| if (CONDITION)
|
||
| true_region;
|
||
| else
|
||
| false_region;
|
||
*/
|
||
|
||
void
|
||
set_ifsese_condition (ifsese if_region, tree condition)
|
||
{
|
||
sese region = if_region->region;
|
||
edge entry = region->entry;
|
||
basic_block bb = entry->dest;
|
||
gimple last = last_stmt (bb);
|
||
gimple_stmt_iterator gsi = gsi_last_bb (bb);
|
||
gcond *cond_stmt;
|
||
|
||
gcc_assert (gimple_code (last) == GIMPLE_COND);
|
||
|
||
gsi_remove (&gsi, true);
|
||
gsi = gsi_last_bb (bb);
|
||
condition = force_gimple_operand_gsi (&gsi, condition, true, NULL,
|
||
false, GSI_NEW_STMT);
|
||
cond_stmt = gimple_build_cond_from_tree (condition, NULL_TREE, NULL_TREE);
|
||
gsi = gsi_last_bb (bb);
|
||
gsi_insert_after (&gsi, cond_stmt, GSI_NEW_STMT);
|
||
}
|
||
|
||
/* Returns the scalar evolution of T in REGION. Every variable that
|
||
is not defined in the REGION is considered a parameter. */
|
||
|
||
tree
|
||
scalar_evolution_in_region (sese region, loop_p loop, tree t)
|
||
{
|
||
gimple def;
|
||
struct loop *def_loop;
|
||
basic_block before = block_before_sese (region);
|
||
|
||
/* SCOP parameters. */
|
||
if (TREE_CODE (t) == SSA_NAME
|
||
&& !defined_in_sese_p (t, region))
|
||
return t;
|
||
|
||
if (TREE_CODE (t) != SSA_NAME
|
||
|| loop_in_sese_p (loop, region))
|
||
return instantiate_scev (before, loop,
|
||
analyze_scalar_evolution (loop, t));
|
||
|
||
def = SSA_NAME_DEF_STMT (t);
|
||
def_loop = loop_containing_stmt (def);
|
||
|
||
if (loop_in_sese_p (def_loop, region))
|
||
{
|
||
t = analyze_scalar_evolution (def_loop, t);
|
||
def_loop = superloop_at_depth (def_loop, loop_depth (loop) + 1);
|
||
t = compute_overall_effect_of_inner_loop (def_loop, t);
|
||
return t;
|
||
}
|
||
else
|
||
return instantiate_scev (before, loop, t);
|
||
}
|