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 "alloc-pool.h"
#include "cgraph.h"
#include "diagnostic.h"
#include "builtins.h"
#include "options.h"
#include "gimple-range.h"
#include "attribs.h"
#include "attr-callback.h"
Functions | |
tree | callback_build_attr (unsigned fn_idx, unsigned arg_count...) |
bool | callback_is_special_cased (tree decl, gcall *stmt) |
tree | callback_special_case_attr (tree decl) |
int | callback_get_fn_index (tree cb_attr) |
tree | callback_fetch_attr_by_edge (cgraph_edge *e, cgraph_edge *carrying) |
auto_vec< int > | callback_get_arg_mapping (cgraph_edge *e, cgraph_edge *carrying) |
int | callback_fetch_fn_position (cgraph_edge *e, cgraph_edge *carrying) |
static tree | get_nth_list_elem (tree list, unsigned idx) |
tree | handle_callback_attribute (tree *node, tree name, tree args, int ARG_UNUSED(flags), bool *no_add_attrs) |
bool | callback_edge_useful_p (cgraph_edge *e) |
size_t | callback_num_args (tree attr) |
tree callback_build_attr | ( | unsigned | fn_idx, |
unsigned | arg_count... ) |
Callback attribute handling Copyright (C) 2025 Free Software Foundation, Inc. Contributed by Josef Melcr <jmelcr@gcc.gnu.org> This file is part of GCC. GCC is free software; you can redistribute it and/or modify under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, 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/>.
Returns a callback attribute with callback index FN_IDX, and ARG_COUNT arguments specified by VA_ARGS.
References build_int_cst(), build_tree_list(), CALLBACK_ATTR_IDENT, get_identifier(), i, integer_type_node, NULL, NULL_TREE, PASS_MEM_STAT, TREE_CHAIN, and tree_cons().
Referenced by callback_special_case_attr(), and set_call_expr_flags().
bool callback_edge_useful_p | ( | cgraph_edge * | e | ) |
Returns TRUE if E is considered useful in the callgraph, FALSE otherwise. If this predicate returns FALSE, then E wasn't used to optimize its callee and can be safely removed from the callgraph.
References gcc_checking_assert.
Referenced by purge_useless_callback_edges().
tree callback_fetch_attr_by_edge | ( | cgraph_edge * | e, |
cgraph_edge * | carrying ) |
For a given callback pair, retrieves the callback attribute used to create E from the callee of CARRYING.
References cgraph_edge::call_stmt, CALLBACK_ATTR_IDENT, callback_get_fn_index(), callback_is_special_cased(), callback_special_case_attr(), cgraph_edge::callee, symtab_node::decl, DECL_ATTRIBUTES, gcc_checking_assert, lookup_attribute(), cgraph_edge::lto_stmt_uid, NULL_TREE, and TREE_CHAIN.
Referenced by callback_fetch_fn_position(), and callback_get_arg_mapping().
int callback_fetch_fn_position | ( | cgraph_edge * | e, |
cgraph_edge * | carrying ) |
For a callback pair, returns the 0-based index of the address of E's callee in the argument list of CARRYING's callee decl.
References callback_fetch_attr_by_edge(), and callback_get_fn_index().
Referenced by cgraph_edge::redirect_call_stmt_to_callee().
auto_vec< int > callback_get_arg_mapping | ( | cgraph_edge * | e, |
cgraph_edge * | carrying ) |
Given an instance of callback attribute, return the 0-base indices of arguments passed to the callback. For a callback function taking n parameters, returns a vector of n indices of their values in the parameter list of it's caller. Indices with unknown positions contain -1.
References callback_fetch_attr_by_edge(), CB_UNKNOWN_POS, gcc_checking_assert, NULL_TREE, TREE_CHAIN, TREE_INT_CST_LOW, and TREE_VALUE.
Referenced by ipa_compute_jump_functions_for_edge().
int callback_get_fn_index | ( | tree | cb_attr | ) |
Given an instance of callback attribute, return the 0-based index of the called function in question.
References TREE_INT_CST_LOW, and TREE_VALUE.
Referenced by callback_fetch_attr_by_edge(), callback_fetch_fn_position(), handle_callback_attribute(), and ipa_compute_jump_functions_for_edge().
Returns TRUE if a function should be treated as if it had a callback attribute despite the DECL not having it. STMT can be passed NULL if the call statement is not available at the time, for example WPA, but it should be called with the statement itself whenever possible.
References fndecl_built_in_p(), gimple_call_arg(), and null_pointer_node.
Referenced by callback_fetch_attr_by_edge(), ipa_compute_jump_functions_for_edge(), purge_useless_callback_edges(), cgraph_edge::redirect_call_stmt_to_callee(), and cgraph_node::verify_node().
size_t callback_num_args | ( | tree | attr | ) |
Returns the number of arguments the callback function described by ATTR takes.
References NULL_TREE, TREE_CHAIN, and TREE_VALUE.
Referenced by init_callback_edge_summary().
Returns an attribute for a special cased function.
References callback_build_attr(), fndecl_built_in_p(), and gcc_unreachable.
Referenced by callback_fetch_attr_by_edge(), and ipa_compute_jump_functions_for_edge().
Returns the element at index idx in the list or NULL_TREE if the list isn't long enough. NULL_TREE is used as the endpoint.
References i, NULL_TREE, TREE_CHAIN, and TREE_VALUE.
Referenced by handle_callback_attribute().
tree handle_callback_attribute | ( | tree * | node, |
tree | name, | ||
tree | args, | ||
int | ARG_UNUSEDflags, | ||
bool * | no_add_attrs ) |
Handle a "callback" attribute; arguments as in struct attribute_spec.handler.
References arg_type, CALLBACK_ATTR_IDENT, callback_get_fn_index(), CB_UNKNOWN_POS, DECL_ATTRIBUTES, DECL_SOURCE_LOCATION, error_at(), get_nth_list_elem(), list_length(), lookup_attribute(), NULL_TREE, TREE_CHAIN, TREE_CODE, TREE_INT_CST_LOW, TREE_TYPE, TREE_VALUE, TYPE_ARG_TYPES, types_compatible_p(), and void_list_node.