cgraph.h: Remove misledaing comment on ipa-ref.h.
authorJan Hubicka <jh@suse.cz>
Tue, 10 Apr 2012 16:03:36 +0000 (18:03 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Tue, 10 Apr 2012 16:03:36 +0000 (16:03 +0000)
* 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.

From-SVN: r186284

gcc/ChangeLog
gcc/cgraph.c
gcc/cgraph.h
gcc/varpool.c

index bd7a2c7377d909d82bbbcfdd2d218c5a009ba428..d346e435a2480b7c22b817a81767a557504ecd8f 100644 (file)
@@ -1,3 +1,13 @@
+2012-04-10  Jan Hubicka  <jh@suse.cz>
+
+       * 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.
+
 2012-04-10  Ulrich Weigand  <ulrich.weigand@linaro.org>
            Richard Sandiford  <rdsandiford@googlemail.com>
 
index 6c315072d9f35fbcfc3549f2977831203ab0e23b..61a8e235fe30690844e43265f3588217f183c722 100644 (file)
@@ -473,6 +473,7 @@ cgraph_create_node_1 (void)
 {
   struct cgraph_node *node = cgraph_allocate_node ();
 
+  node->symbol.type = SYMTAB_FUNCTION;
   node->next = cgraph_nodes;
   node->order = cgraph_order++;
   if (cgraph_nodes)
index dc085e181d0084d39af616a515ed0a092672c2b0..8740fba7c4731d83254802344e2dfc7be24a7940 100644 (file)
@@ -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)
index e064f7bd6485db3d5bb5dd3bb24647174b4c1710..043de4c607b88738f5dd67ff0cd4bd84203e6d4b 100644 (file)
@@ -142,6 +142,7 @@ varpool_node (tree decl)
   if (*slot)
     return *slot;
   node = ggc_alloc_cleared_varpool_node ();
+  node->symbol.type = SYMTAB_VARIABLE;
   node->decl = decl;
   node->order = cgraph_order++;
   node->next = varpool_nodes;