GCC Middle and Back End API Reference
attr-callback.h
Go to the documentation of this file.
1/* Callback attribute handling
2 Copyright (C) 2025 Free Software Foundation, Inc.
3 Contributed by Josef Melcr <jmelcr@gcc.gnu.org>
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
20
21#ifndef ATTR_CALLBACK_H
22#define ATTR_CALLBACK_H
23
25{
26 /* Value used when an argument of a callback function
27 is unknown or when multiple values may be used. */
29};
30
31#define CALLBACK_ATTR_IDENT " callback"
32
33/* Returns a callback attribute with callback index FN_IDX, and ARG_COUNT
34 arguments specified by VA_ARGS. */
35tree callback_build_attr (unsigned fn_idx, unsigned arg_count...);
36
37/* Returns TRUE if a function should be treated as if it had a callback
38 attribute despite the DECL not having it. STMT can be passed NULL
39 if the call statement is not available at the time, for example WPA, but it
40 should be called with the statement itself whenever possible. */
42
43/* Returns an attribute for a special cased function. */
45
46/* Returns TRUE if the callee of E has a callback attribute. */
48
49/* Given an instance of callback attribute, return the 0-based
50 index of the called function in question. */
51int callback_get_fn_index (tree cb_attr);
52
53/* For a given callback pair, retrieves the callback attribute used
54 to create E from the callee of CARRYING. */
56
57/* Given an instance of callback attribute, return the 0-base indices
58 of arguments passed to the callback. For a callback function taking
59 n parameters, returns a vector of n indices of their values in the parameter
60 list of it's caller. Indices with unknown positions contain -1. */
62
63/* For a callback pair, returns the 0-based index of the address of
64 E's callee in the argument list of CARRYING's callee decl. */
66
67/* Handle a "callback" attribute; arguments as in
68 struct attribute_spec.handler. */
70 bool *no_add_attrs);
71
72/* Returns TRUE if E is considered useful in the callgraph, FALSE otherwise. If
73 this predicate returns FALSE, then E wasn't used to optimize its callee and
74 can be safely removed from the callgraph. */
76
77/* Returns the number of arguments the callback function described by ATTR
78 takes. */
79size_t callback_num_args (tree attr);
80
81#endif /* ATTR_CALLBACK_H */
int callback_fetch_fn_position(cgraph_edge *e, cgraph_edge *carrying)
Definition attr-callback.cc:164
bool callback_edge_callee_has_attr(cgraph_edge *e)
Definition attr-callback.cc:88
callback_position
Definition attr-callback.h:25
@ CB_UNKNOWN_POS
Definition attr-callback.h:28
tree callback_build_attr(unsigned fn_idx, unsigned arg_count...)
Definition attr-callback.cc:39
tree callback_fetch_attr_by_edge(cgraph_edge *e, cgraph_edge *carrying)
Definition attr-callback.cc:108
tree handle_callback_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
tree callback_special_case_attr(tree decl)
Definition attr-callback.cc:79
bool callback_edge_useful_p(cgraph_edge *e)
Definition attr-callback.cc:353
auto_vec< int > callback_get_arg_mapping(cgraph_edge *e, cgraph_edge *carrying)
Definition attr-callback.cc:139
int callback_get_fn_index(tree cb_attr)
Definition attr-callback.cc:98
bool callback_is_special_cased(tree decl, gcall *stmt)
Definition attr-callback.cc:66
size_t callback_num_args(tree attr)
Definition attr-callback.cc:375
Definition vec.h:1667
Definition cgraph.h:1747
union tree_node * tree
Definition coretypes.h:97
Definition custom-sarif-properties/state-graphs.h:33
Definition genautomata.cc:499
Definition gimple.h:352