GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "tree.h"
#include "gimple.h"
#include "predict.h"
#include "memmodel.h"
#include "tm_p.h"
#include "ssa.h"
#include "tree-ssa.h"
#include "tree-pretty-print.h"
#include "diagnostic-core.h"
#include "dumpfile.h"
#include "gimple-iterator.h"
#include "tree-ssa-live.h"
#include "tree-ssa-coalesce.h"
#include "explow.h"
#include "tree-dfa.h"
#include "stor-layout.h"
#include "gimple-lower-bitint.h"
Data Structures | |
struct | coalesce_pair |
struct | ssa_conflicts |
struct | coalesce_pair_hasher |
struct | cost_one_pair |
struct | coalesce_list |
class | live_track |
struct | ssa_name_var_hash |
Macros | |
#define | NO_BEST_COALESCE -1 |
#define | MUST_COALESCE_COST INT_MAX |
#define | FOR_EACH_PARTITION_PAIR(PAIR, ITER, CL) |
Typedefs | |
typedef hash_table< coalesce_pair_hasher > | coalesce_table_type |
typedef coalesce_table_type::iterator | coalesce_iterator_type |
Variables | |
static ssa_conflicts * | conflicts_ |
static var_map | map_ |
#define FOR_EACH_PARTITION_PAIR | ( | PAIR, | |
ITER, | |||
CL ) |
Iterate over CL using ITER, returning values in PAIR.
Referenced by compute_optimized_partition_bases(), dump_coalesce_list(), and sort_coalesce_list().
#define MUST_COALESCE_COST INT_MAX |
Referenced by add_coalesce(), coalesce_cost_edge(), and populate_coalesce_list_for_outofssa().
#define NO_BEST_COALESCE -1 |
Referenced by coalesce_partitions(), and pop_cost_one_pair().
|
inlinestatic |
Add a coalesce between P1 and P2 in list CL with a cost of VALUE.
References coalesce_pair::cost, find_coalesce_pair(), gcc_assert, MUST_COALESCE_COST, NULL, and coalesce_list::sorted.
Referenced by create_coalesce_list_for_region(), and populate_coalesce_list_for_outofssa().
|
inlinestatic |
References coalesce_list::cost_one_list, pair::next, and coalesce_list::ob.
Referenced by coalesce_with_default(), and create_coalesce_list_for_region().
|
inlinestatic |
Attempt to coalesce ssa versions X and Y together using the partition mapping in MAP and checking conflicts in GRAPH. Output any debug info to DEBUG, if it is nun-NULL.
References debug, map, NO_PARTITION, partition_to_var(), print_generic_expr(), ssa_conflicts_merge(), ssa_conflicts_test_p(), ssa_name, TDF_SLIM, var_to_partition(), var_union(), and y.
Referenced by coalesce_bitint(), and coalesce_partitions().
|
static |
Build a conflict graph based on LIVEINFO. Any partitions which are in the partition view of the var_map liveinfo is based on get entries in the conflict graph. Only conflicts between ssa_name partitions with the same base variable are added.
References build_bitint_stmt_ssa_conflicts(), cfun, delete_live_track(), ENTRY_BLOCK_PTR_FOR_FN, FOR_EACH_SSA_NAME, FOR_EACH_SSA_TREE_OPERAND, gimple_assign_copy_p(), gimple_assign_lhs(), gimple_assign_rhs1(), graph, gsi_end_p(), gsi_last_bb(), gsi_next(), gsi_prev(), gsi_start_phis(), gsi_stmt(), i, is_gimple_assign(), is_gimple_debug(), live_on_exit(), live_track_clear_base_vars(), live_track_clear_var(), live_track_init(), live_track_live_p(), live_track_process_def(), live_track_process_use(), live_var_map(), map, tree_live_info_d::map, new_live_track(), NULL, num_var_partitions(), PHI_RESULT, single_succ(), ssa_conflicts_new(), SSA_NAME_IS_DEFAULT_DEF, SSA_NAME_VAR, SSA_OP_DEF, SSA_OP_USE, TREE_CODE, VAR_P, _var_map::vec_bbs, and virtual_operand_p().
Referenced by coalesce_ssa_name().
|
static |
For the bitint lowering pass, try harder. Partitions which contain SSA_NAME default def of a PARM_DECL or have RESULT_DECL need to have compatible types because they will use that RESULT_DECL or PARM_DECL. Other partitions can have even incompatible _BitInt types, as long as they have the same size - those will use VAR_DECLs which are just arrays of the limbs.
References attempt_coalesce(), BITMAP_ALLOC, bitmap_bit_p, BITMAP_FREE, bitmap_set_bit, dump_file, dump_flags, EXECUTE_IF_SET_IN_BITMAP, i, map, NULL, num_var_partitions(), partition_to_var(), ssa_name, SSA_NAME_IS_DEFAULT_DEF, SSA_NAME_VAR, SSA_NAME_VERSION, TDF_DETAILS, TREE_CODE, tree_int_cst_equal(), TREE_TYPE, TYPE_SIZE, types_compatible_p(), and var_to_partition().
Referenced by coalesce_ssa_name().
|
inlinestatic |
Return cost of execution of copy instruction with FREQUENCY.
References frequency.
Referenced by coalesce_cost_bb(), coalesce_cost_edge(), and create_coalesce_list_for_region().
|
inlinestatic |
Return the cost of executing a copy instruction in basic block BB.
References cfun, coalesce_cost(), basic_block_def::count, optimize_bb_for_size_p(), and profile_count::to_frequency().
Referenced by create_coalesce_list_for_region(), and populate_coalesce_list_for_outofssa().
|
inlinestatic |
Return the cost of executing a copy instruction on edge E.
References coalesce_cost(), EDGE_CRITICAL_P, EDGE_FREQUENCY, FOR_EACH_EDGE, MUST_COALESCE_COST, and optimize_edge_for_size_p().
Referenced by create_coalesce_list_for_region().
|
static |
Attempt to Coalesce partitions in MAP which occur in the list CL using GRAPH. Debug output is sent to DEBUG if it is non-NULL.
References attempt_coalesce(), cfun, debug, fail_abnormal_edge_coalesce(), FOR_EACH_BB_FN, FOR_EACH_EDGE, gcc_assert, gimple_can_coalesce_p(), gsi_end_p(), gsi_next(), gsi_start_phis(), map, NO_BEST_COALESCE, gphi_iterator::phi(), PHI_ARG_DEF, PHI_RESULT, pop_best_coalesce(), basic_block_def::preds, ssa_name, SSA_NAME_IS_DEFAULT_DEF, SSA_NAME_VAR, SSA_NAME_VERSION, TREE_CODE, virtual_operand_p(), and y.
Referenced by coalesce_ssa_name().
|
extern |
Given an initial var_map MAP, coalesce variables and return a partition map with the resulting coalesce. Note that this function is called in either live range computation context or out-of-ssa context, indicated by MAP.
References bitmap_ior_into(), bitmap_list_view(), bitmap_tree_view(), build_ssa_conflict_graph(), calculate_live_ranges(), coalesce_bitint(), coalesce_partitions(), compute_optimized_partition_bases(), create_coalesce_list_for_region(), delete_coalesce_list(), delete_tree_live_info(), dump_coalesce_list(), dump_file, dump_flags, dump_live_info(), dump_var_map(), graph, LIVEDUMP_ENTRY, map, NULL, num_var_partitions(), partition_view_bitmap(), populate_coalesce_list_for_outofssa(), sort_coalesce_list(), ssa_conflicts_delete(), ssa_conflicts_dump(), and TDF_DETAILS.
Referenced by gimple_lower_bitint(), and remove_ssa_form().
|
static |
If VAR is an SSA_NAME associated with a PARM_DECL or a RESULT_DECL, and the DECL's default def is unused (i.e., it was introduced by create_default_def for out-of-ssa), mark VAR and the default def for coalescing.
References add_cost_one_coalesce(), bitmap_set_bit, cfun, has_zero_uses(), ssa_default_def(), SSA_NAME_IS_DEFAULT_DEF, SSA_NAME_VAR, SSA_NAME_VERSION, and VAR_P.
Referenced by populate_coalesce_list_for_outofssa().
|
static |
Comparison function to allow qsort to sort P1 and P2 in Ascending order.
References conflicts_, coalesce_pair::cost, initialize_conflict_count(), and map_.
Referenced by sort_coalesce_list().
|
static |
Fill in MAP's partition_to_base_index, with one index for each partition of SSA names USED_IN_COPIES and related by CL coalesce possibilities. This must match gimple_can_coalesce_p in the optimized case.
References coalesce_list::cost_one_list, count, dump_file, dump_flags, dump_part_var_map(), EXECUTE_IF_SET_IN_BITMAP, coalesce_pair::first_element, FOR_EACH_EDGE, FOR_EACH_PARTITION_PAIR, gcc_assert, gsi_end_p(), gsi_next(), gsi_start_phis(), i, map, cost_one_pair::next, num_var_partitions(), partition_to_var(), gphi_iterator::phi(), PHI_ARG_DEF, PHI_RESULT, basic_block_def::preds, coalesce_pair::second_element, coalesce_list::sorted, ssa_name, SSA_NAME_IS_DEFAULT_DEF, SSA_NAME_VAR, TDF_DETAILS, TREE_CODE, tree_int_cst_equal(), TREE_TYPE, TYPE_SIZE, var_to_partition(), and virtual_operand_p().
Referenced by coalesce_ssa_name().
|
inlinestatic |
Create a new empty coalesce list object and return it.
References coalesce_list::cost_one_list, gcc_obstack_init, coalesce_list::list, NULL, coalesce_list::num_sorted, num_ssa_names, coalesce_list::ob, and coalesce_list::sorted.
Referenced by create_coalesce_list_for_region().
|
static |
Given var_map MAP for a region, this function creates and returns a coalesce list as well as recording related ssa names in USED_IN_COPIES for use later in the out-of-ssa or live range computation process.
References add_coalesce(), add_cost_one_coalesce(), alloca, as_a(), bitmap_bit_p, bitmap_set_bit, cfun, coalesce_cost(), coalesce_cost_bb(), coalesce_cost_edge(), create_coalesce_list(), current_function_decl, DECL_RESULT, end(), gcc_assert, gimple_asm_input_op(), gimple_asm_ninputs(), gimple_asm_noutputs(), gimple_asm_output_op(), gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_ssa_name_copy_p(), gimple_can_coalesce_p(), gimple_phi_arg_edge(), gimple_phi_num_args(), gimple_phi_result(), gimple_return_retval(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_start_phis(), gsi_stmt(), has_single_use(), i, is_gimple_debug(), is_gimple_reg(), map, optimize_bb_for_size_p(), PHI_ARG_DEF, REG_BR_PROB_BASE, ssa_default_def(), SSA_NAME_VERSION, TREE_CODE, TREE_PURPOSE, TREE_STRING_POINTER, TREE_TYPE, TREE_VALUE, virtual_operand_p(), and VOID_TYPE_P.
Referenced by coalesce_ssa_name().
|
inlinestatic |
Delete coalesce list CL.
References coalesce_list::cost_one_list, free(), gcc_assert, coalesce_list::list, NULL, coalesce_list::num_sorted, coalesce_list::ob, and coalesce_list::sorted.
Referenced by coalesce_ssa_name().
|
static |
This routine will free the memory associated with PTR.
References bitmap_obstack_release(), live_track::live_base_partitions, and live_track::obstack.
Referenced by build_ssa_conflict_graph().
|
static |
Send debug info for coalesce list CL to file F.
References coalesce_pair::conflict_count, coalesce_pair::cost, coalesce_pair::first_element, FOR_EACH_PARTITION_PAIR, NULL, coalesce_list::num_sorted, print_generic_expr(), coalesce_pair::second_element, coalesce_list::sorted, ssa_name, and TDF_SLIM.
Referenced by coalesce_ssa_name().
Output partition map MAP with coalescing plan PART to file F.
References gcc_assert, map, NULL, NULL_TREE, num_ssa_names, partition_to_var(), print_generic_expr(), ssa_name, TDF_SLIM, var_to_partition(), version_to_var(), virtual_operand_p(), and y.
Referenced by compute_optimized_partition_bases().
|
inlinestatic |
Print a failure to coalesce a MUST_COALESCE pair X and Y.
References internal_error(), print_generic_expr(), print_generic_stmt(), ssa_name, TDF_SLIM, and y.
Referenced by coalesce_partitions().
|
static |
Find a matching coalesce pair object in CL for the pair P1 and P2. If one isn't found, return NULL if CREATE is false, otherwise create a new coalesce pair object and return it.
References hash_table< Descriptor, Lazy, Allocator >::find_slot_with_hash(), coalesce_pair::first_element, gcc_assert, coalesce_pair_hasher::hash(), coalesce_list::list, NULL, num_coalesce_pairs(), coalesce_list::ob, coalesce_pair::second_element, and coalesce_list::sorted.
Referenced by add_coalesce().
Given SSA_NAMEs NAME1 and NAME2, return true if they are candidates for coalescing together, false otherwise. This must stay consistent with compute_samebase_partition_bases and compute_optimized_partition_bases.
References DECL_IGNORED_P, DECL_MODE, LOCAL_DECL_ALIGNMENT, MINIMUM_ALIGNMENT, NULL_TREE, promote_ssa_mode(), SSA_NAME_VAR, TREE_TYPE, TYPE_ALIGN, TYPE_MODE, types_compatible_p(), use_register_for_decl(), and VAR_P.
Referenced by coalesce_partitions(), create_coalesce_list_for_region(), populate_coalesce_list_for_outofssa(), and uncprop_into_successor_phis().
|
static |
Compute and record how many unique conflicts would exist for the representative partition for each coalesce pair in CL. CONFLICTS is the conflict graph and MAP is the current partition view.
References bitmap_count_bits(), bitmap_count_unique_bits(), coalesce_pair::conflict_count, conflicts, coalesce_pair::first_element, map, coalesce_pair::second_element, ssa_name, and var_to_partition().
Referenced by compare_pairs().
|
inlinestatic |
This function will adds PARTITION to the live list in PTR.
References basevar_index(), bitmap_clear(), bitmap_set_bit, live_track::live_base_partitions, live_track::live_base_var, and live_track::map.
Referenced by live_track_init(), and live_track_process_use().
|
inlinestatic |
This routine will clear all live partitions in PTR.
References bitmap_clear(), and live_track::live_base_var.
Referenced by build_ssa_conflict_graph().
|
inlinestatic |
Clear the live bit for VAR in PTR.
References live_track_remove_partition(), live_track::map, NO_PARTITION, and var_to_partition().
Referenced by build_ssa_conflict_graph().
|
inlinestatic |
Initialize PTR with the partitions set in INIT.
References EXECUTE_IF_SET_IN_BITMAP, and live_track_add_partition().
Referenced by build_ssa_conflict_graph().
|
inlinestatic |
Return TRUE if VAR is live in PTR.
References basevar_index(), bitmap_bit_p, live_track::live_base_partitions, live_track::live_base_var, live_track::map, NO_PARTITION, and var_to_partition().
Referenced by build_ssa_conflict_graph().
|
inlinestatic |
This routine will process a DEF in PTR. DEF will be removed from the live lists, and if there are any other live partitions with the same base variable, conflicts will be added to GRAPH.
References b, basevar_index(), bitmap_bit_p, EXECUTE_IF_SET_IN_BITMAP, live_track::live_base_partitions, live_track::live_base_var, live_track_remove_partition(), live_track::map, NO_PARTITION, ssa_conflicts_add(), and var_to_partition().
Referenced by build_ssa_conflict_graph().
|
inlinestatic |
This routine will add USE to PTR. USE will be marked as live in both the ssa live map and the live bitmap for the root of USE.
References live_track_add_partition(), live_track::map, NO_PARTITION, and var_to_partition().
Referenced by build_ssa_conflict_graph().
|
inlinestatic |
This function will remove PARTITION from the live list in PTR.
References basevar_index(), bitmap_clear_bit(), bitmap_empty_p(), live_track::live_base_partitions, live_track::live_base_var, and live_track::map.
Referenced by live_track_clear_var(), and live_track_process_def().
|
static |
This routine will create a new live track structure based on the partitions in MAP.
References bitmap_initialize(), bitmap_obstack_initialize(), gcc_assert, live_track::live_base_partitions, live_track::live_base_var, live_track::map, map, NULL, num_basevars(), and live_track::obstack.
Referenced by build_ssa_conflict_graph().
|
inlinestatic |
Return the number of unique coalesce pairs in CL.
References hash_table< Descriptor, Lazy, Allocator >::elements(), and coalesce_list::list.
Referenced by find_coalesce_pair(), and sort_coalesce_list().
|
inlinestatic |
Retrieve the most expensive remaining pair to coalesce from CL. Returns the 2 elements via P1 and P2. Their calculated cost is returned by the function. NO_BEST_COALESCE is returned if the coalesce list is empty.
References coalesce_pair::cost, coalesce_pair::first_element, NULL, coalesce_list::num_sorted, pop_cost_one_pair(), coalesce_pair::second_element, and coalesce_list::sorted.
Referenced by coalesce_partitions().
|
inlinestatic |
Retrieve a pair to coalesce from the cost_one_list in CL. Returns the 2 elements via P1 and P2. 1 is returned by the function if there is a pair, NO_BEST_COALESCE is returned if there aren't any.
References coalesce_list::cost_one_list, cost_one_pair::first_element, cost_one_pair::next, NO_BEST_COALESCE, and cost_one_pair::second_element.
Referenced by pop_best_coalesce().
|
static |
This function populates coalesce list CL as well as recording related ssa names in USED_IN_COPIES for use later in the out-of-ssa process.
References a, add_coalesce(), bitmap_set_bit, cfun, coalesce_cost_bb(), coalesce_with_default(), DECL_IGNORED_P, EXIT_BLOCK_PTR_FOR_FN, hash_table< Descriptor, Lazy, Allocator >::find_slot(), FOR_EACH_SSA_NAME, gcc_assert, gimple_can_coalesce_p(), has_zero_uses(), i, MUST_COALESCE_COST, NULL_TREE, SSA_NAME_IS_DEFAULT_DEF, SSA_NAME_VAR, SSA_NAME_VERSION, TREE_CODE, VAR_P, and virtual_operand_p().
Referenced by coalesce_ssa_name().
|
static |
Prepare CL for removal of preferred pairs. When finished they are sorted in order from most important coalesce to least important.
References compare_pairs(), conflicts, conflicts_, FOR_EACH_PARTITION_PAIR, gcc_assert, map, map_, NULL, num_coalesce_pairs(), coalesce_list::num_sorted, qsort, and coalesce_list::sorted.
Referenced by coalesce_ssa_name().
|
inlinestatic |
Add conflicts between X and Y in graph PTR.
References gcc_checking_assert, ssa_conflicts_add_one(), and y.
Referenced by live_track_process_def().
|
inlinestatic |
Add a conflict with Y to the bitmap for X in graph PTR.
References BITMAP_ALLOC, bitmap_set_bit, ssa_conflicts::conflicts, ssa_conflicts::obstack, and y.
Referenced by ssa_conflicts_add().
|
inlinestatic |
Free storage for conflict graph PTR.
References bitmap_obstack_release(), ssa_conflicts::conflicts, free(), and ssa_conflicts::obstack.
Referenced by coalesce_ssa_name().
|
static |
Dump a conflicts graph.
References b, ssa_conflicts::conflicts, dump_bitmap(), and FOR_EACH_VEC_ELT.
Referenced by coalesce_ssa_name().
|
inlinestatic |
Merge all Y's conflict into X in graph PTR.
References bitmap_clear_bit(), BITMAP_FREE, bitmap_ior_into(), bitmap_set_bit, ssa_conflicts::conflicts, EXECUTE_IF_SET_IN_BITMAP, gcc_checking_assert, NULL, and y.
Referenced by attempt_coalesce().
|
inlinestatic |
Return an empty new conflict graph for SIZE elements.
References bitmap_obstack_initialize(), ssa_conflicts::conflicts, and ssa_conflicts::obstack.
Referenced by build_ssa_conflict_graph().
|
inlinestatic |
Test if elements X and Y conflict in graph PTR.
References bitmap_bit_p, ssa_conflicts::conflicts, gcc_checking_assert, and y.
Referenced by attempt_coalesce().
|
static |
The narrow API of the qsort comparison function doesn't allow easy access to additional arguments. So we have two globals (ick) to hold the data we need. They're initialized before the call to qsort and wiped immediately after.
Referenced by compare_pairs(), and sort_coalesce_list().
|
static |
Referenced by compare_pairs(), and sort_coalesce_list().