We do not yet seem to have consensus on a long term plan.
Would it be reasonable to start on short term prepatory work?
In particular, I was think we could do
Add converters and testers.
Change callers to use those.
and maybe
Change callers to use type-safe parameters.
Where those mean what I earlier stated.
Comments?
CONVERTERS AND TESTERS ###########################################
add
symtab_node_base &symtab_node_def::ref_symbol()
{ return symbol; }
symtab_node_base &cgraph_node::ref_symbol()
{ return symbol; }
symtab_node_base &varpool_node::ref_symbol()
{ return symbol; }
change
node->symbol.whatever
to
node->ref_symbol().whatever
----
should not need to add these
cgraph_node &symtab_node_def::ref_cgraph()
{ gcc_assert (symbol.type == SYMTAB_FUNCTION);
return x_function; }
varpool_node &symtab_node_def::ref_varpool()
{ gcc_assert (symbol.type == SYMTAB_VARIABLE);
return x_variable; }
----
add
symtab_node_base *symtab_node_def::try_symbol()
{ return &symbol; }
cgraph_node *symtab_node_def::try_cgraph()
{ return symbol.type == SYMTAB_FUNCTION ? &x_function : NULL; }
varpool_node *symtab_node_def::try_varpool()
{ return symbol.type == SYMTAB_VARIABLE ? &x_variable : NULL; }
change
if (symtab_function_p (node) && cgraph (node)->analyzed)
return cgraph (node);
to
if (cgraph_node *p = node->try_cgraph())
if (p->analyzed)
return p;
change
if (symtab_function_p (node) && cgraph (node)->callers)
....
to
if (cgraph_node *p = node->try_cgraph())
if (p->callers)
....
change
if (symtab_function_p (node))
{
struct cgraph_node *cnode = cgraph (node);
....
to
if (cgraph_node *cnode = node->try_cgraph ())
{
....
likewise "symtab_variable_p (node)" and "varpool (node)"
----
If there are any "symtab_function_p (node)" expressions left,
add
bool symtab_node_def::is_cgraph()
{ return symbol.type == SYMTAB_FUNCTION; }
bool symtab_node_def::is_varpool()
{ return symbol.type == SYMTAB_VARIABLE; }
change
symtab_function_p (node)
to
node->is_cgraph ()
likewise "symtab_variable_p (node)"
----
Though we would like to avoid doing so,
if there are any "cgraph (node)" or "varpool (node)" expressions left,
add
symtab_node_base *symtab_node_def::ptr_symbol()
{ return &symbol; }
cgraph_node *symtab_node_def::ptr_cgraph()
{ gcc_assert (symbol.type == SYMTAB_FUNCTION);
{ return &x_function; }
varpool_node *symtab_node_def::ptr_varpool()
{ gcc_assert (symbol.type == SYMTAB_VARIABLE);
{ return &x_variable; }
change
cgraph (node) => node->ptr_cgraph()
likewise "varpool (node)"
TYPE SAFETY ###########################################
If a function asserts that its symtab_node parameter is symtab_function_p,
then convert the function to take a cgraph_node*
and change the callers to convert as above.
--
Lawrence Crowl