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 "timevar.h"
#include "ssa.h"
#include "gimple-pretty-print.h"
#include "diagnostic-core.h"
#include "stmt.h"
#include "print-tree.h"
#include "dumpfile.h"
Data Structures | |
class | operands_scanner |
Macros | |
#define | INCLUDE_MEMORY |
#define | opf_use 0 |
#define | opf_def (1 << 0) |
#define | opf_no_vops (1 << 1) |
#define | opf_non_addressable (1 << 3) |
#define | opf_not_non_addressable (1 << 4) |
#define | opf_address_taken (1 << 5) |
#define | OP_SIZE_INIT 0 |
#define | OP_SIZE_1 (1024 - sizeof (void *)) |
#define | OP_SIZE_2 (1024 * 4 - sizeof (void *)) |
#define | OP_SIZE_3 (1024 * 16 - sizeof (void *)) |
#define INCLUDE_MEMORY |
SSA operands management for trees. Copyright (C) 2003-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/>.
#define OP_SIZE_1 (1024 - sizeof (void *)) |
Referenced by ssa_operand_alloc().
#define OP_SIZE_2 (1024 * 4 - sizeof (void *)) |
Referenced by ssa_operand_alloc().
#define OP_SIZE_3 (1024 * 16 - sizeof (void *)) |
Referenced by ssa_operand_alloc().
#define OP_SIZE_INIT 0 |
These are the sizes of the operand memory buffer in bytes which gets allocated each time more operands space is required. The final value is the amount that is allocated every time after that. In 1k we can fit 25 use operands (or 63 def operands) on a host with 8 byte pointers, that would be 10 statements each with 1 def and 2 uses.
Referenced by init_ssa_operands(), and ssa_operand_alloc().
#define opf_address_taken (1 << 5) |
Operand is having its address taken.
Referenced by operands_scanner::get_expr_operands().
#define opf_def (1 << 0) |
Operand is the target of an assignment expression or a call-clobbered variable.
Referenced by operands_scanner::add_stmt_operand(), operands_scanner::add_virtual_operand(), operands_scanner::get_asm_stmt_operands(), operands_scanner::maybe_add_call_vops(), and operands_scanner::parse_ssa_operands().
#define opf_no_vops (1 << 1) |
No virtual operands should be created in the expression. This is used when traversing ADDR_EXPR nodes which have different semantics than other expressions. Inside an ADDR_EXPR node, the only operands that we need to consider are indices into arrays. For instance, &a.b[i] should generate a USE of 'i' but it should not generate a VUSE for 'a' nor a VUSE for 'b'.
Referenced by operands_scanner::add_stmt_operand(), operands_scanner::add_virtual_operand(), operands_scanner::get_expr_operands(), operands_scanner::get_mem_ref_operands(), operands_scanner::get_tmr_operands(), and operands_scanner::parse_ssa_operands().
#define opf_non_addressable (1 << 3) |
Operand is in a place where address-taken does not imply addressable.
Referenced by operands_scanner::get_expr_operands(), operands_scanner::get_mem_ref_operands(), and operands_scanner::get_tmr_operands().
#define opf_not_non_addressable (1 << 4) |
Operand is in a place where opf_non_addressable does not apply.
Referenced by operands_scanner::get_asm_stmt_operands(), operands_scanner::get_expr_operands(), operands_scanner::get_mem_ref_operands(), and operands_scanner::get_tmr_operands().
#define opf_use 0 |
This file contains the code required to manage the operands cache of the SSA optimizer. For every stmt, we maintain an operand cache in the stmt annotation. This cache contains operands that will be of interest to optimizers and other passes wishing to manipulate the IL. The operand type are broken up into REAL and VIRTUAL operands. The real operands are represented as pointers into the stmt's operand tree. Thus any manipulation of the real operands will be reflected in the actual tree. Virtual operands are represented solely in the cache, although the base variable for the SSA_NAME may, or may not occur in the stmt's tree. Manipulation of the virtual operands will not be reflected in the stmt tree. The routines in this file are concerned with creating this operand cache from a stmt tree. The operand tree is the parsed by the various get_* routines which look through the stmt tree for the occurrence of operands which may be of interest, and calls are made to the append_* routines whenever one is found. There are 4 of these routines, each representing one of the 4 types of operands. Defs, Uses, Virtual Uses, and Virtual May Defs. The append_* routines check for duplication, and simply keep a list of unique objects for each operand type in the build_* extendable vectors. Once the stmt tree is completely parsed, the finalize_ssa_operands() routine is called, which proceeds to perform the finalization routine on each of the 4 operand vectors which have been built up. If the stmt had a previous operand cache, the finalization routines attempt to match up the new operands with the old ones. If it's a perfect match, the old vector is simply reused. If it isn't a perfect match, then a new vector is created and the new operands are placed there. For virtual operands, if the previous cache had SSA_NAME version of a variable, and that same variable occurs in the same operands cache, then the new cache vector will also get the same SSA_NAME. i.e., if a stmt had a VUSE of 'a_5', and 'a' occurs in the new operand vector for VUSE, then the new vector will also be modified such that it contains 'a_5' rather than 'a'.
Flags to describe operand properties in helpers.
By default, operands are loaded.
Referenced by operands_scanner::get_expr_operands(), operands_scanner::get_mem_ref_operands(), operands_scanner::get_tmr_operands(), operands_scanner::maybe_add_call_vops(), and operands_scanner::parse_ssa_operands().
|
inlinestatic |
Adds OP to the list of uses of statement STMT after LAST.
References alloc_use(), last, link_imm_use_stmt(), filedep::next, use_optype_d::next, NULL, and USE_OP_PTR.
Referenced by operands_scanner::finalize_ssa_uses().
|
inlinestatic |
Allocate a USE operand.
References ssa_operands::free_uses, gimple_ssa_operands(), use_optype_d::next, and ssa_operand_alloc().
Referenced by add_use_op().
|
static |
Create the VOP variable, an artificial global variable to act as a representative of all of the virtual operands FUD chain.
References build_decl(), BUILTINS_LOCATION, DECL_ARTIFICIAL, DECL_CONTEXT, DECL_EXTERNAL, DECL_IGNORED_P, gcc_assert, get_identifier(), function::gimple_df, NULL_TREE, TREE_ADDRESSABLE, TREE_READONLY, TREE_STATIC, TREE_THIS_VOLATILE, TREE_USED, VAR_DECL_IS_VIRTUAL_OPERAND, void_type_node, and gimple_df::vop.
Referenced by init_ssa_operands().
DEBUG_FUNCTION void debug_immediate_uses | ( | void | ) |
Dump def-use edges on stderr.
References dump_immediate_uses().
DEBUG_FUNCTION void debug_immediate_uses_for | ( | tree | var | ) |
Dump def-use edges on stderr.
References dump_immediate_uses_for().
void dump_immediate_uses | ( | FILE * | file | ) |
Dump all the immediate uses to FILE.
References cfun, dump_immediate_uses_for(), and FOR_EACH_SSA_NAME.
Referenced by debug_immediate_uses().
void dump_immediate_uses_for | ( | FILE * | file, |
tree | var ) |
Dump all the immediate uses to FILE.
References FOR_EACH_IMM_USE_FAST, gcc_assert, has_single_use(), has_zero_uses(), is_gimple_reg(), ssa_use_operand_t::loc, NULL, num_imm_uses(), print_generic_expr(), print_gimple_stmt(), ssa_use_operand_t::stmt, TDF_MEMSYMS, TDF_SLIM, TDF_VOPS, TREE_CODE, ssa_use_operand_t::use, USE_FROM_PTR, and USE_STMT.
Referenced by debug_immediate_uses_for(), and dump_immediate_uses().
void fini_ssa_operands | ( | struct function * | fn | ) |
Dispose of anything required by the operand routines.
References ssa_operands::free_uses, ggc_free(), function::gimple_df, gimple_ssa_operands(), ssa_operand_memory_d::next, NULL, NULL_TREE, ssa_operands::operand_memory, ssa_operands::ops_active, and gimple_df::vop.
Referenced by delete_tree_ssa().
Releases the operands of STMT back to their freelists, and clears the stmt operand lists.
References delink_imm_use(), ssa_operands::free_uses, gimple_has_mem_ops(), gimple_set_use_ops(), gimple_set_vdef(), gimple_set_vuse(), gimple_ssa_operands(), gimple_use_ops(), use_optype_d::next, NULL, NULL_TREE, and USE_OP_PTR.
Referenced by move_block_to_fn().
|
inlinestatic |
Accessor to tree-ssa-operands.cc caches.
References function::gimple_df, and gimple_df::ssa_operands.
Referenced by alloc_use(), operands_scanner::finalize_ssa_uses(), fini_ssa_operands(), free_stmt_operands(), init_ssa_operands(), ssa_operand_alloc(), and ssa_operands_active().
void init_ssa_operands | ( | struct function * | fn | ) |
Initialize the operand cache routines.
References create_vop_var(), gcc_assert, gimple_ssa_operands(), NULL, OP_SIZE_INIT, ssa_operands::operand_memory, ssa_operands::operand_memory_index, ssa_operands::ops_active, and ssa_operands::ssa_operand_mem_size.
Referenced by expand_omp_taskreg(), init_lowered_empty_function(), initialize_cfun(), and input_ssa_names().
|
static |
Mark the base address of REF as having its address taken. REF may be a single variable whose address has been taken or any other valid GIMPLE memory reference (structure reference, array, etc).
References get_base_address(), TREE_ADDRESSABLE, TREE_CODE, and VAR_P.
Referenced by operands_scanner::get_asm_stmt_operands(), and operands_scanner::get_expr_operands().
bool single_imm_use_1 | ( | const ssa_use_operand_t * | head, |
use_operand_p * | use_p, | ||
gimple ** | stmt ) |
Return true if the var whose chain of uses starts at PTR has a single nondebug use. Set USE_P and STMT to that single nondebug use, if so, or to NULL otherwise.
References is_gimple_debug(), ssa_use_operand_t::next, NULL, single_use(), and USE_STMT.
Referenced by single_imm_use().
|
inlinestatic |
Return memory for an operand of size SIZE.
References gcc_assert, gcc_unreachable, ggc_internal_alloc(), gimple_ssa_operands(), ssa_operand_memory_d::mem, ssa_operand_memory_d::next, OP_SIZE_1, OP_SIZE_2, OP_SIZE_3, OP_SIZE_INIT, ssa_operands::operand_memory, ssa_operands::operand_memory_index, and ssa_operands::ssa_operand_mem_size.
Referenced by alloc_use().
Return true if the SSA operands cache is active.
References function::gimple_df, gimple_ssa_operands(), NULL, and ssa_operands::ops_active.
Referenced by delete_tree_ssa(), delink_stmt_imm_use(), update_modified_stmt(), update_modified_stmts(), and update_stmt_operands().
Swap operands EXP0 and EXP1 in statement STMT. No attempt is done to test the validity of the swap operation.
References gimple_use_ops(), use_optype_d::next, NULL, and USE_OP_PTR.
Referenced by linearize_expr_tree(), optimize_vec_cond_expr(), parloops_is_simple_reduction(), parloops_is_slp_reduction(), reorder_operands(), and repropagate_negates().
void unlink_stmt_vdef | ( | gimple * | stmt | ) |
Unlink STMTs virtual definition from the IL by propagating its use.
References FOR_EACH_IMM_USE_ON_STMT, FOR_EACH_IMM_USE_STMT, gimple_vdef(), gimple_vuse(), SET_USE, SSA_NAME_OCCURS_IN_ABNORMAL_PHI, and TREE_CODE.
Referenced by strlen_pass::adjust_last_stmt(), adjust_simduid_builtins(), cleanup_empty_eh_move_lp(), cond_if_else_store_replacement_1(), cond_store_replacement(), delete_dead_or_redundant_assignment(), delete_dead_or_redundant_call(), eliminate_dom_walker::eliminate_cleanup(), eliminate_local_variables_stmt(), execute_omp_device_lower(), execute_update_addresses_taken(), expand_call_inline(), expand_ifn_va_arg_1(), operands_scanner::finalize_ssa_defs(), generate_loops_for_partition(), gimple_fold_builtin_memory_op(), gimple_ic(), gimple_stringop_fixed_value(), gimplify_and_update_call_from_tree(), gsi_replace_with_seq_vops(), strlen_pass::handle_builtin_memset(), strlen_pass::handle_store(), hoist_memory_references(), input_function(), maybe_remove_writeonly_store(), tree_loop_interchange::move_code_to_inner_loop(), optimize_clobbers(), dom_opt_dom_walker::optimize_stmt(), optimize_vector_load(), predicate_statements(), propagate_op_to_single_use(), propagate_with_phi(), remove_dead_stmt(), remove_indirect_clobbers(), remove_prop_source_from_use(), pcom_worker::remove_stmt(), vec_info::remove_stmt(), remove_unused_locals(), replace_call_with_value(), ipa_param_body_adjustments::reset_debug_stmts(), sanopt_optimize_walker(), simple_dce_from_worklist(), simplify_builtin_call(), sink_clobbers(), sink_common_stores_to_bb(), sra_modify_assign(), sra_modify_constructor_assign(), sra_modify_deferred_init(), ubsan_expand_bounds_ifn(), ubsan_expand_null_ifn(), ubsan_expand_objsize_ifn(), ubsan_expand_ptr_ifn(), ubsan_expand_vptr_ifn(), loop_cand::undo_simple_reduction(), vect_remove_slp_scalar_calls(), vect_transform_loop(), and vectorizable_simd_clone_call().
Get the operands of statement STMT.
References operands_scanner::build_ssa_operands(), gcc_assert, gimple_modified_p(), gimple_set_modified(), ssa_operands_active(), timevar_pop(), and timevar_push().
Referenced by update_stmt(), update_stmt_fn(), and update_stmt_if_modified().
DEBUG_FUNCTION bool verify_imm_links | ( | FILE * | f, |
tree | var ) |
Scan the immediate_use list for VAR making sure its linked properly. Return TRUE if there is a problem and emit an error message to F.
References count, error(), gcc_assert, gimple_modified_p(), ssa_use_operand_t::loc, ssa_use_operand_t::next, NULL, ssa_use_operand_t::prev, print_generic_expr(), print_gimple_stmt(), SSA_NAME_IMM_USE_NODE, ssa_use_operand_t::stmt, TDF_SLIM, TREE_CODE, ssa_use_operand_t::use, and USE_FROM_PTR.
Referenced by release_ssa_name_fn(), and verify_use().
DEBUG_FUNCTION bool verify_ssa_operands | ( | struct function * | fn, |
gimple * | stmt ) |
Interface for external use.
References operands_scanner::verify_ssa_operands().
Referenced by verify_ssa().