diff options
author | David Malcolm <dmalcolm@redhat.com> | 2013-10-29 18:25:17 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2013-10-29 18:25:17 +0000 |
commit | a3bfa8b80c84f097b684b5ba7851ceb81642ccd3 (patch) | |
tree | 1448b6640c11838946a37fc6783f028e1f3c26bb /gcc/cgraph.h | |
parent | c960732f0526add82cdf51879ee1b97c221feb08 (diff) | |
download | gcc-a3bfa8b80c84f097b684b5ba7851ceb81642ccd3.zip gcc-a3bfa8b80c84f097b684b5ba7851ceb81642ccd3.tar.gz gcc-a3bfa8b80c84f097b684b5ba7851ceb81642ccd3.tar.bz2 |
Convert symtab, cgraph and varpool nodes into a real class hierarchy
This is the handwritten part of the patch; automated part to follow.
* cgraph.h (symtab_node_base): Convert to a class;
add GTY((desc ("%h.type"), tag ("SYMTAB_SYMBOL"))), and take
chain_next/prev from symtab_node_def.
(cgraph_node): Inherit from symtab_node; add GTY option
tag ("SYMTAB_FUNCTION").
(varpool_node): Inherit from symtab_node; add GTY option
tag ("SYMTAB_VARIABLE").
(symtab_node_def): Remove.
(is_a_helper <cgraph_node>::test (symtab_node_def *)): Convert to...
(is_a_helper <cgraph_node>::test (symtab_node_base *)): ...this.
(is_a_helper <varpool_node>::test (symtab_node_def *)): Convert to...
(is_a_helper <varpool_node>::test (symtab_node_base *)): ...this.
* ipa-ref.h (symtab_node_def): Drop.
(symtab_node): Change underlying type from symtab_node_def to
symtab_node_base.
(const_symtab_node): Likwise.
* is-a.h: Update examples in comment.
* symtab.c (symtab_hash): Change symtab_node_def to symtab_node_base.
(assembler_name_hash): Likewise.
From-SVN: r204170
Diffstat (limited to 'gcc/cgraph.h')
-rw-r--r-- | gcc/cgraph.h | 40 |
1 files changed, 13 insertions, 27 deletions
diff --git a/gcc/cgraph.h b/gcc/cgraph.h index 7706419..4cc2049 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -39,8 +39,11 @@ enum symtab_type /* Base of all entries in the symbol table. The symtab_node is inherited by cgraph and varpol nodes. */ -struct GTY(()) symtab_node_base +class GTY((desc ("%h.type"), tag ("SYMTAB_SYMBOL"), + chain_next ("%h.next"), chain_prev ("%h.previous"))) + symtab_node_base { +public: /* Type of the symbol. */ ENUM_BITFIELD (symtab_type) type : 8; @@ -251,25 +254,19 @@ struct GTY(()) cgraph_clone_info /* The cgraph data structure. Each function decl has assigned cgraph_node listing callees and callers. */ -struct GTY(()) cgraph_node { - struct symtab_node_base symbol; +struct GTY((tag ("SYMTAB_FUNCTION"))) cgraph_node : public symtab_node_base { +public: struct cgraph_edge *callees; struct cgraph_edge *callers; /* List of edges representing indirect calls with a yet undetermined callee. */ struct cgraph_edge *indirect_calls; /* For nested functions points to function the node is nested in. */ - struct cgraph_node * - GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h"))) - origin; + struct cgraph_node *origin; /* Points to first nested function, if any. */ - struct cgraph_node * - GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h"))) - nested; + struct cgraph_node *nested; /* Pointer to the next function with same origin, if any. */ - struct cgraph_node * - GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h"))) - next_nested; + struct cgraph_node *next_nested; /* Pointer to the next clone. */ struct cgraph_node *next_sibling_clone; struct cgraph_node *prev_sibling_clone; @@ -517,9 +514,8 @@ typedef struct cgraph_edge *cgraph_edge_p; /* The varpool data structure. Each static variable decl has assigned varpool_node. */ -struct GTY(()) varpool_node { - struct symtab_node_base symbol; - +class GTY((tag ("SYMTAB_VARIABLE"))) varpool_node : public symtab_node_base { +public: /* Set when variable is scheduled to be assembled. */ unsigned output : 1; }; @@ -535,22 +531,12 @@ struct GTY(()) asm_node { int order; }; -/* Symbol table entry. */ -union GTY((desc ("%h.symbol.type"), chain_next ("%h.symbol.next"), - chain_prev ("%h.symbol.previous"))) symtab_node_def { - struct symtab_node_base GTY ((tag ("SYMTAB_SYMBOL"))) symbol; - /* To access the following fields, - use the use dyn_cast or as_a to obtain the concrete type. */ - struct cgraph_node GTY ((tag ("SYMTAB_FUNCTION"))) x_function; - struct varpool_node GTY ((tag ("SYMTAB_VARIABLE"))) x_variable; -}; - /* Report whether or not THIS symtab node is a function, aka cgraph_node. */ template <> template <> inline bool -is_a_helper <cgraph_node>::test (symtab_node_def *p) +is_a_helper <cgraph_node>::test (symtab_node_base *p) { return p->symbol.type == SYMTAB_FUNCTION; } @@ -560,7 +546,7 @@ is_a_helper <cgraph_node>::test (symtab_node_def *p) template <> template <> inline bool -is_a_helper <varpool_node>::test (symtab_node_def *p) +is_a_helper <varpool_node>::test (symtab_node_base *p) { return p->symbol.type == SYMTAB_VARIABLE; } |