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-2026 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
24/* This enum relates to the attribute's arguments. */
25
27{
28 /* Value used when an argument of a callback function
29 is unknown or when multiple values may be used. */
31};
32
33/* This enum describes values present in the arg_mapping vector. */
34
36{
37 /* Value representing an unknown argument position in the arg_mapping
38 vector. */
40};
41
42/* Returns a callback attribute with callback index FN_IDX, and ARG_COUNT
43 arguments specified by VA_ARGS. */
44tree callback_build_attr (unsigned fn_idx, unsigned arg_count...);
45
46/* Returns TRUE if a function should be treated as if it had a callback
47 attribute despite the DECL not having it. STMT can be passed NULL
48 if the call statement is not available at the time, for example WPA, but it
49 should be called with the statement itself whenever possible. */
51
52/* Returns an attribute for a special cased function. */
54
55/* Returns TRUE if the callee of E has a callback attribute. */
57
58/* Given an instance of callback attribute, return the 0-based
59 index of the called function in question. */
60int callback_get_fn_index (tree cb_attr);
61
62/* For a given callback pair, retrieves the callback attribute used
63 to create E from the callee of CARRYING. */
65
66/* Returns the argument mapping from the dispatching function to the callback
67 function parsed from the attribute. */
69
70/* Returns TRUE if E is considered useful in the callgraph, FALSE otherwise. If
71 this predicate returns FALSE, then E wasn't used to optimize its callee and
72 can be safely removed from the callgraph. */
74
75/* Returns the number of arguments the callback function described by ATTR
76 takes. */
77size_t callback_num_args (tree attr);
78
79#endif /* ATTR_CALLBACK_H */
bool callback_edge_callee_has_attr(cgraph_edge *e)
Definition attr-callback.cc:91
callback_position
Definition attr-callback.h:27
@ CB_UNKNOWN_POS
Definition attr-callback.h:30
arg_mapping_constants
Definition attr-callback.h:36
@ ARG_MAPPING_UNKNOWN_IDX
Definition attr-callback.h:39
tree callback_build_attr(unsigned fn_idx, unsigned arg_count...)
Definition attr-callback.cc:42
tree callback_fetch_attr_by_edge(cgraph_edge *e, cgraph_edge *carrying)
Definition attr-callback.cc:111
tree callback_special_case_attr(tree decl)
Definition attr-callback.cc:82
bool callback_edge_useful_p(cgraph_edge *e)
Definition attr-callback.cc:165
auto_vec< int > callback_get_arg_mapping_from_attr(tree attr)
Definition attr-callback.cc:141
int callback_get_fn_index(tree cb_attr)
Definition attr-callback.cc:101
bool callback_is_special_cased(tree decl, gcall *stmt)
Definition attr-callback.cc:69
size_t callback_num_args(tree attr)
Definition attr-callback.cc:176
Definition vec.h:1667
Definition cgraph.h:1872
union tree_node * tree
Definition coretypes.h:97
Definition genautomata.cc:499
Definition gimple.h:355