]>
Commit | Line | Data |
---|---|---|
726a989a RB |
1 | /* Gimple IR definitions. |
2 | ||
c75c517d | 3 | Copyright 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
726a989a RB |
4 | Contributed by Aldy Hernandez <aldyh@redhat.com> |
5 | ||
6 | This file is part of GCC. | |
7 | ||
8 | GCC is free software; you can redistribute it and/or modify it under | |
9 | the terms of the GNU General Public License as published by the Free | |
10 | Software Foundation; either version 3, or (at your option) any later | |
11 | version. | |
12 | ||
13 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
14 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 | for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with GCC; see the file COPYING3. If not see | |
20 | <http://www.gnu.org/licenses/>. */ | |
21 | ||
22 | #ifndef GCC_GIMPLE_H | |
23 | #define GCC_GIMPLE_H | |
24 | ||
25 | #include "pointer-set.h" | |
26 | #include "vec.h" | |
f4ce02c5 SB |
27 | #include "vecprim.h" |
28 | #include "vecir.h" | |
726a989a RB |
29 | #include "ggc.h" |
30 | #include "tm.h" | |
31 | #include "hard-reg-set.h" | |
32 | #include "basic-block.h" | |
33 | #include "tree-ssa-operands.h" | |
d086d311 | 34 | #include "tree-ssa-alias.h" |
726a989a | 35 | |
f8bf9252 SP |
36 | /* For each block, the PHI nodes that need to be rewritten are stored into |
37 | these vectors. */ | |
38 | typedef VEC(gimple, heap) *gimple_vec; | |
39 | DEF_VEC_P (gimple_vec); | |
40 | DEF_VEC_ALLOC_P (gimple_vec, heap); | |
41 | ||
726a989a RB |
42 | enum gimple_code { |
43 | #define DEFGSCODE(SYM, STRING, STRUCT) SYM, | |
44 | #include "gimple.def" | |
45 | #undef DEFGSCODE | |
46 | LAST_AND_UNUSED_GIMPLE_CODE | |
47 | }; | |
48 | ||
49 | extern const char *const gimple_code_name[]; | |
50 | extern const unsigned char gimple_rhs_class_table[]; | |
51 | ||
52 | /* Error out if a gimple tuple is addressed incorrectly. */ | |
53 | #if defined ENABLE_GIMPLE_CHECKING | |
54 | extern void gimple_check_failed (const_gimple, const char *, int, \ | |
55 | const char *, enum gimple_code, \ | |
56 | enum tree_code) ATTRIBUTE_NORETURN; | |
726a989a RB |
57 | |
58 | #define GIMPLE_CHECK(GS, CODE) \ | |
59 | do { \ | |
60 | const_gimple __gs = (GS); \ | |
61 | if (gimple_code (__gs) != (CODE)) \ | |
62 | gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__, \ | |
bbbbb16a | 63 | (CODE), ERROR_MARK); \ |
726a989a RB |
64 | } while (0) |
65 | #else /* not ENABLE_GIMPLE_CHECKING */ | |
66 | #define GIMPLE_CHECK(GS, CODE) (void)0 | |
67 | #endif | |
68 | ||
69 | /* Class of GIMPLE expressions suitable for the RHS of assignments. See | |
70 | get_gimple_rhs_class. */ | |
71 | enum gimple_rhs_class | |
72 | { | |
73 | GIMPLE_INVALID_RHS, /* The expression cannot be used on the RHS. */ | |
74 | GIMPLE_BINARY_RHS, /* The expression is a binary operation. */ | |
75 | GIMPLE_UNARY_RHS, /* The expression is a unary operation. */ | |
76 | GIMPLE_SINGLE_RHS /* The expression is a single object (an SSA | |
77 | name, a _DECL, a _REF, etc. */ | |
78 | }; | |
79 | ||
80 | /* Specific flags for individual GIMPLE statements. These flags are | |
81 | always stored in gimple_statement_base.subcode and they may only be | |
82 | defined for statement codes that do not use sub-codes. | |
83 | ||
84 | Values for the masks can overlap as long as the overlapping values | |
85 | are never used in the same statement class. | |
86 | ||
87 | The maximum mask value that can be defined is 1 << 15 (i.e., each | |
88 | statement code can hold up to 16 bitflags). | |
89 | ||
90 | Keep this list sorted. */ | |
91 | enum gf_mask { | |
92 | GF_ASM_INPUT = 1 << 0, | |
93 | GF_ASM_VOLATILE = 1 << 1, | |
94 | GF_CALL_CANNOT_INLINE = 1 << 0, | |
95 | GF_CALL_FROM_THUNK = 1 << 1, | |
96 | GF_CALL_RETURN_SLOT_OPT = 1 << 2, | |
97 | GF_CALL_TAILCALL = 1 << 3, | |
98 | GF_CALL_VA_ARG_PACK = 1 << 4, | |
9bb1a81b | 99 | GF_CALL_NOTHROW = 1 << 5, |
726a989a RB |
100 | GF_OMP_PARALLEL_COMBINED = 1 << 0, |
101 | ||
102 | /* True on an GIMPLE_OMP_RETURN statement if the return does not require | |
103 | a thread synchronization via some sort of barrier. The exact barrier | |
104 | that would otherwise be emitted is dependent on the OMP statement with | |
105 | which this return is associated. */ | |
106 | GF_OMP_RETURN_NOWAIT = 1 << 0, | |
107 | ||
108 | GF_OMP_SECTION_LAST = 1 << 0, | |
109 | GF_PREDICT_TAKEN = 1 << 15 | |
110 | }; | |
111 | ||
b5b8b0ac AO |
112 | /* Currently, there's only one type of gimple debug stmt. Others are |
113 | envisioned, for example, to enable the generation of is_stmt notes | |
114 | in line number information, to mark sequence points, etc. This | |
115 | subcode is to be used to tell them apart. */ | |
116 | enum gimple_debug_subcode { | |
117 | GIMPLE_DEBUG_BIND = 0 | |
118 | }; | |
119 | ||
726a989a RB |
120 | /* Masks for selecting a pass local flag (PLF) to work on. These |
121 | masks are used by gimple_set_plf and gimple_plf. */ | |
122 | enum plf_mask { | |
123 | GF_PLF_1 = 1 << 0, | |
124 | GF_PLF_2 = 1 << 1 | |
125 | }; | |
126 | ||
127 | /* A node in a gimple_seq_d. */ | |
d1b38208 | 128 | struct GTY((chain_next ("%h.next"), chain_prev ("%h.prev"))) gimple_seq_node_d { |
726a989a RB |
129 | gimple stmt; |
130 | struct gimple_seq_node_d *prev; | |
131 | struct gimple_seq_node_d *next; | |
132 | }; | |
133 | ||
134 | /* A double-linked sequence of gimple statements. */ | |
d1b38208 | 135 | struct GTY ((chain_next ("%h.next_free"))) gimple_seq_d { |
726a989a RB |
136 | /* First and last statements in the sequence. */ |
137 | gimple_seq_node first; | |
138 | gimple_seq_node last; | |
139 | ||
140 | /* Sequences are created/destroyed frequently. To minimize | |
141 | allocation activity, deallocated sequences are kept in a pool of | |
142 | available sequences. This is the pointer to the next free | |
143 | sequence in the pool. */ | |
144 | gimple_seq next_free; | |
145 | }; | |
146 | ||
147 | ||
148 | /* Return the first node in GIMPLE sequence S. */ | |
149 | ||
150 | static inline gimple_seq_node | |
151 | gimple_seq_first (const_gimple_seq s) | |
152 | { | |
153 | return s ? s->first : NULL; | |
154 | } | |
155 | ||
156 | ||
157 | /* Return the first statement in GIMPLE sequence S. */ | |
158 | ||
159 | static inline gimple | |
160 | gimple_seq_first_stmt (const_gimple_seq s) | |
161 | { | |
162 | gimple_seq_node n = gimple_seq_first (s); | |
163 | return (n) ? n->stmt : NULL; | |
164 | } | |
165 | ||
166 | ||
167 | /* Return the last node in GIMPLE sequence S. */ | |
168 | ||
169 | static inline gimple_seq_node | |
170 | gimple_seq_last (const_gimple_seq s) | |
171 | { | |
172 | return s ? s->last : NULL; | |
173 | } | |
174 | ||
175 | ||
176 | /* Return the last statement in GIMPLE sequence S. */ | |
177 | ||
178 | static inline gimple | |
179 | gimple_seq_last_stmt (const_gimple_seq s) | |
180 | { | |
181 | gimple_seq_node n = gimple_seq_last (s); | |
182 | return (n) ? n->stmt : NULL; | |
183 | } | |
184 | ||
185 | ||
186 | /* Set the last node in GIMPLE sequence S to LAST. */ | |
187 | ||
188 | static inline void | |
189 | gimple_seq_set_last (gimple_seq s, gimple_seq_node last) | |
190 | { | |
191 | s->last = last; | |
192 | } | |
193 | ||
194 | ||
195 | /* Set the first node in GIMPLE sequence S to FIRST. */ | |
196 | ||
197 | static inline void | |
198 | gimple_seq_set_first (gimple_seq s, gimple_seq_node first) | |
199 | { | |
200 | s->first = first; | |
201 | } | |
202 | ||
203 | ||
204 | /* Return true if GIMPLE sequence S is empty. */ | |
205 | ||
206 | static inline bool | |
207 | gimple_seq_empty_p (const_gimple_seq s) | |
208 | { | |
209 | return s == NULL || s->first == NULL; | |
210 | } | |
211 | ||
212 | ||
213 | void gimple_seq_add_stmt (gimple_seq *, gimple); | |
214 | ||
786f715d JM |
215 | /* Link gimple statement GS to the end of the sequence *SEQ_P. If |
216 | *SEQ_P is NULL, a new sequence is allocated. This function is | |
217 | similar to gimple_seq_add_stmt, but does not scan the operands. | |
218 | During gimplification, we need to manipulate statement sequences | |
219 | before the def/use vectors have been constructed. */ | |
220 | void gimplify_seq_add_stmt (gimple_seq *, gimple); | |
221 | ||
726a989a RB |
222 | /* Allocate a new sequence and initialize its first element with STMT. */ |
223 | ||
224 | static inline gimple_seq | |
225 | gimple_seq_alloc_with_stmt (gimple stmt) | |
226 | { | |
227 | gimple_seq seq = NULL; | |
228 | gimple_seq_add_stmt (&seq, stmt); | |
229 | return seq; | |
230 | } | |
231 | ||
232 | ||
233 | /* Returns the sequence of statements in BB. */ | |
234 | ||
235 | static inline gimple_seq | |
236 | bb_seq (const_basic_block bb) | |
237 | { | |
238 | return (!(bb->flags & BB_RTL) && bb->il.gimple) ? bb->il.gimple->seq : NULL; | |
239 | } | |
240 | ||
241 | ||
242 | /* Sets the sequence of statements in BB to SEQ. */ | |
243 | ||
244 | static inline void | |
245 | set_bb_seq (basic_block bb, gimple_seq seq) | |
246 | { | |
247 | gcc_assert (!(bb->flags & BB_RTL)); | |
248 | bb->il.gimple->seq = seq; | |
249 | } | |
250 | ||
251 | /* Iterator object for GIMPLE statement sequences. */ | |
252 | ||
253 | typedef struct | |
254 | { | |
255 | /* Sequence node holding the current statement. */ | |
256 | gimple_seq_node ptr; | |
257 | ||
258 | /* Sequence and basic block holding the statement. These fields | |
259 | are necessary to handle edge cases such as when statement is | |
260 | added to an empty basic block or when the last statement of a | |
261 | block/sequence is removed. */ | |
262 | gimple_seq seq; | |
263 | basic_block bb; | |
264 | } gimple_stmt_iterator; | |
265 | ||
266 | ||
267 | /* Data structure definitions for GIMPLE tuples. NOTE: word markers | |
268 | are for 64 bit hosts. */ | |
269 | ||
d1b38208 | 270 | struct GTY(()) gimple_statement_base { |
726a989a RB |
271 | /* [ WORD 1 ] |
272 | Main identifying code for a tuple. */ | |
273 | ENUM_BITFIELD(gimple_code) code : 8; | |
274 | ||
275 | /* Nonzero if a warning should not be emitted on this tuple. */ | |
276 | unsigned int no_warning : 1; | |
277 | ||
278 | /* Nonzero if this tuple has been visited. Passes are responsible | |
279 | for clearing this bit before using it. */ | |
280 | unsigned int visited : 1; | |
281 | ||
282 | /* Nonzero if this tuple represents a non-temporal move. */ | |
283 | unsigned int nontemporal_move : 1; | |
284 | ||
285 | /* Pass local flags. These flags are free for any pass to use as | |
286 | they see fit. Passes should not assume that these flags contain | |
287 | any useful value when the pass starts. Any initial state that | |
288 | the pass requires should be set on entry to the pass. See | |
289 | gimple_set_plf and gimple_plf for usage. */ | |
290 | unsigned int plf : 2; | |
291 | ||
292 | /* Nonzero if this statement has been modified and needs to have its | |
293 | operands rescanned. */ | |
294 | unsigned modified : 1; | |
295 | ||
296 | /* Nonzero if this statement contains volatile operands. */ | |
297 | unsigned has_volatile_ops : 1; | |
298 | ||
5006671f RG |
299 | /* Padding to get subcode to 16 bit alignment. */ |
300 | unsigned pad : 1; | |
726a989a RB |
301 | |
302 | /* The SUBCODE field can be used for tuple-specific flags for tuples | |
303 | that do not require subcodes. Note that SUBCODE should be at | |
304 | least as wide as tree codes, as several tuples store tree codes | |
305 | in there. */ | |
306 | unsigned int subcode : 16; | |
307 | ||
e0e10d3a DN |
308 | /* UID of this statement. This is used by passes that want to |
309 | assign IDs to statements. It must be assigned and used by each | |
310 | pass. By default it should be assumed to contain garbage. */ | |
726a989a RB |
311 | unsigned uid; |
312 | ||
313 | /* [ WORD 2 ] | |
314 | Locus information for debug info. */ | |
315 | location_t location; | |
316 | ||
317 | /* Number of operands in this tuple. */ | |
318 | unsigned num_ops; | |
319 | ||
320 | /* [ WORD 3 ] | |
321 | Basic block holding this statement. */ | |
322 | struct basic_block_def *bb; | |
323 | ||
324 | /* [ WORD 4 ] | |
325 | Lexical block holding this statement. */ | |
326 | tree block; | |
327 | }; | |
328 | ||
329 | ||
330 | /* Base structure for tuples with operands. */ | |
331 | ||
d1b38208 | 332 | struct GTY(()) gimple_statement_with_ops_base |
726a989a | 333 | { |
ccacdf06 | 334 | /* [ WORD 1-4 ] */ |
726a989a RB |
335 | struct gimple_statement_base gsbase; |
336 | ||
ccacdf06 | 337 | /* [ WORD 5-6 ] |
726a989a RB |
338 | SSA operand vectors. NOTE: It should be possible to |
339 | amalgamate these vectors with the operand vector OP. However, | |
340 | the SSA operand vectors are organized differently and contain | |
341 | more information (like immediate use chaining). */ | |
342 | struct def_optype_d GTY((skip (""))) *def_ops; | |
343 | struct use_optype_d GTY((skip (""))) *use_ops; | |
344 | }; | |
345 | ||
346 | ||
347 | /* Statements that take register operands. */ | |
348 | ||
d1b38208 | 349 | struct GTY(()) gimple_statement_with_ops |
726a989a | 350 | { |
ccacdf06 | 351 | /* [ WORD 1-6 ] */ |
726a989a RB |
352 | struct gimple_statement_with_ops_base opbase; |
353 | ||
ccacdf06 | 354 | /* [ WORD 7 ] |
726a989a RB |
355 | Operand vector. NOTE! This must always be the last field |
356 | of this structure. In particular, this means that this | |
357 | structure cannot be embedded inside another one. */ | |
358 | tree GTY((length ("%h.opbase.gsbase.num_ops"))) op[1]; | |
359 | }; | |
360 | ||
361 | ||
362 | /* Base for statements that take both memory and register operands. */ | |
363 | ||
d1b38208 | 364 | struct GTY(()) gimple_statement_with_memory_ops_base |
726a989a | 365 | { |
ccacdf06 | 366 | /* [ WORD 1-6 ] */ |
726a989a RB |
367 | struct gimple_statement_with_ops_base opbase; |
368 | ||
ccacdf06 | 369 | /* [ WORD 7-8 ] |
5006671f RG |
370 | Virtual operands for this statement. The GC will pick them |
371 | up via the ssa_names array. */ | |
372 | tree GTY((skip (""))) vdef; | |
373 | tree GTY((skip (""))) vuse; | |
726a989a RB |
374 | }; |
375 | ||
376 | ||
377 | /* Statements that take both memory and register operands. */ | |
378 | ||
d1b38208 | 379 | struct GTY(()) gimple_statement_with_memory_ops |
726a989a | 380 | { |
ccacdf06 | 381 | /* [ WORD 1-8 ] */ |
726a989a RB |
382 | struct gimple_statement_with_memory_ops_base membase; |
383 | ||
ccacdf06 | 384 | /* [ WORD 9 ] |
726a989a RB |
385 | Operand vector. NOTE! This must always be the last field |
386 | of this structure. In particular, this means that this | |
387 | structure cannot be embedded inside another one. */ | |
388 | tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1]; | |
389 | }; | |
390 | ||
391 | ||
d086d311 RG |
392 | /* Call statements that take both memory and register operands. */ |
393 | ||
394 | struct GTY(()) gimple_statement_call | |
395 | { | |
396 | /* [ WORD 1-8 ] */ | |
397 | struct gimple_statement_with_memory_ops_base membase; | |
398 | ||
399 | /* [ WORD 9-12 ] */ | |
400 | struct pt_solution call_used; | |
401 | struct pt_solution call_clobbered; | |
402 | ||
403 | /* [ WORD 13 ] | |
404 | Operand vector. NOTE! This must always be the last field | |
405 | of this structure. In particular, this means that this | |
406 | structure cannot be embedded inside another one. */ | |
407 | tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1]; | |
408 | }; | |
409 | ||
410 | ||
726a989a RB |
411 | /* OpenMP statements (#pragma omp). */ |
412 | ||
d1b38208 | 413 | struct GTY(()) gimple_statement_omp { |
726a989a RB |
414 | /* [ WORD 1-4 ] */ |
415 | struct gimple_statement_base gsbase; | |
416 | ||
417 | /* [ WORD 5 ] */ | |
418 | gimple_seq body; | |
419 | }; | |
420 | ||
421 | ||
422 | /* GIMPLE_BIND */ | |
423 | ||
d1b38208 | 424 | struct GTY(()) gimple_statement_bind { |
726a989a RB |
425 | /* [ WORD 1-4 ] */ |
426 | struct gimple_statement_base gsbase; | |
427 | ||
428 | /* [ WORD 5 ] | |
429 | Variables declared in this scope. */ | |
430 | tree vars; | |
431 | ||
432 | /* [ WORD 6 ] | |
433 | This is different than the BLOCK field in gimple_statement_base, | |
434 | which is analogous to TREE_BLOCK (i.e., the lexical block holding | |
435 | this statement). This field is the equivalent of BIND_EXPR_BLOCK | |
436 | in tree land (i.e., the lexical scope defined by this bind). See | |
437 | gimple-low.c. */ | |
438 | tree block; | |
439 | ||
440 | /* [ WORD 7 ] */ | |
441 | gimple_seq body; | |
442 | }; | |
443 | ||
444 | ||
445 | /* GIMPLE_CATCH */ | |
446 | ||
d1b38208 | 447 | struct GTY(()) gimple_statement_catch { |
726a989a RB |
448 | /* [ WORD 1-4 ] */ |
449 | struct gimple_statement_base gsbase; | |
450 | ||
451 | /* [ WORD 5 ] */ | |
452 | tree types; | |
453 | ||
454 | /* [ WORD 6 ] */ | |
455 | gimple_seq handler; | |
456 | }; | |
457 | ||
458 | ||
459 | /* GIMPLE_EH_FILTER */ | |
460 | ||
d1b38208 | 461 | struct GTY(()) gimple_statement_eh_filter { |
726a989a RB |
462 | /* [ WORD 1-4 ] */ |
463 | struct gimple_statement_base gsbase; | |
464 | ||
726a989a RB |
465 | /* [ WORD 5 ] |
466 | Filter types. */ | |
467 | tree types; | |
468 | ||
469 | /* [ WORD 6 ] | |
470 | Failure actions. */ | |
471 | gimple_seq failure; | |
472 | }; | |
473 | ||
474 | ||
1d65f45c RH |
475 | /* GIMPLE_EH_MUST_NOT_THROW */ |
476 | ||
477 | struct GTY(()) gimple_statement_eh_mnt { | |
478 | /* [ WORD 1-4 ] */ | |
479 | struct gimple_statement_base gsbase; | |
480 | ||
481 | /* [ WORD 5 ] Abort function decl. */ | |
482 | tree fndecl; | |
483 | }; | |
484 | ||
726a989a RB |
485 | /* GIMPLE_PHI */ |
486 | ||
d1b38208 | 487 | struct GTY(()) gimple_statement_phi { |
726a989a RB |
488 | /* [ WORD 1-4 ] */ |
489 | struct gimple_statement_base gsbase; | |
490 | ||
491 | /* [ WORD 5 ] */ | |
492 | unsigned capacity; | |
493 | unsigned nargs; | |
494 | ||
495 | /* [ WORD 6 ] */ | |
496 | tree result; | |
497 | ||
498 | /* [ WORD 7 ] */ | |
499 | struct phi_arg_d GTY ((length ("%h.nargs"))) args[1]; | |
500 | }; | |
501 | ||
502 | ||
1d65f45c | 503 | /* GIMPLE_RESX, GIMPLE_EH_DISPATCH */ |
726a989a | 504 | |
1d65f45c RH |
505 | struct GTY(()) gimple_statement_eh_ctrl |
506 | { | |
726a989a RB |
507 | /* [ WORD 1-4 ] */ |
508 | struct gimple_statement_base gsbase; | |
509 | ||
510 | /* [ WORD 5 ] | |
511 | Exception region number. */ | |
512 | int region; | |
513 | }; | |
514 | ||
515 | ||
516 | /* GIMPLE_TRY */ | |
517 | ||
d1b38208 | 518 | struct GTY(()) gimple_statement_try { |
726a989a RB |
519 | /* [ WORD 1-4 ] */ |
520 | struct gimple_statement_base gsbase; | |
521 | ||
522 | /* [ WORD 5 ] | |
523 | Expression to evaluate. */ | |
524 | gimple_seq eval; | |
525 | ||
526 | /* [ WORD 6 ] | |
527 | Cleanup expression. */ | |
528 | gimple_seq cleanup; | |
529 | }; | |
530 | ||
531 | /* Kind of GIMPLE_TRY statements. */ | |
532 | enum gimple_try_flags | |
533 | { | |
534 | /* A try/catch. */ | |
535 | GIMPLE_TRY_CATCH = 1 << 0, | |
536 | ||
537 | /* A try/finally. */ | |
538 | GIMPLE_TRY_FINALLY = 1 << 1, | |
539 | GIMPLE_TRY_KIND = GIMPLE_TRY_CATCH | GIMPLE_TRY_FINALLY, | |
540 | ||
541 | /* Analogous to TRY_CATCH_IS_CLEANUP. */ | |
542 | GIMPLE_TRY_CATCH_IS_CLEANUP = 1 << 2 | |
543 | }; | |
544 | ||
545 | /* GIMPLE_WITH_CLEANUP_EXPR */ | |
546 | ||
d1b38208 | 547 | struct GTY(()) gimple_statement_wce { |
726a989a RB |
548 | /* [ WORD 1-4 ] */ |
549 | struct gimple_statement_base gsbase; | |
550 | ||
551 | /* Subcode: CLEANUP_EH_ONLY. True if the cleanup should only be | |
552 | executed if an exception is thrown, not on normal exit of its | |
553 | scope. This flag is analogous to the CLEANUP_EH_ONLY flag | |
554 | in TARGET_EXPRs. */ | |
555 | ||
556 | /* [ WORD 5 ] | |
557 | Cleanup expression. */ | |
558 | gimple_seq cleanup; | |
559 | }; | |
560 | ||
561 | ||
562 | /* GIMPLE_ASM */ | |
563 | ||
d1b38208 | 564 | struct GTY(()) gimple_statement_asm |
726a989a | 565 | { |
ccacdf06 | 566 | /* [ WORD 1-8 ] */ |
726a989a RB |
567 | struct gimple_statement_with_memory_ops_base membase; |
568 | ||
ccacdf06 | 569 | /* [ WORD 9 ] |
726a989a RB |
570 | __asm__ statement. */ |
571 | const char *string; | |
572 | ||
ccacdf06 | 573 | /* [ WORD 10 ] |
1c384bf1 | 574 | Number of inputs, outputs, clobbers, labels. */ |
726a989a RB |
575 | unsigned char ni; |
576 | unsigned char no; | |
1c384bf1 RH |
577 | unsigned char nc; |
578 | unsigned char nl; | |
726a989a | 579 | |
ccacdf06 | 580 | /* [ WORD 11 ] |
726a989a RB |
581 | Operand vector. NOTE! This must always be the last field |
582 | of this structure. In particular, this means that this | |
583 | structure cannot be embedded inside another one. */ | |
584 | tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1]; | |
585 | }; | |
586 | ||
587 | /* GIMPLE_OMP_CRITICAL */ | |
588 | ||
d1b38208 | 589 | struct GTY(()) gimple_statement_omp_critical { |
726a989a RB |
590 | /* [ WORD 1-5 ] */ |
591 | struct gimple_statement_omp omp; | |
592 | ||
593 | /* [ WORD 6 ] | |
594 | Critical section name. */ | |
595 | tree name; | |
596 | }; | |
597 | ||
598 | ||
d1b38208 | 599 | struct GTY(()) gimple_omp_for_iter { |
726a989a RB |
600 | /* Condition code. */ |
601 | enum tree_code cond; | |
602 | ||
603 | /* Index variable. */ | |
604 | tree index; | |
b8698a0f | 605 | |
726a989a RB |
606 | /* Initial value. */ |
607 | tree initial; | |
608 | ||
609 | /* Final value. */ | |
610 | tree final; | |
b8698a0f | 611 | |
726a989a RB |
612 | /* Increment. */ |
613 | tree incr; | |
614 | }; | |
615 | ||
616 | /* GIMPLE_OMP_FOR */ | |
617 | ||
d1b38208 | 618 | struct GTY(()) gimple_statement_omp_for { |
726a989a RB |
619 | /* [ WORD 1-5 ] */ |
620 | struct gimple_statement_omp omp; | |
621 | ||
622 | /* [ WORD 6 ] */ | |
623 | tree clauses; | |
624 | ||
625 | /* [ WORD 7 ] | |
626 | Number of elements in iter array. */ | |
627 | size_t collapse; | |
628 | ||
629 | /* [ WORD 8 ] */ | |
630 | struct gimple_omp_for_iter * GTY((length ("%h.collapse"))) iter; | |
631 | ||
632 | /* [ WORD 9 ] | |
633 | Pre-body evaluated before the loop body begins. */ | |
634 | gimple_seq pre_body; | |
635 | }; | |
636 | ||
637 | ||
638 | /* GIMPLE_OMP_PARALLEL */ | |
639 | ||
d1b38208 | 640 | struct GTY(()) gimple_statement_omp_parallel { |
726a989a RB |
641 | /* [ WORD 1-5 ] */ |
642 | struct gimple_statement_omp omp; | |
643 | ||
644 | /* [ WORD 6 ] | |
645 | Clauses. */ | |
646 | tree clauses; | |
647 | ||
648 | /* [ WORD 7 ] | |
649 | Child function holding the body of the parallel region. */ | |
650 | tree child_fn; | |
651 | ||
652 | /* [ WORD 8 ] | |
653 | Shared data argument. */ | |
654 | tree data_arg; | |
655 | }; | |
656 | ||
657 | ||
658 | /* GIMPLE_OMP_TASK */ | |
659 | ||
d1b38208 | 660 | struct GTY(()) gimple_statement_omp_task { |
726a989a RB |
661 | /* [ WORD 1-8 ] */ |
662 | struct gimple_statement_omp_parallel par; | |
663 | ||
664 | /* [ WORD 9 ] | |
665 | Child function holding firstprivate initialization if needed. */ | |
666 | tree copy_fn; | |
667 | ||
668 | /* [ WORD 10-11 ] | |
669 | Size and alignment in bytes of the argument data block. */ | |
670 | tree arg_size; | |
671 | tree arg_align; | |
672 | }; | |
673 | ||
674 | ||
675 | /* GIMPLE_OMP_SECTION */ | |
676 | /* Uses struct gimple_statement_omp. */ | |
677 | ||
678 | ||
679 | /* GIMPLE_OMP_SECTIONS */ | |
680 | ||
d1b38208 | 681 | struct GTY(()) gimple_statement_omp_sections { |
726a989a RB |
682 | /* [ WORD 1-5 ] */ |
683 | struct gimple_statement_omp omp; | |
684 | ||
685 | /* [ WORD 6 ] */ | |
686 | tree clauses; | |
687 | ||
688 | /* [ WORD 7 ] | |
689 | The control variable used for deciding which of the sections to | |
690 | execute. */ | |
691 | tree control; | |
692 | }; | |
693 | ||
694 | /* GIMPLE_OMP_CONTINUE. | |
695 | ||
696 | Note: This does not inherit from gimple_statement_omp, because we | |
697 | do not need the body field. */ | |
698 | ||
d1b38208 | 699 | struct GTY(()) gimple_statement_omp_continue { |
726a989a RB |
700 | /* [ WORD 1-4 ] */ |
701 | struct gimple_statement_base gsbase; | |
702 | ||
703 | /* [ WORD 5 ] */ | |
704 | tree control_def; | |
705 | ||
706 | /* [ WORD 6 ] */ | |
707 | tree control_use; | |
708 | }; | |
709 | ||
710 | /* GIMPLE_OMP_SINGLE */ | |
711 | ||
d1b38208 | 712 | struct GTY(()) gimple_statement_omp_single { |
726a989a RB |
713 | /* [ WORD 1-5 ] */ |
714 | struct gimple_statement_omp omp; | |
715 | ||
716 | /* [ WORD 6 ] */ | |
717 | tree clauses; | |
718 | }; | |
719 | ||
720 | ||
b8698a0f | 721 | /* GIMPLE_OMP_ATOMIC_LOAD. |
726a989a RB |
722 | Note: This is based on gimple_statement_base, not g_s_omp, because g_s_omp |
723 | contains a sequence, which we don't need here. */ | |
724 | ||
d1b38208 | 725 | struct GTY(()) gimple_statement_omp_atomic_load { |
726a989a RB |
726 | /* [ WORD 1-4 ] */ |
727 | struct gimple_statement_base gsbase; | |
728 | ||
729 | /* [ WORD 5-6 ] */ | |
730 | tree rhs, lhs; | |
731 | }; | |
732 | ||
733 | /* GIMPLE_OMP_ATOMIC_STORE. | |
734 | See note on GIMPLE_OMP_ATOMIC_LOAD. */ | |
735 | ||
d1b38208 | 736 | struct GTY(()) gimple_statement_omp_atomic_store { |
726a989a RB |
737 | /* [ WORD 1-4 ] */ |
738 | struct gimple_statement_base gsbase; | |
739 | ||
740 | /* [ WORD 5 ] */ | |
741 | tree val; | |
742 | }; | |
743 | ||
f2c4a81c | 744 | #define DEFGSSTRUCT(SYM, STRUCT, HAS_TREE_OP) SYM, |
726a989a | 745 | enum gimple_statement_structure_enum { |
726a989a | 746 | #include "gsstruct.def" |
726a989a RB |
747 | LAST_GSS_ENUM |
748 | }; | |
f2c4a81c | 749 | #undef DEFGSSTRUCT |
726a989a RB |
750 | |
751 | ||
752 | /* Define the overall contents of a gimple tuple. It may be any of the | |
753 | structures declared above for various types of tuples. */ | |
754 | ||
a9429e29 | 755 | union GTY ((desc ("gimple_statement_structure (&%h)"), variable_size)) gimple_statement_d { |
726a989a RB |
756 | struct gimple_statement_base GTY ((tag ("GSS_BASE"))) gsbase; |
757 | struct gimple_statement_with_ops GTY ((tag ("GSS_WITH_OPS"))) gsops; | |
bb4efb4d | 758 | struct gimple_statement_with_memory_ops_base GTY ((tag ("GSS_WITH_MEM_OPS_BASE"))) gsmembase; |
726a989a | 759 | struct gimple_statement_with_memory_ops GTY ((tag ("GSS_WITH_MEM_OPS"))) gsmem; |
d086d311 | 760 | struct gimple_statement_call GTY ((tag ("GSS_CALL"))) gimple_call; |
726a989a RB |
761 | struct gimple_statement_omp GTY ((tag ("GSS_OMP"))) omp; |
762 | struct gimple_statement_bind GTY ((tag ("GSS_BIND"))) gimple_bind; | |
763 | struct gimple_statement_catch GTY ((tag ("GSS_CATCH"))) gimple_catch; | |
764 | struct gimple_statement_eh_filter GTY ((tag ("GSS_EH_FILTER"))) gimple_eh_filter; | |
1d65f45c | 765 | struct gimple_statement_eh_mnt GTY ((tag ("GSS_EH_MNT"))) gimple_eh_mnt; |
726a989a | 766 | struct gimple_statement_phi GTY ((tag ("GSS_PHI"))) gimple_phi; |
1d65f45c | 767 | struct gimple_statement_eh_ctrl GTY ((tag ("GSS_EH_CTRL"))) gimple_eh_ctrl; |
726a989a RB |
768 | struct gimple_statement_try GTY ((tag ("GSS_TRY"))) gimple_try; |
769 | struct gimple_statement_wce GTY ((tag ("GSS_WCE"))) gimple_wce; | |
770 | struct gimple_statement_asm GTY ((tag ("GSS_ASM"))) gimple_asm; | |
771 | struct gimple_statement_omp_critical GTY ((tag ("GSS_OMP_CRITICAL"))) gimple_omp_critical; | |
772 | struct gimple_statement_omp_for GTY ((tag ("GSS_OMP_FOR"))) gimple_omp_for; | |
773 | struct gimple_statement_omp_parallel GTY ((tag ("GSS_OMP_PARALLEL"))) gimple_omp_parallel; | |
774 | struct gimple_statement_omp_task GTY ((tag ("GSS_OMP_TASK"))) gimple_omp_task; | |
775 | struct gimple_statement_omp_sections GTY ((tag ("GSS_OMP_SECTIONS"))) gimple_omp_sections; | |
776 | struct gimple_statement_omp_single GTY ((tag ("GSS_OMP_SINGLE"))) gimple_omp_single; | |
777 | struct gimple_statement_omp_continue GTY ((tag ("GSS_OMP_CONTINUE"))) gimple_omp_continue; | |
778 | struct gimple_statement_omp_atomic_load GTY ((tag ("GSS_OMP_ATOMIC_LOAD"))) gimple_omp_atomic_load; | |
779 | struct gimple_statement_omp_atomic_store GTY ((tag ("GSS_OMP_ATOMIC_STORE"))) gimple_omp_atomic_store; | |
780 | }; | |
781 | ||
782 | /* In gimple.c. */ | |
f2c4a81c RH |
783 | |
784 | /* Offset in bytes to the location of the operand vector. | |
785 | Zero if there is no operand vector for this tuple structure. */ | |
786 | extern size_t const gimple_ops_offset_[]; | |
787 | ||
788 | /* Map GIMPLE codes to GSS codes. */ | |
789 | extern enum gimple_statement_structure_enum const gss_for_code_[]; | |
790 | ||
a5883ba0 MM |
791 | /* This variable holds the currently expanded gimple statement for purposes |
792 | of comminucating the profile info to the builtin expanders. */ | |
793 | extern gimple currently_expanding_gimple_stmt; | |
794 | ||
726a989a RB |
795 | gimple gimple_build_return (tree); |
796 | ||
797 | gimple gimple_build_assign_stat (tree, tree MEM_STAT_DECL); | |
798 | #define gimple_build_assign(l,r) gimple_build_assign_stat (l, r MEM_STAT_INFO) | |
799 | ||
800 | void extract_ops_from_tree (tree, enum tree_code *, tree *, tree *); | |
801 | ||
802 | gimple gimple_build_assign_with_ops_stat (enum tree_code, tree, tree, | |
803 | tree MEM_STAT_DECL); | |
804 | #define gimple_build_assign_with_ops(c,o1,o2,o3) \ | |
805 | gimple_build_assign_with_ops_stat (c, o1, o2, o3 MEM_STAT_INFO) | |
806 | ||
b5b8b0ac AO |
807 | gimple gimple_build_debug_bind_stat (tree, tree, gimple MEM_STAT_DECL); |
808 | #define gimple_build_debug_bind(var,val,stmt) \ | |
809 | gimple_build_debug_bind_stat ((var), (val), (stmt) MEM_STAT_INFO) | |
810 | ||
726a989a RB |
811 | gimple gimple_build_call_vec (tree, VEC(tree, heap) *); |
812 | gimple gimple_build_call (tree, unsigned, ...); | |
813 | gimple gimple_build_call_from_tree (tree); | |
814 | gimple gimplify_assign (tree, tree, gimple_seq *); | |
815 | gimple gimple_build_cond (enum tree_code, tree, tree, tree, tree); | |
816 | gimple gimple_build_label (tree label); | |
817 | gimple gimple_build_goto (tree dest); | |
818 | gimple gimple_build_nop (void); | |
819 | gimple gimple_build_bind (tree, gimple_seq, tree); | |
726a989a | 820 | gimple gimple_build_asm_vec (const char *, VEC(tree,gc) *, VEC(tree,gc) *, |
1c384bf1 | 821 | VEC(tree,gc) *, VEC(tree,gc) *); |
726a989a RB |
822 | gimple gimple_build_catch (tree, gimple_seq); |
823 | gimple gimple_build_eh_filter (tree, gimple_seq); | |
1d65f45c | 824 | gimple gimple_build_eh_must_not_throw (tree); |
cb4ad180 | 825 | gimple gimple_build_try (gimple_seq, gimple_seq, enum gimple_try_flags); |
726a989a RB |
826 | gimple gimple_build_wce (gimple_seq); |
827 | gimple gimple_build_resx (int); | |
1d65f45c RH |
828 | gimple gimple_build_eh_dispatch (int); |
829 | gimple gimple_build_switch_nlabels (unsigned, tree, tree); | |
726a989a RB |
830 | gimple gimple_build_switch (unsigned, tree, tree, ...); |
831 | gimple gimple_build_switch_vec (tree, tree, VEC(tree,heap) *); | |
832 | gimple gimple_build_omp_parallel (gimple_seq, tree, tree, tree); | |
833 | gimple gimple_build_omp_task (gimple_seq, tree, tree, tree, tree, tree, tree); | |
834 | gimple gimple_build_omp_for (gimple_seq, tree, size_t, gimple_seq); | |
835 | gimple gimple_build_omp_critical (gimple_seq, tree); | |
836 | gimple gimple_build_omp_section (gimple_seq); | |
837 | gimple gimple_build_omp_continue (tree, tree); | |
838 | gimple gimple_build_omp_master (gimple_seq); | |
839 | gimple gimple_build_omp_return (bool); | |
840 | gimple gimple_build_omp_ordered (gimple_seq); | |
841 | gimple gimple_build_omp_sections (gimple_seq, tree); | |
842 | gimple gimple_build_omp_sections_switch (void); | |
843 | gimple gimple_build_omp_single (gimple_seq, tree); | |
844 | gimple gimple_build_cdt (tree, tree); | |
845 | gimple gimple_build_omp_atomic_load (tree, tree); | |
846 | gimple gimple_build_omp_atomic_store (tree); | |
847 | gimple gimple_build_predict (enum br_predictor, enum prediction); | |
726a989a RB |
848 | enum gimple_statement_structure_enum gss_for_assign (enum tree_code); |
849 | void sort_case_labels (VEC(tree,heap) *); | |
850 | void gimple_set_body (tree, gimple_seq); | |
851 | gimple_seq gimple_body (tree); | |
39ecc018 | 852 | bool gimple_has_body_p (tree); |
726a989a RB |
853 | gimple_seq gimple_seq_alloc (void); |
854 | void gimple_seq_free (gimple_seq); | |
855 | void gimple_seq_add_seq (gimple_seq *, gimple_seq); | |
856 | gimple_seq gimple_seq_copy (gimple_seq); | |
857 | int gimple_call_flags (const_gimple); | |
0b7b376d RG |
858 | int gimple_call_return_flags (const_gimple); |
859 | int gimple_call_arg_flags (const_gimple, unsigned); | |
d086d311 | 860 | void gimple_call_reset_alias_info (gimple); |
726a989a RB |
861 | bool gimple_assign_copy_p (gimple); |
862 | bool gimple_assign_ssa_name_copy_p (gimple); | |
863 | bool gimple_assign_single_p (gimple); | |
864 | bool gimple_assign_unary_nop_p (gimple); | |
865 | void gimple_set_bb (gimple, struct basic_block_def *); | |
726a989a RB |
866 | void gimple_assign_set_rhs_from_tree (gimple_stmt_iterator *, tree); |
867 | void gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *, enum tree_code, | |
868 | tree, tree); | |
869 | tree gimple_get_lhs (const_gimple); | |
870 | void gimple_set_lhs (gimple, tree); | |
21cf7180 | 871 | void gimple_replace_lhs (gimple, tree); |
726a989a RB |
872 | gimple gimple_copy (gimple); |
873 | bool is_gimple_operand (const_tree); | |
874 | void gimple_set_modified (gimple, bool); | |
875 | void gimple_cond_get_ops_from_tree (tree, enum tree_code *, tree *, tree *); | |
876 | gimple gimple_build_cond_from_tree (tree, tree, tree); | |
877 | void gimple_cond_set_condition_from_tree (gimple, tree); | |
878 | bool gimple_has_side_effects (const_gimple); | |
879 | bool gimple_rhs_has_side_effects (const_gimple); | |
880 | bool gimple_could_trap_p (gimple); | |
881 | bool gimple_assign_rhs_could_trap_p (gimple); | |
882 | void gimple_regimplify_operands (gimple, gimple_stmt_iterator *); | |
883 | bool empty_body_p (gimple_seq); | |
884 | unsigned get_gimple_rhs_num_ops (enum tree_code); | |
d7f09764 DN |
885 | #define gimple_alloc(c, n) gimple_alloc_stat (c, n MEM_STAT_INFO) |
886 | gimple gimple_alloc_stat (enum gimple_code, unsigned MEM_STAT_DECL); | |
4537ec0c DN |
887 | const char *gimple_decl_printable_name (tree, int); |
888 | tree gimple_fold_obj_type_ref (tree, tree); | |
1ae6fe9b MJ |
889 | tree gimple_get_relevant_ref_binfo (tree ref, tree known_binfo); |
890 | tree gimple_fold_obj_type_ref_known_binfo (HOST_WIDE_INT, tree); | |
726a989a RB |
891 | |
892 | /* Returns true iff T is a valid GIMPLE statement. */ | |
893 | extern bool is_gimple_stmt (tree); | |
894 | ||
895 | /* Returns true iff TYPE is a valid type for a scalar register variable. */ | |
896 | extern bool is_gimple_reg_type (tree); | |
897 | /* Returns true iff T is a scalar register variable. */ | |
898 | extern bool is_gimple_reg (tree); | |
726a989a RB |
899 | /* Returns true iff T is any sort of variable. */ |
900 | extern bool is_gimple_variable (tree); | |
901 | /* Returns true iff T is any sort of symbol. */ | |
902 | extern bool is_gimple_id (tree); | |
903 | /* Returns true iff T is a variable or an INDIRECT_REF (of a variable). */ | |
904 | extern bool is_gimple_min_lval (tree); | |
905 | /* Returns true iff T is something whose address can be taken. */ | |
906 | extern bool is_gimple_addressable (tree); | |
907 | /* Returns true iff T is any valid GIMPLE lvalue. */ | |
908 | extern bool is_gimple_lvalue (tree); | |
909 | ||
910 | /* Returns true iff T is a GIMPLE address. */ | |
911 | bool is_gimple_address (const_tree); | |
912 | /* Returns true iff T is a GIMPLE invariant address. */ | |
913 | bool is_gimple_invariant_address (const_tree); | |
00fc2333 JH |
914 | /* Returns true iff T is a GIMPLE invariant address at interprocedural |
915 | level. */ | |
916 | bool is_gimple_ip_invariant_address (const_tree); | |
726a989a RB |
917 | /* Returns true iff T is a valid GIMPLE constant. */ |
918 | bool is_gimple_constant (const_tree); | |
919 | /* Returns true iff T is a GIMPLE restricted function invariant. */ | |
920 | extern bool is_gimple_min_invariant (const_tree); | |
00fc2333 JH |
921 | /* Returns true iff T is a GIMPLE restricted interprecodural invariant. */ |
922 | extern bool is_gimple_ip_invariant (const_tree); | |
726a989a RB |
923 | /* Returns true iff T is a GIMPLE rvalue. */ |
924 | extern bool is_gimple_val (tree); | |
925 | /* Returns true iff T is a GIMPLE asm statement input. */ | |
926 | extern bool is_gimple_asm_val (tree); | |
927 | /* Returns true iff T is a valid rhs for a MODIFY_EXPR where the LHS is a | |
928 | GIMPLE temporary, a renamed user variable, or something else, | |
929 | respectively. */ | |
726a989a RB |
930 | extern bool is_gimple_reg_rhs (tree); |
931 | extern bool is_gimple_mem_rhs (tree); | |
932 | ||
933 | /* Returns true iff T is a valid if-statement condition. */ | |
934 | extern bool is_gimple_condexpr (tree); | |
935 | ||
936 | /* Returns true iff T is a type conversion. */ | |
937 | extern bool is_gimple_cast (tree); | |
938 | /* Returns true iff T is a variable that does not need to live in memory. */ | |
939 | extern bool is_gimple_non_addressable (tree t); | |
940 | ||
941 | /* Returns true iff T is a valid call address expression. */ | |
942 | extern bool is_gimple_call_addr (tree); | |
943 | /* If T makes a function call, returns the CALL_EXPR operand. */ | |
944 | extern tree get_call_expr_in (tree t); | |
945 | ||
946 | extern void recalculate_side_effects (tree); | |
d025732d | 947 | extern bool gimple_compare_field_offset (tree, tree); |
d7f09764 DN |
948 | extern tree gimple_register_type (tree); |
949 | extern void print_gimple_types_stats (void); | |
0d0bfe17 | 950 | extern void free_gimple_type_tables (void); |
d7f09764 DN |
951 | extern tree gimple_unsigned_type (tree); |
952 | extern tree gimple_signed_type (tree); | |
953 | extern alias_set_type gimple_get_alias_set (tree); | |
5006671f RG |
954 | extern void count_uses_and_derefs (tree, gimple, unsigned *, unsigned *, |
955 | unsigned *); | |
346ef3fa RG |
956 | extern bool walk_stmt_load_store_addr_ops (gimple, void *, |
957 | bool (*)(gimple, tree, void *), | |
958 | bool (*)(gimple, tree, void *), | |
959 | bool (*)(gimple, tree, void *)); | |
960 | extern bool walk_stmt_load_store_ops (gimple, void *, | |
961 | bool (*)(gimple, tree, void *), | |
962 | bool (*)(gimple, tree, void *)); | |
ccacdf06 | 963 | extern bool gimple_ior_addresses_taken (bitmap, gimple); |
c54c785d | 964 | extern bool gimple_call_builtin_p (gimple, enum built_in_function); |
726a989a RB |
965 | |
966 | /* In gimplify.c */ | |
967 | extern tree create_tmp_var_raw (tree, const char *); | |
968 | extern tree create_tmp_var_name (const char *); | |
969 | extern tree create_tmp_var (tree, const char *); | |
acd63801 | 970 | extern tree create_tmp_reg (tree, const char *); |
726a989a RB |
971 | extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq *); |
972 | extern tree get_formal_tmp_var (tree, gimple_seq *); | |
973 | extern void declare_vars (tree, gimple, bool); | |
726a989a RB |
974 | extern void annotate_all_with_location (gimple_seq, location_t); |
975 | ||
976 | /* Validation of GIMPLE expressions. Note that these predicates only check | |
977 | the basic form of the expression, they don't recurse to make sure that | |
978 | underlying nodes are also of the right form. */ | |
979 | typedef bool (*gimple_predicate)(tree); | |
980 | ||
981 | ||
982 | /* FIXME we should deduce this from the predicate. */ | |
bbbbb16a | 983 | enum fallback { |
726a989a RB |
984 | fb_none = 0, /* Do not generate a temporary. */ |
985 | ||
986 | fb_rvalue = 1, /* Generate an rvalue to hold the result of a | |
987 | gimplified expression. */ | |
988 | ||
989 | fb_lvalue = 2, /* Generate an lvalue to hold the result of a | |
990 | gimplified expression. */ | |
991 | ||
992 | fb_mayfail = 4, /* Gimplification may fail. Error issued | |
993 | afterwards. */ | |
994 | fb_either= fb_rvalue | fb_lvalue | |
bbbbb16a ILT |
995 | }; |
996 | ||
997 | typedef int fallback_t; | |
726a989a RB |
998 | |
999 | enum gimplify_status { | |
1000 | GS_ERROR = -2, /* Something Bad Seen. */ | |
1001 | GS_UNHANDLED = -1, /* A langhook result for "I dunno". */ | |
1002 | GS_OK = 0, /* We did something, maybe more to do. */ | |
1003 | GS_ALL_DONE = 1 /* The expression is fully gimplified. */ | |
1004 | }; | |
1005 | ||
1006 | struct gimplify_ctx | |
1007 | { | |
1008 | struct gimplify_ctx *prev_context; | |
1009 | ||
1010 | VEC(gimple,heap) *bind_expr_stack; | |
1011 | tree temps; | |
1012 | gimple_seq conditional_cleanups; | |
1013 | tree exit_label; | |
1014 | tree return_temp; | |
b8698a0f | 1015 | |
726a989a RB |
1016 | VEC(tree,heap) *case_labels; |
1017 | /* The formal temporary table. Should this be persistent? */ | |
1018 | htab_t temp_htab; | |
1019 | ||
1020 | int conditions; | |
1021 | bool save_stack; | |
1022 | bool into_ssa; | |
1023 | bool allow_rhs_cond_expr; | |
1024 | }; | |
1025 | ||
1026 | extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *, | |
1027 | bool (*) (tree), fallback_t); | |
1028 | extern void gimplify_type_sizes (tree, gimple_seq *); | |
1029 | extern void gimplify_one_sizepos (tree *, gimple_seq *); | |
1030 | extern bool gimplify_stmt (tree *, gimple_seq *); | |
1031 | extern gimple gimplify_body (tree *, tree, bool); | |
1032 | extern void push_gimplify_context (struct gimplify_ctx *); | |
1033 | extern void pop_gimplify_context (gimple); | |
1034 | extern void gimplify_and_add (tree, gimple_seq *); | |
1035 | ||
1036 | /* Miscellaneous helpers. */ | |
1037 | extern void gimple_add_tmp_var (tree); | |
1038 | extern gimple gimple_current_bind_expr (void); | |
1039 | extern VEC(gimple, heap) *gimple_bind_expr_stack (void); | |
1040 | extern tree voidify_wrapper_expr (tree, tree); | |
1041 | extern tree build_and_jump (tree *); | |
726a989a RB |
1042 | extern tree force_labels_r (tree *, int *, void *); |
1043 | extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *, | |
1044 | gimple_seq *); | |
1045 | struct gimplify_omp_ctx; | |
1046 | extern void omp_firstprivatize_variable (struct gimplify_omp_ctx *, tree); | |
1047 | extern tree gimple_boolify (tree); | |
1048 | extern gimple_predicate rhs_predicate_for (tree); | |
1049 | extern tree canonicalize_cond_expr_cond (tree); | |
1050 | ||
1051 | /* In omp-low.c. */ | |
726a989a RB |
1052 | extern tree omp_reduction_init (tree, tree); |
1053 | ||
1054 | /* In tree-nested.c. */ | |
1055 | extern void lower_nested_functions (tree); | |
1056 | extern void insert_field_into_struct (tree, tree); | |
1057 | ||
1058 | /* In gimplify.c. */ | |
1059 | extern void gimplify_function_tree (tree); | |
1060 | ||
1061 | /* In cfgexpand.c. */ | |
1062 | extern tree gimple_assign_rhs_to_tree (gimple); | |
1063 | ||
1064 | /* In builtins.c */ | |
1065 | extern bool validate_gimple_arglist (const_gimple, ...); | |
1066 | ||
4d2ad64c RG |
1067 | /* In tree-ssa.c */ |
1068 | extern bool tree_ssa_useless_type_conversion (tree); | |
23314e77 | 1069 | extern tree tree_ssa_strip_useless_type_conversions (tree); |
4d2ad64c RG |
1070 | extern bool useless_type_conversion_p (tree, tree); |
1071 | extern bool types_compatible_p (tree, tree); | |
1072 | ||
726a989a RB |
1073 | /* Return the code for GIMPLE statement G. */ |
1074 | ||
1075 | static inline enum gimple_code | |
1076 | gimple_code (const_gimple g) | |
1077 | { | |
1078 | return g->gsbase.code; | |
1079 | } | |
1080 | ||
1081 | ||
f2c4a81c RH |
1082 | /* Return the GSS code used by a GIMPLE code. */ |
1083 | ||
1084 | static inline enum gimple_statement_structure_enum | |
1085 | gss_for_code (enum gimple_code code) | |
1086 | { | |
f68a75df | 1087 | #ifdef ENABLE_CHECKING |
f2c4a81c | 1088 | gcc_assert ((unsigned int)code < LAST_AND_UNUSED_GIMPLE_CODE); |
f68a75df | 1089 | #endif |
f2c4a81c RH |
1090 | return gss_for_code_[code]; |
1091 | } | |
1092 | ||
1093 | ||
1094 | /* Return which GSS code is used by GS. */ | |
1095 | ||
1096 | static inline enum gimple_statement_structure_enum | |
1097 | gimple_statement_structure (gimple gs) | |
1098 | { | |
1099 | return gss_for_code (gimple_code (gs)); | |
1100 | } | |
1101 | ||
1102 | ||
726a989a RB |
1103 | /* Return true if statement G has sub-statements. This is only true for |
1104 | High GIMPLE statements. */ | |
1105 | ||
1106 | static inline bool | |
1107 | gimple_has_substatements (gimple g) | |
1108 | { | |
1109 | switch (gimple_code (g)) | |
1110 | { | |
1111 | case GIMPLE_BIND: | |
1112 | case GIMPLE_CATCH: | |
1113 | case GIMPLE_EH_FILTER: | |
1114 | case GIMPLE_TRY: | |
1115 | case GIMPLE_OMP_FOR: | |
1116 | case GIMPLE_OMP_MASTER: | |
1117 | case GIMPLE_OMP_ORDERED: | |
1118 | case GIMPLE_OMP_SECTION: | |
1119 | case GIMPLE_OMP_PARALLEL: | |
1120 | case GIMPLE_OMP_TASK: | |
1121 | case GIMPLE_OMP_SECTIONS: | |
1122 | case GIMPLE_OMP_SINGLE: | |
05a26161 | 1123 | case GIMPLE_OMP_CRITICAL: |
726a989a RB |
1124 | case GIMPLE_WITH_CLEANUP_EXPR: |
1125 | return true; | |
1126 | ||
1127 | default: | |
1128 | return false; | |
1129 | } | |
1130 | } | |
b8698a0f | 1131 | |
726a989a RB |
1132 | |
1133 | /* Return the basic block holding statement G. */ | |
1134 | ||
1135 | static inline struct basic_block_def * | |
1136 | gimple_bb (const_gimple g) | |
1137 | { | |
1138 | return g->gsbase.bb; | |
1139 | } | |
1140 | ||
1141 | ||
1142 | /* Return the lexical scope block holding statement G. */ | |
1143 | ||
1144 | static inline tree | |
1145 | gimple_block (const_gimple g) | |
1146 | { | |
1147 | return g->gsbase.block; | |
1148 | } | |
1149 | ||
1150 | ||
1151 | /* Set BLOCK to be the lexical scope block holding statement G. */ | |
1152 | ||
1153 | static inline void | |
1154 | gimple_set_block (gimple g, tree block) | |
1155 | { | |
1156 | g->gsbase.block = block; | |
1157 | } | |
1158 | ||
1159 | ||
1160 | /* Return location information for statement G. */ | |
1161 | ||
1162 | static inline location_t | |
1163 | gimple_location (const_gimple g) | |
1164 | { | |
1165 | return g->gsbase.location; | |
1166 | } | |
1167 | ||
1168 | /* Return pointer to location information for statement G. */ | |
1169 | ||
1170 | static inline const location_t * | |
1171 | gimple_location_ptr (const_gimple g) | |
1172 | { | |
1173 | return &g->gsbase.location; | |
1174 | } | |
1175 | ||
1176 | ||
1177 | /* Set location information for statement G. */ | |
1178 | ||
1179 | static inline void | |
1180 | gimple_set_location (gimple g, location_t location) | |
1181 | { | |
1182 | g->gsbase.location = location; | |
1183 | } | |
1184 | ||
1185 | ||
1186 | /* Return true if G contains location information. */ | |
1187 | ||
1188 | static inline bool | |
1189 | gimple_has_location (const_gimple g) | |
1190 | { | |
1191 | return gimple_location (g) != UNKNOWN_LOCATION; | |
1192 | } | |
1193 | ||
1194 | ||
1195 | /* Return the file name of the location of STMT. */ | |
1196 | ||
1197 | static inline const char * | |
1198 | gimple_filename (const_gimple stmt) | |
1199 | { | |
1200 | return LOCATION_FILE (gimple_location (stmt)); | |
1201 | } | |
1202 | ||
1203 | ||
1204 | /* Return the line number of the location of STMT. */ | |
1205 | ||
1206 | static inline int | |
1207 | gimple_lineno (const_gimple stmt) | |
1208 | { | |
1209 | return LOCATION_LINE (gimple_location (stmt)); | |
1210 | } | |
1211 | ||
1212 | ||
1213 | /* Determine whether SEQ is a singleton. */ | |
1214 | ||
1215 | static inline bool | |
1216 | gimple_seq_singleton_p (gimple_seq seq) | |
1217 | { | |
1218 | return ((gimple_seq_first (seq) != NULL) | |
1219 | && (gimple_seq_first (seq) == gimple_seq_last (seq))); | |
1220 | } | |
1221 | ||
1222 | /* Return true if no warnings should be emitted for statement STMT. */ | |
1223 | ||
1224 | static inline bool | |
1225 | gimple_no_warning_p (const_gimple stmt) | |
1226 | { | |
1227 | return stmt->gsbase.no_warning; | |
1228 | } | |
1229 | ||
1230 | /* Set the no_warning flag of STMT to NO_WARNING. */ | |
1231 | ||
1232 | static inline void | |
1233 | gimple_set_no_warning (gimple stmt, bool no_warning) | |
1234 | { | |
1235 | stmt->gsbase.no_warning = (unsigned) no_warning; | |
1236 | } | |
1237 | ||
1238 | /* Set the visited status on statement STMT to VISITED_P. */ | |
1239 | ||
1240 | static inline void | |
1241 | gimple_set_visited (gimple stmt, bool visited_p) | |
1242 | { | |
1243 | stmt->gsbase.visited = (unsigned) visited_p; | |
1244 | } | |
1245 | ||
1246 | ||
1247 | /* Return the visited status for statement STMT. */ | |
1248 | ||
1249 | static inline bool | |
1250 | gimple_visited_p (gimple stmt) | |
1251 | { | |
1252 | return stmt->gsbase.visited; | |
1253 | } | |
1254 | ||
1255 | ||
1256 | /* Set pass local flag PLF on statement STMT to VAL_P. */ | |
1257 | ||
1258 | static inline void | |
1259 | gimple_set_plf (gimple stmt, enum plf_mask plf, bool val_p) | |
1260 | { | |
1261 | if (val_p) | |
1262 | stmt->gsbase.plf |= (unsigned int) plf; | |
1263 | else | |
1264 | stmt->gsbase.plf &= ~((unsigned int) plf); | |
1265 | } | |
1266 | ||
1267 | ||
1268 | /* Return the value of pass local flag PLF on statement STMT. */ | |
1269 | ||
1270 | static inline unsigned int | |
1271 | gimple_plf (gimple stmt, enum plf_mask plf) | |
1272 | { | |
1273 | return stmt->gsbase.plf & ((unsigned int) plf); | |
1274 | } | |
1275 | ||
1276 | ||
e0e10d3a | 1277 | /* Set the UID of statement. */ |
726a989a RB |
1278 | |
1279 | static inline void | |
1280 | gimple_set_uid (gimple g, unsigned uid) | |
1281 | { | |
1282 | g->gsbase.uid = uid; | |
1283 | } | |
1284 | ||
1285 | ||
e0e10d3a | 1286 | /* Return the UID of statement. */ |
726a989a RB |
1287 | |
1288 | static inline unsigned | |
1289 | gimple_uid (const_gimple g) | |
1290 | { | |
1291 | return g->gsbase.uid; | |
1292 | } | |
1293 | ||
1294 | ||
1295 | /* Return true if GIMPLE statement G has register or memory operands. */ | |
1296 | ||
1297 | static inline bool | |
1298 | gimple_has_ops (const_gimple g) | |
1299 | { | |
1300 | return gimple_code (g) >= GIMPLE_COND && gimple_code (g) <= GIMPLE_RETURN; | |
1301 | } | |
1302 | ||
1303 | ||
1304 | /* Return true if GIMPLE statement G has memory operands. */ | |
1305 | ||
1306 | static inline bool | |
1307 | gimple_has_mem_ops (const_gimple g) | |
1308 | { | |
1309 | return gimple_code (g) >= GIMPLE_ASSIGN && gimple_code (g) <= GIMPLE_RETURN; | |
1310 | } | |
1311 | ||
726a989a RB |
1312 | |
1313 | /* Return the set of DEF operands for statement G. */ | |
1314 | ||
1315 | static inline struct def_optype_d * | |
1316 | gimple_def_ops (const_gimple g) | |
1317 | { | |
1318 | if (!gimple_has_ops (g)) | |
1319 | return NULL; | |
1320 | return g->gsops.opbase.def_ops; | |
1321 | } | |
1322 | ||
1323 | ||
1324 | /* Set DEF to be the set of DEF operands for statement G. */ | |
1325 | ||
1326 | static inline void | |
1327 | gimple_set_def_ops (gimple g, struct def_optype_d *def) | |
1328 | { | |
1329 | gcc_assert (gimple_has_ops (g)); | |
1330 | g->gsops.opbase.def_ops = def; | |
1331 | } | |
1332 | ||
1333 | ||
1334 | /* Return the set of USE operands for statement G. */ | |
1335 | ||
1336 | static inline struct use_optype_d * | |
1337 | gimple_use_ops (const_gimple g) | |
1338 | { | |
1339 | if (!gimple_has_ops (g)) | |
1340 | return NULL; | |
1341 | return g->gsops.opbase.use_ops; | |
1342 | } | |
1343 | ||
1344 | ||
1345 | /* Set USE to be the set of USE operands for statement G. */ | |
1346 | ||
1347 | static inline void | |
1348 | gimple_set_use_ops (gimple g, struct use_optype_d *use) | |
1349 | { | |
1350 | gcc_assert (gimple_has_ops (g)); | |
1351 | g->gsops.opbase.use_ops = use; | |
1352 | } | |
1353 | ||
1354 | ||
5006671f | 1355 | /* Return the set of VUSE operand for statement G. */ |
726a989a | 1356 | |
5006671f RG |
1357 | static inline use_operand_p |
1358 | gimple_vuse_op (const_gimple g) | |
726a989a | 1359 | { |
5006671f | 1360 | struct use_optype_d *ops; |
726a989a | 1361 | if (!gimple_has_mem_ops (g)) |
5006671f RG |
1362 | return NULL_USE_OPERAND_P; |
1363 | ops = g->gsops.opbase.use_ops; | |
1364 | if (ops | |
bb4efb4d | 1365 | && USE_OP_PTR (ops)->use == &g->gsmembase.vuse) |
5006671f RG |
1366 | return USE_OP_PTR (ops); |
1367 | return NULL_USE_OPERAND_P; | |
726a989a RB |
1368 | } |
1369 | ||
5006671f | 1370 | /* Return the set of VDEF operand for statement G. */ |
726a989a | 1371 | |
5006671f RG |
1372 | static inline def_operand_p |
1373 | gimple_vdef_op (const_gimple g) | |
726a989a | 1374 | { |
5006671f RG |
1375 | struct def_optype_d *ops; |
1376 | if (!gimple_has_mem_ops (g)) | |
1377 | return NULL_DEF_OPERAND_P; | |
1378 | ops = g->gsops.opbase.def_ops; | |
1379 | if (ops | |
bb4efb4d | 1380 | && DEF_OP_PTR (ops) == &g->gsmembase.vdef) |
5006671f RG |
1381 | return DEF_OP_PTR (ops); |
1382 | return NULL_DEF_OPERAND_P; | |
726a989a RB |
1383 | } |
1384 | ||
1385 | ||
5006671f | 1386 | /* Return the single VUSE operand of the statement G. */ |
726a989a | 1387 | |
5006671f RG |
1388 | static inline tree |
1389 | gimple_vuse (const_gimple g) | |
726a989a RB |
1390 | { |
1391 | if (!gimple_has_mem_ops (g)) | |
5006671f | 1392 | return NULL_TREE; |
bb4efb4d | 1393 | return g->gsmembase.vuse; |
726a989a RB |
1394 | } |
1395 | ||
5006671f | 1396 | /* Return the single VDEF operand of the statement G. */ |
726a989a | 1397 | |
5006671f RG |
1398 | static inline tree |
1399 | gimple_vdef (const_gimple g) | |
726a989a | 1400 | { |
5006671f RG |
1401 | if (!gimple_has_mem_ops (g)) |
1402 | return NULL_TREE; | |
bb4efb4d | 1403 | return g->gsmembase.vdef; |
726a989a RB |
1404 | } |
1405 | ||
5006671f | 1406 | /* Return the single VUSE operand of the statement G. */ |
726a989a | 1407 | |
5006671f RG |
1408 | static inline tree * |
1409 | gimple_vuse_ptr (gimple g) | |
726a989a RB |
1410 | { |
1411 | if (!gimple_has_mem_ops (g)) | |
1412 | return NULL; | |
bb4efb4d | 1413 | return &g->gsmembase.vuse; |
726a989a RB |
1414 | } |
1415 | ||
5006671f | 1416 | /* Return the single VDEF operand of the statement G. */ |
726a989a | 1417 | |
5006671f RG |
1418 | static inline tree * |
1419 | gimple_vdef_ptr (gimple g) | |
726a989a RB |
1420 | { |
1421 | if (!gimple_has_mem_ops (g)) | |
1422 | return NULL; | |
bb4efb4d | 1423 | return &g->gsmembase.vdef; |
5006671f RG |
1424 | } |
1425 | ||
1426 | /* Set the single VUSE operand of the statement G. */ | |
1427 | ||
1428 | static inline void | |
1429 | gimple_set_vuse (gimple g, tree vuse) | |
1430 | { | |
1431 | gcc_assert (gimple_has_mem_ops (g)); | |
bb4efb4d | 1432 | g->gsmembase.vuse = vuse; |
5006671f RG |
1433 | } |
1434 | ||
1435 | /* Set the single VDEF operand of the statement G. */ | |
1436 | ||
1437 | static inline void | |
1438 | gimple_set_vdef (gimple g, tree vdef) | |
1439 | { | |
1440 | gcc_assert (gimple_has_mem_ops (g)); | |
bb4efb4d | 1441 | g->gsmembase.vdef = vdef; |
726a989a RB |
1442 | } |
1443 | ||
1444 | ||
1445 | /* Return true if statement G has operands and the modified field has | |
1446 | been set. */ | |
1447 | ||
1448 | static inline bool | |
1449 | gimple_modified_p (const_gimple g) | |
1450 | { | |
1451 | return (gimple_has_ops (g)) ? (bool) g->gsbase.modified : false; | |
1452 | } | |
1453 | ||
726a989a RB |
1454 | |
1455 | /* Return the tree code for the expression computed by STMT. This is | |
1456 | only valid for GIMPLE_COND, GIMPLE_CALL and GIMPLE_ASSIGN. For | |
1457 | GIMPLE_CALL, return CALL_EXPR as the expression code for | |
1458 | consistency. This is useful when the caller needs to deal with the | |
1459 | three kinds of computation that GIMPLE supports. */ | |
1460 | ||
1461 | static inline enum tree_code | |
1462 | gimple_expr_code (const_gimple stmt) | |
1463 | { | |
1464 | enum gimple_code code = gimple_code (stmt); | |
1465 | if (code == GIMPLE_ASSIGN || code == GIMPLE_COND) | |
1466 | return (enum tree_code) stmt->gsbase.subcode; | |
1467 | else if (code == GIMPLE_CALL) | |
1468 | return CALL_EXPR; | |
1469 | else | |
1470 | gcc_unreachable (); | |
1471 | } | |
1472 | ||
1473 | ||
1474 | /* Mark statement S as modified, and update it. */ | |
1475 | ||
1476 | static inline void | |
1477 | update_stmt (gimple s) | |
1478 | { | |
1479 | if (gimple_has_ops (s)) | |
1480 | { | |
1481 | gimple_set_modified (s, true); | |
1482 | update_stmt_operands (s); | |
1483 | } | |
1484 | } | |
1485 | ||
1486 | /* Update statement S if it has been optimized. */ | |
1487 | ||
1488 | static inline void | |
1489 | update_stmt_if_modified (gimple s) | |
1490 | { | |
1491 | if (gimple_modified_p (s)) | |
1492 | update_stmt_operands (s); | |
1493 | } | |
1494 | ||
1495 | /* Return true if statement STMT contains volatile operands. */ | |
1496 | ||
1497 | static inline bool | |
1498 | gimple_has_volatile_ops (const_gimple stmt) | |
1499 | { | |
1500 | if (gimple_has_mem_ops (stmt)) | |
1501 | return stmt->gsbase.has_volatile_ops; | |
1502 | else | |
1503 | return false; | |
1504 | } | |
1505 | ||
1506 | ||
1507 | /* Set the HAS_VOLATILE_OPS flag to VOLATILEP. */ | |
1508 | ||
1509 | static inline void | |
1510 | gimple_set_has_volatile_ops (gimple stmt, bool volatilep) | |
1511 | { | |
1512 | if (gimple_has_mem_ops (stmt)) | |
1513 | stmt->gsbase.has_volatile_ops = (unsigned) volatilep; | |
1514 | } | |
1515 | ||
1516 | ||
1517 | /* Return true if statement STMT may access memory. */ | |
1518 | ||
1519 | static inline bool | |
1520 | gimple_references_memory_p (gimple stmt) | |
1521 | { | |
5006671f | 1522 | return gimple_has_mem_ops (stmt) && gimple_vuse (stmt); |
726a989a RB |
1523 | } |
1524 | ||
1525 | ||
726a989a RB |
1526 | /* Return the subcode for OMP statement S. */ |
1527 | ||
1528 | static inline unsigned | |
1529 | gimple_omp_subcode (const_gimple s) | |
1530 | { | |
1531 | gcc_assert (gimple_code (s) >= GIMPLE_OMP_ATOMIC_LOAD | |
1532 | && gimple_code (s) <= GIMPLE_OMP_SINGLE); | |
1533 | return s->gsbase.subcode; | |
1534 | } | |
1535 | ||
1536 | /* Set the subcode for OMP statement S to SUBCODE. */ | |
1537 | ||
1538 | static inline void | |
1539 | gimple_omp_set_subcode (gimple s, unsigned int subcode) | |
1540 | { | |
1541 | /* We only have 16 bits for the subcode. Assert that we are not | |
1542 | overflowing it. */ | |
1543 | gcc_assert (subcode < (1 << 16)); | |
1544 | s->gsbase.subcode = subcode; | |
1545 | } | |
1546 | ||
1547 | /* Set the nowait flag on OMP_RETURN statement S. */ | |
1548 | ||
1549 | static inline void | |
1550 | gimple_omp_return_set_nowait (gimple s) | |
1551 | { | |
1552 | GIMPLE_CHECK (s, GIMPLE_OMP_RETURN); | |
1553 | s->gsbase.subcode |= GF_OMP_RETURN_NOWAIT; | |
1554 | } | |
1555 | ||
1556 | ||
1557 | /* Return true if OMP return statement G has the GF_OMP_RETURN_NOWAIT | |
1558 | flag set. */ | |
1559 | ||
1560 | static inline bool | |
1561 | gimple_omp_return_nowait_p (const_gimple g) | |
1562 | { | |
1563 | GIMPLE_CHECK (g, GIMPLE_OMP_RETURN); | |
1564 | return (gimple_omp_subcode (g) & GF_OMP_RETURN_NOWAIT) != 0; | |
1565 | } | |
1566 | ||
1567 | ||
1568 | /* Return true if OMP section statement G has the GF_OMP_SECTION_LAST | |
1569 | flag set. */ | |
1570 | ||
1571 | static inline bool | |
1572 | gimple_omp_section_last_p (const_gimple g) | |
1573 | { | |
1574 | GIMPLE_CHECK (g, GIMPLE_OMP_SECTION); | |
1575 | return (gimple_omp_subcode (g) & GF_OMP_SECTION_LAST) != 0; | |
1576 | } | |
1577 | ||
1578 | ||
1579 | /* Set the GF_OMP_SECTION_LAST flag on G. */ | |
1580 | ||
1581 | static inline void | |
1582 | gimple_omp_section_set_last (gimple g) | |
1583 | { | |
1584 | GIMPLE_CHECK (g, GIMPLE_OMP_SECTION); | |
1585 | g->gsbase.subcode |= GF_OMP_SECTION_LAST; | |
1586 | } | |
1587 | ||
1588 | ||
1589 | /* Return true if OMP parallel statement G has the | |
1590 | GF_OMP_PARALLEL_COMBINED flag set. */ | |
1591 | ||
1592 | static inline bool | |
1593 | gimple_omp_parallel_combined_p (const_gimple g) | |
1594 | { | |
1595 | GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL); | |
1596 | return (gimple_omp_subcode (g) & GF_OMP_PARALLEL_COMBINED) != 0; | |
1597 | } | |
1598 | ||
1599 | ||
1600 | /* Set the GF_OMP_PARALLEL_COMBINED field in G depending on the boolean | |
1601 | value of COMBINED_P. */ | |
1602 | ||
1603 | static inline void | |
1604 | gimple_omp_parallel_set_combined_p (gimple g, bool combined_p) | |
1605 | { | |
1606 | GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL); | |
1607 | if (combined_p) | |
1608 | g->gsbase.subcode |= GF_OMP_PARALLEL_COMBINED; | |
1609 | else | |
1610 | g->gsbase.subcode &= ~GF_OMP_PARALLEL_COMBINED; | |
1611 | } | |
1612 | ||
1613 | ||
1614 | /* Return the number of operands for statement GS. */ | |
1615 | ||
1616 | static inline unsigned | |
1617 | gimple_num_ops (const_gimple gs) | |
1618 | { | |
1619 | return gs->gsbase.num_ops; | |
1620 | } | |
1621 | ||
1622 | ||
1623 | /* Set the number of operands for statement GS. */ | |
1624 | ||
1625 | static inline void | |
1626 | gimple_set_num_ops (gimple gs, unsigned num_ops) | |
1627 | { | |
1628 | gs->gsbase.num_ops = num_ops; | |
1629 | } | |
1630 | ||
1631 | ||
1632 | /* Return the array of operands for statement GS. */ | |
1633 | ||
1634 | static inline tree * | |
1635 | gimple_ops (gimple gs) | |
1636 | { | |
f2c4a81c | 1637 | size_t off; |
726a989a RB |
1638 | |
1639 | /* All the tuples have their operand vector at the very bottom | |
f2c4a81c RH |
1640 | of the structure. Note that those structures that do not |
1641 | have an operand vector have a zero offset. */ | |
1642 | off = gimple_ops_offset_[gimple_statement_structure (gs)]; | |
1643 | gcc_assert (off != 0); | |
1644 | ||
1645 | return (tree *) ((char *) gs + off); | |
726a989a RB |
1646 | } |
1647 | ||
1648 | ||
1649 | /* Return operand I for statement GS. */ | |
1650 | ||
1651 | static inline tree | |
1652 | gimple_op (const_gimple gs, unsigned i) | |
1653 | { | |
1654 | if (gimple_has_ops (gs)) | |
1655 | { | |
f68a75df | 1656 | #ifdef ENABLE_CHECKING |
726a989a | 1657 | gcc_assert (i < gimple_num_ops (gs)); |
f68a75df | 1658 | #endif |
726a989a RB |
1659 | return gimple_ops (CONST_CAST_GIMPLE (gs))[i]; |
1660 | } | |
1661 | else | |
1662 | return NULL_TREE; | |
1663 | } | |
1664 | ||
1665 | /* Return a pointer to operand I for statement GS. */ | |
1666 | ||
1667 | static inline tree * | |
1668 | gimple_op_ptr (const_gimple gs, unsigned i) | |
1669 | { | |
1670 | if (gimple_has_ops (gs)) | |
1671 | { | |
f68a75df | 1672 | #ifdef ENABLE_CHECKING |
726a989a | 1673 | gcc_assert (i < gimple_num_ops (gs)); |
f68a75df | 1674 | #endif |
726a989a RB |
1675 | return gimple_ops (CONST_CAST_GIMPLE (gs)) + i; |
1676 | } | |
1677 | else | |
1678 | return NULL; | |
1679 | } | |
1680 | ||
1681 | /* Set operand I of statement GS to OP. */ | |
1682 | ||
1683 | static inline void | |
1684 | gimple_set_op (gimple gs, unsigned i, tree op) | |
1685 | { | |
1686 | gcc_assert (gimple_has_ops (gs) && i < gimple_num_ops (gs)); | |
1687 | ||
1688 | /* Note. It may be tempting to assert that OP matches | |
1689 | is_gimple_operand, but that would be wrong. Different tuples | |
1690 | accept slightly different sets of tree operands. Each caller | |
1691 | should perform its own validation. */ | |
1692 | gimple_ops (gs)[i] = op; | |
1693 | } | |
1694 | ||
1695 | /* Return true if GS is a GIMPLE_ASSIGN. */ | |
1696 | ||
1697 | static inline bool | |
1698 | is_gimple_assign (const_gimple gs) | |
1699 | { | |
1700 | return gimple_code (gs) == GIMPLE_ASSIGN; | |
1701 | } | |
1702 | ||
1703 | /* Determine if expression CODE is one of the valid expressions that can | |
1704 | be used on the RHS of GIMPLE assignments. */ | |
1705 | ||
1706 | static inline enum gimple_rhs_class | |
1707 | get_gimple_rhs_class (enum tree_code code) | |
1708 | { | |
1709 | return (enum gimple_rhs_class) gimple_rhs_class_table[(int) code]; | |
1710 | } | |
1711 | ||
1712 | /* Return the LHS of assignment statement GS. */ | |
1713 | ||
1714 | static inline tree | |
1715 | gimple_assign_lhs (const_gimple gs) | |
1716 | { | |
1717 | GIMPLE_CHECK (gs, GIMPLE_ASSIGN); | |
1718 | return gimple_op (gs, 0); | |
1719 | } | |
1720 | ||
1721 | ||
1722 | /* Return a pointer to the LHS of assignment statement GS. */ | |
1723 | ||
1724 | static inline tree * | |
1725 | gimple_assign_lhs_ptr (const_gimple gs) | |
1726 | { | |
1727 | GIMPLE_CHECK (gs, GIMPLE_ASSIGN); | |
1728 | return gimple_op_ptr (gs, 0); | |
1729 | } | |
1730 | ||
1731 | ||
1732 | /* Set LHS to be the LHS operand of assignment statement GS. */ | |
1733 | ||
1734 | static inline void | |
1735 | gimple_assign_set_lhs (gimple gs, tree lhs) | |
1736 | { | |
1737 | GIMPLE_CHECK (gs, GIMPLE_ASSIGN); | |
726a989a RB |
1738 | gimple_set_op (gs, 0, lhs); |
1739 | ||
1740 | if (lhs && TREE_CODE (lhs) == SSA_NAME) | |
1741 | SSA_NAME_DEF_STMT (lhs) = gs; | |
1742 | } | |
1743 | ||
1744 | ||
1745 | /* Return the first operand on the RHS of assignment statement GS. */ | |
1746 | ||
1747 | static inline tree | |
1748 | gimple_assign_rhs1 (const_gimple gs) | |
1749 | { | |
1750 | GIMPLE_CHECK (gs, GIMPLE_ASSIGN); | |
1751 | return gimple_op (gs, 1); | |
1752 | } | |
1753 | ||
1754 | ||
1755 | /* Return a pointer to the first operand on the RHS of assignment | |
1756 | statement GS. */ | |
1757 | ||
1758 | static inline tree * | |
1759 | gimple_assign_rhs1_ptr (const_gimple gs) | |
1760 | { | |
1761 | GIMPLE_CHECK (gs, GIMPLE_ASSIGN); | |
1762 | return gimple_op_ptr (gs, 1); | |
1763 | } | |
1764 | ||
1765 | /* Set RHS to be the first operand on the RHS of assignment statement GS. */ | |
1766 | ||
1767 | static inline void | |
1768 | gimple_assign_set_rhs1 (gimple gs, tree rhs) | |
1769 | { | |
1770 | GIMPLE_CHECK (gs, GIMPLE_ASSIGN); | |
1771 | ||
726a989a RB |
1772 | gimple_set_op (gs, 1, rhs); |
1773 | } | |
1774 | ||
1775 | ||
1776 | /* Return the second operand on the RHS of assignment statement GS. | |
1777 | If GS does not have two operands, NULL is returned instead. */ | |
1778 | ||
1779 | static inline tree | |
1780 | gimple_assign_rhs2 (const_gimple gs) | |
1781 | { | |
1782 | GIMPLE_CHECK (gs, GIMPLE_ASSIGN); | |
1783 | ||
1784 | if (gimple_num_ops (gs) >= 3) | |
1785 | return gimple_op (gs, 2); | |
1786 | else | |
1787 | return NULL_TREE; | |
1788 | } | |
1789 | ||
1790 | ||
1791 | /* Return a pointer to the second operand on the RHS of assignment | |
1792 | statement GS. */ | |
1793 | ||
1794 | static inline tree * | |
1795 | gimple_assign_rhs2_ptr (const_gimple gs) | |
1796 | { | |
1797 | GIMPLE_CHECK (gs, GIMPLE_ASSIGN); | |
1798 | return gimple_op_ptr (gs, 2); | |
1799 | } | |
1800 | ||
1801 | ||
1802 | /* Set RHS to be the second operand on the RHS of assignment statement GS. */ | |
1803 | ||
1804 | static inline void | |
1805 | gimple_assign_set_rhs2 (gimple gs, tree rhs) | |
1806 | { | |
1807 | GIMPLE_CHECK (gs, GIMPLE_ASSIGN); | |
1808 | ||
726a989a RB |
1809 | gimple_set_op (gs, 2, rhs); |
1810 | } | |
1811 | ||
1812 | /* Returns true if GS is a nontemporal move. */ | |
1813 | ||
1814 | static inline bool | |
1815 | gimple_assign_nontemporal_move_p (const_gimple gs) | |
1816 | { | |
1817 | GIMPLE_CHECK (gs, GIMPLE_ASSIGN); | |
1818 | return gs->gsbase.nontemporal_move; | |
1819 | } | |
1820 | ||
1821 | /* Sets nontemporal move flag of GS to NONTEMPORAL. */ | |
1822 | ||
1823 | static inline void | |
1824 | gimple_assign_set_nontemporal_move (gimple gs, bool nontemporal) | |
1825 | { | |
1826 | GIMPLE_CHECK (gs, GIMPLE_ASSIGN); | |
1827 | gs->gsbase.nontemporal_move = nontemporal; | |
1828 | } | |
1829 | ||
1830 | ||
1831 | /* Return the code of the expression computed on the rhs of assignment | |
1832 | statement GS. In case that the RHS is a single object, returns the | |
1833 | tree code of the object. */ | |
1834 | ||
1835 | static inline enum tree_code | |
1836 | gimple_assign_rhs_code (const_gimple gs) | |
1837 | { | |
1838 | enum tree_code code; | |
1839 | GIMPLE_CHECK (gs, GIMPLE_ASSIGN); | |
1840 | ||
1841 | code = gimple_expr_code (gs); | |
1842 | if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS) | |
1843 | code = TREE_CODE (gimple_assign_rhs1 (gs)); | |
1844 | ||
1845 | return code; | |
1846 | } | |
1847 | ||
1848 | ||
1849 | /* Set CODE to be the code for the expression computed on the RHS of | |
1850 | assignment S. */ | |
1851 | ||
1852 | static inline void | |
1853 | gimple_assign_set_rhs_code (gimple s, enum tree_code code) | |
1854 | { | |
1855 | GIMPLE_CHECK (s, GIMPLE_ASSIGN); | |
1856 | s->gsbase.subcode = code; | |
1857 | } | |
1858 | ||
1859 | ||
0f336c35 RG |
1860 | /* Return the gimple rhs class of the code of the expression computed on |
1861 | the rhs of assignment statement GS. | |
1862 | This will never return GIMPLE_INVALID_RHS. */ | |
1863 | ||
1864 | static inline enum gimple_rhs_class | |
1865 | gimple_assign_rhs_class (const_gimple gs) | |
1866 | { | |
1867 | return get_gimple_rhs_class (gimple_assign_rhs_code (gs)); | |
1868 | } | |
1869 | ||
1870 | ||
726a989a RB |
1871 | /* Return true if S is a type-cast assignment. */ |
1872 | ||
1873 | static inline bool | |
1874 | gimple_assign_cast_p (gimple s) | |
1875 | { | |
1876 | if (is_gimple_assign (s)) | |
1877 | { | |
1878 | enum tree_code sc = gimple_assign_rhs_code (s); | |
1a87cf0c | 1879 | return CONVERT_EXPR_CODE_P (sc) |
726a989a RB |
1880 | || sc == VIEW_CONVERT_EXPR |
1881 | || sc == FIX_TRUNC_EXPR; | |
1882 | } | |
1883 | ||
1884 | return false; | |
1885 | } | |
1886 | ||
1887 | ||
1888 | /* Return true if GS is a GIMPLE_CALL. */ | |
1889 | ||
1890 | static inline bool | |
1891 | is_gimple_call (const_gimple gs) | |
1892 | { | |
1893 | return gimple_code (gs) == GIMPLE_CALL; | |
1894 | } | |
1895 | ||
1896 | /* Return the LHS of call statement GS. */ | |
1897 | ||
1898 | static inline tree | |
1899 | gimple_call_lhs (const_gimple gs) | |
1900 | { | |
1901 | GIMPLE_CHECK (gs, GIMPLE_CALL); | |
1902 | return gimple_op (gs, 0); | |
1903 | } | |
1904 | ||
1905 | ||
1906 | /* Return a pointer to the LHS of call statement GS. */ | |
1907 | ||
1908 | static inline tree * | |
1909 | gimple_call_lhs_ptr (const_gimple gs) | |
1910 | { | |
1911 | GIMPLE_CHECK (gs, GIMPLE_CALL); | |
1912 | return gimple_op_ptr (gs, 0); | |
1913 | } | |
1914 | ||
1915 | ||
1916 | /* Set LHS to be the LHS operand of call statement GS. */ | |
1917 | ||
1918 | static inline void | |
1919 | gimple_call_set_lhs (gimple gs, tree lhs) | |
1920 | { | |
1921 | GIMPLE_CHECK (gs, GIMPLE_CALL); | |
726a989a RB |
1922 | gimple_set_op (gs, 0, lhs); |
1923 | if (lhs && TREE_CODE (lhs) == SSA_NAME) | |
1924 | SSA_NAME_DEF_STMT (lhs) = gs; | |
1925 | } | |
1926 | ||
1927 | ||
1928 | /* Return the tree node representing the function called by call | |
7c9577be | 1929 | statement GS. */ |
726a989a RB |
1930 | |
1931 | static inline tree | |
1932 | gimple_call_fn (const_gimple gs) | |
1933 | { | |
1934 | GIMPLE_CHECK (gs, GIMPLE_CALL); | |
1935 | return gimple_op (gs, 1); | |
1936 | } | |
1937 | ||
1938 | ||
1939 | /* Return a pointer to the tree node representing the function called by call | |
1940 | statement GS. */ | |
1941 | ||
1942 | static inline tree * | |
1943 | gimple_call_fn_ptr (const_gimple gs) | |
1944 | { | |
1945 | GIMPLE_CHECK (gs, GIMPLE_CALL); | |
1946 | return gimple_op_ptr (gs, 1); | |
1947 | } | |
1948 | ||
1949 | ||
1950 | /* Set FN to be the function called by call statement GS. */ | |
1951 | ||
1952 | static inline void | |
1953 | gimple_call_set_fn (gimple gs, tree fn) | |
1954 | { | |
1955 | GIMPLE_CHECK (gs, GIMPLE_CALL); | |
726a989a RB |
1956 | gimple_set_op (gs, 1, fn); |
1957 | } | |
1958 | ||
1959 | ||
7c9577be RG |
1960 | /* Set FNDECL to be the function called by call statement GS. */ |
1961 | ||
1962 | static inline void | |
1963 | gimple_call_set_fndecl (gimple gs, tree decl) | |
1964 | { | |
1965 | GIMPLE_CHECK (gs, GIMPLE_CALL); | |
db3927fb | 1966 | gimple_set_op (gs, 1, build_fold_addr_expr_loc (gimple_location (gs), decl)); |
7c9577be RG |
1967 | } |
1968 | ||
1969 | ||
726a989a RB |
1970 | /* If a given GIMPLE_CALL's callee is a FUNCTION_DECL, return it. |
1971 | Otherwise return NULL. This function is analogous to | |
1972 | get_callee_fndecl in tree land. */ | |
1973 | ||
1974 | static inline tree | |
1975 | gimple_call_fndecl (const_gimple gs) | |
1976 | { | |
7c9577be RG |
1977 | tree addr = gimple_call_fn (gs); |
1978 | if (TREE_CODE (addr) == ADDR_EXPR) | |
f68a75df | 1979 | return TREE_OPERAND (addr, 0); |
7c9577be | 1980 | return NULL_TREE; |
726a989a RB |
1981 | } |
1982 | ||
1983 | ||
1984 | /* Return the type returned by call statement GS. */ | |
1985 | ||
1986 | static inline tree | |
1987 | gimple_call_return_type (const_gimple gs) | |
1988 | { | |
1989 | tree fn = gimple_call_fn (gs); | |
1990 | tree type = TREE_TYPE (fn); | |
1991 | ||
7c9577be | 1992 | /* See through the pointer. */ |
7c9577be | 1993 | type = TREE_TYPE (type); |
726a989a | 1994 | |
726a989a RB |
1995 | /* The type returned by a FUNCTION_DECL is the type of its |
1996 | function type. */ | |
1997 | return TREE_TYPE (type); | |
1998 | } | |
1999 | ||
2000 | ||
2001 | /* Return the static chain for call statement GS. */ | |
2002 | ||
2003 | static inline tree | |
2004 | gimple_call_chain (const_gimple gs) | |
2005 | { | |
2006 | GIMPLE_CHECK (gs, GIMPLE_CALL); | |
2007 | return gimple_op (gs, 2); | |
2008 | } | |
2009 | ||
2010 | ||
2011 | /* Return a pointer to the static chain for call statement GS. */ | |
2012 | ||
2013 | static inline tree * | |
2014 | gimple_call_chain_ptr (const_gimple gs) | |
2015 | { | |
2016 | GIMPLE_CHECK (gs, GIMPLE_CALL); | |
2017 | return gimple_op_ptr (gs, 2); | |
2018 | } | |
2019 | ||
2020 | /* Set CHAIN to be the static chain for call statement GS. */ | |
2021 | ||
2022 | static inline void | |
2023 | gimple_call_set_chain (gimple gs, tree chain) | |
2024 | { | |
2025 | GIMPLE_CHECK (gs, GIMPLE_CALL); | |
f68a75df | 2026 | |
726a989a RB |
2027 | gimple_set_op (gs, 2, chain); |
2028 | } | |
2029 | ||
2030 | ||
2031 | /* Return the number of arguments used by call statement GS. */ | |
2032 | ||
2033 | static inline unsigned | |
2034 | gimple_call_num_args (const_gimple gs) | |
2035 | { | |
2036 | unsigned num_ops; | |
2037 | GIMPLE_CHECK (gs, GIMPLE_CALL); | |
2038 | num_ops = gimple_num_ops (gs); | |
726a989a RB |
2039 | return num_ops - 3; |
2040 | } | |
2041 | ||
2042 | ||
2043 | /* Return the argument at position INDEX for call statement GS. */ | |
2044 | ||
2045 | static inline tree | |
2046 | gimple_call_arg (const_gimple gs, unsigned index) | |
2047 | { | |
2048 | GIMPLE_CHECK (gs, GIMPLE_CALL); | |
2049 | return gimple_op (gs, index + 3); | |
2050 | } | |
2051 | ||
2052 | ||
2053 | /* Return a pointer to the argument at position INDEX for call | |
2054 | statement GS. */ | |
2055 | ||
2056 | static inline tree * | |
2057 | gimple_call_arg_ptr (const_gimple gs, unsigned index) | |
2058 | { | |
2059 | GIMPLE_CHECK (gs, GIMPLE_CALL); | |
2060 | return gimple_op_ptr (gs, index + 3); | |
2061 | } | |
2062 | ||
2063 | ||
2064 | /* Set ARG to be the argument at position INDEX for call statement GS. */ | |
2065 | ||
2066 | static inline void | |
2067 | gimple_call_set_arg (gimple gs, unsigned index, tree arg) | |
2068 | { | |
2069 | GIMPLE_CHECK (gs, GIMPLE_CALL); | |
726a989a RB |
2070 | gimple_set_op (gs, index + 3, arg); |
2071 | } | |
2072 | ||
2073 | ||
2074 | /* If TAIL_P is true, mark call statement S as being a tail call | |
2075 | (i.e., a call just before the exit of a function). These calls are | |
2076 | candidate for tail call optimization. */ | |
2077 | ||
2078 | static inline void | |
2079 | gimple_call_set_tail (gimple s, bool tail_p) | |
2080 | { | |
2081 | GIMPLE_CHECK (s, GIMPLE_CALL); | |
2082 | if (tail_p) | |
2083 | s->gsbase.subcode |= GF_CALL_TAILCALL; | |
2084 | else | |
2085 | s->gsbase.subcode &= ~GF_CALL_TAILCALL; | |
2086 | } | |
2087 | ||
2088 | ||
2089 | /* Return true if GIMPLE_CALL S is marked as a tail call. */ | |
2090 | ||
2091 | static inline bool | |
2092 | gimple_call_tail_p (gimple s) | |
2093 | { | |
2094 | GIMPLE_CHECK (s, GIMPLE_CALL); | |
2095 | return (s->gsbase.subcode & GF_CALL_TAILCALL) != 0; | |
2096 | } | |
2097 | ||
2098 | ||
2099 | /* Set the inlinable status of GIMPLE_CALL S to INLINABLE_P. */ | |
2100 | ||
2101 | static inline void | |
2102 | gimple_call_set_cannot_inline (gimple s, bool inlinable_p) | |
2103 | { | |
2104 | GIMPLE_CHECK (s, GIMPLE_CALL); | |
2105 | if (inlinable_p) | |
2106 | s->gsbase.subcode |= GF_CALL_CANNOT_INLINE; | |
2107 | else | |
2108 | s->gsbase.subcode &= ~GF_CALL_CANNOT_INLINE; | |
2109 | } | |
2110 | ||
2111 | ||
2112 | /* Return true if GIMPLE_CALL S cannot be inlined. */ | |
2113 | ||
2114 | static inline bool | |
2115 | gimple_call_cannot_inline_p (gimple s) | |
2116 | { | |
2117 | GIMPLE_CHECK (s, GIMPLE_CALL); | |
2118 | return (s->gsbase.subcode & GF_CALL_CANNOT_INLINE) != 0; | |
2119 | } | |
2120 | ||
2121 | ||
2122 | /* If RETURN_SLOT_OPT_P is true mark GIMPLE_CALL S as valid for return | |
2123 | slot optimization. This transformation uses the target of the call | |
2124 | expansion as the return slot for calls that return in memory. */ | |
2125 | ||
2126 | static inline void | |
2127 | gimple_call_set_return_slot_opt (gimple s, bool return_slot_opt_p) | |
2128 | { | |
2129 | GIMPLE_CHECK (s, GIMPLE_CALL); | |
2130 | if (return_slot_opt_p) | |
2131 | s->gsbase.subcode |= GF_CALL_RETURN_SLOT_OPT; | |
2132 | else | |
2133 | s->gsbase.subcode &= ~GF_CALL_RETURN_SLOT_OPT; | |
2134 | } | |
2135 | ||
2136 | ||
2137 | /* Return true if S is marked for return slot optimization. */ | |
2138 | ||
2139 | static inline bool | |
2140 | gimple_call_return_slot_opt_p (gimple s) | |
2141 | { | |
2142 | GIMPLE_CHECK (s, GIMPLE_CALL); | |
2143 | return (s->gsbase.subcode & GF_CALL_RETURN_SLOT_OPT) != 0; | |
2144 | } | |
2145 | ||
2146 | ||
2147 | /* If FROM_THUNK_P is true, mark GIMPLE_CALL S as being the jump from a | |
2148 | thunk to the thunked-to function. */ | |
2149 | ||
2150 | static inline void | |
2151 | gimple_call_set_from_thunk (gimple s, bool from_thunk_p) | |
2152 | { | |
2153 | GIMPLE_CHECK (s, GIMPLE_CALL); | |
2154 | if (from_thunk_p) | |
2155 | s->gsbase.subcode |= GF_CALL_FROM_THUNK; | |
2156 | else | |
2157 | s->gsbase.subcode &= ~GF_CALL_FROM_THUNK; | |
2158 | } | |
2159 | ||
2160 | ||
2161 | /* Return true if GIMPLE_CALL S is a jump from a thunk. */ | |
2162 | ||
2163 | static inline bool | |
2164 | gimple_call_from_thunk_p (gimple s) | |
2165 | { | |
2166 | GIMPLE_CHECK (s, GIMPLE_CALL); | |
2167 | return (s->gsbase.subcode & GF_CALL_FROM_THUNK) != 0; | |
2168 | } | |
2169 | ||
2170 | ||
2171 | /* If PASS_ARG_PACK_P is true, GIMPLE_CALL S is a stdarg call that needs the | |
2172 | argument pack in its argument list. */ | |
2173 | ||
2174 | static inline void | |
2175 | gimple_call_set_va_arg_pack (gimple s, bool pass_arg_pack_p) | |
2176 | { | |
2177 | GIMPLE_CHECK (s, GIMPLE_CALL); | |
2178 | if (pass_arg_pack_p) | |
2179 | s->gsbase.subcode |= GF_CALL_VA_ARG_PACK; | |
2180 | else | |
2181 | s->gsbase.subcode &= ~GF_CALL_VA_ARG_PACK; | |
2182 | } | |
2183 | ||
2184 | ||
2185 | /* Return true if GIMPLE_CALL S is a stdarg call that needs the | |
2186 | argument pack in its argument list. */ | |
2187 | ||
2188 | static inline bool | |
2189 | gimple_call_va_arg_pack_p (gimple s) | |
2190 | { | |
2191 | GIMPLE_CHECK (s, GIMPLE_CALL); | |
2192 | return (s->gsbase.subcode & GF_CALL_VA_ARG_PACK) != 0; | |
2193 | } | |
2194 | ||
2195 | ||
2196 | /* Return true if S is a noreturn call. */ | |
2197 | ||
2198 | static inline bool | |
2199 | gimple_call_noreturn_p (gimple s) | |
2200 | { | |
2201 | GIMPLE_CHECK (s, GIMPLE_CALL); | |
2202 | return (gimple_call_flags (s) & ECF_NORETURN) != 0; | |
2203 | } | |
2204 | ||
2205 | ||
9bb1a81b JM |
2206 | /* If NOTHROW_P is true, GIMPLE_CALL S is a call that is known to not throw |
2207 | even if the called function can throw in other cases. */ | |
2208 | ||
2209 | static inline void | |
2210 | gimple_call_set_nothrow (gimple s, bool nothrow_p) | |
2211 | { | |
2212 | GIMPLE_CHECK (s, GIMPLE_CALL); | |
2213 | if (nothrow_p) | |
2214 | s->gsbase.subcode |= GF_CALL_NOTHROW; | |
2215 | else | |
2216 | s->gsbase.subcode &= ~GF_CALL_NOTHROW; | |
2217 | } | |
2218 | ||
726a989a RB |
2219 | /* Return true if S is a nothrow call. */ |
2220 | ||
2221 | static inline bool | |
2222 | gimple_call_nothrow_p (gimple s) | |
2223 | { | |
2224 | GIMPLE_CHECK (s, GIMPLE_CALL); | |
2225 | return (gimple_call_flags (s) & ECF_NOTHROW) != 0; | |
2226 | } | |
2227 | ||
2228 | ||
2229 | /* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL. */ | |
2230 | ||
2231 | static inline void | |
2232 | gimple_call_copy_flags (gimple dest_call, gimple orig_call) | |
2233 | { | |
2234 | GIMPLE_CHECK (dest_call, GIMPLE_CALL); | |
2235 | GIMPLE_CHECK (orig_call, GIMPLE_CALL); | |
2236 | dest_call->gsbase.subcode = orig_call->gsbase.subcode; | |
2237 | } | |
2238 | ||
2239 | ||
d086d311 RG |
2240 | /* Return a pointer to the points-to solution for the set of call-used |
2241 | variables of the call CALL. */ | |
2242 | ||
2243 | static inline struct pt_solution * | |
2244 | gimple_call_use_set (gimple call) | |
2245 | { | |
2246 | GIMPLE_CHECK (call, GIMPLE_CALL); | |
2247 | return &call->gimple_call.call_used; | |
2248 | } | |
2249 | ||
2250 | ||
2251 | /* Return a pointer to the points-to solution for the set of call-used | |
2252 | variables of the call CALL. */ | |
2253 | ||
2254 | static inline struct pt_solution * | |
2255 | gimple_call_clobber_set (gimple call) | |
2256 | { | |
2257 | GIMPLE_CHECK (call, GIMPLE_CALL); | |
2258 | return &call->gimple_call.call_clobbered; | |
2259 | } | |
2260 | ||
2261 | ||
726a989a RB |
2262 | /* Returns true if this is a GIMPLE_ASSIGN or a GIMPLE_CALL with a |
2263 | non-NULL lhs. */ | |
2264 | ||
2265 | static inline bool | |
2266 | gimple_has_lhs (gimple stmt) | |
2267 | { | |
2268 | return (is_gimple_assign (stmt) | |
2269 | || (is_gimple_call (stmt) | |
2270 | && gimple_call_lhs (stmt) != NULL_TREE)); | |
2271 | } | |
2272 | ||
2273 | ||
2274 | /* Return the code of the predicate computed by conditional statement GS. */ | |
2275 | ||
2276 | static inline enum tree_code | |
2277 | gimple_cond_code (const_gimple gs) | |
2278 | { | |
2279 | GIMPLE_CHECK (gs, GIMPLE_COND); | |
81f40b79 | 2280 | return (enum tree_code) gs->gsbase.subcode; |
726a989a RB |
2281 | } |
2282 | ||
2283 | ||
2284 | /* Set CODE to be the predicate code for the conditional statement GS. */ | |
2285 | ||
2286 | static inline void | |
2287 | gimple_cond_set_code (gimple gs, enum tree_code code) | |
2288 | { | |
2289 | GIMPLE_CHECK (gs, GIMPLE_COND); | |
726a989a RB |
2290 | gs->gsbase.subcode = code; |
2291 | } | |
2292 | ||
2293 | ||
2294 | /* Return the LHS of the predicate computed by conditional statement GS. */ | |
2295 | ||
2296 | static inline tree | |
2297 | gimple_cond_lhs (const_gimple gs) | |
2298 | { | |
2299 | GIMPLE_CHECK (gs, GIMPLE_COND); | |
2300 | return gimple_op (gs, 0); | |
2301 | } | |
2302 | ||
2303 | /* Return the pointer to the LHS of the predicate computed by conditional | |
2304 | statement GS. */ | |
2305 | ||
2306 | static inline tree * | |
2307 | gimple_cond_lhs_ptr (const_gimple gs) | |
2308 | { | |
2309 | GIMPLE_CHECK (gs, GIMPLE_COND); | |
2310 | return gimple_op_ptr (gs, 0); | |
2311 | } | |
2312 | ||
2313 | /* Set LHS to be the LHS operand of the predicate computed by | |
2314 | conditional statement GS. */ | |
2315 | ||
2316 | static inline void | |
2317 | gimple_cond_set_lhs (gimple gs, tree lhs) | |
2318 | { | |
2319 | GIMPLE_CHECK (gs, GIMPLE_COND); | |
726a989a RB |
2320 | gimple_set_op (gs, 0, lhs); |
2321 | } | |
2322 | ||
2323 | ||
2324 | /* Return the RHS operand of the predicate computed by conditional GS. */ | |
2325 | ||
2326 | static inline tree | |
2327 | gimple_cond_rhs (const_gimple gs) | |
2328 | { | |
2329 | GIMPLE_CHECK (gs, GIMPLE_COND); | |
2330 | return gimple_op (gs, 1); | |
2331 | } | |
2332 | ||
2333 | /* Return the pointer to the RHS operand of the predicate computed by | |
2334 | conditional GS. */ | |
2335 | ||
2336 | static inline tree * | |
2337 | gimple_cond_rhs_ptr (const_gimple gs) | |
2338 | { | |
2339 | GIMPLE_CHECK (gs, GIMPLE_COND); | |
2340 | return gimple_op_ptr (gs, 1); | |
2341 | } | |
2342 | ||
2343 | ||
2344 | /* Set RHS to be the RHS operand of the predicate computed by | |
2345 | conditional statement GS. */ | |
2346 | ||
2347 | static inline void | |
2348 | gimple_cond_set_rhs (gimple gs, tree rhs) | |
2349 | { | |
2350 | GIMPLE_CHECK (gs, GIMPLE_COND); | |
726a989a RB |
2351 | gimple_set_op (gs, 1, rhs); |
2352 | } | |
2353 | ||
2354 | ||
2355 | /* Return the label used by conditional statement GS when its | |
2356 | predicate evaluates to true. */ | |
2357 | ||
2358 | static inline tree | |
2359 | gimple_cond_true_label (const_gimple gs) | |
2360 | { | |
2361 | GIMPLE_CHECK (gs, GIMPLE_COND); | |
2362 | return gimple_op (gs, 2); | |
2363 | } | |
2364 | ||
2365 | ||
2366 | /* Set LABEL to be the label used by conditional statement GS when its | |
2367 | predicate evaluates to true. */ | |
2368 | ||
2369 | static inline void | |
2370 | gimple_cond_set_true_label (gimple gs, tree label) | |
2371 | { | |
2372 | GIMPLE_CHECK (gs, GIMPLE_COND); | |
726a989a RB |
2373 | gimple_set_op (gs, 2, label); |
2374 | } | |
2375 | ||
2376 | ||
2377 | /* Set LABEL to be the label used by conditional statement GS when its | |
2378 | predicate evaluates to false. */ | |
2379 | ||
2380 | static inline void | |
2381 | gimple_cond_set_false_label (gimple gs, tree label) | |
2382 | { | |
2383 | GIMPLE_CHECK (gs, GIMPLE_COND); | |
726a989a RB |
2384 | gimple_set_op (gs, 3, label); |
2385 | } | |
2386 | ||
2387 | ||
2388 | /* Return the label used by conditional statement GS when its | |
2389 | predicate evaluates to false. */ | |
2390 | ||
2391 | static inline tree | |
2392 | gimple_cond_false_label (const_gimple gs) | |
2393 | { | |
2394 | GIMPLE_CHECK (gs, GIMPLE_COND); | |
2395 | return gimple_op (gs, 3); | |
2396 | } | |
2397 | ||
2398 | ||
2399 | /* Set the conditional COND_STMT to be of the form 'if (1 == 0)'. */ | |
2400 | ||
2401 | static inline void | |
2402 | gimple_cond_make_false (gimple gs) | |
2403 | { | |
2404 | gimple_cond_set_lhs (gs, boolean_true_node); | |
2405 | gimple_cond_set_rhs (gs, boolean_false_node); | |
2406 | gs->gsbase.subcode = EQ_EXPR; | |
2407 | } | |
2408 | ||
2409 | ||
2410 | /* Set the conditional COND_STMT to be of the form 'if (1 == 1)'. */ | |
2411 | ||
2412 | static inline void | |
2413 | gimple_cond_make_true (gimple gs) | |
2414 | { | |
2415 | gimple_cond_set_lhs (gs, boolean_true_node); | |
2416 | gimple_cond_set_rhs (gs, boolean_true_node); | |
2417 | gs->gsbase.subcode = EQ_EXPR; | |
2418 | } | |
2419 | ||
2420 | /* Check if conditional statemente GS is of the form 'if (1 == 1)', | |
2421 | 'if (0 == 0)', 'if (1 != 0)' or 'if (0 != 1)' */ | |
2422 | ||
2423 | static inline bool | |
2424 | gimple_cond_true_p (const_gimple gs) | |
2425 | { | |
2426 | tree lhs = gimple_cond_lhs (gs); | |
2427 | tree rhs = gimple_cond_rhs (gs); | |
2428 | enum tree_code code = gimple_cond_code (gs); | |
2429 | ||
2430 | if (lhs != boolean_true_node && lhs != boolean_false_node) | |
2431 | return false; | |
2432 | ||
2433 | if (rhs != boolean_true_node && rhs != boolean_false_node) | |
2434 | return false; | |
2435 | ||
2436 | if (code == NE_EXPR && lhs != rhs) | |
2437 | return true; | |
2438 | ||
2439 | if (code == EQ_EXPR && lhs == rhs) | |
2440 | return true; | |
2441 | ||
2442 | return false; | |
2443 | } | |
2444 | ||
2445 | /* Check if conditional statement GS is of the form 'if (1 != 1)', | |
2446 | 'if (0 != 0)', 'if (1 == 0)' or 'if (0 == 1)' */ | |
2447 | ||
2448 | static inline bool | |
2449 | gimple_cond_false_p (const_gimple gs) | |
2450 | { | |
2451 | tree lhs = gimple_cond_lhs (gs); | |
2452 | tree rhs = gimple_cond_rhs (gs); | |
2453 | enum tree_code code = gimple_cond_code (gs); | |
2454 | ||
2455 | if (lhs != boolean_true_node && lhs != boolean_false_node) | |
2456 | return false; | |
2457 | ||
2458 | if (rhs != boolean_true_node && rhs != boolean_false_node) | |
2459 | return false; | |
2460 | ||
2461 | if (code == NE_EXPR && lhs == rhs) | |
2462 | return true; | |
2463 | ||
2464 | if (code == EQ_EXPR && lhs != rhs) | |
2465 | return true; | |
2466 | ||
2467 | return false; | |
2468 | } | |
2469 | ||
2470 | /* Check if conditional statement GS is of the form 'if (var != 0)' or | |
2471 | 'if (var == 1)' */ | |
2472 | ||
2473 | static inline bool | |
2474 | gimple_cond_single_var_p (gimple gs) | |
2475 | { | |
2476 | if (gimple_cond_code (gs) == NE_EXPR | |
2477 | && gimple_cond_rhs (gs) == boolean_false_node) | |
2478 | return true; | |
2479 | ||
2480 | if (gimple_cond_code (gs) == EQ_EXPR | |
2481 | && gimple_cond_rhs (gs) == boolean_true_node) | |
2482 | return true; | |
2483 | ||
2484 | return false; | |
2485 | } | |
2486 | ||
2487 | /* Set the code, LHS and RHS of GIMPLE_COND STMT from CODE, LHS and RHS. */ | |
2488 | ||
2489 | static inline void | |
2490 | gimple_cond_set_condition (gimple stmt, enum tree_code code, tree lhs, tree rhs) | |
2491 | { | |
2492 | gimple_cond_set_code (stmt, code); | |
2493 | gimple_cond_set_lhs (stmt, lhs); | |
2494 | gimple_cond_set_rhs (stmt, rhs); | |
2495 | } | |
2496 | ||
2497 | /* Return the LABEL_DECL node used by GIMPLE_LABEL statement GS. */ | |
2498 | ||
2499 | static inline tree | |
2500 | gimple_label_label (const_gimple gs) | |
2501 | { | |
2502 | GIMPLE_CHECK (gs, GIMPLE_LABEL); | |
2503 | return gimple_op (gs, 0); | |
2504 | } | |
2505 | ||
2506 | ||
2507 | /* Set LABEL to be the LABEL_DECL node used by GIMPLE_LABEL statement | |
2508 | GS. */ | |
2509 | ||
2510 | static inline void | |
2511 | gimple_label_set_label (gimple gs, tree label) | |
2512 | { | |
2513 | GIMPLE_CHECK (gs, GIMPLE_LABEL); | |
726a989a RB |
2514 | gimple_set_op (gs, 0, label); |
2515 | } | |
2516 | ||
2517 | ||
2518 | /* Return the destination of the unconditional jump GS. */ | |
2519 | ||
2520 | static inline tree | |
2521 | gimple_goto_dest (const_gimple gs) | |
2522 | { | |
2523 | GIMPLE_CHECK (gs, GIMPLE_GOTO); | |
2524 | return gimple_op (gs, 0); | |
2525 | } | |
2526 | ||
2527 | ||
2528 | /* Set DEST to be the destination of the unconditonal jump GS. */ | |
2529 | ||
b8698a0f | 2530 | static inline void |
726a989a RB |
2531 | gimple_goto_set_dest (gimple gs, tree dest) |
2532 | { | |
2533 | GIMPLE_CHECK (gs, GIMPLE_GOTO); | |
726a989a RB |
2534 | gimple_set_op (gs, 0, dest); |
2535 | } | |
2536 | ||
2537 | ||
2538 | /* Return the variables declared in the GIMPLE_BIND statement GS. */ | |
2539 | ||
2540 | static inline tree | |
2541 | gimple_bind_vars (const_gimple gs) | |
2542 | { | |
2543 | GIMPLE_CHECK (gs, GIMPLE_BIND); | |
2544 | return gs->gimple_bind.vars; | |
2545 | } | |
2546 | ||
2547 | ||
2548 | /* Set VARS to be the set of variables declared in the GIMPLE_BIND | |
2549 | statement GS. */ | |
2550 | ||
2551 | static inline void | |
2552 | gimple_bind_set_vars (gimple gs, tree vars) | |
2553 | { | |
2554 | GIMPLE_CHECK (gs, GIMPLE_BIND); | |
2555 | gs->gimple_bind.vars = vars; | |
2556 | } | |
2557 | ||
2558 | ||
2559 | /* Append VARS to the set of variables declared in the GIMPLE_BIND | |
2560 | statement GS. */ | |
2561 | ||
2562 | static inline void | |
2563 | gimple_bind_append_vars (gimple gs, tree vars) | |
2564 | { | |
2565 | GIMPLE_CHECK (gs, GIMPLE_BIND); | |
2566 | gs->gimple_bind.vars = chainon (gs->gimple_bind.vars, vars); | |
2567 | } | |
2568 | ||
2569 | ||
2570 | /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS. */ | |
2571 | ||
2572 | static inline gimple_seq | |
2573 | gimple_bind_body (gimple gs) | |
2574 | { | |
2575 | GIMPLE_CHECK (gs, GIMPLE_BIND); | |
2576 | return gs->gimple_bind.body; | |
2577 | } | |
2578 | ||
2579 | ||
2580 | /* Set SEQ to be the GIMPLE sequence contained in the GIMPLE_BIND | |
2581 | statement GS. */ | |
2582 | ||
2583 | static inline void | |
2584 | gimple_bind_set_body (gimple gs, gimple_seq seq) | |
2585 | { | |
2586 | GIMPLE_CHECK (gs, GIMPLE_BIND); | |
2587 | gs->gimple_bind.body = seq; | |
2588 | } | |
2589 | ||
2590 | ||
2591 | /* Append a statement to the end of a GIMPLE_BIND's body. */ | |
2592 | ||
2593 | static inline void | |
2594 | gimple_bind_add_stmt (gimple gs, gimple stmt) | |
2595 | { | |
2596 | GIMPLE_CHECK (gs, GIMPLE_BIND); | |
2597 | gimple_seq_add_stmt (&gs->gimple_bind.body, stmt); | |
2598 | } | |
2599 | ||
2600 | ||
2601 | /* Append a sequence of statements to the end of a GIMPLE_BIND's body. */ | |
2602 | ||
2603 | static inline void | |
2604 | gimple_bind_add_seq (gimple gs, gimple_seq seq) | |
2605 | { | |
2606 | GIMPLE_CHECK (gs, GIMPLE_BIND); | |
2607 | gimple_seq_add_seq (&gs->gimple_bind.body, seq); | |
2608 | } | |
2609 | ||
2610 | ||
2611 | /* Return the TREE_BLOCK node associated with GIMPLE_BIND statement | |
2612 | GS. This is analogous to the BIND_EXPR_BLOCK field in trees. */ | |
2613 | ||
2614 | static inline tree | |
2615 | gimple_bind_block (const_gimple gs) | |
2616 | { | |
2617 | GIMPLE_CHECK (gs, GIMPLE_BIND); | |
2618 | return gs->gimple_bind.block; | |
2619 | } | |
2620 | ||
2621 | ||
2622 | /* Set BLOCK to be the TREE_BLOCK node associated with GIMPLE_BIND | |
2623 | statement GS. */ | |
2624 | ||
2625 | static inline void | |
2626 | gimple_bind_set_block (gimple gs, tree block) | |
2627 | { | |
2628 | GIMPLE_CHECK (gs, GIMPLE_BIND); | |
32001f69 | 2629 | gcc_assert (block == NULL_TREE || TREE_CODE (block) == BLOCK); |
726a989a RB |
2630 | gs->gimple_bind.block = block; |
2631 | } | |
2632 | ||
2633 | ||
2634 | /* Return the number of input operands for GIMPLE_ASM GS. */ | |
2635 | ||
2636 | static inline unsigned | |
2637 | gimple_asm_ninputs (const_gimple gs) | |
2638 | { | |
2639 | GIMPLE_CHECK (gs, GIMPLE_ASM); | |
2640 | return gs->gimple_asm.ni; | |
2641 | } | |
2642 | ||
2643 | ||
2644 | /* Return the number of output operands for GIMPLE_ASM GS. */ | |
2645 | ||
2646 | static inline unsigned | |
2647 | gimple_asm_noutputs (const_gimple gs) | |
2648 | { | |
2649 | GIMPLE_CHECK (gs, GIMPLE_ASM); | |
2650 | return gs->gimple_asm.no; | |
2651 | } | |
2652 | ||
2653 | ||
2654 | /* Return the number of clobber operands for GIMPLE_ASM GS. */ | |
2655 | ||
2656 | static inline unsigned | |
2657 | gimple_asm_nclobbers (const_gimple gs) | |
2658 | { | |
2659 | GIMPLE_CHECK (gs, GIMPLE_ASM); | |
2660 | return gs->gimple_asm.nc; | |
2661 | } | |
2662 | ||
1c384bf1 RH |
2663 | /* Return the number of label operands for GIMPLE_ASM GS. */ |
2664 | ||
2665 | static inline unsigned | |
2666 | gimple_asm_nlabels (const_gimple gs) | |
2667 | { | |
2668 | GIMPLE_CHECK (gs, GIMPLE_ASM); | |
2669 | return gs->gimple_asm.nl; | |
2670 | } | |
726a989a RB |
2671 | |
2672 | /* Return input operand INDEX of GIMPLE_ASM GS. */ | |
2673 | ||
2674 | static inline tree | |
2675 | gimple_asm_input_op (const_gimple gs, unsigned index) | |
2676 | { | |
2677 | GIMPLE_CHECK (gs, GIMPLE_ASM); | |
2678 | gcc_assert (index <= gs->gimple_asm.ni); | |
2679 | return gimple_op (gs, index); | |
2680 | } | |
2681 | ||
2682 | /* Return a pointer to input operand INDEX of GIMPLE_ASM GS. */ | |
2683 | ||
2684 | static inline tree * | |
2685 | gimple_asm_input_op_ptr (const_gimple gs, unsigned index) | |
2686 | { | |
2687 | GIMPLE_CHECK (gs, GIMPLE_ASM); | |
2688 | gcc_assert (index <= gs->gimple_asm.ni); | |
2689 | return gimple_op_ptr (gs, index); | |
2690 | } | |
2691 | ||
2692 | ||
2693 | /* Set IN_OP to be input operand INDEX in GIMPLE_ASM GS. */ | |
2694 | ||
2695 | static inline void | |
2696 | gimple_asm_set_input_op (gimple gs, unsigned index, tree in_op) | |
2697 | { | |
2698 | GIMPLE_CHECK (gs, GIMPLE_ASM); | |
2699 | gcc_assert (index <= gs->gimple_asm.ni); | |
2700 | gcc_assert (TREE_CODE (in_op) == TREE_LIST); | |
2701 | gimple_set_op (gs, index, in_op); | |
2702 | } | |
2703 | ||
2704 | ||
2705 | /* Return output operand INDEX of GIMPLE_ASM GS. */ | |
2706 | ||
2707 | static inline tree | |
2708 | gimple_asm_output_op (const_gimple gs, unsigned index) | |
2709 | { | |
2710 | GIMPLE_CHECK (gs, GIMPLE_ASM); | |
2711 | gcc_assert (index <= gs->gimple_asm.no); | |
2712 | return gimple_op (gs, index + gs->gimple_asm.ni); | |
2713 | } | |
2714 | ||
2715 | /* Return a pointer to output operand INDEX of GIMPLE_ASM GS. */ | |
2716 | ||
2717 | static inline tree * | |
2718 | gimple_asm_output_op_ptr (const_gimple gs, unsigned index) | |
2719 | { | |
2720 | GIMPLE_CHECK (gs, GIMPLE_ASM); | |
2721 | gcc_assert (index <= gs->gimple_asm.no); | |
2722 | return gimple_op_ptr (gs, index + gs->gimple_asm.ni); | |
2723 | } | |
2724 | ||
2725 | ||
2726 | /* Set OUT_OP to be output operand INDEX in GIMPLE_ASM GS. */ | |
2727 | ||
2728 | static inline void | |
2729 | gimple_asm_set_output_op (gimple gs, unsigned index, tree out_op) | |
2730 | { | |
2731 | GIMPLE_CHECK (gs, GIMPLE_ASM); | |
2732 | gcc_assert (index <= gs->gimple_asm.no); | |
2733 | gcc_assert (TREE_CODE (out_op) == TREE_LIST); | |
2734 | gimple_set_op (gs, index + gs->gimple_asm.ni, out_op); | |
2735 | } | |
2736 | ||
2737 | ||
2738 | /* Return clobber operand INDEX of GIMPLE_ASM GS. */ | |
2739 | ||
2740 | static inline tree | |
2741 | gimple_asm_clobber_op (const_gimple gs, unsigned index) | |
2742 | { | |
2743 | GIMPLE_CHECK (gs, GIMPLE_ASM); | |
2744 | gcc_assert (index <= gs->gimple_asm.nc); | |
2745 | return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no); | |
2746 | } | |
2747 | ||
2748 | ||
2749 | /* Set CLOBBER_OP to be clobber operand INDEX in GIMPLE_ASM GS. */ | |
2750 | ||
2751 | static inline void | |
2752 | gimple_asm_set_clobber_op (gimple gs, unsigned index, tree clobber_op) | |
2753 | { | |
2754 | GIMPLE_CHECK (gs, GIMPLE_ASM); | |
2755 | gcc_assert (index <= gs->gimple_asm.nc); | |
2756 | gcc_assert (TREE_CODE (clobber_op) == TREE_LIST); | |
2757 | gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no, clobber_op); | |
2758 | } | |
2759 | ||
1c384bf1 RH |
2760 | /* Return label operand INDEX of GIMPLE_ASM GS. */ |
2761 | ||
2762 | static inline tree | |
2763 | gimple_asm_label_op (const_gimple gs, unsigned index) | |
2764 | { | |
2765 | GIMPLE_CHECK (gs, GIMPLE_ASM); | |
2766 | gcc_assert (index <= gs->gimple_asm.nl); | |
2767 | return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.nc); | |
2768 | } | |
2769 | ||
2770 | /* Set LABEL_OP to be label operand INDEX in GIMPLE_ASM GS. */ | |
2771 | ||
2772 | static inline void | |
2773 | gimple_asm_set_label_op (gimple gs, unsigned index, tree label_op) | |
2774 | { | |
2775 | GIMPLE_CHECK (gs, GIMPLE_ASM); | |
2776 | gcc_assert (index <= gs->gimple_asm.nl); | |
2777 | gcc_assert (TREE_CODE (label_op) == TREE_LIST); | |
2778 | gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.nc, label_op); | |
2779 | } | |
726a989a RB |
2780 | |
2781 | /* Return the string representing the assembly instruction in | |
2782 | GIMPLE_ASM GS. */ | |
2783 | ||
2784 | static inline const char * | |
2785 | gimple_asm_string (const_gimple gs) | |
2786 | { | |
2787 | GIMPLE_CHECK (gs, GIMPLE_ASM); | |
2788 | return gs->gimple_asm.string; | |
2789 | } | |
2790 | ||
2791 | ||
2792 | /* Return true if GS is an asm statement marked volatile. */ | |
2793 | ||
2794 | static inline bool | |
2795 | gimple_asm_volatile_p (const_gimple gs) | |
2796 | { | |
2797 | GIMPLE_CHECK (gs, GIMPLE_ASM); | |
2798 | return (gs->gsbase.subcode & GF_ASM_VOLATILE) != 0; | |
2799 | } | |
2800 | ||
2801 | ||
2802 | /* If VOLATLE_P is true, mark asm statement GS as volatile. */ | |
2803 | ||
2804 | static inline void | |
2805 | gimple_asm_set_volatile (gimple gs, bool volatile_p) | |
2806 | { | |
2807 | GIMPLE_CHECK (gs, GIMPLE_ASM); | |
2808 | if (volatile_p) | |
2809 | gs->gsbase.subcode |= GF_ASM_VOLATILE; | |
2810 | else | |
2811 | gs->gsbase.subcode &= ~GF_ASM_VOLATILE; | |
2812 | } | |
2813 | ||
2814 | ||
2815 | /* If INPUT_P is true, mark asm GS as an ASM_INPUT. */ | |
2816 | ||
2817 | static inline void | |
2818 | gimple_asm_set_input (gimple gs, bool input_p) | |
2819 | { | |
2820 | GIMPLE_CHECK (gs, GIMPLE_ASM); | |
2821 | if (input_p) | |
2822 | gs->gsbase.subcode |= GF_ASM_INPUT; | |
2823 | else | |
2824 | gs->gsbase.subcode &= ~GF_ASM_INPUT; | |
2825 | } | |
2826 | ||
2827 | ||
2828 | /* Return true if asm GS is an ASM_INPUT. */ | |
2829 | ||
2830 | static inline bool | |
2831 | gimple_asm_input_p (const_gimple gs) | |
2832 | { | |
2833 | GIMPLE_CHECK (gs, GIMPLE_ASM); | |
2834 | return (gs->gsbase.subcode & GF_ASM_INPUT) != 0; | |
2835 | } | |
2836 | ||
2837 | ||
2838 | /* Return the types handled by GIMPLE_CATCH statement GS. */ | |
2839 | ||
2840 | static inline tree | |
2841 | gimple_catch_types (const_gimple gs) | |
2842 | { | |
2843 | GIMPLE_CHECK (gs, GIMPLE_CATCH); | |
2844 | return gs->gimple_catch.types; | |
2845 | } | |
2846 | ||
2847 | ||
2848 | /* Return a pointer to the types handled by GIMPLE_CATCH statement GS. */ | |
2849 | ||
2850 | static inline tree * | |
2851 | gimple_catch_types_ptr (gimple gs) | |
2852 | { | |
2853 | GIMPLE_CHECK (gs, GIMPLE_CATCH); | |
2854 | return &gs->gimple_catch.types; | |
2855 | } | |
2856 | ||
2857 | ||
2858 | /* Return the GIMPLE sequence representing the body of the handler of | |
2859 | GIMPLE_CATCH statement GS. */ | |
2860 | ||
2861 | static inline gimple_seq | |
2862 | gimple_catch_handler (gimple gs) | |
2863 | { | |
2864 | GIMPLE_CHECK (gs, GIMPLE_CATCH); | |
2865 | return gs->gimple_catch.handler; | |
2866 | } | |
2867 | ||
2868 | ||
2869 | /* Return a pointer to the GIMPLE sequence representing the body of | |
2870 | the handler of GIMPLE_CATCH statement GS. */ | |
2871 | ||
2872 | static inline gimple_seq * | |
2873 | gimple_catch_handler_ptr (gimple gs) | |
2874 | { | |
2875 | GIMPLE_CHECK (gs, GIMPLE_CATCH); | |
2876 | return &gs->gimple_catch.handler; | |
2877 | } | |
2878 | ||
2879 | ||
2880 | /* Set T to be the set of types handled by GIMPLE_CATCH GS. */ | |
2881 | ||
2882 | static inline void | |
2883 | gimple_catch_set_types (gimple gs, tree t) | |
2884 | { | |
2885 | GIMPLE_CHECK (gs, GIMPLE_CATCH); | |
2886 | gs->gimple_catch.types = t; | |
2887 | } | |
2888 | ||
2889 | ||
2890 | /* Set HANDLER to be the body of GIMPLE_CATCH GS. */ | |
2891 | ||
2892 | static inline void | |
2893 | gimple_catch_set_handler (gimple gs, gimple_seq handler) | |
2894 | { | |
2895 | GIMPLE_CHECK (gs, GIMPLE_CATCH); | |
2896 | gs->gimple_catch.handler = handler; | |
2897 | } | |
2898 | ||
2899 | ||
2900 | /* Return the types handled by GIMPLE_EH_FILTER statement GS. */ | |
2901 | ||
2902 | static inline tree | |
2903 | gimple_eh_filter_types (const_gimple gs) | |
2904 | { | |
2905 | GIMPLE_CHECK (gs, GIMPLE_EH_FILTER); | |
2906 | return gs->gimple_eh_filter.types; | |
2907 | } | |
2908 | ||
2909 | ||
2910 | /* Return a pointer to the types handled by GIMPLE_EH_FILTER statement | |
2911 | GS. */ | |
2912 | ||
2913 | static inline tree * | |
2914 | gimple_eh_filter_types_ptr (gimple gs) | |
2915 | { | |
2916 | GIMPLE_CHECK (gs, GIMPLE_EH_FILTER); | |
2917 | return &gs->gimple_eh_filter.types; | |
2918 | } | |
2919 | ||
2920 | ||
2921 | /* Return the sequence of statement to execute when GIMPLE_EH_FILTER | |
2922 | statement fails. */ | |
2923 | ||
2924 | static inline gimple_seq | |
2925 | gimple_eh_filter_failure (gimple gs) | |
2926 | { | |
2927 | GIMPLE_CHECK (gs, GIMPLE_EH_FILTER); | |
2928 | return gs->gimple_eh_filter.failure; | |
2929 | } | |
2930 | ||
2931 | ||
2932 | /* Set TYPES to be the set of types handled by GIMPLE_EH_FILTER GS. */ | |
2933 | ||
2934 | static inline void | |
2935 | gimple_eh_filter_set_types (gimple gs, tree types) | |
2936 | { | |
2937 | GIMPLE_CHECK (gs, GIMPLE_EH_FILTER); | |
2938 | gs->gimple_eh_filter.types = types; | |
2939 | } | |
2940 | ||
2941 | ||
2942 | /* Set FAILURE to be the sequence of statements to execute on failure | |
2943 | for GIMPLE_EH_FILTER GS. */ | |
2944 | ||
2945 | static inline void | |
2946 | gimple_eh_filter_set_failure (gimple gs, gimple_seq failure) | |
2947 | { | |
2948 | GIMPLE_CHECK (gs, GIMPLE_EH_FILTER); | |
2949 | gs->gimple_eh_filter.failure = failure; | |
2950 | } | |
2951 | ||
1d65f45c | 2952 | /* Get the function decl to be called by the MUST_NOT_THROW region. */ |
726a989a | 2953 | |
1d65f45c RH |
2954 | static inline tree |
2955 | gimple_eh_must_not_throw_fndecl (gimple gs) | |
726a989a | 2956 | { |
1d65f45c RH |
2957 | GIMPLE_CHECK (gs, GIMPLE_EH_MUST_NOT_THROW); |
2958 | return gs->gimple_eh_mnt.fndecl; | |
726a989a RB |
2959 | } |
2960 | ||
d7f09764 DN |
2961 | /* Set the function decl to be called by GS to DECL. */ |
2962 | ||
2963 | static inline void | |
2964 | gimple_eh_must_not_throw_set_fndecl (gimple gs, tree decl) | |
2965 | { | |
2966 | GIMPLE_CHECK (gs, GIMPLE_EH_MUST_NOT_THROW); | |
2967 | gs->gimple_eh_mnt.fndecl = decl; | |
2968 | } | |
2969 | ||
2970 | ||
726a989a RB |
2971 | /* GIMPLE_TRY accessors. */ |
2972 | ||
2973 | /* Return the kind of try block represented by GIMPLE_TRY GS. This is | |
2974 | either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY. */ | |
2975 | ||
2976 | static inline enum gimple_try_flags | |
2977 | gimple_try_kind (const_gimple gs) | |
2978 | { | |
2979 | GIMPLE_CHECK (gs, GIMPLE_TRY); | |
2980 | return (enum gimple_try_flags) (gs->gsbase.subcode & GIMPLE_TRY_KIND); | |
2981 | } | |
2982 | ||
2983 | ||
2984 | /* Set the kind of try block represented by GIMPLE_TRY GS. */ | |
2985 | ||
2986 | static inline void | |
2987 | gimple_try_set_kind (gimple gs, enum gimple_try_flags kind) | |
2988 | { | |
2989 | GIMPLE_CHECK (gs, GIMPLE_TRY); | |
2990 | gcc_assert (kind == GIMPLE_TRY_CATCH || kind == GIMPLE_TRY_FINALLY); | |
2991 | if (gimple_try_kind (gs) != kind) | |
2992 | gs->gsbase.subcode = (unsigned int) kind; | |
2993 | } | |
2994 | ||
2995 | ||
2996 | /* Return the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */ | |
2997 | ||
2998 | static inline bool | |
2999 | gimple_try_catch_is_cleanup (const_gimple gs) | |
3000 | { | |
3001 | gcc_assert (gimple_try_kind (gs) == GIMPLE_TRY_CATCH); | |
3002 | return (gs->gsbase.subcode & GIMPLE_TRY_CATCH_IS_CLEANUP) != 0; | |
3003 | } | |
3004 | ||
3005 | ||
3006 | /* Return the sequence of statements used as the body for GIMPLE_TRY GS. */ | |
3007 | ||
3008 | static inline gimple_seq | |
3009 | gimple_try_eval (gimple gs) | |
3010 | { | |
3011 | GIMPLE_CHECK (gs, GIMPLE_TRY); | |
3012 | return gs->gimple_try.eval; | |
3013 | } | |
3014 | ||
3015 | ||
3016 | /* Return the sequence of statements used as the cleanup body for | |
3017 | GIMPLE_TRY GS. */ | |
3018 | ||
3019 | static inline gimple_seq | |
3020 | gimple_try_cleanup (gimple gs) | |
3021 | { | |
3022 | GIMPLE_CHECK (gs, GIMPLE_TRY); | |
3023 | return gs->gimple_try.cleanup; | |
3024 | } | |
3025 | ||
3026 | ||
3027 | /* Set the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */ | |
3028 | ||
3029 | static inline void | |
3030 | gimple_try_set_catch_is_cleanup (gimple g, bool catch_is_cleanup) | |
3031 | { | |
3032 | gcc_assert (gimple_try_kind (g) == GIMPLE_TRY_CATCH); | |
3033 | if (catch_is_cleanup) | |
3034 | g->gsbase.subcode |= GIMPLE_TRY_CATCH_IS_CLEANUP; | |
3035 | else | |
3036 | g->gsbase.subcode &= ~GIMPLE_TRY_CATCH_IS_CLEANUP; | |
3037 | } | |
3038 | ||
3039 | ||
3040 | /* Set EVAL to be the sequence of statements to use as the body for | |
3041 | GIMPLE_TRY GS. */ | |
3042 | ||
3043 | static inline void | |
3044 | gimple_try_set_eval (gimple gs, gimple_seq eval) | |
3045 | { | |
3046 | GIMPLE_CHECK (gs, GIMPLE_TRY); | |
3047 | gs->gimple_try.eval = eval; | |
3048 | } | |
3049 | ||
3050 | ||
3051 | /* Set CLEANUP to be the sequence of statements to use as the cleanup | |
3052 | body for GIMPLE_TRY GS. */ | |
3053 | ||
3054 | static inline void | |
3055 | gimple_try_set_cleanup (gimple gs, gimple_seq cleanup) | |
3056 | { | |
3057 | GIMPLE_CHECK (gs, GIMPLE_TRY); | |
3058 | gs->gimple_try.cleanup = cleanup; | |
3059 | } | |
3060 | ||
3061 | ||
3062 | /* Return the cleanup sequence for cleanup statement GS. */ | |
3063 | ||
3064 | static inline gimple_seq | |
3065 | gimple_wce_cleanup (gimple gs) | |
3066 | { | |
3067 | GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR); | |
3068 | return gs->gimple_wce.cleanup; | |
3069 | } | |
3070 | ||
3071 | ||
3072 | /* Set CLEANUP to be the cleanup sequence for GS. */ | |
3073 | ||
3074 | static inline void | |
3075 | gimple_wce_set_cleanup (gimple gs, gimple_seq cleanup) | |
3076 | { | |
3077 | GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR); | |
3078 | gs->gimple_wce.cleanup = cleanup; | |
3079 | } | |
3080 | ||
3081 | ||
3082 | /* Return the CLEANUP_EH_ONLY flag for a WCE tuple. */ | |
3083 | ||
3084 | static inline bool | |
3085 | gimple_wce_cleanup_eh_only (const_gimple gs) | |
3086 | { | |
3087 | GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR); | |
3088 | return gs->gsbase.subcode != 0; | |
3089 | } | |
3090 | ||
3091 | ||
3092 | /* Set the CLEANUP_EH_ONLY flag for a WCE tuple. */ | |
3093 | ||
3094 | static inline void | |
3095 | gimple_wce_set_cleanup_eh_only (gimple gs, bool eh_only_p) | |
3096 | { | |
3097 | GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR); | |
3098 | gs->gsbase.subcode = (unsigned int) eh_only_p; | |
3099 | } | |
3100 | ||
3101 | ||
3102 | /* Return the maximum number of arguments supported by GIMPLE_PHI GS. */ | |
3103 | ||
3104 | static inline unsigned | |
3105 | gimple_phi_capacity (const_gimple gs) | |
3106 | { | |
3107 | GIMPLE_CHECK (gs, GIMPLE_PHI); | |
3108 | return gs->gimple_phi.capacity; | |
3109 | } | |
3110 | ||
3111 | ||
3112 | /* Return the number of arguments in GIMPLE_PHI GS. This must always | |
3113 | be exactly the number of incoming edges for the basic block holding | |
3114 | GS. */ | |
3115 | ||
3116 | static inline unsigned | |
3117 | gimple_phi_num_args (const_gimple gs) | |
3118 | { | |
3119 | GIMPLE_CHECK (gs, GIMPLE_PHI); | |
3120 | return gs->gimple_phi.nargs; | |
3121 | } | |
3122 | ||
3123 | ||
3124 | /* Return the SSA name created by GIMPLE_PHI GS. */ | |
3125 | ||
3126 | static inline tree | |
3127 | gimple_phi_result (const_gimple gs) | |
3128 | { | |
3129 | GIMPLE_CHECK (gs, GIMPLE_PHI); | |
3130 | return gs->gimple_phi.result; | |
3131 | } | |
3132 | ||
3133 | /* Return a pointer to the SSA name created by GIMPLE_PHI GS. */ | |
3134 | ||
3135 | static inline tree * | |
3136 | gimple_phi_result_ptr (gimple gs) | |
3137 | { | |
3138 | GIMPLE_CHECK (gs, GIMPLE_PHI); | |
3139 | return &gs->gimple_phi.result; | |
3140 | } | |
3141 | ||
3142 | /* Set RESULT to be the SSA name created by GIMPLE_PHI GS. */ | |
3143 | ||
3144 | static inline void | |
3145 | gimple_phi_set_result (gimple gs, tree result) | |
3146 | { | |
3147 | GIMPLE_CHECK (gs, GIMPLE_PHI); | |
3148 | gs->gimple_phi.result = result; | |
3149 | } | |
3150 | ||
3151 | ||
3152 | /* Return the PHI argument corresponding to incoming edge INDEX for | |
3153 | GIMPLE_PHI GS. */ | |
3154 | ||
3155 | static inline struct phi_arg_d * | |
3156 | gimple_phi_arg (gimple gs, unsigned index) | |
3157 | { | |
3158 | GIMPLE_CHECK (gs, GIMPLE_PHI); | |
3159 | gcc_assert (index <= gs->gimple_phi.capacity); | |
3160 | return &(gs->gimple_phi.args[index]); | |
3161 | } | |
3162 | ||
3163 | /* Set PHIARG to be the argument corresponding to incoming edge INDEX | |
3164 | for GIMPLE_PHI GS. */ | |
3165 | ||
3166 | static inline void | |
3167 | gimple_phi_set_arg (gimple gs, unsigned index, struct phi_arg_d * phiarg) | |
3168 | { | |
3169 | GIMPLE_CHECK (gs, GIMPLE_PHI); | |
3170 | gcc_assert (index <= gs->gimple_phi.nargs); | |
3171 | memcpy (gs->gimple_phi.args + index, phiarg, sizeof (struct phi_arg_d)); | |
3172 | } | |
3173 | ||
3174 | /* Return the region number for GIMPLE_RESX GS. */ | |
3175 | ||
3176 | static inline int | |
3177 | gimple_resx_region (const_gimple gs) | |
3178 | { | |
3179 | GIMPLE_CHECK (gs, GIMPLE_RESX); | |
1d65f45c | 3180 | return gs->gimple_eh_ctrl.region; |
726a989a RB |
3181 | } |
3182 | ||
3183 | /* Set REGION to be the region number for GIMPLE_RESX GS. */ | |
3184 | ||
3185 | static inline void | |
3186 | gimple_resx_set_region (gimple gs, int region) | |
3187 | { | |
3188 | GIMPLE_CHECK (gs, GIMPLE_RESX); | |
1d65f45c | 3189 | gs->gimple_eh_ctrl.region = region; |
726a989a RB |
3190 | } |
3191 | ||
1d65f45c RH |
3192 | /* Return the region number for GIMPLE_EH_DISPATCH GS. */ |
3193 | ||
3194 | static inline int | |
3195 | gimple_eh_dispatch_region (const_gimple gs) | |
3196 | { | |
3197 | GIMPLE_CHECK (gs, GIMPLE_EH_DISPATCH); | |
3198 | return gs->gimple_eh_ctrl.region; | |
3199 | } | |
3200 | ||
3201 | /* Set REGION to be the region number for GIMPLE_EH_DISPATCH GS. */ | |
3202 | ||
3203 | static inline void | |
3204 | gimple_eh_dispatch_set_region (gimple gs, int region) | |
3205 | { | |
3206 | GIMPLE_CHECK (gs, GIMPLE_EH_DISPATCH); | |
3207 | gs->gimple_eh_ctrl.region = region; | |
3208 | } | |
726a989a RB |
3209 | |
3210 | /* Return the number of labels associated with the switch statement GS. */ | |
3211 | ||
3212 | static inline unsigned | |
3213 | gimple_switch_num_labels (const_gimple gs) | |
3214 | { | |
3215 | unsigned num_ops; | |
3216 | GIMPLE_CHECK (gs, GIMPLE_SWITCH); | |
3217 | num_ops = gimple_num_ops (gs); | |
3218 | gcc_assert (num_ops > 1); | |
3219 | return num_ops - 1; | |
3220 | } | |
3221 | ||
3222 | ||
3223 | /* Set NLABELS to be the number of labels for the switch statement GS. */ | |
3224 | ||
3225 | static inline void | |
3226 | gimple_switch_set_num_labels (gimple g, unsigned nlabels) | |
3227 | { | |
3228 | GIMPLE_CHECK (g, GIMPLE_SWITCH); | |
3229 | gimple_set_num_ops (g, nlabels + 1); | |
3230 | } | |
3231 | ||
3232 | ||
3233 | /* Return the index variable used by the switch statement GS. */ | |
3234 | ||
3235 | static inline tree | |
3236 | gimple_switch_index (const_gimple gs) | |
3237 | { | |
3238 | GIMPLE_CHECK (gs, GIMPLE_SWITCH); | |
3239 | return gimple_op (gs, 0); | |
3240 | } | |
3241 | ||
3242 | ||
3243 | /* Return a pointer to the index variable for the switch statement GS. */ | |
3244 | ||
3245 | static inline tree * | |
3246 | gimple_switch_index_ptr (const_gimple gs) | |
3247 | { | |
3248 | GIMPLE_CHECK (gs, GIMPLE_SWITCH); | |
3249 | return gimple_op_ptr (gs, 0); | |
3250 | } | |
3251 | ||
3252 | ||
3253 | /* Set INDEX to be the index variable for switch statement GS. */ | |
3254 | ||
3255 | static inline void | |
3256 | gimple_switch_set_index (gimple gs, tree index) | |
3257 | { | |
3258 | GIMPLE_CHECK (gs, GIMPLE_SWITCH); | |
3259 | gcc_assert (SSA_VAR_P (index) || CONSTANT_CLASS_P (index)); | |
3260 | gimple_set_op (gs, 0, index); | |
3261 | } | |
3262 | ||
3263 | ||
3264 | /* Return the label numbered INDEX. The default label is 0, followed by any | |
3265 | labels in a switch statement. */ | |
3266 | ||
3267 | static inline tree | |
3268 | gimple_switch_label (const_gimple gs, unsigned index) | |
3269 | { | |
3270 | GIMPLE_CHECK (gs, GIMPLE_SWITCH); | |
3271 | gcc_assert (gimple_num_ops (gs) > index + 1); | |
3272 | return gimple_op (gs, index + 1); | |
3273 | } | |
3274 | ||
3275 | /* Set the label number INDEX to LABEL. 0 is always the default label. */ | |
3276 | ||
3277 | static inline void | |
3278 | gimple_switch_set_label (gimple gs, unsigned index, tree label) | |
3279 | { | |
3280 | GIMPLE_CHECK (gs, GIMPLE_SWITCH); | |
3281 | gcc_assert (gimple_num_ops (gs) > index + 1); | |
3282 | gcc_assert (label == NULL_TREE || TREE_CODE (label) == CASE_LABEL_EXPR); | |
3283 | gimple_set_op (gs, index + 1, label); | |
3284 | } | |
3285 | ||
3286 | /* Return the default label for a switch statement. */ | |
3287 | ||
3288 | static inline tree | |
3289 | gimple_switch_default_label (const_gimple gs) | |
3290 | { | |
3291 | return gimple_switch_label (gs, 0); | |
3292 | } | |
3293 | ||
3294 | /* Set the default label for a switch statement. */ | |
3295 | ||
3296 | static inline void | |
3297 | gimple_switch_set_default_label (gimple gs, tree label) | |
3298 | { | |
3299 | gimple_switch_set_label (gs, 0, label); | |
3300 | } | |
3301 | ||
b5b8b0ac AO |
3302 | /* Return true if GS is a GIMPLE_DEBUG statement. */ |
3303 | ||
3304 | static inline bool | |
3305 | is_gimple_debug (const_gimple gs) | |
3306 | { | |
3307 | return gimple_code (gs) == GIMPLE_DEBUG; | |
3308 | } | |
3309 | ||
3310 | /* Return true if S is a GIMPLE_DEBUG BIND statement. */ | |
3311 | ||
3312 | static inline bool | |
3313 | gimple_debug_bind_p (const_gimple s) | |
3314 | { | |
3315 | if (is_gimple_debug (s)) | |
3316 | return s->gsbase.subcode == GIMPLE_DEBUG_BIND; | |
3317 | ||
3318 | return false; | |
3319 | } | |
3320 | ||
3321 | /* Return the variable bound in a GIMPLE_DEBUG bind statement. */ | |
3322 | ||
3323 | static inline tree | |
3324 | gimple_debug_bind_get_var (gimple dbg) | |
3325 | { | |
3326 | GIMPLE_CHECK (dbg, GIMPLE_DEBUG); | |
f68a75df | 3327 | #ifdef ENABLE_CHECKING |
b5b8b0ac | 3328 | gcc_assert (gimple_debug_bind_p (dbg)); |
f68a75df | 3329 | #endif |
b5b8b0ac AO |
3330 | return gimple_op (dbg, 0); |
3331 | } | |
3332 | ||
3333 | /* Return the value bound to the variable in a GIMPLE_DEBUG bind | |
3334 | statement. */ | |
3335 | ||
3336 | static inline tree | |
3337 | gimple_debug_bind_get_value (gimple dbg) | |
3338 | { | |
3339 | GIMPLE_CHECK (dbg, GIMPLE_DEBUG); | |
f68a75df | 3340 | #ifdef ENABLE_CHECKING |
b5b8b0ac | 3341 | gcc_assert (gimple_debug_bind_p (dbg)); |
f68a75df | 3342 | #endif |
b5b8b0ac AO |
3343 | return gimple_op (dbg, 1); |
3344 | } | |
3345 | ||
3346 | /* Return a pointer to the value bound to the variable in a | |
3347 | GIMPLE_DEBUG bind statement. */ | |
3348 | ||
3349 | static inline tree * | |
3350 | gimple_debug_bind_get_value_ptr (gimple dbg) | |
3351 | { | |
3352 | GIMPLE_CHECK (dbg, GIMPLE_DEBUG); | |
f68a75df | 3353 | #ifdef ENABLE_CHECKING |
b5b8b0ac | 3354 | gcc_assert (gimple_debug_bind_p (dbg)); |
f68a75df | 3355 | #endif |
b5b8b0ac AO |
3356 | return gimple_op_ptr (dbg, 1); |
3357 | } | |
3358 | ||
3359 | /* Set the variable bound in a GIMPLE_DEBUG bind statement. */ | |
3360 | ||
3361 | static inline void | |
3362 | gimple_debug_bind_set_var (gimple dbg, tree var) | |
3363 | { | |
3364 | GIMPLE_CHECK (dbg, GIMPLE_DEBUG); | |
f68a75df | 3365 | #ifdef ENABLE_CHECKING |
b5b8b0ac | 3366 | gcc_assert (gimple_debug_bind_p (dbg)); |
f68a75df | 3367 | #endif |
b5b8b0ac AO |
3368 | gimple_set_op (dbg, 0, var); |
3369 | } | |
3370 | ||
3371 | /* Set the value bound to the variable in a GIMPLE_DEBUG bind | |
3372 | statement. */ | |
3373 | ||
3374 | static inline void | |
3375 | gimple_debug_bind_set_value (gimple dbg, tree value) | |
3376 | { | |
3377 | GIMPLE_CHECK (dbg, GIMPLE_DEBUG); | |
f68a75df | 3378 | #ifdef ENABLE_CHECKING |
b5b8b0ac | 3379 | gcc_assert (gimple_debug_bind_p (dbg)); |
f68a75df | 3380 | #endif |
b5b8b0ac AO |
3381 | gimple_set_op (dbg, 1, value); |
3382 | } | |
3383 | ||
3384 | /* The second operand of a GIMPLE_DEBUG_BIND, when the value was | |
3385 | optimized away. */ | |
3386 | #define GIMPLE_DEBUG_BIND_NOVALUE NULL_TREE /* error_mark_node */ | |
3387 | ||
3388 | /* Remove the value bound to the variable in a GIMPLE_DEBUG bind | |
3389 | statement. */ | |
3390 | ||
3391 | static inline void | |
3392 | gimple_debug_bind_reset_value (gimple dbg) | |
3393 | { | |
3394 | GIMPLE_CHECK (dbg, GIMPLE_DEBUG); | |
f68a75df | 3395 | #ifdef ENABLE_CHECKING |
b5b8b0ac | 3396 | gcc_assert (gimple_debug_bind_p (dbg)); |
f68a75df | 3397 | #endif |
b5b8b0ac AO |
3398 | gimple_set_op (dbg, 1, GIMPLE_DEBUG_BIND_NOVALUE); |
3399 | } | |
3400 | ||
3401 | /* Return true if the GIMPLE_DEBUG bind statement is bound to a | |
3402 | value. */ | |
3403 | ||
3404 | static inline bool | |
3405 | gimple_debug_bind_has_value_p (gimple dbg) | |
3406 | { | |
3407 | GIMPLE_CHECK (dbg, GIMPLE_DEBUG); | |
f68a75df | 3408 | #ifdef ENABLE_CHECKING |
b5b8b0ac | 3409 | gcc_assert (gimple_debug_bind_p (dbg)); |
f68a75df | 3410 | #endif |
b5b8b0ac AO |
3411 | return gimple_op (dbg, 1) != GIMPLE_DEBUG_BIND_NOVALUE; |
3412 | } | |
3413 | ||
3414 | #undef GIMPLE_DEBUG_BIND_NOVALUE | |
726a989a RB |
3415 | |
3416 | /* Return the body for the OMP statement GS. */ | |
3417 | ||
b8698a0f | 3418 | static inline gimple_seq |
726a989a RB |
3419 | gimple_omp_body (gimple gs) |
3420 | { | |
3421 | return gs->omp.body; | |
3422 | } | |
3423 | ||
3424 | /* Set BODY to be the body for the OMP statement GS. */ | |
3425 | ||
3426 | static inline void | |
3427 | gimple_omp_set_body (gimple gs, gimple_seq body) | |
3428 | { | |
3429 | gs->omp.body = body; | |
3430 | } | |
3431 | ||
3432 | ||
3433 | /* Return the name associated with OMP_CRITICAL statement GS. */ | |
3434 | ||
3435 | static inline tree | |
3436 | gimple_omp_critical_name (const_gimple gs) | |
3437 | { | |
3438 | GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL); | |
3439 | return gs->gimple_omp_critical.name; | |
3440 | } | |
3441 | ||
3442 | ||
3443 | /* Return a pointer to the name associated with OMP critical statement GS. */ | |
3444 | ||
3445 | static inline tree * | |
3446 | gimple_omp_critical_name_ptr (gimple gs) | |
3447 | { | |
3448 | GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL); | |
3449 | return &gs->gimple_omp_critical.name; | |
3450 | } | |
3451 | ||
3452 | ||
3453 | /* Set NAME to be the name associated with OMP critical statement GS. */ | |
3454 | ||
3455 | static inline void | |
3456 | gimple_omp_critical_set_name (gimple gs, tree name) | |
3457 | { | |
3458 | GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL); | |
3459 | gs->gimple_omp_critical.name = name; | |
3460 | } | |
3461 | ||
3462 | ||
3463 | /* Return the clauses associated with OMP_FOR GS. */ | |
3464 | ||
3465 | static inline tree | |
3466 | gimple_omp_for_clauses (const_gimple gs) | |
3467 | { | |
3468 | GIMPLE_CHECK (gs, GIMPLE_OMP_FOR); | |
3469 | return gs->gimple_omp_for.clauses; | |
3470 | } | |
3471 | ||
3472 | ||
3473 | /* Return a pointer to the OMP_FOR GS. */ | |
3474 | ||
3475 | static inline tree * | |
3476 | gimple_omp_for_clauses_ptr (gimple gs) | |
3477 | { | |
3478 | GIMPLE_CHECK (gs, GIMPLE_OMP_FOR); | |
3479 | return &gs->gimple_omp_for.clauses; | |
3480 | } | |
3481 | ||
3482 | ||
3483 | /* Set CLAUSES to be the list of clauses associated with OMP_FOR GS. */ | |
3484 | ||
3485 | static inline void | |
3486 | gimple_omp_for_set_clauses (gimple gs, tree clauses) | |
3487 | { | |
3488 | GIMPLE_CHECK (gs, GIMPLE_OMP_FOR); | |
3489 | gs->gimple_omp_for.clauses = clauses; | |
3490 | } | |
3491 | ||
3492 | ||
3493 | /* Get the collapse count of OMP_FOR GS. */ | |
3494 | ||
3495 | static inline size_t | |
3496 | gimple_omp_for_collapse (gimple gs) | |
3497 | { | |
3498 | GIMPLE_CHECK (gs, GIMPLE_OMP_FOR); | |
3499 | return gs->gimple_omp_for.collapse; | |
3500 | } | |
3501 | ||
3502 | ||
3503 | /* Return the index variable for OMP_FOR GS. */ | |
3504 | ||
3505 | static inline tree | |
3506 | gimple_omp_for_index (const_gimple gs, size_t i) | |
3507 | { | |
3508 | GIMPLE_CHECK (gs, GIMPLE_OMP_FOR); | |
3509 | gcc_assert (i < gs->gimple_omp_for.collapse); | |
3510 | return gs->gimple_omp_for.iter[i].index; | |
3511 | } | |
3512 | ||
3513 | ||
3514 | /* Return a pointer to the index variable for OMP_FOR GS. */ | |
3515 | ||
3516 | static inline tree * | |
3517 | gimple_omp_for_index_ptr (gimple gs, size_t i) | |
3518 | { | |
3519 | GIMPLE_CHECK (gs, GIMPLE_OMP_FOR); | |
3520 | gcc_assert (i < gs->gimple_omp_for.collapse); | |
3521 | return &gs->gimple_omp_for.iter[i].index; | |
3522 | } | |
3523 | ||
3524 | ||
3525 | /* Set INDEX to be the index variable for OMP_FOR GS. */ | |
3526 | ||
3527 | static inline void | |
3528 | gimple_omp_for_set_index (gimple gs, size_t i, tree index) | |
3529 | { | |
3530 | GIMPLE_CHECK (gs, GIMPLE_OMP_FOR); | |
3531 | gcc_assert (i < gs->gimple_omp_for.collapse); | |
3532 | gs->gimple_omp_for.iter[i].index = index; | |
3533 | } | |
3534 | ||
3535 | ||
3536 | /* Return the initial value for OMP_FOR GS. */ | |
3537 | ||
3538 | static inline tree | |
3539 | gimple_omp_for_initial (const_gimple gs, size_t i) | |
3540 | { | |
3541 | GIMPLE_CHECK (gs, GIMPLE_OMP_FOR); | |
3542 | gcc_assert (i < gs->gimple_omp_for.collapse); | |
3543 | return gs->gimple_omp_for.iter[i].initial; | |
3544 | } | |
3545 | ||
3546 | ||
3547 | /* Return a pointer to the initial value for OMP_FOR GS. */ | |
3548 | ||
3549 | static inline tree * | |
3550 | gimple_omp_for_initial_ptr (gimple gs, size_t i) | |
3551 | { | |
3552 | GIMPLE_CHECK (gs, GIMPLE_OMP_FOR); | |
3553 | gcc_assert (i < gs->gimple_omp_for.collapse); | |
3554 | return &gs->gimple_omp_for.iter[i].initial; | |
3555 | } | |
3556 | ||
3557 | ||
3558 | /* Set INITIAL to be the initial value for OMP_FOR GS. */ | |
3559 | ||
3560 | static inline void | |
3561 | gimple_omp_for_set_initial (gimple gs, size_t i, tree initial) | |
3562 | { | |
3563 | GIMPLE_CHECK (gs, GIMPLE_OMP_FOR); | |
3564 | gcc_assert (i < gs->gimple_omp_for.collapse); | |
3565 | gs->gimple_omp_for.iter[i].initial = initial; | |
3566 | } | |
3567 | ||
3568 | ||
3569 | /* Return the final value for OMP_FOR GS. */ | |
3570 | ||
3571 | static inline tree | |
3572 | gimple_omp_for_final (const_gimple gs, size_t i) | |
3573 | { | |
3574 | GIMPLE_CHECK (gs, GIMPLE_OMP_FOR); | |
3575 | gcc_assert (i < gs->gimple_omp_for.collapse); | |
3576 | return gs->gimple_omp_for.iter[i].final; | |
3577 | } | |
3578 | ||
3579 | ||
3580 | /* Return a pointer to the final value for OMP_FOR GS. */ | |
3581 | ||
3582 | static inline tree * | |
3583 | gimple_omp_for_final_ptr (gimple gs, size_t i) | |
3584 | { | |
3585 | GIMPLE_CHECK (gs, GIMPLE_OMP_FOR); | |
3586 | gcc_assert (i < gs->gimple_omp_for.collapse); | |
3587 | return &gs->gimple_omp_for.iter[i].final; | |
3588 | } | |
3589 | ||
3590 | ||
3591 | /* Set FINAL to be the final value for OMP_FOR GS. */ | |
3592 | ||
3593 | static inline void | |
3594 | gimple_omp_for_set_final (gimple gs, size_t i, tree final) | |
3595 | { | |
3596 | GIMPLE_CHECK (gs, GIMPLE_OMP_FOR); | |
3597 | gcc_assert (i < gs->gimple_omp_for.collapse); | |
3598 | gs->gimple_omp_for.iter[i].final = final; | |
3599 | } | |
3600 | ||
3601 | ||
3602 | /* Return the increment value for OMP_FOR GS. */ | |
3603 | ||
3604 | static inline tree | |
3605 | gimple_omp_for_incr (const_gimple gs, size_t i) | |
3606 | { | |
3607 | GIMPLE_CHECK (gs, GIMPLE_OMP_FOR); | |
3608 | gcc_assert (i < gs->gimple_omp_for.collapse); | |
3609 | return gs->gimple_omp_for.iter[i].incr; | |
3610 | } | |
3611 | ||
3612 | ||
3613 | /* Return a pointer to the increment value for OMP_FOR GS. */ | |
3614 | ||
3615 | static inline tree * | |
3616 | gimple_omp_for_incr_ptr (gimple gs, size_t i) | |
3617 | { | |
3618 | GIMPLE_CHECK (gs, GIMPLE_OMP_FOR); | |
3619 | gcc_assert (i < gs->gimple_omp_for.collapse); | |
3620 | return &gs->gimple_omp_for.iter[i].incr; | |
3621 | } | |
3622 | ||
3623 | ||
3624 | /* Set INCR to be the increment value for OMP_FOR GS. */ | |
3625 | ||
3626 | static inline void | |
3627 | gimple_omp_for_set_incr (gimple gs, size_t i, tree incr) | |
3628 | { | |
3629 | GIMPLE_CHECK (gs, GIMPLE_OMP_FOR); | |
3630 | gcc_assert (i < gs->gimple_omp_for.collapse); | |
3631 | gs->gimple_omp_for.iter[i].incr = incr; | |
3632 | } | |
3633 | ||
3634 | ||
3635 | /* Return the sequence of statements to execute before the OMP_FOR | |
3636 | statement GS starts. */ | |
3637 | ||
3638 | static inline gimple_seq | |
3639 | gimple_omp_for_pre_body (gimple gs) | |
3640 | { | |
3641 | GIMPLE_CHECK (gs, GIMPLE_OMP_FOR); | |
3642 | return gs->gimple_omp_for.pre_body; | |
3643 | } | |
3644 | ||
3645 | ||
3646 | /* Set PRE_BODY to be the sequence of statements to execute before the | |
3647 | OMP_FOR statement GS starts. */ | |
3648 | ||
3649 | static inline void | |
3650 | gimple_omp_for_set_pre_body (gimple gs, gimple_seq pre_body) | |
3651 | { | |
3652 | GIMPLE_CHECK (gs, GIMPLE_OMP_FOR); | |
3653 | gs->gimple_omp_for.pre_body = pre_body; | |
3654 | } | |
3655 | ||
3656 | ||
3657 | /* Return the clauses associated with OMP_PARALLEL GS. */ | |
3658 | ||
3659 | static inline tree | |
3660 | gimple_omp_parallel_clauses (const_gimple gs) | |
3661 | { | |
3662 | GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL); | |
3663 | return gs->gimple_omp_parallel.clauses; | |
3664 | } | |
3665 | ||
3666 | ||
3667 | /* Return a pointer to the clauses associated with OMP_PARALLEL GS. */ | |
3668 | ||
3669 | static inline tree * | |
3670 | gimple_omp_parallel_clauses_ptr (gimple gs) | |
3671 | { | |
3672 | GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL); | |
3673 | return &gs->gimple_omp_parallel.clauses; | |
3674 | } | |
3675 | ||
3676 | ||
3677 | /* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL | |
3678 | GS. */ | |
3679 | ||
3680 | static inline void | |
3681 | gimple_omp_parallel_set_clauses (gimple gs, tree clauses) | |
3682 | { | |
3683 | GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL); | |
3684 | gs->gimple_omp_parallel.clauses = clauses; | |
3685 | } | |
3686 | ||
3687 | ||
3688 | /* Return the child function used to hold the body of OMP_PARALLEL GS. */ | |
3689 | ||
3690 | static inline tree | |
3691 | gimple_omp_parallel_child_fn (const_gimple gs) | |
3692 | { | |
3693 | GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL); | |
3694 | return gs->gimple_omp_parallel.child_fn; | |
3695 | } | |
3696 | ||
3697 | /* Return a pointer to the child function used to hold the body of | |
3698 | OMP_PARALLEL GS. */ | |
3699 | ||
3700 | static inline tree * | |
3701 | gimple_omp_parallel_child_fn_ptr (gimple gs) | |
3702 | { | |
3703 | GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL); | |
3704 | return &gs->gimple_omp_parallel.child_fn; | |
3705 | } | |
3706 | ||
3707 | ||
3708 | /* Set CHILD_FN to be the child function for OMP_PARALLEL GS. */ | |
3709 | ||
3710 | static inline void | |
3711 | gimple_omp_parallel_set_child_fn (gimple gs, tree child_fn) | |
3712 | { | |
3713 | GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL); | |
3714 | gs->gimple_omp_parallel.child_fn = child_fn; | |
3715 | } | |
3716 | ||
3717 | ||
3718 | /* Return the artificial argument used to send variables and values | |
3719 | from the parent to the children threads in OMP_PARALLEL GS. */ | |
3720 | ||
3721 | static inline tree | |
3722 | gimple_omp_parallel_data_arg (const_gimple gs) | |
3723 | { | |
3724 | GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL); | |
3725 | return gs->gimple_omp_parallel.data_arg; | |
3726 | } | |
3727 | ||
3728 | ||
3729 | /* Return a pointer to the data argument for OMP_PARALLEL GS. */ | |
3730 | ||
3731 | static inline tree * | |
3732 | gimple_omp_parallel_data_arg_ptr (gimple gs) | |
3733 | { | |
3734 | GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL); | |
3735 | return &gs->gimple_omp_parallel.data_arg; | |
3736 | } | |
3737 | ||
3738 | ||
3739 | /* Set DATA_ARG to be the data argument for OMP_PARALLEL GS. */ | |
3740 | ||
3741 | static inline void | |
3742 | gimple_omp_parallel_set_data_arg (gimple gs, tree data_arg) | |
3743 | { | |
3744 | GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL); | |
3745 | gs->gimple_omp_parallel.data_arg = data_arg; | |
3746 | } | |
3747 | ||
3748 | ||
3749 | /* Return the clauses associated with OMP_TASK GS. */ | |
3750 | ||
3751 | static inline tree | |
3752 | gimple_omp_task_clauses (const_gimple gs) | |
3753 | { | |
3754 | GIMPLE_CHECK (gs, GIMPLE_OMP_TASK); | |
3755 | return gs->gimple_omp_parallel.clauses; | |
3756 | } | |
3757 | ||
3758 | ||
3759 | /* Return a pointer to the clauses associated with OMP_TASK GS. */ | |
3760 | ||
3761 | static inline tree * | |
3762 | gimple_omp_task_clauses_ptr (gimple gs) | |
3763 | { | |
3764 | GIMPLE_CHECK (gs, GIMPLE_OMP_TASK); | |
3765 | return &gs->gimple_omp_parallel.clauses; | |
3766 | } | |
3767 | ||
3768 | ||
3769 | /* Set CLAUSES to be the list of clauses associated with OMP_TASK | |
3770 | GS. */ | |
3771 | ||
3772 | static inline void | |
3773 | gimple_omp_task_set_clauses (gimple gs, tree clauses) | |
3774 | { | |
3775 | GIMPLE_CHECK (gs, GIMPLE_OMP_TASK); | |
3776 | gs->gimple_omp_parallel.clauses = clauses; | |
3777 | } | |
3778 | ||
3779 | ||
3780 | /* Return the child function used to hold the body of OMP_TASK GS. */ | |
3781 | ||
3782 | static inline tree | |
3783 | gimple_omp_task_child_fn (const_gimple gs) | |
3784 | { | |
3785 | GIMPLE_CHECK (gs, GIMPLE_OMP_TASK); | |
3786 | return gs->gimple_omp_parallel.child_fn; | |
3787 | } | |
3788 | ||
3789 | /* Return a pointer to the child function used to hold the body of | |
3790 | OMP_TASK GS. */ | |
3791 | ||
3792 | static inline tree * | |
3793 | gimple_omp_task_child_fn_ptr (gimple gs) | |
3794 | { | |
3795 | GIMPLE_CHECK (gs, GIMPLE_OMP_TASK); | |
3796 | return &gs->gimple_omp_parallel.child_fn; | |
3797 | } | |
3798 | ||
3799 | ||
3800 | /* Set CHILD_FN to be the child function for OMP_TASK GS. */ | |
3801 | ||
3802 | static inline void | |
3803 | gimple_omp_task_set_child_fn (gimple gs, tree child_fn) | |
3804 | { | |
3805 | GIMPLE_CHECK (gs, GIMPLE_OMP_TASK); | |
3806 | gs->gimple_omp_parallel.child_fn = child_fn; | |
3807 | } | |
3808 | ||
3809 | ||
3810 | /* Return the artificial argument used to send variables and values | |
3811 | from the parent to the children threads in OMP_TASK GS. */ | |
3812 | ||
3813 | static inline tree | |
3814 | gimple_omp_task_data_arg (const_gimple gs) | |
3815 | { | |
3816 | GIMPLE_CHECK (gs, GIMPLE_OMP_TASK); | |
3817 | return gs->gimple_omp_parallel.data_arg; | |
3818 | } | |
3819 | ||
3820 | ||
3821 | /* Return a pointer to the data argument for OMP_TASK GS. */ | |
3822 | ||
3823 | static inline tree * | |
3824 | gimple_omp_task_data_arg_ptr (gimple gs) | |
3825 | { | |
3826 | GIMPLE_CHECK (gs, GIMPLE_OMP_TASK); | |
3827 | return &gs->gimple_omp_parallel.data_arg; | |
3828 | } | |
3829 | ||
3830 | ||
3831 | /* Set DATA_ARG to be the data argument for OMP_TASK GS. */ | |
3832 | ||
3833 | static inline void | |
3834 | gimple_omp_task_set_data_arg (gimple gs, tree data_arg) | |
3835 | { | |
3836 | GIMPLE_CHECK (gs, GIMPLE_OMP_TASK); | |
3837 | gs->gimple_omp_parallel.data_arg = data_arg; | |
3838 | } | |
3839 | ||
3840 | ||
3841 | /* Return the clauses associated with OMP_TASK GS. */ | |
3842 | ||
3843 | static inline tree | |
3844 | gimple_omp_taskreg_clauses (const_gimple gs) | |
3845 | { | |
3846 | if (gimple_code (gs) != GIMPLE_OMP_PARALLEL) | |
3847 | GIMPLE_CHECK (gs, GIMPLE_OMP_TASK); | |
3848 | return gs->gimple_omp_parallel.clauses; | |
3849 | } | |
3850 | ||
3851 | ||
3852 | /* Return a pointer to the clauses associated with OMP_TASK GS. */ | |
3853 | ||
3854 | static inline tree * | |
3855 | gimple_omp_taskreg_clauses_ptr (gimple gs) | |
3856 | { | |
3857 | if (gimple_code (gs) != GIMPLE_OMP_PARALLEL) | |
3858 | GIMPLE_CHECK (gs, GIMPLE_OMP_TASK); | |
3859 | return &gs->gimple_omp_parallel.clauses; | |
3860 | } | |
3861 | ||
3862 | ||
3863 | /* Set CLAUSES to be the list of clauses associated with OMP_TASK | |
3864 | GS. */ | |
3865 | ||
3866 | static inline void | |
3867 | gimple_omp_taskreg_set_clauses (gimple gs, tree clauses) | |
3868 | { | |
3869 | if (gimple_code (gs) != GIMPLE_OMP_PARALLEL) | |
3870 | GIMPLE_CHECK (gs, GIMPLE_OMP_TASK); | |
3871 | gs->gimple_omp_parallel.clauses = clauses; | |
3872 | } | |
3873 | ||
3874 | ||
3875 | /* Return the child function used to hold the body of OMP_TASK GS. */ | |
3876 | ||
3877 | static inline tree | |
3878 | gimple_omp_taskreg_child_fn (const_gimple gs) | |
3879 | { | |
3880 | if (gimple_code (gs) != GIMPLE_OMP_PARALLEL) | |
3881 | GIMPLE_CHECK (gs, GIMPLE_OMP_TASK); | |
3882 | return gs->gimple_omp_parallel.child_fn; | |
3883 | } | |
3884 | ||
3885 | /* Return a pointer to the child function used to hold the body of | |
3886 | OMP_TASK GS. */ | |
3887 | ||
3888 | static inline tree * | |
3889 | gimple_omp_taskreg_child_fn_ptr (gimple gs) | |
3890 | { | |
3891 | if (gimple_code (gs) != GIMPLE_OMP_PARALLEL) | |
3892 | GIMPLE_CHECK (gs, GIMPLE_OMP_TASK); | |
3893 | return &gs->gimple_omp_parallel.child_fn; | |
3894 | } | |
3895 | ||
3896 | ||
3897 | /* Set CHILD_FN to be the child function for OMP_TASK GS. */ | |
3898 | ||
3899 | static inline void | |
3900 | gimple_omp_taskreg_set_child_fn (gimple gs, tree child_fn) | |
3901 | { | |
3902 | if (gimple_code (gs) != GIMPLE_OMP_PARALLEL) | |
3903 | GIMPLE_CHECK (gs, GIMPLE_OMP_TASK); | |
3904 | gs->gimple_omp_parallel.child_fn = child_fn; | |
3905 | } | |
3906 | ||
3907 | ||
3908 | /* Return the artificial argument used to send variables and values | |
3909 | from the parent to the children threads in OMP_TASK GS. */ | |
3910 | ||
3911 | static inline tree | |
3912 | gimple_omp_taskreg_data_arg (const_gimple gs) | |
3913 | { | |
3914 | if (gimple_code (gs) != GIMPLE_OMP_PARALLEL) | |
3915 | GIMPLE_CHECK (gs, GIMPLE_OMP_TASK); | |
3916 | return gs->gimple_omp_parallel.data_arg; | |
3917 | } | |
3918 | ||
3919 | ||
3920 | /* Return a pointer to the data argument for OMP_TASK GS. */ | |
3921 | ||
3922 | static inline tree * | |
3923 | gimple_omp_taskreg_data_arg_ptr (gimple gs) | |
3924 | { | |
3925 | if (gimple_code (gs) != GIMPLE_OMP_PARALLEL) | |
3926 | GIMPLE_CHECK (gs, GIMPLE_OMP_TASK); | |
3927 | return &gs->gimple_omp_parallel.data_arg; | |
3928 | } | |
3929 | ||
3930 | ||
3931 | /* Set DATA_ARG to be the data argument for OMP_TASK GS. */ | |
3932 | ||
3933 | static inline void | |
3934 | gimple_omp_taskreg_set_data_arg (gimple gs, tree data_arg) | |
3935 | { | |
3936 | if (gimple_code (gs) != GIMPLE_OMP_PARALLEL) | |
3937 | GIMPLE_CHECK (gs, GIMPLE_OMP_TASK); | |
3938 | gs->gimple_omp_parallel.data_arg = data_arg; | |
3939 | } | |
3940 | ||
3941 | ||
3942 | /* Return the copy function used to hold the body of OMP_TASK GS. */ | |
3943 | ||
3944 | static inline tree | |
3945 | gimple_omp_task_copy_fn (const_gimple gs) | |
3946 | { | |
3947 | GIMPLE_CHECK (gs, GIMPLE_OMP_TASK); | |
3948 | return gs->gimple_omp_task.copy_fn; | |
3949 | } | |
3950 | ||
3951 | /* Return a pointer to the copy function used to hold the body of | |
3952 | OMP_TASK GS. */ | |
3953 | ||
3954 | static inline tree * | |
3955 | gimple_omp_task_copy_fn_ptr (gimple gs) | |
3956 | { | |
3957 | GIMPLE_CHECK (gs, GIMPLE_OMP_TASK); | |
3958 | return &gs->gimple_omp_task.copy_fn; | |
3959 | } | |
3960 | ||
3961 | ||
3962 | /* Set CHILD_FN to be the copy function for OMP_TASK GS. */ | |
3963 | ||
3964 | static inline void | |
3965 | gimple_omp_task_set_copy_fn (gimple gs, tree copy_fn) | |
3966 | { | |
3967 | GIMPLE_CHECK (gs, GIMPLE_OMP_TASK); | |
3968 | gs->gimple_omp_task.copy_fn = copy_fn; | |
3969 | } | |
3970 | ||
3971 | ||
3972 | /* Return size of the data block in bytes in OMP_TASK GS. */ | |
3973 | ||
3974 | static inline tree | |
3975 | gimple_omp_task_arg_size (const_gimple gs) | |
3976 | { | |
3977 | GIMPLE_CHECK (gs, GIMPLE_OMP_TASK); | |
3978 | return gs->gimple_omp_task.arg_size; | |
3979 | } | |
3980 | ||
3981 | ||
3982 | /* Return a pointer to the data block size for OMP_TASK GS. */ | |
3983 | ||
3984 | static inline tree * | |
3985 | gimple_omp_task_arg_size_ptr (gimple gs) | |
3986 | { | |
3987 | GIMPLE_CHECK (gs, GIMPLE_OMP_TASK); | |
3988 | return &gs->gimple_omp_task.arg_size; | |
3989 | } | |
3990 | ||
3991 | ||
3992 | /* Set ARG_SIZE to be the data block size for OMP_TASK GS. */ | |
3993 | ||
3994 | static inline void | |
3995 | gimple_omp_task_set_arg_size (gimple gs, tree arg_size) | |
3996 | { | |
3997 | GIMPLE_CHECK (gs, GIMPLE_OMP_TASK); | |
3998 | gs->gimple_omp_task.arg_size = arg_size; | |
3999 | } | |
4000 | ||
4001 | ||
4002 | /* Return align of the data block in bytes in OMP_TASK GS. */ | |
4003 | ||
4004 | static inline tree | |
4005 | gimple_omp_task_arg_align (const_gimple gs) | |
4006 | { | |
4007 | GIMPLE_CHECK (gs, GIMPLE_OMP_TASK); | |
4008 | return gs->gimple_omp_task.arg_align; | |
4009 | } | |
4010 | ||
4011 | ||
4012 | /* Return a pointer to the data block align for OMP_TASK GS. */ | |
4013 | ||
4014 | static inline tree * | |
4015 | gimple_omp_task_arg_align_ptr (gimple gs) | |
4016 | { | |
4017 | GIMPLE_CHECK (gs, GIMPLE_OMP_TASK); | |
4018 | return &gs->gimple_omp_task.arg_align; | |
4019 | } | |
4020 | ||
4021 | ||
4022 | /* Set ARG_SIZE to be the data block align for OMP_TASK GS. */ | |
4023 | ||
4024 | static inline void | |
4025 | gimple_omp_task_set_arg_align (gimple gs, tree arg_align) | |
4026 | { | |
4027 | GIMPLE_CHECK (gs, GIMPLE_OMP_TASK); | |
4028 | gs->gimple_omp_task.arg_align = arg_align; | |
4029 | } | |
4030 | ||
4031 | ||
4032 | /* Return the clauses associated with OMP_SINGLE GS. */ | |
4033 | ||
4034 | static inline tree | |
4035 | gimple_omp_single_clauses (const_gimple gs) | |
4036 | { | |
4037 | GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE); | |
4038 | return gs->gimple_omp_single.clauses; | |
4039 | } | |
4040 | ||
4041 | ||
4042 | /* Return a pointer to the clauses associated with OMP_SINGLE GS. */ | |
4043 | ||
4044 | static inline tree * | |
4045 | gimple_omp_single_clauses_ptr (gimple gs) | |
4046 | { | |
4047 | GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE); | |
4048 | return &gs->gimple_omp_single.clauses; | |
4049 | } | |
4050 | ||
4051 | ||
4052 | /* Set CLAUSES to be the clauses associated with OMP_SINGLE GS. */ | |
4053 | ||
4054 | static inline void | |
4055 | gimple_omp_single_set_clauses (gimple gs, tree clauses) | |
4056 | { | |
4057 | GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE); | |
4058 | gs->gimple_omp_single.clauses = clauses; | |
4059 | } | |
4060 | ||
4061 | ||
4062 | /* Return the clauses associated with OMP_SECTIONS GS. */ | |
4063 | ||
4064 | static inline tree | |
4065 | gimple_omp_sections_clauses (const_gimple gs) | |
4066 | { | |
4067 | GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS); | |
4068 | return gs->gimple_omp_sections.clauses; | |
4069 | } | |
4070 | ||
4071 | ||
4072 | /* Return a pointer to the clauses associated with OMP_SECTIONS GS. */ | |
4073 | ||
4074 | static inline tree * | |
4075 | gimple_omp_sections_clauses_ptr (gimple gs) | |
4076 | { | |
4077 | GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS); | |
4078 | return &gs->gimple_omp_sections.clauses; | |
4079 | } | |
4080 | ||
4081 | ||
4082 | /* Set CLAUSES to be the set of clauses associated with OMP_SECTIONS | |
4083 | GS. */ | |
4084 | ||
4085 | static inline void | |
4086 | gimple_omp_sections_set_clauses (gimple gs, tree clauses) | |
4087 | { | |
4088 | GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS); | |
4089 | gs->gimple_omp_sections.clauses = clauses; | |
4090 | } | |
4091 | ||
4092 | ||
4093 | /* Return the control variable associated with the GIMPLE_OMP_SECTIONS | |
4094 | in GS. */ | |
4095 | ||
4096 | static inline tree | |
4097 | gimple_omp_sections_control (const_gimple gs) | |
4098 | { | |
4099 | GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS); | |
4100 | return gs->gimple_omp_sections.control; | |
4101 | } | |
4102 | ||
4103 | ||
4104 | /* Return a pointer to the clauses associated with the GIMPLE_OMP_SECTIONS | |
4105 | GS. */ | |
4106 | ||
4107 | static inline tree * | |
4108 | gimple_omp_sections_control_ptr (gimple gs) | |
4109 | { | |
4110 | GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS); | |
4111 | return &gs->gimple_omp_sections.control; | |
4112 | } | |
4113 | ||
4114 | ||
4115 | /* Set CONTROL to be the set of clauses associated with the | |
4116 | GIMPLE_OMP_SECTIONS in GS. */ | |
4117 | ||
4118 | static inline void | |
4119 | gimple_omp_sections_set_control (gimple gs, tree control) | |
4120 | { | |
4121 | GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS); | |
4122 | gs->gimple_omp_sections.control = control; | |
4123 | } | |
4124 | ||
4125 | ||
4126 | /* Set COND to be the condition code for OMP_FOR GS. */ | |
4127 | ||
4128 | static inline void | |
4129 | gimple_omp_for_set_cond (gimple gs, size_t i, enum tree_code cond) | |
4130 | { | |
4131 | GIMPLE_CHECK (gs, GIMPLE_OMP_FOR); | |
4132 | gcc_assert (TREE_CODE_CLASS (cond) == tcc_comparison); | |
4133 | gcc_assert (i < gs->gimple_omp_for.collapse); | |
4134 | gs->gimple_omp_for.iter[i].cond = cond; | |
4135 | } | |
4136 | ||
4137 | ||
4138 | /* Return the condition code associated with OMP_FOR GS. */ | |
4139 | ||
4140 | static inline enum tree_code | |
4141 | gimple_omp_for_cond (const_gimple gs, size_t i) | |
4142 | { | |
4143 | GIMPLE_CHECK (gs, GIMPLE_OMP_FOR); | |
4144 | gcc_assert (i < gs->gimple_omp_for.collapse); | |
4145 | return gs->gimple_omp_for.iter[i].cond; | |
4146 | } | |
4147 | ||
4148 | ||
4149 | /* Set the value being stored in an atomic store. */ | |
4150 | ||
4151 | static inline void | |
4152 | gimple_omp_atomic_store_set_val (gimple g, tree val) | |
4153 | { | |
4154 | GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE); | |
4155 | g->gimple_omp_atomic_store.val = val; | |
4156 | } | |
4157 | ||
4158 | ||
4159 | /* Return the value being stored in an atomic store. */ | |
4160 | ||
4161 | static inline tree | |
4162 | gimple_omp_atomic_store_val (const_gimple g) | |
4163 | { | |
4164 | GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE); | |
4165 | return g->gimple_omp_atomic_store.val; | |
4166 | } | |
4167 | ||
4168 | ||
4169 | /* Return a pointer to the value being stored in an atomic store. */ | |
4170 | ||
4171 | static inline tree * | |
4172 | gimple_omp_atomic_store_val_ptr (gimple g) | |
4173 | { | |
4174 | GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE); | |
4175 | return &g->gimple_omp_atomic_store.val; | |
4176 | } | |
4177 | ||
4178 | ||
4179 | /* Set the LHS of an atomic load. */ | |
4180 | ||
4181 | static inline void | |
4182 | gimple_omp_atomic_load_set_lhs (gimple g, tree lhs) | |
4183 | { | |
4184 | GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD); | |
4185 | g->gimple_omp_atomic_load.lhs = lhs; | |
4186 | } | |
4187 | ||
4188 | ||
4189 | /* Get the LHS of an atomic load. */ | |
4190 | ||
4191 | static inline tree | |
4192 | gimple_omp_atomic_load_lhs (const_gimple g) | |
4193 | { | |
4194 | GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD); | |
4195 | return g->gimple_omp_atomic_load.lhs; | |
4196 | } | |
4197 | ||
4198 | ||
4199 | /* Return a pointer to the LHS of an atomic load. */ | |
4200 | ||
4201 | static inline tree * | |
4202 | gimple_omp_atomic_load_lhs_ptr (gimple g) | |
4203 | { | |
4204 | GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD); | |
4205 | return &g->gimple_omp_atomic_load.lhs; | |
4206 | } | |
4207 | ||
4208 | ||
4209 | /* Set the RHS of an atomic load. */ | |
4210 | ||
4211 | static inline void | |
4212 | gimple_omp_atomic_load_set_rhs (gimple g, tree rhs) | |
4213 | { | |
4214 | GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD); | |
4215 | g->gimple_omp_atomic_load.rhs = rhs; | |
4216 | } | |
4217 | ||
4218 | ||
4219 | /* Get the RHS of an atomic load. */ | |
4220 | ||
4221 | static inline tree | |
4222 | gimple_omp_atomic_load_rhs (const_gimple g) | |
4223 | { | |
4224 | GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD); | |
4225 | return g->gimple_omp_atomic_load.rhs; | |
4226 | } | |
4227 | ||
4228 | ||
4229 | /* Return a pointer to the RHS of an atomic load. */ | |
4230 | ||
4231 | static inline tree * | |
4232 | gimple_omp_atomic_load_rhs_ptr (gimple g) | |
4233 | { | |
4234 | GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD); | |
4235 | return &g->gimple_omp_atomic_load.rhs; | |
4236 | } | |
4237 | ||
4238 | ||
4239 | /* Get the definition of the control variable in a GIMPLE_OMP_CONTINUE. */ | |
4240 | ||
4241 | static inline tree | |
4242 | gimple_omp_continue_control_def (const_gimple g) | |
4243 | { | |
4244 | GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE); | |
4245 | return g->gimple_omp_continue.control_def; | |
4246 | } | |
4247 | ||
4248 | /* The same as above, but return the address. */ | |
4249 | ||
4250 | static inline tree * | |
4251 | gimple_omp_continue_control_def_ptr (gimple g) | |
4252 | { | |
4253 | GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE); | |
4254 | return &g->gimple_omp_continue.control_def; | |
4255 | } | |
4256 | ||
4257 | /* Set the definition of the control variable in a GIMPLE_OMP_CONTINUE. */ | |
4258 | ||
4259 | static inline void | |
4260 | gimple_omp_continue_set_control_def (gimple g, tree def) | |
4261 | { | |
4262 | GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE); | |
4263 | g->gimple_omp_continue.control_def = def; | |
4264 | } | |
4265 | ||
4266 | ||
4267 | /* Get the use of the control variable in a GIMPLE_OMP_CONTINUE. */ | |
4268 | ||
4269 | static inline tree | |
4270 | gimple_omp_continue_control_use (const_gimple g) | |
4271 | { | |
4272 | GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE); | |
4273 | return g->gimple_omp_continue.control_use; | |
4274 | } | |
4275 | ||
4276 | ||
4277 | /* The same as above, but return the address. */ | |
4278 | ||
4279 | static inline tree * | |
4280 | gimple_omp_continue_control_use_ptr (gimple g) | |
4281 | { | |
4282 | GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE); | |
4283 | return &g->gimple_omp_continue.control_use; | |
4284 | } | |
4285 | ||
4286 | ||
4287 | /* Set the use of the control variable in a GIMPLE_OMP_CONTINUE. */ | |
4288 | ||
4289 | static inline void | |
4290 | gimple_omp_continue_set_control_use (gimple g, tree use) | |
4291 | { | |
4292 | GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE); | |
4293 | g->gimple_omp_continue.control_use = use; | |
4294 | } | |
4295 | ||
4296 | ||
4297 | /* Return a pointer to the return value for GIMPLE_RETURN GS. */ | |
4298 | ||
4299 | static inline tree * | |
4300 | gimple_return_retval_ptr (const_gimple gs) | |
4301 | { | |
4302 | GIMPLE_CHECK (gs, GIMPLE_RETURN); | |
726a989a RB |
4303 | return gimple_op_ptr (gs, 0); |
4304 | } | |
4305 | ||
4306 | /* Return the return value for GIMPLE_RETURN GS. */ | |
4307 | ||
4308 | static inline tree | |
4309 | gimple_return_retval (const_gimple gs) | |
4310 | { | |
4311 | GIMPLE_CHECK (gs, GIMPLE_RETURN); | |
726a989a RB |
4312 | return gimple_op (gs, 0); |
4313 | } | |
4314 | ||
4315 | ||
4316 | /* Set RETVAL to be the return value for GIMPLE_RETURN GS. */ | |
4317 | ||
4318 | static inline void | |
4319 | gimple_return_set_retval (gimple gs, tree retval) | |
4320 | { | |
4321 | GIMPLE_CHECK (gs, GIMPLE_RETURN); | |
726a989a RB |
4322 | gimple_set_op (gs, 0, retval); |
4323 | } | |
4324 | ||
4325 | ||
4326 | /* Returns true when the gimple statment STMT is any of the OpenMP types. */ | |
4327 | ||
8b9db065 RH |
4328 | #define CASE_GIMPLE_OMP \ |
4329 | case GIMPLE_OMP_PARALLEL: \ | |
4330 | case GIMPLE_OMP_TASK: \ | |
4331 | case GIMPLE_OMP_FOR: \ | |
4332 | case GIMPLE_OMP_SECTIONS: \ | |
4333 | case GIMPLE_OMP_SECTIONS_SWITCH: \ | |
4334 | case GIMPLE_OMP_SINGLE: \ | |
4335 | case GIMPLE_OMP_SECTION: \ | |
4336 | case GIMPLE_OMP_MASTER: \ | |
4337 | case GIMPLE_OMP_ORDERED: \ | |
4338 | case GIMPLE_OMP_CRITICAL: \ | |
4339 | case GIMPLE_OMP_RETURN: \ | |
4340 | case GIMPLE_OMP_ATOMIC_LOAD: \ | |
4341 | case GIMPLE_OMP_ATOMIC_STORE: \ | |
4342 | case GIMPLE_OMP_CONTINUE | |
4343 | ||
726a989a RB |
4344 | static inline bool |
4345 | is_gimple_omp (const_gimple stmt) | |
4346 | { | |
8b9db065 RH |
4347 | switch (gimple_code (stmt)) |
4348 | { | |
4349 | CASE_GIMPLE_OMP: | |
4350 | return true; | |
4351 | default: | |
4352 | return false; | |
4353 | } | |
726a989a RB |
4354 | } |
4355 | ||
4356 | ||
4357 | /* Returns TRUE if statement G is a GIMPLE_NOP. */ | |
4358 | ||
4359 | static inline bool | |
4360 | gimple_nop_p (const_gimple g) | |
4361 | { | |
4362 | return gimple_code (g) == GIMPLE_NOP; | |
4363 | } | |
4364 | ||
4365 | ||
1d65f45c RH |
4366 | /* Return true if GS is a GIMPLE_RESX. */ |
4367 | ||
4368 | static inline bool | |
4369 | is_gimple_resx (const_gimple gs) | |
4370 | { | |
4371 | return gimple_code (gs) == GIMPLE_RESX; | |
4372 | } | |
4373 | ||
726a989a RB |
4374 | /* Return the predictor of GIMPLE_PREDICT statement GS. */ |
4375 | ||
4376 | static inline enum br_predictor | |
4377 | gimple_predict_predictor (gimple gs) | |
4378 | { | |
4379 | GIMPLE_CHECK (gs, GIMPLE_PREDICT); | |
4380 | return (enum br_predictor) (gs->gsbase.subcode & ~GF_PREDICT_TAKEN); | |
4381 | } | |
4382 | ||
4383 | ||
4384 | /* Set the predictor of GIMPLE_PREDICT statement GS to PREDICT. */ | |
4385 | ||
4386 | static inline void | |
4387 | gimple_predict_set_predictor (gimple gs, enum br_predictor predictor) | |
4388 | { | |
4389 | GIMPLE_CHECK (gs, GIMPLE_PREDICT); | |
4390 | gs->gsbase.subcode = (gs->gsbase.subcode & GF_PREDICT_TAKEN) | |
4391 | | (unsigned) predictor; | |
4392 | } | |
4393 | ||
4394 | ||
4395 | /* Return the outcome of GIMPLE_PREDICT statement GS. */ | |
4396 | ||
4397 | static inline enum prediction | |
4398 | gimple_predict_outcome (gimple gs) | |
4399 | { | |
4400 | GIMPLE_CHECK (gs, GIMPLE_PREDICT); | |
4401 | return (gs->gsbase.subcode & GF_PREDICT_TAKEN) ? TAKEN : NOT_TAKEN; | |
4402 | } | |
4403 | ||
4404 | ||
4405 | /* Set the outcome of GIMPLE_PREDICT statement GS to OUTCOME. */ | |
4406 | ||
4407 | static inline void | |
4408 | gimple_predict_set_outcome (gimple gs, enum prediction outcome) | |
4409 | { | |
4410 | GIMPLE_CHECK (gs, GIMPLE_PREDICT); | |
4411 | if (outcome == TAKEN) | |
4412 | gs->gsbase.subcode |= GF_PREDICT_TAKEN; | |
4413 | else | |
4414 | gs->gsbase.subcode &= ~GF_PREDICT_TAKEN; | |
4415 | } | |
4416 | ||
4417 | ||
828552ed RG |
4418 | /* Return the type of the main expression computed by STMT. Return |
4419 | void_type_node if the statement computes nothing. */ | |
4420 | ||
4421 | static inline tree | |
4422 | gimple_expr_type (const_gimple stmt) | |
4423 | { | |
4424 | enum gimple_code code = gimple_code (stmt); | |
4425 | ||
4426 | if (code == GIMPLE_ASSIGN || code == GIMPLE_CALL) | |
4427 | { | |
4428 | tree type; | |
4429 | /* In general we want to pass out a type that can be substituted | |
4430 | for both the RHS and the LHS types if there is a possibly | |
4431 | useless conversion involved. That means returning the | |
4432 | original RHS type as far as we can reconstruct it. */ | |
4433 | if (code == GIMPLE_CALL) | |
4434 | type = gimple_call_return_type (stmt); | |
4435 | else | |
4436 | switch (gimple_assign_rhs_code (stmt)) | |
4437 | { | |
4438 | case POINTER_PLUS_EXPR: | |
4439 | type = TREE_TYPE (gimple_assign_rhs1 (stmt)); | |
4440 | break; | |
4441 | ||
4442 | default: | |
4443 | /* As fallback use the type of the LHS. */ | |
4444 | type = TREE_TYPE (gimple_get_lhs (stmt)); | |
4445 | break; | |
4446 | } | |
4447 | return type; | |
4448 | } | |
4449 | else if (code == GIMPLE_COND) | |
4450 | return boolean_type_node; | |
4451 | else | |
4452 | return void_type_node; | |
4453 | } | |
4454 | ||
4455 | ||
726a989a RB |
4456 | /* Return a new iterator pointing to GIMPLE_SEQ's first statement. */ |
4457 | ||
4458 | static inline gimple_stmt_iterator | |
4459 | gsi_start (gimple_seq seq) | |
4460 | { | |
4461 | gimple_stmt_iterator i; | |
4462 | ||
4463 | i.ptr = gimple_seq_first (seq); | |
4464 | i.seq = seq; | |
4465 | i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL; | |
4466 | ||
4467 | return i; | |
4468 | } | |
4469 | ||
4470 | ||
4471 | /* Return a new iterator pointing to the first statement in basic block BB. */ | |
4472 | ||
4473 | static inline gimple_stmt_iterator | |
4474 | gsi_start_bb (basic_block bb) | |
4475 | { | |
4476 | gimple_stmt_iterator i; | |
4477 | gimple_seq seq; | |
b8698a0f | 4478 | |
726a989a RB |
4479 | seq = bb_seq (bb); |
4480 | i.ptr = gimple_seq_first (seq); | |
4481 | i.seq = seq; | |
4482 | i.bb = bb; | |
4483 | ||
4484 | return i; | |
4485 | } | |
4486 | ||
4487 | ||
4488 | /* Return a new iterator initially pointing to GIMPLE_SEQ's last statement. */ | |
4489 | ||
4490 | static inline gimple_stmt_iterator | |
4491 | gsi_last (gimple_seq seq) | |
4492 | { | |
4493 | gimple_stmt_iterator i; | |
4494 | ||
4495 | i.ptr = gimple_seq_last (seq); | |
4496 | i.seq = seq; | |
4497 | i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL; | |
4498 | ||
4499 | return i; | |
4500 | } | |
4501 | ||
4502 | ||
4503 | /* Return a new iterator pointing to the last statement in basic block BB. */ | |
4504 | ||
4505 | static inline gimple_stmt_iterator | |
4506 | gsi_last_bb (basic_block bb) | |
4507 | { | |
4508 | gimple_stmt_iterator i; | |
4509 | gimple_seq seq; | |
4510 | ||
4511 | seq = bb_seq (bb); | |
4512 | i.ptr = gimple_seq_last (seq); | |
4513 | i.seq = seq; | |
4514 | i.bb = bb; | |
4515 | ||
4516 | return i; | |
4517 | } | |
4518 | ||
4519 | ||
4520 | /* Return true if I is at the end of its sequence. */ | |
4521 | ||
4522 | static inline bool | |
4523 | gsi_end_p (gimple_stmt_iterator i) | |
4524 | { | |
4525 | return i.ptr == NULL; | |
4526 | } | |
4527 | ||
4528 | ||
4529 | /* Return true if I is one statement before the end of its sequence. */ | |
4530 | ||
4531 | static inline bool | |
4532 | gsi_one_before_end_p (gimple_stmt_iterator i) | |
4533 | { | |
4534 | return i.ptr != NULL && i.ptr->next == NULL; | |
4535 | } | |
4536 | ||
4537 | ||
4538 | /* Advance the iterator to the next gimple statement. */ | |
4539 | ||
4540 | static inline void | |
4541 | gsi_next (gimple_stmt_iterator *i) | |
4542 | { | |
4543 | i->ptr = i->ptr->next; | |
4544 | } | |
4545 | ||
4546 | /* Advance the iterator to the previous gimple statement. */ | |
4547 | ||
4548 | static inline void | |
4549 | gsi_prev (gimple_stmt_iterator *i) | |
4550 | { | |
4551 | i->ptr = i->ptr->prev; | |
4552 | } | |
4553 | ||
4554 | /* Return the current stmt. */ | |
4555 | ||
4556 | static inline gimple | |
4557 | gsi_stmt (gimple_stmt_iterator i) | |
4558 | { | |
4559 | return i.ptr->stmt; | |
4560 | } | |
4561 | ||
4562 | /* Return a block statement iterator that points to the first non-label | |
4563 | statement in block BB. */ | |
4564 | ||
4565 | static inline gimple_stmt_iterator | |
4566 | gsi_after_labels (basic_block bb) | |
4567 | { | |
4568 | gimple_stmt_iterator gsi = gsi_start_bb (bb); | |
4569 | ||
4570 | while (!gsi_end_p (gsi) && gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL) | |
4571 | gsi_next (&gsi); | |
4572 | ||
4573 | return gsi; | |
4574 | } | |
4575 | ||
b5b8b0ac AO |
4576 | /* Advance the iterator to the next non-debug gimple statement. */ |
4577 | ||
4578 | static inline void | |
4579 | gsi_next_nondebug (gimple_stmt_iterator *i) | |
4580 | { | |
4581 | do | |
4582 | { | |
4583 | gsi_next (i); | |
4584 | } | |
4585 | while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i))); | |
4586 | } | |
4587 | ||
4588 | /* Advance the iterator to the next non-debug gimple statement. */ | |
4589 | ||
4590 | static inline void | |
4591 | gsi_prev_nondebug (gimple_stmt_iterator *i) | |
4592 | { | |
4593 | do | |
4594 | { | |
4595 | gsi_prev (i); | |
4596 | } | |
4597 | while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i))); | |
4598 | } | |
4599 | ||
4600 | /* Return a new iterator pointing to the first non-debug statement in | |
4601 | basic block BB. */ | |
4602 | ||
4603 | static inline gimple_stmt_iterator | |
4604 | gsi_start_nondebug_bb (basic_block bb) | |
4605 | { | |
4606 | gimple_stmt_iterator i = gsi_start_bb (bb); | |
4607 | ||
4608 | if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i))) | |
4609 | gsi_next_nondebug (&i); | |
4610 | ||
4611 | return i; | |
4612 | } | |
4613 | ||
4614 | /* Return a new iterator pointing to the last non-debug statement in | |
4615 | basic block BB. */ | |
4616 | ||
4617 | static inline gimple_stmt_iterator | |
4618 | gsi_last_nondebug_bb (basic_block bb) | |
4619 | { | |
4620 | gimple_stmt_iterator i = gsi_last_bb (bb); | |
4621 | ||
4622 | if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i))) | |
4623 | gsi_prev_nondebug (&i); | |
4624 | ||
4625 | return i; | |
4626 | } | |
4627 | ||
726a989a | 4628 | /* Return a pointer to the current stmt. |
b8698a0f | 4629 | |
726a989a RB |
4630 | NOTE: You may want to use gsi_replace on the iterator itself, |
4631 | as this performs additional bookkeeping that will not be done | |
4632 | if you simply assign through a pointer returned by gsi_stmt_ptr. */ | |
4633 | ||
4634 | static inline gimple * | |
4635 | gsi_stmt_ptr (gimple_stmt_iterator *i) | |
4636 | { | |
4637 | return &i->ptr->stmt; | |
4638 | } | |
4639 | ||
4640 | ||
4641 | /* Return the basic block associated with this iterator. */ | |
4642 | ||
4643 | static inline basic_block | |
4644 | gsi_bb (gimple_stmt_iterator i) | |
4645 | { | |
4646 | return i.bb; | |
4647 | } | |
4648 | ||
4649 | ||
4650 | /* Return the sequence associated with this iterator. */ | |
4651 | ||
4652 | static inline gimple_seq | |
4653 | gsi_seq (gimple_stmt_iterator i) | |
4654 | { | |
4655 | return i.seq; | |
4656 | } | |
4657 | ||
4658 | ||
4659 | enum gsi_iterator_update | |
4660 | { | |
4661 | GSI_NEW_STMT, /* Only valid when single statement is added, move | |
4662 | iterator to it. */ | |
4663 | GSI_SAME_STMT, /* Leave the iterator at the same statement. */ | |
4664 | GSI_CONTINUE_LINKING /* Move iterator to whatever position is suitable | |
4665 | for linking other statements in the same | |
4666 | direction. */ | |
4667 | }; | |
4668 | ||
4669 | /* In gimple-iterator.c */ | |
4670 | gimple_stmt_iterator gsi_start_phis (basic_block); | |
4671 | gimple_seq gsi_split_seq_after (gimple_stmt_iterator); | |
4672 | gimple_seq gsi_split_seq_before (gimple_stmt_iterator *); | |
4673 | void gsi_replace (gimple_stmt_iterator *, gimple, bool); | |
4674 | void gsi_insert_before (gimple_stmt_iterator *, gimple, | |
4675 | enum gsi_iterator_update); | |
4676 | void gsi_insert_before_without_update (gimple_stmt_iterator *, gimple, | |
4677 | enum gsi_iterator_update); | |
4678 | void gsi_insert_seq_before (gimple_stmt_iterator *, gimple_seq, | |
4679 | enum gsi_iterator_update); | |
4680 | void gsi_insert_seq_before_without_update (gimple_stmt_iterator *, gimple_seq, | |
4681 | enum gsi_iterator_update); | |
4682 | void gsi_insert_after (gimple_stmt_iterator *, gimple, | |
4683 | enum gsi_iterator_update); | |
4684 | void gsi_insert_after_without_update (gimple_stmt_iterator *, gimple, | |
4685 | enum gsi_iterator_update); | |
4686 | void gsi_insert_seq_after (gimple_stmt_iterator *, gimple_seq, | |
4687 | enum gsi_iterator_update); | |
4688 | void gsi_insert_seq_after_without_update (gimple_stmt_iterator *, gimple_seq, | |
4689 | enum gsi_iterator_update); | |
4690 | void gsi_remove (gimple_stmt_iterator *, bool); | |
4691 | gimple_stmt_iterator gsi_for_stmt (gimple); | |
4692 | void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *); | |
4693 | void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *); | |
4694 | void gsi_move_to_bb_end (gimple_stmt_iterator *, struct basic_block_def *); | |
4695 | void gsi_insert_on_edge (edge, gimple); | |
4696 | void gsi_insert_seq_on_edge (edge, gimple_seq); | |
4697 | basic_block gsi_insert_on_edge_immediate (edge, gimple); | |
4698 | basic_block gsi_insert_seq_on_edge_immediate (edge, gimple_seq); | |
4699 | void gsi_commit_one_edge_insert (edge, basic_block *); | |
4700 | void gsi_commit_edge_inserts (void); | |
5c0466b5 | 4701 | gimple gimple_call_copy_skip_args (gimple, bitmap); |
726a989a RB |
4702 | |
4703 | ||
4704 | /* Convenience routines to walk all statements of a gimple function. | |
4705 | Note that this is useful exclusively before the code is converted | |
4706 | into SSA form. Once the program is in SSA form, the standard | |
4707 | operand interface should be used to analyze/modify statements. */ | |
4708 | struct walk_stmt_info | |
4709 | { | |
4710 | /* Points to the current statement being walked. */ | |
4711 | gimple_stmt_iterator gsi; | |
4712 | ||
4713 | /* Additional data that the callback functions may want to carry | |
4714 | through the recursion. */ | |
4715 | void *info; | |
4716 | ||
4717 | /* Pointer map used to mark visited tree nodes when calling | |
4718 | walk_tree on each operand. If set to NULL, duplicate tree nodes | |
4719 | will be visited more than once. */ | |
4720 | struct pointer_set_t *pset; | |
4721 | ||
4722 | /* Indicates whether the operand being examined may be replaced | |
4723 | with something that matches is_gimple_val (if true) or something | |
4724 | slightly more complicated (if false). "Something" technically | |
4725 | means the common subset of is_gimple_lvalue and is_gimple_rhs, | |
4726 | but we never try to form anything more complicated than that, so | |
4727 | we don't bother checking. | |
4728 | ||
4729 | Also note that CALLBACK should update this flag while walking the | |
4730 | sub-expressions of a statement. For instance, when walking the | |
4731 | statement 'foo (&var)', the flag VAL_ONLY will initially be set | |
4732 | to true, however, when walking &var, the operand of that | |
4733 | ADDR_EXPR does not need to be a GIMPLE value. */ | |
4734 | bool val_only; | |
4735 | ||
4736 | /* True if we are currently walking the LHS of an assignment. */ | |
4737 | bool is_lhs; | |
4738 | ||
4739 | /* Optional. Set to true by the callback functions if they made any | |
4740 | changes. */ | |
4741 | bool changed; | |
4742 | ||
4743 | /* True if we're interested in location information. */ | |
4744 | bool want_locations; | |
4745 | ||
4746 | /* Operand returned by the callbacks. This is set when calling | |
4747 | walk_gimple_seq. If the walk_stmt_fn or walk_tree_fn callback | |
4748 | returns non-NULL, this field will contain the tree returned by | |
4749 | the last callback. */ | |
4750 | tree callback_result; | |
4751 | }; | |
4752 | ||
4753 | /* Callback for walk_gimple_stmt. Called for every statement found | |
4754 | during traversal. The first argument points to the statement to | |
4755 | walk. The second argument is a flag that the callback sets to | |
4756 | 'true' if it the callback handled all the operands and | |
4757 | sub-statements of the statement (the default value of this flag is | |
4758 | 'false'). The third argument is an anonymous pointer to data | |
4759 | to be used by the callback. */ | |
4760 | typedef tree (*walk_stmt_fn) (gimple_stmt_iterator *, bool *, | |
4761 | struct walk_stmt_info *); | |
4762 | ||
4763 | gimple walk_gimple_seq (gimple_seq, walk_stmt_fn, walk_tree_fn, | |
4764 | struct walk_stmt_info *); | |
4765 | tree walk_gimple_stmt (gimple_stmt_iterator *, walk_stmt_fn, walk_tree_fn, | |
4766 | struct walk_stmt_info *); | |
4767 | tree walk_gimple_op (gimple, walk_tree_fn, struct walk_stmt_info *); | |
4768 | ||
4769 | #ifdef GATHER_STATISTICS | |
4770 | /* Enum and arrays used for allocation stats. Keep in sync with | |
4771 | gimple.c:gimple_alloc_kind_names. */ | |
4772 | enum gimple_alloc_kind | |
4773 | { | |
4774 | gimple_alloc_kind_assign, /* Assignments. */ | |
4775 | gimple_alloc_kind_phi, /* PHI nodes. */ | |
4776 | gimple_alloc_kind_cond, /* Conditionals. */ | |
4777 | gimple_alloc_kind_seq, /* Sequences. */ | |
4778 | gimple_alloc_kind_rest, /* Everything else. */ | |
4779 | gimple_alloc_kind_all | |
4780 | }; | |
4781 | ||
4782 | extern int gimple_alloc_counts[]; | |
4783 | extern int gimple_alloc_sizes[]; | |
4784 | ||
4785 | /* Return the allocation kind for a given stmt CODE. */ | |
4786 | static inline enum gimple_alloc_kind | |
4787 | gimple_alloc_kind (enum gimple_code code) | |
4788 | { | |
4789 | switch (code) | |
4790 | { | |
4791 | case GIMPLE_ASSIGN: | |
4792 | return gimple_alloc_kind_assign; | |
4793 | case GIMPLE_PHI: | |
4794 | return gimple_alloc_kind_phi; | |
4795 | case GIMPLE_COND: | |
4796 | return gimple_alloc_kind_cond; | |
4797 | default: | |
4798 | return gimple_alloc_kind_rest; | |
4799 | } | |
4800 | } | |
4801 | #endif /* GATHER_STATISTICS */ | |
4802 | ||
4803 | extern void dump_gimple_statistics (void); | |
4804 | ||
cbdd87d4 RG |
4805 | /* In gimple-fold.c. */ |
4806 | void gimplify_and_update_call_from_tree (gimple_stmt_iterator *, tree); | |
4807 | tree gimple_fold_builtin (gimple); | |
4808 | bool fold_stmt (gimple_stmt_iterator *); | |
4809 | bool fold_stmt_inplace (gimple); | |
4810 | tree maybe_fold_offset_to_reference (location_t, tree, tree, tree); | |
4811 | tree maybe_fold_offset_to_address (location_t, tree, tree, tree); | |
4812 | tree maybe_fold_stmt_addition (location_t, tree, tree, tree); | |
4813 | tree get_symbol_constant_value (tree); | |
4814 | bool may_propagate_address_into_dereference (tree, tree); | |
4815 | ||
4816 | ||
726a989a | 4817 | #endif /* GCC_GIMPLE_H */ |