1 @c Copyright (C) 2008-2018 Free Software Foundation, Inc.
2 @c Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
10 GIMPLE is a three-address representation derived from GENERIC by
11 breaking down GENERIC expressions into tuples of no more than 3
12 operands (with some exceptions like function calls). GIMPLE was
13 heavily influenced by the SIMPLE IL used by the McCAT compiler
14 project at McGill University, though we have made some different
15 choices. For one thing, SIMPLE doesn't support @code{goto}.
17 Temporaries are introduced to hold intermediate values needed to
18 compute complex expressions. Additionally, all the control
19 structures used in GENERIC are lowered into conditional jumps,
20 lexical scopes are removed and exception regions are converted
21 into an on the side exception region tree.
23 The compiler pass which converts GENERIC into GIMPLE is referred to as
24 the @samp{gimplifier}. The gimplifier works recursively, generating
25 GIMPLE tuples out of the original GENERIC expressions.
27 One of the early implementation strategies used for the GIMPLE
28 representation was to use the same internal data structures used
29 by front ends to represent parse trees. This simplified
30 implementation because we could leverage existing functionality
31 and interfaces. However, GIMPLE is a much more restrictive
32 representation than abstract syntax trees (AST), therefore it
33 does not require the full structural complexity provided by the
34 main tree data structure.
36 The GENERIC representation of a function is stored in the
37 @code{DECL_SAVED_TREE} field of the associated @code{FUNCTION_DECL}
38 tree node. It is converted to GIMPLE by a call to
39 @code{gimplify_function_tree}.
41 If a front end wants to include language-specific tree codes in the tree
42 representation which it provides to the back end, it must provide a
43 definition of @code{LANG_HOOKS_GIMPLIFY_EXPR} which knows how to
44 convert the front end trees to GIMPLE@. Usually such a hook will involve
45 much of the same code for expanding front end trees to RTL@. This function
46 can return fully lowered GIMPLE, or it can return GENERIC trees and let the
47 main gimplifier lower them the rest of the way; this is often simpler.
48 GIMPLE that is not fully lowered is known as ``High GIMPLE'' and
49 consists of the IL before the pass @code{pass_lower_cf}. High GIMPLE
50 contains some container statements like lexical scopes
51 (represented by @code{GIMPLE_BIND}) and nested expressions (e.g.,
52 @code{GIMPLE_TRY}), while ``Low GIMPLE'' exposes all of the
53 implicit jumps for control and exception expressions directly in
54 the IL and EH region trees.
56 The C and C++ front ends currently convert directly from front end
57 trees to GIMPLE, and hand that off to the back end rather than first
58 converting to GENERIC@. Their gimplifier hooks know about all the
59 @code{_STMT} nodes and how to convert them to GENERIC forms. There
60 was some work done on a genericization pass which would run first, but
61 the existence of @code{STMT_EXPR} meant that in order to convert all
62 of the C statements into GENERIC equivalents would involve walking the
63 entire tree anyway, so it was simpler to lower all the way. This
64 might change in the future if someone writes an optimization pass
65 which would work better with higher-level trees, but currently the
66 optimizers all expect GIMPLE@.
68 You can request to dump a C-like representation of the GIMPLE form
69 with the flag @option{-fdump-tree-gimple}.
72 * Tuple representation::
73 * Class hierarchy of GIMPLE statements::
74 * GIMPLE instruction set::
75 * GIMPLE Exception Handling::
78 * Manipulating GIMPLE statements::
79 * Tuple specific accessors::
81 * Sequence iterators::
82 * Adding a new GIMPLE statement code::
83 * Statement and operand traversals::
86 @node Tuple representation
87 @section Tuple representation
90 GIMPLE instructions are tuples of variable size divided in two
91 groups: a header describing the instruction and its locations,
92 and a variable length body with all the operands. Tuples are
93 organized into a hierarchy with 3 main classes of tuples.
95 @subsection @code{gimple} (gsbase)
98 This is the root of the hierarchy, it holds basic information
99 needed by most GIMPLE statements. There are some fields that
100 may not be relevant to every GIMPLE statement, but those were
101 moved into the base structure to take advantage of holes left by
102 other fields (thus making the structure more compact). The
103 structure takes 4 words (32 bytes) on 64 bit hosts:
105 @multitable {@code{references_memory_p}} {Size (bits)}
106 @item Field @tab Size (bits)
107 @item @code{code} @tab 8
108 @item @code{subcode} @tab 16
109 @item @code{no_warning} @tab 1
110 @item @code{visited} @tab 1
111 @item @code{nontemporal_move} @tab 1
112 @item @code{plf} @tab 2
113 @item @code{modified} @tab 1
114 @item @code{has_volatile_ops} @tab 1
115 @item @code{references_memory_p} @tab 1
116 @item @code{uid} @tab 32
117 @item @code{location} @tab 32
118 @item @code{num_ops} @tab 32
119 @item @code{bb} @tab 64
120 @item @code{block} @tab 63
121 @item Total size @tab 32 bytes
126 Main identifier for a GIMPLE instruction.
129 Used to distinguish different variants of the same basic
130 instruction or provide flags applicable to a given code. The
131 @code{subcode} flags field has different uses depending on the code of
132 the instruction, but mostly it distinguishes instructions of the
133 same family. The most prominent use of this field is in
134 assignments, where subcode indicates the operation done on the
135 RHS of the assignment. For example, a = b + c is encoded as
136 @code{GIMPLE_ASSIGN <PLUS_EXPR, a, b, c>}.
138 @item @code{no_warning}
139 Bitflag to indicate whether a warning has already been issued on
143 General purpose ``visited'' marker. Set and cleared by each pass
146 @item @code{nontemporal_move}
147 Bitflag used in assignments that represent non-temporal moves.
148 Although this bitflag is only used in assignments, it was moved
149 into the base to take advantage of the bit holes left by the
153 Pass Local Flags. This 2-bit mask can be used as general purpose
154 markers by any pass. Passes are responsible for clearing and
155 setting these two flags accordingly.
157 @item @code{modified}
158 Bitflag to indicate whether the statement has been modified.
159 Used mainly by the operand scanner to determine when to re-scan a
160 statement for operands.
162 @item @code{has_volatile_ops}
163 Bitflag to indicate whether this statement contains operands that
164 have been marked volatile.
166 @item @code{references_memory_p}
167 Bitflag to indicate whether this statement contains memory
168 references (i.e., its operands are either global variables, or
169 pointer dereferences or anything that must reside in memory).
172 This is an unsigned integer used by passes that want to assign
173 IDs to every statement. These IDs must be assigned and used by
176 @item @code{location}
177 This is a @code{location_t} identifier to specify source code
178 location for this statement. It is inherited from the front
182 Number of operands that this statement has. This specifies the
183 size of the operand vector embedded in the tuple. Only used in
184 some tuples, but it is declared in the base tuple to take
185 advantage of the 32-bit hole left by the previous fields.
188 Basic block holding the instruction.
191 Lexical block holding this statement. Also used for debug
192 information generation.
195 @subsection @code{gimple_statement_with_ops}
196 @cindex gimple_statement_with_ops
198 This tuple is actually split in two:
199 @code{gimple_statement_with_ops_base} and
200 @code{gimple_statement_with_ops}. This is needed to accommodate the
201 way the operand vector is allocated. The operand vector is
202 defined to be an array of 1 element. So, to allocate a dynamic
203 number of operands, the memory allocator (@code{gimple_alloc}) simply
204 allocates enough memory to hold the structure itself plus @code{N
205 - 1} operands which run ``off the end'' of the structure. For
206 example, to allocate space for a tuple with 3 operands,
207 @code{gimple_alloc} reserves @code{sizeof (struct
208 gimple_statement_with_ops) + 2 * sizeof (tree)} bytes.
210 On the other hand, several fields in this tuple need to be shared
211 with the @code{gimple_statement_with_memory_ops} tuple. So, these
212 common fields are placed in @code{gimple_statement_with_ops_base} which
213 is then inherited from the other two tuples.
216 @multitable {@code{def_ops}} {48 + 8 * @code{num_ops} bytes}
217 @item @code{gsbase} @tab 256
218 @item @code{def_ops} @tab 64
219 @item @code{use_ops} @tab 64
220 @item @code{op} @tab @code{num_ops} * 64
221 @item Total size @tab 48 + 8 * @code{num_ops} bytes
226 Inherited from @code{struct gimple}.
229 Array of pointers into the operand array indicating all the slots that
230 contain a variable written-to by the statement. This array is
231 also used for immediate use chaining. Note that it would be
232 possible to not rely on this array, but the changes required to
233 implement this are pretty invasive.
236 Similar to @code{def_ops} but for variables read by the statement.
239 Array of trees with @code{num_ops} slots.
242 @subsection @code{gimple_statement_with_memory_ops}
244 This tuple is essentially identical to @code{gimple_statement_with_ops},
245 except that it contains 4 additional fields to hold vectors
246 related memory stores and loads. Similar to the previous case,
247 the structure is split in two to accommodate for the operand
248 vector (@code{gimple_statement_with_memory_ops_base} and
249 @code{gimple_statement_with_memory_ops}).
252 @multitable {@code{vdef_ops}} {80 + 8 * @code{num_ops} bytes}
253 @item Field @tab Size (bits)
254 @item @code{gsbase} @tab 256
255 @item @code{def_ops} @tab 64
256 @item @code{use_ops} @tab 64
257 @item @code{vdef_ops} @tab 64
258 @item @code{vuse_ops} @tab 64
259 @item @code{stores} @tab 64
260 @item @code{loads} @tab 64
261 @item @code{op} @tab @code{num_ops} * 64
262 @item Total size @tab 80 + 8 * @code{num_ops} bytes
266 @item @code{vdef_ops}
267 Similar to @code{def_ops} but for @code{VDEF} operators. There is
268 one entry per memory symbol written by this statement. This is
269 used to maintain the memory SSA use-def and def-def chains.
271 @item @code{vuse_ops}
272 Similar to @code{use_ops} but for @code{VUSE} operators. There is
273 one entry per memory symbol loaded by this statement. This is
274 used to maintain the memory SSA use-def chains.
277 Bitset with all the UIDs for the symbols written-to by the
278 statement. This is different than @code{vdef_ops} in that all the
279 affected symbols are mentioned in this set. If memory
280 partitioning is enabled, the @code{vdef_ops} vector will refer to memory
281 partitions. Furthermore, no SSA information is stored in this
285 Similar to @code{stores}, but for memory loads. (Note that there
286 is some amount of redundancy here, it should be possible to
287 reduce memory utilization further by removing these sets).
290 All the other tuples are defined in terms of these three basic
291 ones. Each tuple will add some fields.
294 @node Class hierarchy of GIMPLE statements
295 @section Class hierarchy of GIMPLE statements
296 @cindex GIMPLE class hierarchy
298 The following diagram shows the C++ inheritance hierarchy of statement
299 kinds, along with their relationships to @code{GSS_} values (layouts) and
300 @code{GIMPLE_} values (codes):
305 | used for 4 codes: GIMPLE_ERROR_MARK
307 | GIMPLE_OMP_SECTIONS_SWITCH
310 + gimple_statement_with_ops_base
313 | + gimple_statement_with_ops
314 | | | layout: GSS_WITH_OPS
317 | | | code: GIMPLE_COND
320 | | | code: GIMPLE_DEBUG
323 | | | code: GIMPLE_GOTO
326 | | | code: GIMPLE_LABEL
329 | | code: GIMPLE_SWITCH
331 | + gimple_statement_with_memory_ops_base
332 | | layout: GSS_WITH_MEM_OPS_BASE
334 | + gimple_statement_with_memory_ops
335 | | | layout: GSS_WITH_MEM_OPS
338 | | | code GIMPLE_ASSIGN
341 | | code GIMPLE_RETURN
344 | | layout: GSS_CALL, code: GIMPLE_CALL
347 | | layout: GSS_ASM, code: GIMPLE_ASM
350 | layout: GSS_TRANSACTION, code: GIMPLE_TRANSACTION
352 + gimple_statement_omp
353 | | layout: GSS_OMP. Used for code GIMPLE_OMP_SECTION
356 | | layout: GSS_OMP_CRITICAL, code: GIMPLE_OMP_CRITICAL
359 | | layout: GSS_OMP_FOR, code: GIMPLE_OMP_FOR
361 | + gomp_parallel_layout
362 | | | layout: GSS_OMP_PARALLEL_LAYOUT
364 | | + gimple_statement_omp_taskreg
366 | | | + gomp_parallel
367 | | | | code: GIMPLE_OMP_PARALLEL
370 | | | code: GIMPLE_OMP_TASK
372 | | + gimple_statement_omp_target
373 | | code: GIMPLE_OMP_TARGET
376 | | layout: GSS_OMP_SECTIONS, code: GIMPLE_OMP_SECTIONS
378 | + gimple_statement_omp_single_layout
379 | | layout: GSS_OMP_SINGLE_LAYOUT
382 | | code: GIMPLE_OMP_SINGLE
385 | code: GIMPLE_OMP_TEAMS
388 | layout: GSS_BIND, code: GIMPLE_BIND
391 | layout: GSS_CATCH, code: GIMPLE_CATCH
394 | layout: GSS_EH_FILTER, code: GIMPLE_EH_FILTER
397 | layout: GSS_EH_ELSE, code: GIMPLE_EH_ELSE
400 | layout: GSS_EH_MNT, code: GIMPLE_EH_MUST_NOT_THROW
403 | layout: GSS_PHI, code: GIMPLE_PHI
405 + gimple_statement_eh_ctrl
406 | | layout: GSS_EH_CTRL
409 | | code: GIMPLE_RESX
412 | code: GIMPLE_EH_DISPATCH
415 | layout: GSS_TRY, code: GIMPLE_TRY
417 + gimple_statement_wce
418 | layout: GSS_WCE, code: GIMPLE_WITH_CLEANUP_EXPR
421 | layout: GSS_OMP_CONTINUE, code: GIMPLE_OMP_CONTINUE
424 | layout: GSS_OMP_ATOMIC_LOAD, code: GIMPLE_OMP_ATOMIC_LOAD
426 + gimple_statement_omp_atomic_store_layout
427 | layout: GSS_OMP_ATOMIC_STORE_LAYOUT,
428 | code: GIMPLE_OMP_ATOMIC_STORE
431 | code: GIMPLE_OMP_ATOMIC_STORE
434 code: GIMPLE_OMP_RETURN
438 @node GIMPLE instruction set
439 @section GIMPLE instruction set
440 @cindex GIMPLE instruction set
442 The following table briefly describes the GIMPLE instruction set.
444 @multitable {@code{GIMPLE_OMP_SECTIONS_SWITCH}} {High GIMPLE} {Low GIMPLE}
445 @item Instruction @tab High GIMPLE @tab Low GIMPLE
446 @item @code{GIMPLE_ASM} @tab x @tab x
447 @item @code{GIMPLE_ASSIGN} @tab x @tab x
448 @item @code{GIMPLE_BIND} @tab x @tab
449 @item @code{GIMPLE_CALL} @tab x @tab x
450 @item @code{GIMPLE_CATCH} @tab x @tab
451 @item @code{GIMPLE_COND} @tab x @tab x
452 @item @code{GIMPLE_DEBUG} @tab x @tab x
453 @item @code{GIMPLE_EH_FILTER} @tab x @tab
454 @item @code{GIMPLE_GOTO} @tab x @tab x
455 @item @code{GIMPLE_LABEL} @tab x @tab x
456 @item @code{GIMPLE_NOP} @tab x @tab x
457 @item @code{GIMPLE_OMP_ATOMIC_LOAD} @tab x @tab x
458 @item @code{GIMPLE_OMP_ATOMIC_STORE} @tab x @tab x
459 @item @code{GIMPLE_OMP_CONTINUE} @tab x @tab x
460 @item @code{GIMPLE_OMP_CRITICAL} @tab x @tab x
461 @item @code{GIMPLE_OMP_FOR} @tab x @tab x
462 @item @code{GIMPLE_OMP_MASTER} @tab x @tab x
463 @item @code{GIMPLE_OMP_ORDERED} @tab x @tab x
464 @item @code{GIMPLE_OMP_PARALLEL} @tab x @tab x
465 @item @code{GIMPLE_OMP_RETURN} @tab x @tab x
466 @item @code{GIMPLE_OMP_SECTION} @tab x @tab x
467 @item @code{GIMPLE_OMP_SECTIONS} @tab x @tab x
468 @item @code{GIMPLE_OMP_SECTIONS_SWITCH} @tab x @tab x
469 @item @code{GIMPLE_OMP_SINGLE} @tab x @tab x
470 @item @code{GIMPLE_PHI} @tab @tab x
471 @item @code{GIMPLE_RESX} @tab @tab x
472 @item @code{GIMPLE_RETURN} @tab x @tab x
473 @item @code{GIMPLE_SWITCH} @tab x @tab x
474 @item @code{GIMPLE_TRY} @tab x @tab
477 @node GIMPLE Exception Handling
478 @section Exception Handling
479 @cindex GIMPLE Exception Handling
481 Other exception handling constructs are represented using
482 @code{GIMPLE_TRY_CATCH}. @code{GIMPLE_TRY_CATCH} has two operands. The
483 first operand is a sequence of statements to execute. If executing
484 these statements does not throw an exception, then the second operand
485 is ignored. Otherwise, if an exception is thrown, then the second
486 operand of the @code{GIMPLE_TRY_CATCH} is checked. The second
487 operand may have the following forms:
491 @item A sequence of statements to execute. When an exception occurs,
492 these statements are executed, and then the exception is rethrown.
494 @item A sequence of @code{GIMPLE_CATCH} statements. Each
495 @code{GIMPLE_CATCH} has a list of applicable exception types and
496 handler code. If the thrown exception matches one of the caught
497 types, the associated handler code is executed. If the handler
498 code falls off the bottom, execution continues after the original
499 @code{GIMPLE_TRY_CATCH}.
501 @item A @code{GIMPLE_EH_FILTER} statement. This has a list of
502 permitted exception types, and code to handle a match failure. If the
503 thrown exception does not match one of the allowed types, the
504 associated match failure code is executed. If the thrown exception
505 does match, it continues unwinding the stack looking for the next
510 Currently throwing an exception is not directly represented in
511 GIMPLE, since it is implemented by calling a function. At some
512 point in the future we will want to add some way to express that
513 the call will throw an exception of a known type.
515 Just before running the optimizers, the compiler lowers the
516 high-level EH constructs above into a set of @samp{goto}s, magic
517 labels, and EH regions. Continuing to unwind at the end of a
518 cleanup is represented with a @code{GIMPLE_RESX}.
525 When gimplification encounters a subexpression that is too
526 complex, it creates a new temporary variable to hold the value of
527 the subexpression, and adds a new statement to initialize it
528 before the current statement. These special temporaries are known
529 as @samp{expression temporaries}, and are allocated using
530 @code{get_formal_tmp_var}. The compiler tries to always evaluate
531 identical expressions into the same temporary, to simplify
532 elimination of redundant calculations.
534 We can only use expression temporaries when we know that it will
535 not be reevaluated before its value is used, and that it will not
536 be otherwise modified@footnote{These restrictions are derived
537 from those in Morgan 4.8.}. Other temporaries can be allocated
538 using @code{get_initialized_tmp_var} or @code{create_tmp_var}.
540 Currently, an expression like @code{a = b + 5} is not reduced any
541 further. We tried converting it to something like
546 but this bloated the representation for minimal benefit. However, a
547 variable which must live in memory cannot appear in an expression; its
548 value is explicitly loaded into a temporary first. Similarly, storing
549 the value of an expression to a memory variable goes through a
556 In general, expressions in GIMPLE consist of an operation and the
557 appropriate number of simple operands; these operands must either be a
558 GIMPLE rvalue (@code{is_gimple_val}), i.e.@: a constant or a register
559 variable. More complex operands are factored out into temporaries, so
570 The same rule holds for arguments to a @code{GIMPLE_CALL}.
572 The target of an assignment is usually a variable, but can also be a
573 @code{MEM_REF} or a compound lvalue as described below.
576 * Compound Expressions::
578 * Conditional Expressions::
579 * Logical Operators::
582 @node Compound Expressions
583 @subsection Compound Expressions
584 @cindex Compound Expressions
586 The left-hand side of a C comma expression is simply moved into a separate
589 @node Compound Lvalues
590 @subsection Compound Lvalues
591 @cindex Compound Lvalues
593 Currently compound lvalues involving array and structure field references
594 are not broken down; an expression like @code{a.b[2] = 42} is not reduced
595 any further (though complex array subscripts are). This restriction is a
596 workaround for limitations in later optimizers; if we were to convert this
604 alias analysis would not remember that the reference to @code{T1[2]} came
605 by way of @code{a.b}, so it would think that the assignment could alias
606 another member of @code{a}; this broke @code{struct-alias-1.c}. Future
607 optimizer improvements may make this limitation unnecessary.
609 @node Conditional Expressions
610 @subsection Conditional Expressions
611 @cindex Conditional Expressions
613 A C @code{?:} expression is converted into an @code{if} statement with
614 each branch assigning to the same temporary. So,
628 The GIMPLE level if-conversion pass re-introduces @code{?:}
629 expression, if appropriate. It is used to vectorize loops with
630 conditions using vector conditional operations.
632 Note that in GIMPLE, @code{if} statements are represented using
633 @code{GIMPLE_COND}, as described below.
635 @node Logical Operators
636 @subsection Logical Operators
637 @cindex Logical Operators
639 Except when they appear in the condition operand of a
640 @code{GIMPLE_COND}, logical `and' and `or' operators are simplified
641 as follows: @code{a = b && c} becomes
650 Note that @code{T1} in this example cannot be an expression temporary,
651 because it has two different assignments.
653 @subsection Manipulating operands
655 All gimple operands are of type @code{tree}. But only certain
656 types of trees are allowed to be used as operand tuples. Basic
657 validation is controlled by the function
658 @code{get_gimple_rhs_class}, which given a tree code, returns an
659 @code{enum} with the following values of type @code{enum
663 @item @code{GIMPLE_INVALID_RHS}
664 The tree cannot be used as a GIMPLE operand.
666 @item @code{GIMPLE_TERNARY_RHS}
667 The tree is a valid GIMPLE ternary operation.
669 @item @code{GIMPLE_BINARY_RHS}
670 The tree is a valid GIMPLE binary operation.
672 @item @code{GIMPLE_UNARY_RHS}
673 The tree is a valid GIMPLE unary operation.
675 @item @code{GIMPLE_SINGLE_RHS}
676 The tree is a single object, that cannot be split into simpler
677 operands (for instance, @code{SSA_NAME}, @code{VAR_DECL}, @code{COMPONENT_REF}, etc).
679 This operand class also acts as an escape hatch for tree nodes
680 that may be flattened out into the operand vector, but would need
681 more than two slots on the RHS. For instance, a @code{COND_EXPR}
682 expression of the form @code{(a op b) ? x : y} could be flattened
683 out on the operand vector using 4 slots, but it would also
684 require additional processing to distinguish @code{c = a op b}
685 from @code{c = a op b ? x : y}. Something similar occurs with
686 @code{ASSERT_EXPR}. In time, these special case tree
687 expressions should be flattened into the operand vector.
690 For tree nodes in the categories @code{GIMPLE_TERNARY_RHS},
691 @code{GIMPLE_BINARY_RHS} and @code{GIMPLE_UNARY_RHS}, they cannot be
692 stored inside tuples directly. They first need to be flattened and
693 separated into individual components. For instance, given the GENERIC
700 its tree representation is:
703 MODIFY_EXPR <VAR_DECL <a>, PLUS_EXPR <VAR_DECL <b>, VAR_DECL <c>>>
706 In this case, the GIMPLE form for this statement is logically
707 identical to its GENERIC form but in GIMPLE, the @code{PLUS_EXPR}
708 on the RHS of the assignment is not represented as a tree,
709 instead the two operands are taken out of the @code{PLUS_EXPR} sub-tree
710 and flattened into the GIMPLE tuple as follows:
713 GIMPLE_ASSIGN <PLUS_EXPR, VAR_DECL <a>, VAR_DECL <b>, VAR_DECL <c>>
716 @subsection Operand vector allocation
718 The operand vector is stored at the bottom of the three tuple
719 structures that accept operands. This means, that depending on
720 the code of a given statement, its operand vector will be at
721 different offsets from the base of the structure. To access
722 tuple operands use the following accessors
724 @deftypefn {GIMPLE function} unsigned gimple_num_ops (gimple g)
725 Returns the number of operands in statement G.
728 @deftypefn {GIMPLE function} tree gimple_op (gimple g, unsigned i)
729 Returns operand @code{I} from statement @code{G}.
732 @deftypefn {GIMPLE function} {tree *} gimple_ops (gimple g)
733 Returns a pointer into the operand vector for statement @code{G}. This
734 is computed using an internal table called @code{gimple_ops_offset_}[].
735 This table is indexed by the gimple code of @code{G}.
737 When the compiler is built, this table is filled-in using the
738 sizes of the structures used by each statement code defined in
739 gimple.def. Since the operand vector is at the bottom of the
740 structure, for a gimple code @code{C} the offset is computed as sizeof
741 (struct-of @code{C}) - sizeof (tree).
743 This mechanism adds one memory indirection to every access when
744 using @code{gimple_op}(), if this becomes a bottleneck, a pass can
745 choose to memoize the result from @code{gimple_ops}() and use that to
749 @subsection Operand validation
751 When adding a new operand to a gimple statement, the operand will
752 be validated according to what each tuple accepts in its operand
753 vector. These predicates are called by the
754 @code{gimple_@var{name}_set_...()}. Each tuple will use one of the
755 following predicates (Note, this list is not exhaustive):
757 @deftypefn {GIMPLE function} bool is_gimple_val (tree t)
758 Returns true if t is a "GIMPLE value", which are all the
759 non-addressable stack variables (variables for which
760 @code{is_gimple_reg} returns true) and constants (expressions for which
761 @code{is_gimple_min_invariant} returns true).
764 @deftypefn {GIMPLE function} bool is_gimple_addressable (tree t)
765 Returns true if t is a symbol or memory reference whose address
769 @deftypefn {GIMPLE function} bool is_gimple_asm_val (tree t)
770 Similar to @code{is_gimple_val} but it also accepts hard registers.
773 @deftypefn {GIMPLE function} bool is_gimple_call_addr (tree t)
774 Return true if t is a valid expression to use as the function
775 called by a @code{GIMPLE_CALL}.
778 @deftypefn {GIMPLE function} bool is_gimple_mem_ref_addr (tree t)
779 Return true if t is a valid expression to use as first operand
780 of a @code{MEM_REF} expression.
783 @deftypefn {GIMPLE function} bool is_gimple_constant (tree t)
784 Return true if t is a valid gimple constant.
787 @deftypefn {GIMPLE function} bool is_gimple_min_invariant (tree t)
788 Return true if t is a valid minimal invariant. This is different
789 from constants, in that the specific value of t may not be known
790 at compile time, but it is known that it doesn't change (e.g.,
791 the address of a function local variable).
794 @deftypefn {GIMPLE function} bool is_gimple_ip_invariant (tree t)
795 Return true if t is an interprocedural invariant. This means that t
796 is a valid invariant in all functions (e.g. it can be an address of a
797 global variable but not of a local one).
800 @deftypefn {GIMPLE function} bool is_gimple_ip_invariant_address (tree t)
801 Return true if t is an @code{ADDR_EXPR} that does not change once the
802 program is running (and which is valid in all functions).
806 @subsection Statement validation
808 @deftypefn {GIMPLE function} bool is_gimple_assign (gimple g)
809 Return true if the code of g is @code{GIMPLE_ASSIGN}.
812 @deftypefn {GIMPLE function} bool is_gimple_call (gimple g)
813 Return true if the code of g is @code{GIMPLE_CALL}.
816 @deftypefn {GIMPLE function} bool is_gimple_debug (gimple g)
817 Return true if the code of g is @code{GIMPLE_DEBUG}.
820 @deftypefn {GIMPLE function} bool gimple_assign_cast_p (const_gimple g)
821 Return true if g is a @code{GIMPLE_ASSIGN} that performs a type cast
825 @deftypefn {GIMPLE function} bool gimple_debug_bind_p (gimple g)
826 Return true if g is a @code{GIMPLE_DEBUG} that binds the value of an
827 expression to a variable.
830 @deftypefn {GIMPLE function} bool is_gimple_omp (gimple g)
831 Return true if g is any of the OpenMP codes.
834 @deftypefn {GIMPLE function} gimple_debug_begin_stmt_p (gimple g)
835 Return true if g is a @code{GIMPLE_DEBUG} that marks the beginning of
839 @deftypefn {GIMPLE function} gimple_debug_nonbind_marker_p (gimple g)
840 Return true if g is a @code{GIMPLE_DEBUG} that marks a program location,
841 without any variable binding.
844 @node Manipulating GIMPLE statements
845 @section Manipulating GIMPLE statements
846 @cindex Manipulating GIMPLE statements
848 This section documents all the functions available to handle each
849 of the GIMPLE instructions.
851 @subsection Common accessors
852 The following are common accessors for gimple statements.
854 @deftypefn {GIMPLE function} {enum gimple_code} gimple_code (gimple g)
855 Return the code for statement @code{G}.
858 @deftypefn {GIMPLE function} basic_block gimple_bb (gimple g)
859 Return the basic block to which statement @code{G} belongs to.
862 @deftypefn {GIMPLE function} tree gimple_block (gimple g)
863 Return the lexical scope block holding statement @code{G}.
866 @deftypefn {GIMPLE function} tree gimple_expr_type (gimple stmt)
867 Return the type of the main expression computed by @code{STMT}. Return
868 @code{void_type_node} if @code{STMT} computes nothing. This will only return
869 something meaningful for @code{GIMPLE_ASSIGN}, @code{GIMPLE_COND} and
870 @code{GIMPLE_CALL}. For all other tuple codes, it will return
871 @code{void_type_node}.
874 @deftypefn {GIMPLE function} {enum tree_code} gimple_expr_code (gimple stmt)
875 Return the tree code for the expression computed by @code{STMT}. This
876 is only meaningful for @code{GIMPLE_CALL}, @code{GIMPLE_ASSIGN} and
877 @code{GIMPLE_COND}. If @code{STMT} is @code{GIMPLE_CALL}, it will return @code{CALL_EXPR}.
878 For @code{GIMPLE_COND}, it returns the code of the comparison predicate.
879 For @code{GIMPLE_ASSIGN} it returns the code of the operation performed
880 by the @code{RHS} of the assignment.
883 @deftypefn {GIMPLE function} void gimple_set_block (gimple g, tree block)
884 Set the lexical scope block of @code{G} to @code{BLOCK}.
887 @deftypefn {GIMPLE function} location_t gimple_locus (gimple g)
888 Return locus information for statement @code{G}.
891 @deftypefn {GIMPLE function} void gimple_set_locus (gimple g, location_t locus)
892 Set locus information for statement @code{G}.
895 @deftypefn {GIMPLE function} bool gimple_locus_empty_p (gimple g)
896 Return true if @code{G} does not have locus information.
899 @deftypefn {GIMPLE function} bool gimple_no_warning_p (gimple stmt)
900 Return true if no warnings should be emitted for statement @code{STMT}.
903 @deftypefn {GIMPLE function} void gimple_set_visited (gimple stmt, bool visited_p)
904 Set the visited status on statement @code{STMT} to @code{VISITED_P}.
907 @deftypefn {GIMPLE function} bool gimple_visited_p (gimple stmt)
908 Return the visited status on statement @code{STMT}.
911 @deftypefn {GIMPLE function} void gimple_set_plf (gimple stmt, enum plf_mask plf, bool val_p)
912 Set pass local flag @code{PLF} on statement @code{STMT} to @code{VAL_P}.
915 @deftypefn {GIMPLE function} {unsigned int} gimple_plf (gimple stmt, enum plf_mask plf)
916 Return the value of pass local flag @code{PLF} on statement @code{STMT}.
919 @deftypefn {GIMPLE function} bool gimple_has_ops (gimple g)
920 Return true if statement @code{G} has register or memory operands.
923 @deftypefn {GIMPLE function} bool gimple_has_mem_ops (gimple g)
924 Return true if statement @code{G} has memory operands.
927 @deftypefn {GIMPLE function} unsigned gimple_num_ops (gimple g)
928 Return the number of operands for statement @code{G}.
931 @deftypefn {GIMPLE function} {tree *} gimple_ops (gimple g)
932 Return the array of operands for statement @code{G}.
935 @deftypefn {GIMPLE function} tree gimple_op (gimple g, unsigned i)
936 Return operand @code{I} for statement @code{G}.
939 @deftypefn {GIMPLE function} {tree *} gimple_op_ptr (gimple g, unsigned i)
940 Return a pointer to operand @code{I} for statement @code{G}.
943 @deftypefn {GIMPLE function} void gimple_set_op (gimple g, unsigned i, tree op)
944 Set operand @code{I} of statement @code{G} to @code{OP}.
947 @deftypefn {GIMPLE function} bitmap gimple_addresses_taken (gimple stmt)
948 Return the set of symbols that have had their address taken by
952 @deftypefn {GIMPLE function} {struct def_optype_d *} gimple_def_ops (gimple g)
953 Return the set of @code{DEF} operands for statement @code{G}.
956 @deftypefn {GIMPLE function} void gimple_set_def_ops (gimple g, struct def_optype_d *def)
957 Set @code{DEF} to be the set of @code{DEF} operands for statement @code{G}.
960 @deftypefn {GIMPLE function} {struct use_optype_d *} gimple_use_ops (gimple g)
961 Return the set of @code{USE} operands for statement @code{G}.
964 @deftypefn {GIMPLE function} void gimple_set_use_ops (gimple g, struct use_optype_d *use)
965 Set @code{USE} to be the set of @code{USE} operands for statement @code{G}.
968 @deftypefn {GIMPLE function} {struct voptype_d *} gimple_vuse_ops (gimple g)
969 Return the set of @code{VUSE} operands for statement @code{G}.
972 @deftypefn {GIMPLE function} void gimple_set_vuse_ops (gimple g, struct voptype_d *ops)
973 Set @code{OPS} to be the set of @code{VUSE} operands for statement @code{G}.
976 @deftypefn {GIMPLE function} {struct voptype_d *} gimple_vdef_ops (gimple g)
977 Return the set of @code{VDEF} operands for statement @code{G}.
980 @deftypefn {GIMPLE function} void gimple_set_vdef_ops (gimple g, struct voptype_d *ops)
981 Set @code{OPS} to be the set of @code{VDEF} operands for statement @code{G}.
984 @deftypefn {GIMPLE function} bitmap gimple_loaded_syms (gimple g)
985 Return the set of symbols loaded by statement @code{G}. Each element of
986 the set is the @code{DECL_UID} of the corresponding symbol.
989 @deftypefn {GIMPLE function} bitmap gimple_stored_syms (gimple g)
990 Return the set of symbols stored by statement @code{G}. Each element of
991 the set is the @code{DECL_UID} of the corresponding symbol.
994 @deftypefn {GIMPLE function} bool gimple_modified_p (gimple g)
995 Return true if statement @code{G} has operands and the modified field
999 @deftypefn {GIMPLE function} bool gimple_has_volatile_ops (gimple stmt)
1000 Return true if statement @code{STMT} contains volatile operands.
1003 @deftypefn {GIMPLE function} void gimple_set_has_volatile_ops (gimple stmt, bool volatilep)
1004 Return true if statement @code{STMT} contains volatile operands.
1007 @deftypefn {GIMPLE function} void update_stmt (gimple s)
1008 Mark statement @code{S} as modified, and update it.
1011 @deftypefn {GIMPLE function} void update_stmt_if_modified (gimple s)
1012 Update statement @code{S} if it has been marked modified.
1015 @deftypefn {GIMPLE function} gimple gimple_copy (gimple stmt)
1016 Return a deep copy of statement @code{STMT}.
1019 @node Tuple specific accessors
1020 @section Tuple specific accessors
1021 @cindex Tuple specific accessors
1024 * @code{GIMPLE_ASM}::
1025 * @code{GIMPLE_ASSIGN}::
1026 * @code{GIMPLE_BIND}::
1027 * @code{GIMPLE_CALL}::
1028 * @code{GIMPLE_CATCH}::
1029 * @code{GIMPLE_COND}::
1030 * @code{GIMPLE_DEBUG}::
1031 * @code{GIMPLE_EH_FILTER}::
1032 * @code{GIMPLE_LABEL}::
1033 * @code{GIMPLE_GOTO}::
1034 * @code{GIMPLE_NOP}::
1035 * @code{GIMPLE_OMP_ATOMIC_LOAD}::
1036 * @code{GIMPLE_OMP_ATOMIC_STORE}::
1037 * @code{GIMPLE_OMP_CONTINUE}::
1038 * @code{GIMPLE_OMP_CRITICAL}::
1039 * @code{GIMPLE_OMP_FOR}::
1040 * @code{GIMPLE_OMP_MASTER}::
1041 * @code{GIMPLE_OMP_ORDERED}::
1042 * @code{GIMPLE_OMP_PARALLEL}::
1043 * @code{GIMPLE_OMP_RETURN}::
1044 * @code{GIMPLE_OMP_SECTION}::
1045 * @code{GIMPLE_OMP_SECTIONS}::
1046 * @code{GIMPLE_OMP_SINGLE}::
1047 * @code{GIMPLE_PHI}::
1048 * @code{GIMPLE_RESX}::
1049 * @code{GIMPLE_RETURN}::
1050 * @code{GIMPLE_SWITCH}::
1051 * @code{GIMPLE_TRY}::
1052 * @code{GIMPLE_WITH_CLEANUP_EXPR}::
1056 @node @code{GIMPLE_ASM}
1057 @subsection @code{GIMPLE_ASM}
1058 @cindex @code{GIMPLE_ASM}
1060 @deftypefn {GIMPLE function} gasm *gimple_build_asm_vec ( @
1061 const char *string, vec<tree, va_gc> *inputs, @
1062 vec<tree, va_gc> *outputs, vec<tree, va_gc> *clobbers, @
1063 vec<tree, va_gc> *labels)
1064 Build a @code{GIMPLE_ASM} statement. This statement is used for
1065 building in-line assembly constructs. @code{STRING} is the assembly
1066 code. @code{INPUTS}, @code{OUTPUTS}, @code{CLOBBERS} and @code{LABELS}
1067 are the inputs, outputs, clobbered registers and labels.
1070 @deftypefn {GIMPLE function} unsigned gimple_asm_ninputs (const gasm *g)
1071 Return the number of input operands for @code{GIMPLE_ASM} @code{G}.
1074 @deftypefn {GIMPLE function} unsigned gimple_asm_noutputs (const gasm *g)
1075 Return the number of output operands for @code{GIMPLE_ASM} @code{G}.
1078 @deftypefn {GIMPLE function} unsigned gimple_asm_nclobbers (const gasm *g)
1079 Return the number of clobber operands for @code{GIMPLE_ASM} @code{G}.
1082 @deftypefn {GIMPLE function} tree gimple_asm_input_op (const gasm *g, @
1084 Return input operand @code{INDEX} of @code{GIMPLE_ASM} @code{G}.
1087 @deftypefn {GIMPLE function} void gimple_asm_set_input_op (gasm *g, @
1088 unsigned index, tree in_op)
1089 Set @code{IN_OP} to be input operand @code{INDEX} in @code{GIMPLE_ASM} @code{G}.
1092 @deftypefn {GIMPLE function} tree gimple_asm_output_op (const gasm *g, @
1094 Return output operand @code{INDEX} of @code{GIMPLE_ASM} @code{G}.
1097 @deftypefn {GIMPLE function} void gimple_asm_set_output_op (gasm *g, @
1098 unsigned index, tree out_op)
1099 Set @code{OUT_OP} to be output operand @code{INDEX} in @code{GIMPLE_ASM} @code{G}.
1102 @deftypefn {GIMPLE function} tree gimple_asm_clobber_op (const gasm *g, @
1104 Return clobber operand @code{INDEX} of @code{GIMPLE_ASM} @code{G}.
1107 @deftypefn {GIMPLE function} void gimple_asm_set_clobber_op (gasm *g, @
1108 unsigned index, tree clobber_op)
1109 Set @code{CLOBBER_OP} to be clobber operand @code{INDEX} in @code{GIMPLE_ASM} @code{G}.
1112 @deftypefn {GIMPLE function} {const char *} gimple_asm_string (const gasm *g)
1113 Return the string representing the assembly instruction in
1114 @code{GIMPLE_ASM} @code{G}.
1117 @deftypefn {GIMPLE function} bool gimple_asm_volatile_p (const gasm *g)
1118 Return true if @code{G} is an asm statement marked volatile.
1121 @deftypefn {GIMPLE function} void gimple_asm_set_volatile (gasm *g, @
1123 Mark asm statement @code{G} as volatile or non-volatile based on
1127 @node @code{GIMPLE_ASSIGN}
1128 @subsection @code{GIMPLE_ASSIGN}
1129 @cindex @code{GIMPLE_ASSIGN}
1131 @deftypefn {GIMPLE function} gassign *gimple_build_assign (tree lhs, tree rhs)
1132 Build a @code{GIMPLE_ASSIGN} statement. The left-hand side is an lvalue
1133 passed in lhs. The right-hand side can be either a unary or
1134 binary tree expression. The expression tree rhs will be
1135 flattened and its operands assigned to the corresponding operand
1136 slots in the new statement. This function is useful when you
1137 already have a tree expression that you want to convert into a
1138 tuple. However, try to avoid building expression trees for the
1139 sole purpose of calling this function. If you already have the
1140 operands in separate trees, it is better to use
1141 @code{gimple_build_assign} with @code{enum tree_code} argument and separate
1142 arguments for each operand.
1145 @deftypefn {GIMPLE function} gassign *gimple_build_assign @
1146 (tree lhs, enum tree_code subcode, tree op1, tree op2, tree op3)
1147 This function is similar to two operand @code{gimple_build_assign},
1148 but is used to build a @code{GIMPLE_ASSIGN} statement when the operands of the
1149 right-hand side of the assignment are already split into
1152 The left-hand side is an lvalue passed in lhs. Subcode is the
1153 @code{tree_code} for the right-hand side of the assignment. Op1, op2 and op3
1157 @deftypefn {GIMPLE function} gassign *gimple_build_assign @
1158 (tree lhs, enum tree_code subcode, tree op1, tree op2)
1159 Like the above 5 operand @code{gimple_build_assign}, but with the last
1160 argument @code{NULL} - this overload should not be used for
1161 @code{GIMPLE_TERNARY_RHS} assignments.
1164 @deftypefn {GIMPLE function} gassign *gimple_build_assign @
1165 (tree lhs, enum tree_code subcode, tree op1)
1166 Like the above 4 operand @code{gimple_build_assign}, but with the last
1167 argument @code{NULL} - this overload should be used only for
1168 @code{GIMPLE_UNARY_RHS} and @code{GIMPLE_SINGLE_RHS} assignments.
1171 @deftypefn {GIMPLE function} gimple gimplify_assign (tree dst, tree src, gimple_seq *seq_p)
1172 Build a new @code{GIMPLE_ASSIGN} tuple and append it to the end of
1176 @code{DST}/@code{SRC} are the destination and source respectively. You can
1177 pass ungimplified trees in @code{DST} or @code{SRC}, in which
1178 case they will be converted to a gimple operand if necessary.
1180 This function returns the newly created @code{GIMPLE_ASSIGN} tuple.
1182 @deftypefn {GIMPLE function} {enum tree_code} gimple_assign_rhs_code (gimple g)
1183 Return the code of the expression computed on the @code{RHS} of
1184 assignment statement @code{G}.
1188 @deftypefn {GIMPLE function} {enum gimple_rhs_class} gimple_assign_rhs_class (gimple g)
1189 Return the gimple rhs class of the code for the expression
1190 computed on the rhs of assignment statement @code{G}. This will never
1191 return @code{GIMPLE_INVALID_RHS}.
1194 @deftypefn {GIMPLE function} tree gimple_assign_lhs (gimple g)
1195 Return the @code{LHS} of assignment statement @code{G}.
1198 @deftypefn {GIMPLE function} {tree *} gimple_assign_lhs_ptr (gimple g)
1199 Return a pointer to the @code{LHS} of assignment statement @code{G}.
1202 @deftypefn {GIMPLE function} tree gimple_assign_rhs1 (gimple g)
1203 Return the first operand on the @code{RHS} of assignment statement @code{G}.
1206 @deftypefn {GIMPLE function} {tree *} gimple_assign_rhs1_ptr (gimple g)
1207 Return the address of the first operand on the @code{RHS} of assignment
1211 @deftypefn {GIMPLE function} tree gimple_assign_rhs2 (gimple g)
1212 Return the second operand on the @code{RHS} of assignment statement @code{G}.
1215 @deftypefn {GIMPLE function} {tree *} gimple_assign_rhs2_ptr (gimple g)
1216 Return the address of the second operand on the @code{RHS} of assignment
1220 @deftypefn {GIMPLE function} tree gimple_assign_rhs3 (gimple g)
1221 Return the third operand on the @code{RHS} of assignment statement @code{G}.
1224 @deftypefn {GIMPLE function} {tree *} gimple_assign_rhs3_ptr (gimple g)
1225 Return the address of the third operand on the @code{RHS} of assignment
1229 @deftypefn {GIMPLE function} void gimple_assign_set_lhs (gimple g, tree lhs)
1230 Set @code{LHS} to be the @code{LHS} operand of assignment statement @code{G}.
1233 @deftypefn {GIMPLE function} void gimple_assign_set_rhs1 (gimple g, tree rhs)
1234 Set @code{RHS} to be the first operand on the @code{RHS} of assignment
1238 @deftypefn {GIMPLE function} void gimple_assign_set_rhs2 (gimple g, tree rhs)
1239 Set @code{RHS} to be the second operand on the @code{RHS} of assignment
1243 @deftypefn {GIMPLE function} void gimple_assign_set_rhs3 (gimple g, tree rhs)
1244 Set @code{RHS} to be the third operand on the @code{RHS} of assignment
1248 @deftypefn {GIMPLE function} bool gimple_assign_cast_p (const_gimple s)
1249 Return true if @code{S} is a type-cast assignment.
1253 @node @code{GIMPLE_BIND}
1254 @subsection @code{GIMPLE_BIND}
1255 @cindex @code{GIMPLE_BIND}
1257 @deftypefn {GIMPLE function} gbind *gimple_build_bind (tree vars, @
1259 Build a @code{GIMPLE_BIND} statement with a list of variables in @code{VARS}
1260 and a body of statements in sequence @code{BODY}.
1263 @deftypefn {GIMPLE function} tree gimple_bind_vars (const gbind *g)
1264 Return the variables declared in the @code{GIMPLE_BIND} statement @code{G}.
1267 @deftypefn {GIMPLE function} void gimple_bind_set_vars (gbind *g, tree vars)
1268 Set @code{VARS} to be the set of variables declared in the @code{GIMPLE_BIND}
1272 @deftypefn {GIMPLE function} void gimple_bind_append_vars (gbind *g, tree vars)
1273 Append @code{VARS} to the set of variables declared in the @code{GIMPLE_BIND}
1277 @deftypefn {GIMPLE function} gimple_seq gimple_bind_body (gbind *g)
1278 Return the GIMPLE sequence contained in the @code{GIMPLE_BIND} statement
1282 @deftypefn {GIMPLE function} void gimple_bind_set_body (gbind *g, @
1284 Set @code{SEQ} to be sequence contained in the @code{GIMPLE_BIND} statement @code{G}.
1287 @deftypefn {GIMPLE function} void gimple_bind_add_stmt (gbind *gs, gimple stmt)
1288 Append a statement to the end of a @code{GIMPLE_BIND}'s body.
1291 @deftypefn {GIMPLE function} void gimple_bind_add_seq (gbind *gs, @
1293 Append a sequence of statements to the end of a @code{GIMPLE_BIND}'s
1297 @deftypefn {GIMPLE function} tree gimple_bind_block (const gbind *g)
1298 Return the @code{TREE_BLOCK} node associated with @code{GIMPLE_BIND} statement
1299 @code{G}. This is analogous to the @code{BIND_EXPR_BLOCK} field in trees.
1302 @deftypefn {GIMPLE function} void gimple_bind_set_block (gbind *g, tree block)
1303 Set @code{BLOCK} to be the @code{TREE_BLOCK} node associated with @code{GIMPLE_BIND}
1308 @node @code{GIMPLE_CALL}
1309 @subsection @code{GIMPLE_CALL}
1310 @cindex @code{GIMPLE_CALL}
1312 @deftypefn {GIMPLE function} gcall *gimple_build_call (tree fn, @
1313 unsigned nargs, ...)
1314 Build a @code{GIMPLE_CALL} statement to function @code{FN}. The argument @code{FN}
1315 must be either a @code{FUNCTION_DECL} or a gimple call address as
1316 determined by @code{is_gimple_call_addr}. @code{NARGS} are the number of
1317 arguments. The rest of the arguments follow the argument @code{NARGS},
1318 and must be trees that are valid as rvalues in gimple (i.e., each
1319 operand is validated with @code{is_gimple_operand}).
1323 @deftypefn {GIMPLE function} gcall *gimple_build_call_from_tree (tree call_expr, @
1325 Build a @code{GIMPLE_CALL} from a @code{CALL_EXPR} node. The arguments
1326 and the function are taken from the expression directly. The type of the
1327 @code{GIMPLE_CALL} is set from the second parameter passed by a caller.
1328 This routine assumes that @code{call_expr} is already in GIMPLE form.
1329 That is, its operands are GIMPLE values and the function call needs no further
1330 simplification. All the call flags in @code{call_expr} are copied over
1331 to the new @code{GIMPLE_CALL}.
1334 @deftypefn {GIMPLE function} gcall *gimple_build_call_vec (tree fn, @
1335 @code{vec<tree>} args)
1336 Identical to @code{gimple_build_call} but the arguments are stored in a
1340 @deftypefn {GIMPLE function} tree gimple_call_lhs (gimple g)
1341 Return the @code{LHS} of call statement @code{G}.
1344 @deftypefn {GIMPLE function} {tree *} gimple_call_lhs_ptr (gimple g)
1345 Return a pointer to the @code{LHS} of call statement @code{G}.
1348 @deftypefn {GIMPLE function} void gimple_call_set_lhs (gimple g, tree lhs)
1349 Set @code{LHS} to be the @code{LHS} operand of call statement @code{G}.
1352 @deftypefn {GIMPLE function} tree gimple_call_fn (gimple g)
1353 Return the tree node representing the function called by call
1357 @deftypefn {GIMPLE function} void gimple_call_set_fn (gcall *g, tree fn)
1358 Set @code{FN} to be the function called by call statement @code{G}. This has
1359 to be a gimple value specifying the address of the called
1363 @deftypefn {GIMPLE function} tree gimple_call_fndecl (gimple g)
1364 If a given @code{GIMPLE_CALL}'s callee is a @code{FUNCTION_DECL}, return it.
1365 Otherwise return @code{NULL}. This function is analogous to
1366 @code{get_callee_fndecl} in @code{GENERIC}.
1369 @deftypefn {GIMPLE function} tree gimple_call_set_fndecl (gimple g, tree fndecl)
1370 Set the called function to @code{FNDECL}.
1373 @deftypefn {GIMPLE function} tree gimple_call_return_type (const gcall *g)
1374 Return the type returned by call statement @code{G}.
1377 @deftypefn {GIMPLE function} tree gimple_call_chain (gimple g)
1378 Return the static chain for call statement @code{G}.
1381 @deftypefn {GIMPLE function} void gimple_call_set_chain (gcall *g, tree chain)
1382 Set @code{CHAIN} to be the static chain for call statement @code{G}.
1385 @deftypefn {GIMPLE function} unsigned gimple_call_num_args (gimple g)
1386 Return the number of arguments used by call statement @code{G}.
1389 @deftypefn {GIMPLE function} tree gimple_call_arg (gimple g, unsigned index)
1390 Return the argument at position @code{INDEX} for call statement @code{G}. The
1391 first argument is 0.
1394 @deftypefn {GIMPLE function} {tree *} gimple_call_arg_ptr (gimple g, unsigned index)
1395 Return a pointer to the argument at position @code{INDEX} for call
1399 @deftypefn {GIMPLE function} void gimple_call_set_arg (gimple g, unsigned index, tree arg)
1400 Set @code{ARG} to be the argument at position @code{INDEX} for call statement
1404 @deftypefn {GIMPLE function} void gimple_call_set_tail (gcall *s)
1405 Mark call statement @code{S} as being a tail call (i.e., a call just
1406 before the exit of a function). These calls are candidate for
1407 tail call optimization.
1410 @deftypefn {GIMPLE function} bool gimple_call_tail_p (gcall *s)
1411 Return true if @code{GIMPLE_CALL} @code{S} is marked as a tail call.
1414 @deftypefn {GIMPLE function} bool gimple_call_noreturn_p (gimple s)
1415 Return true if @code{S} is a noreturn call.
1418 @deftypefn {GIMPLE function} gimple gimple_call_copy_skip_args (gcall *stmt, @
1419 bitmap args_to_skip)
1420 Build a @code{GIMPLE_CALL} identical to @code{STMT} but skipping the arguments
1421 in the positions marked by the set @code{ARGS_TO_SKIP}.
1425 @node @code{GIMPLE_CATCH}
1426 @subsection @code{GIMPLE_CATCH}
1427 @cindex @code{GIMPLE_CATCH}
1429 @deftypefn {GIMPLE function} gcatch *gimple_build_catch (tree types, @
1431 Build a @code{GIMPLE_CATCH} statement. @code{TYPES} are the tree types this
1432 catch handles. @code{HANDLER} is a sequence of statements with the code
1436 @deftypefn {GIMPLE function} tree gimple_catch_types (const gcatch *g)
1437 Return the types handled by @code{GIMPLE_CATCH} statement @code{G}.
1440 @deftypefn {GIMPLE function} {tree *} gimple_catch_types_ptr (gcatch *g)
1441 Return a pointer to the types handled by @code{GIMPLE_CATCH} statement
1445 @deftypefn {GIMPLE function} gimple_seq gimple_catch_handler (gcatch *g)
1446 Return the GIMPLE sequence representing the body of the handler
1447 of @code{GIMPLE_CATCH} statement @code{G}.
1450 @deftypefn {GIMPLE function} void gimple_catch_set_types (gcatch *g, tree t)
1451 Set @code{T} to be the set of types handled by @code{GIMPLE_CATCH} @code{G}.
1454 @deftypefn {GIMPLE function} void gimple_catch_set_handler (gcatch *g, @
1456 Set @code{HANDLER} to be the body of @code{GIMPLE_CATCH} @code{G}.
1460 @node @code{GIMPLE_COND}
1461 @subsection @code{GIMPLE_COND}
1462 @cindex @code{GIMPLE_COND}
1464 @deftypefn {GIMPLE function} gcond *gimple_build_cond ( @
1465 enum tree_code pred_code, tree lhs, tree rhs, tree t_label, tree f_label)
1466 Build a @code{GIMPLE_COND} statement. @code{A} @code{GIMPLE_COND} statement compares
1467 @code{LHS} and @code{RHS} and if the condition in @code{PRED_CODE} is true, jump to
1468 the label in @code{t_label}, otherwise jump to the label in @code{f_label}.
1469 @code{PRED_CODE} are relational operator tree codes like @code{EQ_EXPR},
1470 @code{LT_EXPR}, @code{LE_EXPR}, @code{NE_EXPR}, etc.
1474 @deftypefn {GIMPLE function} gcond *gimple_build_cond_from_tree (tree cond, @
1475 tree t_label, tree f_label)
1476 Build a @code{GIMPLE_COND} statement from the conditional expression
1477 tree @code{COND}. @code{T_LABEL} and @code{F_LABEL} are as in @code{gimple_build_cond}.
1480 @deftypefn {GIMPLE function} {enum tree_code} gimple_cond_code (gimple g)
1481 Return the code of the predicate computed by conditional
1485 @deftypefn {GIMPLE function} void gimple_cond_set_code (gcond *g, @
1486 enum tree_code code)
1487 Set @code{CODE} to be the predicate code for the conditional statement
1491 @deftypefn {GIMPLE function} tree gimple_cond_lhs (gimple g)
1492 Return the @code{LHS} of the predicate computed by conditional statement
1496 @deftypefn {GIMPLE function} void gimple_cond_set_lhs (gcond *g, tree lhs)
1497 Set @code{LHS} to be the @code{LHS} operand of the predicate computed by
1498 conditional statement @code{G}.
1501 @deftypefn {GIMPLE function} tree gimple_cond_rhs (gimple g)
1502 Return the @code{RHS} operand of the predicate computed by conditional
1506 @deftypefn {GIMPLE function} void gimple_cond_set_rhs (gcond *g, tree rhs)
1507 Set @code{RHS} to be the @code{RHS} operand of the predicate computed by
1508 conditional statement @code{G}.
1511 @deftypefn {GIMPLE function} tree gimple_cond_true_label (const gcond *g)
1512 Return the label used by conditional statement @code{G} when its
1513 predicate evaluates to true.
1516 @deftypefn {GIMPLE function} void gimple_cond_set_true_label (gcond *g, tree label)
1517 Set @code{LABEL} to be the label used by conditional statement @code{G} when
1518 its predicate evaluates to true.
1521 @deftypefn {GIMPLE function} void gimple_cond_set_false_label (gcond *g, tree label)
1522 Set @code{LABEL} to be the label used by conditional statement @code{G} when
1523 its predicate evaluates to false.
1526 @deftypefn {GIMPLE function} tree gimple_cond_false_label (const gcond *g)
1527 Return the label used by conditional statement @code{G} when its
1528 predicate evaluates to false.
1531 @deftypefn {GIMPLE function} void gimple_cond_make_false (gcond *g)
1532 Set the conditional @code{COND_STMT} to be of the form 'if (1 == 0)'.
1535 @deftypefn {GIMPLE function} void gimple_cond_make_true (gcond *g)
1536 Set the conditional @code{COND_STMT} to be of the form 'if (1 == 1)'.
1539 @node @code{GIMPLE_DEBUG}
1540 @subsection @code{GIMPLE_DEBUG}
1541 @cindex @code{GIMPLE_DEBUG}
1542 @cindex @code{GIMPLE_DEBUG_BIND}
1543 @cindex @code{GIMPLE_DEBUG_BEGIN_STMT}
1545 @deftypefn {GIMPLE function} gdebug *gimple_build_debug_bind (tree var, @
1546 tree value, gimple stmt)
1547 Build a @code{GIMPLE_DEBUG} statement with @code{GIMPLE_DEBUG_BIND}
1548 @code{subcode}. The effect of this statement is to tell debug
1549 information generation machinery that the value of user variable
1550 @code{var} is given by @code{value} at that point, and to remain with
1551 that value until @code{var} runs out of scope, a
1552 dynamically-subsequent debug bind statement overrides the binding, or
1553 conflicting values reach a control flow merge point. Even if
1554 components of the @code{value} expression change afterwards, the
1555 variable is supposed to retain the same value, though not necessarily
1558 It is expected that @code{var} be most often a tree for automatic user
1559 variables (@code{VAR_DECL} or @code{PARM_DECL}) that satisfy the
1560 requirements for gimple registers, but it may also be a tree for a
1561 scalarized component of a user variable (@code{ARRAY_REF},
1562 @code{COMPONENT_REF}), or a debug temporary (@code{DEBUG_EXPR_DECL}).
1564 As for @code{value}, it can be an arbitrary tree expression, but it is
1565 recommended that it be in a suitable form for a gimple assignment
1566 @code{RHS}. It is not expected that user variables that could appear
1567 as @code{var} ever appear in @code{value}, because in the latter we'd
1568 have their @code{SSA_NAME}s instead, but even if they were not in SSA
1569 form, user variables appearing in @code{value} are to be regarded as
1570 part of the executable code space, whereas those in @code{var} are to
1571 be regarded as part of the source code space. There is no way to
1572 refer to the value bound to a user variable within a @code{value}
1575 If @code{value} is @code{GIMPLE_DEBUG_BIND_NOVALUE}, debug information
1576 generation machinery is informed that the variable @code{var} is
1577 unbound, i.e., that its value is indeterminate, which sometimes means
1578 it is really unavailable, and other times that the compiler could not
1581 Block and location information for the newly-created stmt are
1582 taken from @code{stmt}, if given.
1585 @deftypefn {GIMPLE function} tree gimple_debug_bind_get_var (gimple stmt)
1586 Return the user variable @var{var} that is bound at @code{stmt}.
1589 @deftypefn {GIMPLE function} tree gimple_debug_bind_get_value (gimple stmt)
1590 Return the value expression that is bound to a user variable at
1594 @deftypefn {GIMPLE function} {tree *} gimple_debug_bind_get_value_ptr (gimple stmt)
1595 Return a pointer to the value expression that is bound to a user
1596 variable at @code{stmt}.
1599 @deftypefn {GIMPLE function} void gimple_debug_bind_set_var (gimple stmt, tree var)
1600 Modify the user variable bound at @code{stmt} to @var{var}.
1603 @deftypefn {GIMPLE function} void gimple_debug_bind_set_value (gimple stmt, tree var)
1604 Modify the value bound to the user variable bound at @code{stmt} to
1608 @deftypefn {GIMPLE function} void gimple_debug_bind_reset_value (gimple stmt)
1609 Modify the value bound to the user variable bound at @code{stmt} so
1610 that the variable becomes unbound.
1613 @deftypefn {GIMPLE function} bool gimple_debug_bind_has_value_p (gimple stmt)
1614 Return @code{TRUE} if @code{stmt} binds a user variable to a value,
1615 and @code{FALSE} if it unbinds the variable.
1618 @deftypefn {GIMPLE function} gimple gimple_build_debug_begin_stmt (tree block, location_t location)
1619 Build a @code{GIMPLE_DEBUG} statement with
1620 @code{GIMPLE_DEBUG_BEGIN_STMT} @code{subcode}. The effect of this
1621 statement is to tell debug information generation machinery that the
1622 user statement at the given @code{location} and @code{block} starts at
1623 the point at which the statement is inserted. The intent is that side
1624 effects (e.g. variable bindings) of all prior user statements are
1625 observable, and that none of the side effects of subsequent user
1629 @node @code{GIMPLE_EH_FILTER}
1630 @subsection @code{GIMPLE_EH_FILTER}
1631 @cindex @code{GIMPLE_EH_FILTER}
1633 @deftypefn {GIMPLE function} geh_filter *gimple_build_eh_filter (tree types, @
1635 Build a @code{GIMPLE_EH_FILTER} statement. @code{TYPES} are the filter's
1636 types. @code{FAILURE} is a sequence with the filter's failure action.
1639 @deftypefn {GIMPLE function} tree gimple_eh_filter_types (gimple g)
1640 Return the types handled by @code{GIMPLE_EH_FILTER} statement @code{G}.
1643 @deftypefn {GIMPLE function} {tree *} gimple_eh_filter_types_ptr (gimple g)
1644 Return a pointer to the types handled by @code{GIMPLE_EH_FILTER}
1648 @deftypefn {GIMPLE function} gimple_seq gimple_eh_filter_failure (gimple g)
1649 Return the sequence of statement to execute when @code{GIMPLE_EH_FILTER}
1653 @deftypefn {GIMPLE function} void gimple_eh_filter_set_types (geh_filter *g, @
1655 Set @code{TYPES} to be the set of types handled by @code{GIMPLE_EH_FILTER} @code{G}.
1658 @deftypefn {GIMPLE function} void gimple_eh_filter_set_failure (geh_filter *g, @
1660 Set @code{FAILURE} to be the sequence of statements to execute on
1661 failure for @code{GIMPLE_EH_FILTER} @code{G}.
1664 @deftypefn {GIMPLE function} tree gimple_eh_must_not_throw_fndecl ( @
1665 geh_mnt *eh_mnt_stmt)
1666 Get the function decl to be called by the MUST_NOT_THROW region.
1669 @deftypefn {GIMPLE function} void gimple_eh_must_not_throw_set_fndecl ( @
1670 geh_mnt *eh_mnt_stmt, tree decl)
1671 Set the function decl to be called by GS to DECL.
1675 @node @code{GIMPLE_LABEL}
1676 @subsection @code{GIMPLE_LABEL}
1677 @cindex @code{GIMPLE_LABEL}
1679 @deftypefn {GIMPLE function} glabel *gimple_build_label (tree label)
1680 Build a @code{GIMPLE_LABEL} statement with corresponding to the tree
1681 label, @code{LABEL}.
1684 @deftypefn {GIMPLE function} tree gimple_label_label (const glabel *g)
1685 Return the @code{LABEL_DECL} node used by @code{GIMPLE_LABEL} statement @code{G}.
1688 @deftypefn {GIMPLE function} void gimple_label_set_label (glabel *g, tree label)
1689 Set @code{LABEL} to be the @code{LABEL_DECL} node used by @code{GIMPLE_LABEL}
1693 @node @code{GIMPLE_GOTO}
1694 @subsection @code{GIMPLE_GOTO}
1695 @cindex @code{GIMPLE_GOTO}
1697 @deftypefn {GIMPLE function} ggoto *gimple_build_goto (tree dest)
1698 Build a @code{GIMPLE_GOTO} statement to label @code{DEST}.
1701 @deftypefn {GIMPLE function} tree gimple_goto_dest (gimple g)
1702 Return the destination of the unconditional jump @code{G}.
1705 @deftypefn {GIMPLE function} void gimple_goto_set_dest (ggoto *g, tree dest)
1706 Set @code{DEST} to be the destination of the unconditional jump @code{G}.
1710 @node @code{GIMPLE_NOP}
1711 @subsection @code{GIMPLE_NOP}
1712 @cindex @code{GIMPLE_NOP}
1714 @deftypefn {GIMPLE function} gimple gimple_build_nop (void)
1715 Build a @code{GIMPLE_NOP} statement.
1718 @deftypefn {GIMPLE function} bool gimple_nop_p (gimple g)
1719 Returns @code{TRUE} if statement @code{G} is a @code{GIMPLE_NOP}.
1722 @node @code{GIMPLE_OMP_ATOMIC_LOAD}
1723 @subsection @code{GIMPLE_OMP_ATOMIC_LOAD}
1724 @cindex @code{GIMPLE_OMP_ATOMIC_LOAD}
1726 @deftypefn {GIMPLE function} gomp_atomic_load *gimple_build_omp_atomic_load ( @
1728 Build a @code{GIMPLE_OMP_ATOMIC_LOAD} statement. @code{LHS} is the left-hand
1729 side of the assignment. @code{RHS} is the right-hand side of the
1733 @deftypefn {GIMPLE function} void gimple_omp_atomic_load_set_lhs ( @
1734 gomp_atomic_load *g, tree lhs)
1735 Set the @code{LHS} of an atomic load.
1738 @deftypefn {GIMPLE function} tree gimple_omp_atomic_load_lhs ( @
1739 const gomp_atomic_load *g)
1740 Get the @code{LHS} of an atomic load.
1743 @deftypefn {GIMPLE function} void gimple_omp_atomic_load_set_rhs ( @
1744 gomp_atomic_load *g, tree rhs)
1745 Set the @code{RHS} of an atomic set.
1748 @deftypefn {GIMPLE function} tree gimple_omp_atomic_load_rhs ( @
1749 const gomp_atomic_load *g)
1750 Get the @code{RHS} of an atomic set.
1754 @node @code{GIMPLE_OMP_ATOMIC_STORE}
1755 @subsection @code{GIMPLE_OMP_ATOMIC_STORE}
1756 @cindex @code{GIMPLE_OMP_ATOMIC_STORE}
1758 @deftypefn {GIMPLE function} gomp_atomic_store *gimple_build_omp_atomic_store ( @
1760 Build a @code{GIMPLE_OMP_ATOMIC_STORE} statement. @code{VAL} is the value to be
1764 @deftypefn {GIMPLE function} void gimple_omp_atomic_store_set_val ( @
1765 gomp_atomic_store *g, tree val)
1766 Set the value being stored in an atomic store.
1769 @deftypefn {GIMPLE function} tree gimple_omp_atomic_store_val ( @
1770 const gomp_atomic_store *g)
1771 Return the value being stored in an atomic store.
1774 @node @code{GIMPLE_OMP_CONTINUE}
1775 @subsection @code{GIMPLE_OMP_CONTINUE}
1776 @cindex @code{GIMPLE_OMP_CONTINUE}
1778 @deftypefn {GIMPLE function} gomp_continue *gimple_build_omp_continue ( @
1779 tree control_def, tree control_use)
1780 Build a @code{GIMPLE_OMP_CONTINUE} statement. @code{CONTROL_DEF} is the
1781 definition of the control variable. @code{CONTROL_USE} is the use of
1782 the control variable.
1785 @deftypefn {GIMPLE function} tree gimple_omp_continue_control_def ( @
1786 const gomp_continue *s)
1787 Return the definition of the control variable on a
1788 @code{GIMPLE_OMP_CONTINUE} in @code{S}.
1791 @deftypefn {GIMPLE function} tree gimple_omp_continue_control_def_ptr ( @
1793 Same as above, but return the pointer.
1796 @deftypefn {GIMPLE function} tree gimple_omp_continue_set_control_def ( @
1798 Set the control variable definition for a @code{GIMPLE_OMP_CONTINUE}
1799 statement in @code{S}.
1802 @deftypefn {GIMPLE function} tree gimple_omp_continue_control_use ( @
1803 const gomp_continue *s)
1804 Return the use of the control variable on a @code{GIMPLE_OMP_CONTINUE}
1808 @deftypefn {GIMPLE function} tree gimple_omp_continue_control_use_ptr ( @
1810 Same as above, but return the pointer.
1813 @deftypefn {GIMPLE function} tree gimple_omp_continue_set_control_use ( @
1815 Set the control variable use for a @code{GIMPLE_OMP_CONTINUE} statement
1820 @node @code{GIMPLE_OMP_CRITICAL}
1821 @subsection @code{GIMPLE_OMP_CRITICAL}
1822 @cindex @code{GIMPLE_OMP_CRITICAL}
1824 @deftypefn {GIMPLE function} gomp_critical *gimple_build_omp_critical ( @
1825 gimple_seq body, tree name)
1826 Build a @code{GIMPLE_OMP_CRITICAL} statement. @code{BODY} is the sequence of
1827 statements for which only one thread can execute. @code{NAME} is an
1828 optional identifier for this critical block.
1831 @deftypefn {GIMPLE function} tree gimple_omp_critical_name ( @
1832 const gomp_critical *g)
1833 Return the name associated with @code{OMP_CRITICAL} statement @code{G}.
1836 @deftypefn {GIMPLE function} {tree *} gimple_omp_critical_name_ptr ( @
1838 Return a pointer to the name associated with @code{OMP} critical
1842 @deftypefn {GIMPLE function} void gimple_omp_critical_set_name ( @
1843 gomp_critical *g, tree name)
1844 Set @code{NAME} to be the name associated with @code{OMP} critical statement @code{G}.
1847 @node @code{GIMPLE_OMP_FOR}
1848 @subsection @code{GIMPLE_OMP_FOR}
1849 @cindex @code{GIMPLE_OMP_FOR}
1851 @deftypefn {GIMPLE function} gomp_for *gimple_build_omp_for (gimple_seq body, @
1852 tree clauses, tree index, tree initial, tree final, tree incr, @
1853 gimple_seq pre_body, enum tree_code omp_for_cond)
1854 Build a @code{GIMPLE_OMP_FOR} statement. @code{BODY} is sequence of statements
1855 inside the for loop. @code{CLAUSES}, are any of the loop
1856 construct's clauses. @code{PRE_BODY} is the
1857 sequence of statements that are loop invariant. @code{INDEX} is the
1858 index variable. @code{INITIAL} is the initial value of @code{INDEX}. @code{FINAL} is
1859 final value of @code{INDEX}. OMP_FOR_COND is the predicate used to
1860 compare @code{INDEX} and @code{FINAL}. @code{INCR} is the increment expression.
1863 @deftypefn {GIMPLE function} tree gimple_omp_for_clauses (gimple g)
1864 Return the clauses associated with @code{OMP_FOR} @code{G}.
1867 @deftypefn {GIMPLE function} {tree *} gimple_omp_for_clauses_ptr (gimple g)
1868 Return a pointer to the @code{OMP_FOR} @code{G}.
1871 @deftypefn {GIMPLE function} void gimple_omp_for_set_clauses (gimple g, tree clauses)
1872 Set @code{CLAUSES} to be the list of clauses associated with @code{OMP_FOR} @code{G}.
1875 @deftypefn {GIMPLE function} tree gimple_omp_for_index (gimple g)
1876 Return the index variable for @code{OMP_FOR} @code{G}.
1879 @deftypefn {GIMPLE function} {tree *} gimple_omp_for_index_ptr (gimple g)
1880 Return a pointer to the index variable for @code{OMP_FOR} @code{G}.
1883 @deftypefn {GIMPLE function} void gimple_omp_for_set_index (gimple g, tree index)
1884 Set @code{INDEX} to be the index variable for @code{OMP_FOR} @code{G}.
1887 @deftypefn {GIMPLE function} tree gimple_omp_for_initial (gimple g)
1888 Return the initial value for @code{OMP_FOR} @code{G}.
1891 @deftypefn {GIMPLE function} {tree *} gimple_omp_for_initial_ptr (gimple g)
1892 Return a pointer to the initial value for @code{OMP_FOR} @code{G}.
1895 @deftypefn {GIMPLE function} void gimple_omp_for_set_initial (gimple g, tree initial)
1896 Set @code{INITIAL} to be the initial value for @code{OMP_FOR} @code{G}.
1899 @deftypefn {GIMPLE function} tree gimple_omp_for_final (gimple g)
1900 Return the final value for @code{OMP_FOR} @code{G}.
1903 @deftypefn {GIMPLE function} {tree *} gimple_omp_for_final_ptr (gimple g)
1904 turn a pointer to the final value for @code{OMP_FOR} @code{G}.
1907 @deftypefn {GIMPLE function} void gimple_omp_for_set_final (gimple g, tree final)
1908 Set @code{FINAL} to be the final value for @code{OMP_FOR} @code{G}.
1911 @deftypefn {GIMPLE function} tree gimple_omp_for_incr (gimple g)
1912 Return the increment value for @code{OMP_FOR} @code{G}.
1915 @deftypefn {GIMPLE function} {tree *} gimple_omp_for_incr_ptr (gimple g)
1916 Return a pointer to the increment value for @code{OMP_FOR} @code{G}.
1919 @deftypefn {GIMPLE function} void gimple_omp_for_set_incr (gimple g, tree incr)
1920 Set @code{INCR} to be the increment value for @code{OMP_FOR} @code{G}.
1923 @deftypefn {GIMPLE function} gimple_seq gimple_omp_for_pre_body (gimple g)
1924 Return the sequence of statements to execute before the @code{OMP_FOR}
1925 statement @code{G} starts.
1928 @deftypefn {GIMPLE function} void gimple_omp_for_set_pre_body (gimple g, gimple_seq pre_body)
1929 Set @code{PRE_BODY} to be the sequence of statements to execute before
1930 the @code{OMP_FOR} statement @code{G} starts.
1933 @deftypefn {GIMPLE function} void gimple_omp_for_set_cond (gimple g, enum tree_code cond)
1934 Set @code{COND} to be the condition code for @code{OMP_FOR} @code{G}.
1937 @deftypefn {GIMPLE function} {enum tree_code} gimple_omp_for_cond (gimple g)
1938 Return the condition code associated with @code{OMP_FOR} @code{G}.
1942 @node @code{GIMPLE_OMP_MASTER}
1943 @subsection @code{GIMPLE_OMP_MASTER}
1944 @cindex @code{GIMPLE_OMP_MASTER}
1946 @deftypefn {GIMPLE function} gimple gimple_build_omp_master (gimple_seq body)
1947 Build a @code{GIMPLE_OMP_MASTER} statement. @code{BODY} is the sequence of
1948 statements to be executed by just the master.
1952 @node @code{GIMPLE_OMP_ORDERED}
1953 @subsection @code{GIMPLE_OMP_ORDERED}
1954 @cindex @code{GIMPLE_OMP_ORDERED}
1956 @deftypefn {GIMPLE function} gimple gimple_build_omp_ordered (gimple_seq body)
1957 Build a @code{GIMPLE_OMP_ORDERED} statement.
1960 @code{BODY} is the sequence of statements inside a loop that will
1961 executed in sequence.
1964 @node @code{GIMPLE_OMP_PARALLEL}
1965 @subsection @code{GIMPLE_OMP_PARALLEL}
1966 @cindex @code{GIMPLE_OMP_PARALLEL}
1968 @deftypefn {GIMPLE function} gomp_parallel *gimple_build_omp_parallel (@
1969 gimple_seq body, tree clauses, tree child_fn, tree data_arg)
1970 Build a @code{GIMPLE_OMP_PARALLEL} statement.
1973 @code{BODY} is sequence of statements which are executed in parallel.
1974 @code{CLAUSES}, are the @code{OMP} parallel construct's clauses. @code{CHILD_FN} is
1975 the function created for the parallel threads to execute.
1976 @code{DATA_ARG} are the shared data argument(s).
1978 @deftypefn {GIMPLE function} bool gimple_omp_parallel_combined_p (gimple g)
1979 Return true if @code{OMP} parallel statement @code{G} has the
1980 @code{GF_OMP_PARALLEL_COMBINED} flag set.
1983 @deftypefn {GIMPLE function} void gimple_omp_parallel_set_combined_p (gimple g)
1984 Set the @code{GF_OMP_PARALLEL_COMBINED} field in @code{OMP} parallel statement
1988 @deftypefn {GIMPLE function} gimple_seq gimple_omp_body (gimple g)
1989 Return the body for the @code{OMP} statement @code{G}.
1992 @deftypefn {GIMPLE function} void gimple_omp_set_body (gimple g, gimple_seq body)
1993 Set @code{BODY} to be the body for the @code{OMP} statement @code{G}.
1996 @deftypefn {GIMPLE function} tree gimple_omp_parallel_clauses (gimple g)
1997 Return the clauses associated with @code{OMP_PARALLEL} @code{G}.
2000 @deftypefn {GIMPLE function} {tree *} gimple_omp_parallel_clauses_ptr ( @
2002 Return a pointer to the clauses associated with @code{OMP_PARALLEL} @code{G}.
2005 @deftypefn {GIMPLE function} void gimple_omp_parallel_set_clauses ( @
2006 gomp_parallel *g, tree clauses)
2007 Set @code{CLAUSES} to be the list of clauses associated with
2008 @code{OMP_PARALLEL} @code{G}.
2011 @deftypefn {GIMPLE function} tree gimple_omp_parallel_child_fn ( @
2012 const gomp_parallel *g)
2013 Return the child function used to hold the body of @code{OMP_PARALLEL}
2017 @deftypefn {GIMPLE function} {tree *} gimple_omp_parallel_child_fn_ptr ( @
2019 Return a pointer to the child function used to hold the body of
2020 @code{OMP_PARALLEL} @code{G}.
2023 @deftypefn {GIMPLE function} void gimple_omp_parallel_set_child_fn ( @
2024 gomp_parallel *g, tree child_fn)
2025 Set @code{CHILD_FN} to be the child function for @code{OMP_PARALLEL} @code{G}.
2028 @deftypefn {GIMPLE function} tree gimple_omp_parallel_data_arg ( @
2029 const gomp_parallel *g)
2030 Return the artificial argument used to send variables and values
2031 from the parent to the children threads in @code{OMP_PARALLEL} @code{G}.
2034 @deftypefn {GIMPLE function} {tree *} gimple_omp_parallel_data_arg_ptr ( @
2036 Return a pointer to the data argument for @code{OMP_PARALLEL} @code{G}.
2039 @deftypefn {GIMPLE function} void gimple_omp_parallel_set_data_arg ( @
2040 gomp_parallel *g, tree data_arg)
2041 Set @code{DATA_ARG} to be the data argument for @code{OMP_PARALLEL} @code{G}.
2045 @node @code{GIMPLE_OMP_RETURN}
2046 @subsection @code{GIMPLE_OMP_RETURN}
2047 @cindex @code{GIMPLE_OMP_RETURN}
2049 @deftypefn {GIMPLE function} gimple gimple_build_omp_return (bool wait_p)
2050 Build a @code{GIMPLE_OMP_RETURN} statement. @code{WAIT_P} is true if this is a
2054 @deftypefn {GIMPLE function} void gimple_omp_return_set_nowait (gimple s)
2055 Set the nowait flag on @code{GIMPLE_OMP_RETURN} statement @code{S}.
2059 @deftypefn {GIMPLE function} bool gimple_omp_return_nowait_p (gimple g)
2060 Return true if @code{OMP} return statement @code{G} has the
2061 @code{GF_OMP_RETURN_NOWAIT} flag set.
2064 @node @code{GIMPLE_OMP_SECTION}
2065 @subsection @code{GIMPLE_OMP_SECTION}
2066 @cindex @code{GIMPLE_OMP_SECTION}
2068 @deftypefn {GIMPLE function} gimple gimple_build_omp_section (gimple_seq body)
2069 Build a @code{GIMPLE_OMP_SECTION} statement for a sections statement.
2072 @code{BODY} is the sequence of statements in the section.
2074 @deftypefn {GIMPLE function} bool gimple_omp_section_last_p (gimple g)
2075 Return true if @code{OMP} section statement @code{G} has the
2076 @code{GF_OMP_SECTION_LAST} flag set.
2079 @deftypefn {GIMPLE function} void gimple_omp_section_set_last (gimple g)
2080 Set the @code{GF_OMP_SECTION_LAST} flag on @code{G}.
2083 @node @code{GIMPLE_OMP_SECTIONS}
2084 @subsection @code{GIMPLE_OMP_SECTIONS}
2085 @cindex @code{GIMPLE_OMP_SECTIONS}
2087 @deftypefn {GIMPLE function} gomp_sections *gimple_build_omp_sections ( @
2088 gimple_seq body, tree clauses)
2089 Build a @code{GIMPLE_OMP_SECTIONS} statement. @code{BODY} is a sequence of
2090 section statements. @code{CLAUSES} are any of the @code{OMP} sections
2091 construct's clauses: private, firstprivate, lastprivate,
2092 reduction, and nowait.
2096 @deftypefn {GIMPLE function} gimple gimple_build_omp_sections_switch (void)
2097 Build a @code{GIMPLE_OMP_SECTIONS_SWITCH} statement.
2100 @deftypefn {GIMPLE function} tree gimple_omp_sections_control (gimple g)
2101 Return the control variable associated with the
2102 @code{GIMPLE_OMP_SECTIONS} in @code{G}.
2105 @deftypefn {GIMPLE function} {tree *} gimple_omp_sections_control_ptr (gimple g)
2106 Return a pointer to the clauses associated with the
2107 @code{GIMPLE_OMP_SECTIONS} in @code{G}.
2110 @deftypefn {GIMPLE function} void gimple_omp_sections_set_control (gimple g, tree control)
2111 Set @code{CONTROL} to be the set of clauses associated with the
2112 @code{GIMPLE_OMP_SECTIONS} in @code{G}.
2115 @deftypefn {GIMPLE function} tree gimple_omp_sections_clauses (gimple g)
2116 Return the clauses associated with @code{OMP_SECTIONS} @code{G}.
2119 @deftypefn {GIMPLE function} {tree *} gimple_omp_sections_clauses_ptr (gimple g)
2120 Return a pointer to the clauses associated with @code{OMP_SECTIONS} @code{G}.
2123 @deftypefn {GIMPLE function} void gimple_omp_sections_set_clauses (gimple g, tree clauses)
2124 Set @code{CLAUSES} to be the set of clauses associated with @code{OMP_SECTIONS}
2129 @node @code{GIMPLE_OMP_SINGLE}
2130 @subsection @code{GIMPLE_OMP_SINGLE}
2131 @cindex @code{GIMPLE_OMP_SINGLE}
2133 @deftypefn {GIMPLE function} gomp_single *gimple_build_omp_single ( @
2134 gimple_seq body, tree clauses)
2135 Build a @code{GIMPLE_OMP_SINGLE} statement. @code{BODY} is the sequence of
2136 statements that will be executed once. @code{CLAUSES} are any of the
2137 @code{OMP} single construct's clauses: private, firstprivate,
2138 copyprivate, nowait.
2141 @deftypefn {GIMPLE function} tree gimple_omp_single_clauses (gimple g)
2142 Return the clauses associated with @code{OMP_SINGLE} @code{G}.
2145 @deftypefn {GIMPLE function} {tree *} gimple_omp_single_clauses_ptr (gimple g)
2146 Return a pointer to the clauses associated with @code{OMP_SINGLE} @code{G}.
2149 @deftypefn {GIMPLE function} void gimple_omp_single_set_clauses ( @
2150 gomp_single *g, tree clauses)
2151 Set @code{CLAUSES} to be the clauses associated with @code{OMP_SINGLE} @code{G}.
2155 @node @code{GIMPLE_PHI}
2156 @subsection @code{GIMPLE_PHI}
2157 @cindex @code{GIMPLE_PHI}
2159 @deftypefn {GIMPLE function} unsigned gimple_phi_capacity (gimple g)
2160 Return the maximum number of arguments supported by @code{GIMPLE_PHI} @code{G}.
2163 @deftypefn {GIMPLE function} unsigned gimple_phi_num_args (gimple g)
2164 Return the number of arguments in @code{GIMPLE_PHI} @code{G}. This must always
2165 be exactly the number of incoming edges for the basic block
2169 @deftypefn {GIMPLE function} tree gimple_phi_result (gimple g)
2170 Return the @code{SSA} name created by @code{GIMPLE_PHI} @code{G}.
2173 @deftypefn {GIMPLE function} {tree *} gimple_phi_result_ptr (gimple g)
2174 Return a pointer to the @code{SSA} name created by @code{GIMPLE_PHI} @code{G}.
2177 @deftypefn {GIMPLE function} void gimple_phi_set_result (gphi *g, tree result)
2178 Set @code{RESULT} to be the @code{SSA} name created by @code{GIMPLE_PHI} @code{G}.
2181 @deftypefn {GIMPLE function} {struct phi_arg_d *} gimple_phi_arg (gimple g, index)
2182 Return the @code{PHI} argument corresponding to incoming edge @code{INDEX} for
2183 @code{GIMPLE_PHI} @code{G}.
2186 @deftypefn {GIMPLE function} void gimple_phi_set_arg (gphi *g, index, @
2187 struct phi_arg_d * phiarg)
2188 Set @code{PHIARG} to be the argument corresponding to incoming edge
2189 @code{INDEX} for @code{GIMPLE_PHI} @code{G}.
2192 @node @code{GIMPLE_RESX}
2193 @subsection @code{GIMPLE_RESX}
2194 @cindex @code{GIMPLE_RESX}
2196 @deftypefn {GIMPLE function} gresx *gimple_build_resx (int region)
2197 Build a @code{GIMPLE_RESX} statement which is a statement. This
2198 statement is a placeholder for _Unwind_Resume before we know if a
2199 function call or a branch is needed. @code{REGION} is the exception
2200 region from which control is flowing.
2203 @deftypefn {GIMPLE function} int gimple_resx_region (const gresx *g)
2204 Return the region number for @code{GIMPLE_RESX} @code{G}.
2207 @deftypefn {GIMPLE function} void gimple_resx_set_region (gresx *g, int region)
2208 Set @code{REGION} to be the region number for @code{GIMPLE_RESX} @code{G}.
2211 @node @code{GIMPLE_RETURN}
2212 @subsection @code{GIMPLE_RETURN}
2213 @cindex @code{GIMPLE_RETURN}
2215 @deftypefn {GIMPLE function} greturn *gimple_build_return (tree retval)
2216 Build a @code{GIMPLE_RETURN} statement whose return value is retval.
2219 @deftypefn {GIMPLE function} tree gimple_return_retval (const greturn *g)
2220 Return the return value for @code{GIMPLE_RETURN} @code{G}.
2223 @deftypefn {GIMPLE function} void gimple_return_set_retval (greturn *g, @
2225 Set @code{RETVAL} to be the return value for @code{GIMPLE_RETURN} @code{G}.
2228 @node @code{GIMPLE_SWITCH}
2229 @subsection @code{GIMPLE_SWITCH}
2230 @cindex @code{GIMPLE_SWITCH}
2232 @deftypefn {GIMPLE function} gswitch *gimple_build_switch (tree index, @
2233 tree default_label, @code{vec}<tree> *args)
2234 Build a @code{GIMPLE_SWITCH} statement. @code{INDEX} is the index variable
2235 to switch on, and @code{DEFAULT_LABEL} represents the default label.
2236 @code{ARGS} is a vector of @code{CASE_LABEL_EXPR} trees that contain the
2237 non-default case labels. Each label is a tree of code @code{CASE_LABEL_EXPR}.
2240 @deftypefn {GIMPLE function} unsigned gimple_switch_num_labels ( @
2242 Return the number of labels associated with the switch statement
2246 @deftypefn {GIMPLE function} void gimple_switch_set_num_labels (gswitch *g, @
2248 Set @code{NLABELS} to be the number of labels for the switch statement
2252 @deftypefn {GIMPLE function} tree gimple_switch_index (const gswitch *g)
2253 Return the index variable used by the switch statement @code{G}.
2256 @deftypefn {GIMPLE function} void gimple_switch_set_index (gswitch *g, @
2258 Set @code{INDEX} to be the index variable for switch statement @code{G}.
2261 @deftypefn {GIMPLE function} tree gimple_switch_label (const gswitch *g, @
2263 Return the label numbered @code{INDEX}. The default label is 0, followed
2264 by any labels in a switch statement.
2267 @deftypefn {GIMPLE function} void gimple_switch_set_label (gswitch *g, @
2268 unsigned index, tree label)
2269 Set the label number @code{INDEX} to @code{LABEL}. 0 is always the default
2273 @deftypefn {GIMPLE function} tree gimple_switch_default_label ( @
2275 Return the default label for a switch statement.
2278 @deftypefn {GIMPLE function} void gimple_switch_set_default_label (gswitch *g, @
2280 Set the default label for a switch statement.
2284 @node @code{GIMPLE_TRY}
2285 @subsection @code{GIMPLE_TRY}
2286 @cindex @code{GIMPLE_TRY}
2288 @deftypefn {GIMPLE function} gtry *gimple_build_try (gimple_seq eval, @
2289 gimple_seq cleanup, unsigned int kind)
2290 Build a @code{GIMPLE_TRY} statement. @code{EVAL} is a sequence with the
2291 expression to evaluate. @code{CLEANUP} is a sequence of statements to
2292 run at clean-up time. @code{KIND} is the enumeration value
2293 @code{GIMPLE_TRY_CATCH} if this statement denotes a try/catch construct
2294 or @code{GIMPLE_TRY_FINALLY} if this statement denotes a try/finally
2298 @deftypefn {GIMPLE function} {enum gimple_try_flags} gimple_try_kind (gimple g)
2299 Return the kind of try block represented by @code{GIMPLE_TRY} @code{G}. This is
2300 either @code{GIMPLE_TRY_CATCH} or @code{GIMPLE_TRY_FINALLY}.
2303 @deftypefn {GIMPLE function} bool gimple_try_catch_is_cleanup (gimple g)
2304 Return the @code{GIMPLE_TRY_CATCH_IS_CLEANUP} flag.
2307 @deftypefn {GIMPLE function} gimple_seq gimple_try_eval (gimple g)
2308 Return the sequence of statements used as the body for @code{GIMPLE_TRY}
2312 @deftypefn {GIMPLE function} gimple_seq gimple_try_cleanup (gimple g)
2313 Return the sequence of statements used as the cleanup body for
2314 @code{GIMPLE_TRY} @code{G}.
2317 @deftypefn {GIMPLE function} void gimple_try_set_catch_is_cleanup (gimple g, @
2318 bool catch_is_cleanup)
2319 Set the @code{GIMPLE_TRY_CATCH_IS_CLEANUP} flag.
2322 @deftypefn {GIMPLE function} void gimple_try_set_eval (gtry *g, gimple_seq eval)
2323 Set @code{EVAL} to be the sequence of statements to use as the body for
2324 @code{GIMPLE_TRY} @code{G}.
2327 @deftypefn {GIMPLE function} void gimple_try_set_cleanup (gtry *g, @
2329 Set @code{CLEANUP} to be the sequence of statements to use as the
2330 cleanup body for @code{GIMPLE_TRY} @code{G}.
2333 @node @code{GIMPLE_WITH_CLEANUP_EXPR}
2334 @subsection @code{GIMPLE_WITH_CLEANUP_EXPR}
2335 @cindex @code{GIMPLE_WITH_CLEANUP_EXPR}
2337 @deftypefn {GIMPLE function} gimple gimple_build_wce (gimple_seq cleanup)
2338 Build a @code{GIMPLE_WITH_CLEANUP_EXPR} statement. @code{CLEANUP} is the
2339 clean-up expression.
2342 @deftypefn {GIMPLE function} gimple_seq gimple_wce_cleanup (gimple g)
2343 Return the cleanup sequence for cleanup statement @code{G}.
2346 @deftypefn {GIMPLE function} void gimple_wce_set_cleanup (gimple g, gimple_seq cleanup)
2347 Set @code{CLEANUP} to be the cleanup sequence for @code{G}.
2350 @deftypefn {GIMPLE function} bool gimple_wce_cleanup_eh_only (gimple g)
2351 Return the @code{CLEANUP_EH_ONLY} flag for a @code{WCE} tuple.
2354 @deftypefn {GIMPLE function} void gimple_wce_set_cleanup_eh_only (gimple g, bool eh_only_p)
2355 Set the @code{CLEANUP_EH_ONLY} flag for a @code{WCE} tuple.
2359 @node GIMPLE sequences
2360 @section GIMPLE sequences
2361 @cindex GIMPLE sequences
2363 GIMPLE sequences are the tuple equivalent of @code{STATEMENT_LIST}'s
2364 used in @code{GENERIC}. They are used to chain statements together, and
2365 when used in conjunction with sequence iterators, provide a
2366 framework for iterating through statements.
2368 GIMPLE sequences are of type struct @code{gimple_sequence}, but are more
2369 commonly passed by reference to functions dealing with sequences.
2370 The type for a sequence pointer is @code{gimple_seq} which is the same
2371 as struct @code{gimple_sequence} *. When declaring a local sequence,
2372 you can define a local variable of type struct @code{gimple_sequence}.
2373 When declaring a sequence allocated on the garbage collected
2374 heap, use the function @code{gimple_seq_alloc} documented below.
2376 There are convenience functions for iterating through sequences
2377 in the section entitled Sequence Iterators.
2379 Below is a list of functions to manipulate and query sequences.
2381 @deftypefn {GIMPLE function} void gimple_seq_add_stmt (gimple_seq *seq, gimple g)
2382 Link a gimple statement to the end of the sequence *@code{SEQ} if @code{G} is
2383 not @code{NULL}. If *@code{SEQ} is @code{NULL}, allocate a sequence before linking.
2386 @deftypefn {GIMPLE function} void gimple_seq_add_seq (gimple_seq *dest, gimple_seq src)
2387 Append sequence @code{SRC} to the end of sequence *@code{DEST} if @code{SRC} is not
2388 @code{NULL}. If *@code{DEST} is @code{NULL}, allocate a new sequence before
2392 @deftypefn {GIMPLE function} gimple_seq gimple_seq_deep_copy (gimple_seq src)
2393 Perform a deep copy of sequence @code{SRC} and return the result.
2396 @deftypefn {GIMPLE function} gimple_seq gimple_seq_reverse (gimple_seq seq)
2397 Reverse the order of the statements in the sequence @code{SEQ}. Return
2401 @deftypefn {GIMPLE function} gimple gimple_seq_first (gimple_seq s)
2402 Return the first statement in sequence @code{S}.
2405 @deftypefn {GIMPLE function} gimple gimple_seq_last (gimple_seq s)
2406 Return the last statement in sequence @code{S}.
2409 @deftypefn {GIMPLE function} void gimple_seq_set_last (gimple_seq s, gimple last)
2410 Set the last statement in sequence @code{S} to the statement in @code{LAST}.
2413 @deftypefn {GIMPLE function} void gimple_seq_set_first (gimple_seq s, gimple first)
2414 Set the first statement in sequence @code{S} to the statement in @code{FIRST}.
2417 @deftypefn {GIMPLE function} void gimple_seq_init (gimple_seq s)
2418 Initialize sequence @code{S} to an empty sequence.
2421 @deftypefn {GIMPLE function} gimple_seq gimple_seq_alloc (void)
2422 Allocate a new sequence in the garbage collected store and return
2426 @deftypefn {GIMPLE function} void gimple_seq_copy (gimple_seq dest, gimple_seq src)
2427 Copy the sequence @code{SRC} into the sequence @code{DEST}.
2430 @deftypefn {GIMPLE function} bool gimple_seq_empty_p (gimple_seq s)
2431 Return true if the sequence @code{S} is empty.
2434 @deftypefn {GIMPLE function} gimple_seq bb_seq (basic_block bb)
2435 Returns the sequence of statements in @code{BB}.
2438 @deftypefn {GIMPLE function} void set_bb_seq (basic_block bb, gimple_seq seq)
2439 Sets the sequence of statements in @code{BB} to @code{SEQ}.
2442 @deftypefn {GIMPLE function} bool gimple_seq_singleton_p (gimple_seq seq)
2443 Determine whether @code{SEQ} contains exactly one statement.
2446 @node Sequence iterators
2447 @section Sequence iterators
2448 @cindex Sequence iterators
2450 Sequence iterators are convenience constructs for iterating
2451 through statements in a sequence. Given a sequence @code{SEQ}, here is
2452 a typical use of gimple sequence iterators:
2455 gimple_stmt_iterator gsi;
2457 for (gsi = gsi_start (seq); !gsi_end_p (gsi); gsi_next (&gsi))
2459 gimple g = gsi_stmt (gsi);
2460 /* Do something with gimple statement @code{G}. */
2464 Backward iterations are possible:
2467 for (gsi = gsi_last (seq); !gsi_end_p (gsi); gsi_prev (&gsi))
2470 Forward and backward iterations on basic blocks are possible with
2471 @code{gsi_start_bb} and @code{gsi_last_bb}.
2473 In the documentation below we sometimes refer to enum
2474 @code{gsi_iterator_update}. The valid options for this enumeration are:
2477 @item @code{GSI_NEW_STMT}
2478 Only valid when a single statement is added. Move the iterator to it.
2480 @item @code{GSI_SAME_STMT}
2481 Leave the iterator at the same statement.
2483 @item @code{GSI_CONTINUE_LINKING}
2484 Move iterator to whatever position is suitable for linking other
2485 statements in the same direction.
2488 Below is a list of the functions used to manipulate and use
2489 statement iterators.
2491 @deftypefn {GIMPLE function} gimple_stmt_iterator gsi_start (gimple_seq seq)
2492 Return a new iterator pointing to the sequence @code{SEQ}'s first
2493 statement. If @code{SEQ} is empty, the iterator's basic block is @code{NULL}.
2494 Use @code{gsi_start_bb} instead when the iterator needs to always have
2495 the correct basic block set.
2498 @deftypefn {GIMPLE function} gimple_stmt_iterator gsi_start_bb (basic_block bb)
2499 Return a new iterator pointing to the first statement in basic
2503 @deftypefn {GIMPLE function} gimple_stmt_iterator gsi_last (gimple_seq seq)
2504 Return a new iterator initially pointing to the last statement of
2505 sequence @code{SEQ}. If @code{SEQ} is empty, the iterator's basic block is
2506 @code{NULL}. Use @code{gsi_last_bb} instead when the iterator needs to always
2507 have the correct basic block set.
2510 @deftypefn {GIMPLE function} gimple_stmt_iterator gsi_last_bb (basic_block bb)
2511 Return a new iterator pointing to the last statement in basic
2515 @deftypefn {GIMPLE function} bool gsi_end_p (gimple_stmt_iterator i)
2516 Return @code{TRUE} if at the end of @code{I}.
2519 @deftypefn {GIMPLE function} bool gsi_one_before_end_p (gimple_stmt_iterator i)
2520 Return @code{TRUE} if we're one statement before the end of @code{I}.
2523 @deftypefn {GIMPLE function} void gsi_next (gimple_stmt_iterator *i)
2524 Advance the iterator to the next gimple statement.
2527 @deftypefn {GIMPLE function} void gsi_prev (gimple_stmt_iterator *i)
2528 Advance the iterator to the previous gimple statement.
2531 @deftypefn {GIMPLE function} gimple gsi_stmt (gimple_stmt_iterator i)
2532 Return the current stmt.
2535 @deftypefn {GIMPLE function} gimple_stmt_iterator gsi_after_labels (basic_block bb)
2536 Return a block statement iterator that points to the first
2537 non-label statement in block @code{BB}.
2540 @deftypefn {GIMPLE function} {gimple *} gsi_stmt_ptr (gimple_stmt_iterator *i)
2541 Return a pointer to the current stmt.
2544 @deftypefn {GIMPLE function} basic_block gsi_bb (gimple_stmt_iterator i)
2545 Return the basic block associated with this iterator.
2548 @deftypefn {GIMPLE function} gimple_seq gsi_seq (gimple_stmt_iterator i)
2549 Return the sequence associated with this iterator.
2552 @deftypefn {GIMPLE function} void gsi_remove (gimple_stmt_iterator *i, bool remove_eh_info)
2553 Remove the current stmt from the sequence. The iterator is
2554 updated to point to the next statement. When @code{REMOVE_EH_INFO} is
2555 true we remove the statement pointed to by iterator @code{I} from the @code{EH}
2556 tables. Otherwise we do not modify the @code{EH} tables. Generally,
2557 @code{REMOVE_EH_INFO} should be true when the statement is going to be
2558 removed from the @code{IL} and not reinserted elsewhere.
2561 @deftypefn {GIMPLE function} void gsi_link_seq_before (gimple_stmt_iterator *i, gimple_seq seq, enum gsi_iterator_update mode)
2562 Links the sequence of statements @code{SEQ} before the statement pointed
2563 by iterator @code{I}. @code{MODE} indicates what to do with the iterator
2564 after insertion (see @code{enum gsi_iterator_update} above).
2567 @deftypefn {GIMPLE function} void gsi_link_before (gimple_stmt_iterator *i, gimple g, enum gsi_iterator_update mode)
2568 Links statement @code{G} before the statement pointed-to by iterator @code{I}.
2569 Updates iterator @code{I} according to @code{MODE}.
2572 @deftypefn {GIMPLE function} void gsi_link_seq_after (gimple_stmt_iterator *i, @
2573 gimple_seq seq, enum gsi_iterator_update mode)
2574 Links sequence @code{SEQ} after the statement pointed-to by iterator @code{I}.
2575 @code{MODE} is as in @code{gsi_insert_after}.
2578 @deftypefn {GIMPLE function} void gsi_link_after (gimple_stmt_iterator *i, @
2579 gimple g, enum gsi_iterator_update mode)
2580 Links statement @code{G} after the statement pointed-to by iterator @code{I}.
2581 @code{MODE} is as in @code{gsi_insert_after}.
2584 @deftypefn {GIMPLE function} gimple_seq gsi_split_seq_after (gimple_stmt_iterator i)
2585 Move all statements in the sequence after @code{I} to a new sequence.
2586 Return this new sequence.
2589 @deftypefn {GIMPLE function} gimple_seq gsi_split_seq_before (gimple_stmt_iterator *i)
2590 Move all statements in the sequence before @code{I} to a new sequence.
2591 Return this new sequence.
2594 @deftypefn {GIMPLE function} void gsi_replace (gimple_stmt_iterator *i, @
2595 gimple stmt, bool update_eh_info)
2596 Replace the statement pointed-to by @code{I} to @code{STMT}. If @code{UPDATE_EH_INFO}
2597 is true, the exception handling information of the original
2598 statement is moved to the new statement.
2601 @deftypefn {GIMPLE function} void gsi_insert_before (gimple_stmt_iterator *i, @
2602 gimple stmt, enum gsi_iterator_update mode)
2603 Insert statement @code{STMT} before the statement pointed-to by iterator
2604 @code{I}, update @code{STMT}'s basic block and scan it for new operands. @code{MODE}
2605 specifies how to update iterator @code{I} after insertion (see enum
2606 @code{gsi_iterator_update}).
2609 @deftypefn {GIMPLE function} void gsi_insert_seq_before (gimple_stmt_iterator *i, @
2610 gimple_seq seq, enum gsi_iterator_update mode)
2611 Like @code{gsi_insert_before}, but for all the statements in @code{SEQ}.
2614 @deftypefn {GIMPLE function} void gsi_insert_after (gimple_stmt_iterator *i, @
2615 gimple stmt, enum gsi_iterator_update mode)
2616 Insert statement @code{STMT} after the statement pointed-to by iterator
2617 @code{I}, update @code{STMT}'s basic block and scan it for new operands. @code{MODE}
2618 specifies how to update iterator @code{I} after insertion (see enum
2619 @code{gsi_iterator_update}).
2622 @deftypefn {GIMPLE function} void gsi_insert_seq_after (gimple_stmt_iterator *i, @
2623 gimple_seq seq, enum gsi_iterator_update mode)
2624 Like @code{gsi_insert_after}, but for all the statements in @code{SEQ}.
2627 @deftypefn {GIMPLE function} gimple_stmt_iterator gsi_for_stmt (gimple stmt)
2628 Finds iterator for @code{STMT}.
2631 @deftypefn {GIMPLE function} void gsi_move_after (gimple_stmt_iterator *from, @
2632 gimple_stmt_iterator *to)
2633 Move the statement at @code{FROM} so it comes right after the statement
2637 @deftypefn {GIMPLE function} void gsi_move_before (gimple_stmt_iterator *from, @
2638 gimple_stmt_iterator *to)
2639 Move the statement at @code{FROM} so it comes right before the statement
2643 @deftypefn {GIMPLE function} void gsi_move_to_bb_end (gimple_stmt_iterator *from, @
2645 Move the statement at @code{FROM} to the end of basic block @code{BB}.
2648 @deftypefn {GIMPLE function} void gsi_insert_on_edge (edge e, gimple stmt)
2649 Add @code{STMT} to the pending list of edge @code{E}. No actual insertion is
2650 made until a call to @code{gsi_commit_edge_inserts}() is made.
2653 @deftypefn {GIMPLE function} void gsi_insert_seq_on_edge (edge e, gimple_seq seq)
2654 Add the sequence of statements in @code{SEQ} to the pending list of edge
2655 @code{E}. No actual insertion is made until a call to
2656 @code{gsi_commit_edge_inserts}() is made.
2659 @deftypefn {GIMPLE function} basic_block gsi_insert_on_edge_immediate (edge e, gimple stmt)
2660 Similar to @code{gsi_insert_on_edge}+@code{gsi_commit_edge_inserts}. If a new
2661 block has to be created, it is returned.
2664 @deftypefn {GIMPLE function} void gsi_commit_one_edge_insert (edge e, basic_block *new_bb)
2665 Commit insertions pending at edge @code{E}. If a new block is created,
2666 set @code{NEW_BB} to this block, otherwise set it to @code{NULL}.
2669 @deftypefn {GIMPLE function} void gsi_commit_edge_inserts (void)
2670 This routine will commit all pending edge insertions, creating
2671 any new basic blocks which are necessary.
2675 @node Adding a new GIMPLE statement code
2676 @section Adding a new GIMPLE statement code
2677 @cindex Adding a new GIMPLE statement code
2679 The first step in adding a new GIMPLE statement code, is
2680 modifying the file @code{gimple.def}, which contains all the GIMPLE
2681 codes. Then you must add a corresponding gimple subclass
2682 located in @code{gimple.h}. This in turn, will require you to add a
2683 corresponding @code{GTY} tag in @code{gsstruct.def}, and code to handle
2684 this tag in @code{gss_for_code} which is located in @code{gimple.c}.
2686 In order for the garbage collector to know the size of the
2687 structure you created in @code{gimple.h}, you need to add a case to
2688 handle your new GIMPLE statement in @code{gimple_size} which is located
2691 You will probably want to create a function to build the new
2692 gimple statement in @code{gimple.c}. The function should be called
2693 @code{gimple_build_@var{new-tuple-name}}, and should return the new tuple
2694 as a pointer to the appropriate gimple subclass.
2696 If your new statement requires accessors for any members or
2697 operands it may have, put simple inline accessors in
2698 @code{gimple.h} and any non-trivial accessors in @code{gimple.c} with a
2699 corresponding prototype in @code{gimple.h}.
2701 You should add the new statement subclass to the class hierarchy diagram
2702 in @code{gimple.texi}.
2705 @node Statement and operand traversals
2706 @section Statement and operand traversals
2707 @cindex Statement and operand traversals
2709 There are two functions available for walking statements and
2710 sequences: @code{walk_gimple_stmt} and @code{walk_gimple_seq},
2711 accordingly, and a third function for walking the operands in a
2712 statement: @code{walk_gimple_op}.
2714 @deftypefn {GIMPLE function} tree walk_gimple_stmt (gimple_stmt_iterator *gsi, @
2715 walk_stmt_fn callback_stmt, walk_tree_fn callback_op, struct walk_stmt_info *wi)
2716 This function is used to walk the current statement in @code{GSI},
2717 optionally using traversal state stored in @code{WI}. If @code{WI} is @code{NULL}, no
2718 state is kept during the traversal.
2720 The callback @code{CALLBACK_STMT} is called. If @code{CALLBACK_STMT} returns
2721 true, it means that the callback function has handled all the
2722 operands of the statement and it is not necessary to walk its
2725 If @code{CALLBACK_STMT} is @code{NULL} or it returns false, @code{CALLBACK_OP} is
2726 called on each operand of the statement via @code{walk_gimple_op}. If
2727 @code{walk_gimple_op} returns non-@code{NULL} for any operand, the remaining
2728 operands are not scanned.
2730 The return value is that returned by the last call to
2731 @code{walk_gimple_op}, or @code{NULL_TREE} if no @code{CALLBACK_OP} is specified.
2735 @deftypefn {GIMPLE function} tree walk_gimple_op (gimple stmt, @
2736 walk_tree_fn callback_op, struct walk_stmt_info *wi)
2737 Use this function to walk the operands of statement @code{STMT}. Every
2738 operand is walked via @code{walk_tree} with optional state information
2741 @code{CALLBACK_OP} is called on each operand of @code{STMT} via @code{walk_tree}.
2742 Additional parameters to @code{walk_tree} must be stored in @code{WI}. For
2743 each operand @code{OP}, @code{walk_tree} is called as:
2746 walk_tree (&@code{OP}, @code{CALLBACK_OP}, @code{WI}, @code{PSET})
2749 If @code{CALLBACK_OP} returns non-@code{NULL} for an operand, the remaining
2750 operands are not scanned. The return value is that returned by
2751 the last call to @code{walk_tree}, or @code{NULL_TREE} if no @code{CALLBACK_OP} is
2756 @deftypefn {GIMPLE function} tree walk_gimple_seq (gimple_seq seq, @
2757 walk_stmt_fn callback_stmt, walk_tree_fn callback_op, struct walk_stmt_info *wi)
2758 This function walks all the statements in the sequence @code{SEQ}
2759 calling @code{walk_gimple_stmt} on each one. @code{WI} is as in
2760 @code{walk_gimple_stmt}. If @code{walk_gimple_stmt} returns non-@code{NULL}, the walk
2761 is stopped and the value returned. Otherwise, all the statements
2762 are walked and @code{NULL_TREE} returned.