summaryrefslogtreecommitdiff
path: root/gcc/cgraph.h
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2012-04-10 16:03:36 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2012-04-10 16:03:36 +0000
commitb6c89d329fa8112bd0d11e199263a4d2b0c57c28 (patch)
tree7f3b302f0d6eb4540bd850a0c5e0a38b29f73019 /gcc/cgraph.h
parent37598f0f97ec961cee103989521a56a682b6be04 (diff)
downloadgcc-b6c89d329fa8112bd0d11e199263a4d2b0c57c28.tar.gz
* cgraph.h: Remove misledaing comment on ipa-ref.h.
(symtab_type): New enum. (symtab_node): New structure. (cgraph_node, varpool_node): Add symbol base type. (cgraph, varpool): New accestor functions. * cgraph.c (cgraph_create_node_1): Set symbol type. * varpool.c (varpool_node): Set symbol type. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@186284 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cgraph.h')
-rw-r--r--gcc/cgraph.h37
1 files changed, 36 insertions, 1 deletions
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index dc085e181d0..8740fba7c47 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -27,7 +27,23 @@ along with GCC; see the file COPYING3. If not see
#include "tree.h"
#include "basic-block.h"
#include "function.h"
-#include "ipa-ref.h" /* FIXME: inappropriate dependency of cgraph on IPA. */
+#include "ipa-ref.h"
+
+/* Symbol table consists of functions and variables.
+ TODO: add labels, constant pool and aliases. */
+enum symtab_type
+{
+ SYMTAB_FUNCTION,
+ SYMTAB_VARIABLE
+};
+
+/* Base of all entries in the symbol table.
+ The symtab_node is inherited by cgraph and varpol nodes. */
+struct GTY(()) symtab_node
+{
+ /* Type of the symbol. */
+ enum symtab_type type;
+};
enum availability
{
@@ -150,6 +166,7 @@ struct GTY(()) cgraph_clone_info
Each function decl has assigned cgraph_node listing callees and callers. */
struct GTY((chain_next ("%h.next"), chain_prev ("%h.previous"))) cgraph_node {
+ struct symtab_node symbol;
tree decl;
struct cgraph_edge *callees;
struct cgraph_edge *callers;
@@ -387,6 +404,7 @@ DEF_VEC_ALLOC_P(cgraph_edge_p,heap);
Each static variable decl has assigned varpool_node. */
struct GTY((chain_next ("%h.next"), chain_prev ("%h.prev"))) varpool_node {
+ struct symtab_node symbol;
tree decl;
/* For aliases points to declaration DECL is alias of. */
tree alias_of;
@@ -689,6 +707,23 @@ void varpool_add_new_variable (tree);
#define FOR_EACH_STATIC_VARIABLE(node) \
for ((node) = varpool_nodes_queue; (node); (node) = (node)->next_needed)
+/* Return callgraph node for given symbol and check it is a function. */
+static inline struct cgraph_node *
+cgraph (struct symtab_node *node)
+{
+ gcc_checking_assert (node->type == SYMTAB_FUNCTION);
+ return (struct cgraph_node *)node;
+}
+
+/* Return varpool node for given symbol and check it is a variable. */
+static inline struct varpool_node *
+varpool (struct symtab_node *node)
+{
+ gcc_checking_assert (node->type == SYMTAB_FUNCTION);
+ return (struct varpool_node *)node;
+}
+
+
/* Return first reachable static variable with initializer. */
static inline struct varpool_node *
varpool_first_static_initializer (void)