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