[tree-ssa] Make tsi insert iterators handle chains of COMPOUND_EXPRs

Andrew MacLeod amacleod@redhat.com
Thu Aug 28 20:53:00 GMT 2003


On Thu, 2003-08-28 at 15:53, Zdenek Dvorak wrote:
> Hello,
> 
> this patch improves tsi_link_before and tsi_link_after so that if
> the statement you link in is right-recursive chain of COMPOUND_EXPRs,
> rationalize_compound_expr does not have to be called.
> 
> This enables to remove creation of BIND_EXPR from replace_stmt.


I would prefer to see us handle inserting a chain of stmts with a
different link routine. Implementing it your way presumes that a tree
can points to a list of stmt's, which it happens to now because of the
whole COMPOUND_EXPR concept. If we change this down the road and the
linking mechamism is no longer contained in the tree node, we'll have to
look at all the uses of tree_insert_* and determine whether we need to
use the stmt_list version or the single stmt version. 
 
 I would prefer to see a routine like:

tsi_link_chain_{before_after} 
          (tree_stmt_iterator *i, tree_stmt_anchor new_chain,  mode)

where if you want to insert a multiple stmt chain, you'd call it thusly
right now:

tsi_stmt_anchor new_chain;

new_chain = tsi_anchor_start (my_compound_expr_node);
tsi_link_chain_after (iterator, new_chain, TSI_SAME) or whateever.



tsi_anchor_start() doesnt exist right now, it would effectively do
nothing except return the parameter right now. tsi_anchor does exist, we
just havent started using it yet. It was inteneted to represent the star
point of a stmt list which is not linked into the program.

The prototype for these routines for bsi_ versions exists but was never
implemented.

I would settle for simply using a new routine tho since the semantics
are slightly different and it'll still be easy to find down the road
if/when we do switch implementations of the linking mechanism, and we
can switch to anchors then.

Andrew



More information about the Gcc-patches mailing list