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