GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "target.h"
#include "rtl.h"
#include "tree.h"
#include "gimple.h"
#include "cfghooks.h"
#include "tree-pass.h"
#include "ssa.h"
#include "fold-const.h"
#include "stor-layout.h"
#include "tree-eh.h"
#include "gimplify.h"
#include "gimple-iterator.h"
#include "gimplify-me.h"
#include "tree-cfg.h"
#include "tree-dfa.h"
#include "tree-ssa.h"
#include "tree-ssa-propagate.h"
#include "tree-hasher.h"
#include "cfgloop.h"
#include "cfganal.h"
#include "gimple-fold.h"
#include "diagnostic-core.h"
#include "case-cfn-macros.h"
#include "builtins.h"
#include "optabs-tree.h"
#include "tree-ssa-dce.h"
Data Structures | |
class | complex_propagate |
Macros | |
#define | PAIR(a, b) |
Typedefs | |
typedef int | complex_lattice_t |
Enumerations | |
enum | { UNINITIALIZED = 0 , ONLY_REAL = 1 , ONLY_IMAG = 2 , VARYING = 3 } |
Variables | |
static vec< complex_lattice_t > | complex_lattice_values |
static int_tree_htab_type * | complex_variable_components |
static vec< tree > | complex_ssa_name_components |
static vec< gphi * > | phis_to_revisit |
static bitmap | need_eh_cleanup |
static bitmap | dce_worklist |
Referenced by expand_complex_addition(), expand_complex_division(), and expand_complex_multiplication().
typedef int complex_lattice_t |
The type complex_lattice_t holds combinations of the above constants.
anonymous enum |
Lower complex number operations to scalar operations. Copyright (C) 2004-2024 Free Software Foundation, Inc. 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/>.
For each complex ssa name, a lattice value. We're interested in finding out whether a complex number is degenerate in some way, having only real or only complex parts.
Enumerator | |
---|---|
UNINITIALIZED | |
ONLY_REAL | |
ONLY_IMAG | |
VARYING |
|
static |
Create one backing variable for a complex component of ORIG.
References build1(), copy_warning(), create_tmp_var, DECL_ARTIFICIAL, DECL_HAS_DEBUG_EXPR_P, DECL_IGNORED_P, DECL_NAME, DECL_SOURCE_LOCATION, get_identifier(), IDENTIFIER_POINTER, NULL, r, SET_DECL_DEBUG_EXPR, and suppress_warning().
Referenced by get_component_var().
|
static |
Insert the pair UID, TO into the complex_variable_components hashtable.
References complex_variable_components, hash_table< Descriptor, Lazy, Allocator >::find_slot_with_hash(), int_tree_map::to, and int_tree_map::uid.
Referenced by get_component_var().
|
static |
Lookup UID in the complex_variable_components hashtable and return the associated tree.
References complex_variable_components, hash_table< Descriptor, Lazy, Allocator >::find_with_hash(), and int_tree_map::uid.
Referenced by get_component_var().
|
static |
Expand complex addition to scalars: a + b = (ar + br) + i(ai + bi) a - b = (ar - br) + i(ai + bi)
References gcc_unreachable, gimple_build(), gimple_location(), gsi_insert_seq_before(), GSI_SAME_STMT, gsi_stmt(), NULL, ONLY_IMAG, ONLY_REAL, operand_equal_p(), PAIR, update_complex_assignment(), and VARYING.
Referenced by expand_complex_operations_1().
|
static |
Expand inline asm that sets some complex SSA_NAMEs.
References as_a(), build1(), build_zero_cst(), gimple_asm_nlabels(), gimple_asm_noutputs(), gimple_asm_output_op(), gimple_location(), GSI_CONTINUE_LINKING, gsi_insert_seq_after(), gsi_stmt(), i, r, set_component_ssa_name(), sorry_at(), TREE_CODE, TREE_TYPE, and TREE_VALUE.
Referenced by expand_complex_operations_1().
|
static |
Expand complex comparison (EQ or NE only).
References as_a(), bitmap_set_bit, boolean_true_node, boolean_type_node, fold_convert, gcc_unreachable, gimple_assign_lhs(), gimple_assign_set_rhs_from_tree(), gimple_bb(), gimple_build(), gimple_cond_set_code(), gimple_cond_set_lhs(), gimple_cond_set_rhs(), gimple_location(), gsi_insert_seq_before(), GSI_SAME_STMT, gsi_stmt(), maybe_clean_eh_stmt(), need_eh_cleanup, NULL, TREE_TYPE, type(), and update_stmt().
Referenced by expand_complex_operations_1().
|
static |
Expand complex conjugate to scalars: ~a = (ar) + i(-ai)
References gimple_build(), gimple_location(), gsi_insert_seq_before(), GSI_SAME_STMT, gsi_stmt(), NULL, and update_complex_assignment().
Referenced by expand_complex_operations_1().
|
static |
Keep this algorithm in sync with fold-const.cc:const_binop(). Expand complex division to scalars, straightforward algorithm. a / b = ((ar*br + ai*bi)/t) + i((ai*br - ar*bi)/t) t = br*br + bi*bi
References gimple_build(), gimple_location(), gsi_insert_seq_before(), GSI_SAME_STMT, gsi_stmt(), NULL, and update_complex_assignment().
Referenced by expand_complex_division().
|
static |
Keep this algorithm in sync with fold-const.cc:const_binop(). Expand complex division to scalars, modified algorithm to minimize overflow with wide input ranges.
References add_bb_to_loop(), profile_count::apply_probability(), boolean_false_node, boolean_type_node, CDI_DOMINATORS, basic_block_def::count, create_empty_bb(), create_tmp_reg(), dom_info_available_p(), profile_probability::even(), gimple_build(), gimple_build_assign(), gimple_build_cond(), gimple_build_nop(), gimple_location(), gimple_seq_discard(), gsi_bb(), gsi_insert_after(), gsi_insert_before(), gsi_insert_seq_before(), gsi_last_bb(), GSI_NEW_STMT, gsi_remove(), GSI_SAME_STMT, gsi_start_bb(), gsi_stmt(), integer_nonzerop(), integer_zerop(), basic_block_def::loop_father, make_edge(), make_single_succ_edge(), NULL, NULL_TREE, redirect_edge_succ(), set_immediate_dominator(), split_block(), tr(), TREE_CODE, and update_complex_assignment().
Referenced by expand_complex_division().
|
static |
Expand complex division to scalars.
References expand_complex_div_straight(), expand_complex_div_wide(), expand_complex_libcall(), gcc_unreachable, gimple_build(), gimple_location(), gsi_insert_seq_before(), GSI_SAME_STMT, gsi_stmt(), NULL, ONLY_IMAG, ONLY_REAL, PAIR, SCALAR_FLOAT_TYPE_P, TREE_TYPE, update_complex_assignment(), and VARYING.
Referenced by expand_complex_operations_1().
|
static |
Expand a complex multiplication or division to a libcall to the c99 compliant routines. TYPE is the complex type of the operation. If INPLACE_P replace the statement at GSI with the libcall and return NULL_TREE. Else insert the call, assign its result to an output variable and return that variable. If INPLACE_P is true then the statement being replaced should be an assignment statement.
References build1(), BUILT_IN_COMPLEX_DIV_MIN, builtin_decl_explicit(), cfun, FOR_EACH_EDGE, gcc_assert, gcc_unreachable, GET_MODE_CLASS, gimple_assign_lhs(), gimple_bb(), gimple_build_call(), gimple_call_set_lhs(), gimple_call_set_nothrow(), gsi_insert_before(), gsi_replace(), GSI_SAME_STMT, gsi_start_bb(), gsi_stmt(), make_ssa_name(), NULL_TREE, split_edge(), SSA_NAME_DEF_STMT, stmt_can_throw_internal(), stmt_could_throw_p(), TREE_TYPE, TYPE_MODE, and update_complex_components().
Referenced by expand_complex_division(), and expand_complex_multiplication().
|
static |
Expand a complex move to scalars.
References as_a(), build1(), extract_component(), find_fallthru_edge(), gcc_assert, gcc_unreachable, gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_assign_set_lhs(), gimple_assign_set_rhs1(), gimple_build_assign(), gimple_call_lhs(), gimple_has_side_effects(), gimple_location(), gimple_num_ops(), gimple_return_set_retval(), gimple_set_location(), gsi_bb(), gsi_insert_before(), GSI_SAME_STMT, gsi_stmt(), i, is_ctrl_altering_stmt(), is_gimple_assign(), is_gimple_call(), NULL_TREE, r, basic_block_def::succs, TREE_CODE, TREE_SIDE_EFFECTS, TREE_TYPE, unshare_expr(), update_complex_assignment(), update_complex_components(), update_complex_components_on_edge(), and update_stmt().
Referenced by expand_complex_operations_1().
|
static |
Expand complex multiplication to scalars: a * b = (ar*br - ai*bi) + i(ar*bi + br*ai)
References add_phi_arg(), cfun, create_phi_node(), dconst1, expand_complex_libcall(), expand_complex_multiplication_components(), find_edge(), gcc_unreachable, gimple_build(), gimple_build_cond(), gimple_build_nop(), gimple_location(), gsi_bb(), gsi_insert_after(), gsi_insert_seq_before(), gsi_last_bb(), GSI_NEW_STMT, gsi_prev(), GSI_SAME_STMT, gsi_start_nondebug_after_labels_bb(), gsi_stmt(), HONOR_NANS(), insert_cond_bb(), make_ssa_name(), NULL, NULL_TREE, ONLY_IMAG, ONLY_REAL, optimize_bb_for_size_p(), PAIR, real_identical(), SCALAR_FLOAT_TYPE_P, single_succ_edge(), stmt_can_throw_internal(), TREE_CODE, TREE_REAL_CST, TREE_TYPE, UNKNOWN_LOCATION, update_complex_assignment(), VARYING, and profile_probability::very_unlikely().
Referenced by expand_complex_operations_1().
|
static |
Perform a complex multiplication on two complex constants A, B represented by AR, AI, BR, BI of type TYPE. The operation we want is: a * b = (ar*br - ai*bi) + i(ar*bi + br*ai). Insert the GIMPLE statements into GSI. Store the real and imaginary components of the result into RR and RI.
References gimple_build().
Referenced by expand_complex_multiplication().
|
static |
Expand complex negation to scalars: -a = (-ar) + i(-ai)
References gimple_build(), gimple_location(), gsi_insert_seq_before(), GSI_SAME_STMT, gsi_stmt(), NULL, and update_complex_assignment().
Referenced by expand_complex_operations_1().
|
static |
Process one statement. If we identify a complex operation, expand it.
References expand_complex_addition(), expand_complex_asm(), expand_complex_comparison(), expand_complex_conjugate(), expand_complex_division(), expand_complex_move(), expand_complex_multiplication(), expand_complex_negation(), expand_complex_paren(), extract_component(), find_lattice_value(), gcc_unreachable, gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_assign_set_rhs_from_tree(), gimple_call_combined_fn(), gimple_cond_lhs(), gimple_cond_rhs(), gimple_expand_builtin_cabs(), gimple_expr_code(), gimple_get_lhs(), gimple_num_ops(), gimple_op(), gsi_stmt(), is_gimple_assign(), NULL, NULL_TREE, tcc_unary, TREE_CODE, TREE_CODE_CLASS, TREE_OPERAND, TREE_TYPE, type(), UNINITIALIZED, update_stmt(), and VARYING.
Referenced by tree_lower_complex().
|
static |
Expand complex paren to scalars: ((a)) = ((ar)) + i((ai))
References gimple_build(), gimple_location(), gsi_insert_seq_before(), GSI_SAME_STMT, gsi_stmt(), NULL, and update_complex_assignment().
Referenced by expand_complex_operations_1().
|
static |
Extract the real or imaginary part of a complex variable or constant. Make sure that it's a proper gimple_val and gimplify it if not. Emit any new code before gsi.
References build1(), force_gimple_operand_gsi(), gcc_assert, gcc_unreachable, get_component_ssa_name(), GSI_SAME_STMT, NULL, size_binop, SSA_NAME_DEF_STMT, TREE_CODE, TREE_IMAGPART, TREE_OPERAND, TREE_REALPART, TREE_TYPE, TYPE_SIZE, and unshare_expr().
Referenced by expand_complex_move(), expand_complex_operations_1(), gimple_expand_builtin_cabs(), tree_lower_complex(), and update_phi_components().
|
static |
Compute a lattice value from gimple_val T.
References complex_lattice_values, find_lattice_value_parts(), gcc_unreachable, SSA_NAME_VERSION, TREE_CODE, TREE_IMAGPART, and TREE_REALPART.
Referenced by expand_complex_operations_1(), get_component_ssa_name(), set_component_ssa_name(), complex_propagate::visit_phi(), and complex_propagate::visit_stmt().
|
static |
Compute a lattice value from the components of a complex type REAL and IMAG.
References i, ONLY_IMAG, ONLY_REAL, r, some_nonzerop(), and UNINITIALIZED.
Referenced by find_lattice_value(), and complex_propagate::visit_stmt().
Retrieve a value for a complex component of SSA_NAME.
References build_int_cst(), build_real(), cfun, complex_ssa_name_components, dconst0, find_lattice_value(), get_component_var(), lattice, make_ssa_name(), NULL, ONLY_IMAG, ONLY_REAL, SCALAR_FLOAT_TYPE_P, set_ssa_default_def(), ssa_name, SSA_NAME_DEF_STMT, SSA_NAME_IS_DEFAULT_DEF, SSA_NAME_OCCURS_IN_ABNORMAL_PHI, SSA_NAME_VAR, SSA_NAME_VERSION, TREE_TYPE, and VAR_P.
Referenced by extract_component(), set_component_ssa_name(), and update_phi_components().
Retrieve a value for a complex component of VAR.
References create_one_component_var(), cvc_insert(), cvc_lookup(), DECL_UID, NULL, and TREE_TYPE.
Referenced by get_component_ssa_name(), and set_component_ssa_name().
|
static |
ARG is the argument to a cabs builtin call in GSI from the original OLD_STMT. Create a sequence of statements prior to GSI that calculates sqrt(R*R + I*I), where R and I are the real and imaginary components of ARG, respectively.
References build_real_truncate(), dconst_sqrt2, extract_component(), gimple_bb(), gimple_build(), gimple_build_assign(), gimple_build_call(), gimple_call_arg(), gimple_call_lhs(), gimple_call_set_lhs(), gimple_location(), gimple_set_location(), gsi_insert_seq_before(), gsi_replace(), GSI_SAME_STMT, mathfn_built_in(), NULL, operand_equal_p(), optab_handler(), optimize_bb_for_speed_p(), real_zerop(), TREE_TYPE, and TYPE_MODE.
Referenced by expand_complex_operations_1().
|
static |
Initialize simulation state for each statement. Return false if we found no statements we want to simulate, and thus there's nothing for the entire pass to do.
References cfun, FOR_EACH_BB_FN, gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_call_combined_fn(), gimple_call_lhs(), gimple_cond_lhs(), gimple_cond_rhs(), gimple_expr_code(), gimple_num_ops(), gimple_op(), gimple_phi_result(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_start_phis(), gsi_stmt(), is_complex_reg(), NULL_TREE, prop_set_simulate_again(), ssa_undefined_value_p(), stmt_ends_bb_p(), TREE_CODE, TREE_OPERAND, and TREE_TYPE.
Referenced by tree_lower_complex().
|
static |
Mark the incoming parameters to the function as VARYING.
References cfun, complex_lattice_values, DECL_ARGUMENTS, DECL_CHAIN, is_complex_reg(), NULL_TREE, ssa_default_def(), ssa_name, SSA_NAME_VERSION, and VARYING.
Referenced by tree_lower_complex().
Determine if LHS is something for which we're interested in seeing simulation results.
References is_gimple_reg(), TREE_CODE, and TREE_TYPE.
Referenced by init_dont_simulate_again(), init_parameter_lattice_values(), and update_phi_components().
gimple_opt_pass * make_pass_lower_complex | ( | gcc::context * | ctxt | ) |
gimple_opt_pass * make_pass_lower_complex_O0 | ( | gcc::context * | ctxt | ) |
|
static |
Set a value for a complex component of SSA_NAME, return a gimple_seq of stuff that needs doing.
References comp, complex_ssa_name_components, DECL_IGNORED_P, find_lattice_value(), force_gimple_operand(), gcc_assert, get_component_ssa_name(), get_component_var(), gimple_build_assign(), gimple_seq_add_stmt(), is_gimple_min_invariant(), last, lattice, NULL, ONLY_IMAG, ONLY_REAL, replace_ssa_name_symbol(), ssa_name, SSA_NAME_DEF_STMT, SSA_NAME_IS_DEFAULT_DEF, SSA_NAME_OCCURS_IN_ABNORMAL_PHI, SSA_NAME_VAR, SSA_NAME_VERSION, and TREE_CODE.
Referenced by expand_complex_asm(), update_complex_components(), and update_complex_components_on_edge().
|
static |
Return true if T is not a zero constant. In the case of real values, we're only interested in +0.0.
References dconst0, fixed_zerop(), integer_zerop(), real_identical(), TREE_CODE, TREE_REAL_CST, and zerop().
Referenced by find_lattice_value_parts().
|
static |
Entry point for complex operation lowering during optimization.
References BASIC_BLOCK_FOR_FN, BITMAP_ALLOC, BITMAP_FREE, cfun, complex_lattice_values, complex_ssa_name_components, complex_variable_components, dce_worklist, expand_complex_operations_1(), extract_component(), free(), gimple_phi_arg_def(), gimple_phi_num_args(), gimple_purge_all_dead_eh_edges(), gsi_commit_edge_inserts(), gsi_end_p(), gsi_next(), gsi_start_bb(), i, init_dont_simulate_again(), init_parameter_lattice_values(), is_gimple_min_invariant(), last_basic_block_for_fn, need_eh_cleanup, NULL, num_ssa_names, phis_to_revisit, pre_and_rev_post_order_compute(), SET_PHI_ARG_DEF, simple_dce_from_worklist(), ssa_propagation_engine::ssa_propagate(), todo, TODO_cleanup_cfg, TREE_CODE, update_parameter_components(), and update_phi_components().
|
static |
Update an assignment to a complex variable in place.
References bitmap_set_bit, dce_worklist, gimple_assign_lhs(), gimple_assign_set_rhs_with_ops(), gimple_bb(), gsi_stmt(), i, maybe_clean_or_replace_eh_stmt(), need_eh_cleanup, r, SSA_NAME_VERSION, update_complex_components(), and update_stmt().
Referenced by expand_complex_addition(), expand_complex_conjugate(), expand_complex_div_straight(), expand_complex_div_wide(), expand_complex_division(), expand_complex_move(), expand_complex_multiplication(), expand_complex_negation(), and expand_complex_paren().
|
static |
Update the complex components of the ssa name on the lhs of STMT.
References gimple_get_lhs(), GSI_CONTINUE_LINKING, gsi_insert_seq_after(), i, r, and set_component_ssa_name().
Referenced by expand_complex_libcall(), expand_complex_move(), and update_complex_assignment().
References gsi_insert_seq_on_edge(), i, r, and set_component_ssa_name().
Referenced by expand_complex_move(), and update_parameter_components().
|
static |
Generate code at the entry point of the function to initialize the component variables for a complex parameter.
References build1(), cfun, DECL_ARGUMENTS, DECL_CHAIN, ENTRY_BLOCK_PTR_FOR_FN, i, is_gimple_reg(), r, single_succ_edge(), ssa_default_def(), ssa_name, TREE_CODE, TREE_TYPE, and update_complex_components_on_edge().
Referenced by tree_lower_complex().
|
static |
Generate code to set the component variables of a complex variable to match the PHI statements in block BB.
References comp, create_phi_node(), create_tmp_reg(), extract_component(), get_component_ssa_name(), get_name(), gimple_phi_arg_def(), gimple_phi_num_args(), gimple_phi_result(), gsi_end_p(), gsi_next(), gsi_start_phis(), i, is_complex_reg(), NULL, gphi_iterator::phi(), phis_to_revisit, SET_PHI_ARG_DEF, SSA_NAME_DEF_STMT, SSA_NAME_VAR, TREE_CODE, and TREE_TYPE.
Referenced by tree_lower_complex().
|
static |
For each complex SSA_NAME, a pair of ssa names for the components.
Referenced by get_component_ssa_name(), set_component_ssa_name(), and tree_lower_complex().
|
static |
For each complex variable, a pair of variables for the components exists in the hashtable.
Referenced by cvc_insert(), cvc_lookup(), and tree_lower_complex().
|
static |
SSA defs we should try to DCE.
Referenced by fold_stmt_1(), mark_lhs_in_seq_for_dce(), replace_stmt_with_simplification(), tree_lower_complex(), and update_complex_assignment().
|
static |
BBs that need EH cleanup.
Referenced by expand_complex_comparison(), dom_opt_dom_walker::optimize_stmt(), simple_dce_from_worklist(), tree_lower_complex(), and update_complex_assignment().
Vector of PHI triplets (original complex PHI and corresponding real and imag PHIs if real and/or imag PHIs contain temporarily non-SSA_NAME/non-invariant args that need to be replaced by SSA_NAMEs.
Referenced by tree_lower_complex(), and update_phi_components().