PR libgomp/38270
[official-gcc.git] / gcc / gimple.h
blobdebba122c9c209e8f84f1e9a271adad365ad65a0
1 /* Gimple IR definitions.
3 Copyright 2007, 2008 Free Software Foundation, Inc.
4 Contributed by Aldy Hernandez <aldyh@redhat.com>
6 This file is part of GCC.
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.
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.
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/>. */
22 #ifndef GCC_GIMPLE_H
23 #define GCC_GIMPLE_H
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"
33 DEF_VEC_P(gimple);
34 DEF_VEC_ALLOC_P(gimple,heap);
35 DEF_VEC_ALLOC_P(gimple,gc);
37 DEF_VEC_P(gimple_seq);
38 DEF_VEC_ALLOC_P(gimple_seq,gc);
39 DEF_VEC_ALLOC_P(gimple_seq,heap);
41 /* For each block, the PHI nodes that need to be rewritten are stored into
42 these vectors. */
43 typedef VEC(gimple, heap) *gimple_vec;
44 DEF_VEC_P (gimple_vec);
45 DEF_VEC_ALLOC_P (gimple_vec, heap);
47 enum gimple_code {
48 #define DEFGSCODE(SYM, STRING, STRUCT) SYM,
49 #include "gimple.def"
50 #undef DEFGSCODE
51 LAST_AND_UNUSED_GIMPLE_CODE
54 extern const char *const gimple_code_name[];
55 extern const unsigned char gimple_rhs_class_table[];
57 /* Error out if a gimple tuple is addressed incorrectly. */
58 #if defined ENABLE_GIMPLE_CHECKING
59 extern void gimple_check_failed (const_gimple, const char *, int, \
60 const char *, enum gimple_code, \
61 enum tree_code) ATTRIBUTE_NORETURN;
63 #define GIMPLE_CHECK(GS, CODE) \
64 do { \
65 const_gimple __gs = (GS); \
66 if (gimple_code (__gs) != (CODE)) \
67 gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__, \
68 (CODE), 0); \
69 } while (0)
70 #else /* not ENABLE_GIMPLE_CHECKING */
71 #define GIMPLE_CHECK(GS, CODE) (void)0
72 #endif
74 /* Class of GIMPLE expressions suitable for the RHS of assignments. See
75 get_gimple_rhs_class. */
76 enum gimple_rhs_class
78 GIMPLE_INVALID_RHS, /* The expression cannot be used on the RHS. */
79 GIMPLE_BINARY_RHS, /* The expression is a binary operation. */
80 GIMPLE_UNARY_RHS, /* The expression is a unary operation. */
81 GIMPLE_SINGLE_RHS /* The expression is a single object (an SSA
82 name, a _DECL, a _REF, etc. */
85 /* Specific flags for individual GIMPLE statements. These flags are
86 always stored in gimple_statement_base.subcode and they may only be
87 defined for statement codes that do not use sub-codes.
89 Values for the masks can overlap as long as the overlapping values
90 are never used in the same statement class.
92 The maximum mask value that can be defined is 1 << 15 (i.e., each
93 statement code can hold up to 16 bitflags).
95 Keep this list sorted. */
96 enum gf_mask {
97 GF_ASM_INPUT = 1 << 0,
98 GF_ASM_VOLATILE = 1 << 1,
99 GF_CALL_CANNOT_INLINE = 1 << 0,
100 GF_CALL_FROM_THUNK = 1 << 1,
101 GF_CALL_RETURN_SLOT_OPT = 1 << 2,
102 GF_CALL_TAILCALL = 1 << 3,
103 GF_CALL_VA_ARG_PACK = 1 << 4,
104 GF_OMP_PARALLEL_COMBINED = 1 << 0,
106 /* True on an GIMPLE_OMP_RETURN statement if the return does not require
107 a thread synchronization via some sort of barrier. The exact barrier
108 that would otherwise be emitted is dependent on the OMP statement with
109 which this return is associated. */
110 GF_OMP_RETURN_NOWAIT = 1 << 0,
112 GF_OMP_SECTION_LAST = 1 << 0,
113 GF_PREDICT_TAKEN = 1 << 15
116 /* Masks for selecting a pass local flag (PLF) to work on. These
117 masks are used by gimple_set_plf and gimple_plf. */
118 enum plf_mask {
119 GF_PLF_1 = 1 << 0,
120 GF_PLF_2 = 1 << 1
123 /* A node in a gimple_seq_d. */
124 struct gimple_seq_node_d GTY((chain_next ("%h.next"), chain_prev ("%h.prev")))
126 gimple stmt;
127 struct gimple_seq_node_d *prev;
128 struct gimple_seq_node_d *next;
131 /* A double-linked sequence of gimple statements. */
132 struct gimple_seq_d GTY ((chain_next ("%h.next_free")))
134 /* First and last statements in the sequence. */
135 gimple_seq_node first;
136 gimple_seq_node last;
138 /* Sequences are created/destroyed frequently. To minimize
139 allocation activity, deallocated sequences are kept in a pool of
140 available sequences. This is the pointer to the next free
141 sequence in the pool. */
142 gimple_seq next_free;
146 /* Return the first node in GIMPLE sequence S. */
148 static inline gimple_seq_node
149 gimple_seq_first (const_gimple_seq s)
151 return s ? s->first : NULL;
155 /* Return the first statement in GIMPLE sequence S. */
157 static inline gimple
158 gimple_seq_first_stmt (const_gimple_seq s)
160 gimple_seq_node n = gimple_seq_first (s);
161 return (n) ? n->stmt : NULL;
165 /* Return the last node in GIMPLE sequence S. */
167 static inline gimple_seq_node
168 gimple_seq_last (const_gimple_seq s)
170 return s ? s->last : NULL;
174 /* Return the last statement in GIMPLE sequence S. */
176 static inline gimple
177 gimple_seq_last_stmt (const_gimple_seq s)
179 gimple_seq_node n = gimple_seq_last (s);
180 return (n) ? n->stmt : NULL;
184 /* Set the last node in GIMPLE sequence S to LAST. */
186 static inline void
187 gimple_seq_set_last (gimple_seq s, gimple_seq_node last)
189 s->last = last;
193 /* Set the first node in GIMPLE sequence S to FIRST. */
195 static inline void
196 gimple_seq_set_first (gimple_seq s, gimple_seq_node first)
198 s->first = first;
202 /* Return true if GIMPLE sequence S is empty. */
204 static inline bool
205 gimple_seq_empty_p (const_gimple_seq s)
207 return s == NULL || s->first == NULL;
211 void gimple_seq_add_stmt (gimple_seq *, gimple);
213 /* Allocate a new sequence and initialize its first element with STMT. */
215 static inline gimple_seq
216 gimple_seq_alloc_with_stmt (gimple stmt)
218 gimple_seq seq = NULL;
219 gimple_seq_add_stmt (&seq, stmt);
220 return seq;
224 /* Returns the sequence of statements in BB. */
226 static inline gimple_seq
227 bb_seq (const_basic_block bb)
229 return (!(bb->flags & BB_RTL) && bb->il.gimple) ? bb->il.gimple->seq : NULL;
233 /* Sets the sequence of statements in BB to SEQ. */
235 static inline void
236 set_bb_seq (basic_block bb, gimple_seq seq)
238 gcc_assert (!(bb->flags & BB_RTL));
239 bb->il.gimple->seq = seq;
242 /* Iterator object for GIMPLE statement sequences. */
244 typedef struct
246 /* Sequence node holding the current statement. */
247 gimple_seq_node ptr;
249 /* Sequence and basic block holding the statement. These fields
250 are necessary to handle edge cases such as when statement is
251 added to an empty basic block or when the last statement of a
252 block/sequence is removed. */
253 gimple_seq seq;
254 basic_block bb;
255 } gimple_stmt_iterator;
258 /* Data structure definitions for GIMPLE tuples. NOTE: word markers
259 are for 64 bit hosts. */
261 struct gimple_statement_base GTY(())
263 /* [ WORD 1 ]
264 Main identifying code for a tuple. */
265 ENUM_BITFIELD(gimple_code) code : 8;
267 /* Nonzero if a warning should not be emitted on this tuple. */
268 unsigned int no_warning : 1;
270 /* Nonzero if this tuple has been visited. Passes are responsible
271 for clearing this bit before using it. */
272 unsigned int visited : 1;
274 /* Nonzero if this tuple represents a non-temporal move. */
275 unsigned int nontemporal_move : 1;
277 /* Pass local flags. These flags are free for any pass to use as
278 they see fit. Passes should not assume that these flags contain
279 any useful value when the pass starts. Any initial state that
280 the pass requires should be set on entry to the pass. See
281 gimple_set_plf and gimple_plf for usage. */
282 unsigned int plf : 2;
284 /* Nonzero if this statement has been modified and needs to have its
285 operands rescanned. */
286 unsigned modified : 1;
288 /* Nonzero if this statement contains volatile operands. */
289 unsigned has_volatile_ops : 1;
291 /* Nonzero if this statement contains memory refernces. */
292 unsigned references_memory_p : 1;
294 /* The SUBCODE field can be used for tuple-specific flags for tuples
295 that do not require subcodes. Note that SUBCODE should be at
296 least as wide as tree codes, as several tuples store tree codes
297 in there. */
298 unsigned int subcode : 16;
300 /* UID of this statement. */
301 unsigned uid;
303 /* [ WORD 2 ]
304 Locus information for debug info. */
305 location_t location;
307 /* Number of operands in this tuple. */
308 unsigned num_ops;
310 /* [ WORD 3 ]
311 Basic block holding this statement. */
312 struct basic_block_def *bb;
314 /* [ WORD 4 ]
315 Lexical block holding this statement. */
316 tree block;
320 /* Base structure for tuples with operands. */
322 struct gimple_statement_with_ops_base GTY(())
324 /* [ WORD 1-4 ] */
325 struct gimple_statement_base gsbase;
327 /* [ WORD 5 ]
328 Symbols whose addresses are taken by this statement (i.e., they
329 appear inside ADDR_EXPR nodes). */
330 bitmap GTY((skip (""))) addresses_taken;
332 /* [ WORD 6-7 ]
333 SSA operand vectors. NOTE: It should be possible to
334 amalgamate these vectors with the operand vector OP. However,
335 the SSA operand vectors are organized differently and contain
336 more information (like immediate use chaining). */
337 struct def_optype_d GTY((skip (""))) *def_ops;
338 struct use_optype_d GTY((skip (""))) *use_ops;
342 /* Statements that take register operands. */
344 struct gimple_statement_with_ops GTY(())
346 /* [ WORD 1-7 ] */
347 struct gimple_statement_with_ops_base opbase;
349 /* [ WORD 8 ]
350 Operand vector. NOTE! This must always be the last field
351 of this structure. In particular, this means that this
352 structure cannot be embedded inside another one. */
353 tree GTY((length ("%h.opbase.gsbase.num_ops"))) op[1];
357 /* Base for statements that take both memory and register operands. */
359 struct gimple_statement_with_memory_ops_base GTY(())
361 /* [ WORD 1-7 ] */
362 struct gimple_statement_with_ops_base opbase;
364 /* [ WORD 8-9 ]
365 Vectors for virtual operands. */
366 struct voptype_d GTY((skip (""))) *vdef_ops;
367 struct voptype_d GTY((skip (""))) *vuse_ops;
369 /* [ WORD 9-10 ]
370 Symbols stored/loaded by this statement. */
371 bitmap GTY((skip (""))) stores;
372 bitmap GTY((skip (""))) loads;
376 /* Statements that take both memory and register operands. */
378 struct gimple_statement_with_memory_ops GTY(())
380 /* [ WORD 1-10 ] */
381 struct gimple_statement_with_memory_ops_base membase;
383 /* [ WORD 11 ]
384 Operand vector. NOTE! This must always be the last field
385 of this structure. In particular, this means that this
386 structure cannot be embedded inside another one. */
387 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
391 /* OpenMP statements (#pragma omp). */
393 struct gimple_statement_omp GTY(())
395 /* [ WORD 1-4 ] */
396 struct gimple_statement_base gsbase;
398 /* [ WORD 5 ] */
399 gimple_seq body;
403 /* GIMPLE_BIND */
405 struct gimple_statement_bind GTY(())
407 /* [ WORD 1-4 ] */
408 struct gimple_statement_base gsbase;
410 /* [ WORD 5 ]
411 Variables declared in this scope. */
412 tree vars;
414 /* [ WORD 6 ]
415 This is different than the BLOCK field in gimple_statement_base,
416 which is analogous to TREE_BLOCK (i.e., the lexical block holding
417 this statement). This field is the equivalent of BIND_EXPR_BLOCK
418 in tree land (i.e., the lexical scope defined by this bind). See
419 gimple-low.c. */
420 tree block;
422 /* [ WORD 7 ] */
423 gimple_seq body;
427 /* GIMPLE_CATCH */
429 struct gimple_statement_catch GTY(())
431 /* [ WORD 1-4 ] */
432 struct gimple_statement_base gsbase;
434 /* [ WORD 5 ] */
435 tree types;
437 /* [ WORD 6 ] */
438 gimple_seq handler;
442 /* GIMPLE_EH_FILTER */
444 struct gimple_statement_eh_filter GTY(())
446 /* [ WORD 1-4 ] */
447 struct gimple_statement_base gsbase;
449 /* Subcode: EH_FILTER_MUST_NOT_THROW. A boolean flag analogous to
450 the tree counterpart. */
452 /* [ WORD 5 ]
453 Filter types. */
454 tree types;
456 /* [ WORD 6 ]
457 Failure actions. */
458 gimple_seq failure;
462 /* GIMPLE_PHI */
464 struct gimple_statement_phi GTY(())
466 /* [ WORD 1-4 ] */
467 struct gimple_statement_base gsbase;
469 /* [ WORD 5 ] */
470 unsigned capacity;
471 unsigned nargs;
473 /* [ WORD 6 ] */
474 tree result;
476 /* [ WORD 7 ] */
477 struct phi_arg_d GTY ((length ("%h.nargs"))) args[1];
481 /* GIMPLE_RESX */
483 struct gimple_statement_resx GTY(())
485 /* [ WORD 1-4 ] */
486 struct gimple_statement_base gsbase;
488 /* [ WORD 5 ]
489 Exception region number. */
490 int region;
494 /* GIMPLE_TRY */
496 struct gimple_statement_try GTY(())
498 /* [ WORD 1-4 ] */
499 struct gimple_statement_base gsbase;
501 /* [ WORD 5 ]
502 Expression to evaluate. */
503 gimple_seq eval;
505 /* [ WORD 6 ]
506 Cleanup expression. */
507 gimple_seq cleanup;
510 /* Kind of GIMPLE_TRY statements. */
511 enum gimple_try_flags
513 /* A try/catch. */
514 GIMPLE_TRY_CATCH = 1 << 0,
516 /* A try/finally. */
517 GIMPLE_TRY_FINALLY = 1 << 1,
518 GIMPLE_TRY_KIND = GIMPLE_TRY_CATCH | GIMPLE_TRY_FINALLY,
520 /* Analogous to TRY_CATCH_IS_CLEANUP. */
521 GIMPLE_TRY_CATCH_IS_CLEANUP = 1 << 2
524 /* GIMPLE_WITH_CLEANUP_EXPR */
526 struct gimple_statement_wce GTY(())
528 /* [ WORD 1-4 ] */
529 struct gimple_statement_base gsbase;
531 /* Subcode: CLEANUP_EH_ONLY. True if the cleanup should only be
532 executed if an exception is thrown, not on normal exit of its
533 scope. This flag is analogous to the CLEANUP_EH_ONLY flag
534 in TARGET_EXPRs. */
536 /* [ WORD 5 ]
537 Cleanup expression. */
538 gimple_seq cleanup;
542 /* GIMPLE_ASM */
544 struct gimple_statement_asm GTY(())
546 /* [ WORD 1-10 ] */
547 struct gimple_statement_with_memory_ops_base membase;
549 /* [ WORD 11 ]
550 __asm__ statement. */
551 const char *string;
553 /* [ WORD 12 ]
554 Number of inputs, outputs and clobbers. */
555 unsigned char ni;
556 unsigned char no;
557 unsigned short nc;
559 /* [ WORD 13 ]
560 Operand vector. NOTE! This must always be the last field
561 of this structure. In particular, this means that this
562 structure cannot be embedded inside another one. */
563 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
566 /* GIMPLE_OMP_CRITICAL */
568 struct gimple_statement_omp_critical GTY(())
570 /* [ WORD 1-5 ] */
571 struct gimple_statement_omp omp;
573 /* [ WORD 6 ]
574 Critical section name. */
575 tree name;
579 struct gimple_omp_for_iter GTY(())
581 /* Condition code. */
582 enum tree_code cond;
584 /* Index variable. */
585 tree index;
587 /* Initial value. */
588 tree initial;
590 /* Final value. */
591 tree final;
593 /* Increment. */
594 tree incr;
597 /* GIMPLE_OMP_FOR */
599 struct gimple_statement_omp_for GTY(())
601 /* [ WORD 1-5 ] */
602 struct gimple_statement_omp omp;
604 /* [ WORD 6 ] */
605 tree clauses;
607 /* [ WORD 7 ]
608 Number of elements in iter array. */
609 size_t collapse;
611 /* [ WORD 8 ] */
612 struct gimple_omp_for_iter * GTY((length ("%h.collapse"))) iter;
614 /* [ WORD 9 ]
615 Pre-body evaluated before the loop body begins. */
616 gimple_seq pre_body;
620 /* GIMPLE_OMP_PARALLEL */
622 struct gimple_statement_omp_parallel GTY(())
624 /* [ WORD 1-5 ] */
625 struct gimple_statement_omp omp;
627 /* [ WORD 6 ]
628 Clauses. */
629 tree clauses;
631 /* [ WORD 7 ]
632 Child function holding the body of the parallel region. */
633 tree child_fn;
635 /* [ WORD 8 ]
636 Shared data argument. */
637 tree data_arg;
641 /* GIMPLE_OMP_TASK */
643 struct gimple_statement_omp_task GTY(())
645 /* [ WORD 1-8 ] */
646 struct gimple_statement_omp_parallel par;
648 /* [ WORD 9 ]
649 Child function holding firstprivate initialization if needed. */
650 tree copy_fn;
652 /* [ WORD 10-11 ]
653 Size and alignment in bytes of the argument data block. */
654 tree arg_size;
655 tree arg_align;
659 /* GIMPLE_OMP_SECTION */
660 /* Uses struct gimple_statement_omp. */
663 /* GIMPLE_OMP_SECTIONS */
665 struct gimple_statement_omp_sections GTY(())
667 /* [ WORD 1-5 ] */
668 struct gimple_statement_omp omp;
670 /* [ WORD 6 ] */
671 tree clauses;
673 /* [ WORD 7 ]
674 The control variable used for deciding which of the sections to
675 execute. */
676 tree control;
679 /* GIMPLE_OMP_CONTINUE.
681 Note: This does not inherit from gimple_statement_omp, because we
682 do not need the body field. */
684 struct gimple_statement_omp_continue GTY(())
686 /* [ WORD 1-4 ] */
687 struct gimple_statement_base gsbase;
689 /* [ WORD 5 ] */
690 tree control_def;
692 /* [ WORD 6 ] */
693 tree control_use;
696 /* GIMPLE_OMP_SINGLE */
698 struct gimple_statement_omp_single GTY(())
700 /* [ WORD 1-5 ] */
701 struct gimple_statement_omp omp;
703 /* [ WORD 6 ] */
704 tree clauses;
708 /* GIMPLE_OMP_ATOMIC_LOAD.
709 Note: This is based on gimple_statement_base, not g_s_omp, because g_s_omp
710 contains a sequence, which we don't need here. */
712 struct gimple_statement_omp_atomic_load GTY(())
714 /* [ WORD 1-4 ] */
715 struct gimple_statement_base gsbase;
717 /* [ WORD 5-6 ] */
718 tree rhs, lhs;
721 /* GIMPLE_OMP_ATOMIC_STORE.
722 See note on GIMPLE_OMP_ATOMIC_LOAD. */
724 struct gimple_statement_omp_atomic_store GTY(())
726 /* [ WORD 1-4 ] */
727 struct gimple_statement_base gsbase;
729 /* [ WORD 5 ] */
730 tree val;
733 enum gimple_statement_structure_enum {
734 #define DEFGSSTRUCT(SYM, STRING) SYM,
735 #include "gsstruct.def"
736 #undef DEFGSSTRUCT
737 LAST_GSS_ENUM
741 /* Define the overall contents of a gimple tuple. It may be any of the
742 structures declared above for various types of tuples. */
744 union gimple_statement_d GTY ((desc ("gimple_statement_structure (&%h)")))
746 struct gimple_statement_base GTY ((tag ("GSS_BASE"))) gsbase;
747 struct gimple_statement_with_ops GTY ((tag ("GSS_WITH_OPS"))) gsops;
748 struct gimple_statement_with_memory_ops GTY ((tag ("GSS_WITH_MEM_OPS"))) gsmem;
749 struct gimple_statement_omp GTY ((tag ("GSS_OMP"))) omp;
750 struct gimple_statement_bind GTY ((tag ("GSS_BIND"))) gimple_bind;
751 struct gimple_statement_catch GTY ((tag ("GSS_CATCH"))) gimple_catch;
752 struct gimple_statement_eh_filter GTY ((tag ("GSS_EH_FILTER"))) gimple_eh_filter;
753 struct gimple_statement_phi GTY ((tag ("GSS_PHI"))) gimple_phi;
754 struct gimple_statement_resx GTY ((tag ("GSS_RESX"))) gimple_resx;
755 struct gimple_statement_try GTY ((tag ("GSS_TRY"))) gimple_try;
756 struct gimple_statement_wce GTY ((tag ("GSS_WCE"))) gimple_wce;
757 struct gimple_statement_asm GTY ((tag ("GSS_ASM"))) gimple_asm;
758 struct gimple_statement_omp_critical GTY ((tag ("GSS_OMP_CRITICAL"))) gimple_omp_critical;
759 struct gimple_statement_omp_for GTY ((tag ("GSS_OMP_FOR"))) gimple_omp_for;
760 struct gimple_statement_omp_parallel GTY ((tag ("GSS_OMP_PARALLEL"))) gimple_omp_parallel;
761 struct gimple_statement_omp_task GTY ((tag ("GSS_OMP_TASK"))) gimple_omp_task;
762 struct gimple_statement_omp_sections GTY ((tag ("GSS_OMP_SECTIONS"))) gimple_omp_sections;
763 struct gimple_statement_omp_single GTY ((tag ("GSS_OMP_SINGLE"))) gimple_omp_single;
764 struct gimple_statement_omp_continue GTY ((tag ("GSS_OMP_CONTINUE"))) gimple_omp_continue;
765 struct gimple_statement_omp_atomic_load GTY ((tag ("GSS_OMP_ATOMIC_LOAD"))) gimple_omp_atomic_load;
766 struct gimple_statement_omp_atomic_store GTY ((tag ("GSS_OMP_ATOMIC_STORE"))) gimple_omp_atomic_store;
769 /* In gimple.c. */
770 gimple gimple_build_return (tree);
772 gimple gimple_build_assign_stat (tree, tree MEM_STAT_DECL);
773 #define gimple_build_assign(l,r) gimple_build_assign_stat (l, r MEM_STAT_INFO)
775 void extract_ops_from_tree (tree, enum tree_code *, tree *, tree *);
777 gimple gimple_build_assign_with_ops_stat (enum tree_code, tree, tree,
778 tree MEM_STAT_DECL);
779 #define gimple_build_assign_with_ops(c,o1,o2,o3) \
780 gimple_build_assign_with_ops_stat (c, o1, o2, o3 MEM_STAT_INFO)
782 gimple gimple_build_call_vec (tree, VEC(tree, heap) *);
783 gimple gimple_build_call (tree, unsigned, ...);
784 gimple gimple_build_call_from_tree (tree);
785 gimple gimplify_assign (tree, tree, gimple_seq *);
786 gimple gimple_build_cond (enum tree_code, tree, tree, tree, tree);
787 gimple gimple_build_label (tree label);
788 gimple gimple_build_goto (tree dest);
789 gimple gimple_build_nop (void);
790 gimple gimple_build_bind (tree, gimple_seq, tree);
791 gimple gimple_build_asm (const char *, unsigned, unsigned, unsigned, ...);
792 gimple gimple_build_asm_vec (const char *, VEC(tree,gc) *, VEC(tree,gc) *,
793 VEC(tree,gc) *);
794 gimple gimple_build_catch (tree, gimple_seq);
795 gimple gimple_build_eh_filter (tree, gimple_seq);
796 gimple gimple_build_try (gimple_seq, gimple_seq, unsigned int);
797 gimple gimple_build_wce (gimple_seq);
798 gimple gimple_build_resx (int);
799 gimple gimple_build_switch (unsigned, tree, tree, ...);
800 gimple gimple_build_switch_vec (tree, tree, VEC(tree,heap) *);
801 gimple gimple_build_omp_parallel (gimple_seq, tree, tree, tree);
802 gimple gimple_build_omp_task (gimple_seq, tree, tree, tree, tree, tree, tree);
803 gimple gimple_build_omp_for (gimple_seq, tree, size_t, gimple_seq);
804 gimple gimple_build_omp_critical (gimple_seq, tree);
805 gimple gimple_build_omp_section (gimple_seq);
806 gimple gimple_build_omp_continue (tree, tree);
807 gimple gimple_build_omp_master (gimple_seq);
808 gimple gimple_build_omp_return (bool);
809 gimple gimple_build_omp_ordered (gimple_seq);
810 gimple gimple_build_omp_sections (gimple_seq, tree);
811 gimple gimple_build_omp_sections_switch (void);
812 gimple gimple_build_omp_single (gimple_seq, tree);
813 gimple gimple_build_cdt (tree, tree);
814 gimple gimple_build_omp_atomic_load (tree, tree);
815 gimple gimple_build_omp_atomic_store (tree);
816 gimple gimple_build_predict (enum br_predictor, enum prediction);
817 enum gimple_statement_structure_enum gimple_statement_structure (gimple);
818 enum gimple_statement_structure_enum gss_for_assign (enum tree_code);
819 void sort_case_labels (VEC(tree,heap) *);
820 void gimple_set_body (tree, gimple_seq);
821 gimple_seq gimple_body (tree);
822 bool gimple_has_body_p (tree);
823 gimple_seq gimple_seq_alloc (void);
824 void gimple_seq_free (gimple_seq);
825 void gimple_seq_add_seq (gimple_seq *, gimple_seq);
826 gimple_seq gimple_seq_copy (gimple_seq);
827 int gimple_call_flags (const_gimple);
828 bool gimple_assign_copy_p (gimple);
829 bool gimple_assign_ssa_name_copy_p (gimple);
830 bool gimple_assign_single_p (gimple);
831 bool gimple_assign_unary_nop_p (gimple);
832 void gimple_set_bb (gimple, struct basic_block_def *);
833 tree gimple_fold (const_gimple);
834 void gimple_assign_set_rhs_from_tree (gimple_stmt_iterator *, tree);
835 void gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *, enum tree_code,
836 tree, tree);
837 tree gimple_get_lhs (const_gimple);
838 void gimple_set_lhs (gimple, tree);
839 gimple gimple_copy (gimple);
840 bool is_gimple_operand (const_tree);
841 void gimple_set_modified (gimple, bool);
842 void gimple_cond_get_ops_from_tree (tree, enum tree_code *, tree *, tree *);
843 gimple gimple_build_cond_from_tree (tree, tree, tree);
844 void gimple_cond_set_condition_from_tree (gimple, tree);
845 bool gimple_has_side_effects (const_gimple);
846 bool gimple_rhs_has_side_effects (const_gimple);
847 bool gimple_could_trap_p (gimple);
848 bool gimple_assign_rhs_could_trap_p (gimple);
849 void gimple_regimplify_operands (gimple, gimple_stmt_iterator *);
850 bool empty_body_p (gimple_seq);
851 unsigned get_gimple_rhs_num_ops (enum tree_code);
853 /* Returns true iff T is a valid GIMPLE statement. */
854 extern bool is_gimple_stmt (tree);
856 /* Returns true iff TYPE is a valid type for a scalar register variable. */
857 extern bool is_gimple_reg_type (tree);
858 /* Returns true iff T is a scalar register variable. */
859 extern bool is_gimple_reg (tree);
860 /* Returns true if T is a GIMPLE temporary variable, false otherwise. */
861 extern bool is_gimple_formal_tmp_var (tree);
862 /* Returns true if T is a GIMPLE temporary register variable. */
863 extern bool is_gimple_formal_tmp_reg (tree);
864 /* Returns true iff T is any sort of variable. */
865 extern bool is_gimple_variable (tree);
866 /* Returns true iff T is any sort of symbol. */
867 extern bool is_gimple_id (tree);
868 /* Returns true iff T is a variable or an INDIRECT_REF (of a variable). */
869 extern bool is_gimple_min_lval (tree);
870 /* Returns true iff T is something whose address can be taken. */
871 extern bool is_gimple_addressable (tree);
872 /* Returns true iff T is any valid GIMPLE lvalue. */
873 extern bool is_gimple_lvalue (tree);
875 /* Returns true iff T is a GIMPLE address. */
876 bool is_gimple_address (const_tree);
877 /* Returns true iff T is a GIMPLE invariant address. */
878 bool is_gimple_invariant_address (const_tree);
879 /* Returns true iff T is a GIMPLE invariant address at interprocedural
880 level. */
881 bool is_gimple_ip_invariant_address (const_tree);
882 /* Returns true iff T is a valid GIMPLE constant. */
883 bool is_gimple_constant (const_tree);
884 /* Returns true iff T is a GIMPLE restricted function invariant. */
885 extern bool is_gimple_min_invariant (const_tree);
886 /* Returns true iff T is a GIMPLE restricted interprecodural invariant. */
887 extern bool is_gimple_ip_invariant (const_tree);
888 /* Returns true iff T is a GIMPLE rvalue. */
889 extern bool is_gimple_val (tree);
890 /* Returns true iff T is a GIMPLE asm statement input. */
891 extern bool is_gimple_asm_val (tree);
892 /* Returns true iff T is a valid rhs for a MODIFY_EXPR where the LHS is a
893 GIMPLE temporary, a renamed user variable, or something else,
894 respectively. */
895 extern bool is_gimple_formal_tmp_rhs (tree);
896 extern bool is_gimple_reg_rhs (tree);
897 extern bool is_gimple_mem_rhs (tree);
899 /* Returns true iff T is a valid if-statement condition. */
900 extern bool is_gimple_condexpr (tree);
902 /* Returns true iff T is a type conversion. */
903 extern bool is_gimple_cast (tree);
904 /* Returns true iff T is a variable that does not need to live in memory. */
905 extern bool is_gimple_non_addressable (tree t);
907 /* Returns true iff T is a valid call address expression. */
908 extern bool is_gimple_call_addr (tree);
909 /* If T makes a function call, returns the CALL_EXPR operand. */
910 extern tree get_call_expr_in (tree t);
912 extern void recalculate_side_effects (tree);
914 /* In gimplify.c */
915 extern tree create_tmp_var_raw (tree, const char *);
916 extern tree create_tmp_var_name (const char *);
917 extern tree create_tmp_var (tree, const char *);
918 extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq *);
919 extern tree get_formal_tmp_var (tree, gimple_seq *);
920 extern void declare_vars (tree, gimple, bool);
921 extern void tree_annotate_all_with_location (tree *, location_t);
922 extern void annotate_all_with_location (gimple_seq, location_t);
924 /* Validation of GIMPLE expressions. Note that these predicates only check
925 the basic form of the expression, they don't recurse to make sure that
926 underlying nodes are also of the right form. */
927 typedef bool (*gimple_predicate)(tree);
930 /* FIXME we should deduce this from the predicate. */
931 typedef enum fallback_t {
932 fb_none = 0, /* Do not generate a temporary. */
934 fb_rvalue = 1, /* Generate an rvalue to hold the result of a
935 gimplified expression. */
937 fb_lvalue = 2, /* Generate an lvalue to hold the result of a
938 gimplified expression. */
940 fb_mayfail = 4, /* Gimplification may fail. Error issued
941 afterwards. */
942 fb_either= fb_rvalue | fb_lvalue
943 } fallback_t;
945 enum gimplify_status {
946 GS_ERROR = -2, /* Something Bad Seen. */
947 GS_UNHANDLED = -1, /* A langhook result for "I dunno". */
948 GS_OK = 0, /* We did something, maybe more to do. */
949 GS_ALL_DONE = 1 /* The expression is fully gimplified. */
952 struct gimplify_ctx
954 struct gimplify_ctx *prev_context;
956 VEC(gimple,heap) *bind_expr_stack;
957 tree temps;
958 gimple_seq conditional_cleanups;
959 tree exit_label;
960 tree return_temp;
962 VEC(tree,heap) *case_labels;
963 /* The formal temporary table. Should this be persistent? */
964 htab_t temp_htab;
966 int conditions;
967 bool save_stack;
968 bool into_ssa;
969 bool allow_rhs_cond_expr;
972 extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *,
973 bool (*) (tree), fallback_t);
974 extern void gimplify_type_sizes (tree, gimple_seq *);
975 extern void gimplify_one_sizepos (tree *, gimple_seq *);
976 extern bool gimplify_stmt (tree *, gimple_seq *);
977 extern gimple gimplify_body (tree *, tree, bool);
978 extern void push_gimplify_context (struct gimplify_ctx *);
979 extern void pop_gimplify_context (gimple);
980 extern void gimplify_and_add (tree, gimple_seq *);
982 /* Miscellaneous helpers. */
983 extern void gimple_add_tmp_var (tree);
984 extern gimple gimple_current_bind_expr (void);
985 extern VEC(gimple, heap) *gimple_bind_expr_stack (void);
986 extern tree voidify_wrapper_expr (tree, tree);
987 extern tree build_and_jump (tree *);
988 extern tree alloc_stmt_list (void);
989 extern void free_stmt_list (tree);
990 extern tree force_labels_r (tree *, int *, void *);
991 extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *,
992 gimple_seq *);
993 struct gimplify_omp_ctx;
994 extern void omp_firstprivatize_variable (struct gimplify_omp_ctx *, tree);
995 extern tree gimple_boolify (tree);
996 extern gimple_predicate rhs_predicate_for (tree);
997 extern tree canonicalize_cond_expr_cond (tree);
999 /* In omp-low.c. */
1000 extern void diagnose_omp_structured_block_errors (tree);
1001 extern tree omp_reduction_init (tree, tree);
1003 /* In tree-nested.c. */
1004 extern void lower_nested_functions (tree);
1005 extern void insert_field_into_struct (tree, tree);
1007 /* In gimplify.c. */
1008 extern void gimplify_function_tree (tree);
1010 /* In cfgexpand.c. */
1011 extern tree gimple_assign_rhs_to_tree (gimple);
1013 /* In builtins.c */
1014 extern bool validate_gimple_arglist (const_gimple, ...);
1016 /* In tree-ssa-operands.c */
1017 extern void gimple_add_to_addresses_taken (gimple, tree);
1019 /* In tree-ssa.c */
1020 extern bool tree_ssa_useless_type_conversion (tree);
1021 extern bool useless_type_conversion_p (tree, tree);
1022 extern bool types_compatible_p (tree, tree);
1024 /* Return the code for GIMPLE statement G. */
1026 static inline enum gimple_code
1027 gimple_code (const_gimple g)
1029 return g->gsbase.code;
1033 /* Return true if statement G has sub-statements. This is only true for
1034 High GIMPLE statements. */
1036 static inline bool
1037 gimple_has_substatements (gimple g)
1039 switch (gimple_code (g))
1041 case GIMPLE_BIND:
1042 case GIMPLE_CATCH:
1043 case GIMPLE_EH_FILTER:
1044 case GIMPLE_TRY:
1045 case GIMPLE_OMP_FOR:
1046 case GIMPLE_OMP_MASTER:
1047 case GIMPLE_OMP_ORDERED:
1048 case GIMPLE_OMP_SECTION:
1049 case GIMPLE_OMP_PARALLEL:
1050 case GIMPLE_OMP_TASK:
1051 case GIMPLE_OMP_SECTIONS:
1052 case GIMPLE_OMP_SINGLE:
1053 case GIMPLE_OMP_CRITICAL:
1054 case GIMPLE_WITH_CLEANUP_EXPR:
1055 return true;
1057 default:
1058 return false;
1063 /* Return the basic block holding statement G. */
1065 static inline struct basic_block_def *
1066 gimple_bb (const_gimple g)
1068 return g->gsbase.bb;
1072 /* Return the lexical scope block holding statement G. */
1074 static inline tree
1075 gimple_block (const_gimple g)
1077 return g->gsbase.block;
1081 /* Set BLOCK to be the lexical scope block holding statement G. */
1083 static inline void
1084 gimple_set_block (gimple g, tree block)
1086 g->gsbase.block = block;
1090 /* Return location information for statement G. */
1092 static inline location_t
1093 gimple_location (const_gimple g)
1095 return g->gsbase.location;
1098 /* Return pointer to location information for statement G. */
1100 static inline const location_t *
1101 gimple_location_ptr (const_gimple g)
1103 return &g->gsbase.location;
1107 /* Set location information for statement G. */
1109 static inline void
1110 gimple_set_location (gimple g, location_t location)
1112 g->gsbase.location = location;
1116 /* Return true if G contains location information. */
1118 static inline bool
1119 gimple_has_location (const_gimple g)
1121 return gimple_location (g) != UNKNOWN_LOCATION;
1125 /* Return the file name of the location of STMT. */
1127 static inline const char *
1128 gimple_filename (const_gimple stmt)
1130 return LOCATION_FILE (gimple_location (stmt));
1134 /* Return the line number of the location of STMT. */
1136 static inline int
1137 gimple_lineno (const_gimple stmt)
1139 return LOCATION_LINE (gimple_location (stmt));
1143 /* Determine whether SEQ is a singleton. */
1145 static inline bool
1146 gimple_seq_singleton_p (gimple_seq seq)
1148 return ((gimple_seq_first (seq) != NULL)
1149 && (gimple_seq_first (seq) == gimple_seq_last (seq)));
1152 /* Return true if no warnings should be emitted for statement STMT. */
1154 static inline bool
1155 gimple_no_warning_p (const_gimple stmt)
1157 return stmt->gsbase.no_warning;
1160 /* Set the no_warning flag of STMT to NO_WARNING. */
1162 static inline void
1163 gimple_set_no_warning (gimple stmt, bool no_warning)
1165 stmt->gsbase.no_warning = (unsigned) no_warning;
1168 /* Set the visited status on statement STMT to VISITED_P. */
1170 static inline void
1171 gimple_set_visited (gimple stmt, bool visited_p)
1173 stmt->gsbase.visited = (unsigned) visited_p;
1177 /* Return the visited status for statement STMT. */
1179 static inline bool
1180 gimple_visited_p (gimple stmt)
1182 return stmt->gsbase.visited;
1186 /* Set pass local flag PLF on statement STMT to VAL_P. */
1188 static inline void
1189 gimple_set_plf (gimple stmt, enum plf_mask plf, bool val_p)
1191 if (val_p)
1192 stmt->gsbase.plf |= (unsigned int) plf;
1193 else
1194 stmt->gsbase.plf &= ~((unsigned int) plf);
1198 /* Return the value of pass local flag PLF on statement STMT. */
1200 static inline unsigned int
1201 gimple_plf (gimple stmt, enum plf_mask plf)
1203 return stmt->gsbase.plf & ((unsigned int) plf);
1207 /* Set the uid of statement */
1209 static inline void
1210 gimple_set_uid (gimple g, unsigned uid)
1212 g->gsbase.uid = uid;
1216 /* Return the uid of statement */
1218 static inline unsigned
1219 gimple_uid (const_gimple g)
1221 return g->gsbase.uid;
1225 /* Return true if GIMPLE statement G has register or memory operands. */
1227 static inline bool
1228 gimple_has_ops (const_gimple g)
1230 return gimple_code (g) >= GIMPLE_COND && gimple_code (g) <= GIMPLE_RETURN;
1234 /* Return true if GIMPLE statement G has memory operands. */
1236 static inline bool
1237 gimple_has_mem_ops (const_gimple g)
1239 return gimple_code (g) >= GIMPLE_ASSIGN && gimple_code (g) <= GIMPLE_RETURN;
1242 /* Return the set of addresses taken by statement G. */
1244 static inline bitmap
1245 gimple_addresses_taken (const_gimple g)
1247 if (gimple_has_ops (g))
1248 return g->gsops.opbase.addresses_taken;
1249 else
1250 return NULL;
1254 /* Return a pointer to the set of addresses taken by statement G. */
1256 static inline bitmap *
1257 gimple_addresses_taken_ptr (gimple g)
1259 if (gimple_has_ops (g))
1260 return &g->gsops.opbase.addresses_taken;
1261 else
1262 return NULL;
1266 /* Set B to be the set of addresses taken by statement G. The
1267 previous set is freed. */
1269 static inline void
1270 gimple_set_addresses_taken (gimple g, bitmap b)
1272 gcc_assert (gimple_has_ops (g));
1273 BITMAP_FREE (g->gsops.opbase.addresses_taken);
1274 g->gsops.opbase.addresses_taken = b;
1278 /* Return the set of DEF operands for statement G. */
1280 static inline struct def_optype_d *
1281 gimple_def_ops (const_gimple g)
1283 if (!gimple_has_ops (g))
1284 return NULL;
1285 return g->gsops.opbase.def_ops;
1289 /* Set DEF to be the set of DEF operands for statement G. */
1291 static inline void
1292 gimple_set_def_ops (gimple g, struct def_optype_d *def)
1294 gcc_assert (gimple_has_ops (g));
1295 g->gsops.opbase.def_ops = def;
1299 /* Return the set of USE operands for statement G. */
1301 static inline struct use_optype_d *
1302 gimple_use_ops (const_gimple g)
1304 if (!gimple_has_ops (g))
1305 return NULL;
1306 return g->gsops.opbase.use_ops;
1310 /* Set USE to be the set of USE operands for statement G. */
1312 static inline void
1313 gimple_set_use_ops (gimple g, struct use_optype_d *use)
1315 gcc_assert (gimple_has_ops (g));
1316 g->gsops.opbase.use_ops = use;
1320 /* Return the set of VUSE operands for statement G. */
1322 static inline struct voptype_d *
1323 gimple_vuse_ops (const_gimple g)
1325 if (!gimple_has_mem_ops (g))
1326 return NULL;
1327 return g->gsmem.membase.vuse_ops;
1331 /* Set OPS to be the set of VUSE operands for statement G. */
1333 static inline void
1334 gimple_set_vuse_ops (gimple g, struct voptype_d *ops)
1336 gcc_assert (gimple_has_mem_ops (g));
1337 g->gsmem.membase.vuse_ops = ops;
1341 /* Return the set of VDEF operands for statement G. */
1343 static inline struct voptype_d *
1344 gimple_vdef_ops (const_gimple g)
1346 if (!gimple_has_mem_ops (g))
1347 return NULL;
1348 return g->gsmem.membase.vdef_ops;
1352 /* Set OPS to be the set of VDEF operands for statement G. */
1354 static inline void
1355 gimple_set_vdef_ops (gimple g, struct voptype_d *ops)
1357 gcc_assert (gimple_has_mem_ops (g));
1358 g->gsmem.membase.vdef_ops = ops;
1362 /* Return the set of symbols loaded by statement G. Each element of the
1363 set is the DECL_UID of the corresponding symbol. */
1365 static inline bitmap
1366 gimple_loaded_syms (const_gimple g)
1368 if (!gimple_has_mem_ops (g))
1369 return NULL;
1370 return g->gsmem.membase.loads;
1374 /* Return the set of symbols stored by statement G. Each element of
1375 the set is the DECL_UID of the corresponding symbol. */
1377 static inline bitmap
1378 gimple_stored_syms (const_gimple g)
1380 if (!gimple_has_mem_ops (g))
1381 return NULL;
1382 return g->gsmem.membase.stores;
1386 /* Return true if statement G has operands and the modified field has
1387 been set. */
1389 static inline bool
1390 gimple_modified_p (const_gimple g)
1392 return (gimple_has_ops (g)) ? (bool) g->gsbase.modified : false;
1395 /* Return the type of the main expression computed by STMT. Return
1396 void_type_node if the statement computes nothing. */
1398 static inline tree
1399 gimple_expr_type (const_gimple stmt)
1401 enum gimple_code code = gimple_code (stmt);
1403 if (code == GIMPLE_ASSIGN || code == GIMPLE_CALL)
1405 tree type = TREE_TYPE (gimple_get_lhs (stmt));
1406 /* Integral sub-types are never the type of the expression,
1407 but they still can be the type of the result as the base
1408 type (in which expressions are computed) is trivially
1409 convertible to one of its sub-types. So always return
1410 the base type here. */
1411 if (INTEGRAL_TYPE_P (type)
1412 && TREE_TYPE (type)
1413 /* But only if they are trivially convertible. */
1414 && useless_type_conversion_p (type, TREE_TYPE (type)))
1415 type = TREE_TYPE (type);
1416 return type;
1418 else if (code == GIMPLE_COND)
1419 return boolean_type_node;
1420 else
1421 return void_type_node;
1425 /* Return the tree code for the expression computed by STMT. This is
1426 only valid for GIMPLE_COND, GIMPLE_CALL and GIMPLE_ASSIGN. For
1427 GIMPLE_CALL, return CALL_EXPR as the expression code for
1428 consistency. This is useful when the caller needs to deal with the
1429 three kinds of computation that GIMPLE supports. */
1431 static inline enum tree_code
1432 gimple_expr_code (const_gimple stmt)
1434 enum gimple_code code = gimple_code (stmt);
1435 if (code == GIMPLE_ASSIGN || code == GIMPLE_COND)
1436 return (enum tree_code) stmt->gsbase.subcode;
1437 else if (code == GIMPLE_CALL)
1438 return CALL_EXPR;
1439 else
1440 gcc_unreachable ();
1444 /* Mark statement S as modified, and update it. */
1446 static inline void
1447 update_stmt (gimple s)
1449 if (gimple_has_ops (s))
1451 gimple_set_modified (s, true);
1452 update_stmt_operands (s);
1456 /* Update statement S if it has been optimized. */
1458 static inline void
1459 update_stmt_if_modified (gimple s)
1461 if (gimple_modified_p (s))
1462 update_stmt_operands (s);
1465 /* Return true if statement STMT contains volatile operands. */
1467 static inline bool
1468 gimple_has_volatile_ops (const_gimple stmt)
1470 if (gimple_has_mem_ops (stmt))
1471 return stmt->gsbase.has_volatile_ops;
1472 else
1473 return false;
1477 /* Set the HAS_VOLATILE_OPS flag to VOLATILEP. */
1479 static inline void
1480 gimple_set_has_volatile_ops (gimple stmt, bool volatilep)
1482 if (gimple_has_mem_ops (stmt))
1483 stmt->gsbase.has_volatile_ops = (unsigned) volatilep;
1487 /* Return true if statement STMT may access memory. */
1489 static inline bool
1490 gimple_references_memory_p (gimple stmt)
1492 return gimple_has_mem_ops (stmt) && stmt->gsbase.references_memory_p;
1496 /* Set the REFERENCES_MEMORY_P flag for STMT to MEM_P. */
1498 static inline void
1499 gimple_set_references_memory (gimple stmt, bool mem_p)
1501 if (gimple_has_mem_ops (stmt))
1502 stmt->gsbase.references_memory_p = (unsigned) mem_p;
1505 /* Return the subcode for OMP statement S. */
1507 static inline unsigned
1508 gimple_omp_subcode (const_gimple s)
1510 gcc_assert (gimple_code (s) >= GIMPLE_OMP_ATOMIC_LOAD
1511 && gimple_code (s) <= GIMPLE_OMP_SINGLE);
1512 return s->gsbase.subcode;
1515 /* Set the subcode for OMP statement S to SUBCODE. */
1517 static inline void
1518 gimple_omp_set_subcode (gimple s, unsigned int subcode)
1520 /* We only have 16 bits for the subcode. Assert that we are not
1521 overflowing it. */
1522 gcc_assert (subcode < (1 << 16));
1523 s->gsbase.subcode = subcode;
1526 /* Set the nowait flag on OMP_RETURN statement S. */
1528 static inline void
1529 gimple_omp_return_set_nowait (gimple s)
1531 GIMPLE_CHECK (s, GIMPLE_OMP_RETURN);
1532 s->gsbase.subcode |= GF_OMP_RETURN_NOWAIT;
1536 /* Return true if OMP return statement G has the GF_OMP_RETURN_NOWAIT
1537 flag set. */
1539 static inline bool
1540 gimple_omp_return_nowait_p (const_gimple g)
1542 GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
1543 return (gimple_omp_subcode (g) & GF_OMP_RETURN_NOWAIT) != 0;
1547 /* Return true if OMP section statement G has the GF_OMP_SECTION_LAST
1548 flag set. */
1550 static inline bool
1551 gimple_omp_section_last_p (const_gimple g)
1553 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1554 return (gimple_omp_subcode (g) & GF_OMP_SECTION_LAST) != 0;
1558 /* Set the GF_OMP_SECTION_LAST flag on G. */
1560 static inline void
1561 gimple_omp_section_set_last (gimple g)
1563 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1564 g->gsbase.subcode |= GF_OMP_SECTION_LAST;
1568 /* Return true if OMP parallel statement G has the
1569 GF_OMP_PARALLEL_COMBINED flag set. */
1571 static inline bool
1572 gimple_omp_parallel_combined_p (const_gimple g)
1574 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1575 return (gimple_omp_subcode (g) & GF_OMP_PARALLEL_COMBINED) != 0;
1579 /* Set the GF_OMP_PARALLEL_COMBINED field in G depending on the boolean
1580 value of COMBINED_P. */
1582 static inline void
1583 gimple_omp_parallel_set_combined_p (gimple g, bool combined_p)
1585 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1586 if (combined_p)
1587 g->gsbase.subcode |= GF_OMP_PARALLEL_COMBINED;
1588 else
1589 g->gsbase.subcode &= ~GF_OMP_PARALLEL_COMBINED;
1593 /* Return the number of operands for statement GS. */
1595 static inline unsigned
1596 gimple_num_ops (const_gimple gs)
1598 return gs->gsbase.num_ops;
1602 /* Set the number of operands for statement GS. */
1604 static inline void
1605 gimple_set_num_ops (gimple gs, unsigned num_ops)
1607 gs->gsbase.num_ops = num_ops;
1611 /* Return the array of operands for statement GS. */
1613 static inline tree *
1614 gimple_ops (gimple gs)
1616 /* Offset in bytes to the location of the operand vector in every
1617 tuple structure. Defined in gimple.c */
1618 extern size_t const gimple_ops_offset_[];
1620 if (!gimple_has_ops (gs))
1621 return NULL;
1623 /* All the tuples have their operand vector at the very bottom
1624 of the structure. */
1625 return ((tree *) ((char *) gs + gimple_ops_offset_[gimple_code (gs)]));
1629 /* Return operand I for statement GS. */
1631 static inline tree
1632 gimple_op (const_gimple gs, unsigned i)
1634 if (gimple_has_ops (gs))
1636 gcc_assert (i < gimple_num_ops (gs));
1637 return gimple_ops (CONST_CAST_GIMPLE (gs))[i];
1639 else
1640 return NULL_TREE;
1643 /* Return a pointer to operand I for statement GS. */
1645 static inline tree *
1646 gimple_op_ptr (const_gimple gs, unsigned i)
1648 if (gimple_has_ops (gs))
1650 gcc_assert (i < gimple_num_ops (gs));
1651 return gimple_ops (CONST_CAST_GIMPLE (gs)) + i;
1653 else
1654 return NULL;
1657 /* Set operand I of statement GS to OP. */
1659 static inline void
1660 gimple_set_op (gimple gs, unsigned i, tree op)
1662 gcc_assert (gimple_has_ops (gs) && i < gimple_num_ops (gs));
1664 /* Note. It may be tempting to assert that OP matches
1665 is_gimple_operand, but that would be wrong. Different tuples
1666 accept slightly different sets of tree operands. Each caller
1667 should perform its own validation. */
1668 gimple_ops (gs)[i] = op;
1671 /* Return true if GS is a GIMPLE_ASSIGN. */
1673 static inline bool
1674 is_gimple_assign (const_gimple gs)
1676 return gimple_code (gs) == GIMPLE_ASSIGN;
1679 /* Determine if expression CODE is one of the valid expressions that can
1680 be used on the RHS of GIMPLE assignments. */
1682 static inline enum gimple_rhs_class
1683 get_gimple_rhs_class (enum tree_code code)
1685 return (enum gimple_rhs_class) gimple_rhs_class_table[(int) code];
1688 /* Return the LHS of assignment statement GS. */
1690 static inline tree
1691 gimple_assign_lhs (const_gimple gs)
1693 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1694 return gimple_op (gs, 0);
1698 /* Return a pointer to the LHS of assignment statement GS. */
1700 static inline tree *
1701 gimple_assign_lhs_ptr (const_gimple gs)
1703 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1704 return gimple_op_ptr (gs, 0);
1708 /* Set LHS to be the LHS operand of assignment statement GS. */
1710 static inline void
1711 gimple_assign_set_lhs (gimple gs, tree lhs)
1713 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1714 gcc_assert (is_gimple_operand (lhs));
1715 gimple_set_op (gs, 0, lhs);
1717 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1718 SSA_NAME_DEF_STMT (lhs) = gs;
1722 /* Return the first operand on the RHS of assignment statement GS. */
1724 static inline tree
1725 gimple_assign_rhs1 (const_gimple gs)
1727 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1728 return gimple_op (gs, 1);
1732 /* Return a pointer to the first operand on the RHS of assignment
1733 statement GS. */
1735 static inline tree *
1736 gimple_assign_rhs1_ptr (const_gimple gs)
1738 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1739 return gimple_op_ptr (gs, 1);
1742 /* Set RHS to be the first operand on the RHS of assignment statement GS. */
1744 static inline void
1745 gimple_assign_set_rhs1 (gimple gs, tree rhs)
1747 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1749 /* If there are 3 or more operands, the 2 operands on the RHS must be
1750 GIMPLE values. */
1751 if (gimple_num_ops (gs) >= 3)
1752 gcc_assert (is_gimple_val (rhs));
1753 else
1754 gcc_assert (is_gimple_operand (rhs));
1756 gimple_set_op (gs, 1, rhs);
1760 /* Return the second operand on the RHS of assignment statement GS.
1761 If GS does not have two operands, NULL is returned instead. */
1763 static inline tree
1764 gimple_assign_rhs2 (const_gimple gs)
1766 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1768 if (gimple_num_ops (gs) >= 3)
1769 return gimple_op (gs, 2);
1770 else
1771 return NULL_TREE;
1775 /* Return a pointer to the second operand on the RHS of assignment
1776 statement GS. */
1778 static inline tree *
1779 gimple_assign_rhs2_ptr (const_gimple gs)
1781 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1782 return gimple_op_ptr (gs, 2);
1786 /* Set RHS to be the second operand on the RHS of assignment statement GS. */
1788 static inline void
1789 gimple_assign_set_rhs2 (gimple gs, tree rhs)
1791 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1793 /* The 2 operands on the RHS must be GIMPLE values. */
1794 gcc_assert (is_gimple_val (rhs));
1796 gimple_set_op (gs, 2, rhs);
1799 /* Returns true if GS is a nontemporal move. */
1801 static inline bool
1802 gimple_assign_nontemporal_move_p (const_gimple gs)
1804 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1805 return gs->gsbase.nontemporal_move;
1808 /* Sets nontemporal move flag of GS to NONTEMPORAL. */
1810 static inline void
1811 gimple_assign_set_nontemporal_move (gimple gs, bool nontemporal)
1813 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1814 gs->gsbase.nontemporal_move = nontemporal;
1818 /* Return the code of the expression computed on the rhs of assignment
1819 statement GS. In case that the RHS is a single object, returns the
1820 tree code of the object. */
1822 static inline enum tree_code
1823 gimple_assign_rhs_code (const_gimple gs)
1825 enum tree_code code;
1826 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1828 code = gimple_expr_code (gs);
1829 if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS)
1830 code = TREE_CODE (gimple_assign_rhs1 (gs));
1832 return code;
1836 /* Set CODE to be the code for the expression computed on the RHS of
1837 assignment S. */
1839 static inline void
1840 gimple_assign_set_rhs_code (gimple s, enum tree_code code)
1842 GIMPLE_CHECK (s, GIMPLE_ASSIGN);
1843 s->gsbase.subcode = code;
1847 /* Return the gimple rhs class of the code of the expression computed on
1848 the rhs of assignment statement GS.
1849 This will never return GIMPLE_INVALID_RHS. */
1851 static inline enum gimple_rhs_class
1852 gimple_assign_rhs_class (const_gimple gs)
1854 return get_gimple_rhs_class (gimple_assign_rhs_code (gs));
1858 /* Return true if S is a type-cast assignment. */
1860 static inline bool
1861 gimple_assign_cast_p (gimple s)
1863 if (is_gimple_assign (s))
1865 enum tree_code sc = gimple_assign_rhs_code (s);
1866 return CONVERT_EXPR_CODE_P (sc)
1867 || sc == VIEW_CONVERT_EXPR
1868 || sc == FIX_TRUNC_EXPR;
1871 return false;
1875 /* Return true if GS is a GIMPLE_CALL. */
1877 static inline bool
1878 is_gimple_call (const_gimple gs)
1880 return gimple_code (gs) == GIMPLE_CALL;
1883 /* Return the LHS of call statement GS. */
1885 static inline tree
1886 gimple_call_lhs (const_gimple gs)
1888 GIMPLE_CHECK (gs, GIMPLE_CALL);
1889 return gimple_op (gs, 0);
1893 /* Return a pointer to the LHS of call statement GS. */
1895 static inline tree *
1896 gimple_call_lhs_ptr (const_gimple gs)
1898 GIMPLE_CHECK (gs, GIMPLE_CALL);
1899 return gimple_op_ptr (gs, 0);
1903 /* Set LHS to be the LHS operand of call statement GS. */
1905 static inline void
1906 gimple_call_set_lhs (gimple gs, tree lhs)
1908 GIMPLE_CHECK (gs, GIMPLE_CALL);
1909 gcc_assert (!lhs || is_gimple_operand (lhs));
1910 gimple_set_op (gs, 0, lhs);
1911 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1912 SSA_NAME_DEF_STMT (lhs) = gs;
1916 /* Return the tree node representing the function called by call
1917 statement GS. */
1919 static inline tree
1920 gimple_call_fn (const_gimple gs)
1922 GIMPLE_CHECK (gs, GIMPLE_CALL);
1923 return gimple_op (gs, 1);
1927 /* Return a pointer to the tree node representing the function called by call
1928 statement GS. */
1930 static inline tree *
1931 gimple_call_fn_ptr (const_gimple gs)
1933 GIMPLE_CHECK (gs, GIMPLE_CALL);
1934 return gimple_op_ptr (gs, 1);
1938 /* Set FN to be the function called by call statement GS. */
1940 static inline void
1941 gimple_call_set_fn (gimple gs, tree fn)
1943 GIMPLE_CHECK (gs, GIMPLE_CALL);
1944 gcc_assert (is_gimple_operand (fn));
1945 gimple_set_op (gs, 1, fn);
1949 /* Set FNDECL to be the function called by call statement GS. */
1951 static inline void
1952 gimple_call_set_fndecl (gimple gs, tree decl)
1954 GIMPLE_CHECK (gs, GIMPLE_CALL);
1955 gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
1956 gimple_set_op (gs, 1, build_fold_addr_expr (decl));
1960 /* If a given GIMPLE_CALL's callee is a FUNCTION_DECL, return it.
1961 Otherwise return NULL. This function is analogous to
1962 get_callee_fndecl in tree land. */
1964 static inline tree
1965 gimple_call_fndecl (const_gimple gs)
1967 tree addr = gimple_call_fn (gs);
1968 if (TREE_CODE (addr) == ADDR_EXPR)
1970 gcc_assert (TREE_CODE (TREE_OPERAND (addr, 0)) == FUNCTION_DECL);
1971 return TREE_OPERAND (addr, 0);
1973 return NULL_TREE;
1977 /* Return the type returned by call statement GS. */
1979 static inline tree
1980 gimple_call_return_type (const_gimple gs)
1982 tree fn = gimple_call_fn (gs);
1983 tree type = TREE_TYPE (fn);
1985 /* See through the pointer. */
1986 gcc_assert (POINTER_TYPE_P (type));
1987 type = TREE_TYPE (type);
1989 gcc_assert (TREE_CODE (type) == FUNCTION_TYPE
1990 || TREE_CODE (type) == METHOD_TYPE);
1992 /* The type returned by a FUNCTION_DECL is the type of its
1993 function type. */
1994 return TREE_TYPE (type);
1998 /* Return the static chain for call statement GS. */
2000 static inline tree
2001 gimple_call_chain (const_gimple gs)
2003 GIMPLE_CHECK (gs, GIMPLE_CALL);
2004 return gimple_op (gs, 2);
2008 /* Return a pointer to the static chain for call statement GS. */
2010 static inline tree *
2011 gimple_call_chain_ptr (const_gimple gs)
2013 GIMPLE_CHECK (gs, GIMPLE_CALL);
2014 return gimple_op_ptr (gs, 2);
2017 /* Set CHAIN to be the static chain for call statement GS. */
2019 static inline void
2020 gimple_call_set_chain (gimple gs, tree chain)
2022 GIMPLE_CHECK (gs, GIMPLE_CALL);
2023 gcc_assert (chain == NULL
2024 || TREE_CODE (chain) == ADDR_EXPR
2025 || SSA_VAR_P (chain));
2026 gimple_set_op (gs, 2, chain);
2030 /* Return the number of arguments used by call statement GS. */
2032 static inline unsigned
2033 gimple_call_num_args (const_gimple gs)
2035 unsigned num_ops;
2036 GIMPLE_CHECK (gs, GIMPLE_CALL);
2037 num_ops = gimple_num_ops (gs);
2038 gcc_assert (num_ops >= 3);
2039 return num_ops - 3;
2043 /* Return the argument at position INDEX for call statement GS. */
2045 static inline tree
2046 gimple_call_arg (const_gimple gs, unsigned index)
2048 GIMPLE_CHECK (gs, GIMPLE_CALL);
2049 return gimple_op (gs, index + 3);
2053 /* Return a pointer to the argument at position INDEX for call
2054 statement GS. */
2056 static inline tree *
2057 gimple_call_arg_ptr (const_gimple gs, unsigned index)
2059 GIMPLE_CHECK (gs, GIMPLE_CALL);
2060 return gimple_op_ptr (gs, index + 3);
2064 /* Set ARG to be the argument at position INDEX for call statement GS. */
2066 static inline void
2067 gimple_call_set_arg (gimple gs, unsigned index, tree arg)
2069 GIMPLE_CHECK (gs, GIMPLE_CALL);
2070 gcc_assert (is_gimple_operand (arg));
2071 gimple_set_op (gs, index + 3, arg);
2075 /* If TAIL_P is true, mark call statement S as being a tail call
2076 (i.e., a call just before the exit of a function). These calls are
2077 candidate for tail call optimization. */
2079 static inline void
2080 gimple_call_set_tail (gimple s, bool tail_p)
2082 GIMPLE_CHECK (s, GIMPLE_CALL);
2083 if (tail_p)
2084 s->gsbase.subcode |= GF_CALL_TAILCALL;
2085 else
2086 s->gsbase.subcode &= ~GF_CALL_TAILCALL;
2090 /* Return true if GIMPLE_CALL S is marked as a tail call. */
2092 static inline bool
2093 gimple_call_tail_p (gimple s)
2095 GIMPLE_CHECK (s, GIMPLE_CALL);
2096 return (s->gsbase.subcode & GF_CALL_TAILCALL) != 0;
2100 /* Set the inlinable status of GIMPLE_CALL S to INLINABLE_P. */
2102 static inline void
2103 gimple_call_set_cannot_inline (gimple s, bool inlinable_p)
2105 GIMPLE_CHECK (s, GIMPLE_CALL);
2106 if (inlinable_p)
2107 s->gsbase.subcode |= GF_CALL_CANNOT_INLINE;
2108 else
2109 s->gsbase.subcode &= ~GF_CALL_CANNOT_INLINE;
2113 /* Return true if GIMPLE_CALL S cannot be inlined. */
2115 static inline bool
2116 gimple_call_cannot_inline_p (gimple s)
2118 GIMPLE_CHECK (s, GIMPLE_CALL);
2119 return (s->gsbase.subcode & GF_CALL_CANNOT_INLINE) != 0;
2123 /* If RETURN_SLOT_OPT_P is true mark GIMPLE_CALL S as valid for return
2124 slot optimization. This transformation uses the target of the call
2125 expansion as the return slot for calls that return in memory. */
2127 static inline void
2128 gimple_call_set_return_slot_opt (gimple s, bool return_slot_opt_p)
2130 GIMPLE_CHECK (s, GIMPLE_CALL);
2131 if (return_slot_opt_p)
2132 s->gsbase.subcode |= GF_CALL_RETURN_SLOT_OPT;
2133 else
2134 s->gsbase.subcode &= ~GF_CALL_RETURN_SLOT_OPT;
2138 /* Return true if S is marked for return slot optimization. */
2140 static inline bool
2141 gimple_call_return_slot_opt_p (gimple s)
2143 GIMPLE_CHECK (s, GIMPLE_CALL);
2144 return (s->gsbase.subcode & GF_CALL_RETURN_SLOT_OPT) != 0;
2148 /* If FROM_THUNK_P is true, mark GIMPLE_CALL S as being the jump from a
2149 thunk to the thunked-to function. */
2151 static inline void
2152 gimple_call_set_from_thunk (gimple s, bool from_thunk_p)
2154 GIMPLE_CHECK (s, GIMPLE_CALL);
2155 if (from_thunk_p)
2156 s->gsbase.subcode |= GF_CALL_FROM_THUNK;
2157 else
2158 s->gsbase.subcode &= ~GF_CALL_FROM_THUNK;
2162 /* Return true if GIMPLE_CALL S is a jump from a thunk. */
2164 static inline bool
2165 gimple_call_from_thunk_p (gimple s)
2167 GIMPLE_CHECK (s, GIMPLE_CALL);
2168 return (s->gsbase.subcode & GF_CALL_FROM_THUNK) != 0;
2172 /* If PASS_ARG_PACK_P is true, GIMPLE_CALL S is a stdarg call that needs the
2173 argument pack in its argument list. */
2175 static inline void
2176 gimple_call_set_va_arg_pack (gimple s, bool pass_arg_pack_p)
2178 GIMPLE_CHECK (s, GIMPLE_CALL);
2179 if (pass_arg_pack_p)
2180 s->gsbase.subcode |= GF_CALL_VA_ARG_PACK;
2181 else
2182 s->gsbase.subcode &= ~GF_CALL_VA_ARG_PACK;
2186 /* Return true if GIMPLE_CALL S is a stdarg call that needs the
2187 argument pack in its argument list. */
2189 static inline bool
2190 gimple_call_va_arg_pack_p (gimple s)
2192 GIMPLE_CHECK (s, GIMPLE_CALL);
2193 return (s->gsbase.subcode & GF_CALL_VA_ARG_PACK) != 0;
2197 /* Return true if S is a noreturn call. */
2199 static inline bool
2200 gimple_call_noreturn_p (gimple s)
2202 GIMPLE_CHECK (s, GIMPLE_CALL);
2203 return (gimple_call_flags (s) & ECF_NORETURN) != 0;
2207 /* Return true if S is a nothrow call. */
2209 static inline bool
2210 gimple_call_nothrow_p (gimple s)
2212 GIMPLE_CHECK (s, GIMPLE_CALL);
2213 return (gimple_call_flags (s) & ECF_NOTHROW) != 0;
2217 /* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL. */
2219 static inline void
2220 gimple_call_copy_flags (gimple dest_call, gimple orig_call)
2222 GIMPLE_CHECK (dest_call, GIMPLE_CALL);
2223 GIMPLE_CHECK (orig_call, GIMPLE_CALL);
2224 dest_call->gsbase.subcode = orig_call->gsbase.subcode;
2228 /* Returns true if this is a GIMPLE_ASSIGN or a GIMPLE_CALL with a
2229 non-NULL lhs. */
2231 static inline bool
2232 gimple_has_lhs (gimple stmt)
2234 return (is_gimple_assign (stmt)
2235 || (is_gimple_call (stmt)
2236 && gimple_call_lhs (stmt) != NULL_TREE));
2240 /* Return the code of the predicate computed by conditional statement GS. */
2242 static inline enum tree_code
2243 gimple_cond_code (const_gimple gs)
2245 GIMPLE_CHECK (gs, GIMPLE_COND);
2246 return gs->gsbase.subcode;
2250 /* Set CODE to be the predicate code for the conditional statement GS. */
2252 static inline void
2253 gimple_cond_set_code (gimple gs, enum tree_code code)
2255 GIMPLE_CHECK (gs, GIMPLE_COND);
2256 gcc_assert (TREE_CODE_CLASS (code) == tcc_comparison);
2257 gs->gsbase.subcode = code;
2261 /* Return the LHS of the predicate computed by conditional statement GS. */
2263 static inline tree
2264 gimple_cond_lhs (const_gimple gs)
2266 GIMPLE_CHECK (gs, GIMPLE_COND);
2267 return gimple_op (gs, 0);
2270 /* Return the pointer to the LHS of the predicate computed by conditional
2271 statement GS. */
2273 static inline tree *
2274 gimple_cond_lhs_ptr (const_gimple gs)
2276 GIMPLE_CHECK (gs, GIMPLE_COND);
2277 return gimple_op_ptr (gs, 0);
2280 /* Set LHS to be the LHS operand of the predicate computed by
2281 conditional statement GS. */
2283 static inline void
2284 gimple_cond_set_lhs (gimple gs, tree lhs)
2286 GIMPLE_CHECK (gs, GIMPLE_COND);
2287 gcc_assert (is_gimple_operand (lhs));
2288 gimple_set_op (gs, 0, lhs);
2292 /* Return the RHS operand of the predicate computed by conditional GS. */
2294 static inline tree
2295 gimple_cond_rhs (const_gimple gs)
2297 GIMPLE_CHECK (gs, GIMPLE_COND);
2298 return gimple_op (gs, 1);
2301 /* Return the pointer to the RHS operand of the predicate computed by
2302 conditional GS. */
2304 static inline tree *
2305 gimple_cond_rhs_ptr (const_gimple gs)
2307 GIMPLE_CHECK (gs, GIMPLE_COND);
2308 return gimple_op_ptr (gs, 1);
2312 /* Set RHS to be the RHS operand of the predicate computed by
2313 conditional statement GS. */
2315 static inline void
2316 gimple_cond_set_rhs (gimple gs, tree rhs)
2318 GIMPLE_CHECK (gs, GIMPLE_COND);
2319 gcc_assert (is_gimple_operand (rhs));
2320 gimple_set_op (gs, 1, rhs);
2324 /* Return the label used by conditional statement GS when its
2325 predicate evaluates to true. */
2327 static inline tree
2328 gimple_cond_true_label (const_gimple gs)
2330 GIMPLE_CHECK (gs, GIMPLE_COND);
2331 return gimple_op (gs, 2);
2335 /* Set LABEL to be the label used by conditional statement GS when its
2336 predicate evaluates to true. */
2338 static inline void
2339 gimple_cond_set_true_label (gimple gs, tree label)
2341 GIMPLE_CHECK (gs, GIMPLE_COND);
2342 gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
2343 gimple_set_op (gs, 2, label);
2347 /* Set LABEL to be the label used by conditional statement GS when its
2348 predicate evaluates to false. */
2350 static inline void
2351 gimple_cond_set_false_label (gimple gs, tree label)
2353 GIMPLE_CHECK (gs, GIMPLE_COND);
2354 gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
2355 gimple_set_op (gs, 3, label);
2359 /* Return the label used by conditional statement GS when its
2360 predicate evaluates to false. */
2362 static inline tree
2363 gimple_cond_false_label (const_gimple gs)
2365 GIMPLE_CHECK (gs, GIMPLE_COND);
2366 return gimple_op (gs, 3);
2370 /* Set the conditional COND_STMT to be of the form 'if (1 == 0)'. */
2372 static inline void
2373 gimple_cond_make_false (gimple gs)
2375 gimple_cond_set_lhs (gs, boolean_true_node);
2376 gimple_cond_set_rhs (gs, boolean_false_node);
2377 gs->gsbase.subcode = EQ_EXPR;
2381 /* Set the conditional COND_STMT to be of the form 'if (1 == 1)'. */
2383 static inline void
2384 gimple_cond_make_true (gimple gs)
2386 gimple_cond_set_lhs (gs, boolean_true_node);
2387 gimple_cond_set_rhs (gs, boolean_true_node);
2388 gs->gsbase.subcode = EQ_EXPR;
2391 /* Check if conditional statemente GS is of the form 'if (1 == 1)',
2392 'if (0 == 0)', 'if (1 != 0)' or 'if (0 != 1)' */
2394 static inline bool
2395 gimple_cond_true_p (const_gimple gs)
2397 tree lhs = gimple_cond_lhs (gs);
2398 tree rhs = gimple_cond_rhs (gs);
2399 enum tree_code code = gimple_cond_code (gs);
2401 if (lhs != boolean_true_node && lhs != boolean_false_node)
2402 return false;
2404 if (rhs != boolean_true_node && rhs != boolean_false_node)
2405 return false;
2407 if (code == NE_EXPR && lhs != rhs)
2408 return true;
2410 if (code == EQ_EXPR && lhs == rhs)
2411 return true;
2413 return false;
2416 /* Check if conditional statement GS is of the form 'if (1 != 1)',
2417 'if (0 != 0)', 'if (1 == 0)' or 'if (0 == 1)' */
2419 static inline bool
2420 gimple_cond_false_p (const_gimple gs)
2422 tree lhs = gimple_cond_lhs (gs);
2423 tree rhs = gimple_cond_rhs (gs);
2424 enum tree_code code = gimple_cond_code (gs);
2426 if (lhs != boolean_true_node && lhs != boolean_false_node)
2427 return false;
2429 if (rhs != boolean_true_node && rhs != boolean_false_node)
2430 return false;
2432 if (code == NE_EXPR && lhs == rhs)
2433 return true;
2435 if (code == EQ_EXPR && lhs != rhs)
2436 return true;
2438 return false;
2441 /* Check if conditional statement GS is of the form 'if (var != 0)' or
2442 'if (var == 1)' */
2444 static inline bool
2445 gimple_cond_single_var_p (gimple gs)
2447 if (gimple_cond_code (gs) == NE_EXPR
2448 && gimple_cond_rhs (gs) == boolean_false_node)
2449 return true;
2451 if (gimple_cond_code (gs) == EQ_EXPR
2452 && gimple_cond_rhs (gs) == boolean_true_node)
2453 return true;
2455 return false;
2458 /* Set the code, LHS and RHS of GIMPLE_COND STMT from CODE, LHS and RHS. */
2460 static inline void
2461 gimple_cond_set_condition (gimple stmt, enum tree_code code, tree lhs, tree rhs)
2463 gimple_cond_set_code (stmt, code);
2464 gimple_cond_set_lhs (stmt, lhs);
2465 gimple_cond_set_rhs (stmt, rhs);
2468 /* Return the LABEL_DECL node used by GIMPLE_LABEL statement GS. */
2470 static inline tree
2471 gimple_label_label (const_gimple gs)
2473 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2474 return gimple_op (gs, 0);
2478 /* Set LABEL to be the LABEL_DECL node used by GIMPLE_LABEL statement
2479 GS. */
2481 static inline void
2482 gimple_label_set_label (gimple gs, tree label)
2484 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2485 gcc_assert (TREE_CODE (label) == LABEL_DECL);
2486 gimple_set_op (gs, 0, label);
2490 /* Return the destination of the unconditional jump GS. */
2492 static inline tree
2493 gimple_goto_dest (const_gimple gs)
2495 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2496 return gimple_op (gs, 0);
2500 /* Set DEST to be the destination of the unconditonal jump GS. */
2502 static inline void
2503 gimple_goto_set_dest (gimple gs, tree dest)
2505 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2506 gcc_assert (is_gimple_operand (dest));
2507 gimple_set_op (gs, 0, dest);
2511 /* Return the variables declared in the GIMPLE_BIND statement GS. */
2513 static inline tree
2514 gimple_bind_vars (const_gimple gs)
2516 GIMPLE_CHECK (gs, GIMPLE_BIND);
2517 return gs->gimple_bind.vars;
2521 /* Set VARS to be the set of variables declared in the GIMPLE_BIND
2522 statement GS. */
2524 static inline void
2525 gimple_bind_set_vars (gimple gs, tree vars)
2527 GIMPLE_CHECK (gs, GIMPLE_BIND);
2528 gs->gimple_bind.vars = vars;
2532 /* Append VARS to the set of variables declared in the GIMPLE_BIND
2533 statement GS. */
2535 static inline void
2536 gimple_bind_append_vars (gimple gs, tree vars)
2538 GIMPLE_CHECK (gs, GIMPLE_BIND);
2539 gs->gimple_bind.vars = chainon (gs->gimple_bind.vars, vars);
2543 /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS. */
2545 static inline gimple_seq
2546 gimple_bind_body (gimple gs)
2548 GIMPLE_CHECK (gs, GIMPLE_BIND);
2549 return gs->gimple_bind.body;
2553 /* Set SEQ to be the GIMPLE sequence contained in the GIMPLE_BIND
2554 statement GS. */
2556 static inline void
2557 gimple_bind_set_body (gimple gs, gimple_seq seq)
2559 GIMPLE_CHECK (gs, GIMPLE_BIND);
2560 gs->gimple_bind.body = seq;
2564 /* Append a statement to the end of a GIMPLE_BIND's body. */
2566 static inline void
2567 gimple_bind_add_stmt (gimple gs, gimple stmt)
2569 GIMPLE_CHECK (gs, GIMPLE_BIND);
2570 gimple_seq_add_stmt (&gs->gimple_bind.body, stmt);
2574 /* Append a sequence of statements to the end of a GIMPLE_BIND's body. */
2576 static inline void
2577 gimple_bind_add_seq (gimple gs, gimple_seq seq)
2579 GIMPLE_CHECK (gs, GIMPLE_BIND);
2580 gimple_seq_add_seq (&gs->gimple_bind.body, seq);
2584 /* Return the TREE_BLOCK node associated with GIMPLE_BIND statement
2585 GS. This is analogous to the BIND_EXPR_BLOCK field in trees. */
2587 static inline tree
2588 gimple_bind_block (const_gimple gs)
2590 GIMPLE_CHECK (gs, GIMPLE_BIND);
2591 return gs->gimple_bind.block;
2595 /* Set BLOCK to be the TREE_BLOCK node associated with GIMPLE_BIND
2596 statement GS. */
2598 static inline void
2599 gimple_bind_set_block (gimple gs, tree block)
2601 GIMPLE_CHECK (gs, GIMPLE_BIND);
2602 gcc_assert (block == NULL_TREE || TREE_CODE (block) == BLOCK);
2603 gs->gimple_bind.block = block;
2607 /* Return the number of input operands for GIMPLE_ASM GS. */
2609 static inline unsigned
2610 gimple_asm_ninputs (const_gimple gs)
2612 GIMPLE_CHECK (gs, GIMPLE_ASM);
2613 return gs->gimple_asm.ni;
2617 /* Return the number of output operands for GIMPLE_ASM GS. */
2619 static inline unsigned
2620 gimple_asm_noutputs (const_gimple gs)
2622 GIMPLE_CHECK (gs, GIMPLE_ASM);
2623 return gs->gimple_asm.no;
2627 /* Return the number of clobber operands for GIMPLE_ASM GS. */
2629 static inline unsigned
2630 gimple_asm_nclobbers (const_gimple gs)
2632 GIMPLE_CHECK (gs, GIMPLE_ASM);
2633 return gs->gimple_asm.nc;
2637 /* Return input operand INDEX of GIMPLE_ASM GS. */
2639 static inline tree
2640 gimple_asm_input_op (const_gimple gs, unsigned index)
2642 GIMPLE_CHECK (gs, GIMPLE_ASM);
2643 gcc_assert (index <= gs->gimple_asm.ni);
2644 return gimple_op (gs, index);
2647 /* Return a pointer to input operand INDEX of GIMPLE_ASM GS. */
2649 static inline tree *
2650 gimple_asm_input_op_ptr (const_gimple gs, unsigned index)
2652 GIMPLE_CHECK (gs, GIMPLE_ASM);
2653 gcc_assert (index <= gs->gimple_asm.ni);
2654 return gimple_op_ptr (gs, index);
2658 /* Set IN_OP to be input operand INDEX in GIMPLE_ASM GS. */
2660 static inline void
2661 gimple_asm_set_input_op (gimple gs, unsigned index, tree in_op)
2663 GIMPLE_CHECK (gs, GIMPLE_ASM);
2664 gcc_assert (index <= gs->gimple_asm.ni);
2665 gcc_assert (TREE_CODE (in_op) == TREE_LIST);
2666 gimple_set_op (gs, index, in_op);
2670 /* Return output operand INDEX of GIMPLE_ASM GS. */
2672 static inline tree
2673 gimple_asm_output_op (const_gimple gs, unsigned index)
2675 GIMPLE_CHECK (gs, GIMPLE_ASM);
2676 gcc_assert (index <= gs->gimple_asm.no);
2677 return gimple_op (gs, index + gs->gimple_asm.ni);
2680 /* Return a pointer to output operand INDEX of GIMPLE_ASM GS. */
2682 static inline tree *
2683 gimple_asm_output_op_ptr (const_gimple gs, unsigned index)
2685 GIMPLE_CHECK (gs, GIMPLE_ASM);
2686 gcc_assert (index <= gs->gimple_asm.no);
2687 return gimple_op_ptr (gs, index + gs->gimple_asm.ni);
2691 /* Set OUT_OP to be output operand INDEX in GIMPLE_ASM GS. */
2693 static inline void
2694 gimple_asm_set_output_op (gimple gs, unsigned index, tree out_op)
2696 GIMPLE_CHECK (gs, GIMPLE_ASM);
2697 gcc_assert (index <= gs->gimple_asm.no);
2698 gcc_assert (TREE_CODE (out_op) == TREE_LIST);
2699 gimple_set_op (gs, index + gs->gimple_asm.ni, out_op);
2703 /* Return clobber operand INDEX of GIMPLE_ASM GS. */
2705 static inline tree
2706 gimple_asm_clobber_op (const_gimple gs, unsigned index)
2708 GIMPLE_CHECK (gs, GIMPLE_ASM);
2709 gcc_assert (index <= gs->gimple_asm.nc);
2710 return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no);
2714 /* Set CLOBBER_OP to be clobber operand INDEX in GIMPLE_ASM GS. */
2716 static inline void
2717 gimple_asm_set_clobber_op (gimple gs, unsigned index, tree clobber_op)
2719 GIMPLE_CHECK (gs, GIMPLE_ASM);
2720 gcc_assert (index <= gs->gimple_asm.nc);
2721 gcc_assert (TREE_CODE (clobber_op) == TREE_LIST);
2722 gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no, clobber_op);
2726 /* Return the string representing the assembly instruction in
2727 GIMPLE_ASM GS. */
2729 static inline const char *
2730 gimple_asm_string (const_gimple gs)
2732 GIMPLE_CHECK (gs, GIMPLE_ASM);
2733 return gs->gimple_asm.string;
2737 /* Return true if GS is an asm statement marked volatile. */
2739 static inline bool
2740 gimple_asm_volatile_p (const_gimple gs)
2742 GIMPLE_CHECK (gs, GIMPLE_ASM);
2743 return (gs->gsbase.subcode & GF_ASM_VOLATILE) != 0;
2747 /* If VOLATLE_P is true, mark asm statement GS as volatile. */
2749 static inline void
2750 gimple_asm_set_volatile (gimple gs, bool volatile_p)
2752 GIMPLE_CHECK (gs, GIMPLE_ASM);
2753 if (volatile_p)
2754 gs->gsbase.subcode |= GF_ASM_VOLATILE;
2755 else
2756 gs->gsbase.subcode &= ~GF_ASM_VOLATILE;
2760 /* If INPUT_P is true, mark asm GS as an ASM_INPUT. */
2762 static inline void
2763 gimple_asm_set_input (gimple gs, bool input_p)
2765 GIMPLE_CHECK (gs, GIMPLE_ASM);
2766 if (input_p)
2767 gs->gsbase.subcode |= GF_ASM_INPUT;
2768 else
2769 gs->gsbase.subcode &= ~GF_ASM_INPUT;
2773 /* Return true if asm GS is an ASM_INPUT. */
2775 static inline bool
2776 gimple_asm_input_p (const_gimple gs)
2778 GIMPLE_CHECK (gs, GIMPLE_ASM);
2779 return (gs->gsbase.subcode & GF_ASM_INPUT) != 0;
2783 /* Return the types handled by GIMPLE_CATCH statement GS. */
2785 static inline tree
2786 gimple_catch_types (const_gimple gs)
2788 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2789 return gs->gimple_catch.types;
2793 /* Return a pointer to the types handled by GIMPLE_CATCH statement GS. */
2795 static inline tree *
2796 gimple_catch_types_ptr (gimple gs)
2798 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2799 return &gs->gimple_catch.types;
2803 /* Return the GIMPLE sequence representing the body of the handler of
2804 GIMPLE_CATCH statement GS. */
2806 static inline gimple_seq
2807 gimple_catch_handler (gimple gs)
2809 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2810 return gs->gimple_catch.handler;
2814 /* Return a pointer to the GIMPLE sequence representing the body of
2815 the handler of GIMPLE_CATCH statement GS. */
2817 static inline gimple_seq *
2818 gimple_catch_handler_ptr (gimple gs)
2820 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2821 return &gs->gimple_catch.handler;
2825 /* Set T to be the set of types handled by GIMPLE_CATCH GS. */
2827 static inline void
2828 gimple_catch_set_types (gimple gs, tree t)
2830 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2831 gs->gimple_catch.types = t;
2835 /* Set HANDLER to be the body of GIMPLE_CATCH GS. */
2837 static inline void
2838 gimple_catch_set_handler (gimple gs, gimple_seq handler)
2840 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2841 gs->gimple_catch.handler = handler;
2845 /* Return the types handled by GIMPLE_EH_FILTER statement GS. */
2847 static inline tree
2848 gimple_eh_filter_types (const_gimple gs)
2850 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2851 return gs->gimple_eh_filter.types;
2855 /* Return a pointer to the types handled by GIMPLE_EH_FILTER statement
2856 GS. */
2858 static inline tree *
2859 gimple_eh_filter_types_ptr (gimple gs)
2861 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2862 return &gs->gimple_eh_filter.types;
2866 /* Return the sequence of statement to execute when GIMPLE_EH_FILTER
2867 statement fails. */
2869 static inline gimple_seq
2870 gimple_eh_filter_failure (gimple gs)
2872 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2873 return gs->gimple_eh_filter.failure;
2877 /* Set TYPES to be the set of types handled by GIMPLE_EH_FILTER GS. */
2879 static inline void
2880 gimple_eh_filter_set_types (gimple gs, tree types)
2882 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2883 gs->gimple_eh_filter.types = types;
2887 /* Set FAILURE to be the sequence of statements to execute on failure
2888 for GIMPLE_EH_FILTER GS. */
2890 static inline void
2891 gimple_eh_filter_set_failure (gimple gs, gimple_seq failure)
2893 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2894 gs->gimple_eh_filter.failure = failure;
2897 /* Return the EH_FILTER_MUST_NOT_THROW flag. */
2899 static inline bool
2901 gimple_eh_filter_must_not_throw (gimple gs)
2903 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2904 return gs->gsbase.subcode != 0;
2907 /* Set the EH_FILTER_MUST_NOT_THROW flag to the value MNTP. */
2909 static inline void
2910 gimple_eh_filter_set_must_not_throw (gimple gs, bool mntp)
2912 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2913 gs->gsbase.subcode = (unsigned int) mntp;
2917 /* GIMPLE_TRY accessors. */
2919 /* Return the kind of try block represented by GIMPLE_TRY GS. This is
2920 either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY. */
2922 static inline enum gimple_try_flags
2923 gimple_try_kind (const_gimple gs)
2925 GIMPLE_CHECK (gs, GIMPLE_TRY);
2926 return (enum gimple_try_flags) (gs->gsbase.subcode & GIMPLE_TRY_KIND);
2930 /* Set the kind of try block represented by GIMPLE_TRY GS. */
2932 static inline void
2933 gimple_try_set_kind (gimple gs, enum gimple_try_flags kind)
2935 GIMPLE_CHECK (gs, GIMPLE_TRY);
2936 gcc_assert (kind == GIMPLE_TRY_CATCH || kind == GIMPLE_TRY_FINALLY);
2937 if (gimple_try_kind (gs) != kind)
2938 gs->gsbase.subcode = (unsigned int) kind;
2942 /* Return the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2944 static inline bool
2945 gimple_try_catch_is_cleanup (const_gimple gs)
2947 gcc_assert (gimple_try_kind (gs) == GIMPLE_TRY_CATCH);
2948 return (gs->gsbase.subcode & GIMPLE_TRY_CATCH_IS_CLEANUP) != 0;
2952 /* Return the sequence of statements used as the body for GIMPLE_TRY GS. */
2954 static inline gimple_seq
2955 gimple_try_eval (gimple gs)
2957 GIMPLE_CHECK (gs, GIMPLE_TRY);
2958 return gs->gimple_try.eval;
2962 /* Return the sequence of statements used as the cleanup body for
2963 GIMPLE_TRY GS. */
2965 static inline gimple_seq
2966 gimple_try_cleanup (gimple gs)
2968 GIMPLE_CHECK (gs, GIMPLE_TRY);
2969 return gs->gimple_try.cleanup;
2973 /* Set the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2975 static inline void
2976 gimple_try_set_catch_is_cleanup (gimple g, bool catch_is_cleanup)
2978 gcc_assert (gimple_try_kind (g) == GIMPLE_TRY_CATCH);
2979 if (catch_is_cleanup)
2980 g->gsbase.subcode |= GIMPLE_TRY_CATCH_IS_CLEANUP;
2981 else
2982 g->gsbase.subcode &= ~GIMPLE_TRY_CATCH_IS_CLEANUP;
2986 /* Set EVAL to be the sequence of statements to use as the body for
2987 GIMPLE_TRY GS. */
2989 static inline void
2990 gimple_try_set_eval (gimple gs, gimple_seq eval)
2992 GIMPLE_CHECK (gs, GIMPLE_TRY);
2993 gs->gimple_try.eval = eval;
2997 /* Set CLEANUP to be the sequence of statements to use as the cleanup
2998 body for GIMPLE_TRY GS. */
3000 static inline void
3001 gimple_try_set_cleanup (gimple gs, gimple_seq cleanup)
3003 GIMPLE_CHECK (gs, GIMPLE_TRY);
3004 gs->gimple_try.cleanup = cleanup;
3008 /* Return the cleanup sequence for cleanup statement GS. */
3010 static inline gimple_seq
3011 gimple_wce_cleanup (gimple gs)
3013 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3014 return gs->gimple_wce.cleanup;
3018 /* Set CLEANUP to be the cleanup sequence for GS. */
3020 static inline void
3021 gimple_wce_set_cleanup (gimple gs, gimple_seq cleanup)
3023 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3024 gs->gimple_wce.cleanup = cleanup;
3028 /* Return the CLEANUP_EH_ONLY flag for a WCE tuple. */
3030 static inline bool
3031 gimple_wce_cleanup_eh_only (const_gimple gs)
3033 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3034 return gs->gsbase.subcode != 0;
3038 /* Set the CLEANUP_EH_ONLY flag for a WCE tuple. */
3040 static inline void
3041 gimple_wce_set_cleanup_eh_only (gimple gs, bool eh_only_p)
3043 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3044 gs->gsbase.subcode = (unsigned int) eh_only_p;
3048 /* Return the maximum number of arguments supported by GIMPLE_PHI GS. */
3050 static inline unsigned
3051 gimple_phi_capacity (const_gimple gs)
3053 GIMPLE_CHECK (gs, GIMPLE_PHI);
3054 return gs->gimple_phi.capacity;
3058 /* Return the number of arguments in GIMPLE_PHI GS. This must always
3059 be exactly the number of incoming edges for the basic block holding
3060 GS. */
3062 static inline unsigned
3063 gimple_phi_num_args (const_gimple gs)
3065 GIMPLE_CHECK (gs, GIMPLE_PHI);
3066 return gs->gimple_phi.nargs;
3070 /* Return the SSA name created by GIMPLE_PHI GS. */
3072 static inline tree
3073 gimple_phi_result (const_gimple gs)
3075 GIMPLE_CHECK (gs, GIMPLE_PHI);
3076 return gs->gimple_phi.result;
3079 /* Return a pointer to the SSA name created by GIMPLE_PHI GS. */
3081 static inline tree *
3082 gimple_phi_result_ptr (gimple gs)
3084 GIMPLE_CHECK (gs, GIMPLE_PHI);
3085 return &gs->gimple_phi.result;
3088 /* Set RESULT to be the SSA name created by GIMPLE_PHI GS. */
3090 static inline void
3091 gimple_phi_set_result (gimple gs, tree result)
3093 GIMPLE_CHECK (gs, GIMPLE_PHI);
3094 gs->gimple_phi.result = result;
3098 /* Return the PHI argument corresponding to incoming edge INDEX for
3099 GIMPLE_PHI GS. */
3101 static inline struct phi_arg_d *
3102 gimple_phi_arg (gimple gs, unsigned index)
3104 GIMPLE_CHECK (gs, GIMPLE_PHI);
3105 gcc_assert (index <= gs->gimple_phi.capacity);
3106 return &(gs->gimple_phi.args[index]);
3109 /* Set PHIARG to be the argument corresponding to incoming edge INDEX
3110 for GIMPLE_PHI GS. */
3112 static inline void
3113 gimple_phi_set_arg (gimple gs, unsigned index, struct phi_arg_d * phiarg)
3115 GIMPLE_CHECK (gs, GIMPLE_PHI);
3116 gcc_assert (index <= gs->gimple_phi.nargs);
3117 memcpy (gs->gimple_phi.args + index, phiarg, sizeof (struct phi_arg_d));
3120 /* Return the region number for GIMPLE_RESX GS. */
3122 static inline int
3123 gimple_resx_region (const_gimple gs)
3125 GIMPLE_CHECK (gs, GIMPLE_RESX);
3126 return gs->gimple_resx.region;
3129 /* Set REGION to be the region number for GIMPLE_RESX GS. */
3131 static inline void
3132 gimple_resx_set_region (gimple gs, int region)
3134 GIMPLE_CHECK (gs, GIMPLE_RESX);
3135 gs->gimple_resx.region = region;
3139 /* Return the number of labels associated with the switch statement GS. */
3141 static inline unsigned
3142 gimple_switch_num_labels (const_gimple gs)
3144 unsigned num_ops;
3145 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3146 num_ops = gimple_num_ops (gs);
3147 gcc_assert (num_ops > 1);
3148 return num_ops - 1;
3152 /* Set NLABELS to be the number of labels for the switch statement GS. */
3154 static inline void
3155 gimple_switch_set_num_labels (gimple g, unsigned nlabels)
3157 GIMPLE_CHECK (g, GIMPLE_SWITCH);
3158 gimple_set_num_ops (g, nlabels + 1);
3162 /* Return the index variable used by the switch statement GS. */
3164 static inline tree
3165 gimple_switch_index (const_gimple gs)
3167 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3168 return gimple_op (gs, 0);
3172 /* Return a pointer to the index variable for the switch statement GS. */
3174 static inline tree *
3175 gimple_switch_index_ptr (const_gimple gs)
3177 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3178 return gimple_op_ptr (gs, 0);
3182 /* Set INDEX to be the index variable for switch statement GS. */
3184 static inline void
3185 gimple_switch_set_index (gimple gs, tree index)
3187 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3188 gcc_assert (SSA_VAR_P (index) || CONSTANT_CLASS_P (index));
3189 gimple_set_op (gs, 0, index);
3193 /* Return the label numbered INDEX. The default label is 0, followed by any
3194 labels in a switch statement. */
3196 static inline tree
3197 gimple_switch_label (const_gimple gs, unsigned index)
3199 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3200 gcc_assert (gimple_num_ops (gs) > index + 1);
3201 return gimple_op (gs, index + 1);
3204 /* Set the label number INDEX to LABEL. 0 is always the default label. */
3206 static inline void
3207 gimple_switch_set_label (gimple gs, unsigned index, tree label)
3209 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3210 gcc_assert (gimple_num_ops (gs) > index + 1);
3211 gcc_assert (label == NULL_TREE || TREE_CODE (label) == CASE_LABEL_EXPR);
3212 gimple_set_op (gs, index + 1, label);
3215 /* Return the default label for a switch statement. */
3217 static inline tree
3218 gimple_switch_default_label (const_gimple gs)
3220 return gimple_switch_label (gs, 0);
3223 /* Set the default label for a switch statement. */
3225 static inline void
3226 gimple_switch_set_default_label (gimple gs, tree label)
3228 gimple_switch_set_label (gs, 0, label);
3232 /* Return the body for the OMP statement GS. */
3234 static inline gimple_seq
3235 gimple_omp_body (gimple gs)
3237 return gs->omp.body;
3240 /* Set BODY to be the body for the OMP statement GS. */
3242 static inline void
3243 gimple_omp_set_body (gimple gs, gimple_seq body)
3245 gs->omp.body = body;
3249 /* Return the name associated with OMP_CRITICAL statement GS. */
3251 static inline tree
3252 gimple_omp_critical_name (const_gimple gs)
3254 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3255 return gs->gimple_omp_critical.name;
3259 /* Return a pointer to the name associated with OMP critical statement GS. */
3261 static inline tree *
3262 gimple_omp_critical_name_ptr (gimple gs)
3264 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3265 return &gs->gimple_omp_critical.name;
3269 /* Set NAME to be the name associated with OMP critical statement GS. */
3271 static inline void
3272 gimple_omp_critical_set_name (gimple gs, tree name)
3274 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3275 gs->gimple_omp_critical.name = name;
3279 /* Return the clauses associated with OMP_FOR GS. */
3281 static inline tree
3282 gimple_omp_for_clauses (const_gimple gs)
3284 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3285 return gs->gimple_omp_for.clauses;
3289 /* Return a pointer to the OMP_FOR GS. */
3291 static inline tree *
3292 gimple_omp_for_clauses_ptr (gimple gs)
3294 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3295 return &gs->gimple_omp_for.clauses;
3299 /* Set CLAUSES to be the list of clauses associated with OMP_FOR GS. */
3301 static inline void
3302 gimple_omp_for_set_clauses (gimple gs, tree clauses)
3304 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3305 gs->gimple_omp_for.clauses = clauses;
3309 /* Get the collapse count of OMP_FOR GS. */
3311 static inline size_t
3312 gimple_omp_for_collapse (gimple gs)
3314 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3315 return gs->gimple_omp_for.collapse;
3319 /* Return the index variable for OMP_FOR GS. */
3321 static inline tree
3322 gimple_omp_for_index (const_gimple gs, size_t i)
3324 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3325 gcc_assert (i < gs->gimple_omp_for.collapse);
3326 return gs->gimple_omp_for.iter[i].index;
3330 /* Return a pointer to the index variable for OMP_FOR GS. */
3332 static inline tree *
3333 gimple_omp_for_index_ptr (gimple gs, size_t i)
3335 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3336 gcc_assert (i < gs->gimple_omp_for.collapse);
3337 return &gs->gimple_omp_for.iter[i].index;
3341 /* Set INDEX to be the index variable for OMP_FOR GS. */
3343 static inline void
3344 gimple_omp_for_set_index (gimple gs, size_t i, tree index)
3346 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3347 gcc_assert (i < gs->gimple_omp_for.collapse);
3348 gs->gimple_omp_for.iter[i].index = index;
3352 /* Return the initial value for OMP_FOR GS. */
3354 static inline tree
3355 gimple_omp_for_initial (const_gimple gs, size_t i)
3357 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3358 gcc_assert (i < gs->gimple_omp_for.collapse);
3359 return gs->gimple_omp_for.iter[i].initial;
3363 /* Return a pointer to the initial value for OMP_FOR GS. */
3365 static inline tree *
3366 gimple_omp_for_initial_ptr (gimple gs, size_t i)
3368 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3369 gcc_assert (i < gs->gimple_omp_for.collapse);
3370 return &gs->gimple_omp_for.iter[i].initial;
3374 /* Set INITIAL to be the initial value for OMP_FOR GS. */
3376 static inline void
3377 gimple_omp_for_set_initial (gimple gs, size_t i, tree initial)
3379 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3380 gcc_assert (i < gs->gimple_omp_for.collapse);
3381 gs->gimple_omp_for.iter[i].initial = initial;
3385 /* Return the final value for OMP_FOR GS. */
3387 static inline tree
3388 gimple_omp_for_final (const_gimple gs, size_t i)
3390 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3391 gcc_assert (i < gs->gimple_omp_for.collapse);
3392 return gs->gimple_omp_for.iter[i].final;
3396 /* Return a pointer to the final value for OMP_FOR GS. */
3398 static inline tree *
3399 gimple_omp_for_final_ptr (gimple gs, size_t i)
3401 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3402 gcc_assert (i < gs->gimple_omp_for.collapse);
3403 return &gs->gimple_omp_for.iter[i].final;
3407 /* Set FINAL to be the final value for OMP_FOR GS. */
3409 static inline void
3410 gimple_omp_for_set_final (gimple gs, size_t i, tree final)
3412 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3413 gcc_assert (i < gs->gimple_omp_for.collapse);
3414 gs->gimple_omp_for.iter[i].final = final;
3418 /* Return the increment value for OMP_FOR GS. */
3420 static inline tree
3421 gimple_omp_for_incr (const_gimple gs, size_t i)
3423 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3424 gcc_assert (i < gs->gimple_omp_for.collapse);
3425 return gs->gimple_omp_for.iter[i].incr;
3429 /* Return a pointer to the increment value for OMP_FOR GS. */
3431 static inline tree *
3432 gimple_omp_for_incr_ptr (gimple gs, size_t i)
3434 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3435 gcc_assert (i < gs->gimple_omp_for.collapse);
3436 return &gs->gimple_omp_for.iter[i].incr;
3440 /* Set INCR to be the increment value for OMP_FOR GS. */
3442 static inline void
3443 gimple_omp_for_set_incr (gimple gs, size_t i, tree incr)
3445 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3446 gcc_assert (i < gs->gimple_omp_for.collapse);
3447 gs->gimple_omp_for.iter[i].incr = incr;
3451 /* Return the sequence of statements to execute before the OMP_FOR
3452 statement GS starts. */
3454 static inline gimple_seq
3455 gimple_omp_for_pre_body (gimple gs)
3457 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3458 return gs->gimple_omp_for.pre_body;
3462 /* Set PRE_BODY to be the sequence of statements to execute before the
3463 OMP_FOR statement GS starts. */
3465 static inline void
3466 gimple_omp_for_set_pre_body (gimple gs, gimple_seq pre_body)
3468 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3469 gs->gimple_omp_for.pre_body = pre_body;
3473 /* Return the clauses associated with OMP_PARALLEL GS. */
3475 static inline tree
3476 gimple_omp_parallel_clauses (const_gimple gs)
3478 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3479 return gs->gimple_omp_parallel.clauses;
3483 /* Return a pointer to the clauses associated with OMP_PARALLEL GS. */
3485 static inline tree *
3486 gimple_omp_parallel_clauses_ptr (gimple gs)
3488 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3489 return &gs->gimple_omp_parallel.clauses;
3493 /* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL
3494 GS. */
3496 static inline void
3497 gimple_omp_parallel_set_clauses (gimple gs, tree clauses)
3499 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3500 gs->gimple_omp_parallel.clauses = clauses;
3504 /* Return the child function used to hold the body of OMP_PARALLEL GS. */
3506 static inline tree
3507 gimple_omp_parallel_child_fn (const_gimple gs)
3509 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3510 return gs->gimple_omp_parallel.child_fn;
3513 /* Return a pointer to the child function used to hold the body of
3514 OMP_PARALLEL GS. */
3516 static inline tree *
3517 gimple_omp_parallel_child_fn_ptr (gimple gs)
3519 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3520 return &gs->gimple_omp_parallel.child_fn;
3524 /* Set CHILD_FN to be the child function for OMP_PARALLEL GS. */
3526 static inline void
3527 gimple_omp_parallel_set_child_fn (gimple gs, tree child_fn)
3529 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3530 gs->gimple_omp_parallel.child_fn = child_fn;
3534 /* Return the artificial argument used to send variables and values
3535 from the parent to the children threads in OMP_PARALLEL GS. */
3537 static inline tree
3538 gimple_omp_parallel_data_arg (const_gimple gs)
3540 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3541 return gs->gimple_omp_parallel.data_arg;
3545 /* Return a pointer to the data argument for OMP_PARALLEL GS. */
3547 static inline tree *
3548 gimple_omp_parallel_data_arg_ptr (gimple gs)
3550 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3551 return &gs->gimple_omp_parallel.data_arg;
3555 /* Set DATA_ARG to be the data argument for OMP_PARALLEL GS. */
3557 static inline void
3558 gimple_omp_parallel_set_data_arg (gimple gs, tree data_arg)
3560 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3561 gs->gimple_omp_parallel.data_arg = data_arg;
3565 /* Return the clauses associated with OMP_TASK GS. */
3567 static inline tree
3568 gimple_omp_task_clauses (const_gimple gs)
3570 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3571 return gs->gimple_omp_parallel.clauses;
3575 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3577 static inline tree *
3578 gimple_omp_task_clauses_ptr (gimple gs)
3580 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3581 return &gs->gimple_omp_parallel.clauses;
3585 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3586 GS. */
3588 static inline void
3589 gimple_omp_task_set_clauses (gimple gs, tree clauses)
3591 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3592 gs->gimple_omp_parallel.clauses = clauses;
3596 /* Return the child function used to hold the body of OMP_TASK GS. */
3598 static inline tree
3599 gimple_omp_task_child_fn (const_gimple gs)
3601 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3602 return gs->gimple_omp_parallel.child_fn;
3605 /* Return a pointer to the child function used to hold the body of
3606 OMP_TASK GS. */
3608 static inline tree *
3609 gimple_omp_task_child_fn_ptr (gimple gs)
3611 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3612 return &gs->gimple_omp_parallel.child_fn;
3616 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3618 static inline void
3619 gimple_omp_task_set_child_fn (gimple gs, tree child_fn)
3621 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3622 gs->gimple_omp_parallel.child_fn = child_fn;
3626 /* Return the artificial argument used to send variables and values
3627 from the parent to the children threads in OMP_TASK GS. */
3629 static inline tree
3630 gimple_omp_task_data_arg (const_gimple gs)
3632 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3633 return gs->gimple_omp_parallel.data_arg;
3637 /* Return a pointer to the data argument for OMP_TASK GS. */
3639 static inline tree *
3640 gimple_omp_task_data_arg_ptr (gimple gs)
3642 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3643 return &gs->gimple_omp_parallel.data_arg;
3647 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3649 static inline void
3650 gimple_omp_task_set_data_arg (gimple gs, tree data_arg)
3652 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3653 gs->gimple_omp_parallel.data_arg = data_arg;
3657 /* Return the clauses associated with OMP_TASK GS. */
3659 static inline tree
3660 gimple_omp_taskreg_clauses (const_gimple gs)
3662 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3663 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3664 return gs->gimple_omp_parallel.clauses;
3668 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3670 static inline tree *
3671 gimple_omp_taskreg_clauses_ptr (gimple gs)
3673 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3674 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3675 return &gs->gimple_omp_parallel.clauses;
3679 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3680 GS. */
3682 static inline void
3683 gimple_omp_taskreg_set_clauses (gimple gs, tree clauses)
3685 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3686 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3687 gs->gimple_omp_parallel.clauses = clauses;
3691 /* Return the child function used to hold the body of OMP_TASK GS. */
3693 static inline tree
3694 gimple_omp_taskreg_child_fn (const_gimple gs)
3696 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3697 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3698 return gs->gimple_omp_parallel.child_fn;
3701 /* Return a pointer to the child function used to hold the body of
3702 OMP_TASK GS. */
3704 static inline tree *
3705 gimple_omp_taskreg_child_fn_ptr (gimple gs)
3707 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3708 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3709 return &gs->gimple_omp_parallel.child_fn;
3713 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3715 static inline void
3716 gimple_omp_taskreg_set_child_fn (gimple gs, tree child_fn)
3718 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3719 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3720 gs->gimple_omp_parallel.child_fn = child_fn;
3724 /* Return the artificial argument used to send variables and values
3725 from the parent to the children threads in OMP_TASK GS. */
3727 static inline tree
3728 gimple_omp_taskreg_data_arg (const_gimple gs)
3730 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3731 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3732 return gs->gimple_omp_parallel.data_arg;
3736 /* Return a pointer to the data argument for OMP_TASK GS. */
3738 static inline tree *
3739 gimple_omp_taskreg_data_arg_ptr (gimple gs)
3741 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3742 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3743 return &gs->gimple_omp_parallel.data_arg;
3747 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3749 static inline void
3750 gimple_omp_taskreg_set_data_arg (gimple gs, tree data_arg)
3752 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3753 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3754 gs->gimple_omp_parallel.data_arg = data_arg;
3758 /* Return the copy function used to hold the body of OMP_TASK GS. */
3760 static inline tree
3761 gimple_omp_task_copy_fn (const_gimple gs)
3763 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3764 return gs->gimple_omp_task.copy_fn;
3767 /* Return a pointer to the copy function used to hold the body of
3768 OMP_TASK GS. */
3770 static inline tree *
3771 gimple_omp_task_copy_fn_ptr (gimple gs)
3773 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3774 return &gs->gimple_omp_task.copy_fn;
3778 /* Set CHILD_FN to be the copy function for OMP_TASK GS. */
3780 static inline void
3781 gimple_omp_task_set_copy_fn (gimple gs, tree copy_fn)
3783 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3784 gs->gimple_omp_task.copy_fn = copy_fn;
3788 /* Return size of the data block in bytes in OMP_TASK GS. */
3790 static inline tree
3791 gimple_omp_task_arg_size (const_gimple gs)
3793 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3794 return gs->gimple_omp_task.arg_size;
3798 /* Return a pointer to the data block size for OMP_TASK GS. */
3800 static inline tree *
3801 gimple_omp_task_arg_size_ptr (gimple gs)
3803 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3804 return &gs->gimple_omp_task.arg_size;
3808 /* Set ARG_SIZE to be the data block size for OMP_TASK GS. */
3810 static inline void
3811 gimple_omp_task_set_arg_size (gimple gs, tree arg_size)
3813 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3814 gs->gimple_omp_task.arg_size = arg_size;
3818 /* Return align of the data block in bytes in OMP_TASK GS. */
3820 static inline tree
3821 gimple_omp_task_arg_align (const_gimple gs)
3823 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3824 return gs->gimple_omp_task.arg_align;
3828 /* Return a pointer to the data block align for OMP_TASK GS. */
3830 static inline tree *
3831 gimple_omp_task_arg_align_ptr (gimple gs)
3833 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3834 return &gs->gimple_omp_task.arg_align;
3838 /* Set ARG_SIZE to be the data block align for OMP_TASK GS. */
3840 static inline void
3841 gimple_omp_task_set_arg_align (gimple gs, tree arg_align)
3843 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3844 gs->gimple_omp_task.arg_align = arg_align;
3848 /* Return the clauses associated with OMP_SINGLE GS. */
3850 static inline tree
3851 gimple_omp_single_clauses (const_gimple gs)
3853 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3854 return gs->gimple_omp_single.clauses;
3858 /* Return a pointer to the clauses associated with OMP_SINGLE GS. */
3860 static inline tree *
3861 gimple_omp_single_clauses_ptr (gimple gs)
3863 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3864 return &gs->gimple_omp_single.clauses;
3868 /* Set CLAUSES to be the clauses associated with OMP_SINGLE GS. */
3870 static inline void
3871 gimple_omp_single_set_clauses (gimple gs, tree clauses)
3873 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3874 gs->gimple_omp_single.clauses = clauses;
3878 /* Return the clauses associated with OMP_SECTIONS GS. */
3880 static inline tree
3881 gimple_omp_sections_clauses (const_gimple gs)
3883 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3884 return gs->gimple_omp_sections.clauses;
3888 /* Return a pointer to the clauses associated with OMP_SECTIONS GS. */
3890 static inline tree *
3891 gimple_omp_sections_clauses_ptr (gimple gs)
3893 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3894 return &gs->gimple_omp_sections.clauses;
3898 /* Set CLAUSES to be the set of clauses associated with OMP_SECTIONS
3899 GS. */
3901 static inline void
3902 gimple_omp_sections_set_clauses (gimple gs, tree clauses)
3904 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3905 gs->gimple_omp_sections.clauses = clauses;
3909 /* Return the control variable associated with the GIMPLE_OMP_SECTIONS
3910 in GS. */
3912 static inline tree
3913 gimple_omp_sections_control (const_gimple gs)
3915 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3916 return gs->gimple_omp_sections.control;
3920 /* Return a pointer to the clauses associated with the GIMPLE_OMP_SECTIONS
3921 GS. */
3923 static inline tree *
3924 gimple_omp_sections_control_ptr (gimple gs)
3926 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3927 return &gs->gimple_omp_sections.control;
3931 /* Set CONTROL to be the set of clauses associated with the
3932 GIMPLE_OMP_SECTIONS in GS. */
3934 static inline void
3935 gimple_omp_sections_set_control (gimple gs, tree control)
3937 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3938 gs->gimple_omp_sections.control = control;
3942 /* Set COND to be the condition code for OMP_FOR GS. */
3944 static inline void
3945 gimple_omp_for_set_cond (gimple gs, size_t i, enum tree_code cond)
3947 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3948 gcc_assert (TREE_CODE_CLASS (cond) == tcc_comparison);
3949 gcc_assert (i < gs->gimple_omp_for.collapse);
3950 gs->gimple_omp_for.iter[i].cond = cond;
3954 /* Return the condition code associated with OMP_FOR GS. */
3956 static inline enum tree_code
3957 gimple_omp_for_cond (const_gimple gs, size_t i)
3959 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3960 gcc_assert (i < gs->gimple_omp_for.collapse);
3961 return gs->gimple_omp_for.iter[i].cond;
3965 /* Set the value being stored in an atomic store. */
3967 static inline void
3968 gimple_omp_atomic_store_set_val (gimple g, tree val)
3970 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3971 g->gimple_omp_atomic_store.val = val;
3975 /* Return the value being stored in an atomic store. */
3977 static inline tree
3978 gimple_omp_atomic_store_val (const_gimple g)
3980 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3981 return g->gimple_omp_atomic_store.val;
3985 /* Return a pointer to the value being stored in an atomic store. */
3987 static inline tree *
3988 gimple_omp_atomic_store_val_ptr (gimple g)
3990 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3991 return &g->gimple_omp_atomic_store.val;
3995 /* Set the LHS of an atomic load. */
3997 static inline void
3998 gimple_omp_atomic_load_set_lhs (gimple g, tree lhs)
4000 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4001 g->gimple_omp_atomic_load.lhs = lhs;
4005 /* Get the LHS of an atomic load. */
4007 static inline tree
4008 gimple_omp_atomic_load_lhs (const_gimple g)
4010 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4011 return g->gimple_omp_atomic_load.lhs;
4015 /* Return a pointer to the LHS of an atomic load. */
4017 static inline tree *
4018 gimple_omp_atomic_load_lhs_ptr (gimple g)
4020 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4021 return &g->gimple_omp_atomic_load.lhs;
4025 /* Set the RHS of an atomic load. */
4027 static inline void
4028 gimple_omp_atomic_load_set_rhs (gimple g, tree rhs)
4030 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4031 g->gimple_omp_atomic_load.rhs = rhs;
4035 /* Get the RHS of an atomic load. */
4037 static inline tree
4038 gimple_omp_atomic_load_rhs (const_gimple g)
4040 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4041 return g->gimple_omp_atomic_load.rhs;
4045 /* Return a pointer to the RHS of an atomic load. */
4047 static inline tree *
4048 gimple_omp_atomic_load_rhs_ptr (gimple g)
4050 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4051 return &g->gimple_omp_atomic_load.rhs;
4055 /* Get the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4057 static inline tree
4058 gimple_omp_continue_control_def (const_gimple g)
4060 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4061 return g->gimple_omp_continue.control_def;
4064 /* The same as above, but return the address. */
4066 static inline tree *
4067 gimple_omp_continue_control_def_ptr (gimple g)
4069 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4070 return &g->gimple_omp_continue.control_def;
4073 /* Set the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4075 static inline void
4076 gimple_omp_continue_set_control_def (gimple g, tree def)
4078 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4079 g->gimple_omp_continue.control_def = def;
4083 /* Get the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4085 static inline tree
4086 gimple_omp_continue_control_use (const_gimple g)
4088 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4089 return g->gimple_omp_continue.control_use;
4093 /* The same as above, but return the address. */
4095 static inline tree *
4096 gimple_omp_continue_control_use_ptr (gimple g)
4098 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4099 return &g->gimple_omp_continue.control_use;
4103 /* Set the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4105 static inline void
4106 gimple_omp_continue_set_control_use (gimple g, tree use)
4108 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4109 g->gimple_omp_continue.control_use = use;
4113 /* Return a pointer to the return value for GIMPLE_RETURN GS. */
4115 static inline tree *
4116 gimple_return_retval_ptr (const_gimple gs)
4118 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4119 gcc_assert (gimple_num_ops (gs) == 1);
4120 return gimple_op_ptr (gs, 0);
4123 /* Return the return value for GIMPLE_RETURN GS. */
4125 static inline tree
4126 gimple_return_retval (const_gimple gs)
4128 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4129 gcc_assert (gimple_num_ops (gs) == 1);
4130 return gimple_op (gs, 0);
4134 /* Set RETVAL to be the return value for GIMPLE_RETURN GS. */
4136 static inline void
4137 gimple_return_set_retval (gimple gs, tree retval)
4139 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4140 gcc_assert (gimple_num_ops (gs) == 1);
4141 gcc_assert (retval == NULL_TREE
4142 || TREE_CODE (retval) == RESULT_DECL
4143 || is_gimple_val (retval));
4144 gimple_set_op (gs, 0, retval);
4148 /* Returns true when the gimple statment STMT is any of the OpenMP types. */
4150 static inline bool
4151 is_gimple_omp (const_gimple stmt)
4153 return (gimple_code (stmt) == GIMPLE_OMP_PARALLEL
4154 || gimple_code (stmt) == GIMPLE_OMP_TASK
4155 || gimple_code (stmt) == GIMPLE_OMP_FOR
4156 || gimple_code (stmt) == GIMPLE_OMP_SECTIONS
4157 || gimple_code (stmt) == GIMPLE_OMP_SECTIONS_SWITCH
4158 || gimple_code (stmt) == GIMPLE_OMP_SINGLE
4159 || gimple_code (stmt) == GIMPLE_OMP_SECTION
4160 || gimple_code (stmt) == GIMPLE_OMP_MASTER
4161 || gimple_code (stmt) == GIMPLE_OMP_ORDERED
4162 || gimple_code (stmt) == GIMPLE_OMP_CRITICAL
4163 || gimple_code (stmt) == GIMPLE_OMP_RETURN
4164 || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_LOAD
4165 || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_STORE
4166 || gimple_code (stmt) == GIMPLE_OMP_CONTINUE);
4170 /* Returns TRUE if statement G is a GIMPLE_NOP. */
4172 static inline bool
4173 gimple_nop_p (const_gimple g)
4175 return gimple_code (g) == GIMPLE_NOP;
4179 /* Return the new type set by GIMPLE_CHANGE_DYNAMIC_TYPE statement GS. */
4181 static inline tree
4182 gimple_cdt_new_type (gimple gs)
4184 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4185 return gimple_op (gs, 1);
4188 /* Return a pointer to the new type set by GIMPLE_CHANGE_DYNAMIC_TYPE
4189 statement GS. */
4191 static inline tree *
4192 gimple_cdt_new_type_ptr (gimple gs)
4194 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4195 return gimple_op_ptr (gs, 1);
4198 /* Set NEW_TYPE to be the type returned by GIMPLE_CHANGE_DYNAMIC_TYPE
4199 statement GS. */
4201 static inline void
4202 gimple_cdt_set_new_type (gimple gs, tree new_type)
4204 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4205 gcc_assert (TREE_CODE_CLASS (TREE_CODE (new_type)) == tcc_type);
4206 gimple_set_op (gs, 1, new_type);
4210 /* Return the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE statement GS. */
4212 static inline tree
4213 gimple_cdt_location (gimple gs)
4215 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4216 return gimple_op (gs, 0);
4220 /* Return a pointer to the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE
4221 statement GS. */
4223 static inline tree *
4224 gimple_cdt_location_ptr (gimple gs)
4226 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4227 return gimple_op_ptr (gs, 0);
4231 /* Set PTR to be the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE
4232 statement GS. */
4234 static inline void
4235 gimple_cdt_set_location (gimple gs, tree ptr)
4237 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4238 gimple_set_op (gs, 0, ptr);
4242 /* Return the predictor of GIMPLE_PREDICT statement GS. */
4244 static inline enum br_predictor
4245 gimple_predict_predictor (gimple gs)
4247 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4248 return (enum br_predictor) (gs->gsbase.subcode & ~GF_PREDICT_TAKEN);
4252 /* Set the predictor of GIMPLE_PREDICT statement GS to PREDICT. */
4254 static inline void
4255 gimple_predict_set_predictor (gimple gs, enum br_predictor predictor)
4257 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4258 gs->gsbase.subcode = (gs->gsbase.subcode & GF_PREDICT_TAKEN)
4259 | (unsigned) predictor;
4263 /* Return the outcome of GIMPLE_PREDICT statement GS. */
4265 static inline enum prediction
4266 gimple_predict_outcome (gimple gs)
4268 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4269 return (gs->gsbase.subcode & GF_PREDICT_TAKEN) ? TAKEN : NOT_TAKEN;
4273 /* Set the outcome of GIMPLE_PREDICT statement GS to OUTCOME. */
4275 static inline void
4276 gimple_predict_set_outcome (gimple gs, enum prediction outcome)
4278 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4279 if (outcome == TAKEN)
4280 gs->gsbase.subcode |= GF_PREDICT_TAKEN;
4281 else
4282 gs->gsbase.subcode &= ~GF_PREDICT_TAKEN;
4286 /* Return a new iterator pointing to GIMPLE_SEQ's first statement. */
4288 static inline gimple_stmt_iterator
4289 gsi_start (gimple_seq seq)
4291 gimple_stmt_iterator i;
4293 i.ptr = gimple_seq_first (seq);
4294 i.seq = seq;
4295 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4297 return i;
4301 /* Return a new iterator pointing to the first statement in basic block BB. */
4303 static inline gimple_stmt_iterator
4304 gsi_start_bb (basic_block bb)
4306 gimple_stmt_iterator i;
4307 gimple_seq seq;
4309 seq = bb_seq (bb);
4310 i.ptr = gimple_seq_first (seq);
4311 i.seq = seq;
4312 i.bb = bb;
4314 return i;
4318 /* Return a new iterator initially pointing to GIMPLE_SEQ's last statement. */
4320 static inline gimple_stmt_iterator
4321 gsi_last (gimple_seq seq)
4323 gimple_stmt_iterator i;
4325 i.ptr = gimple_seq_last (seq);
4326 i.seq = seq;
4327 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4329 return i;
4333 /* Return a new iterator pointing to the last statement in basic block BB. */
4335 static inline gimple_stmt_iterator
4336 gsi_last_bb (basic_block bb)
4338 gimple_stmt_iterator i;
4339 gimple_seq seq;
4341 seq = bb_seq (bb);
4342 i.ptr = gimple_seq_last (seq);
4343 i.seq = seq;
4344 i.bb = bb;
4346 return i;
4350 /* Return true if I is at the end of its sequence. */
4352 static inline bool
4353 gsi_end_p (gimple_stmt_iterator i)
4355 return i.ptr == NULL;
4359 /* Return true if I is one statement before the end of its sequence. */
4361 static inline bool
4362 gsi_one_before_end_p (gimple_stmt_iterator i)
4364 return i.ptr != NULL && i.ptr->next == NULL;
4368 /* Advance the iterator to the next gimple statement. */
4370 static inline void
4371 gsi_next (gimple_stmt_iterator *i)
4373 i->ptr = i->ptr->next;
4376 /* Advance the iterator to the previous gimple statement. */
4378 static inline void
4379 gsi_prev (gimple_stmt_iterator *i)
4381 i->ptr = i->ptr->prev;
4384 /* Return the current stmt. */
4386 static inline gimple
4387 gsi_stmt (gimple_stmt_iterator i)
4389 return i.ptr->stmt;
4392 /* Return a block statement iterator that points to the first non-label
4393 statement in block BB. */
4395 static inline gimple_stmt_iterator
4396 gsi_after_labels (basic_block bb)
4398 gimple_stmt_iterator gsi = gsi_start_bb (bb);
4400 while (!gsi_end_p (gsi) && gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL)
4401 gsi_next (&gsi);
4403 return gsi;
4406 /* Return a pointer to the current stmt.
4408 NOTE: You may want to use gsi_replace on the iterator itself,
4409 as this performs additional bookkeeping that will not be done
4410 if you simply assign through a pointer returned by gsi_stmt_ptr. */
4412 static inline gimple *
4413 gsi_stmt_ptr (gimple_stmt_iterator *i)
4415 return &i->ptr->stmt;
4419 /* Return the basic block associated with this iterator. */
4421 static inline basic_block
4422 gsi_bb (gimple_stmt_iterator i)
4424 return i.bb;
4428 /* Return the sequence associated with this iterator. */
4430 static inline gimple_seq
4431 gsi_seq (gimple_stmt_iterator i)
4433 return i.seq;
4437 enum gsi_iterator_update
4439 GSI_NEW_STMT, /* Only valid when single statement is added, move
4440 iterator to it. */
4441 GSI_SAME_STMT, /* Leave the iterator at the same statement. */
4442 GSI_CONTINUE_LINKING /* Move iterator to whatever position is suitable
4443 for linking other statements in the same
4444 direction. */
4447 /* In gimple-iterator.c */
4448 gimple_stmt_iterator gsi_start_phis (basic_block);
4449 gimple_seq gsi_split_seq_after (gimple_stmt_iterator);
4450 gimple_seq gsi_split_seq_before (gimple_stmt_iterator *);
4451 void gsi_replace (gimple_stmt_iterator *, gimple, bool);
4452 void gsi_insert_before (gimple_stmt_iterator *, gimple,
4453 enum gsi_iterator_update);
4454 void gsi_insert_before_without_update (gimple_stmt_iterator *, gimple,
4455 enum gsi_iterator_update);
4456 void gsi_insert_seq_before (gimple_stmt_iterator *, gimple_seq,
4457 enum gsi_iterator_update);
4458 void gsi_insert_seq_before_without_update (gimple_stmt_iterator *, gimple_seq,
4459 enum gsi_iterator_update);
4460 void gsi_insert_after (gimple_stmt_iterator *, gimple,
4461 enum gsi_iterator_update);
4462 void gsi_insert_after_without_update (gimple_stmt_iterator *, gimple,
4463 enum gsi_iterator_update);
4464 void gsi_insert_seq_after (gimple_stmt_iterator *, gimple_seq,
4465 enum gsi_iterator_update);
4466 void gsi_insert_seq_after_without_update (gimple_stmt_iterator *, gimple_seq,
4467 enum gsi_iterator_update);
4468 void gsi_remove (gimple_stmt_iterator *, bool);
4469 gimple_stmt_iterator gsi_for_stmt (gimple);
4470 void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *);
4471 void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *);
4472 void gsi_move_to_bb_end (gimple_stmt_iterator *, struct basic_block_def *);
4473 void gsi_insert_on_edge (edge, gimple);
4474 void gsi_insert_seq_on_edge (edge, gimple_seq);
4475 basic_block gsi_insert_on_edge_immediate (edge, gimple);
4476 basic_block gsi_insert_seq_on_edge_immediate (edge, gimple_seq);
4477 void gsi_commit_one_edge_insert (edge, basic_block *);
4478 void gsi_commit_edge_inserts (void);
4479 gimple gimple_call_copy_skip_args (gimple, bitmap);
4482 /* Convenience routines to walk all statements of a gimple function.
4483 Note that this is useful exclusively before the code is converted
4484 into SSA form. Once the program is in SSA form, the standard
4485 operand interface should be used to analyze/modify statements. */
4486 struct walk_stmt_info
4488 /* Points to the current statement being walked. */
4489 gimple_stmt_iterator gsi;
4491 /* Additional data that the callback functions may want to carry
4492 through the recursion. */
4493 void *info;
4495 /* Pointer map used to mark visited tree nodes when calling
4496 walk_tree on each operand. If set to NULL, duplicate tree nodes
4497 will be visited more than once. */
4498 struct pointer_set_t *pset;
4500 /* Indicates whether the operand being examined may be replaced
4501 with something that matches is_gimple_val (if true) or something
4502 slightly more complicated (if false). "Something" technically
4503 means the common subset of is_gimple_lvalue and is_gimple_rhs,
4504 but we never try to form anything more complicated than that, so
4505 we don't bother checking.
4507 Also note that CALLBACK should update this flag while walking the
4508 sub-expressions of a statement. For instance, when walking the
4509 statement 'foo (&var)', the flag VAL_ONLY will initially be set
4510 to true, however, when walking &var, the operand of that
4511 ADDR_EXPR does not need to be a GIMPLE value. */
4512 bool val_only;
4514 /* True if we are currently walking the LHS of an assignment. */
4515 bool is_lhs;
4517 /* Optional. Set to true by the callback functions if they made any
4518 changes. */
4519 bool changed;
4521 /* True if we're interested in location information. */
4522 bool want_locations;
4524 /* Operand returned by the callbacks. This is set when calling
4525 walk_gimple_seq. If the walk_stmt_fn or walk_tree_fn callback
4526 returns non-NULL, this field will contain the tree returned by
4527 the last callback. */
4528 tree callback_result;
4531 /* Callback for walk_gimple_stmt. Called for every statement found
4532 during traversal. The first argument points to the statement to
4533 walk. The second argument is a flag that the callback sets to
4534 'true' if it the callback handled all the operands and
4535 sub-statements of the statement (the default value of this flag is
4536 'false'). The third argument is an anonymous pointer to data
4537 to be used by the callback. */
4538 typedef tree (*walk_stmt_fn) (gimple_stmt_iterator *, bool *,
4539 struct walk_stmt_info *);
4541 gimple walk_gimple_seq (gimple_seq, walk_stmt_fn, walk_tree_fn,
4542 struct walk_stmt_info *);
4543 tree walk_gimple_stmt (gimple_stmt_iterator *, walk_stmt_fn, walk_tree_fn,
4544 struct walk_stmt_info *);
4545 tree walk_gimple_op (gimple, walk_tree_fn, struct walk_stmt_info *);
4547 #ifdef GATHER_STATISTICS
4548 /* Enum and arrays used for allocation stats. Keep in sync with
4549 gimple.c:gimple_alloc_kind_names. */
4550 enum gimple_alloc_kind
4552 gimple_alloc_kind_assign, /* Assignments. */
4553 gimple_alloc_kind_phi, /* PHI nodes. */
4554 gimple_alloc_kind_cond, /* Conditionals. */
4555 gimple_alloc_kind_seq, /* Sequences. */
4556 gimple_alloc_kind_rest, /* Everything else. */
4557 gimple_alloc_kind_all
4560 extern int gimple_alloc_counts[];
4561 extern int gimple_alloc_sizes[];
4563 /* Return the allocation kind for a given stmt CODE. */
4564 static inline enum gimple_alloc_kind
4565 gimple_alloc_kind (enum gimple_code code)
4567 switch (code)
4569 case GIMPLE_ASSIGN:
4570 return gimple_alloc_kind_assign;
4571 case GIMPLE_PHI:
4572 return gimple_alloc_kind_phi;
4573 case GIMPLE_COND:
4574 return gimple_alloc_kind_cond;
4575 default:
4576 return gimple_alloc_kind_rest;
4579 #endif /* GATHER_STATISTICS */
4581 extern void dump_gimple_statistics (void);
4583 #endif /* GCC_GIMPLE_H */