constant.cc File Reference
Go to the source code of this file.
|
Functions |
| static Boolean | _substitutable_type (EXPR_TYPE type, PC_REAL_BOOL subst_reals) |
| | substitutable_type Returns true if the given type may be legally substituted
|
| static void | _add_refs (RefSet< Symbol > &vars, const RefSet< Expression > &refs) |
| | add_refs - Add the given set of references to the given variable set.
|
| static void | _filter_vars (RefSet< Symbol > &vars, PC_REAL_BOOL subst_reals, PC_ARRAY_BOOL subst_arrays) |
| | filter_vars - Filter out all variables from the given set that are disallowed by my switch values.
|
| static void | _init_candidates (const RefSet< Symbol > &def_vars, const RefSet< Symbol > &use_vars, Map< Symbol, IntElem > &def_candidates, Map< Symbol, IntElem > &use_candidates, Array< Symbol * > &tag_to_candidate) |
| | init_candidates - Initialize def_candidates and use_candidates to be mappings from elements in def_vars or use_vars to integers.
|
| static void | _collect_candidates (const RefSet< Symbol > &def_vars, const StmtList &stmts, const Statement &first_stmt, const Statement &last_stmt, Map< Symbol, IntElem > &def_candidates, Map< Symbol, IntElem > &use_candidates, Array< Symbol * > &tag_to_candidate) |
| | collect_candidates - Determine all the variables that are candidates for forward substitution and initialize the _candidates and _tag_to_candidates data structures to contain these variables.
|
| static void | _collect_candidates (const StmtList &stmts, const Statement &first_stmt, const Statement &last_stmt, Map< Symbol, IntElem > &def_candidates, Map< Symbol, IntElem > &use_candidates, Array< Symbol * > &tag_to_candidate, PC_REAL_BOOL subst_reals, PC_ARRAY_BOOL subst_arrays) |
| static List< Statement > * | _create_data_assigns (ProgramUnit &pgm, const RefSet< Symbol > *candidates, PC_REAL_BOOL subst_reals) |
| | create_data_assigns - Create a list of pseudo assignment statements which assign all variables in the program unit's data statements to their constant values.
|
| static void | _add_data_assigns (ProgramUnit &pgm, const RefSet< Symbol > *candidates, PC_REAL_BOOL subst_reals, RefSet< Statement > &pseudo_stmts) |
| | add_data_assigns - Add a list of pseudo assignment statements at the beginning of a program unit which assign all variables in the program unit's data statements to their constant values.
|
| static void | _add_control_assigns (StmtList &stmts, const Statement &first_stmt, const Statement &last_stmt, const RefSet< Symbol > *candidates, RefSet< Statement > &pseudo_stmts) |
| | add_control_assigns - Add a list of pseudo assignment statements at the start of the loop bodies of IF statements that represent constants derived from the conditional statement of the IF statement.
|
| static void | _init_workspaces (StmtList &stmts, const Statement &first_stmt, const Statement &last_stmt, const Map< Symbol, IntElem > &def_candidates, const Map< Symbol, IntElem > &use_candidates, const Array< Symbol * > &tag_to_candidate) |
| | init_workspaces Initialize the workspaces for each statement in the program.
|
| static PropConstWS & | _get_workspace (const Statement &stmt) |
| | get_workspace Get the workspace for the given statement.
|
| static void | _dump_workspaces (ostream &o, const StmtList &stmts, const Statement &first_stmt, const Statement &last_stmt) |
| | dump_workspaces Dump out the data inside all of the workspaces of the program
|
| static void | _make_nonlocals_modified_at_calls (StmtList &stmts, const Statement &first_stmt, const Statement &last_stmt, const Map< Symbol, IntElem > &use_candidates, const Array< Symbol * > &tag_to_candidate) |
| | _make_nonlocals_modified_at_calls Make all non-local variables be marked as potentially modified for all call statements and all statements containing function calls.
|
| static void | _patch_flow_graph (StmtList &stmts, const Statement &first_stmt, const Statement &last_stmt) |
| | patch_flow_graph Add flow edges from all ENDDO statements in the flow graph to the statement following the ENDDO.
|
| static int | _num_stmts_in_block (const StmtList &stmts, const Statement &first_stmt, const Statement &last_stmt) |
| | num_stmts_in_block Return the number of statements in the given block.
|
| static void | _determine_entry_points (StmtList &stmts, const Statement &first_stmt, const Statement &last_stmt, RefSet< Statement > &entry_points) |
| | determine_entry_points.
|
| static void | _calc_toporder1 (PropConstWS &my_ws, int &toporder) |
| | _calc_toporder Calculate toporder for the flow graph.
|
| static void | _calc_toporder (StmtList &stmts, const Statement &first_stmt, const Statement &last_stmt, const RefSet< Statement > &entry_points, Array< Statement * > &toporder_to_stmt) |
| static Expression * | _annotate_expr (Expression *expr, const PropConstMap &orig_const_map, const PropConstMap &curr_const_map, const Map< Symbol, IntElem > &use_candidates) |
| | _annotate_expr Annotate the substituted field of variables of the given expression with their constant values.
|
| static Expression * | _annotate_expr (Expression *expr, const PropConstMap &const_map, const Map< Symbol, IntElem > &use_candidates) |
| | _annotate_expr Annotate the substituted field of variables of the given expression with their constant values.
|
| Expression * | _annotate_expr (Expression *expr, const Statement &stmt, const Map< Symbol, IntElem > &use_candidates) |
| static void | _annotate_assert (Statement &stmt, const PropConstMap &const_map, const Map< Symbol, IntElem > &use_candidates) |
| | _annotate_assert Annotate assertions of the given statement with the calculated constant expressions
|
| static void | _annotate_stmt (Statement &stmt, const Map< Symbol, IntElem > &use_candidates) |
| | _annotate_stmt Annotate expressions the given statement with the calculated constant expressions
|
| static void | _annotate_stmts (StmtList &stmts, const Statement &first_stmt, const Statement &last_stmt, const Map< Symbol, IntElem > &use_candidates) |
| | annotate_stmts Annotate each statement of the given block of statements with its calculated constant expressions.
|
| void | _kill_bad_join_consts (Statement &stmt, PropConstMap &const_map) |
| | kill_bad_join_consts Kill any constant expressions formed by the join of two or more reaching definitions, whose constant expression is no longer valid for one of these definitions.
|
| static Boolean | _const_if_took_then (const Statement &stmt) |
| | _const_if_took_then Return true if I am an IF statement with a constant conditional expression that took only the THEN clause.
|
| Statement * | _const_if_succ (Statement &stmt, const Map< Symbol, IntElem > &use_candidates) |
| | _const_if_succ If I am a constant IF statement, return my single successor.
|
| static void | _put_succ_on_work_list (IntSet &work_list, Statement &stmt, const Map< Symbol, IntElem > &use_candidates) |
| | put_succ_on_work_list Put all of my successors on the work list.
|
| static void | _iterate_to_fixed_point (StmtList &, const Statement &, const Statement &, const RefSet< Statement > &entry_points, const Array< Statement * > &toporder_to_stmt, const Map< Symbol, IntElem > &use_candidates, const Array< Symbol * > &tag_to_candidate, const Map< Symbol, Expression > &entering_constants) |
| | iterate_to_fixed_point Propagate the constants contained in the statement's const_maps until a fixed point is reached.
|
| static Boolean | _is_block_unreachable (const StmtList &stmts, const Statement &first_stmt, const Statement &last_stmt) |
| | is_block_unreachable Return True if the block fo code between the given pair of statements is unreachable code.
|
| static void | _remove_unreachable (StmtList &stmts, const Statement &first_stmt, const Statement &last_stmt, const Map< Symbol, IntElem > &use_candidates) |
| | remove_unreachable Remove any dead code in the program.
|
| static void | _propagate_constants1 (StmtList &stmts, const Statement &first_stmt, const Statement &last_stmt, Map< Symbol, IntElem > &def_candidates, Map< Symbol, IntElem > &use_candidates, Array< Symbol * > &tag_to_candidate, RefSet< Statement > &pseudo_stmts, PC_UNREACH_BOOL remove_unreachable, int debug) |
| | propagate_constants1 - Main routine of propagate_constants.
|
| static void | _propagate_constants_all_vars (StmtList &stmts, const Statement &first_stmt, const Statement &last_stmt, RefSet< Statement > &pseudo_stmts, PC_REAL_BOOL subst_reals, PC_ARRAY_BOOL subst_arrays, PC_UNREACH_BOOL remove_unreachable, int debug) |
| | propagate_constants_all_vars Perform constant propagation for all variables in the given statement block.
|
| static void | _propagate_constants_some_vars (StmtList &stmts, const Statement &first_stmt, const Statement &last_stmt, const RefSet< Symbol > &candidates, RefSet< Statement > &pseudo_stmts, PC_UNREACH_BOOL remove_unreachable, int debug) |
| | propagate_constants_all_vars Perform constant propagation for only the variables in candidates for the given statement block.
|
| void | propagate_constants (StmtList &stmts, const Statement &first_stmt, const Statement &last_stmt, PC_REAL_BOOL subst_reals, PC_ARRAY_BOOL subst_arrays, PC_UNREACH_BOOL remove_unreachable, int debug GIV(0)) |
| | propagate_constants - Perform forward substitution of scalar variables throughout pgm.
|
| void | propagate_constants (ProgramUnit &pgm, PC_REAL_BOOL subst_reals, PC_ARRAY_BOOL subst_arrays, PC_UNREACH_BOOL remove_unreachable, int debug GIV(0)) |
| void | propagate_constants (StmtList &stmts, const Statement &first_stmt, const Statement &last_stmt, const RefSet< Symbol > &candidates, PC_UNREACH_BOOL remove_unreachable, int debug GIV(0)) |
| void | propagate_constants (ProgramUnit &pgm, const RefSet< Symbol > &candidates, PC_UNREACH_BOOL remove_unreachable, int debug GIV(0)) |
| int | propagate_constants_pu (char **data, int *len) |
| | Description: Used by InterProcConstProp to compute the side effects of a single program unit.
|
| static void | _init_ipcp_workspaces (StmtList &stmts, const IPCPProcData &proc_data, const Map< Symbol, IntElem > &def_candidates, const Map< Symbol, IntElem > &use_candidates, const Array< Symbol * > &tag_to_candidate) |
| | init_ipcp_workspaces Initialize the workspaces for each statement in the program.
|
| static RefSet< Symbol > * | _build_modified_vars (const StmtList &stmts, const RefSet< Statement > &ignorable_stmts, const Array< Symbol * > &tag_to_candidate) |
| | _build_modified_vars.
|
| static void | _alias_consts (RefSet< Symbol > &alias_consts, RefMap< Symbol, Symbol > &alias_const_map, const RefList< Symbol > &formals, const List< Expression > &actuals, const RefSet< Symbol > &keepable_vars) |
| | alias_consts Compute the set of actual parameters that are aliased to formal parameters, where it is safe to replace the actual parameters with the formal parameters.
|
| static void | _rename_alias_consts (Expression &expr, const RefMap< Symbol, Symbol > &alias_const_map) |
| | rename_alias_consts Rename all variables in the given mapping to their mapped values.
|
| static Expression * | _remove_local_effects_from_expr1 (Expression *expr, const PropConstMap &const_map, const Map< Symbol, IntElem > &candidates) |
| | _remove_local_effects_from_expr Given an expression and a constant map, eliminate all locally modified variables form the expression, so that the final expression would be in terms of the initial values of the subroutine.
|
| static Expression * | _remove_local_effects_from_expr (Expression *expr, const PropConstMap &const_map, const Map< Symbol, IntElem > &candidates) |
| static Map< Symbol, Expression > * | _create_old_const_mods (const Map< Symbol, IntElem > &candidates, const PropConstMap &const_map, const RefSet< Symbol > &keepable_vars, const RefSet< Symbol > *modified_vars_ref) |
| | _create_old_const_mods Create a mapping from old constants to new constants.
|
| static Expression * | _subst_unkeepable_vars (Expression *expr, const RefSet< Symbol > &keepable_vars) |
| | subst_unkeepable_vars Substitute all unkeepable variables.
|
| static Map< Symbol, Expression > * | _create_new_consts (const Map< Symbol, IntElem > &candidates, const PropConstMap &const_map, const RefSet< Symbol > &keepable_vars) |
| | _create_new_consts Create a set of newly generated symbolic constants.
|
| static const List< Expression > & | _call_arg_list (const Statement &call_site) |
| | call_arg_list Return a reference to the argument list of the given call site.
|
| static Boolean | _contains_non_candidate_vars (const Expression &expr, const Map< Symbol, IntElem > &candidates) |
| | contains_non_candidate_vars Return true if the expression contains a variable not in cadidates.
|
| static List< Expression > * | _create_new_actual_consts (const Map< Symbol, IntElem > &candidates, const Statement &stmt, const IPCPProcData &, const IPCPProcData &call_proc_data, const RefSet< Symbol > &keepable_vars) |
| | create_new_actual_consts Build a set of new actual expressions.
|
| static void | _build_call_jump_functions (ProgramUnit &pgm, IPCPProcData &proc_data, const Map< Symbol, IntElem > &candidates, const RefSet< Symbol > *modified_vars_ref) |
| | build_call_jump_function Build a jump function for each call site.
|
| static void | _ipcp_compute_constants (ProgramUnit &pgm, IPCPProcData &proc_data, const Map< Symbol, IntElem > &def_candidates, const Map< Symbol, IntElem > &use_candidates, Array< Symbol * > &tag_to_candidate, const Map< Symbol, Expression > &entering_constants) |
| | ipcp_compute_constants Compute the constants for single procedure for interprocedural constant propagation.
|
| void | _ipcp_build_jump_functions (ProgramUnit &pgm, IPCPProcData &proc_data, const RefSet< Symbol > &def_vars, const RefSet< Symbol > &use_vars, const Map< Symbol, Expression > &entering_constants, int debug GIV(0)) |
| | ipcp_build_jump_functions Build the jump functions for the given proc_data object.
|
| void | _ipcp_propagate_constants (ProgramUnit &pgm, IPCPProcData &proc_data, const RefSet< Symbol > &def_vars, const RefSet< Symbol > &use_vars, PC_UNREACH_BOOL remove_unreachable, const Map< Symbol, Expression > &entering_constants, int debug GIV(0)) |
| | ipcp_propagate_constants Propagate constants within a single procedure for interprocedural constant propagation.
|
| static void | _assert_clear_substituted (Statement &stmt) |
| | _assert_clear_substituted Remove all constant subexpression annotations from all expressions in all assertions of the given statement.
|
| void | clear_substituted (ProgramUnit &pgm) |
| | Description: See previous function.
|
| void | clear_substituted (StmtList &stmts, const Statement &first_stmt, const Statement &last_stmt) |
| | Description: See previous function.
|
| void | clear_substituted (Statement &stmt) |
| | Description: See previous function.
|
| void | clear_substituted (Expression &expr) |
| | Description: Interface to clear_substituted(pgm) from SETL.
|
| int | clear_substituted_pu (char **data, int *len) |
| | Description: Replace some variables with their precomputed constant expressions for all expressions in the given object.
|
| Boolean | substituted_var () |
| | Description: Reset the substituted_var flag to False.
|
| void | clear_substituted_var () |
| | Description: Substitute all precomputed values for PARAMETER constants.
|
| static void | _assert_expand_substituted (Statement &stmt, Boolean(*expr_filter)(const Expression &), Boolean(*const_filter)(const Expression &)) |
| | Do this for all assertions except INDUCTION, FIRSTVALUE, RANGEWRITTEN assertions.
|
| static void | _call_args_expand_substituted (Expression &comma_expr, Boolean(*expr_filter)(const Expression &), Boolean(*const_filter)(const Expression &)) |
| | call_args_expand_substituted Expand all constants in the given list of expressions, except for those constants at the top level.
|
| void | expand_substituted (ProgramUnit &pgm, Boolean(*expr_filter)(const Expression &) GIV(0), Boolean(*const_filter)(const Expression &) GIV(0)) |
| | expand_substituted Replace some variables with their precomputed constant expressions for all expressions in the given object.
|
| void | expand_substituted (StmtList &stmts, const Statement &first_stmt, const Statement &last_stmt, Boolean(*expr_filter)(const Expression &) GIV(0), Boolean(*const_filter)(const Expression &) GIV(0)) |
| void | expand_substituted (Statement &stmt, Boolean(*expr_filter)(const Expression &) GIV(0), Boolean(*const_filter)(const Expression &) GIV(0)) |
| int | expand_substituted_pu (char **data, int *len) |
| | Description: Acts similarly to the function expand_substituted() except that it applies to only a single expression.
|
| static Boolean | _is_constant_expr (const Expression &expr) |
| | is_constant_expr Return True if the given expression would simplify down to an integer constant or logical constant.
|
| Expression * | expr_expand_substituted (Expression *expr, Boolean(*expr_filter)(const Expression &) GIV(0), Boolean(*const_filter)(const Expression &) GIV(0)) |
| | expr_expand_substituted Acts similarly to the method expand_substituted() except that it applies to only a single expression.
|
| static Boolean | _is_expr_top_linear (const Expression &expr) |
| | expand_linear_substituted Expand the variables whose constant expressions are linear for all expressions in the object.
|
| static Boolean | _linear_const_filter (const Expression &expr) |
| void | expand_linear_substituted (ProgramUnit &pgm) |
| | Description: See previous function.
|
| void | expand_linear_substituted (StmtList &stmts, const Statement &first_stmt, const Statement &last_stmt) |
| | Description: See previous function.
|
| void | expand_linear_substituted (Statement &stmt) |
| | Description: See previous function.
|
| Expression * | expr_expand_linear_substituted (Expression *expr) |
| | Description: Expand the variables whose constant expressions are either an ID expression or an expression that can be simplified to an integer or logical constant.
|
| static Boolean | _is_constant_expr_filter (const Expression &expr) |
| | expand_small_substituted Expand the variables whose constant expressions are ID expressions or integer or logical constant expressions.
|
| static Boolean | _small_const_filter (const Expression &expr) |
| void | expand_small_substituted (ProgramUnit &pgm) |
| | Description: See previous function.
|
| void | expand_small_substituted (StmtList &stmts, const Statement &first_stmt, const Statement &last_stmt) |
| | Description: See previous function.
|
| void | expand_small_substituted (Statement &stmt) |
| | Description: See previous function.
|
| Expression * | expr_expand_small_substituted (Expression *expr) |
| | Description: Return True if any calls to the expand_substituted routines substitutes a variable in an expression.
|
| static Boolean | _has_param_in_expr (const Expression &expr) |
| | has_param_in_expr Return true if the given expression has a parameter variable contained within it.
|
| static void | _assert_substitute_parameters (Statement &stmt, PC_REAL_BOOL subst_reals) |
| | _assert_substitute_parameters Substitute all precomputed values for PARAMETER constants in all assertions of the given statement.
|
| static void | substitute_parameters_data (ProgramUnit &pgm, PC_REAL_BOOL subst_reals) |
| void | substitute_parameters (ProgramUnit &pgm, PC_REAL_BOOL subst_reals) |
| | Description: See previous function.
|
| void | substitute_parameters (Symtab &symtab, PC_REAL_BOOL subst_reals) |
| | Description: See previous function.
|
| void | substitute_parameters (StmtList &stmts, const Statement &first_stmt, const Statement &last_stmt, PC_REAL_BOOL subst_reals) |
| | Description: See previous function.
|
| void | substitute_parameters (Statement &stmt, PC_REAL_BOOL subst_reals) |
| | Description: Interface to substutute_parameters(pgm) from SETL.
|
| Expression * | expr_substitute_parameters (Expression *expr, PC_REAL_BOOL subst_reals) |
| | expr_substitute_parameters Acts similarly to the method substitute_parameters() except that it applies to only a single expression.
|
| int | substitute_parameters_pu (char **data, int *len) |
| | Description: Acts similarly to the function substitute_parameters() except that it applies to only a single expression.
|
Variables |
| static unsigned int | _pass_tag |
| static int | _debug_level = 0 |
| | ... Pass tag associated with this pass
|
| static Boolean | _substituted_var = False |
| static Boolean | _stmt_substituted_var = False |
| | ...
|
Detailed Description
Definition in file constant.cc.
Function Documentation
|
|
substitutable_type Returns true if the given type may be legally substituted
Definition at line 50 of file constant.cc.
References COMPLEX_TYPE, DOUBLE_PRECISION_TYPE, False, INTEGER_TYPE, LOGICAL_TYPE, REAL_TYPE, SUBST_REALS, and True.
Referenced by _collect_candidates(), _create_data_assigns(), _filter_vars(), and expr_substitute_parameters(). |
|
|
collect_candidates - Determine all the variables that are candidates for forward substitution and initialize the _candidates and _tag_to_candidates data structures to contain these variables.
Definition at line 159 of file constant.cc.
References _add_refs(), _init_candidates(), ASSIGNMENT_STMT, Iterator< T >::current(), ID_OP, Statement::in_refs(), Statement::lhs(), Expression::op(), Statement::stmt_class(), Expression::symbol(), and Iterator< T >::valid().
Referenced by _propagate_constants_all_vars(), _propagate_constants_some_vars(), and eliminate_dead_code(). |
|
|
Definition at line 185 of file constant.cc.
References _add_refs(), _filter_vars(), _init_candidates(), _substitutable_type(), ASSIGNMENT_STMT, Iterator< T >::current(), Type::data_type(), ID_OP, Statement::in_refs(), RefSet< T >::ins(), Symbol::is_array(), Expression::is_side_effect_free(), Statement::lhs(), Expression::op(), Statement::rhs(), Statement::stmt_class(), Symbol::sym_class(), Expression::symbol(), Symbol::type(), Iterator< T >::valid(), and VARIABLE_CLASS. |
|
|
create_data_assigns - Create a list of pseudo assignment statements which assign all variables in the program unit's data statements to their constant values.
Definition at line 229 of file constant.cc.
References _substitutable_type(), NonBinaryExpr::arg_list(), Expression::base_variable_ref(), Expression::clone(), Iterator< T >::current(), Type::data_type(), List< T >::entries(), List< T >::ins_last(), Symbol::is_array(), Symbol::type(), Iterator< T >::valid(), Data::value_list(), and Data::variable_list().
Referenced by _add_data_assigns(). |
|
|
add_control_assigns - Add a list of pseudo assignment statements at the start of the loop bodies of IF statements that represent constants derived from the conditional statement of the IF statement.
A RefList of these statements is returned for future deletion.
... Make sure that we have an ELSE clause.
... Handle IF (FLAG) THEN ... or IF (.NOT. FLAG) THEN ...
... Handle IF (X .EQ. 1) THEN ... or IF (X .NE. 1) THEN ...
Definition at line 308 of file constant.cc.
References Expression::clone(), constant(), Iterator< T >::current(), Type::data_type(), ELSE_STMT, ELSEIF_STMT, ENDIF_STMT, EQ_OP, Statement::expr(), Expression::expr_guarded(), Statement::follow_ref(), ID_OP, IF_STMT, IMPLIED_GOTO_STMT, INTEGER_CONSTANT_OP, INTEGER_TYPE, Expression::left_guarded(), LOGICAL_TYPE, NE_OP, NOT_OP, Expression::op(), Statement::prev_ref(), Expression::right_guarded(), Statement::stmt_class(), Expression::symbol(), Symbol::type(), and Iterator< T >::valid().
Referenced by _ipcp_build_jump_functions(), _ipcp_propagate_constants(), _propagate_constants_all_vars(), and _propagate_constants_some_vars(). |
|
|
get_workspace Get the workspace for the given statement.
Definition at line 440 of file constant.cc.
References _pass_tag.
Referenced by _add_flow_edges(), _annotate_expr(), _annotate_stmt(), _build_call_jump_functions(), _build_modified_vars(), _calc_loop_variants(), _calc_toporder(), _calc_toporder1(), _collect_stats(), _compute_private_kill_sets(), _const_if_succ(), _const_if_took_then(), _create_new_actual_consts(), _delete_dead_code(), _determine_entry_points(), _dump_workspaces(), _ipcp_build_jump_functions(), _is_block_unreachable(), _iterate_to_fixed_point(), _iterate_to_fixed_point_phase(), _kill_bad_join_consts(), _make_nonlocals_modified_at_calls(), _make_nonlocals_used_at_calls(), _patch_flow_graph(), _put_pred_on_work_list(), _put_succ_on_work_list(), _remove_local_effects_from_expr1(), _remove_unreachable(), _set_needs_widening(), _update_do_succs(), _update_enddo_succs(), _update_if_succs(), _update_succ_edges(), and stmt_toporder(). |
| static void _dump_workspaces |
( |
ostream & |
o, |
|
|
const StmtList & |
stmts, |
|
|
const Statement & |
first_stmt, |
|
|
const Statement & |
last_stmt |
|
) |
[static] |
|
|
|
_make_nonlocals_modified_at_calls Make all non-local variables be marked as potentially modified for all call statements and all statements containing function calls.
... Calculate the set of non-local variables.
... Mark any variables aliased to the non-local variable ... as also non-local.
... Add the non-local variables to the mod_set of all statements that ... are either call statements or contain function calls.
Definition at line 474 of file constant.cc.
References _get_workspace(), Statement::act_refs(), ASSIGNMENT_STMT, Expression::base_variable_ref(), Symbol::common_ref(), Iterator< T >::current(), IntSet::del(), equiv_aliases(), Symbol::formal(), IntSet::ins(), RefSet< T >::ins(), PropConstMap::int_non_const(), IS_FORMAL, Statement::lhs(), PropConstWS::lhs_tag(), PropConstWS::mod_set, PropConstWS::out_const_map, Statement::stmt_class(), stmt_maymods(), switch_value(), PropConstWS::unknown_call, Iterator< T >::valid(), and IntElem::value().
Referenced by _ipcp_compute_constants(), and _propagate_constants1(). |
|
|
patch_flow_graph Add flow edges from all ENDDO statements in the flow graph to the statement following the ENDDO.
These edges are added so to allow constant information calculated inside a DO loop to be propagated to statements after a DO loop in the same iteration. Without these additional edges, constant information calculated inside a loop can affect statements after the loop only on the successive iteration. This would mean that the the number of iterations required will be a multiple of the depth of the maximum loop nesting of the program.
Definition at line 594 of file constant.cc.
References _get_workspace(), _pass_tag, Iterator< T >::current(), ENDDO_STMT, RefSet< T >::ins(), Statement::next_ref(), PropConstWS::pred, Statement::stmt_class(), PropConstWS::succ, WorkSpaceStack::top_ref(), Iterator< T >::valid(), and Statement::work_stack().
Referenced by _ipcp_compute_constants(), and _propagate_constants1(). |
|
|
determine_entry_points.
Determine all the entry statements for the given block of statements. Simultaneously, delete all predecessors and successor edges entering/ exiting the block.
Definition at line 645 of file constant.cc.
References _get_workspace(), Iterator< T >::current(), Mutator< T >::del(), entry_points(), ENTRY_STMT, FLOW_ENTRY_STMT, RefDatabase< S, T >::ins(), RefList< T >::ins_last(), RefList< T >::member(), PropConstWS::pred, Statement::stmt_class(), PropConstWS::succ, and Iterator< T >::valid().
Referenced by _ipcp_compute_constants(), and _propagate_constants1(). |
| static void _calc_toporder1 |
( |
PropConstWS & |
my_ws, |
|
|
int & |
toporder |
|
) |
[static] |
|
|
|
... Calculate the topological order for each statement
... Initialize toporder_to_stmt
Definition at line 712 of file constant.cc.
References _calc_toporder1(), _get_workspace(), _num_stmts_in_block(), Iterator< T >::current(), entry_points(), stmt_toporder(), PropConstWS::toporder(), Iterator< T >::valid(), and PropConstWS::visited().
Referenced by _ipcp_compute_constants(), _propagate_constants1(), eliminate_dead_code(), and stmt_toporder(). |
|
|
_annotate_expr Annotate the substituted field of variables of the given expression with their constant values.
If certain constant values must be substituted, this algorithm will perform the substitution. If any of the variables that must be substituted in the given expression is non-constant, this function will return NULL.
... We must substitute the constant value of ... the variable because either an earlier ... substitution poisoned the variable or the ... definition point of that variable for the ... given expression differs from the ... definition point of that variable for the ... statement being annotated.
... Expression already has a filled substituted field.
Definition at line 762 of file constant.cc.
References _get_workspace(), Expression::arg_list(), Mutator< T >::assign(), clear_substituted(), Expression::clone(), CONST, constant(), IntSet::del(), PropConstElem::expr(), False, ID_OP, PropConstWS::in_const_map, IntSet::ins(), PropConstElem::last_mod(), LOGICAL_TYPE, PropConstWS::poisoned_vars, Mutator< T >::pull(), PropConstElem::state(), Expression::substituted(), Iterator< T >::valid(), and IntElem::value().
Referenced by _annotate_assert(), _annotate_expr(), _annotate_stmt(), _create_new_actual_consts(), and _create_new_consts(). |
|
|
_annotate_expr Annotate the substituted field of variables of the given expression with their constant values.
Definition at line 867 of file constant.cc.
References _annotate_expr(). |
|
|
_annotate_stmt Annotate expressions the given statement with the calculated constant expressions
... Create a copy of my entering constants, where all variables ... modified by myself is marked as non-constant.
... Annotate all the expressions in myself.
... Update lhs.
... Update rhs, ignoring the modification to the lhs variable.
Definition at line 921 of file constant.cc.
References _annotate_assert(), _annotate_expr(), _debug_level, _get_workspace(), Mutator< T >::assign(), ASSIGNMENT_STMT, IntSet::first(), PropConstWS::in_const_map, PropConstWS::mod_set, IntSet::next(), Expression::print_debug(), Mutator< T >::pull(), and Iterator< T >::valid().
Referenced by _annotate_stmts(). |
|
|
kill_bad_join_consts Kill any constant expressions formed by the join of two or more reaching definitions, whose constant expression is no longer valid for one of these definitions.
That is, one of the variables used by the constant expression was modified somewhere along a control flow path from the definition to the current statement.
... We have a join of two or more definitions of a constant ... symbolic expression.
... Test each of its reaching definitions.
... Test each of its uses.
Definition at line 1004 of file constant.cc.
References _get_workspace(), CONST, Iterator< T >::current(), IntSet::entries(), RefSet< T >::entries(), False, IntSet::first(), PropConstElem::last_mod(), MAY_BE_CONST, IntSet::next(), PropConstElem::non_const(), PropConstWS::num_visits(), PropConstWS::out_const_map, PropConstWS::pred, PropConstElem::state(), True, PropConstElem::use_set(), and Iterator< T >::valid().
Referenced by _iterate_to_fixed_point(). |
|
|
_const_if_succ If I am a constant IF statement, return my single successor.
Otherwise return NULL.
Definition at line 1084 of file constant.cc.
References _get_workspace(), ARITHMETIC_IF_STMT, ELSEIF_STMT, Statement::follow_ref(), IF_STMT, PropConstWS::in_const_map, int_const_val(), Statement::label_list(), and Statement::next_ref().
Referenced by _iterate_to_fixed_point(), _put_succ_on_work_list(), and _remove_unreachable(). |
|
|
put_succ_on_work_list Put all of my successors on the work list.
Definition at line 1123 of file constant.cc.
References _const_if_succ(), _debug_level, _get_workspace(), PropConstWS::const_cond, Iterator< T >::current(), False, RefSet< T >::ins(), PropConstWS::succ, PropConstWS::toporder(), and Iterator< T >::valid().
Referenced by _iterate_to_fixed_point(), and _iterate_to_fixed_point_phase(). |
|
|
iterate_to_fixed_point Propagate the constants contained in the statement's const_maps until a fixed point is reached.
... List of statements that need to be updated.
... Put all entries on the work list.
... Iterate until there are no more elements on the work list
... Visit each statement in the work list, in topological order
... Generate the new constant mapping entering the statement.
... New entering constant mapping differs from the old ... one. So update the entering and exiting constant ... mappings for the statement.
... Exiting constant map has changed, so place ... the statements successors on the work list so ... that they can update their constant mappings ... with my new constant mapping.
Definition at line 1158 of file constant.cc.
References _const_if_succ(), _const_if_took_then(), _debug_level, _get_workspace(), _kill_bad_join_consts(), _put_succ_on_work_list(), PropConstWS::add_consts(), PropConstWS::const_cond, Iterator< T >::current(), ENDIF_STMT, entry_points(), False, PropConstWS::in_const_map, PropConstWS::incr_num_visits(), RefDatabase< S, T >::ins(), ProtoRefDatabase< S, T >::member(), PropConstWS::num_visits(), PropConstWS::out_const_map, PropConstWS::pred, PropConstWS::pretty_print(), Statement::print_debug(), Statement::stmt_class(), PropConstWS::toporder(), True, PropConstWS::update_out_const_map(), and Iterator< T >::valid().
Referenced by _ipcp_compute_constants(), _propagate_constants1(), and eliminate_dead_code(). |
|
|
remove_unreachable Remove any dead code in the program.
... Delete all IF statements where only one branch is taken.
... Replace the arithmetic if with a goto to its single ... successor.
... Currently, don't allow ELSEIF stmts to be deleted.
... Delete the IF part of an IF () THEN ... ELSEIF statement ... Currently, do nothing.
... Delete the IF statement only if none of the statements ... in the not-taken branch is reachable.
... Make sure that the ELSE or ELSEIF part of IF ... statement isn't deleted by marking it as reachable.
... Delete all unreachable code.
... Check for the case of an ENDDO statement being unreachable. ... In this case, if the associated DO is reachable, ... then DO will be deleted when the ENDDO is deleted, ... so we must place an assignment statement for the loop index, ... assigning the initial value of the index, ... plus the loop-entry test. ... If the associated DO is not reachable either, then don't ... insert the assignment or the IF at all (and the ... whole loop should vanish).
... Statement &newif =
... remove_trivial_gotos(pgm);
Definition at line 1289 of file constant.cc.
References _const_if_succ(), _debug_level, _get_workspace(), _is_block_unreachable(), ARITHMETIC_IF_STMT, Expression::clone(), PropConstWS::const_cond, Iterator< T >::current(), Iterator< T >::current_valid(), ELSEIF_STMT, ENDDO_STMT, ENDIF_STMT, RefSet< T >::entries(), False, FLOW_ENTRY_STMT, Statement::follow_ref(), ge(), IF_STMT, PropConstWS::incr_num_visits(), Statement::index(), Statement::init(), RefSet< T >::ins(), Statement::limit(), Statement::matching_endif_ref(), RefSet< T >::member(), Statement::next_ref(), PropConstWS::num_visits(), Statement::prev_ref(), Statement::print_debug(), WorkSpaceStack::push(), Iterator< T >::reset(), Statement::stmt_class(), True, RefSet< T >::valid(), Iterator< T >::valid(), and Statement::work_stack().
Referenced by _ipcp_propagate_constants(), and _propagate_constants1(). |
| static void _propagate_constants1 |
( |
StmtList & |
stmts, |
|
|
const Statement & |
first_stmt, |
|
|
const Statement & |
last_stmt, |
|
|
Map< Symbol, IntElem > & |
def_candidates, |
|
|
Map< Symbol, IntElem > & |
use_candidates, |
|
|
Array< Symbol * > & |
tag_to_candidate, |
|
|
RefSet< Statement > & |
pseudo_stmts, |
|
|
PC_UNREACH_BOOL |
remove_unreachable, |
|
|
int |
debug |
|
) |
[static] |
|
|
|
propagate_constants1 - Main routine of propagate_constants.
Perform forward substitution of scalar variables throughout given statement block.
... Set of entry points into the given block of statements.
... An array that maps integers to statements.
... Initialize ... clear_substituted_var();
... Iteratively propagate the constants throughout the program until a ... fixed point is reached.
... Annotate all the expressions in the program with the calculated ... constant values
... Remove any deadcode from the program, if desired.
... Clean up
Definition at line 1427 of file constant.cc.
References _annotate_stmts(), _calc_toporder(), _debug_level, _determine_entry_points(), _dump_workspaces(), _init_workspaces(), _iterate_to_fixed_point(), _make_nonlocals_modified_at_calls(), _num_stmts_in_block(), _pass_tag, _patch_flow_graph(), _remove_unreachable(), create_pass_tag(), Iterator< T >::current(), entry_points(), WorkSpaceStack::pop(), REMOVE_UNREACH_CODE, Timer::reset(), Iterator< T >::valid(), and Statement::work_stack().
Referenced by _propagate_constants_all_vars(), and _propagate_constants_some_vars(). |
| int propagate_constants_pu |
( |
char ** |
data, |
|
|
int * |
len |
|
) |
|
|
|
|
_remove_local_effects_from_expr Given an expression and a constant map, eliminate all locally modified variables form the expression, so that the final expression would be in terms of the initial values of the subroutine.
Definition at line 1828 of file constant.cc.
References _get_workspace(), Expression::arg_list(), Mutator< T >::assign(), Expression::base_variable_ref(), Expression::clone(), CONST, IntSet::del(), ENTRY_STMT, PropConstElem::expr(), FLOW_ENTRY_STMT, ID_OP, PropConstWS::in_const_map, IntSet::ins(), PropConstElem::last_mod(), paren(), PropConstWS::poisoned_vars, Mutator< T >::pull(), PropConstElem::state(), Statement::stmt_class(), Iterator< T >::valid(), IntElem::value(), and VARIABLE_CLASS.
Referenced by _remove_local_effects_from_expr(). |
|
|
_create_old_const_mods Create a mapping from old constants to new constants.
Definition at line 1915 of file constant.cc.
References _remove_local_effects_from_expr(), KeyIterator< S, T >::current_key(), ID_OP, Map< S, T >::ins(), OMEGA_OP, Expression::op(), Expression::symbol(), and KeyIterator< S, T >::valid().
Referenced by _build_call_jump_functions(), and _ipcp_build_jump_functions(). |
|
|
create_new_actual_consts Build a set of new actual expressions.
... Compute the set of variable that are allowable in the actual ... expressions.
... Compute the list of constant actuals.
Definition at line 2070 of file constant.cc.
References _alias_consts(), _annotate_expr(), _call_arg_list(), _contains_non_candidate_vars(), _get_workspace(), _rename_alias_consts(), _subst_unkeepable_vars(), Expression::base_variable_ref(), Expression::clone(), Iterator< T >::current(), List< T >::entries(), RefList< T >::entries(), PropConstWS::in_const_map, RefSet< T >::ins(), List< T >::ins_last(), omega(), and Iterator< T >::valid().
Referenced by _build_call_jump_functions(). |
|
|
build_call_jump_function Build a jump function for each call site.
Definition at line 2140 of file constant.cc.
References _create_new_actual_consts(), _create_new_consts(), _create_old_const_mods(), _get_workspace(), ASSIGNMENT_STMT, CALL_STMT, Iterator< T >::current(), IPCPCallData::data_ref(), FUNCTION_CALL_OP, PropConstWS::in_const_map, RefSet< T >::ins(), IPCPProcData::local_vars(), PropConstWS::num_visits(), Expression::op(), Statement::rhs(), Statement::stmt_class(), Expression::symbol(), IPCPProcData::usable_global_vars(), and Iterator< T >::valid().
Referenced by _ipcp_build_jump_functions(). |
|
|
ipcp_compute_constants Compute the constants for single procedure for interprocedural constant propagation.
... Set of entry points into the given block of statements.
... An array that maps integers to statements.
... Iteratively propagate the constants throughout the program until a ... fixed point is reached.
Definition at line 2192 of file constant.cc.
References _calc_toporder(), _debug_level, _determine_entry_points(), _dump_workspaces(), _init_ipcp_workspaces(), _iterate_to_fixed_point(), _make_nonlocals_modified_at_calls(), _pass_tag, _patch_flow_graph(), create_pass_tag(), entry_points(), List< T >::first_ref(), List< T >::last_ref(), and Timer::reset().
Referenced by _ipcp_build_jump_functions(), and _ipcp_propagate_constants(). |
|
|
ipcp_build_jump_functions Build the jump functions for the given proc_data object.
... Set of all variables that are candidates for forward substitution
... Set of all variables that may be in the constant symbolic values ... for a variable in def_candidates.
... An array that maps integers to variable candidates.
... Set of pseudo statements inserted to represent constants from control ... flow.
... Initialize
... Compute my constants.
... If some pseudo-statements were added to the program, compute the ... set of variables modified by the program, ignoring pseudo-statements ... and unreachable statements.
... Build the jump functions.
... Clean up
Definition at line 2245 of file constant.cc.
References _add_control_assigns(), _build_call_jump_functions(), _build_modified_vars(), _create_new_consts(), _create_old_const_mods(), _debug_level, _get_workspace(), _init_candidates(), _ipcp_compute_constants(), _num_stmts_in_block(), _pass_tag, Iterator< T >::current(), BaseMapRoot::entries(), RefSet< T >::entries(), List< T >::first_ref(), FLOW_EXIT_STMT, PropConstWS::in_const_map, StmtList::iterator(), List< T >::last_ref(), modified_vars(), WorkSpaceStack::pop(), Timer::reset(), Iterator< T >::valid(), and Statement::work_stack(). |
|
|
ipcp_propagate_constants Propagate constants within a single procedure for interprocedural constant propagation.
... Set of all variables that are candidates for forward substitution
... Set of all variables that may be in the constant symbolic values ... for a variable in def_candidates.
... An array that maps integers to variable candidates.
... Set of pseudo statements inserted to represent constants from control ... flow.
... Initialize
... Compute my constants.
... Annotate all the expressions in the program with the calculated ... constant values
... Remove any deadcode from the program, if desired.
... Clean up
Definition at line 2347 of file constant.cc.
References _add_control_assigns(), _annotate_stmts(), _debug_level, _init_candidates(), _ipcp_compute_constants(), _num_stmts_in_block(), _pass_tag, _remove_unreachable(), Iterator< T >::current(), BaseMapRoot::entries(), List< T >::first_ref(), StmtList::iterator(), List< T >::last_ref(), WorkSpaceStack::pop(), REMOVE_UNREACH_CODE, Timer::reset(), Iterator< T >::valid(), and Statement::work_stack(). |
| static void _assert_clear_substituted |
( |
Statement & |
stmt |
) |
[static] |
|
|
|
Description: See previous function.
Definition at line 2459 of file constant.cc. |
|
|
Description: See previous function.
Definition at line 2469 of file constant.cc. |
| int clear_substituted_pu |
( |
char ** |
data, |
|
|
int * |
len |
|
) |
|
|
|
|
Description: Replace some variables with their precomputed constant expressions for all expressions in the given object.
This function also takes two optional filter functions to determine whether a certain variable is to be substituted.
If non-NULL, the expr_filter() function tests each subexpression of the expression whose variables are to be substituted with constant values. If it returns False for a given subexpression, no variable substitutions will be performed upon that subexpression.
If non-NULL, the const_filter() function tests the constant value associated with each variable. If it returns False for the constant value of a a certain variable, then that constant value will not be substituted for any occurrence of that variable.
Definition at line 2494 of file constant.cc.
References clear_substituted(), external_interface_init(), external_program_unit(), ProgramUnit::pu_tag_ref(), and setup_to_return_handle(). |
| void clear_substituted_var |
( |
|
) |
|
|
|
|
Description: Substitute all precomputed values for PARAMETER constants.
If subst_reals == SUBST_REALS, substitute integer, logical, real, double-precision, and complex parameters. Otherwise, only propagate integer and logical parameters.
Definition at line 2522 of file constant.cc.
References _substituted_var, and False. |
|
|
Do this for all assertions except INDUCTION, FIRSTVALUE, RANGEWRITTEN assertions.
... Don't expand in INDUCTION assertions
Definition at line 2535 of file constant.cc.
References Assertion::arg_list_guarded(), Assertion::arg_list_valid(), AS_FIRSTVALUE, AS_INDUCTION, AS_RANGEWRITTEN, Mutator< T >::assign(), Iterator< T >::current(), expr_expand_substituted(), Mutator< T >::pull(), Assertion::type(), and Iterator< T >::valid().
Referenced by expand_substituted(). |
|
|
call_args_expand_substituted Expand all constants in the given list of expressions, except for those constants at the top level.
This function is used to make sure that potentially aliased subroutine or function arguments are not removed by constant propagation.
Definition at line 2570 of file constant.cc.
References Expression::arg_list(), Mutator< T >::assign(), COMMA_OP, Iterator< T >::current(), expr_expand_substituted(), ID_OP, Expression::op(), Mutator< T >::pull(), Expression::substituted(), and Iterator< T >::valid().
Referenced by expand_substituted(), and expr_expand_substituted(). |
|
|
expand_substituted Replace some variables with their precomputed constant expressions for all expressions in the given object.
This method requires two filter functions to determine whether a certain variable is to be substituted. The first filter function tests a subexpression of the current expression whose variables are being substituted. If it returns false, none of the variables inside this subexpression will substituted. The second function tests the constant expression associated with a variable to be substituted. If this function returns false, the variable is not substituted with that expression.
Definition at line 2602 of file constant.cc.
Referenced by IPCPProcData::expand_all_substituted(), expand_linear_substituted(), expand_small_substituted(), expand_substituted(), expand_substituted_pu(), and main(). |
| int expand_substituted_pu |
( |
char ** |
data, |
|
|
int * |
len |
|
) |
|
|
|
|
expr_expand_substituted Acts similarly to the method expand_substituted() except that it applies to only a single expression.
This method modifies the given expression and returns the result.
Definition at line 2699 of file constant.cc.
References _call_args_expand_substituted(), _is_constant_expr(), _stmt_substituted_var, _substituted_var, Mutator< T >::assign(), FUNCTION_CALL_OP, Expression::grab_substituted(), ID_OP, Mutator< T >::pull(), simplify(), Expression::substituted(), True, and Iterator< T >::valid().
Referenced by _assert_expand_substituted(), _call_args_expand_substituted(), RangeComparator::compare(), expand_substituted(), expr_expand_linear_substituted(), expr_expand_small_substituted(), extract_ranges(), intersect_ranges(), and union_ranges(). |
|
|
expand_linear_substituted Expand the variables whose constant expressions are linear for all expressions in the object.
An expression is considered linear if it is made up of only additive and multiplicative operators.
... Let the leaf expressions be linear
... Let the logical operations be linear
Definition at line 2756 of file constant.cc.
References ADD_OP, AND_OP, ARRAY_REF_OP, COMMA_OP, COMPLEX_OP, EQ_OP, EQV_OP, False, GE_OP, GT_OP, HOLLERITH_CONSTANT_OP, ID_OP, INTEGER_CONSTANT_OP, LE_OP, LOGICAL_CONSTANT_OP, LT_OP, MULT_OP, NE_OP, NEQV_OP, NOT_OP, OMEGA_OP, OR_OP, PAREN_OP, REAL_CONSTANT_OP, SUB_OP, True, U_MINUS_OP, and U_PLUS_OP.
Referenced by _linear_const_filter(), expand_linear_substituted(), and expr_expand_linear_substituted(). |
|
|
Description: See previous function.
Definition at line 2813 of file constant.cc. |
|
|
Description: See previous function.
Definition at line 2819 of file constant.cc. |
| void expand_linear_substituted |
( |
Statement & |
stmt |
) |
|
|
|
|
Description: See previous function.
Definition at line 2879 of file constant.cc. |
| void expand_small_substituted |
( |
Statement & |
stmt |
) |
|
|
|
|
Description: See previous function.
... Substitute all parameters contained inside other parameters and ... simplify them down.
... Substitute all parameters found in the bounds of arrays.
Definition at line 2970 of file constant.cc. |
|
|
Description: See previous function.
Definition at line 3024 of file constant.cc. |
|
|
expr_substitute_parameters Acts similarly to the method substitute_parameters() except that it applies to only a single expression.
This method modifies the given expression and returns the result.
Definition at line 3056 of file constant.cc.
References _stmt_substituted_var, _substitutable_type(), Mutator< T >::assign(), Expression::clone(), Symbol::expr_ref(), expr_substitute_parameters(), ID_OP, Mutator< T >::pull(), Expression::symbol(), SYMBOLIC_CONSTANT_CLASS, True, and Iterator< T >::valid().
Referenced by _assert_substitute_parameters(), expr_substitute_parameters(), substitute_parameters(), and substitute_parameters_data(). |
| int substitute_parameters_pu |
( |
char ** |
data, |
|
|
int * |
len |
|
) |
|
|
Variable Documentation
|