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/* Given an instance of callback attribute, return the 0-based
47 index of the called function in question. */
48int callback_get_fn_index (tree cb_attr);
49
50/* For a given callback pair, retrieves the callback attribute used
51 to create E from the callee of CARRYING. */
53
54/* Given an instance of callback attribute, return the 0-base indices
55 of arguments passed to the callback. For a callback function taking
56 n parameters, returns a vector of n indices of their values in the parameter
57 list of it's caller. Indices with unknown positions contain -1. */
59
60/* For a callback pair, returns the 0-based index of the address of
61 E's callee in the argument list of CARRYING's callee decl. */
63
64/* Handle a "callback" attribute; arguments as in
65 struct attribute_spec.handler. */
67 bool *no_add_attrs);
68
69/* Returns TRUE if E is considered useful in the callgraph, FALSE otherwise. If
70 this predicate returns FALSE, then E wasn't used to optimize its callee and
71 can be safely removed from the callgraph. */
73
74/* Returns the number of arguments the callback function described by ATTR
75 takes. */
76size_t callback_num_args (tree attr);
77
78#endif /* ATTR_CALLBACK_H */
int callback_fetch_fn_position(cgraph_edge *e, cgraph_edge *carrying)
Definition attr-callback.cc:155
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:99
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:344
auto_vec< int > callback_get_arg_mapping(cgraph_edge *e, cgraph_edge *carrying)
Definition attr-callback.cc:130
int callback_get_fn_index(tree cb_attr)
Definition attr-callback.cc:89
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:358
Definition vec.h:1667
Definition cgraph.h:1730
union tree_node * tree
Definition coretypes.h:97
Definition custom-sarif-properties/state-graphs.h:33
Definition genautomata.cc:499
Definition gimple.h:352