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