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.
6 .. index:: GIMPLE sequences
13 GIMPLE sequences are the tuple equivalent of ``STATEMENT_LIST`` 's
14 used in ``GENERIC``. They are used to chain statements together, and
15 when used in conjunction with sequence iterators, provide a
16 framework for iterating through statements.
18 GIMPLE sequences are of type struct ``gimple_sequence``, but are more
19 commonly passed by reference to functions dealing with sequences.
20 The type for a sequence pointer is ``gimple_seq`` which is the same
21 as struct ``gimple_sequence`` \*. When declaring a local sequence,
22 you can define a local variable of type struct ``gimple_sequence``.
23 When declaring a sequence allocated on the garbage collected
24 heap, use the function ``gimple_seq_alloc`` documented below.
26 There are convenience functions for iterating through sequences
27 in the section entitled Sequence Iterators.
29 Below is a list of functions to manipulate and query sequences.
31 .. function:: void gimple_seq_add_stmt (gimple_seq *seq, gimple g)
33 Link a gimple statement to the end of the sequence \* ``SEQ`` if ``G`` is
34 not ``NULL``. If \* ``SEQ`` is ``NULL``, allocate a sequence before linking.
36 .. function:: void gimple_seq_add_seq (gimple_seq *dest, gimple_seq src)
38 Append sequence ``SRC`` to the end of sequence \* ``DEST`` if ``SRC`` is not
39 ``NULL``. If \* ``DEST`` is ``NULL``, allocate a new sequence before
42 .. function:: gimple_seq gimple_seq_deep_copy (gimple_seq src)
44 Perform a deep copy of sequence ``SRC`` and return the result.
46 .. function:: gimple_seq gimple_seq_reverse (gimple_seq seq)
48 Reverse the order of the statements in the sequence ``SEQ``. Return
51 .. function:: gimple gimple_seq_first (gimple_seq s)
53 Return the first statement in sequence ``S``.
55 .. function:: gimple gimple_seq_last (gimple_seq s)
57 Return the last statement in sequence ``S``.
59 .. function:: void gimple_seq_set_last (gimple_seq s, gimple last)
61 Set the last statement in sequence ``S`` to the statement in ``LAST``.
63 .. function:: void gimple_seq_set_first (gimple_seq s, gimple first)
65 Set the first statement in sequence ``S`` to the statement in ``FIRST``.
67 .. function:: void gimple_seq_init (gimple_seq s)
69 Initialize sequence ``S`` to an empty sequence.
71 .. function:: gimple_seq gimple_seq_alloc (void)
73 Allocate a new sequence in the garbage collected store and return
76 .. function:: void gimple_seq_copy (gimple_seq dest, gimple_seq src)
78 Copy the sequence ``SRC`` into the sequence ``DEST``.
80 .. function:: bool gimple_seq_empty_p (gimple_seq s)
82 Return true if the sequence ``S`` is empty.
84 .. function:: gimple_seq bb_seq (basic_block bb)
86 Returns the sequence of statements in ``BB``.
88 .. function:: void set_bb_seq (basic_block bb, gimple_seq seq)
90 Sets the sequence of statements in ``BB`` to ``SEQ``.
92 .. function:: bool gimple_seq_singleton_p (gimple_seq seq)
94 Determine whether ``SEQ`` contains exactly one statement.