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