Statement and operand traversals#
There are two functions available for walking statements and
sequences: walk_gimple_stmt
and walk_gimple_seq
,
accordingly, and a third function for walking the operands in a
statement: walk_gimple_op
.
-
tree walk_gimple_stmt(gimple_stmt_iterator *gsi, walk_stmt_fn callback_stmt, walk_tree_fn callback_op, struct walk_stmt_info *wi)#
This function is used to walk the current statement in
GSI
, optionally using traversal state stored inWI
. IfWI
isNULL
, no state is kept during the traversal.The callback
CALLBACK_STMT
is called. IfCALLBACK_STMT
returns true, it means that the callback function has handled all the operands of the statement and it is not necessary to walk its operands.If
CALLBACK_STMT
isNULL
or it returns false,CALLBACK_OP
is called on each operand of the statement viawalk_gimple_op
. Ifwalk_gimple_op
returns non-NULL
for any operand, the remaining operands are not scanned.The return value is that returned by the last call to
walk_gimple_op
, orNULL_TREE
if noCALLBACK_OP
is specified.
-
tree walk_gimple_op(gimple stmt, walk_tree_fn callback_op, struct walk_stmt_info *wi)#
Use this function to walk the operands of statement
STMT
. Every operand is walked viawalk_tree
with optional state information inWI
.CALLBACK_OP
is called on each operand ofSTMT
viawalk_tree
. Additional parameters towalk_tree
must be stored inWI
. For each operandOP
,walk_tree
is called as:walk_tree (&OP, CALLBACK_OP, WI, PSET)
If
CALLBACK_OP
returns non-NULL
for an operand, the remaining operands are not scanned. The return value is that returned by the last call towalk_tree
, orNULL_TREE
if noCALLBACK_OP
is specified.
-
tree walk_gimple_seq(gimple_seq seq, walk_stmt_fn callback_stmt, walk_tree_fn callback_op, struct walk_stmt_info *wi)#
This function walks all the statements in the sequence
SEQ
callingwalk_gimple_stmt
on each one.WI
is as inwalk_gimple_stmt
. Ifwalk_gimple_stmt
returns non-NULL
, the walk is stopped and the value returned. Otherwise, all the statements are walked andNULL_TREE
returned.