diff options
Diffstat (limited to 'gcc/cgraph.h')
-rw-r--r-- | gcc/cgraph.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/gcc/cgraph.h b/gcc/cgraph.h index 35d1a9d..e250ecd 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -695,6 +695,79 @@ varpool_next_static_initializer (struct varpool_node *node) for ((node) = varpool_first_static_initializer (); (node); \ (node) = varpool_next_static_initializer (node)) +/* Return first function with body defined. */ +static inline struct cgraph_node * +cgraph_first_defined_function (void) +{ + struct cgraph_node *node; + for (node = cgraph_nodes; node; node = node->next) + { + if (node->analyzed) + return node; + } + return NULL; +} + +/* Return next reachable static variable with initializer after NODE. */ +static inline struct cgraph_node * +cgraph_next_defined_function (struct cgraph_node *node) +{ + for (node = node->next; node; node = node->next) + { + if (node->analyzed) + return node; + } + return NULL; +} + +/* Walk all functions with body defined. */ +#define FOR_EACH_DEFINED_FUNCTION(node) \ + for ((node) = cgraph_first_defined_function (); (node); \ + (node) = cgraph_next_defined_function (node)) + + +/* Return true when NODE is a function with Gimple body defined + in current unit. Functions can also be define externally or they + can be thunks with no Gimple representation. + + Note that at WPA stage, the function body may not be present in memory. */ + +static inline bool +cgraph_function_with_gimple_body_p (struct cgraph_node *node) +{ + return node->analyzed && !node->thunk.thunk_p; +} + +/* Return first function with body defined. */ +static inline struct cgraph_node * +cgraph_first_function_with_gimple_body (void) +{ + struct cgraph_node *node; + for (node = cgraph_nodes; node; node = node->next) + { + if (cgraph_function_with_gimple_body_p (node)) + return node; + } + return NULL; +} + +/* Return next reachable static variable with initializer after NODE. */ +static inline struct cgraph_node * +cgraph_next_function_with_gimple_body (struct cgraph_node *node) +{ + for (node = node->next; node; node = node->next) + { + if (cgraph_function_with_gimple_body_p (node)) + return node; + } + return NULL; +} + +/* Walk all functions with body defined. */ +#define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \ + for ((node) = cgraph_first_function_with_gimple_body (); (node); \ + (node) = cgraph_next_function_with_gimple_body (node)) + /* Create a new static variable of type TYPE. */ tree add_new_static_var (tree type); |