]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/doc/gimple.texi
Update copyright years.
[thirdparty/gcc.git] / gcc / doc / gimple.texi
CommitLineData
a945c346 1@c Copyright (C) 2008-2024 Free Software Foundation, Inc.
d77de738
ML
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.
5
6@node GIMPLE
7@chapter GIMPLE
8@cindex GIMPLE
9
10GIMPLE is a three-address representation derived from GENERIC by
11breaking down GENERIC expressions into tuples of no more than 3
12operands (with some exceptions like function calls). GIMPLE was
13heavily influenced by the SIMPLE IL used by the McCAT compiler
14project at McGill University, though we have made some different
15choices. For one thing, SIMPLE doesn't support @code{goto}.
16
17Temporaries are introduced to hold intermediate values needed to
18compute complex expressions. Additionally, all the control
19structures used in GENERIC are lowered into conditional jumps,
20lexical scopes are removed and exception regions are converted
21into an on the side exception region tree.
22
23The compiler pass which converts GENERIC into GIMPLE is referred to as
24the @samp{gimplifier}. The gimplifier works recursively, generating
25GIMPLE tuples out of the original GENERIC expressions.
26
27One of the early implementation strategies used for the GIMPLE
28representation was to use the same internal data structures used
29by front ends to represent parse trees. This simplified
30implementation because we could leverage existing functionality
31and interfaces. However, GIMPLE is a much more restrictive
32representation than abstract syntax trees (AST), therefore it
33does not require the full structural complexity provided by the
34main tree data structure.
35
36The GENERIC representation of a function is stored in the
37@code{DECL_SAVED_TREE} field of the associated @code{FUNCTION_DECL}
38tree node. It is converted to GIMPLE by a call to
39@code{gimplify_function_tree}.
40
41If a front end wants to include language-specific tree codes in the tree
42representation which it provides to the back end, it must provide a
43definition of @code{LANG_HOOKS_GIMPLIFY_EXPR} which knows how to
44convert the front end trees to GIMPLE@. Usually such a hook will involve
45much of the same code for expanding front end trees to RTL@. This function
46can return fully lowered GIMPLE, or it can return GENERIC trees and let the
47main gimplifier lower them the rest of the way; this is often simpler.
48GIMPLE that is not fully lowered is known as ``High GIMPLE'' and
49consists of the IL before the pass @code{pass_lower_cf}. High GIMPLE
50contains 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
53implicit jumps for control and exception expressions directly in
54the IL and EH region trees.
55
56The C and C++ front ends currently convert directly from front end
57trees to GIMPLE, and hand that off to the back end rather than first
58converting to GENERIC@. Their gimplifier hooks know about all the
59@code{_STMT} nodes and how to convert them to GENERIC forms. There
60was some work done on a genericization pass which would run first, but
61the existence of @code{STMT_EXPR} meant that in order to convert all
62of the C statements into GENERIC equivalents would involve walking the
63entire tree anyway, so it was simpler to lower all the way. This
64might change in the future if someone writes an optimization pass
65which would work better with higher-level trees, but currently the
66optimizers all expect GIMPLE@.
67
68You can request to dump a C-like representation of the GIMPLE form
69with the flag @option{-fdump-tree-gimple}.
70
71@menu
72* Tuple representation::
73* Class hierarchy of GIMPLE statements::
74* GIMPLE instruction set::
75* GIMPLE Exception Handling::
76* Temporaries::
77* Operands::
78* Manipulating GIMPLE statements::
79* Tuple specific accessors::
80* GIMPLE sequences::
81* Sequence iterators::
82* Adding a new GIMPLE statement code::
83* Statement and operand traversals::
84@end menu
85
86@node Tuple representation
87@section Tuple representation
88@cindex tuples
89
90GIMPLE instructions are tuples of variable size divided in two
91groups: a header describing the instruction and its locations,
92and a variable length body with all the operands. Tuples are
93organized into a hierarchy with 3 main classes of tuples.
94
95@subsection @code{gimple} (gsbase)
96@cindex gimple
97
98This is the root of the hierarchy, it holds basic information
99needed by most GIMPLE statements. There are some fields that
100may not be relevant to every GIMPLE statement, but those were
101moved into the base structure to take advantage of holes left by
102other fields (thus making the structure more compact). The
103structure takes 4 words (32 bytes) on 64 bit hosts:
104
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
122@end multitable
123
124@itemize @bullet
125@item @code{code}
126Main identifier for a GIMPLE instruction.
127
128@item @code{subcode}
129Used to distinguish different variants of the same basic
130instruction or provide flags applicable to a given code. The
131@code{subcode} flags field has different uses depending on the code of
132the instruction, but mostly it distinguishes instructions of the
133same family. The most prominent use of this field is in
134assignments, where subcode indicates the operation done on the
135RHS of the assignment. For example, a = b + c is encoded as
136@code{GIMPLE_ASSIGN <PLUS_EXPR, a, b, c>}.
137
138@item @code{no_warning}
139Bitflag to indicate whether a warning has already been issued on
140this statement.
141
142@item @code{visited}
143General purpose ``visited'' marker. Set and cleared by each pass
144when needed.
145
146@item @code{nontemporal_move}
147Bitflag used in assignments that represent non-temporal moves.
148Although this bitflag is only used in assignments, it was moved
149into the base to take advantage of the bit holes left by the
150previous fields.
151
152@item @code{plf}
153Pass Local Flags. This 2-bit mask can be used as general purpose
154markers by any pass. Passes are responsible for clearing and
155setting these two flags accordingly.
156
157@item @code{modified}
158Bitflag to indicate whether the statement has been modified.
159Used mainly by the operand scanner to determine when to re-scan a
160statement for operands.
161
162@item @code{has_volatile_ops}
163Bitflag to indicate whether this statement contains operands that
164have been marked volatile.
165
166@item @code{references_memory_p}
167Bitflag to indicate whether this statement contains memory
168references (i.e., its operands are either global variables, or
169pointer dereferences or anything that must reside in memory).
170
171@item @code{uid}
172This is an unsigned integer used by passes that want to assign
173IDs to every statement. These IDs must be assigned and used by
174each pass.
175
176@item @code{location}
177This is a @code{location_t} identifier to specify source code
178location for this statement. It is inherited from the front
179end.
180
181@item @code{num_ops}
182Number of operands that this statement has. This specifies the
183size of the operand vector embedded in the tuple. Only used in
184some tuples, but it is declared in the base tuple to take
185advantage of the 32-bit hole left by the previous fields.
186
187@item @code{bb}
188Basic block holding the instruction.
189
190@item @code{block}
191Lexical block holding this statement. Also used for debug
192information generation.
193@end itemize
194
195@subsection @code{gimple_statement_with_ops}
196@cindex gimple_statement_with_ops
197
198This 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
201way the operand vector is allocated. The operand vector is
202defined to be an array of 1 element. So, to allocate a dynamic
203number of operands, the memory allocator (@code{gimple_alloc}) simply
204allocates enough memory to hold the structure itself plus @code{N
205- 1} operands which run ``off the end'' of the structure. For
206example, to allocate space for a tuple with 3 operands,
207@code{gimple_alloc} reserves @code{sizeof (struct
208gimple_statement_with_ops) + 2 * sizeof (tree)} bytes.
209
210On the other hand, several fields in this tuple need to be shared
211with the @code{gimple_statement_with_memory_ops} tuple. So, these
212common fields are placed in @code{gimple_statement_with_ops_base} which
213is then inherited from the other two tuples.
214
215
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
222@end multitable
223
224@itemize @bullet
225@item @code{gsbase}
226Inherited from @code{struct gimple}.
227
228@item @code{def_ops}
229Array of pointers into the operand array indicating all the slots that
230contain a variable written-to by the statement. This array is
231also used for immediate use chaining. Note that it would be
232possible to not rely on this array, but the changes required to
233implement this are pretty invasive.
234
235@item @code{use_ops}
236Similar to @code{def_ops} but for variables read by the statement.
237
238@item @code{op}
239Array of trees with @code{num_ops} slots.
240@end itemize
241
242@subsection @code{gimple_statement_with_memory_ops}
243
244This tuple is essentially identical to @code{gimple_statement_with_ops},
245except that it contains 4 additional fields to hold vectors
246related memory stores and loads. Similar to the previous case,
247the structure is split in two to accommodate for the operand
248vector (@code{gimple_statement_with_memory_ops_base} and
249@code{gimple_statement_with_memory_ops}).
250
251
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
263@end multitable
264
265@itemize @bullet
266@item @code{vdef_ops}
267Similar to @code{def_ops} but for @code{VDEF} operators. There is
268one entry per memory symbol written by this statement. This is
269used to maintain the memory SSA use-def and def-def chains.
270
271@item @code{vuse_ops}
272Similar to @code{use_ops} but for @code{VUSE} operators. There is
273one entry per memory symbol loaded by this statement. This is
274used to maintain the memory SSA use-def chains.
275
276@item @code{stores}
277Bitset with all the UIDs for the symbols written-to by the
278statement. This is different than @code{vdef_ops} in that all the
279affected symbols are mentioned in this set. If memory
280partitioning is enabled, the @code{vdef_ops} vector will refer to memory
281partitions. Furthermore, no SSA information is stored in this
282set.
283
284@item @code{loads}
285Similar to @code{stores}, but for memory loads. (Note that there
286is some amount of redundancy here, it should be possible to
287reduce memory utilization further by removing these sets).
288@end itemize
289
290All the other tuples are defined in terms of these three basic
291ones. Each tuple will add some fields.
292
293
294@node Class hierarchy of GIMPLE statements
295@section Class hierarchy of GIMPLE statements
296@cindex GIMPLE class hierarchy
297
298The following diagram shows the C++ inheritance hierarchy of statement
299kinds, along with their relationships to @code{GSS_} values (layouts) and
300@code{GIMPLE_} values (codes):
301
302@smallexample
303 gimple
304 | layout: GSS_BASE
305 | used for 4 codes: GIMPLE_ERROR_MARK
306 | GIMPLE_NOP
307 | GIMPLE_OMP_SECTIONS_SWITCH
308 | GIMPLE_PREDICT
309 |
310 + gimple_statement_with_ops_base
311 | | (no GSS layout)
312 | |
313 | + gimple_statement_with_ops
314 | | | layout: GSS_WITH_OPS
315 | | |
316 | | + gcond
317 | | | code: GIMPLE_COND
318 | | |
319 | | + gdebug
320 | | | code: GIMPLE_DEBUG
321 | | |
322 | | + ggoto
323 | | | code: GIMPLE_GOTO
324 | | |
325 | | + glabel
326 | | | code: GIMPLE_LABEL
327 | | |
328 | | + gswitch
329 | | code: GIMPLE_SWITCH
330 | |
331 | + gimple_statement_with_memory_ops_base
332 | | layout: GSS_WITH_MEM_OPS_BASE
333 | |
334 | + gimple_statement_with_memory_ops
335 | | | layout: GSS_WITH_MEM_OPS
336 | | |
337 | | + gassign
338 | | | code GIMPLE_ASSIGN
339 | | |
340 | | + greturn
341 | | code GIMPLE_RETURN
342 | |
343 | + gcall
344 | | layout: GSS_CALL, code: GIMPLE_CALL
345 | |
346 | + gasm
347 | | layout: GSS_ASM, code: GIMPLE_ASM
348 | |
349 | + gtransaction
350 | layout: GSS_TRANSACTION, code: GIMPLE_TRANSACTION
351 |
352 + gimple_statement_omp
353 | | layout: GSS_OMP. Used for code GIMPLE_OMP_SECTION
354 | |
355 | + gomp_critical
356 | | layout: GSS_OMP_CRITICAL, code: GIMPLE_OMP_CRITICAL
357 | |
358 | + gomp_for
359 | | layout: GSS_OMP_FOR, code: GIMPLE_OMP_FOR
360 | |
361 | + gomp_parallel_layout
362 | | | layout: GSS_OMP_PARALLEL_LAYOUT
363 | | |
364 | | + gimple_statement_omp_taskreg
365 | | | |
366 | | | + gomp_parallel
367 | | | | code: GIMPLE_OMP_PARALLEL
368 | | | |
369 | | | + gomp_task
370 | | | code: GIMPLE_OMP_TASK
371 | | |
372 | | + gimple_statement_omp_target
373 | | code: GIMPLE_OMP_TARGET
374 | |
375 | + gomp_sections
376 | | layout: GSS_OMP_SECTIONS, code: GIMPLE_OMP_SECTIONS
377 | |
378 | + gimple_statement_omp_single_layout
379 | | layout: GSS_OMP_SINGLE_LAYOUT
380 | |
381 | + gomp_single
382 | | code: GIMPLE_OMP_SINGLE
383 | |
384 | + gomp_teams
385 | code: GIMPLE_OMP_TEAMS
386 |
387 + gbind
388 | layout: GSS_BIND, code: GIMPLE_BIND
389 |
390 + gcatch
391 | layout: GSS_CATCH, code: GIMPLE_CATCH
392 |
393 + geh_filter
394 | layout: GSS_EH_FILTER, code: GIMPLE_EH_FILTER
395 |
396 + geh_else
397 | layout: GSS_EH_ELSE, code: GIMPLE_EH_ELSE
398 |
399 + geh_mnt
400 | layout: GSS_EH_MNT, code: GIMPLE_EH_MUST_NOT_THROW
401 |
402 + gphi
403 | layout: GSS_PHI, code: GIMPLE_PHI
404 |
405 + gimple_statement_eh_ctrl
406 | | layout: GSS_EH_CTRL
407 | |
408 | + gresx
409 | | code: GIMPLE_RESX
410 | |
411 | + geh_dispatch
412 | code: GIMPLE_EH_DISPATCH
413 |
414 + gtry
415 | layout: GSS_TRY, code: GIMPLE_TRY
416 |
417 + gimple_statement_wce
418 | layout: GSS_WCE, code: GIMPLE_WITH_CLEANUP_EXPR
419 |
420 + gomp_continue
421 | layout: GSS_OMP_CONTINUE, code: GIMPLE_OMP_CONTINUE
422 |
423 + gomp_atomic_load
424 | layout: GSS_OMP_ATOMIC_LOAD, code: GIMPLE_OMP_ATOMIC_LOAD
425 |
426 + gimple_statement_omp_atomic_store_layout
427 | layout: GSS_OMP_ATOMIC_STORE_LAYOUT,
428 | code: GIMPLE_OMP_ATOMIC_STORE
429 |
430 + gomp_atomic_store
431 | code: GIMPLE_OMP_ATOMIC_STORE
432 |
433 + gomp_return
434 code: GIMPLE_OMP_RETURN
435@end smallexample
436
437
438@node GIMPLE instruction set
439@section GIMPLE instruction set
440@cindex GIMPLE instruction set
441
442The following table briefly describes the GIMPLE instruction set.
443
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
a62c8324 471@item @code{GIMPLE_OMP_STRUCTURED_BLOCK} @tab x @tab
d77de738
ML
472@item @code{GIMPLE_RESX} @tab @tab x
473@item @code{GIMPLE_RETURN} @tab x @tab x
474@item @code{GIMPLE_SWITCH} @tab x @tab x
475@item @code{GIMPLE_TRY} @tab x @tab
476@end multitable
477
478@node GIMPLE Exception Handling
479@section Exception Handling
480@cindex GIMPLE Exception Handling
481
482Other exception handling constructs are represented using
483@code{GIMPLE_TRY_CATCH}. @code{GIMPLE_TRY_CATCH} has two operands. The
484first operand is a sequence of statements to execute. If executing
485these statements does not throw an exception, then the second operand
486is ignored. Otherwise, if an exception is thrown, then the second
487operand of the @code{GIMPLE_TRY_CATCH} is checked. The second
488operand may have the following forms:
489
490@enumerate
491
492@item A sequence of statements to execute. When an exception occurs,
493these statements are executed, and then the exception is rethrown.
494
495@item A sequence of @code{GIMPLE_CATCH} statements. Each
496@code{GIMPLE_CATCH} has a list of applicable exception types and
497handler code. If the thrown exception matches one of the caught
498types, the associated handler code is executed. If the handler
499code falls off the bottom, execution continues after the original
500@code{GIMPLE_TRY_CATCH}.
501
502@item A @code{GIMPLE_EH_FILTER} statement. This has a list of
503permitted exception types, and code to handle a match failure. If the
504thrown exception does not match one of the allowed types, the
505associated match failure code is executed. If the thrown exception
506does match, it continues unwinding the stack looking for the next
507handler.
508
509@end enumerate
510
511Currently throwing an exception is not directly represented in
512GIMPLE, since it is implemented by calling a function. At some
513point in the future we will want to add some way to express that
514the call will throw an exception of a known type.
515
516Just before running the optimizers, the compiler lowers the
517high-level EH constructs above into a set of @samp{goto}s, magic
518labels, and EH regions. Continuing to unwind at the end of a
519cleanup is represented with a @code{GIMPLE_RESX}.
520
521
522@node Temporaries
523@section Temporaries
524@cindex Temporaries
525
526When gimplification encounters a subexpression that is too
527complex, it creates a new temporary variable to hold the value of
528the subexpression, and adds a new statement to initialize it
529before the current statement. These special temporaries are known
530as @samp{expression temporaries}, and are allocated using
531@code{get_formal_tmp_var}. The compiler tries to always evaluate
532identical expressions into the same temporary, to simplify
533elimination of redundant calculations.
534
535We can only use expression temporaries when we know that it will
536not be reevaluated before its value is used, and that it will not
537be otherwise modified@footnote{These restrictions are derived
538from those in Morgan 4.8.}. Other temporaries can be allocated
539using @code{get_initialized_tmp_var} or @code{create_tmp_var}.
540
541Currently, an expression like @code{a = b + 5} is not reduced any
542further. We tried converting it to something like
543@smallexample
544T1 = b + 5;
545a = T1;
546@end smallexample
547but this bloated the representation for minimal benefit. However, a
548variable which must live in memory cannot appear in an expression; its
549value is explicitly loaded into a temporary first. Similarly, storing
550the value of an expression to a memory variable goes through a
551temporary.
552
553@node Operands
554@section Operands
555@cindex Operands
556
557In general, expressions in GIMPLE consist of an operation and the
558appropriate number of simple operands; these operands must either be a
559GIMPLE rvalue (@code{is_gimple_val}), i.e.@: a constant or a register
560variable. More complex operands are factored out into temporaries, so
561that
562@smallexample
563a = b + c + d
564@end smallexample
565becomes
566@smallexample
567T1 = b + c;
568a = T1 + d;
569@end smallexample
570
571The same rule holds for arguments to a @code{GIMPLE_CALL}.
572
573The target of an assignment is usually a variable, but can also be a
574@code{MEM_REF} or a compound lvalue as described below.
575
576@menu
577* Compound Expressions::
578* Compound Lvalues::
579* Conditional Expressions::
580* Logical Operators::
581@end menu
582
583@node Compound Expressions
584@subsection Compound Expressions
585@cindex Compound Expressions
586
587The left-hand side of a C comma expression is simply moved into a separate
588statement.
589
590@node Compound Lvalues
591@subsection Compound Lvalues
592@cindex Compound Lvalues
593
594Currently compound lvalues involving array and structure field references
595are not broken down; an expression like @code{a.b[2] = 42} is not reduced
596any further (though complex array subscripts are). This restriction is a
597workaround for limitations in later optimizers; if we were to convert this
598to
599
600@smallexample
601T1 = &a.b;
602T1[2] = 42;
603@end smallexample
604
605alias analysis would not remember that the reference to @code{T1[2]} came
606by way of @code{a.b}, so it would think that the assignment could alias
607another member of @code{a}; this broke @code{struct-alias-1.c}. Future
608optimizer improvements may make this limitation unnecessary.
609
610@node Conditional Expressions
611@subsection Conditional Expressions
612@cindex Conditional Expressions
613
614A C @code{?:} expression is converted into an @code{if} statement with
615each branch assigning to the same temporary. So,
616
617@smallexample
618a = b ? c : d;
619@end smallexample
620becomes
621@smallexample
622if (b == 1)
623 T1 = c;
624else
625 T1 = d;
626a = T1;
627@end smallexample
628
629The GIMPLE level if-conversion pass re-introduces @code{?:}
630expression, if appropriate. It is used to vectorize loops with
631conditions using vector conditional operations.
632
633Note that in GIMPLE, @code{if} statements are represented using
634@code{GIMPLE_COND}, as described below.
635
636@node Logical Operators
637@subsection Logical Operators
638@cindex Logical Operators
639
640Except when they appear in the condition operand of a
641@code{GIMPLE_COND}, logical `and' and `or' operators are simplified
642as follows: @code{a = b && c} becomes
643
644@smallexample
645T1 = (bool)b;
646if (T1 == true)
647 T1 = (bool)c;
648a = T1;
649@end smallexample
650
651Note that @code{T1} in this example cannot be an expression temporary,
652because it has two different assignments.
653
654@subsection Manipulating operands
655
656All gimple operands are of type @code{tree}. But only certain
657types of trees are allowed to be used as operand tuples. Basic
658validation is controlled by the function
659@code{get_gimple_rhs_class}, which given a tree code, returns an
660@code{enum} with the following values of type @code{enum
661gimple_rhs_class}
662
663@itemize @bullet
664@item @code{GIMPLE_INVALID_RHS}
665The tree cannot be used as a GIMPLE operand.
666
667@item @code{GIMPLE_TERNARY_RHS}
668The tree is a valid GIMPLE ternary operation.
669
670@item @code{GIMPLE_BINARY_RHS}
671The tree is a valid GIMPLE binary operation.
672
673@item @code{GIMPLE_UNARY_RHS}
674The tree is a valid GIMPLE unary operation.
675
676@item @code{GIMPLE_SINGLE_RHS}
677The tree is a single object, that cannot be split into simpler
678operands (for instance, @code{SSA_NAME}, @code{VAR_DECL}, @code{COMPONENT_REF}, etc).
679
680This operand class also acts as an escape hatch for tree nodes
681that may be flattened out into the operand vector, but would need
682more than two slots on the RHS. For instance, a @code{COND_EXPR}
683expression of the form @code{(a op b) ? x : y} could be flattened
684out on the operand vector using 4 slots, but it would also
685require additional processing to distinguish @code{c = a op b}
42639a36 686from @code{c = a op b ? x : y}. In time, these special case tree
d77de738
ML
687expressions should be flattened into the operand vector.
688@end itemize
689
690For tree nodes in the categories @code{GIMPLE_TERNARY_RHS},
691@code{GIMPLE_BINARY_RHS} and @code{GIMPLE_UNARY_RHS}, they cannot be
692stored inside tuples directly. They first need to be flattened and
693separated into individual components. For instance, given the GENERIC
694expression
695
696@smallexample
697a = b + c
698@end smallexample
699
700its tree representation is:
701
702@smallexample
703MODIFY_EXPR <VAR_DECL <a>, PLUS_EXPR <VAR_DECL <b>, VAR_DECL <c>>>
704@end smallexample
705
706In this case, the GIMPLE form for this statement is logically
707identical to its GENERIC form but in GIMPLE, the @code{PLUS_EXPR}
708on the RHS of the assignment is not represented as a tree,
709instead the two operands are taken out of the @code{PLUS_EXPR} sub-tree
710and flattened into the GIMPLE tuple as follows:
711
712@smallexample
713GIMPLE_ASSIGN <PLUS_EXPR, VAR_DECL <a>, VAR_DECL <b>, VAR_DECL <c>>
714@end smallexample
715
716@subsection Operand vector allocation
717
718The operand vector is stored at the bottom of the three tuple
719structures that accept operands. This means, that depending on
720the code of a given statement, its operand vector will be at
721different offsets from the base of the structure. To access
722tuple operands use the following accessors
723
724@deftypefn {GIMPLE function} unsigned gimple_num_ops (gimple g)
725Returns the number of operands in statement G.
726@end deftypefn
727
728@deftypefn {GIMPLE function} tree gimple_op (gimple g, unsigned i)
729Returns operand @code{I} from statement @code{G}.
730@end deftypefn
731
732@deftypefn {GIMPLE function} {tree *} gimple_ops (gimple g)
733Returns a pointer into the operand vector for statement @code{G}. This
734is computed using an internal table called @code{gimple_ops_offset_}[].
735This table is indexed by the gimple code of @code{G}.
736
737When the compiler is built, this table is filled-in using the
738sizes of the structures used by each statement code defined in
739gimple.def. Since the operand vector is at the bottom of the
740structure, for a gimple code @code{C} the offset is computed as sizeof
741(struct-of @code{C}) - sizeof (tree).
742
743This mechanism adds one memory indirection to every access when
744using @code{gimple_op}(), if this becomes a bottleneck, a pass can
745choose to memoize the result from @code{gimple_ops}() and use that to
746access the operands.
747@end deftypefn
748
749@subsection Operand validation
750
751When adding a new operand to a gimple statement, the operand will
752be validated according to what each tuple accepts in its operand
753vector. These predicates are called by the
754@code{gimple_@var{name}_set_...()}. Each tuple will use one of the
755following predicates (Note, this list is not exhaustive):
756
757@deftypefn {GIMPLE function} bool is_gimple_val (tree t)
758Returns true if t is a "GIMPLE value", which are all the
759non-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).
762@end deftypefn
763
764@deftypefn {GIMPLE function} bool is_gimple_addressable (tree t)
765Returns true if t is a symbol or memory reference whose address
766can be taken.
767@end deftypefn
768
769@deftypefn {GIMPLE function} bool is_gimple_asm_val (tree t)
770Similar to @code{is_gimple_val} but it also accepts hard registers.
771@end deftypefn
772
773@deftypefn {GIMPLE function} bool is_gimple_call_addr (tree t)
774Return true if t is a valid expression to use as the function
775called by a @code{GIMPLE_CALL}.
776@end deftypefn
777
778@deftypefn {GIMPLE function} bool is_gimple_mem_ref_addr (tree t)
779Return true if t is a valid expression to use as first operand
780of a @code{MEM_REF} expression.
781@end deftypefn
782
783@deftypefn {GIMPLE function} bool is_gimple_constant (tree t)
784Return true if t is a valid gimple constant.
785@end deftypefn
786
787@deftypefn {GIMPLE function} bool is_gimple_min_invariant (tree t)
788Return true if t is a valid minimal invariant. This is different
789from constants, in that the specific value of t may not be known
790at compile time, but it is known that it doesn't change (e.g.,
791the address of a function local variable).
792@end deftypefn
793
794@deftypefn {GIMPLE function} bool is_gimple_ip_invariant (tree t)
795Return true if t is an interprocedural invariant. This means that t
796is a valid invariant in all functions (e.g.@: it can be an address of a
797global variable but not of a local one).
798@end deftypefn
799
800@deftypefn {GIMPLE function} bool is_gimple_ip_invariant_address (tree t)
801Return true if t is an @code{ADDR_EXPR} that does not change once the
802program is running (and which is valid in all functions).
803@end deftypefn
804
805
806@subsection Statement validation
807
808@deftypefn {GIMPLE function} bool is_gimple_assign (gimple g)
809Return true if the code of g is @code{GIMPLE_ASSIGN}.
810@end deftypefn
811
812@deftypefn {GIMPLE function} bool is_gimple_call (gimple g)
813Return true if the code of g is @code{GIMPLE_CALL}.
814@end deftypefn
815
816@deftypefn {GIMPLE function} bool is_gimple_debug (gimple g)
817Return true if the code of g is @code{GIMPLE_DEBUG}.
818@end deftypefn
819
820@deftypefn {GIMPLE function} bool gimple_assign_cast_p (const_gimple g)
821Return true if g is a @code{GIMPLE_ASSIGN} that performs a type cast
822operation.
823@end deftypefn
824
825@deftypefn {GIMPLE function} bool gimple_debug_bind_p (gimple g)
826Return true if g is a @code{GIMPLE_DEBUG} that binds the value of an
827expression to a variable.
828@end deftypefn
829
830@deftypefn {GIMPLE function} bool is_gimple_omp (gimple g)
831Return true if g is any of the OpenMP codes.
832@end deftypefn
833
834@deftypefn {GIMPLE function} bool gimple_debug_begin_stmt_p (gimple g)
835Return true if g is a @code{GIMPLE_DEBUG} that marks the beginning of
836a source statement.
837@end deftypefn
838
839@deftypefn {GIMPLE function} bool gimple_debug_inline_entry_p (gimple g)
840Return true if g is a @code{GIMPLE_DEBUG} that marks the entry
841point of an inlined function.
842@end deftypefn
843
844@deftypefn {GIMPLE function} bool gimple_debug_nonbind_marker_p (gimple g)
845Return true if g is a @code{GIMPLE_DEBUG} that marks a program location,
846without any variable binding.
847@end deftypefn
848
849@node Manipulating GIMPLE statements
850@section Manipulating GIMPLE statements
851@cindex Manipulating GIMPLE statements
852
853This section documents all the functions available to handle each
854of the GIMPLE instructions.
855
856@subsection Common accessors
857The following are common accessors for gimple statements.
858
859@deftypefn {GIMPLE function} {enum gimple_code} gimple_code (gimple g)
860Return the code for statement @code{G}.
861@end deftypefn
862
863@deftypefn {GIMPLE function} basic_block gimple_bb (gimple g)
864Return the basic block to which statement @code{G} belongs to.
865@end deftypefn
866
867@deftypefn {GIMPLE function} tree gimple_block (gimple g)
868Return the lexical scope block holding statement @code{G}.
869@end deftypefn
870
871@deftypefn {GIMPLE function} {enum tree_code} gimple_expr_code (gimple stmt)
872Return the tree code for the expression computed by @code{STMT}. This
873is only meaningful for @code{GIMPLE_CALL}, @code{GIMPLE_ASSIGN} and
874@code{GIMPLE_COND}. If @code{STMT} is @code{GIMPLE_CALL}, it will return @code{CALL_EXPR}.
875For @code{GIMPLE_COND}, it returns the code of the comparison predicate.
876For @code{GIMPLE_ASSIGN} it returns the code of the operation performed
877by the @code{RHS} of the assignment.
878@end deftypefn
879
880@deftypefn {GIMPLE function} void gimple_set_block (gimple g, tree block)
881Set the lexical scope block of @code{G} to @code{BLOCK}.
882@end deftypefn
883
884@deftypefn {GIMPLE function} location_t gimple_locus (gimple g)
885Return locus information for statement @code{G}.
886@end deftypefn
887
888@deftypefn {GIMPLE function} void gimple_set_locus (gimple g, location_t locus)
889Set locus information for statement @code{G}.
890@end deftypefn
891
892@deftypefn {GIMPLE function} bool gimple_locus_empty_p (gimple g)
893Return true if @code{G} does not have locus information.
894@end deftypefn
895
896@deftypefn {GIMPLE function} bool gimple_no_warning_p (gimple stmt)
897Return true if no warnings should be emitted for statement @code{STMT}.
898@end deftypefn
899
900@deftypefn {GIMPLE function} void gimple_set_visited (gimple stmt, bool visited_p)
901Set the visited status on statement @code{STMT} to @code{VISITED_P}.
902@end deftypefn
903
904@deftypefn {GIMPLE function} bool gimple_visited_p (gimple stmt)
905Return the visited status on statement @code{STMT}.
906@end deftypefn
907
908@deftypefn {GIMPLE function} void gimple_set_plf (gimple stmt, enum plf_mask plf, bool val_p)
909Set pass local flag @code{PLF} on statement @code{STMT} to @code{VAL_P}.
910@end deftypefn
911
912@deftypefn {GIMPLE function} {unsigned int} gimple_plf (gimple stmt, enum plf_mask plf)
913Return the value of pass local flag @code{PLF} on statement @code{STMT}.
914@end deftypefn
915
916@deftypefn {GIMPLE function} bool gimple_has_ops (gimple g)
917Return true if statement @code{G} has register or memory operands.
918@end deftypefn
919
920@deftypefn {GIMPLE function} bool gimple_has_mem_ops (gimple g)
921Return true if statement @code{G} has memory operands.
922@end deftypefn
923
924@deftypefn {GIMPLE function} unsigned gimple_num_ops (gimple g)
925Return the number of operands for statement @code{G}.
926@end deftypefn
927
928@deftypefn {GIMPLE function} {tree *} gimple_ops (gimple g)
929Return the array of operands for statement @code{G}.
930@end deftypefn
931
932@deftypefn {GIMPLE function} tree gimple_op (gimple g, unsigned i)
933Return operand @code{I} for statement @code{G}.
934@end deftypefn
935
936@deftypefn {GIMPLE function} {tree *} gimple_op_ptr (gimple g, unsigned i)
937Return a pointer to operand @code{I} for statement @code{G}.
938@end deftypefn
939
940@deftypefn {GIMPLE function} void gimple_set_op (gimple g, unsigned i, tree op)
941Set operand @code{I} of statement @code{G} to @code{OP}.
942@end deftypefn
943
944@deftypefn {GIMPLE function} bitmap gimple_addresses_taken (gimple stmt)
945Return the set of symbols that have had their address taken by
946@code{STMT}.
947@end deftypefn
948
949@deftypefn {GIMPLE function} {struct def_optype_d *} gimple_def_ops (gimple g)
950Return the set of @code{DEF} operands for statement @code{G}.
951@end deftypefn
952
953@deftypefn {GIMPLE function} void gimple_set_def_ops (gimple g, struct def_optype_d *def)
954Set @code{DEF} to be the set of @code{DEF} operands for statement @code{G}.
955@end deftypefn
956
957@deftypefn {GIMPLE function} {struct use_optype_d *} gimple_use_ops (gimple g)
958Return the set of @code{USE} operands for statement @code{G}.
959@end deftypefn
960
961@deftypefn {GIMPLE function} void gimple_set_use_ops (gimple g, struct use_optype_d *use)
962Set @code{USE} to be the set of @code{USE} operands for statement @code{G}.
963@end deftypefn
964
965@deftypefn {GIMPLE function} {struct voptype_d *} gimple_vuse_ops (gimple g)
966Return the set of @code{VUSE} operands for statement @code{G}.
967@end deftypefn
968
969@deftypefn {GIMPLE function} void gimple_set_vuse_ops (gimple g, struct voptype_d *ops)
970Set @code{OPS} to be the set of @code{VUSE} operands for statement @code{G}.
971@end deftypefn
972
973@deftypefn {GIMPLE function} {struct voptype_d *} gimple_vdef_ops (gimple g)
974Return the set of @code{VDEF} operands for statement @code{G}.
975@end deftypefn
976
977@deftypefn {GIMPLE function} void gimple_set_vdef_ops (gimple g, struct voptype_d *ops)
978Set @code{OPS} to be the set of @code{VDEF} operands for statement @code{G}.
979@end deftypefn
980
981@deftypefn {GIMPLE function} bitmap gimple_loaded_syms (gimple g)
982Return the set of symbols loaded by statement @code{G}. Each element of
983the set is the @code{DECL_UID} of the corresponding symbol.
984@end deftypefn
985
986@deftypefn {GIMPLE function} bitmap gimple_stored_syms (gimple g)
987Return the set of symbols stored by statement @code{G}. Each element of
988the set is the @code{DECL_UID} of the corresponding symbol.
989@end deftypefn
990
991@deftypefn {GIMPLE function} bool gimple_modified_p (gimple g)
992Return true if statement @code{G} has operands and the modified field
993has been set.
994@end deftypefn
995
996@deftypefn {GIMPLE function} bool gimple_has_volatile_ops (gimple stmt)
997Return true if statement @code{STMT} contains volatile operands.
998@end deftypefn
999
1000@deftypefn {GIMPLE function} void gimple_set_has_volatile_ops (gimple stmt, bool volatilep)
1001Return true if statement @code{STMT} contains volatile operands.
1002@end deftypefn
1003
1004@deftypefn {GIMPLE function} void update_stmt (gimple s)
1005Mark statement @code{S} as modified, and update it.
1006@end deftypefn
1007
1008@deftypefn {GIMPLE function} void update_stmt_if_modified (gimple s)
1009Update statement @code{S} if it has been marked modified.
1010@end deftypefn
1011
1012@deftypefn {GIMPLE function} gimple gimple_copy (gimple stmt)
1013Return a deep copy of statement @code{STMT}.
1014@end deftypefn
1015
1016@node Tuple specific accessors
1017@section Tuple specific accessors
1018@cindex Tuple specific accessors
1019
1020@menu
1021* @code{GIMPLE_ASM}::
1022* @code{GIMPLE_ASSIGN}::
1023* @code{GIMPLE_BIND}::
1024* @code{GIMPLE_CALL}::
1025* @code{GIMPLE_CATCH}::
1026* @code{GIMPLE_COND}::
1027* @code{GIMPLE_DEBUG}::
1028* @code{GIMPLE_EH_FILTER}::
1029* @code{GIMPLE_LABEL}::
1030* @code{GIMPLE_GOTO}::
1031* @code{GIMPLE_NOP}::
1032* @code{GIMPLE_OMP_ATOMIC_LOAD}::
1033* @code{GIMPLE_OMP_ATOMIC_STORE}::
1034* @code{GIMPLE_OMP_CONTINUE}::
1035* @code{GIMPLE_OMP_CRITICAL}::
1036* @code{GIMPLE_OMP_FOR}::
1037* @code{GIMPLE_OMP_MASTER}::
1038* @code{GIMPLE_OMP_ORDERED}::
1039* @code{GIMPLE_OMP_PARALLEL}::
1040* @code{GIMPLE_OMP_RETURN}::
1041* @code{GIMPLE_OMP_SECTION}::
1042* @code{GIMPLE_OMP_SECTIONS}::
1043* @code{GIMPLE_OMP_SINGLE}::
a62c8324 1044* @code{GIMPLE_OMP_STRUCTURED_BLOCK}::
d77de738
ML
1045* @code{GIMPLE_PHI}::
1046* @code{GIMPLE_RESX}::
1047* @code{GIMPLE_RETURN}::
1048* @code{GIMPLE_SWITCH}::
1049* @code{GIMPLE_TRY}::
1050* @code{GIMPLE_WITH_CLEANUP_EXPR}::
1051@end menu
1052
1053
1054@node @code{GIMPLE_ASM}
1055@subsection @code{GIMPLE_ASM}
1056@cindex @code{GIMPLE_ASM}
1057
1058@deftypefn {GIMPLE function} gasm *gimple_build_asm_vec ( @
1059const char *string, vec<tree, va_gc> *inputs, @
1060vec<tree, va_gc> *outputs, vec<tree, va_gc> *clobbers, @
1061vec<tree, va_gc> *labels)
1062Build a @code{GIMPLE_ASM} statement. This statement is used for
1063building in-line assembly constructs. @code{STRING} is the assembly
1064code. @code{INPUTS}, @code{OUTPUTS}, @code{CLOBBERS} and @code{LABELS}
1065are the inputs, outputs, clobbered registers and labels.
1066@end deftypefn
1067
1068@deftypefn {GIMPLE function} unsigned gimple_asm_ninputs (const gasm *g)
1069Return the number of input operands for @code{GIMPLE_ASM} @code{G}.
1070@end deftypefn
1071
1072@deftypefn {GIMPLE function} unsigned gimple_asm_noutputs (const gasm *g)
1073Return the number of output operands for @code{GIMPLE_ASM} @code{G}.
1074@end deftypefn
1075
1076@deftypefn {GIMPLE function} unsigned gimple_asm_nclobbers (const gasm *g)
1077Return the number of clobber operands for @code{GIMPLE_ASM} @code{G}.
1078@end deftypefn
1079
1080@deftypefn {GIMPLE function} tree gimple_asm_input_op (const gasm *g, @
1081unsigned index)
1082Return input operand @code{INDEX} of @code{GIMPLE_ASM} @code{G}.
1083@end deftypefn
1084
1085@deftypefn {GIMPLE function} void gimple_asm_set_input_op (gasm *g, @
1086unsigned index, tree in_op)
1087Set @code{IN_OP} to be input operand @code{INDEX} in @code{GIMPLE_ASM} @code{G}.
1088@end deftypefn
1089
1090@deftypefn {GIMPLE function} tree gimple_asm_output_op (const gasm *g, @
1091unsigned index)
1092Return output operand @code{INDEX} of @code{GIMPLE_ASM} @code{G}.
1093@end deftypefn
1094
1095@deftypefn {GIMPLE function} void gimple_asm_set_output_op (gasm *g, @
1096unsigned index, tree out_op)
1097Set @code{OUT_OP} to be output operand @code{INDEX} in @code{GIMPLE_ASM} @code{G}.
1098@end deftypefn
1099
1100@deftypefn {GIMPLE function} tree gimple_asm_clobber_op (const gasm *g, @
1101unsigned index)
1102Return clobber operand @code{INDEX} of @code{GIMPLE_ASM} @code{G}.
1103@end deftypefn
1104
1105@deftypefn {GIMPLE function} void gimple_asm_set_clobber_op (gasm *g, @
1106unsigned index, tree clobber_op)
1107Set @code{CLOBBER_OP} to be clobber operand @code{INDEX} in @code{GIMPLE_ASM} @code{G}.
1108@end deftypefn
1109
1110@deftypefn {GIMPLE function} {const char *} gimple_asm_string (const gasm *g)
1111Return the string representing the assembly instruction in
1112@code{GIMPLE_ASM} @code{G}.
1113@end deftypefn
1114
1115@deftypefn {GIMPLE function} bool gimple_asm_volatile_p (const gasm *g)
1116Return true if @code{G} is an asm statement marked volatile.
1117@end deftypefn
1118
1119@deftypefn {GIMPLE function} void gimple_asm_set_volatile (gasm *g, @
1120bool volatile_p)
1121Mark asm statement @code{G} as volatile or non-volatile based on
1122@code{VOLATILE_P}.
1123@end deftypefn
1124
1125@node @code{GIMPLE_ASSIGN}
1126@subsection @code{GIMPLE_ASSIGN}
1127@cindex @code{GIMPLE_ASSIGN}
1128
1129@deftypefn {GIMPLE function} gassign *gimple_build_assign (tree lhs, tree rhs)
1130Build a @code{GIMPLE_ASSIGN} statement. The left-hand side is an lvalue
1131passed in lhs. The right-hand side can be either a unary or
1132binary tree expression. The expression tree rhs will be
1133flattened and its operands assigned to the corresponding operand
1134slots in the new statement. This function is useful when you
1135already have a tree expression that you want to convert into a
1136tuple. However, try to avoid building expression trees for the
1137sole purpose of calling this function. If you already have the
1138operands in separate trees, it is better to use
1139@code{gimple_build_assign} with @code{enum tree_code} argument and separate
1140arguments for each operand.
1141@end deftypefn
1142
1143@deftypefn {GIMPLE function} gassign *gimple_build_assign @
1144(tree lhs, enum tree_code subcode, tree op1, tree op2, tree op3)
1145This function is similar to two operand @code{gimple_build_assign},
1146but is used to build a @code{GIMPLE_ASSIGN} statement when the operands of the
1147right-hand side of the assignment are already split into
1148different operands.
1149
1150The left-hand side is an lvalue passed in lhs. Subcode is the
1151@code{tree_code} for the right-hand side of the assignment. Op1, op2 and op3
1152are the operands.
1153@end deftypefn
1154
1155@deftypefn {GIMPLE function} gassign *gimple_build_assign @
1156(tree lhs, enum tree_code subcode, tree op1, tree op2)
1157Like the above 5 operand @code{gimple_build_assign}, but with the last
1158argument @code{NULL} - this overload should not be used for
1159@code{GIMPLE_TERNARY_RHS} assignments.
1160@end deftypefn
1161
1162@deftypefn {GIMPLE function} gassign *gimple_build_assign @
1163(tree lhs, enum tree_code subcode, tree op1)
1164Like the above 4 operand @code{gimple_build_assign}, but with the last
1165argument @code{NULL} - this overload should be used only for
1166@code{GIMPLE_UNARY_RHS} and @code{GIMPLE_SINGLE_RHS} assignments.
1167@end deftypefn
1168
1169@deftypefn {GIMPLE function} gimple gimplify_assign (tree dst, tree src, gimple_seq *seq_p)
1170Build a new @code{GIMPLE_ASSIGN} tuple and append it to the end of
1171@code{*SEQ_P}.
1172@end deftypefn
1173
1174@code{DST}/@code{SRC} are the destination and source respectively. You can
1175pass ungimplified trees in @code{DST} or @code{SRC}, in which
1176case they will be converted to a gimple operand if necessary.
1177
1178This function returns the newly created @code{GIMPLE_ASSIGN} tuple.
1179
1180@deftypefn {GIMPLE function} {enum tree_code} gimple_assign_rhs_code (gimple g)
1181Return the code of the expression computed on the @code{RHS} of
1182assignment statement @code{G}.
1183@end deftypefn
1184
1185
1186@deftypefn {GIMPLE function} {enum gimple_rhs_class} gimple_assign_rhs_class (gimple g)
1187Return the gimple rhs class of the code for the expression
1188computed on the rhs of assignment statement @code{G}. This will never
1189return @code{GIMPLE_INVALID_RHS}.
1190@end deftypefn
1191
1192@deftypefn {GIMPLE function} tree gimple_assign_lhs (gimple g)
1193Return the @code{LHS} of assignment statement @code{G}.
1194@end deftypefn
1195
1196@deftypefn {GIMPLE function} {tree *} gimple_assign_lhs_ptr (gimple g)
1197Return a pointer to the @code{LHS} of assignment statement @code{G}.
1198@end deftypefn
1199
1200@deftypefn {GIMPLE function} tree gimple_assign_rhs1 (gimple g)
1201Return the first operand on the @code{RHS} of assignment statement @code{G}.
1202@end deftypefn
1203
1204@deftypefn {GIMPLE function} {tree *} gimple_assign_rhs1_ptr (gimple g)
1205Return the address of the first operand on the @code{RHS} of assignment
1206statement @code{G}.
1207@end deftypefn
1208
1209@deftypefn {GIMPLE function} tree gimple_assign_rhs2 (gimple g)
1210Return the second operand on the @code{RHS} of assignment statement @code{G}.
1211@end deftypefn
1212
1213@deftypefn {GIMPLE function} {tree *} gimple_assign_rhs2_ptr (gimple g)
1214Return the address of the second operand on the @code{RHS} of assignment
1215statement @code{G}.
1216@end deftypefn
1217
1218@deftypefn {GIMPLE function} tree gimple_assign_rhs3 (gimple g)
1219Return the third operand on the @code{RHS} of assignment statement @code{G}.
1220@end deftypefn
1221
1222@deftypefn {GIMPLE function} {tree *} gimple_assign_rhs3_ptr (gimple g)
1223Return the address of the third operand on the @code{RHS} of assignment
1224statement @code{G}.
1225@end deftypefn
1226
1227@deftypefn {GIMPLE function} void gimple_assign_set_lhs (gimple g, tree lhs)
1228Set @code{LHS} to be the @code{LHS} operand of assignment statement @code{G}.
1229@end deftypefn
1230
1231@deftypefn {GIMPLE function} void gimple_assign_set_rhs1 (gimple g, tree rhs)
1232Set @code{RHS} to be the first operand on the @code{RHS} of assignment
1233statement @code{G}.
1234@end deftypefn
1235
1236@deftypefn {GIMPLE function} void gimple_assign_set_rhs2 (gimple g, tree rhs)
1237Set @code{RHS} to be the second operand on the @code{RHS} of assignment
1238statement @code{G}.
1239@end deftypefn
1240
1241@deftypefn {GIMPLE function} void gimple_assign_set_rhs3 (gimple g, tree rhs)
1242Set @code{RHS} to be the third operand on the @code{RHS} of assignment
1243statement @code{G}.
1244@end deftypefn
1245
1246@deftypefn {GIMPLE function} bool gimple_assign_cast_p (const_gimple s)
1247Return true if @code{S} is a type-cast assignment.
1248@end deftypefn
1249
1250
1251@node @code{GIMPLE_BIND}
1252@subsection @code{GIMPLE_BIND}
1253@cindex @code{GIMPLE_BIND}
1254
1255@deftypefn {GIMPLE function} gbind *gimple_build_bind (tree vars, @
1256gimple_seq body)
1257Build a @code{GIMPLE_BIND} statement with a list of variables in @code{VARS}
1258and a body of statements in sequence @code{BODY}.
1259@end deftypefn
1260
1261@deftypefn {GIMPLE function} tree gimple_bind_vars (const gbind *g)
1262Return the variables declared in the @code{GIMPLE_BIND} statement @code{G}.
1263@end deftypefn
1264
1265@deftypefn {GIMPLE function} void gimple_bind_set_vars (gbind *g, tree vars)
1266Set @code{VARS} to be the set of variables declared in the @code{GIMPLE_BIND}
1267statement @code{G}.
1268@end deftypefn
1269
1270@deftypefn {GIMPLE function} void gimple_bind_append_vars (gbind *g, tree vars)
1271Append @code{VARS} to the set of variables declared in the @code{GIMPLE_BIND}
1272statement @code{G}.
1273@end deftypefn
1274
1275@deftypefn {GIMPLE function} gimple_seq gimple_bind_body (gbind *g)
1276Return the GIMPLE sequence contained in the @code{GIMPLE_BIND} statement
1277@code{G}.
1278@end deftypefn
1279
1280@deftypefn {GIMPLE function} void gimple_bind_set_body (gbind *g, @
1281gimple_seq seq)
1282Set @code{SEQ} to be sequence contained in the @code{GIMPLE_BIND} statement @code{G}.
1283@end deftypefn
1284
1285@deftypefn {GIMPLE function} void gimple_bind_add_stmt (gbind *gs, gimple stmt)
1286Append a statement to the end of a @code{GIMPLE_BIND}'s body.
1287@end deftypefn
1288
1289@deftypefn {GIMPLE function} void gimple_bind_add_seq (gbind *gs, @
1290gimple_seq seq)
1291Append a sequence of statements to the end of a @code{GIMPLE_BIND}'s
1292body.
1293@end deftypefn
1294
1295@deftypefn {GIMPLE function} tree gimple_bind_block (const gbind *g)
1296Return the @code{TREE_BLOCK} node associated with @code{GIMPLE_BIND} statement
1297@code{G}. This is analogous to the @code{BIND_EXPR_BLOCK} field in trees.
1298@end deftypefn
1299
1300@deftypefn {GIMPLE function} void gimple_bind_set_block (gbind *g, tree block)
1301Set @code{BLOCK} to be the @code{TREE_BLOCK} node associated with @code{GIMPLE_BIND}
1302statement @code{G}.
1303@end deftypefn
1304
1305
1306@node @code{GIMPLE_CALL}
1307@subsection @code{GIMPLE_CALL}
1308@cindex @code{GIMPLE_CALL}
1309
1310@deftypefn {GIMPLE function} gcall *gimple_build_call (tree fn, @
1311unsigned nargs, ...)
1312Build a @code{GIMPLE_CALL} statement to function @code{FN}. The argument @code{FN}
1313must be either a @code{FUNCTION_DECL} or a gimple call address as
1314determined by @code{is_gimple_call_addr}. @code{NARGS} are the number of
1315arguments. The rest of the arguments follow the argument @code{NARGS},
1316and must be trees that are valid as rvalues in gimple (i.e., each
1317operand is validated with @code{is_gimple_operand}).
1318@end deftypefn
1319
1320
1321@deftypefn {GIMPLE function} gcall *gimple_build_call_from_tree (tree call_expr, @
1322tree fnptrtype)
1323Build a @code{GIMPLE_CALL} from a @code{CALL_EXPR} node. The arguments
1324and the function are taken from the expression directly. The type of the
1325@code{GIMPLE_CALL} is set from the second parameter passed by a caller.
1326This routine assumes that @code{call_expr} is already in GIMPLE form.
1327That is, its operands are GIMPLE values and the function call needs no further
1328simplification. All the call flags in @code{call_expr} are copied over
1329to the new @code{GIMPLE_CALL}.
1330@end deftypefn
1331
1332@deftypefn {GIMPLE function} gcall *gimple_build_call_vec (tree fn, @
1333@code{vec<tree>} args)
1334Identical to @code{gimple_build_call} but the arguments are stored in a
1335@code{vec<tree>}.
1336@end deftypefn
1337
1338@deftypefn {GIMPLE function} tree gimple_call_lhs (gimple g)
1339Return the @code{LHS} of call statement @code{G}.
1340@end deftypefn
1341
1342@deftypefn {GIMPLE function} {tree *} gimple_call_lhs_ptr (gimple g)
1343Return a pointer to the @code{LHS} of call statement @code{G}.
1344@end deftypefn
1345
1346@deftypefn {GIMPLE function} void gimple_call_set_lhs (gimple g, tree lhs)
1347Set @code{LHS} to be the @code{LHS} operand of call statement @code{G}.
1348@end deftypefn
1349
1350@deftypefn {GIMPLE function} tree gimple_call_fn (gimple g)
1351Return the tree node representing the function called by call
1352statement @code{G}.
1353@end deftypefn
1354
1355@deftypefn {GIMPLE function} void gimple_call_set_fn (gcall *g, tree fn)
1356Set @code{FN} to be the function called by call statement @code{G}. This has
1357to be a gimple value specifying the address of the called
1358function.
1359@end deftypefn
1360
1361@deftypefn {GIMPLE function} tree gimple_call_fndecl (gimple g)
1362If a given @code{GIMPLE_CALL}'s callee is a @code{FUNCTION_DECL}, return it.
1363Otherwise return @code{NULL}. This function is analogous to
1364@code{get_callee_fndecl} in @code{GENERIC}.
1365@end deftypefn
1366
1367@deftypefn {GIMPLE function} tree gimple_call_set_fndecl (gimple g, tree fndecl)
1368Set the called function to @code{FNDECL}.
1369@end deftypefn
1370
1371@deftypefn {GIMPLE function} tree gimple_call_return_type (const gcall *g)
1372Return the type returned by call statement @code{G}.
1373@end deftypefn
1374
1375@deftypefn {GIMPLE function} tree gimple_call_chain (gimple g)
1376Return the static chain for call statement @code{G}.
1377@end deftypefn
1378
1379@deftypefn {GIMPLE function} void gimple_call_set_chain (gcall *g, tree chain)
1380Set @code{CHAIN} to be the static chain for call statement @code{G}.
1381@end deftypefn
1382
1383@deftypefn {GIMPLE function} unsigned gimple_call_num_args (gimple g)
1384Return the number of arguments used by call statement @code{G}.
1385@end deftypefn
1386
1387@deftypefn {GIMPLE function} tree gimple_call_arg (gimple g, unsigned index)
1388Return the argument at position @code{INDEX} for call statement @code{G}. The
1389first argument is 0.
1390@end deftypefn
1391
1392@deftypefn {GIMPLE function} {tree *} gimple_call_arg_ptr (gimple g, unsigned index)
1393Return a pointer to the argument at position @code{INDEX} for call
1394statement @code{G}.
1395@end deftypefn
1396
1397@deftypefn {GIMPLE function} void gimple_call_set_arg (gimple g, unsigned index, tree arg)
1398Set @code{ARG} to be the argument at position @code{INDEX} for call statement
1399@code{G}.
1400@end deftypefn
1401
1402@deftypefn {GIMPLE function} void gimple_call_set_tail (gcall *s)
1403Mark call statement @code{S} as being a tail call (i.e., a call just
1404before the exit of a function). These calls are candidate for
1405tail call optimization.
1406@end deftypefn
1407
1408@deftypefn {GIMPLE function} bool gimple_call_tail_p (gcall *s)
1409Return true if @code{GIMPLE_CALL} @code{S} is marked as a tail call.
1410@end deftypefn
1411
1412@deftypefn {GIMPLE function} bool gimple_call_noreturn_p (gimple s)
1413Return true if @code{S} is a noreturn call.
1414@end deftypefn
1415
1416@deftypefn {GIMPLE function} gimple gimple_call_copy_skip_args (gcall *stmt, @
1417bitmap args_to_skip)
1418Build a @code{GIMPLE_CALL} identical to @code{STMT} but skipping the arguments
1419in the positions marked by the set @code{ARGS_TO_SKIP}.
1420@end deftypefn
1421
1422
1423@node @code{GIMPLE_CATCH}
1424@subsection @code{GIMPLE_CATCH}
1425@cindex @code{GIMPLE_CATCH}
1426
1427@deftypefn {GIMPLE function} gcatch *gimple_build_catch (tree types, @
1428gimple_seq handler)
1429Build a @code{GIMPLE_CATCH} statement. @code{TYPES} are the tree types this
1430catch handles. @code{HANDLER} is a sequence of statements with the code
1431for the handler.
1432@end deftypefn
1433
1434@deftypefn {GIMPLE function} tree gimple_catch_types (const gcatch *g)
1435Return the types handled by @code{GIMPLE_CATCH} statement @code{G}.
1436@end deftypefn
1437
1438@deftypefn {GIMPLE function} {tree *} gimple_catch_types_ptr (gcatch *g)
1439Return a pointer to the types handled by @code{GIMPLE_CATCH} statement
1440@code{G}.
1441@end deftypefn
1442
1443@deftypefn {GIMPLE function} gimple_seq gimple_catch_handler (gcatch *g)
1444Return the GIMPLE sequence representing the body of the handler
1445of @code{GIMPLE_CATCH} statement @code{G}.
1446@end deftypefn
1447
1448@deftypefn {GIMPLE function} void gimple_catch_set_types (gcatch *g, tree t)
1449Set @code{T} to be the set of types handled by @code{GIMPLE_CATCH} @code{G}.
1450@end deftypefn
1451
1452@deftypefn {GIMPLE function} void gimple_catch_set_handler (gcatch *g, @
1453gimple_seq handler)
1454Set @code{HANDLER} to be the body of @code{GIMPLE_CATCH} @code{G}.
1455@end deftypefn
1456
1457
1458@node @code{GIMPLE_COND}
1459@subsection @code{GIMPLE_COND}
1460@cindex @code{GIMPLE_COND}
1461
1462@deftypefn {GIMPLE function} gcond *gimple_build_cond ( @
1463enum tree_code pred_code, tree lhs, tree rhs, tree t_label, tree f_label)
1464Build a @code{GIMPLE_COND} statement. @code{A} @code{GIMPLE_COND} statement compares
1465@code{LHS} and @code{RHS} and if the condition in @code{PRED_CODE} is true, jump to
1466the label in @code{t_label}, otherwise jump to the label in @code{f_label}.
1467@code{PRED_CODE} are relational operator tree codes like @code{EQ_EXPR},
1468@code{LT_EXPR}, @code{LE_EXPR}, @code{NE_EXPR}, etc.
1469@end deftypefn
1470
1471
1472@deftypefn {GIMPLE function} gcond *gimple_build_cond_from_tree (tree cond, @
1473tree t_label, tree f_label)
1474Build a @code{GIMPLE_COND} statement from the conditional expression
1475tree @code{COND}. @code{T_LABEL} and @code{F_LABEL} are as in @code{gimple_build_cond}.
1476@end deftypefn
1477
1478@deftypefn {GIMPLE function} {enum tree_code} gimple_cond_code (gimple g)
1479Return the code of the predicate computed by conditional
1480statement @code{G}.
1481@end deftypefn
1482
1483@deftypefn {GIMPLE function} void gimple_cond_set_code (gcond *g, @
1484enum tree_code code)
1485Set @code{CODE} to be the predicate code for the conditional statement
1486@code{G}.
1487@end deftypefn
1488
1489@deftypefn {GIMPLE function} tree gimple_cond_lhs (gimple g)
1490Return the @code{LHS} of the predicate computed by conditional statement
1491@code{G}.
1492@end deftypefn
1493
1494@deftypefn {GIMPLE function} void gimple_cond_set_lhs (gcond *g, tree lhs)
1495Set @code{LHS} to be the @code{LHS} operand of the predicate computed by
1496conditional statement @code{G}.
1497@end deftypefn
1498
1499@deftypefn {GIMPLE function} tree gimple_cond_rhs (gimple g)
1500Return the @code{RHS} operand of the predicate computed by conditional
1501@code{G}.
1502@end deftypefn
1503
1504@deftypefn {GIMPLE function} void gimple_cond_set_rhs (gcond *g, tree rhs)
1505Set @code{RHS} to be the @code{RHS} operand of the predicate computed by
1506conditional statement @code{G}.
1507@end deftypefn
1508
1509@deftypefn {GIMPLE function} tree gimple_cond_true_label (const gcond *g)
1510Return the label used by conditional statement @code{G} when its
1511predicate evaluates to true.
1512@end deftypefn
1513
1514@deftypefn {GIMPLE function} void gimple_cond_set_true_label (gcond *g, tree label)
1515Set @code{LABEL} to be the label used by conditional statement @code{G} when
1516its predicate evaluates to true.
1517@end deftypefn
1518
1519@deftypefn {GIMPLE function} void gimple_cond_set_false_label (gcond *g, tree label)
1520Set @code{LABEL} to be the label used by conditional statement @code{G} when
1521its predicate evaluates to false.
1522@end deftypefn
1523
1524@deftypefn {GIMPLE function} tree gimple_cond_false_label (const gcond *g)
1525Return the label used by conditional statement @code{G} when its
1526predicate evaluates to false.
1527@end deftypefn
1528
1529@deftypefn {GIMPLE function} void gimple_cond_make_false (gcond *g)
1530Set the conditional @code{COND_STMT} to be of the form 'if (1 == 0)'.
1531@end deftypefn
1532
1533@deftypefn {GIMPLE function} void gimple_cond_make_true (gcond *g)
1534Set the conditional @code{COND_STMT} to be of the form 'if (1 == 1)'.
1535@end deftypefn
1536
1537@node @code{GIMPLE_DEBUG}
1538@subsection @code{GIMPLE_DEBUG}
1539@cindex @code{GIMPLE_DEBUG}
1540@cindex @code{GIMPLE_DEBUG_BIND}
1541@cindex @code{GIMPLE_DEBUG_BEGIN_STMT}
1542@cindex @code{GIMPLE_DEBUG_INLINE_ENTRY}
1543
1544@deftypefn {GIMPLE function} gdebug *gimple_build_debug_bind (tree var, @
1545tree value, gimple stmt)
1546Build a @code{GIMPLE_DEBUG} statement with @code{GIMPLE_DEBUG_BIND}
1547@code{subcode}. The effect of this statement is to tell debug
1548information generation machinery that the value of user variable
1549@code{var} is given by @code{value} at that point, and to remain with
1550that value until @code{var} runs out of scope, a
1551dynamically-subsequent debug bind statement overrides the binding, or
1552conflicting values reach a control flow merge point. Even if
1553components of the @code{value} expression change afterwards, the
1554variable is supposed to retain the same value, though not necessarily
1555the same location.
1556
1557It is expected that @code{var} be most often a tree for automatic user
1558variables (@code{VAR_DECL} or @code{PARM_DECL}) that satisfy the
1559requirements for gimple registers, but it may also be a tree for a
1560scalarized component of a user variable (@code{ARRAY_REF},
1561@code{COMPONENT_REF}), or a debug temporary (@code{DEBUG_EXPR_DECL}).
1562
1563As for @code{value}, it can be an arbitrary tree expression, but it is
1564recommended that it be in a suitable form for a gimple assignment
1565@code{RHS}. It is not expected that user variables that could appear
1566as @code{var} ever appear in @code{value}, because in the latter we'd
1567have their @code{SSA_NAME}s instead, but even if they were not in SSA
1568form, user variables appearing in @code{value} are to be regarded as
1569part of the executable code space, whereas those in @code{var} are to
1570be regarded as part of the source code space. There is no way to
1571refer to the value bound to a user variable within a @code{value}
1572expression.
1573
1574If @code{value} is @code{GIMPLE_DEBUG_BIND_NOVALUE}, debug information
1575generation machinery is informed that the variable @code{var} is
1576unbound, i.e., that its value is indeterminate, which sometimes means
1577it is really unavailable, and other times that the compiler could not
1578keep track of it.
1579
1580Block and location information for the newly-created stmt are
1581taken from @code{stmt}, if given.
1582@end deftypefn
1583
1584@deftypefn {GIMPLE function} tree gimple_debug_bind_get_var (gimple stmt)
1585Return the user variable @var{var} that is bound at @code{stmt}.
1586@end deftypefn
1587
1588@deftypefn {GIMPLE function} tree gimple_debug_bind_get_value (gimple stmt)
1589Return the value expression that is bound to a user variable at
1590@code{stmt}.
1591@end deftypefn
1592
1593@deftypefn {GIMPLE function} {tree *} gimple_debug_bind_get_value_ptr (gimple stmt)
1594Return a pointer to the value expression that is bound to a user
1595variable at @code{stmt}.
1596@end deftypefn
1597
1598@deftypefn {GIMPLE function} void gimple_debug_bind_set_var (gimple stmt, tree var)
1599Modify the user variable bound at @code{stmt} to @var{var}.
1600@end deftypefn
1601
1602@deftypefn {GIMPLE function} void gimple_debug_bind_set_value (gimple stmt, tree var)
1603Modify the value bound to the user variable bound at @code{stmt} to
1604@var{value}.
1605@end deftypefn
1606
1607@deftypefn {GIMPLE function} void gimple_debug_bind_reset_value (gimple stmt)
1608Modify the value bound to the user variable bound at @code{stmt} so
1609that the variable becomes unbound.
1610@end deftypefn
1611
1612@deftypefn {GIMPLE function} bool gimple_debug_bind_has_value_p (gimple stmt)
1613Return @code{TRUE} if @code{stmt} binds a user variable to a value,
1614and @code{FALSE} if it unbinds the variable.
1615@end deftypefn
1616
1617@deftypefn {GIMPLE function} gimple gimple_build_debug_begin_stmt (tree block, location_t location)
1618Build a @code{GIMPLE_DEBUG} statement with
1619@code{GIMPLE_DEBUG_BEGIN_STMT} @code{subcode}. The effect of this
1620statement is to tell debug information generation machinery that the
1621user statement at the given @code{location} and @code{block} starts at
1622the point at which the statement is inserted. The intent is that side
1623effects (e.g.@: variable bindings) of all prior user statements are
1624observable, and that none of the side effects of subsequent user
1625statements are.
1626@end deftypefn
1627
1628@deftypefn {GIMPLE function} gimple gimple_build_debug_inline_entry (tree block, location_t location)
1629Build a @code{GIMPLE_DEBUG} statement with
1630@code{GIMPLE_DEBUG_INLINE_ENTRY} @code{subcode}. The effect of this
1631statement is to tell debug information generation machinery that a
1632function call at @code{location} underwent inline substitution, that
1633@code{block} is the enclosing lexical block created for the
1634substitution, and that at the point of the program in which the stmt is
1635inserted, all parameters for the inlined function are bound to the
1636respective arguments, and none of the side effects of its stmts are
1637observable.
1638@end deftypefn
1639
1640@node @code{GIMPLE_EH_FILTER}
1641@subsection @code{GIMPLE_EH_FILTER}
1642@cindex @code{GIMPLE_EH_FILTER}
1643
1644@deftypefn {GIMPLE function} geh_filter *gimple_build_eh_filter (tree types, @
1645gimple_seq failure)
1646Build a @code{GIMPLE_EH_FILTER} statement. @code{TYPES} are the filter's
1647types. @code{FAILURE} is a sequence with the filter's failure action.
1648@end deftypefn
1649
1650@deftypefn {GIMPLE function} tree gimple_eh_filter_types (gimple g)
1651Return the types handled by @code{GIMPLE_EH_FILTER} statement @code{G}.
1652@end deftypefn
1653
1654@deftypefn {GIMPLE function} {tree *} gimple_eh_filter_types_ptr (gimple g)
1655Return a pointer to the types handled by @code{GIMPLE_EH_FILTER}
1656statement @code{G}.
1657@end deftypefn
1658
1659@deftypefn {GIMPLE function} gimple_seq gimple_eh_filter_failure (gimple g)
1660Return the sequence of statement to execute when @code{GIMPLE_EH_FILTER}
1661statement fails.
1662@end deftypefn
1663
1664@deftypefn {GIMPLE function} void gimple_eh_filter_set_types (geh_filter *g, @
1665tree types)
1666Set @code{TYPES} to be the set of types handled by @code{GIMPLE_EH_FILTER} @code{G}.
1667@end deftypefn
1668
1669@deftypefn {GIMPLE function} void gimple_eh_filter_set_failure (geh_filter *g, @
1670gimple_seq failure)
1671Set @code{FAILURE} to be the sequence of statements to execute on
1672failure for @code{GIMPLE_EH_FILTER} @code{G}.
1673@end deftypefn
1674
1675@deftypefn {GIMPLE function} tree gimple_eh_must_not_throw_fndecl ( @
1676geh_mnt *eh_mnt_stmt)
1677Get the function decl to be called by the MUST_NOT_THROW region.
1678@end deftypefn
1679
1680@deftypefn {GIMPLE function} void gimple_eh_must_not_throw_set_fndecl ( @
1681geh_mnt *eh_mnt_stmt, tree decl)
1682Set the function decl to be called by GS to DECL.
1683@end deftypefn
1684
1685
1686@node @code{GIMPLE_LABEL}
1687@subsection @code{GIMPLE_LABEL}
1688@cindex @code{GIMPLE_LABEL}
1689
1690@deftypefn {GIMPLE function} glabel *gimple_build_label (tree label)
1691Build a @code{GIMPLE_LABEL} statement with corresponding to the tree
1692label, @code{LABEL}.
1693@end deftypefn
1694
1695@deftypefn {GIMPLE function} tree gimple_label_label (const glabel *g)
1696Return the @code{LABEL_DECL} node used by @code{GIMPLE_LABEL} statement @code{G}.
1697@end deftypefn
1698
1699@deftypefn {GIMPLE function} void gimple_label_set_label (glabel *g, tree label)
1700Set @code{LABEL} to be the @code{LABEL_DECL} node used by @code{GIMPLE_LABEL}
1701statement @code{G}.
1702@end deftypefn
1703
1704@node @code{GIMPLE_GOTO}
1705@subsection @code{GIMPLE_GOTO}
1706@cindex @code{GIMPLE_GOTO}
1707
1708@deftypefn {GIMPLE function} ggoto *gimple_build_goto (tree dest)
1709Build a @code{GIMPLE_GOTO} statement to label @code{DEST}.
1710@end deftypefn
1711
1712@deftypefn {GIMPLE function} tree gimple_goto_dest (gimple g)
1713Return the destination of the unconditional jump @code{G}.
1714@end deftypefn
1715
1716@deftypefn {GIMPLE function} void gimple_goto_set_dest (ggoto *g, tree dest)
1717Set @code{DEST} to be the destination of the unconditional jump @code{G}.
1718@end deftypefn
1719
1720
1721@node @code{GIMPLE_NOP}
1722@subsection @code{GIMPLE_NOP}
1723@cindex @code{GIMPLE_NOP}
1724
1725@deftypefn {GIMPLE function} gimple gimple_build_nop (void)
1726Build a @code{GIMPLE_NOP} statement.
1727@end deftypefn
1728
1729@deftypefn {GIMPLE function} bool gimple_nop_p (gimple g)
1730Returns @code{TRUE} if statement @code{G} is a @code{GIMPLE_NOP}.
1731@end deftypefn
1732
1733@node @code{GIMPLE_OMP_ATOMIC_LOAD}
1734@subsection @code{GIMPLE_OMP_ATOMIC_LOAD}
1735@cindex @code{GIMPLE_OMP_ATOMIC_LOAD}
1736
1737@deftypefn {GIMPLE function} gomp_atomic_load *gimple_build_omp_atomic_load ( @
1738tree lhs, tree rhs)
1739Build a @code{GIMPLE_OMP_ATOMIC_LOAD} statement. @code{LHS} is the left-hand
1740side of the assignment. @code{RHS} is the right-hand side of the
1741assignment.
1742@end deftypefn
1743
1744@deftypefn {GIMPLE function} void gimple_omp_atomic_load_set_lhs ( @
1745gomp_atomic_load *g, tree lhs)
1746Set the @code{LHS} of an atomic load.
1747@end deftypefn
1748
1749@deftypefn {GIMPLE function} tree gimple_omp_atomic_load_lhs ( @
1750const gomp_atomic_load *g)
1751Get the @code{LHS} of an atomic load.
1752@end deftypefn
1753
1754@deftypefn {GIMPLE function} void gimple_omp_atomic_load_set_rhs ( @
1755gomp_atomic_load *g, tree rhs)
1756Set the @code{RHS} of an atomic set.
1757@end deftypefn
1758
1759@deftypefn {GIMPLE function} tree gimple_omp_atomic_load_rhs ( @
1760const gomp_atomic_load *g)
1761Get the @code{RHS} of an atomic set.
1762@end deftypefn
1763
1764
1765@node @code{GIMPLE_OMP_ATOMIC_STORE}
1766@subsection @code{GIMPLE_OMP_ATOMIC_STORE}
1767@cindex @code{GIMPLE_OMP_ATOMIC_STORE}
1768
1769@deftypefn {GIMPLE function} gomp_atomic_store *gimple_build_omp_atomic_store ( @
1770tree val)
1771Build a @code{GIMPLE_OMP_ATOMIC_STORE} statement. @code{VAL} is the value to be
1772stored.
1773@end deftypefn
1774
1775@deftypefn {GIMPLE function} void gimple_omp_atomic_store_set_val ( @
1776gomp_atomic_store *g, tree val)
1777Set the value being stored in an atomic store.
1778@end deftypefn
1779
1780@deftypefn {GIMPLE function} tree gimple_omp_atomic_store_val ( @
1781const gomp_atomic_store *g)
1782Return the value being stored in an atomic store.
1783@end deftypefn
1784
1785@node @code{GIMPLE_OMP_CONTINUE}
1786@subsection @code{GIMPLE_OMP_CONTINUE}
1787@cindex @code{GIMPLE_OMP_CONTINUE}
1788
1789@deftypefn {GIMPLE function} gomp_continue *gimple_build_omp_continue ( @
1790tree control_def, tree control_use)
1791Build a @code{GIMPLE_OMP_CONTINUE} statement. @code{CONTROL_DEF} is the
1792definition of the control variable. @code{CONTROL_USE} is the use of
1793the control variable.
1794@end deftypefn
1795
1796@deftypefn {GIMPLE function} tree gimple_omp_continue_control_def ( @
1797const gomp_continue *s)
1798Return the definition of the control variable on a
1799@code{GIMPLE_OMP_CONTINUE} in @code{S}.
1800@end deftypefn
1801
1802@deftypefn {GIMPLE function} tree gimple_omp_continue_control_def_ptr ( @
1803gomp_continue *s)
1804Same as above, but return the pointer.
1805@end deftypefn
1806
1807@deftypefn {GIMPLE function} tree gimple_omp_continue_set_control_def ( @
1808gomp_continue *s)
1809Set the control variable definition for a @code{GIMPLE_OMP_CONTINUE}
1810statement in @code{S}.
1811@end deftypefn
1812
1813@deftypefn {GIMPLE function} tree gimple_omp_continue_control_use ( @
1814const gomp_continue *s)
1815Return the use of the control variable on a @code{GIMPLE_OMP_CONTINUE}
1816in @code{S}.
1817@end deftypefn
1818
1819@deftypefn {GIMPLE function} tree gimple_omp_continue_control_use_ptr ( @
1820gomp_continue *s)
1821Same as above, but return the pointer.
1822@end deftypefn
1823
1824@deftypefn {GIMPLE function} tree gimple_omp_continue_set_control_use ( @
1825gomp_continue *s)
1826Set the control variable use for a @code{GIMPLE_OMP_CONTINUE} statement
1827in @code{S}.
1828@end deftypefn
1829
1830
1831@node @code{GIMPLE_OMP_CRITICAL}
1832@subsection @code{GIMPLE_OMP_CRITICAL}
1833@cindex @code{GIMPLE_OMP_CRITICAL}
1834
1835@deftypefn {GIMPLE function} gomp_critical *gimple_build_omp_critical ( @
1836gimple_seq body, tree name)
1837Build a @code{GIMPLE_OMP_CRITICAL} statement. @code{BODY} is the sequence of
1838statements for which only one thread can execute. @code{NAME} is an
1839optional identifier for this critical block.
1840@end deftypefn
1841
1842@deftypefn {GIMPLE function} tree gimple_omp_critical_name ( @
1843const gomp_critical *g)
1844Return the name associated with @code{OMP_CRITICAL} statement @code{G}.
1845@end deftypefn
1846
1847@deftypefn {GIMPLE function} {tree *} gimple_omp_critical_name_ptr ( @
1848gomp_critical *g)
1849Return a pointer to the name associated with @code{OMP} critical
1850statement @code{G}.
1851@end deftypefn
1852
1853@deftypefn {GIMPLE function} void gimple_omp_critical_set_name ( @
1854gomp_critical *g, tree name)
1855Set @code{NAME} to be the name associated with @code{OMP} critical statement @code{G}.
1856@end deftypefn
1857
1858@node @code{GIMPLE_OMP_FOR}
1859@subsection @code{GIMPLE_OMP_FOR}
1860@cindex @code{GIMPLE_OMP_FOR}
1861
1862@deftypefn {GIMPLE function} gomp_for *gimple_build_omp_for (gimple_seq body, @
1863tree clauses, tree index, tree initial, tree final, tree incr, @
1864gimple_seq pre_body, enum tree_code omp_for_cond)
1865Build a @code{GIMPLE_OMP_FOR} statement. @code{BODY} is sequence of statements
1866inside the for loop. @code{CLAUSES}, are any of the loop
1867construct's clauses. @code{PRE_BODY} is the
1868sequence of statements that are loop invariant. @code{INDEX} is the
1869index variable. @code{INITIAL} is the initial value of @code{INDEX}. @code{FINAL} is
1870final value of @code{INDEX}. OMP_FOR_COND is the predicate used to
1871compare @code{INDEX} and @code{FINAL}. @code{INCR} is the increment expression.
1872@end deftypefn
1873
1874@deftypefn {GIMPLE function} tree gimple_omp_for_clauses (gimple g)
1875Return the clauses associated with @code{OMP_FOR} @code{G}.
1876@end deftypefn
1877
1878@deftypefn {GIMPLE function} {tree *} gimple_omp_for_clauses_ptr (gimple g)
1879Return a pointer to the @code{OMP_FOR} @code{G}.
1880@end deftypefn
1881
1882@deftypefn {GIMPLE function} void gimple_omp_for_set_clauses (gimple g, tree clauses)
1883Set @code{CLAUSES} to be the list of clauses associated with @code{OMP_FOR} @code{G}.
1884@end deftypefn
1885
1886@deftypefn {GIMPLE function} tree gimple_omp_for_index (gimple g)
1887Return the index variable for @code{OMP_FOR} @code{G}.
1888@end deftypefn
1889
1890@deftypefn {GIMPLE function} {tree *} gimple_omp_for_index_ptr (gimple g)
1891Return a pointer to the index variable for @code{OMP_FOR} @code{G}.
1892@end deftypefn
1893
1894@deftypefn {GIMPLE function} void gimple_omp_for_set_index (gimple g, tree index)
1895Set @code{INDEX} to be the index variable for @code{OMP_FOR} @code{G}.
1896@end deftypefn
1897
1898@deftypefn {GIMPLE function} tree gimple_omp_for_initial (gimple g)
1899Return the initial value for @code{OMP_FOR} @code{G}.
1900@end deftypefn
1901
1902@deftypefn {GIMPLE function} {tree *} gimple_omp_for_initial_ptr (gimple g)
1903Return a pointer to the initial value for @code{OMP_FOR} @code{G}.
1904@end deftypefn
1905
1906@deftypefn {GIMPLE function} void gimple_omp_for_set_initial (gimple g, tree initial)
1907Set @code{INITIAL} to be the initial value for @code{OMP_FOR} @code{G}.
1908@end deftypefn
1909
1910@deftypefn {GIMPLE function} tree gimple_omp_for_final (gimple g)
1911Return the final value for @code{OMP_FOR} @code{G}.
1912@end deftypefn
1913
1914@deftypefn {GIMPLE function} {tree *} gimple_omp_for_final_ptr (gimple g)
1915turn a pointer to the final value for @code{OMP_FOR} @code{G}.
1916@end deftypefn
1917
1918@deftypefn {GIMPLE function} void gimple_omp_for_set_final (gimple g, tree final)
1919Set @code{FINAL} to be the final value for @code{OMP_FOR} @code{G}.
1920@end deftypefn
1921
1922@deftypefn {GIMPLE function} tree gimple_omp_for_incr (gimple g)
1923Return the increment value for @code{OMP_FOR} @code{G}.
1924@end deftypefn
1925
1926@deftypefn {GIMPLE function} {tree *} gimple_omp_for_incr_ptr (gimple g)
1927Return a pointer to the increment value for @code{OMP_FOR} @code{G}.
1928@end deftypefn
1929
1930@deftypefn {GIMPLE function} void gimple_omp_for_set_incr (gimple g, tree incr)
1931Set @code{INCR} to be the increment value for @code{OMP_FOR} @code{G}.
1932@end deftypefn
1933
1934@deftypefn {GIMPLE function} gimple_seq gimple_omp_for_pre_body (gimple g)
1935Return the sequence of statements to execute before the @code{OMP_FOR}
1936statement @code{G} starts.
1937@end deftypefn
1938
1939@deftypefn {GIMPLE function} void gimple_omp_for_set_pre_body (gimple g, gimple_seq pre_body)
1940Set @code{PRE_BODY} to be the sequence of statements to execute before
1941the @code{OMP_FOR} statement @code{G} starts.
1942@end deftypefn
1943
1944@deftypefn {GIMPLE function} void gimple_omp_for_set_cond (gimple g, enum tree_code cond)
1945Set @code{COND} to be the condition code for @code{OMP_FOR} @code{G}.
1946@end deftypefn
1947
1948@deftypefn {GIMPLE function} {enum tree_code} gimple_omp_for_cond (gimple g)
1949Return the condition code associated with @code{OMP_FOR} @code{G}.
1950@end deftypefn
1951
1952
1953@node @code{GIMPLE_OMP_MASTER}
1954@subsection @code{GIMPLE_OMP_MASTER}
1955@cindex @code{GIMPLE_OMP_MASTER}
1956
1957@deftypefn {GIMPLE function} gimple gimple_build_omp_master (gimple_seq body)
1958Build a @code{GIMPLE_OMP_MASTER} statement. @code{BODY} is the sequence of
1959statements to be executed by just the master.
1960@end deftypefn
1961
1962
1963@node @code{GIMPLE_OMP_ORDERED}
1964@subsection @code{GIMPLE_OMP_ORDERED}
1965@cindex @code{GIMPLE_OMP_ORDERED}
1966
1967@deftypefn {GIMPLE function} gimple gimple_build_omp_ordered (gimple_seq body)
1968Build a @code{GIMPLE_OMP_ORDERED} statement.
1969
1970@code{BODY} is the sequence of statements inside a loop that will
1971executed in sequence.
1972@end deftypefn
1973
1974@node @code{GIMPLE_OMP_PARALLEL}
1975@subsection @code{GIMPLE_OMP_PARALLEL}
1976@cindex @code{GIMPLE_OMP_PARALLEL}
1977
1978@deftypefn {GIMPLE function} gomp_parallel *gimple_build_omp_parallel (@
1979gimple_seq body, tree clauses, tree child_fn, tree data_arg)
1980Build a @code{GIMPLE_OMP_PARALLEL} statement.
1981
1982@code{BODY} is sequence of statements which are executed in parallel.
1983@code{CLAUSES}, are the @code{OMP} parallel construct's clauses. @code{CHILD_FN} is
1984the function created for the parallel threads to execute.
1985@code{DATA_ARG} are the shared data argument(s).
1986@end deftypefn
1987
1988@deftypefn {GIMPLE function} bool gimple_omp_parallel_combined_p (gimple g)
1989Return true if @code{OMP} parallel statement @code{G} has the
1990@code{GF_OMP_PARALLEL_COMBINED} flag set.
1991@end deftypefn
1992
1993@deftypefn {GIMPLE function} void gimple_omp_parallel_set_combined_p (gimple g)
1994Set the @code{GF_OMP_PARALLEL_COMBINED} field in @code{OMP} parallel statement
1995@code{G}.
1996@end deftypefn
1997
1998@deftypefn {GIMPLE function} gimple_seq gimple_omp_body (gimple g)
1999Return the body for the @code{OMP} statement @code{G}.
2000@end deftypefn
2001
2002@deftypefn {GIMPLE function} void gimple_omp_set_body (gimple g, gimple_seq body)
2003Set @code{BODY} to be the body for the @code{OMP} statement @code{G}.
2004@end deftypefn
2005
2006@deftypefn {GIMPLE function} tree gimple_omp_parallel_clauses (gimple g)
2007Return the clauses associated with @code{OMP_PARALLEL} @code{G}.
2008@end deftypefn
2009
2010@deftypefn {GIMPLE function} {tree *} gimple_omp_parallel_clauses_ptr ( @
2011gomp_parallel *g)
2012Return a pointer to the clauses associated with @code{OMP_PARALLEL} @code{G}.
2013@end deftypefn
2014
2015@deftypefn {GIMPLE function} void gimple_omp_parallel_set_clauses ( @
2016gomp_parallel *g, tree clauses)
2017Set @code{CLAUSES} to be the list of clauses associated with
2018@code{OMP_PARALLEL} @code{G}.
2019@end deftypefn
2020
2021@deftypefn {GIMPLE function} tree gimple_omp_parallel_child_fn ( @
2022const gomp_parallel *g)
2023Return the child function used to hold the body of @code{OMP_PARALLEL}
2024@code{G}.
2025@end deftypefn
2026
2027@deftypefn {GIMPLE function} {tree *} gimple_omp_parallel_child_fn_ptr ( @
2028gomp_parallel *g)
2029Return a pointer to the child function used to hold the body of
2030@code{OMP_PARALLEL} @code{G}.
2031@end deftypefn
2032
2033@deftypefn {GIMPLE function} void gimple_omp_parallel_set_child_fn ( @
2034gomp_parallel *g, tree child_fn)
2035Set @code{CHILD_FN} to be the child function for @code{OMP_PARALLEL} @code{G}.
2036@end deftypefn
2037
2038@deftypefn {GIMPLE function} tree gimple_omp_parallel_data_arg ( @
2039const gomp_parallel *g)
2040Return the artificial argument used to send variables and values
2041from the parent to the children threads in @code{OMP_PARALLEL} @code{G}.
2042@end deftypefn
2043
2044@deftypefn {GIMPLE function} {tree *} gimple_omp_parallel_data_arg_ptr ( @
2045gomp_parallel *g)
2046Return a pointer to the data argument for @code{OMP_PARALLEL} @code{G}.
2047@end deftypefn
2048
2049@deftypefn {GIMPLE function} void gimple_omp_parallel_set_data_arg ( @
2050gomp_parallel *g, tree data_arg)
2051Set @code{DATA_ARG} to be the data argument for @code{OMP_PARALLEL} @code{G}.
2052@end deftypefn
2053
2054
2055@node @code{GIMPLE_OMP_RETURN}
2056@subsection @code{GIMPLE_OMP_RETURN}
2057@cindex @code{GIMPLE_OMP_RETURN}
2058
2059@deftypefn {GIMPLE function} gimple gimple_build_omp_return (bool wait_p)
2060Build a @code{GIMPLE_OMP_RETURN} statement. @code{WAIT_P} is true if this is a
2061non-waiting return.
2062@end deftypefn
2063
2064@deftypefn {GIMPLE function} void gimple_omp_return_set_nowait (gimple s)
2065Set the nowait flag on @code{GIMPLE_OMP_RETURN} statement @code{S}.
2066@end deftypefn
2067
2068
2069@deftypefn {GIMPLE function} bool gimple_omp_return_nowait_p (gimple g)
2070Return true if @code{OMP} return statement @code{G} has the
2071@code{GF_OMP_RETURN_NOWAIT} flag set.
2072@end deftypefn
2073
2074@node @code{GIMPLE_OMP_SECTION}
2075@subsection @code{GIMPLE_OMP_SECTION}
2076@cindex @code{GIMPLE_OMP_SECTION}
2077
2078@deftypefn {GIMPLE function} gimple gimple_build_omp_section (gimple_seq body)
2079Build a @code{GIMPLE_OMP_SECTION} statement for a sections statement.
2080
2081@code{BODY} is the sequence of statements in the section.
2082@end deftypefn
2083
2084@deftypefn {GIMPLE function} bool gimple_omp_section_last_p (gimple g)
2085Return true if @code{OMP} section statement @code{G} has the
2086@code{GF_OMP_SECTION_LAST} flag set.
2087@end deftypefn
2088
2089@deftypefn {GIMPLE function} void gimple_omp_section_set_last (gimple g)
2090Set the @code{GF_OMP_SECTION_LAST} flag on @code{G}.
2091@end deftypefn
2092
2093@node @code{GIMPLE_OMP_SECTIONS}
2094@subsection @code{GIMPLE_OMP_SECTIONS}
2095@cindex @code{GIMPLE_OMP_SECTIONS}
2096
2097@deftypefn {GIMPLE function} gomp_sections *gimple_build_omp_sections ( @
2098gimple_seq body, tree clauses)
2099Build a @code{GIMPLE_OMP_SECTIONS} statement. @code{BODY} is a sequence of
2100section statements. @code{CLAUSES} are any of the @code{OMP} sections
2101construct's clauses: private, firstprivate, lastprivate,
2102reduction, and nowait.
2103@end deftypefn
2104
2105
2106@deftypefn {GIMPLE function} gimple gimple_build_omp_sections_switch (void)
2107Build a @code{GIMPLE_OMP_SECTIONS_SWITCH} statement.
2108@end deftypefn
2109
2110@deftypefn {GIMPLE function} tree gimple_omp_sections_control (gimple g)
2111Return the control variable associated with the
2112@code{GIMPLE_OMP_SECTIONS} in @code{G}.
2113@end deftypefn
2114
2115@deftypefn {GIMPLE function} {tree *} gimple_omp_sections_control_ptr (gimple g)
2116Return a pointer to the clauses associated with the
2117@code{GIMPLE_OMP_SECTIONS} in @code{G}.
2118@end deftypefn
2119
2120@deftypefn {GIMPLE function} void gimple_omp_sections_set_control (gimple g, tree control)
2121Set @code{CONTROL} to be the set of clauses associated with the
2122@code{GIMPLE_OMP_SECTIONS} in @code{G}.
2123@end deftypefn
2124
2125@deftypefn {GIMPLE function} tree gimple_omp_sections_clauses (gimple g)
2126Return the clauses associated with @code{OMP_SECTIONS} @code{G}.
2127@end deftypefn
2128
2129@deftypefn {GIMPLE function} {tree *} gimple_omp_sections_clauses_ptr (gimple g)
2130Return a pointer to the clauses associated with @code{OMP_SECTIONS} @code{G}.
2131@end deftypefn
2132
2133@deftypefn {GIMPLE function} void gimple_omp_sections_set_clauses (gimple g, tree clauses)
2134Set @code{CLAUSES} to be the set of clauses associated with @code{OMP_SECTIONS}
2135@code{G}.
2136@end deftypefn
2137
2138
2139@node @code{GIMPLE_OMP_SINGLE}
2140@subsection @code{GIMPLE_OMP_SINGLE}
2141@cindex @code{GIMPLE_OMP_SINGLE}
2142
2143@deftypefn {GIMPLE function} gomp_single *gimple_build_omp_single ( @
2144gimple_seq body, tree clauses)
2145Build a @code{GIMPLE_OMP_SINGLE} statement. @code{BODY} is the sequence of
2146statements that will be executed once. @code{CLAUSES} are any of the
2147@code{OMP} single construct's clauses: private, firstprivate,
2148copyprivate, nowait.
2149@end deftypefn
2150
2151@deftypefn {GIMPLE function} tree gimple_omp_single_clauses (gimple g)
2152Return the clauses associated with @code{OMP_SINGLE} @code{G}.
2153@end deftypefn
2154
2155@deftypefn {GIMPLE function} {tree *} gimple_omp_single_clauses_ptr (gimple g)
2156Return a pointer to the clauses associated with @code{OMP_SINGLE} @code{G}.
2157@end deftypefn
2158
2159@deftypefn {GIMPLE function} void gimple_omp_single_set_clauses ( @
2160gomp_single *g, tree clauses)
2161Set @code{CLAUSES} to be the clauses associated with @code{OMP_SINGLE} @code{G}.
2162@end deftypefn
2163
2164
a62c8324
SL
2165@node @code{GIMPLE_OMP_STRUCTURED_BLOCK}
2166@subsection @code{GIMPLE_OMP_STRUCTURED_BLOCK}
2167@cindex @code{GIMPLE_OMP_STRUCTURED_BLOCK}
2168
2169Like the GENERIC equivalent @code{OMP_STRUCTURED_BLOCK}, this GIMPLE
2170statement does not correspond directly to an OpenMP directive, and
2171exists only to permit error checking of transfers of control
2172in/out of structured block sequences (the @code{diagnose_omp_blocks} pass
2173in @file{omp-low.cc}). All @code{GIMPLE_OMP_STRUCTURED_BLOCK}
2174nodes are eliminated during OpenMP lowering.
2175
2176@deftypefn {GIMPLE function} gimple gimple_build_omp_structured_block (gimple_seq body)
2177Build a @code{GIMPLE_OMP_STRUCTURED_BLOCK} statement.
2178@code{BODY} is the sequence of statements in the structured block sequence.
2179@end deftypefn
2180
2181
d77de738
ML
2182@node @code{GIMPLE_PHI}
2183@subsection @code{GIMPLE_PHI}
2184@cindex @code{GIMPLE_PHI}
2185
2186@deftypefn {GIMPLE function} unsigned gimple_phi_capacity (gimple g)
2187Return the maximum number of arguments supported by @code{GIMPLE_PHI} @code{G}.
2188@end deftypefn
2189
2190@deftypefn {GIMPLE function} unsigned gimple_phi_num_args (gimple g)
2191Return the number of arguments in @code{GIMPLE_PHI} @code{G}. This must always
2192be exactly the number of incoming edges for the basic block
2193holding @code{G}.
2194@end deftypefn
2195
2196@deftypefn {GIMPLE function} tree gimple_phi_result (gimple g)
2197Return the @code{SSA} name created by @code{GIMPLE_PHI} @code{G}.
2198@end deftypefn
2199
2200@deftypefn {GIMPLE function} {tree *} gimple_phi_result_ptr (gimple g)
2201Return a pointer to the @code{SSA} name created by @code{GIMPLE_PHI} @code{G}.
2202@end deftypefn
2203
2204@deftypefn {GIMPLE function} void gimple_phi_set_result (gphi *g, tree result)
2205Set @code{RESULT} to be the @code{SSA} name created by @code{GIMPLE_PHI} @code{G}.
2206@end deftypefn
2207
2208@deftypefn {GIMPLE function} {struct phi_arg_d *} gimple_phi_arg (gimple g, index)
2209Return the @code{PHI} argument corresponding to incoming edge @code{INDEX} for
2210@code{GIMPLE_PHI} @code{G}.
2211@end deftypefn
2212
2213@deftypefn {GIMPLE function} void gimple_phi_set_arg (gphi *g, index, @
2214struct phi_arg_d * phiarg)
2215Set @code{PHIARG} to be the argument corresponding to incoming edge
2216@code{INDEX} for @code{GIMPLE_PHI} @code{G}.
2217@end deftypefn
2218
2219@node @code{GIMPLE_RESX}
2220@subsection @code{GIMPLE_RESX}
2221@cindex @code{GIMPLE_RESX}
2222
2223@deftypefn {GIMPLE function} gresx *gimple_build_resx (int region)
2224Build a @code{GIMPLE_RESX} statement which is a statement. This
2225statement is a placeholder for _Unwind_Resume before we know if a
2226function call or a branch is needed. @code{REGION} is the exception
2227region from which control is flowing.
2228@end deftypefn
2229
2230@deftypefn {GIMPLE function} int gimple_resx_region (const gresx *g)
2231Return the region number for @code{GIMPLE_RESX} @code{G}.
2232@end deftypefn
2233
2234@deftypefn {GIMPLE function} void gimple_resx_set_region (gresx *g, int region)
2235Set @code{REGION} to be the region number for @code{GIMPLE_RESX} @code{G}.
2236@end deftypefn
2237
2238@node @code{GIMPLE_RETURN}
2239@subsection @code{GIMPLE_RETURN}
2240@cindex @code{GIMPLE_RETURN}
2241
2242@deftypefn {GIMPLE function} greturn *gimple_build_return (tree retval)
2243Build a @code{GIMPLE_RETURN} statement whose return value is retval.
2244@end deftypefn
2245
2246@deftypefn {GIMPLE function} tree gimple_return_retval (const greturn *g)
2247Return the return value for @code{GIMPLE_RETURN} @code{G}.
2248@end deftypefn
2249
2250@deftypefn {GIMPLE function} void gimple_return_set_retval (greturn *g, @
2251tree retval)
2252Set @code{RETVAL} to be the return value for @code{GIMPLE_RETURN} @code{G}.
2253@end deftypefn
2254
2255@node @code{GIMPLE_SWITCH}
2256@subsection @code{GIMPLE_SWITCH}
2257@cindex @code{GIMPLE_SWITCH}
2258
2259@deftypefn {GIMPLE function} gswitch *gimple_build_switch (tree index, @
2260tree default_label, @code{vec}<tree> *args)
2261Build a @code{GIMPLE_SWITCH} statement. @code{INDEX} is the index variable
2262to switch on, and @code{DEFAULT_LABEL} represents the default label.
2263@code{ARGS} is a vector of @code{CASE_LABEL_EXPR} trees that contain the
2264non-default case labels. Each label is a tree of code @code{CASE_LABEL_EXPR}.
2265@end deftypefn
2266
2267@deftypefn {GIMPLE function} unsigned gimple_switch_num_labels ( @
2268const gswitch *g)
2269Return the number of labels associated with the switch statement
2270@code{G}.
2271@end deftypefn
2272
2273@deftypefn {GIMPLE function} void gimple_switch_set_num_labels (gswitch *g, @
2274unsigned nlabels)
2275Set @code{NLABELS} to be the number of labels for the switch statement
2276@code{G}.
2277@end deftypefn
2278
2279@deftypefn {GIMPLE function} tree gimple_switch_index (const gswitch *g)
2280Return the index variable used by the switch statement @code{G}.
2281@end deftypefn
2282
2283@deftypefn {GIMPLE function} void gimple_switch_set_index (gswitch *g, @
2284tree index)
2285Set @code{INDEX} to be the index variable for switch statement @code{G}.
2286@end deftypefn
2287
2288@deftypefn {GIMPLE function} tree gimple_switch_label (const gswitch *g, @
2289unsigned index)
2290Return the label numbered @code{INDEX}. The default label is 0, followed
2291by any labels in a switch statement.
2292@end deftypefn
2293
2294@deftypefn {GIMPLE function} void gimple_switch_set_label (gswitch *g, @
2295unsigned index, tree label)
2296Set the label number @code{INDEX} to @code{LABEL}. 0 is always the default
2297label.
2298@end deftypefn
2299
2300@deftypefn {GIMPLE function} tree gimple_switch_default_label ( @
2301const gswitch *g)
2302Return the default label for a switch statement.
2303@end deftypefn
2304
2305@deftypefn {GIMPLE function} void gimple_switch_set_default_label (gswitch *g, @
2306tree label)
2307Set the default label for a switch statement.
2308@end deftypefn
2309
2310
2311@node @code{GIMPLE_TRY}
2312@subsection @code{GIMPLE_TRY}
2313@cindex @code{GIMPLE_TRY}
2314
2315@deftypefn {GIMPLE function} gtry *gimple_build_try (gimple_seq eval, @
2316gimple_seq cleanup, unsigned int kind)
2317Build a @code{GIMPLE_TRY} statement. @code{EVAL} is a sequence with the
2318expression to evaluate. @code{CLEANUP} is a sequence of statements to
2319run at clean-up time. @code{KIND} is the enumeration value
2320@code{GIMPLE_TRY_CATCH} if this statement denotes a try/catch construct
2321or @code{GIMPLE_TRY_FINALLY} if this statement denotes a try/finally
2322construct.
2323@end deftypefn
2324
2325@deftypefn {GIMPLE function} {enum gimple_try_flags} gimple_try_kind (gimple g)
2326Return the kind of try block represented by @code{GIMPLE_TRY} @code{G}. This is
2327either @code{GIMPLE_TRY_CATCH} or @code{GIMPLE_TRY_FINALLY}.
2328@end deftypefn
2329
2330@deftypefn {GIMPLE function} bool gimple_try_catch_is_cleanup (gimple g)
2331Return the @code{GIMPLE_TRY_CATCH_IS_CLEANUP} flag.
2332@end deftypefn
2333
2334@deftypefn {GIMPLE function} gimple_seq gimple_try_eval (gimple g)
2335Return the sequence of statements used as the body for @code{GIMPLE_TRY}
2336@code{G}.
2337@end deftypefn
2338
2339@deftypefn {GIMPLE function} gimple_seq gimple_try_cleanup (gimple g)
2340Return the sequence of statements used as the cleanup body for
2341@code{GIMPLE_TRY} @code{G}.
2342@end deftypefn
2343
2344@deftypefn {GIMPLE function} void gimple_try_set_catch_is_cleanup (gimple g, @
2345bool catch_is_cleanup)
2346Set the @code{GIMPLE_TRY_CATCH_IS_CLEANUP} flag.
2347@end deftypefn
2348
2349@deftypefn {GIMPLE function} void gimple_try_set_eval (gtry *g, gimple_seq eval)
2350Set @code{EVAL} to be the sequence of statements to use as the body for
2351@code{GIMPLE_TRY} @code{G}.
2352@end deftypefn
2353
2354@deftypefn {GIMPLE function} void gimple_try_set_cleanup (gtry *g, @
2355gimple_seq cleanup)
2356Set @code{CLEANUP} to be the sequence of statements to use as the
2357cleanup body for @code{GIMPLE_TRY} @code{G}.
2358@end deftypefn
2359
2360@node @code{GIMPLE_WITH_CLEANUP_EXPR}
2361@subsection @code{GIMPLE_WITH_CLEANUP_EXPR}
2362@cindex @code{GIMPLE_WITH_CLEANUP_EXPR}
2363
2364@deftypefn {GIMPLE function} gimple gimple_build_wce (gimple_seq cleanup)
2365Build a @code{GIMPLE_WITH_CLEANUP_EXPR} statement. @code{CLEANUP} is the
2366clean-up expression.
2367@end deftypefn
2368
2369@deftypefn {GIMPLE function} gimple_seq gimple_wce_cleanup (gimple g)
2370Return the cleanup sequence for cleanup statement @code{G}.
2371@end deftypefn
2372
2373@deftypefn {GIMPLE function} void gimple_wce_set_cleanup (gimple g, gimple_seq cleanup)
2374Set @code{CLEANUP} to be the cleanup sequence for @code{G}.
2375@end deftypefn
2376
2377@deftypefn {GIMPLE function} bool gimple_wce_cleanup_eh_only (gimple g)
2378Return the @code{CLEANUP_EH_ONLY} flag for a @code{WCE} tuple.
2379@end deftypefn
2380
2381@deftypefn {GIMPLE function} void gimple_wce_set_cleanup_eh_only (gimple g, bool eh_only_p)
2382Set the @code{CLEANUP_EH_ONLY} flag for a @code{WCE} tuple.
2383@end deftypefn
2384
2385
2386@node GIMPLE sequences
2387@section GIMPLE sequences
2388@cindex GIMPLE sequences
2389
2390GIMPLE sequences are the tuple equivalent of @code{STATEMENT_LIST}'s
2391used in @code{GENERIC}. They are used to chain statements together, and
2392when used in conjunction with sequence iterators, provide a
2393framework for iterating through statements.
2394
2395GIMPLE sequences are of type struct @code{gimple_sequence}, but are more
2396commonly passed by reference to functions dealing with sequences.
2397The type for a sequence pointer is @code{gimple_seq} which is the same
2398as struct @code{gimple_sequence} *. When declaring a local sequence,
2399you can define a local variable of type struct @code{gimple_sequence}.
2400When declaring a sequence allocated on the garbage collected
2401heap, use the function @code{gimple_seq_alloc} documented below.
2402
2403There are convenience functions for iterating through sequences
2404in the section entitled Sequence Iterators.
2405
2406Below is a list of functions to manipulate and query sequences.
2407
2408@deftypefn {GIMPLE function} void gimple_seq_add_stmt (gimple_seq *seq, gimple g)
2409Link a gimple statement to the end of the sequence *@code{SEQ} if @code{G} is
2410not @code{NULL}. If *@code{SEQ} is @code{NULL}, allocate a sequence before linking.
2411@end deftypefn
2412
2413@deftypefn {GIMPLE function} void gimple_seq_add_seq (gimple_seq *dest, gimple_seq src)
2414Append sequence @code{SRC} to the end of sequence *@code{DEST} if @code{SRC} is not
2415@code{NULL}. If *@code{DEST} is @code{NULL}, allocate a new sequence before
2416appending.
2417@end deftypefn
2418
2419@deftypefn {GIMPLE function} gimple_seq gimple_seq_deep_copy (gimple_seq src)
2420Perform a deep copy of sequence @code{SRC} and return the result.
2421@end deftypefn
2422
2423@deftypefn {GIMPLE function} gimple_seq gimple_seq_reverse (gimple_seq seq)
2424Reverse the order of the statements in the sequence @code{SEQ}. Return
2425@code{SEQ}.
2426@end deftypefn
2427
2428@deftypefn {GIMPLE function} gimple gimple_seq_first (gimple_seq s)
2429Return the first statement in sequence @code{S}.
2430@end deftypefn
2431
2432@deftypefn {GIMPLE function} gimple gimple_seq_last (gimple_seq s)
2433Return the last statement in sequence @code{S}.
2434@end deftypefn
2435
2436@deftypefn {GIMPLE function} void gimple_seq_set_last (gimple_seq s, gimple last)
2437Set the last statement in sequence @code{S} to the statement in @code{LAST}.
2438@end deftypefn
2439
2440@deftypefn {GIMPLE function} void gimple_seq_set_first (gimple_seq s, gimple first)
2441Set the first statement in sequence @code{S} to the statement in @code{FIRST}.
2442@end deftypefn
2443
2444@deftypefn {GIMPLE function} void gimple_seq_init (gimple_seq s)
2445Initialize sequence @code{S} to an empty sequence.
2446@end deftypefn
2447
2448@deftypefn {GIMPLE function} gimple_seq gimple_seq_alloc (void)
2449Allocate a new sequence in the garbage collected store and return
2450it.
2451@end deftypefn
2452
2453@deftypefn {GIMPLE function} void gimple_seq_copy (gimple_seq dest, gimple_seq src)
2454Copy the sequence @code{SRC} into the sequence @code{DEST}.
2455@end deftypefn
2456
2457@deftypefn {GIMPLE function} bool gimple_seq_empty_p (gimple_seq s)
2458Return true if the sequence @code{S} is empty.
2459@end deftypefn
2460
2461@deftypefn {GIMPLE function} gimple_seq bb_seq (basic_block bb)
2462Returns the sequence of statements in @code{BB}.
2463@end deftypefn
2464
2465@deftypefn {GIMPLE function} void set_bb_seq (basic_block bb, gimple_seq seq)
2466Sets the sequence of statements in @code{BB} to @code{SEQ}.
2467@end deftypefn
2468
2469@deftypefn {GIMPLE function} bool gimple_seq_singleton_p (gimple_seq seq)
2470Determine whether @code{SEQ} contains exactly one statement.
2471@end deftypefn
2472
2473@node Sequence iterators
2474@section Sequence iterators
2475@cindex Sequence iterators
2476
2477Sequence iterators are convenience constructs for iterating
2478through statements in a sequence. Given a sequence @code{SEQ}, here is
2479a typical use of gimple sequence iterators:
2480
2481@smallexample
2482gimple_stmt_iterator gsi;
2483
2484for (gsi = gsi_start (seq); !gsi_end_p (gsi); gsi_next (&gsi))
2485 @{
2486 gimple g = gsi_stmt (gsi);
2487 /* Do something with gimple statement @code{G}. */
2488 @}
2489@end smallexample
2490
2491Backward iterations are possible:
2492
2493@smallexample
2494 for (gsi = gsi_last (seq); !gsi_end_p (gsi); gsi_prev (&gsi))
2495@end smallexample
2496
2497Forward and backward iterations on basic blocks are possible with
2498@code{gsi_start_bb} and @code{gsi_last_bb}.
2499
2500In the documentation below we sometimes refer to enum
2501@code{gsi_iterator_update}. The valid options for this enumeration are:
2502
2503@itemize @bullet
2504@item @code{GSI_NEW_STMT}
2505Only valid when a single statement is added. Move the iterator to it.
2506
2507@item @code{GSI_SAME_STMT}
2508Leave the iterator at the same statement.
2509
2510@item @code{GSI_CONTINUE_LINKING}
2511Move iterator to whatever position is suitable for linking other
2512statements in the same direction.
2513@end itemize
2514
2515Below is a list of the functions used to manipulate and use
2516statement iterators.
2517
2518@deftypefn {GIMPLE function} gimple_stmt_iterator gsi_start (gimple_seq seq)
2519Return a new iterator pointing to the sequence @code{SEQ}'s first
2520statement. If @code{SEQ} is empty, the iterator's basic block is @code{NULL}.
2521Use @code{gsi_start_bb} instead when the iterator needs to always have
2522the correct basic block set.
2523@end deftypefn
2524
2525@deftypefn {GIMPLE function} gimple_stmt_iterator gsi_start_bb (basic_block bb)
2526Return a new iterator pointing to the first statement in basic
2527block @code{BB}.
2528@end deftypefn
2529
2530@deftypefn {GIMPLE function} gimple_stmt_iterator gsi_last (gimple_seq seq)
2531Return a new iterator initially pointing to the last statement of
2532sequence @code{SEQ}. If @code{SEQ} is empty, the iterator's basic block is
2533@code{NULL}. Use @code{gsi_last_bb} instead when the iterator needs to always
2534have the correct basic block set.
2535@end deftypefn
2536
2537@deftypefn {GIMPLE function} gimple_stmt_iterator gsi_last_bb (basic_block bb)
2538Return a new iterator pointing to the last statement in basic
2539block @code{BB}.
2540@end deftypefn
2541
2542@deftypefn {GIMPLE function} bool gsi_end_p (gimple_stmt_iterator i)
2543Return @code{TRUE} if at the end of @code{I}.
2544@end deftypefn
2545
2546@deftypefn {GIMPLE function} bool gsi_one_before_end_p (gimple_stmt_iterator i)
2547Return @code{TRUE} if we're one statement before the end of @code{I}.
2548@end deftypefn
2549
2550@deftypefn {GIMPLE function} void gsi_next (gimple_stmt_iterator *i)
2551Advance the iterator to the next gimple statement.
2552@end deftypefn
2553
2554@deftypefn {GIMPLE function} void gsi_prev (gimple_stmt_iterator *i)
2555Advance the iterator to the previous gimple statement.
2556@end deftypefn
2557
2558@deftypefn {GIMPLE function} gimple gsi_stmt (gimple_stmt_iterator i)
2559Return the current stmt.
2560@end deftypefn
2561
2562@deftypefn {GIMPLE function} gimple_stmt_iterator gsi_after_labels (basic_block bb)
2563Return a block statement iterator that points to the first
2564non-label statement in block @code{BB}.
2565@end deftypefn
2566
2567@deftypefn {GIMPLE function} {gimple *} gsi_stmt_ptr (gimple_stmt_iterator *i)
2568Return a pointer to the current stmt.
2569@end deftypefn
2570
2571@deftypefn {GIMPLE function} basic_block gsi_bb (gimple_stmt_iterator i)
2572Return the basic block associated with this iterator.
2573@end deftypefn
2574
2575@deftypefn {GIMPLE function} gimple_seq gsi_seq (gimple_stmt_iterator i)
2576Return the sequence associated with this iterator.
2577@end deftypefn
2578
2579@deftypefn {GIMPLE function} void gsi_remove (gimple_stmt_iterator *i, bool remove_eh_info)
2580Remove the current stmt from the sequence. The iterator is
2581updated to point to the next statement. When @code{REMOVE_EH_INFO} is
2582true we remove the statement pointed to by iterator @code{I} from the @code{EH}
2583tables. Otherwise we do not modify the @code{EH} tables. Generally,
2584@code{REMOVE_EH_INFO} should be true when the statement is going to be
2585removed from the @code{IL} and not reinserted elsewhere.
2586@end deftypefn
2587
2588@deftypefn {GIMPLE function} void gsi_link_seq_before (gimple_stmt_iterator *i, gimple_seq seq, enum gsi_iterator_update mode)
2589Links the sequence of statements @code{SEQ} before the statement pointed
2590by iterator @code{I}. @code{MODE} indicates what to do with the iterator
2591after insertion (see @code{enum gsi_iterator_update} above).
2592@end deftypefn
2593
2594@deftypefn {GIMPLE function} void gsi_link_before (gimple_stmt_iterator *i, gimple g, enum gsi_iterator_update mode)
2595Links statement @code{G} before the statement pointed-to by iterator @code{I}.
2596Updates iterator @code{I} according to @code{MODE}.
2597@end deftypefn
2598
2599@deftypefn {GIMPLE function} void gsi_link_seq_after (gimple_stmt_iterator *i, @
2600gimple_seq seq, enum gsi_iterator_update mode)
2601Links sequence @code{SEQ} after the statement pointed-to by iterator @code{I}.
2602@code{MODE} is as in @code{gsi_insert_after}.
2603@end deftypefn
2604
2605@deftypefn {GIMPLE function} void gsi_link_after (gimple_stmt_iterator *i, @
2606gimple g, enum gsi_iterator_update mode)
2607Links statement @code{G} after the statement pointed-to by iterator @code{I}.
2608@code{MODE} is as in @code{gsi_insert_after}.
2609@end deftypefn
2610
2611@deftypefn {GIMPLE function} gimple_seq gsi_split_seq_after (gimple_stmt_iterator i)
2612Move all statements in the sequence after @code{I} to a new sequence.
2613Return this new sequence.
2614@end deftypefn
2615
2616@deftypefn {GIMPLE function} gimple_seq gsi_split_seq_before (gimple_stmt_iterator *i)
2617Move all statements in the sequence before @code{I} to a new sequence.
2618Return this new sequence.
2619@end deftypefn
2620
2621@deftypefn {GIMPLE function} void gsi_replace (gimple_stmt_iterator *i, @
2622gimple stmt, bool update_eh_info)
2623Replace the statement pointed-to by @code{I} to @code{STMT}. If @code{UPDATE_EH_INFO}
2624is true, the exception handling information of the original
2625statement is moved to the new statement.
2626@end deftypefn
2627
2628@deftypefn {GIMPLE function} void gsi_insert_before (gimple_stmt_iterator *i, @
2629gimple stmt, enum gsi_iterator_update mode)
2630Insert statement @code{STMT} before the statement pointed-to by iterator
2631@code{I}, update @code{STMT}'s basic block and scan it for new operands. @code{MODE}
2632specifies how to update iterator @code{I} after insertion (see enum
2633@code{gsi_iterator_update}).
2634@end deftypefn
2635
2636@deftypefn {GIMPLE function} void gsi_insert_seq_before (gimple_stmt_iterator *i, @
2637gimple_seq seq, enum gsi_iterator_update mode)
2638Like @code{gsi_insert_before}, but for all the statements in @code{SEQ}.
2639@end deftypefn
2640
2641@deftypefn {GIMPLE function} void gsi_insert_after (gimple_stmt_iterator *i, @
2642gimple stmt, enum gsi_iterator_update mode)
2643Insert statement @code{STMT} after the statement pointed-to by iterator
2644@code{I}, update @code{STMT}'s basic block and scan it for new operands. @code{MODE}
2645specifies how to update iterator @code{I} after insertion (see enum
2646@code{gsi_iterator_update}).
2647@end deftypefn
2648
2649@deftypefn {GIMPLE function} void gsi_insert_seq_after (gimple_stmt_iterator *i, @
2650gimple_seq seq, enum gsi_iterator_update mode)
2651Like @code{gsi_insert_after}, but for all the statements in @code{SEQ}.
2652@end deftypefn
2653
2654@deftypefn {GIMPLE function} gimple_stmt_iterator gsi_for_stmt (gimple stmt)
2655Finds iterator for @code{STMT}.
2656@end deftypefn
2657
2658@deftypefn {GIMPLE function} void gsi_move_after (gimple_stmt_iterator *from, @
2659gimple_stmt_iterator *to)
2660Move the statement at @code{FROM} so it comes right after the statement
2661at @code{TO}.
2662@end deftypefn
2663
2664@deftypefn {GIMPLE function} void gsi_move_before (gimple_stmt_iterator *from, @
2665gimple_stmt_iterator *to)
2666Move the statement at @code{FROM} so it comes right before the statement
2667at @code{TO}.
2668@end deftypefn
2669
2670@deftypefn {GIMPLE function} void gsi_move_to_bb_end (gimple_stmt_iterator *from, @
2671basic_block bb)
2672Move the statement at @code{FROM} to the end of basic block @code{BB}.
2673@end deftypefn
2674
2675@deftypefn {GIMPLE function} void gsi_insert_on_edge (edge e, gimple stmt)
2676Add @code{STMT} to the pending list of edge @code{E}. No actual insertion is
2677made until a call to @code{gsi_commit_edge_inserts}() is made.
2678@end deftypefn
2679
2680@deftypefn {GIMPLE function} void gsi_insert_seq_on_edge (edge e, gimple_seq seq)
2681Add the sequence of statements in @code{SEQ} to the pending list of edge
2682@code{E}. No actual insertion is made until a call to
2683@code{gsi_commit_edge_inserts}() is made.
2684@end deftypefn
2685
2686@deftypefn {GIMPLE function} basic_block gsi_insert_on_edge_immediate (edge e, gimple stmt)
2687Similar to @code{gsi_insert_on_edge}+@code{gsi_commit_edge_inserts}. If a new
2688block has to be created, it is returned.
2689@end deftypefn
2690
2691@deftypefn {GIMPLE function} void gsi_commit_one_edge_insert (edge e, basic_block *new_bb)
2692Commit insertions pending at edge @code{E}. If a new block is created,
2693set @code{NEW_BB} to this block, otherwise set it to @code{NULL}.
2694@end deftypefn
2695
2696@deftypefn {GIMPLE function} void gsi_commit_edge_inserts (void)
2697This routine will commit all pending edge insertions, creating
2698any new basic blocks which are necessary.
2699@end deftypefn
2700
2701
2702@node Adding a new GIMPLE statement code
2703@section Adding a new GIMPLE statement code
2704@cindex Adding a new GIMPLE statement code
2705
2706The first step in adding a new GIMPLE statement code, is
2707modifying the file @code{gimple.def}, which contains all the GIMPLE
2708codes. Then you must add a corresponding gimple subclass
2709located in @code{gimple.h}. This in turn, will require you to add a
2710corresponding @code{GTY} tag in @code{gsstruct.def}, and code to handle
2711this tag in @code{gss_for_code} which is located in @code{gimple.cc}.
2712
2713In order for the garbage collector to know the size of the
2714structure you created in @code{gimple.h}, you need to add a case to
2715handle your new GIMPLE statement in @code{gimple_size} which is located
2716in @code{gimple.cc}.
2717
2718You will probably want to create a function to build the new
2719gimple statement in @code{gimple.cc}. The function should be called
2720@code{gimple_build_@var{new-tuple-name}}, and should return the new tuple
2721as a pointer to the appropriate gimple subclass.
2722
2723If your new statement requires accessors for any members or
2724operands it may have, put simple inline accessors in
2725@code{gimple.h} and any non-trivial accessors in @code{gimple.cc} with a
2726corresponding prototype in @code{gimple.h}.
2727
2728You should add the new statement subclass to the class hierarchy diagram
2729in @code{gimple.texi}.
2730
2731
2732@node Statement and operand traversals
2733@section Statement and operand traversals
2734@cindex Statement and operand traversals
2735
2736There are two functions available for walking statements and
2737sequences: @code{walk_gimple_stmt} and @code{walk_gimple_seq},
2738accordingly, and a third function for walking the operands in a
2739statement: @code{walk_gimple_op}.
2740
2741@deftypefn {GIMPLE function} tree walk_gimple_stmt (gimple_stmt_iterator *gsi, @
2742 walk_stmt_fn callback_stmt, walk_tree_fn callback_op, struct walk_stmt_info *wi)
2743This function is used to walk the current statement in @code{GSI},
2744optionally using traversal state stored in @code{WI}. If @code{WI} is @code{NULL}, no
2745state is kept during the traversal.
2746
2747The callback @code{CALLBACK_STMT} is called. If @code{CALLBACK_STMT} returns
2748true, it means that the callback function has handled all the
2749operands of the statement and it is not necessary to walk its
2750operands.
2751
2752If @code{CALLBACK_STMT} is @code{NULL} or it returns false, @code{CALLBACK_OP} is
2753called on each operand of the statement via @code{walk_gimple_op}. If
2754@code{walk_gimple_op} returns non-@code{NULL} for any operand, the remaining
2755operands are not scanned.
2756
2757The return value is that returned by the last call to
2758@code{walk_gimple_op}, or @code{NULL_TREE} if no @code{CALLBACK_OP} is specified.
2759@end deftypefn
2760
2761
2762@deftypefn {GIMPLE function} tree walk_gimple_op (gimple stmt, @
2763 walk_tree_fn callback_op, struct walk_stmt_info *wi)
2764Use this function to walk the operands of statement @code{STMT}. Every
2765operand is walked via @code{walk_tree} with optional state information
2766in @code{WI}.
2767
2768@code{CALLBACK_OP} is called on each operand of @code{STMT} via @code{walk_tree}.
2769Additional parameters to @code{walk_tree} must be stored in @code{WI}. For
2770each operand @code{OP}, @code{walk_tree} is called as:
2771
2772@smallexample
2773walk_tree (&@code{OP}, @code{CALLBACK_OP}, @code{WI}, @code{PSET})
2774@end smallexample
2775
2776If @code{CALLBACK_OP} returns non-@code{NULL} for an operand, the remaining
2777operands are not scanned. The return value is that returned by
2778the last call to @code{walk_tree}, or @code{NULL_TREE} if no @code{CALLBACK_OP} is
2779specified.
2780@end deftypefn
2781
2782
2783@deftypefn {GIMPLE function} tree walk_gimple_seq (gimple_seq seq, @
2784 walk_stmt_fn callback_stmt, walk_tree_fn callback_op, struct walk_stmt_info *wi)
2785This function walks all the statements in the sequence @code{SEQ}
2786calling @code{walk_gimple_stmt} on each one. @code{WI} is as in
2787@code{walk_gimple_stmt}. If @code{walk_gimple_stmt} returns non-@code{NULL}, the walk
2788is stopped and the value returned. Otherwise, all the statements
2789are walked and @code{NULL_TREE} returned.
2790@end deftypefn