]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/doc/gccint/gimple/statement-and-operand-traversals.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / doc / gccint / gimple / statement-and-operand-traversals.rst
1 ..
2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
5
6 .. index:: Statement and operand traversals
7
8 .. _statement-and-operand-traversals:
9
10 Statement and operand traversals
11 ********************************
12
13 There are two functions available for walking statements and
14 sequences: ``walk_gimple_stmt`` and ``walk_gimple_seq``,
15 accordingly, and a third function for walking the operands in a
16 statement: ``walk_gimple_op``.
17
18 .. function:: tree walk_gimple_stmt (gimple_stmt_iterator *gsi, walk_stmt_fn callback_stmt, walk_tree_fn callback_op, struct walk_stmt_info *wi)
19
20 This function is used to walk the current statement in ``GSI``,
21 optionally using traversal state stored in ``WI``. If ``WI`` is ``NULL``, no
22 state is kept during the traversal.
23
24 The callback ``CALLBACK_STMT`` is called. If ``CALLBACK_STMT`` returns
25 true, it means that the callback function has handled all the
26 operands of the statement and it is not necessary to walk its
27 operands.
28
29 If ``CALLBACK_STMT`` is ``NULL`` or it returns false, ``CALLBACK_OP`` is
30 called on each operand of the statement via ``walk_gimple_op``. If
31 ``walk_gimple_op`` returns non- ``NULL`` for any operand, the remaining
32 operands are not scanned.
33
34 The return value is that returned by the last call to
35 ``walk_gimple_op``, or ``NULL_TREE`` if no ``CALLBACK_OP`` is specified.
36
37 .. function:: tree walk_gimple_op (gimple stmt, walk_tree_fn callback_op, struct walk_stmt_info *wi)
38
39 Use this function to walk the operands of statement ``STMT``. Every
40 operand is walked via ``walk_tree`` with optional state information
41 in ``WI``.
42
43 ``CALLBACK_OP`` is called on each operand of ``STMT`` via ``walk_tree``.
44 Additional parameters to ``walk_tree`` must be stored in ``WI``. For
45 each operand ``OP``, ``walk_tree`` is called as:
46
47 .. code-block:: c++
48
49 walk_tree (&OP, CALLBACK_OP, WI, PSET)
50
51 If ``CALLBACK_OP`` returns non- ``NULL`` for an operand, the remaining
52 operands are not scanned. The return value is that returned by
53 the last call to ``walk_tree``, or ``NULL_TREE`` if no ``CALLBACK_OP`` is
54 specified.
55
56 .. function:: tree walk_gimple_seq (gimple_seq seq, walk_stmt_fn callback_stmt, walk_tree_fn callback_op, struct walk_stmt_info *wi)
57
58 This function walks all the statements in the sequence ``SEQ``
59 calling ``walk_gimple_stmt`` on each one. ``WI`` is as in
60 ``walk_gimple_stmt``. If ``walk_gimple_stmt`` returns non- ``NULL``, the walk
61 is stopped and the value returned. Otherwise, all the statements
62 are walked and ``NULL_TREE`` returned.