1 | /* Header file for Nested function decomposition for GIMPLE. |
2 | Copyright (C) 2013-2023 Free Software Foundation, Inc. |
3 | |
4 | This file is part of GCC. |
5 | |
6 | GCC is free software; you can redistribute it and/or modify it under |
7 | the terms of the GNU General Public License as published by the Free |
8 | Software Foundation; either version 3, or (at your option) any later |
9 | version. |
10 | |
11 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or |
13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
14 | for more details. |
15 | |
16 | You should have received a copy of the GNU General Public License |
17 | along with GCC; see the file COPYING3. If not see |
18 | <http://www.gnu.org/licenses/>. */ |
19 | |
20 | #ifndef GCC_TREE_NESTED_H |
21 | #define GCC_TREE_NESTED_H |
22 | |
23 | extern tree build_addr (tree); |
24 | extern void insert_field_into_struct (tree, tree); |
25 | extern void lower_nested_functions (tree); |
26 | |
27 | class nested_function_info |
28 | { |
29 | public: |
30 | /* Constructor. */ |
31 | nested_function_info () |
32 | : origin (NULL), |
33 | nested (NULL), |
34 | next_nested (NULL) |
35 | { |
36 | } |
37 | /* Copy constructor. We can not simply copy the structure, |
38 | because the linked lists would go wrong. However we should never |
39 | need that. */ |
40 | nested_function_info (const nested_function_info &) |
41 | { |
42 | gcc_unreachable (); |
43 | } |
44 | ~nested_function_info (); |
45 | |
46 | /* Return nested_function_info, if available. */ |
47 | static nested_function_info *get (cgraph_node *node); |
48 | |
49 | /* Return nested_function_info possibly creating new one. */ |
50 | static nested_function_info *get_create (cgraph_node *node); |
51 | |
52 | /* Release all nested_function_infos. */ |
53 | static void release (void); |
54 | |
55 | /* For nested functions points to function the node is nested in. */ |
56 | cgraph_node *origin; |
57 | /* Points to first nested function, if any. */ |
58 | cgraph_node *nested; |
59 | /* Pointer to the next function with same origin, if any. */ |
60 | cgraph_node *next_nested; |
61 | }; |
62 | |
63 | extern void maybe_record_nested_function (cgraph_node *node); |
64 | extern void unnest_function (cgraph_node *node); |
65 | |
66 | /* If there are functions nested in NODE, return first one. */ |
67 | inline cgraph_node * |
68 | first_nested_function (cgraph_node *node) |
69 | { |
70 | nested_function_info *info = nested_function_info::get (node); |
71 | return info ? info->nested : NULL; |
72 | } |
73 | |
74 | /* Return next nested function (used to iterate from first_nested_function). */ |
75 | inline cgraph_node * |
76 | next_nested_function (cgraph_node *node) |
77 | { |
78 | return nested_function_info::get (node)->next_nested; |
79 | } |
80 | |
81 | /* Return origin of nested function (and NULL otherwise). */ |
82 | inline cgraph_node * |
83 | nested_function_origin (cgraph_node *node) |
84 | { |
85 | nested_function_info *info = nested_function_info::get (node); |
86 | return info ? info->origin : NULL; |
87 | } |
88 | |
89 | #endif /* GCC_TREE_NESTED_H */ |
90 | |