* config.gcc (cygwin tm_file): Add cygwin-stdint.h.
[official-gcc.git] / gcc / gimple.h
blobdde7f942e16451bf8a6770a84c824891020df2a7
1 /* Gimple IR definitions.
3 Copyright 2007, 2008, 2009 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 typedef gimple *gimple_p;
38 DEF_VEC_P(gimple_p);
39 DEF_VEC_ALLOC_P(gimple_p,heap);
41 DEF_VEC_P(gimple_seq);
42 DEF_VEC_ALLOC_P(gimple_seq,gc);
43 DEF_VEC_ALLOC_P(gimple_seq,heap);
45 /* For each block, the PHI nodes that need to be rewritten are stored into
46 these vectors. */
47 typedef VEC(gimple, heap) *gimple_vec;
48 DEF_VEC_P (gimple_vec);
49 DEF_VEC_ALLOC_P (gimple_vec, heap);
51 enum gimple_code {
52 #define DEFGSCODE(SYM, STRING, STRUCT) SYM,
53 #include "gimple.def"
54 #undef DEFGSCODE
55 LAST_AND_UNUSED_GIMPLE_CODE
58 extern const char *const gimple_code_name[];
59 extern const unsigned char gimple_rhs_class_table[];
61 /* Error out if a gimple tuple is addressed incorrectly. */
62 #if defined ENABLE_GIMPLE_CHECKING
63 extern void gimple_check_failed (const_gimple, const char *, int, \
64 const char *, enum gimple_code, \
65 enum tree_code) ATTRIBUTE_NORETURN;
67 #define GIMPLE_CHECK(GS, CODE) \
68 do { \
69 const_gimple __gs = (GS); \
70 if (gimple_code (__gs) != (CODE)) \
71 gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__, \
72 (CODE), 0); \
73 } while (0)
74 #else /* not ENABLE_GIMPLE_CHECKING */
75 #define GIMPLE_CHECK(GS, CODE) (void)0
76 #endif
78 /* Class of GIMPLE expressions suitable for the RHS of assignments. See
79 get_gimple_rhs_class. */
80 enum gimple_rhs_class
82 GIMPLE_INVALID_RHS, /* The expression cannot be used on the RHS. */
83 GIMPLE_BINARY_RHS, /* The expression is a binary operation. */
84 GIMPLE_UNARY_RHS, /* The expression is a unary operation. */
85 GIMPLE_SINGLE_RHS /* The expression is a single object (an SSA
86 name, a _DECL, a _REF, etc. */
89 /* Specific flags for individual GIMPLE statements. These flags are
90 always stored in gimple_statement_base.subcode and they may only be
91 defined for statement codes that do not use sub-codes.
93 Values for the masks can overlap as long as the overlapping values
94 are never used in the same statement class.
96 The maximum mask value that can be defined is 1 << 15 (i.e., each
97 statement code can hold up to 16 bitflags).
99 Keep this list sorted. */
100 enum gf_mask {
101 GF_ASM_INPUT = 1 << 0,
102 GF_ASM_VOLATILE = 1 << 1,
103 GF_CALL_CANNOT_INLINE = 1 << 0,
104 GF_CALL_FROM_THUNK = 1 << 1,
105 GF_CALL_RETURN_SLOT_OPT = 1 << 2,
106 GF_CALL_TAILCALL = 1 << 3,
107 GF_CALL_VA_ARG_PACK = 1 << 4,
108 GF_OMP_PARALLEL_COMBINED = 1 << 0,
110 /* True on an GIMPLE_OMP_RETURN statement if the return does not require
111 a thread synchronization via some sort of barrier. The exact barrier
112 that would otherwise be emitted is dependent on the OMP statement with
113 which this return is associated. */
114 GF_OMP_RETURN_NOWAIT = 1 << 0,
116 GF_OMP_SECTION_LAST = 1 << 0,
117 GF_PREDICT_TAKEN = 1 << 15
120 /* Masks for selecting a pass local flag (PLF) to work on. These
121 masks are used by gimple_set_plf and gimple_plf. */
122 enum plf_mask {
123 GF_PLF_1 = 1 << 0,
124 GF_PLF_2 = 1 << 1
127 /* A node in a gimple_seq_d. */
128 struct gimple_seq_node_d GTY((chain_next ("%h.next"), chain_prev ("%h.prev")))
130 gimple stmt;
131 struct gimple_seq_node_d *prev;
132 struct gimple_seq_node_d *next;
135 /* A double-linked sequence of gimple statements. */
136 struct gimple_seq_d GTY ((chain_next ("%h.next_free")))
138 /* First and last statements in the sequence. */
139 gimple_seq_node first;
140 gimple_seq_node last;
142 /* Sequences are created/destroyed frequently. To minimize
143 allocation activity, deallocated sequences are kept in a pool of
144 available sequences. This is the pointer to the next free
145 sequence in the pool. */
146 gimple_seq next_free;
150 /* Return the first node in GIMPLE sequence S. */
152 static inline gimple_seq_node
153 gimple_seq_first (const_gimple_seq s)
155 return s ? s->first : NULL;
159 /* Return the first statement in GIMPLE sequence S. */
161 static inline gimple
162 gimple_seq_first_stmt (const_gimple_seq s)
164 gimple_seq_node n = gimple_seq_first (s);
165 return (n) ? n->stmt : NULL;
169 /* Return the last node in GIMPLE sequence S. */
171 static inline gimple_seq_node
172 gimple_seq_last (const_gimple_seq s)
174 return s ? s->last : NULL;
178 /* Return the last statement in GIMPLE sequence S. */
180 static inline gimple
181 gimple_seq_last_stmt (const_gimple_seq s)
183 gimple_seq_node n = gimple_seq_last (s);
184 return (n) ? n->stmt : NULL;
188 /* Set the last node in GIMPLE sequence S to LAST. */
190 static inline void
191 gimple_seq_set_last (gimple_seq s, gimple_seq_node last)
193 s->last = last;
197 /* Set the first node in GIMPLE sequence S to FIRST. */
199 static inline void
200 gimple_seq_set_first (gimple_seq s, gimple_seq_node first)
202 s->first = first;
206 /* Return true if GIMPLE sequence S is empty. */
208 static inline bool
209 gimple_seq_empty_p (const_gimple_seq s)
211 return s == NULL || s->first == NULL;
215 void gimple_seq_add_stmt (gimple_seq *, gimple);
217 /* Allocate a new sequence and initialize its first element with STMT. */
219 static inline gimple_seq
220 gimple_seq_alloc_with_stmt (gimple stmt)
222 gimple_seq seq = NULL;
223 gimple_seq_add_stmt (&seq, stmt);
224 return seq;
228 /* Returns the sequence of statements in BB. */
230 static inline gimple_seq
231 bb_seq (const_basic_block bb)
233 return (!(bb->flags & BB_RTL) && bb->il.gimple) ? bb->il.gimple->seq : NULL;
237 /* Sets the sequence of statements in BB to SEQ. */
239 static inline void
240 set_bb_seq (basic_block bb, gimple_seq seq)
242 gcc_assert (!(bb->flags & BB_RTL));
243 bb->il.gimple->seq = seq;
246 /* Iterator object for GIMPLE statement sequences. */
248 typedef struct
250 /* Sequence node holding the current statement. */
251 gimple_seq_node ptr;
253 /* Sequence and basic block holding the statement. These fields
254 are necessary to handle edge cases such as when statement is
255 added to an empty basic block or when the last statement of a
256 block/sequence is removed. */
257 gimple_seq seq;
258 basic_block bb;
259 } gimple_stmt_iterator;
262 /* Data structure definitions for GIMPLE tuples. NOTE: word markers
263 are for 64 bit hosts. */
265 struct gimple_statement_base GTY(())
267 /* [ WORD 1 ]
268 Main identifying code for a tuple. */
269 ENUM_BITFIELD(gimple_code) code : 8;
271 /* Nonzero if a warning should not be emitted on this tuple. */
272 unsigned int no_warning : 1;
274 /* Nonzero if this tuple has been visited. Passes are responsible
275 for clearing this bit before using it. */
276 unsigned int visited : 1;
278 /* Nonzero if this tuple represents a non-temporal move. */
279 unsigned int nontemporal_move : 1;
281 /* Pass local flags. These flags are free for any pass to use as
282 they see fit. Passes should not assume that these flags contain
283 any useful value when the pass starts. Any initial state that
284 the pass requires should be set on entry to the pass. See
285 gimple_set_plf and gimple_plf for usage. */
286 unsigned int plf : 2;
288 /* Nonzero if this statement has been modified and needs to have its
289 operands rescanned. */
290 unsigned modified : 1;
292 /* Nonzero if this statement contains volatile operands. */
293 unsigned has_volatile_ops : 1;
295 /* Padding to get subcode to 16 bit alignment. */
296 unsigned pad : 1;
298 /* The SUBCODE field can be used for tuple-specific flags for tuples
299 that do not require subcodes. Note that SUBCODE should be at
300 least as wide as tree codes, as several tuples store tree codes
301 in there. */
302 unsigned int subcode : 16;
304 /* UID of this statement. This is used by passes that want to
305 assign IDs to statements. It must be assigned and used by each
306 pass. By default it should be assumed to contain garbage. */
307 unsigned uid;
309 /* [ WORD 2 ]
310 Locus information for debug info. */
311 location_t location;
313 /* Number of operands in this tuple. */
314 unsigned num_ops;
316 /* [ WORD 3 ]
317 Basic block holding this statement. */
318 struct basic_block_def *bb;
320 /* [ WORD 4 ]
321 Lexical block holding this statement. */
322 tree block;
326 /* Base structure for tuples with operands. */
328 struct gimple_statement_with_ops_base GTY(())
330 /* [ WORD 1-4 ] */
331 struct gimple_statement_base gsbase;
333 /* [ WORD 5 ]
334 Symbols whose addresses are taken by this statement (i.e., they
335 appear inside ADDR_EXPR nodes). */
336 bitmap GTY((skip (""))) addresses_taken;
338 /* [ WORD 6-7 ]
339 SSA operand vectors. NOTE: It should be possible to
340 amalgamate these vectors with the operand vector OP. However,
341 the SSA operand vectors are organized differently and contain
342 more information (like immediate use chaining). */
343 struct def_optype_d GTY((skip (""))) *def_ops;
344 struct use_optype_d GTY((skip (""))) *use_ops;
348 /* Statements that take register operands. */
350 struct gimple_statement_with_ops GTY(())
352 /* [ WORD 1-7 ] */
353 struct gimple_statement_with_ops_base opbase;
355 /* [ WORD 8 ]
356 Operand vector. NOTE! This must always be the last field
357 of this structure. In particular, this means that this
358 structure cannot be embedded inside another one. */
359 tree GTY((length ("%h.opbase.gsbase.num_ops"))) op[1];
363 /* Base for statements that take both memory and register operands. */
365 struct gimple_statement_with_memory_ops_base GTY(())
367 /* [ WORD 1-7 ] */
368 struct gimple_statement_with_ops_base opbase;
370 /* [ WORD 8-9 ]
371 Virtual operands for this statement. The GC will pick them
372 up via the ssa_names array. */
373 tree GTY((skip (""))) vdef;
374 tree GTY((skip (""))) vuse;
378 /* Statements that take both memory and register operands. */
380 struct gimple_statement_with_memory_ops GTY(())
382 /* [ WORD 1-9 ] */
383 struct gimple_statement_with_memory_ops_base membase;
385 /* [ WORD 10 ]
386 Operand vector. NOTE! This must always be the last field
387 of this structure. In particular, this means that this
388 structure cannot be embedded inside another one. */
389 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
393 /* OpenMP statements (#pragma omp). */
395 struct gimple_statement_omp GTY(())
397 /* [ WORD 1-4 ] */
398 struct gimple_statement_base gsbase;
400 /* [ WORD 5 ] */
401 gimple_seq body;
405 /* GIMPLE_BIND */
407 struct gimple_statement_bind GTY(())
409 /* [ WORD 1-4 ] */
410 struct gimple_statement_base gsbase;
412 /* [ WORD 5 ]
413 Variables declared in this scope. */
414 tree vars;
416 /* [ WORD 6 ]
417 This is different than the BLOCK field in gimple_statement_base,
418 which is analogous to TREE_BLOCK (i.e., the lexical block holding
419 this statement). This field is the equivalent of BIND_EXPR_BLOCK
420 in tree land (i.e., the lexical scope defined by this bind). See
421 gimple-low.c. */
422 tree block;
424 /* [ WORD 7 ] */
425 gimple_seq body;
429 /* GIMPLE_CATCH */
431 struct gimple_statement_catch GTY(())
433 /* [ WORD 1-4 ] */
434 struct gimple_statement_base gsbase;
436 /* [ WORD 5 ] */
437 tree types;
439 /* [ WORD 6 ] */
440 gimple_seq handler;
444 /* GIMPLE_EH_FILTER */
446 struct gimple_statement_eh_filter GTY(())
448 /* [ WORD 1-4 ] */
449 struct gimple_statement_base gsbase;
451 /* Subcode: EH_FILTER_MUST_NOT_THROW. A boolean flag analogous to
452 the tree counterpart. */
454 /* [ WORD 5 ]
455 Filter types. */
456 tree types;
458 /* [ WORD 6 ]
459 Failure actions. */
460 gimple_seq failure;
464 /* GIMPLE_PHI */
466 struct gimple_statement_phi GTY(())
468 /* [ WORD 1-4 ] */
469 struct gimple_statement_base gsbase;
471 /* [ WORD 5 ] */
472 unsigned capacity;
473 unsigned nargs;
475 /* [ WORD 6 ] */
476 tree result;
478 /* [ WORD 7 ] */
479 struct phi_arg_d GTY ((length ("%h.nargs"))) args[1];
483 /* GIMPLE_RESX */
485 struct gimple_statement_resx GTY(())
487 /* [ WORD 1-4 ] */
488 struct gimple_statement_base gsbase;
490 /* [ WORD 5 ]
491 Exception region number. */
492 int region;
496 /* GIMPLE_TRY */
498 struct gimple_statement_try GTY(())
500 /* [ WORD 1-4 ] */
501 struct gimple_statement_base gsbase;
503 /* [ WORD 5 ]
504 Expression to evaluate. */
505 gimple_seq eval;
507 /* [ WORD 6 ]
508 Cleanup expression. */
509 gimple_seq cleanup;
512 /* Kind of GIMPLE_TRY statements. */
513 enum gimple_try_flags
515 /* A try/catch. */
516 GIMPLE_TRY_CATCH = 1 << 0,
518 /* A try/finally. */
519 GIMPLE_TRY_FINALLY = 1 << 1,
520 GIMPLE_TRY_KIND = GIMPLE_TRY_CATCH | GIMPLE_TRY_FINALLY,
522 /* Analogous to TRY_CATCH_IS_CLEANUP. */
523 GIMPLE_TRY_CATCH_IS_CLEANUP = 1 << 2
526 /* GIMPLE_WITH_CLEANUP_EXPR */
528 struct gimple_statement_wce GTY(())
530 /* [ WORD 1-4 ] */
531 struct gimple_statement_base gsbase;
533 /* Subcode: CLEANUP_EH_ONLY. True if the cleanup should only be
534 executed if an exception is thrown, not on normal exit of its
535 scope. This flag is analogous to the CLEANUP_EH_ONLY flag
536 in TARGET_EXPRs. */
538 /* [ WORD 5 ]
539 Cleanup expression. */
540 gimple_seq cleanup;
544 /* GIMPLE_ASM */
546 struct gimple_statement_asm GTY(())
548 /* [ WORD 1-9 ] */
549 struct gimple_statement_with_memory_ops_base membase;
551 /* [ WORD 10 ]
552 __asm__ statement. */
553 const char *string;
555 /* [ WORD 11 ]
556 Number of inputs, outputs and clobbers. */
557 unsigned char ni;
558 unsigned char no;
559 unsigned short nc;
561 /* [ WORD 12 ]
562 Operand vector. NOTE! This must always be the last field
563 of this structure. In particular, this means that this
564 structure cannot be embedded inside another one. */
565 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
568 /* GIMPLE_OMP_CRITICAL */
570 struct gimple_statement_omp_critical GTY(())
572 /* [ WORD 1-5 ] */
573 struct gimple_statement_omp omp;
575 /* [ WORD 6 ]
576 Critical section name. */
577 tree name;
581 struct gimple_omp_for_iter GTY(())
583 /* Condition code. */
584 enum tree_code cond;
586 /* Index variable. */
587 tree index;
589 /* Initial value. */
590 tree initial;
592 /* Final value. */
593 tree final;
595 /* Increment. */
596 tree incr;
599 /* GIMPLE_OMP_FOR */
601 struct gimple_statement_omp_for GTY(())
603 /* [ WORD 1-5 ] */
604 struct gimple_statement_omp omp;
606 /* [ WORD 6 ] */
607 tree clauses;
609 /* [ WORD 7 ]
610 Number of elements in iter array. */
611 size_t collapse;
613 /* [ WORD 8 ] */
614 struct gimple_omp_for_iter * GTY((length ("%h.collapse"))) iter;
616 /* [ WORD 9 ]
617 Pre-body evaluated before the loop body begins. */
618 gimple_seq pre_body;
622 /* GIMPLE_OMP_PARALLEL */
624 struct gimple_statement_omp_parallel GTY(())
626 /* [ WORD 1-5 ] */
627 struct gimple_statement_omp omp;
629 /* [ WORD 6 ]
630 Clauses. */
631 tree clauses;
633 /* [ WORD 7 ]
634 Child function holding the body of the parallel region. */
635 tree child_fn;
637 /* [ WORD 8 ]
638 Shared data argument. */
639 tree data_arg;
643 /* GIMPLE_OMP_TASK */
645 struct gimple_statement_omp_task GTY(())
647 /* [ WORD 1-8 ] */
648 struct gimple_statement_omp_parallel par;
650 /* [ WORD 9 ]
651 Child function holding firstprivate initialization if needed. */
652 tree copy_fn;
654 /* [ WORD 10-11 ]
655 Size and alignment in bytes of the argument data block. */
656 tree arg_size;
657 tree arg_align;
661 /* GIMPLE_OMP_SECTION */
662 /* Uses struct gimple_statement_omp. */
665 /* GIMPLE_OMP_SECTIONS */
667 struct gimple_statement_omp_sections GTY(())
669 /* [ WORD 1-5 ] */
670 struct gimple_statement_omp omp;
672 /* [ WORD 6 ] */
673 tree clauses;
675 /* [ WORD 7 ]
676 The control variable used for deciding which of the sections to
677 execute. */
678 tree control;
681 /* GIMPLE_OMP_CONTINUE.
683 Note: This does not inherit from gimple_statement_omp, because we
684 do not need the body field. */
686 struct gimple_statement_omp_continue GTY(())
688 /* [ WORD 1-4 ] */
689 struct gimple_statement_base gsbase;
691 /* [ WORD 5 ] */
692 tree control_def;
694 /* [ WORD 6 ] */
695 tree control_use;
698 /* GIMPLE_OMP_SINGLE */
700 struct gimple_statement_omp_single GTY(())
702 /* [ WORD 1-5 ] */
703 struct gimple_statement_omp omp;
705 /* [ WORD 6 ] */
706 tree clauses;
710 /* GIMPLE_OMP_ATOMIC_LOAD.
711 Note: This is based on gimple_statement_base, not g_s_omp, because g_s_omp
712 contains a sequence, which we don't need here. */
714 struct gimple_statement_omp_atomic_load GTY(())
716 /* [ WORD 1-4 ] */
717 struct gimple_statement_base gsbase;
719 /* [ WORD 5-6 ] */
720 tree rhs, lhs;
723 /* GIMPLE_OMP_ATOMIC_STORE.
724 See note on GIMPLE_OMP_ATOMIC_LOAD. */
726 struct gimple_statement_omp_atomic_store GTY(())
728 /* [ WORD 1-4 ] */
729 struct gimple_statement_base gsbase;
731 /* [ WORD 5 ] */
732 tree val;
735 enum gimple_statement_structure_enum {
736 #define DEFGSSTRUCT(SYM, STRING) SYM,
737 #include "gsstruct.def"
738 #undef DEFGSSTRUCT
739 LAST_GSS_ENUM
743 /* Define the overall contents of a gimple tuple. It may be any of the
744 structures declared above for various types of tuples. */
746 union gimple_statement_d GTY ((desc ("gimple_statement_structure (&%h)")))
748 struct gimple_statement_base GTY ((tag ("GSS_BASE"))) gsbase;
749 struct gimple_statement_with_ops GTY ((tag ("GSS_WITH_OPS"))) gsops;
750 struct gimple_statement_with_memory_ops GTY ((tag ("GSS_WITH_MEM_OPS"))) gsmem;
751 struct gimple_statement_omp GTY ((tag ("GSS_OMP"))) omp;
752 struct gimple_statement_bind GTY ((tag ("GSS_BIND"))) gimple_bind;
753 struct gimple_statement_catch GTY ((tag ("GSS_CATCH"))) gimple_catch;
754 struct gimple_statement_eh_filter GTY ((tag ("GSS_EH_FILTER"))) gimple_eh_filter;
755 struct gimple_statement_phi GTY ((tag ("GSS_PHI"))) gimple_phi;
756 struct gimple_statement_resx GTY ((tag ("GSS_RESX"))) gimple_resx;
757 struct gimple_statement_try GTY ((tag ("GSS_TRY"))) gimple_try;
758 struct gimple_statement_wce GTY ((tag ("GSS_WCE"))) gimple_wce;
759 struct gimple_statement_asm GTY ((tag ("GSS_ASM"))) gimple_asm;
760 struct gimple_statement_omp_critical GTY ((tag ("GSS_OMP_CRITICAL"))) gimple_omp_critical;
761 struct gimple_statement_omp_for GTY ((tag ("GSS_OMP_FOR"))) gimple_omp_for;
762 struct gimple_statement_omp_parallel GTY ((tag ("GSS_OMP_PARALLEL"))) gimple_omp_parallel;
763 struct gimple_statement_omp_task GTY ((tag ("GSS_OMP_TASK"))) gimple_omp_task;
764 struct gimple_statement_omp_sections GTY ((tag ("GSS_OMP_SECTIONS"))) gimple_omp_sections;
765 struct gimple_statement_omp_single GTY ((tag ("GSS_OMP_SINGLE"))) gimple_omp_single;
766 struct gimple_statement_omp_continue GTY ((tag ("GSS_OMP_CONTINUE"))) gimple_omp_continue;
767 struct gimple_statement_omp_atomic_load GTY ((tag ("GSS_OMP_ATOMIC_LOAD"))) gimple_omp_atomic_load;
768 struct gimple_statement_omp_atomic_store GTY ((tag ("GSS_OMP_ATOMIC_STORE"))) gimple_omp_atomic_store;
771 /* In gimple.c. */
772 gimple gimple_build_return (tree);
774 gimple gimple_build_assign_stat (tree, tree MEM_STAT_DECL);
775 #define gimple_build_assign(l,r) gimple_build_assign_stat (l, r MEM_STAT_INFO)
777 void extract_ops_from_tree (tree, enum tree_code *, tree *, tree *);
779 gimple gimple_build_assign_with_ops_stat (enum tree_code, tree, tree,
780 tree MEM_STAT_DECL);
781 #define gimple_build_assign_with_ops(c,o1,o2,o3) \
782 gimple_build_assign_with_ops_stat (c, o1, o2, o3 MEM_STAT_INFO)
784 gimple gimple_build_call_vec (tree, VEC(tree, heap) *);
785 gimple gimple_build_call (tree, unsigned, ...);
786 gimple gimple_build_call_from_tree (tree);
787 gimple gimplify_assign (tree, tree, gimple_seq *);
788 gimple gimple_build_cond (enum tree_code, tree, tree, tree, tree);
789 gimple gimple_build_label (tree label);
790 gimple gimple_build_goto (tree dest);
791 gimple gimple_build_nop (void);
792 gimple gimple_build_bind (tree, gimple_seq, tree);
793 gimple gimple_build_asm (const char *, unsigned, unsigned, unsigned, ...);
794 gimple gimple_build_asm_vec (const char *, VEC(tree,gc) *, VEC(tree,gc) *,
795 VEC(tree,gc) *);
796 gimple gimple_build_catch (tree, gimple_seq);
797 gimple gimple_build_eh_filter (tree, gimple_seq);
798 gimple gimple_build_try (gimple_seq, gimple_seq, enum gimple_try_flags);
799 gimple gimple_build_wce (gimple_seq);
800 gimple gimple_build_resx (int);
801 gimple gimple_build_switch (unsigned, tree, tree, ...);
802 gimple gimple_build_switch_vec (tree, tree, VEC(tree,heap) *);
803 gimple gimple_build_omp_parallel (gimple_seq, tree, tree, tree);
804 gimple gimple_build_omp_task (gimple_seq, tree, tree, tree, tree, tree, tree);
805 gimple gimple_build_omp_for (gimple_seq, tree, size_t, gimple_seq);
806 gimple gimple_build_omp_critical (gimple_seq, tree);
807 gimple gimple_build_omp_section (gimple_seq);
808 gimple gimple_build_omp_continue (tree, tree);
809 gimple gimple_build_omp_master (gimple_seq);
810 gimple gimple_build_omp_return (bool);
811 gimple gimple_build_omp_ordered (gimple_seq);
812 gimple gimple_build_omp_sections (gimple_seq, tree);
813 gimple gimple_build_omp_sections_switch (void);
814 gimple gimple_build_omp_single (gimple_seq, tree);
815 gimple gimple_build_cdt (tree, tree);
816 gimple gimple_build_omp_atomic_load (tree, tree);
817 gimple gimple_build_omp_atomic_store (tree);
818 gimple gimple_build_predict (enum br_predictor, enum prediction);
819 enum gimple_statement_structure_enum gimple_statement_structure (gimple);
820 enum gimple_statement_structure_enum gss_for_assign (enum tree_code);
821 void sort_case_labels (VEC(tree,heap) *);
822 void gimple_set_body (tree, gimple_seq);
823 gimple_seq gimple_body (tree);
824 bool gimple_has_body_p (tree);
825 gimple_seq gimple_seq_alloc (void);
826 void gimple_seq_free (gimple_seq);
827 void gimple_seq_add_seq (gimple_seq *, gimple_seq);
828 gimple_seq gimple_seq_copy (gimple_seq);
829 int gimple_call_flags (const_gimple);
830 bool gimple_assign_copy_p (gimple);
831 bool gimple_assign_ssa_name_copy_p (gimple);
832 bool gimple_assign_single_p (gimple);
833 bool gimple_assign_unary_nop_p (gimple);
834 void gimple_set_bb (gimple, struct basic_block_def *);
835 tree gimple_fold (const_gimple);
836 void gimple_assign_set_rhs_from_tree (gimple_stmt_iterator *, tree);
837 void gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *, enum tree_code,
838 tree, tree);
839 tree gimple_get_lhs (const_gimple);
840 void gimple_set_lhs (gimple, tree);
841 gimple gimple_copy (gimple);
842 bool is_gimple_operand (const_tree);
843 void gimple_set_modified (gimple, bool);
844 void gimple_cond_get_ops_from_tree (tree, enum tree_code *, tree *, tree *);
845 gimple gimple_build_cond_from_tree (tree, tree, tree);
846 void gimple_cond_set_condition_from_tree (gimple, tree);
847 bool gimple_has_side_effects (const_gimple);
848 bool gimple_rhs_has_side_effects (const_gimple);
849 bool gimple_could_trap_p (gimple);
850 bool gimple_assign_rhs_could_trap_p (gimple);
851 void gimple_regimplify_operands (gimple, gimple_stmt_iterator *);
852 bool empty_body_p (gimple_seq);
853 unsigned get_gimple_rhs_num_ops (enum tree_code);
855 /* Returns true iff T is a valid GIMPLE statement. */
856 extern bool is_gimple_stmt (tree);
858 /* Returns true iff TYPE is a valid type for a scalar register variable. */
859 extern bool is_gimple_reg_type (tree);
860 /* Returns true iff T is a scalar register variable. */
861 extern bool is_gimple_reg (tree);
862 /* Returns true iff T is any sort of variable. */
863 extern bool is_gimple_variable (tree);
864 /* Returns true iff T is any sort of symbol. */
865 extern bool is_gimple_id (tree);
866 /* Returns true iff T is a variable or an INDIRECT_REF (of a variable). */
867 extern bool is_gimple_min_lval (tree);
868 /* Returns true iff T is something whose address can be taken. */
869 extern bool is_gimple_addressable (tree);
870 /* Returns true iff T is any valid GIMPLE lvalue. */
871 extern bool is_gimple_lvalue (tree);
873 /* Returns true iff T is a GIMPLE address. */
874 bool is_gimple_address (const_tree);
875 /* Returns true iff T is a GIMPLE invariant address. */
876 bool is_gimple_invariant_address (const_tree);
877 /* Returns true iff T is a GIMPLE invariant address at interprocedural
878 level. */
879 bool is_gimple_ip_invariant_address (const_tree);
880 /* Returns true iff T is a valid GIMPLE constant. */
881 bool is_gimple_constant (const_tree);
882 /* Returns true iff T is a GIMPLE restricted function invariant. */
883 extern bool is_gimple_min_invariant (const_tree);
884 /* Returns true iff T is a GIMPLE restricted interprecodural invariant. */
885 extern bool is_gimple_ip_invariant (const_tree);
886 /* Returns true iff T is a GIMPLE rvalue. */
887 extern bool is_gimple_val (tree);
888 /* Returns true iff T is a GIMPLE asm statement input. */
889 extern bool is_gimple_asm_val (tree);
890 /* Returns true iff T is a valid rhs for a MODIFY_EXPR where the LHS is a
891 GIMPLE temporary, a renamed user variable, or something else,
892 respectively. */
893 extern bool is_gimple_reg_rhs (tree);
894 extern bool is_gimple_mem_rhs (tree);
896 /* Returns true iff T is a valid if-statement condition. */
897 extern bool is_gimple_condexpr (tree);
899 /* Returns true iff T is a type conversion. */
900 extern bool is_gimple_cast (tree);
901 /* Returns true iff T is a variable that does not need to live in memory. */
902 extern bool is_gimple_non_addressable (tree t);
904 /* Returns true iff T is a valid call address expression. */
905 extern bool is_gimple_call_addr (tree);
906 /* If T makes a function call, returns the CALL_EXPR operand. */
907 extern tree get_call_expr_in (tree t);
909 extern void recalculate_side_effects (tree);
910 extern void count_uses_and_derefs (tree, gimple, unsigned *, unsigned *,
911 unsigned *);
913 /* In gimplify.c */
914 extern tree create_tmp_var_raw (tree, const char *);
915 extern tree create_tmp_var_name (const char *);
916 extern tree create_tmp_var (tree, const char *);
917 extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq *);
918 extern tree get_formal_tmp_var (tree, gimple_seq *);
919 extern void declare_vars (tree, gimple, bool);
920 extern void tree_annotate_all_with_location (tree *, location_t);
921 extern void annotate_all_with_location (gimple_seq, location_t);
923 /* Validation of GIMPLE expressions. Note that these predicates only check
924 the basic form of the expression, they don't recurse to make sure that
925 underlying nodes are also of the right form. */
926 typedef bool (*gimple_predicate)(tree);
929 /* FIXME we should deduce this from the predicate. */
930 typedef enum fallback_t {
931 fb_none = 0, /* Do not generate a temporary. */
933 fb_rvalue = 1, /* Generate an rvalue to hold the result of a
934 gimplified expression. */
936 fb_lvalue = 2, /* Generate an lvalue to hold the result of a
937 gimplified expression. */
939 fb_mayfail = 4, /* Gimplification may fail. Error issued
940 afterwards. */
941 fb_either= fb_rvalue | fb_lvalue
942 } fallback_t;
944 enum gimplify_status {
945 GS_ERROR = -2, /* Something Bad Seen. */
946 GS_UNHANDLED = -1, /* A langhook result for "I dunno". */
947 GS_OK = 0, /* We did something, maybe more to do. */
948 GS_ALL_DONE = 1 /* The expression is fully gimplified. */
951 struct gimplify_ctx
953 struct gimplify_ctx *prev_context;
955 VEC(gimple,heap) *bind_expr_stack;
956 tree temps;
957 gimple_seq conditional_cleanups;
958 tree exit_label;
959 tree return_temp;
961 VEC(tree,heap) *case_labels;
962 /* The formal temporary table. Should this be persistent? */
963 htab_t temp_htab;
965 int conditions;
966 bool save_stack;
967 bool into_ssa;
968 bool allow_rhs_cond_expr;
971 extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *,
972 bool (*) (tree), fallback_t);
973 extern void gimplify_type_sizes (tree, gimple_seq *);
974 extern void gimplify_one_sizepos (tree *, gimple_seq *);
975 extern bool gimplify_stmt (tree *, gimple_seq *);
976 extern gimple gimplify_body (tree *, tree, bool);
977 extern void push_gimplify_context (struct gimplify_ctx *);
978 extern void pop_gimplify_context (gimple);
979 extern void gimplify_and_add (tree, gimple_seq *);
981 /* Miscellaneous helpers. */
982 extern void gimple_add_tmp_var (tree);
983 extern gimple gimple_current_bind_expr (void);
984 extern VEC(gimple, heap) *gimple_bind_expr_stack (void);
985 extern tree voidify_wrapper_expr (tree, tree);
986 extern tree build_and_jump (tree *);
987 extern tree alloc_stmt_list (void);
988 extern void free_stmt_list (tree);
989 extern tree force_labels_r (tree *, int *, void *);
990 extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *,
991 gimple_seq *);
992 struct gimplify_omp_ctx;
993 extern void omp_firstprivatize_variable (struct gimplify_omp_ctx *, tree);
994 extern tree gimple_boolify (tree);
995 extern gimple_predicate rhs_predicate_for (tree);
996 extern tree canonicalize_cond_expr_cond (tree);
998 /* In omp-low.c. */
999 extern void diagnose_omp_structured_block_errors (tree);
1000 extern tree omp_reduction_init (tree, tree);
1002 /* In tree-nested.c. */
1003 extern void lower_nested_functions (tree);
1004 extern void insert_field_into_struct (tree, tree);
1006 /* In gimplify.c. */
1007 extern void gimplify_function_tree (tree);
1009 /* In cfgexpand.c. */
1010 extern tree gimple_assign_rhs_to_tree (gimple);
1012 /* In builtins.c */
1013 extern bool validate_gimple_arglist (const_gimple, ...);
1015 /* In tree-ssa.c */
1016 extern bool tree_ssa_useless_type_conversion (tree);
1017 extern bool useless_type_conversion_p (tree, tree);
1018 extern bool types_compatible_p (tree, tree);
1020 /* Return the code for GIMPLE statement G. */
1022 static inline enum gimple_code
1023 gimple_code (const_gimple g)
1025 return g->gsbase.code;
1029 /* Return true if statement G has sub-statements. This is only true for
1030 High GIMPLE statements. */
1032 static inline bool
1033 gimple_has_substatements (gimple g)
1035 switch (gimple_code (g))
1037 case GIMPLE_BIND:
1038 case GIMPLE_CATCH:
1039 case GIMPLE_EH_FILTER:
1040 case GIMPLE_TRY:
1041 case GIMPLE_OMP_FOR:
1042 case GIMPLE_OMP_MASTER:
1043 case GIMPLE_OMP_ORDERED:
1044 case GIMPLE_OMP_SECTION:
1045 case GIMPLE_OMP_PARALLEL:
1046 case GIMPLE_OMP_TASK:
1047 case GIMPLE_OMP_SECTIONS:
1048 case GIMPLE_OMP_SINGLE:
1049 case GIMPLE_OMP_CRITICAL:
1050 case GIMPLE_WITH_CLEANUP_EXPR:
1051 return true;
1053 default:
1054 return false;
1059 /* Return the basic block holding statement G. */
1061 static inline struct basic_block_def *
1062 gimple_bb (const_gimple g)
1064 return g->gsbase.bb;
1068 /* Return the lexical scope block holding statement G. */
1070 static inline tree
1071 gimple_block (const_gimple g)
1073 return g->gsbase.block;
1077 /* Set BLOCK to be the lexical scope block holding statement G. */
1079 static inline void
1080 gimple_set_block (gimple g, tree block)
1082 g->gsbase.block = block;
1086 /* Return location information for statement G. */
1088 static inline location_t
1089 gimple_location (const_gimple g)
1091 return g->gsbase.location;
1094 /* Return pointer to location information for statement G. */
1096 static inline const location_t *
1097 gimple_location_ptr (const_gimple g)
1099 return &g->gsbase.location;
1103 /* Set location information for statement G. */
1105 static inline void
1106 gimple_set_location (gimple g, location_t location)
1108 g->gsbase.location = location;
1112 /* Return true if G contains location information. */
1114 static inline bool
1115 gimple_has_location (const_gimple g)
1117 return gimple_location (g) != UNKNOWN_LOCATION;
1121 /* Return the file name of the location of STMT. */
1123 static inline const char *
1124 gimple_filename (const_gimple stmt)
1126 return LOCATION_FILE (gimple_location (stmt));
1130 /* Return the line number of the location of STMT. */
1132 static inline int
1133 gimple_lineno (const_gimple stmt)
1135 return LOCATION_LINE (gimple_location (stmt));
1139 /* Determine whether SEQ is a singleton. */
1141 static inline bool
1142 gimple_seq_singleton_p (gimple_seq seq)
1144 return ((gimple_seq_first (seq) != NULL)
1145 && (gimple_seq_first (seq) == gimple_seq_last (seq)));
1148 /* Return true if no warnings should be emitted for statement STMT. */
1150 static inline bool
1151 gimple_no_warning_p (const_gimple stmt)
1153 return stmt->gsbase.no_warning;
1156 /* Set the no_warning flag of STMT to NO_WARNING. */
1158 static inline void
1159 gimple_set_no_warning (gimple stmt, bool no_warning)
1161 stmt->gsbase.no_warning = (unsigned) no_warning;
1164 /* Set the visited status on statement STMT to VISITED_P. */
1166 static inline void
1167 gimple_set_visited (gimple stmt, bool visited_p)
1169 stmt->gsbase.visited = (unsigned) visited_p;
1173 /* Return the visited status for statement STMT. */
1175 static inline bool
1176 gimple_visited_p (gimple stmt)
1178 return stmt->gsbase.visited;
1182 /* Set pass local flag PLF on statement STMT to VAL_P. */
1184 static inline void
1185 gimple_set_plf (gimple stmt, enum plf_mask plf, bool val_p)
1187 if (val_p)
1188 stmt->gsbase.plf |= (unsigned int) plf;
1189 else
1190 stmt->gsbase.plf &= ~((unsigned int) plf);
1194 /* Return the value of pass local flag PLF on statement STMT. */
1196 static inline unsigned int
1197 gimple_plf (gimple stmt, enum plf_mask plf)
1199 return stmt->gsbase.plf & ((unsigned int) plf);
1203 /* Set the UID of statement. */
1205 static inline void
1206 gimple_set_uid (gimple g, unsigned uid)
1208 g->gsbase.uid = uid;
1212 /* Return the UID of statement. */
1214 static inline unsigned
1215 gimple_uid (const_gimple g)
1217 return g->gsbase.uid;
1221 /* Return true if GIMPLE statement G has register or memory operands. */
1223 static inline bool
1224 gimple_has_ops (const_gimple g)
1226 return gimple_code (g) >= GIMPLE_COND && gimple_code (g) <= GIMPLE_RETURN;
1230 /* Return true if GIMPLE statement G has memory operands. */
1232 static inline bool
1233 gimple_has_mem_ops (const_gimple g)
1235 return gimple_code (g) >= GIMPLE_ASSIGN && gimple_code (g) <= GIMPLE_RETURN;
1238 /* Return the set of addresses taken by statement G. */
1240 static inline bitmap
1241 gimple_addresses_taken (const_gimple g)
1243 if (gimple_has_ops (g))
1244 return g->gsops.opbase.addresses_taken;
1245 else
1246 return NULL;
1250 /* Return a pointer to the set of addresses taken by statement G. */
1252 static inline bitmap *
1253 gimple_addresses_taken_ptr (gimple g)
1255 if (gimple_has_ops (g))
1256 return &g->gsops.opbase.addresses_taken;
1257 else
1258 return NULL;
1262 /* Set B to be the set of addresses taken by statement G. The
1263 previous set is freed. */
1265 static inline void
1266 gimple_set_addresses_taken (gimple g, bitmap b)
1268 gcc_assert (gimple_has_ops (g));
1269 BITMAP_FREE (g->gsops.opbase.addresses_taken);
1270 g->gsops.opbase.addresses_taken = b;
1274 /* Return the set of DEF operands for statement G. */
1276 static inline struct def_optype_d *
1277 gimple_def_ops (const_gimple g)
1279 if (!gimple_has_ops (g))
1280 return NULL;
1281 return g->gsops.opbase.def_ops;
1285 /* Set DEF to be the set of DEF operands for statement G. */
1287 static inline void
1288 gimple_set_def_ops (gimple g, struct def_optype_d *def)
1290 gcc_assert (gimple_has_ops (g));
1291 g->gsops.opbase.def_ops = def;
1295 /* Return the set of USE operands for statement G. */
1297 static inline struct use_optype_d *
1298 gimple_use_ops (const_gimple g)
1300 if (!gimple_has_ops (g))
1301 return NULL;
1302 return g->gsops.opbase.use_ops;
1306 /* Set USE to be the set of USE operands for statement G. */
1308 static inline void
1309 gimple_set_use_ops (gimple g, struct use_optype_d *use)
1311 gcc_assert (gimple_has_ops (g));
1312 g->gsops.opbase.use_ops = use;
1316 /* Return the set of VUSE operand for statement G. */
1318 static inline use_operand_p
1319 gimple_vuse_op (const_gimple g)
1321 struct use_optype_d *ops;
1322 if (!gimple_has_mem_ops (g))
1323 return NULL_USE_OPERAND_P;
1324 ops = g->gsops.opbase.use_ops;
1325 if (ops
1326 && USE_OP_PTR (ops)->use == &g->gsmem.membase.vuse)
1327 return USE_OP_PTR (ops);
1328 return NULL_USE_OPERAND_P;
1331 /* Return the set of VDEF operand for statement G. */
1333 static inline def_operand_p
1334 gimple_vdef_op (const_gimple g)
1336 struct def_optype_d *ops;
1337 if (!gimple_has_mem_ops (g))
1338 return NULL_DEF_OPERAND_P;
1339 ops = g->gsops.opbase.def_ops;
1340 if (ops
1341 && DEF_OP_PTR (ops) == &g->gsmem.membase.vdef)
1342 return DEF_OP_PTR (ops);
1343 return NULL_DEF_OPERAND_P;
1347 /* Return the single VUSE operand of the statement G. */
1349 static inline tree
1350 gimple_vuse (const_gimple g)
1352 if (!gimple_has_mem_ops (g))
1353 return NULL_TREE;
1354 return g->gsmem.membase.vuse;
1357 /* Return the single VDEF operand of the statement G. */
1359 static inline tree
1360 gimple_vdef (const_gimple g)
1362 if (!gimple_has_mem_ops (g))
1363 return NULL_TREE;
1364 return g->gsmem.membase.vdef;
1367 /* Return the single VUSE operand of the statement G. */
1369 static inline tree *
1370 gimple_vuse_ptr (gimple g)
1372 if (!gimple_has_mem_ops (g))
1373 return NULL;
1374 return &g->gsmem.membase.vuse;
1377 /* Return the single VDEF operand of the statement G. */
1379 static inline tree *
1380 gimple_vdef_ptr (gimple g)
1382 if (!gimple_has_mem_ops (g))
1383 return NULL;
1384 return &g->gsmem.membase.vdef;
1387 /* Set the single VUSE operand of the statement G. */
1389 static inline void
1390 gimple_set_vuse (gimple g, tree vuse)
1392 gcc_assert (gimple_has_mem_ops (g));
1393 g->gsmem.membase.vuse = vuse;
1396 /* Set the single VDEF operand of the statement G. */
1398 static inline void
1399 gimple_set_vdef (gimple g, tree vdef)
1401 gcc_assert (gimple_has_mem_ops (g));
1402 g->gsmem.membase.vdef = vdef;
1406 /* Return true if statement G has operands and the modified field has
1407 been set. */
1409 static inline bool
1410 gimple_modified_p (const_gimple g)
1412 return (gimple_has_ops (g)) ? (bool) g->gsbase.modified : false;
1415 /* Return the type of the main expression computed by STMT. Return
1416 void_type_node if the statement computes nothing. */
1418 static inline tree
1419 gimple_expr_type (const_gimple stmt)
1421 enum gimple_code code = gimple_code (stmt);
1423 if (code == GIMPLE_ASSIGN || code == GIMPLE_CALL)
1425 tree type = TREE_TYPE (gimple_get_lhs (stmt));
1426 /* Integral sub-types are never the type of the expression,
1427 but they still can be the type of the result as the base
1428 type (in which expressions are computed) is trivially
1429 convertible to one of its sub-types. So always return
1430 the base type here. */
1431 if (INTEGRAL_TYPE_P (type)
1432 && TREE_TYPE (type)
1433 /* But only if they are trivially convertible. */
1434 && useless_type_conversion_p (type, TREE_TYPE (type)))
1435 type = TREE_TYPE (type);
1436 return type;
1438 else if (code == GIMPLE_COND)
1439 return boolean_type_node;
1440 else
1441 return void_type_node;
1445 /* Return the tree code for the expression computed by STMT. This is
1446 only valid for GIMPLE_COND, GIMPLE_CALL and GIMPLE_ASSIGN. For
1447 GIMPLE_CALL, return CALL_EXPR as the expression code for
1448 consistency. This is useful when the caller needs to deal with the
1449 three kinds of computation that GIMPLE supports. */
1451 static inline enum tree_code
1452 gimple_expr_code (const_gimple stmt)
1454 enum gimple_code code = gimple_code (stmt);
1455 if (code == GIMPLE_ASSIGN || code == GIMPLE_COND)
1456 return (enum tree_code) stmt->gsbase.subcode;
1457 else if (code == GIMPLE_CALL)
1458 return CALL_EXPR;
1459 else
1460 gcc_unreachable ();
1464 /* Mark statement S as modified, and update it. */
1466 static inline void
1467 update_stmt (gimple s)
1469 if (gimple_has_ops (s))
1471 gimple_set_modified (s, true);
1472 update_stmt_operands (s);
1476 /* Update statement S if it has been optimized. */
1478 static inline void
1479 update_stmt_if_modified (gimple s)
1481 if (gimple_modified_p (s))
1482 update_stmt_operands (s);
1485 /* Return true if statement STMT contains volatile operands. */
1487 static inline bool
1488 gimple_has_volatile_ops (const_gimple stmt)
1490 if (gimple_has_mem_ops (stmt))
1491 return stmt->gsbase.has_volatile_ops;
1492 else
1493 return false;
1497 /* Set the HAS_VOLATILE_OPS flag to VOLATILEP. */
1499 static inline void
1500 gimple_set_has_volatile_ops (gimple stmt, bool volatilep)
1502 if (gimple_has_mem_ops (stmt))
1503 stmt->gsbase.has_volatile_ops = (unsigned) volatilep;
1507 /* Return true if statement STMT may access memory. */
1509 static inline bool
1510 gimple_references_memory_p (gimple stmt)
1512 return gimple_has_mem_ops (stmt) && gimple_vuse (stmt);
1516 /* Return the subcode for OMP statement S. */
1518 static inline unsigned
1519 gimple_omp_subcode (const_gimple s)
1521 gcc_assert (gimple_code (s) >= GIMPLE_OMP_ATOMIC_LOAD
1522 && gimple_code (s) <= GIMPLE_OMP_SINGLE);
1523 return s->gsbase.subcode;
1526 /* Set the subcode for OMP statement S to SUBCODE. */
1528 static inline void
1529 gimple_omp_set_subcode (gimple s, unsigned int subcode)
1531 /* We only have 16 bits for the subcode. Assert that we are not
1532 overflowing it. */
1533 gcc_assert (subcode < (1 << 16));
1534 s->gsbase.subcode = subcode;
1537 /* Set the nowait flag on OMP_RETURN statement S. */
1539 static inline void
1540 gimple_omp_return_set_nowait (gimple s)
1542 GIMPLE_CHECK (s, GIMPLE_OMP_RETURN);
1543 s->gsbase.subcode |= GF_OMP_RETURN_NOWAIT;
1547 /* Return true if OMP return statement G has the GF_OMP_RETURN_NOWAIT
1548 flag set. */
1550 static inline bool
1551 gimple_omp_return_nowait_p (const_gimple g)
1553 GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
1554 return (gimple_omp_subcode (g) & GF_OMP_RETURN_NOWAIT) != 0;
1558 /* Return true if OMP section statement G has the GF_OMP_SECTION_LAST
1559 flag set. */
1561 static inline bool
1562 gimple_omp_section_last_p (const_gimple g)
1564 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1565 return (gimple_omp_subcode (g) & GF_OMP_SECTION_LAST) != 0;
1569 /* Set the GF_OMP_SECTION_LAST flag on G. */
1571 static inline void
1572 gimple_omp_section_set_last (gimple g)
1574 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1575 g->gsbase.subcode |= GF_OMP_SECTION_LAST;
1579 /* Return true if OMP parallel statement G has the
1580 GF_OMP_PARALLEL_COMBINED flag set. */
1582 static inline bool
1583 gimple_omp_parallel_combined_p (const_gimple g)
1585 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1586 return (gimple_omp_subcode (g) & GF_OMP_PARALLEL_COMBINED) != 0;
1590 /* Set the GF_OMP_PARALLEL_COMBINED field in G depending on the boolean
1591 value of COMBINED_P. */
1593 static inline void
1594 gimple_omp_parallel_set_combined_p (gimple g, bool combined_p)
1596 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1597 if (combined_p)
1598 g->gsbase.subcode |= GF_OMP_PARALLEL_COMBINED;
1599 else
1600 g->gsbase.subcode &= ~GF_OMP_PARALLEL_COMBINED;
1604 /* Return the number of operands for statement GS. */
1606 static inline unsigned
1607 gimple_num_ops (const_gimple gs)
1609 return gs->gsbase.num_ops;
1613 /* Set the number of operands for statement GS. */
1615 static inline void
1616 gimple_set_num_ops (gimple gs, unsigned num_ops)
1618 gs->gsbase.num_ops = num_ops;
1622 /* Return the array of operands for statement GS. */
1624 static inline tree *
1625 gimple_ops (gimple gs)
1627 /* Offset in bytes to the location of the operand vector in every
1628 tuple structure. Defined in gimple.c */
1629 extern size_t const gimple_ops_offset_[];
1631 if (!gimple_has_ops (gs))
1632 return NULL;
1634 /* All the tuples have their operand vector at the very bottom
1635 of the structure. */
1636 return ((tree *) ((char *) gs + gimple_ops_offset_[gimple_code (gs)]));
1640 /* Return operand I for statement GS. */
1642 static inline tree
1643 gimple_op (const_gimple gs, unsigned i)
1645 if (gimple_has_ops (gs))
1647 gcc_assert (i < gimple_num_ops (gs));
1648 return gimple_ops (CONST_CAST_GIMPLE (gs))[i];
1650 else
1651 return NULL_TREE;
1654 /* Return a pointer to operand I for statement GS. */
1656 static inline tree *
1657 gimple_op_ptr (const_gimple gs, unsigned i)
1659 if (gimple_has_ops (gs))
1661 gcc_assert (i < gimple_num_ops (gs));
1662 return gimple_ops (CONST_CAST_GIMPLE (gs)) + i;
1664 else
1665 return NULL;
1668 /* Set operand I of statement GS to OP. */
1670 static inline void
1671 gimple_set_op (gimple gs, unsigned i, tree op)
1673 gcc_assert (gimple_has_ops (gs) && i < gimple_num_ops (gs));
1675 /* Note. It may be tempting to assert that OP matches
1676 is_gimple_operand, but that would be wrong. Different tuples
1677 accept slightly different sets of tree operands. Each caller
1678 should perform its own validation. */
1679 gimple_ops (gs)[i] = op;
1682 /* Return true if GS is a GIMPLE_ASSIGN. */
1684 static inline bool
1685 is_gimple_assign (const_gimple gs)
1687 return gimple_code (gs) == GIMPLE_ASSIGN;
1690 /* Determine if expression CODE is one of the valid expressions that can
1691 be used on the RHS of GIMPLE assignments. */
1693 static inline enum gimple_rhs_class
1694 get_gimple_rhs_class (enum tree_code code)
1696 return (enum gimple_rhs_class) gimple_rhs_class_table[(int) code];
1699 /* Return the LHS of assignment statement GS. */
1701 static inline tree
1702 gimple_assign_lhs (const_gimple gs)
1704 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1705 return gimple_op (gs, 0);
1709 /* Return a pointer to the LHS of assignment statement GS. */
1711 static inline tree *
1712 gimple_assign_lhs_ptr (const_gimple gs)
1714 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1715 return gimple_op_ptr (gs, 0);
1719 /* Set LHS to be the LHS operand of assignment statement GS. */
1721 static inline void
1722 gimple_assign_set_lhs (gimple gs, tree lhs)
1724 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1725 gcc_assert (is_gimple_operand (lhs));
1726 gimple_set_op (gs, 0, lhs);
1728 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1729 SSA_NAME_DEF_STMT (lhs) = gs;
1733 /* Return the first operand on the RHS of assignment statement GS. */
1735 static inline tree
1736 gimple_assign_rhs1 (const_gimple gs)
1738 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1739 return gimple_op (gs, 1);
1743 /* Return a pointer to the first operand on the RHS of assignment
1744 statement GS. */
1746 static inline tree *
1747 gimple_assign_rhs1_ptr (const_gimple gs)
1749 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1750 return gimple_op_ptr (gs, 1);
1753 /* Set RHS to be the first operand on the RHS of assignment statement GS. */
1755 static inline void
1756 gimple_assign_set_rhs1 (gimple gs, tree rhs)
1758 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1760 /* If there are 3 or more operands, the 2 operands on the RHS must be
1761 GIMPLE values. */
1762 if (gimple_num_ops (gs) >= 3)
1763 gcc_assert (is_gimple_val (rhs));
1764 else
1765 gcc_assert (is_gimple_operand (rhs));
1767 gimple_set_op (gs, 1, rhs);
1771 /* Return the second operand on the RHS of assignment statement GS.
1772 If GS does not have two operands, NULL is returned instead. */
1774 static inline tree
1775 gimple_assign_rhs2 (const_gimple gs)
1777 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1779 if (gimple_num_ops (gs) >= 3)
1780 return gimple_op (gs, 2);
1781 else
1782 return NULL_TREE;
1786 /* Return a pointer to the second operand on the RHS of assignment
1787 statement GS. */
1789 static inline tree *
1790 gimple_assign_rhs2_ptr (const_gimple gs)
1792 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1793 return gimple_op_ptr (gs, 2);
1797 /* Set RHS to be the second operand on the RHS of assignment statement GS. */
1799 static inline void
1800 gimple_assign_set_rhs2 (gimple gs, tree rhs)
1802 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1804 /* The 2 operands on the RHS must be GIMPLE values. */
1805 gcc_assert (is_gimple_val (rhs));
1807 gimple_set_op (gs, 2, rhs);
1810 /* Returns true if GS is a nontemporal move. */
1812 static inline bool
1813 gimple_assign_nontemporal_move_p (const_gimple gs)
1815 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1816 return gs->gsbase.nontemporal_move;
1819 /* Sets nontemporal move flag of GS to NONTEMPORAL. */
1821 static inline void
1822 gimple_assign_set_nontemporal_move (gimple gs, bool nontemporal)
1824 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1825 gs->gsbase.nontemporal_move = nontemporal;
1829 /* Return the code of the expression computed on the rhs of assignment
1830 statement GS. In case that the RHS is a single object, returns the
1831 tree code of the object. */
1833 static inline enum tree_code
1834 gimple_assign_rhs_code (const_gimple gs)
1836 enum tree_code code;
1837 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1839 code = gimple_expr_code (gs);
1840 if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS)
1841 code = TREE_CODE (gimple_assign_rhs1 (gs));
1843 return code;
1847 /* Set CODE to be the code for the expression computed on the RHS of
1848 assignment S. */
1850 static inline void
1851 gimple_assign_set_rhs_code (gimple s, enum tree_code code)
1853 GIMPLE_CHECK (s, GIMPLE_ASSIGN);
1854 s->gsbase.subcode = code;
1858 /* Return the gimple rhs class of the code of the expression computed on
1859 the rhs of assignment statement GS.
1860 This will never return GIMPLE_INVALID_RHS. */
1862 static inline enum gimple_rhs_class
1863 gimple_assign_rhs_class (const_gimple gs)
1865 return get_gimple_rhs_class (gimple_assign_rhs_code (gs));
1869 /* Return true if S is a type-cast assignment. */
1871 static inline bool
1872 gimple_assign_cast_p (gimple s)
1874 if (is_gimple_assign (s))
1876 enum tree_code sc = gimple_assign_rhs_code (s);
1877 return CONVERT_EXPR_CODE_P (sc)
1878 || sc == VIEW_CONVERT_EXPR
1879 || sc == FIX_TRUNC_EXPR;
1882 return false;
1886 /* Return true if GS is a GIMPLE_CALL. */
1888 static inline bool
1889 is_gimple_call (const_gimple gs)
1891 return gimple_code (gs) == GIMPLE_CALL;
1894 /* Return the LHS of call statement GS. */
1896 static inline tree
1897 gimple_call_lhs (const_gimple gs)
1899 GIMPLE_CHECK (gs, GIMPLE_CALL);
1900 return gimple_op (gs, 0);
1904 /* Return a pointer to the LHS of call statement GS. */
1906 static inline tree *
1907 gimple_call_lhs_ptr (const_gimple gs)
1909 GIMPLE_CHECK (gs, GIMPLE_CALL);
1910 return gimple_op_ptr (gs, 0);
1914 /* Set LHS to be the LHS operand of call statement GS. */
1916 static inline void
1917 gimple_call_set_lhs (gimple gs, tree lhs)
1919 GIMPLE_CHECK (gs, GIMPLE_CALL);
1920 gcc_assert (!lhs || is_gimple_operand (lhs));
1921 gimple_set_op (gs, 0, lhs);
1922 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1923 SSA_NAME_DEF_STMT (lhs) = gs;
1927 /* Return the tree node representing the function called by call
1928 statement GS. */
1930 static inline tree
1931 gimple_call_fn (const_gimple gs)
1933 GIMPLE_CHECK (gs, GIMPLE_CALL);
1934 return gimple_op (gs, 1);
1938 /* Return a pointer to the tree node representing the function called by call
1939 statement GS. */
1941 static inline tree *
1942 gimple_call_fn_ptr (const_gimple gs)
1944 GIMPLE_CHECK (gs, GIMPLE_CALL);
1945 return gimple_op_ptr (gs, 1);
1949 /* Set FN to be the function called by call statement GS. */
1951 static inline void
1952 gimple_call_set_fn (gimple gs, tree fn)
1954 GIMPLE_CHECK (gs, GIMPLE_CALL);
1955 gcc_assert (is_gimple_operand (fn));
1956 gimple_set_op (gs, 1, fn);
1960 /* Set FNDECL to be the function called by call statement GS. */
1962 static inline void
1963 gimple_call_set_fndecl (gimple gs, tree decl)
1965 GIMPLE_CHECK (gs, GIMPLE_CALL);
1966 gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
1967 gimple_set_op (gs, 1, build_fold_addr_expr (decl));
1971 /* If a given GIMPLE_CALL's callee is a FUNCTION_DECL, return it.
1972 Otherwise return NULL. This function is analogous to
1973 get_callee_fndecl in tree land. */
1975 static inline tree
1976 gimple_call_fndecl (const_gimple gs)
1978 tree addr = gimple_call_fn (gs);
1979 if (TREE_CODE (addr) == ADDR_EXPR)
1981 gcc_assert (TREE_CODE (TREE_OPERAND (addr, 0)) == FUNCTION_DECL);
1982 return TREE_OPERAND (addr, 0);
1984 return NULL_TREE;
1988 /* Return the type returned by call statement GS. */
1990 static inline tree
1991 gimple_call_return_type (const_gimple gs)
1993 tree fn = gimple_call_fn (gs);
1994 tree type = TREE_TYPE (fn);
1996 /* See through the pointer. */
1997 gcc_assert (POINTER_TYPE_P (type));
1998 type = TREE_TYPE (type);
2000 gcc_assert (TREE_CODE (type) == FUNCTION_TYPE
2001 || TREE_CODE (type) == METHOD_TYPE);
2003 /* The type returned by a FUNCTION_DECL is the type of its
2004 function type. */
2005 return TREE_TYPE (type);
2009 /* Return the static chain for call statement GS. */
2011 static inline tree
2012 gimple_call_chain (const_gimple gs)
2014 GIMPLE_CHECK (gs, GIMPLE_CALL);
2015 return gimple_op (gs, 2);
2019 /* Return a pointer to the static chain for call statement GS. */
2021 static inline tree *
2022 gimple_call_chain_ptr (const_gimple gs)
2024 GIMPLE_CHECK (gs, GIMPLE_CALL);
2025 return gimple_op_ptr (gs, 2);
2028 /* Set CHAIN to be the static chain for call statement GS. */
2030 static inline void
2031 gimple_call_set_chain (gimple gs, tree chain)
2033 GIMPLE_CHECK (gs, GIMPLE_CALL);
2034 gcc_assert (chain == NULL
2035 || TREE_CODE (chain) == ADDR_EXPR
2036 || SSA_VAR_P (chain));
2037 gimple_set_op (gs, 2, chain);
2041 /* Return the number of arguments used by call statement GS. */
2043 static inline unsigned
2044 gimple_call_num_args (const_gimple gs)
2046 unsigned num_ops;
2047 GIMPLE_CHECK (gs, GIMPLE_CALL);
2048 num_ops = gimple_num_ops (gs);
2049 gcc_assert (num_ops >= 3);
2050 return num_ops - 3;
2054 /* Return the argument at position INDEX for call statement GS. */
2056 static inline tree
2057 gimple_call_arg (const_gimple gs, unsigned index)
2059 GIMPLE_CHECK (gs, GIMPLE_CALL);
2060 return gimple_op (gs, index + 3);
2064 /* Return a pointer to the argument at position INDEX for call
2065 statement GS. */
2067 static inline tree *
2068 gimple_call_arg_ptr (const_gimple gs, unsigned index)
2070 GIMPLE_CHECK (gs, GIMPLE_CALL);
2071 return gimple_op_ptr (gs, index + 3);
2075 /* Set ARG to be the argument at position INDEX for call statement GS. */
2077 static inline void
2078 gimple_call_set_arg (gimple gs, unsigned index, tree arg)
2080 GIMPLE_CHECK (gs, GIMPLE_CALL);
2081 gcc_assert (is_gimple_operand (arg));
2082 gimple_set_op (gs, index + 3, arg);
2086 /* If TAIL_P is true, mark call statement S as being a tail call
2087 (i.e., a call just before the exit of a function). These calls are
2088 candidate for tail call optimization. */
2090 static inline void
2091 gimple_call_set_tail (gimple s, bool tail_p)
2093 GIMPLE_CHECK (s, GIMPLE_CALL);
2094 if (tail_p)
2095 s->gsbase.subcode |= GF_CALL_TAILCALL;
2096 else
2097 s->gsbase.subcode &= ~GF_CALL_TAILCALL;
2101 /* Return true if GIMPLE_CALL S is marked as a tail call. */
2103 static inline bool
2104 gimple_call_tail_p (gimple s)
2106 GIMPLE_CHECK (s, GIMPLE_CALL);
2107 return (s->gsbase.subcode & GF_CALL_TAILCALL) != 0;
2111 /* Set the inlinable status of GIMPLE_CALL S to INLINABLE_P. */
2113 static inline void
2114 gimple_call_set_cannot_inline (gimple s, bool inlinable_p)
2116 GIMPLE_CHECK (s, GIMPLE_CALL);
2117 if (inlinable_p)
2118 s->gsbase.subcode |= GF_CALL_CANNOT_INLINE;
2119 else
2120 s->gsbase.subcode &= ~GF_CALL_CANNOT_INLINE;
2124 /* Return true if GIMPLE_CALL S cannot be inlined. */
2126 static inline bool
2127 gimple_call_cannot_inline_p (gimple s)
2129 GIMPLE_CHECK (s, GIMPLE_CALL);
2130 return (s->gsbase.subcode & GF_CALL_CANNOT_INLINE) != 0;
2134 /* If RETURN_SLOT_OPT_P is true mark GIMPLE_CALL S as valid for return
2135 slot optimization. This transformation uses the target of the call
2136 expansion as the return slot for calls that return in memory. */
2138 static inline void
2139 gimple_call_set_return_slot_opt (gimple s, bool return_slot_opt_p)
2141 GIMPLE_CHECK (s, GIMPLE_CALL);
2142 if (return_slot_opt_p)
2143 s->gsbase.subcode |= GF_CALL_RETURN_SLOT_OPT;
2144 else
2145 s->gsbase.subcode &= ~GF_CALL_RETURN_SLOT_OPT;
2149 /* Return true if S is marked for return slot optimization. */
2151 static inline bool
2152 gimple_call_return_slot_opt_p (gimple s)
2154 GIMPLE_CHECK (s, GIMPLE_CALL);
2155 return (s->gsbase.subcode & GF_CALL_RETURN_SLOT_OPT) != 0;
2159 /* If FROM_THUNK_P is true, mark GIMPLE_CALL S as being the jump from a
2160 thunk to the thunked-to function. */
2162 static inline void
2163 gimple_call_set_from_thunk (gimple s, bool from_thunk_p)
2165 GIMPLE_CHECK (s, GIMPLE_CALL);
2166 if (from_thunk_p)
2167 s->gsbase.subcode |= GF_CALL_FROM_THUNK;
2168 else
2169 s->gsbase.subcode &= ~GF_CALL_FROM_THUNK;
2173 /* Return true if GIMPLE_CALL S is a jump from a thunk. */
2175 static inline bool
2176 gimple_call_from_thunk_p (gimple s)
2178 GIMPLE_CHECK (s, GIMPLE_CALL);
2179 return (s->gsbase.subcode & GF_CALL_FROM_THUNK) != 0;
2183 /* If PASS_ARG_PACK_P is true, GIMPLE_CALL S is a stdarg call that needs the
2184 argument pack in its argument list. */
2186 static inline void
2187 gimple_call_set_va_arg_pack (gimple s, bool pass_arg_pack_p)
2189 GIMPLE_CHECK (s, GIMPLE_CALL);
2190 if (pass_arg_pack_p)
2191 s->gsbase.subcode |= GF_CALL_VA_ARG_PACK;
2192 else
2193 s->gsbase.subcode &= ~GF_CALL_VA_ARG_PACK;
2197 /* Return true if GIMPLE_CALL S is a stdarg call that needs the
2198 argument pack in its argument list. */
2200 static inline bool
2201 gimple_call_va_arg_pack_p (gimple s)
2203 GIMPLE_CHECK (s, GIMPLE_CALL);
2204 return (s->gsbase.subcode & GF_CALL_VA_ARG_PACK) != 0;
2208 /* Return true if S is a noreturn call. */
2210 static inline bool
2211 gimple_call_noreturn_p (gimple s)
2213 GIMPLE_CHECK (s, GIMPLE_CALL);
2214 return (gimple_call_flags (s) & ECF_NORETURN) != 0;
2218 /* Return true if S is a nothrow call. */
2220 static inline bool
2221 gimple_call_nothrow_p (gimple s)
2223 GIMPLE_CHECK (s, GIMPLE_CALL);
2224 return (gimple_call_flags (s) & ECF_NOTHROW) != 0;
2228 /* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL. */
2230 static inline void
2231 gimple_call_copy_flags (gimple dest_call, gimple orig_call)
2233 GIMPLE_CHECK (dest_call, GIMPLE_CALL);
2234 GIMPLE_CHECK (orig_call, GIMPLE_CALL);
2235 dest_call->gsbase.subcode = orig_call->gsbase.subcode;
2239 /* Returns true if this is a GIMPLE_ASSIGN or a GIMPLE_CALL with a
2240 non-NULL lhs. */
2242 static inline bool
2243 gimple_has_lhs (gimple stmt)
2245 return (is_gimple_assign (stmt)
2246 || (is_gimple_call (stmt)
2247 && gimple_call_lhs (stmt) != NULL_TREE));
2251 /* Return the code of the predicate computed by conditional statement GS. */
2253 static inline enum tree_code
2254 gimple_cond_code (const_gimple gs)
2256 GIMPLE_CHECK (gs, GIMPLE_COND);
2257 return gs->gsbase.subcode;
2261 /* Set CODE to be the predicate code for the conditional statement GS. */
2263 static inline void
2264 gimple_cond_set_code (gimple gs, enum tree_code code)
2266 GIMPLE_CHECK (gs, GIMPLE_COND);
2267 gcc_assert (TREE_CODE_CLASS (code) == tcc_comparison);
2268 gs->gsbase.subcode = code;
2272 /* Return the LHS of the predicate computed by conditional statement GS. */
2274 static inline tree
2275 gimple_cond_lhs (const_gimple gs)
2277 GIMPLE_CHECK (gs, GIMPLE_COND);
2278 return gimple_op (gs, 0);
2281 /* Return the pointer to the LHS of the predicate computed by conditional
2282 statement GS. */
2284 static inline tree *
2285 gimple_cond_lhs_ptr (const_gimple gs)
2287 GIMPLE_CHECK (gs, GIMPLE_COND);
2288 return gimple_op_ptr (gs, 0);
2291 /* Set LHS to be the LHS operand of the predicate computed by
2292 conditional statement GS. */
2294 static inline void
2295 gimple_cond_set_lhs (gimple gs, tree lhs)
2297 GIMPLE_CHECK (gs, GIMPLE_COND);
2298 gcc_assert (is_gimple_operand (lhs));
2299 gimple_set_op (gs, 0, lhs);
2303 /* Return the RHS operand of the predicate computed by conditional GS. */
2305 static inline tree
2306 gimple_cond_rhs (const_gimple gs)
2308 GIMPLE_CHECK (gs, GIMPLE_COND);
2309 return gimple_op (gs, 1);
2312 /* Return the pointer to the RHS operand of the predicate computed by
2313 conditional GS. */
2315 static inline tree *
2316 gimple_cond_rhs_ptr (const_gimple gs)
2318 GIMPLE_CHECK (gs, GIMPLE_COND);
2319 return gimple_op_ptr (gs, 1);
2323 /* Set RHS to be the RHS operand of the predicate computed by
2324 conditional statement GS. */
2326 static inline void
2327 gimple_cond_set_rhs (gimple gs, tree rhs)
2329 GIMPLE_CHECK (gs, GIMPLE_COND);
2330 gcc_assert (is_gimple_operand (rhs));
2331 gimple_set_op (gs, 1, rhs);
2335 /* Return the label used by conditional statement GS when its
2336 predicate evaluates to true. */
2338 static inline tree
2339 gimple_cond_true_label (const_gimple gs)
2341 GIMPLE_CHECK (gs, GIMPLE_COND);
2342 return gimple_op (gs, 2);
2346 /* Set LABEL to be the label used by conditional statement GS when its
2347 predicate evaluates to true. */
2349 static inline void
2350 gimple_cond_set_true_label (gimple gs, tree label)
2352 GIMPLE_CHECK (gs, GIMPLE_COND);
2353 gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
2354 gimple_set_op (gs, 2, label);
2358 /* Set LABEL to be the label used by conditional statement GS when its
2359 predicate evaluates to false. */
2361 static inline void
2362 gimple_cond_set_false_label (gimple gs, tree label)
2364 GIMPLE_CHECK (gs, GIMPLE_COND);
2365 gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
2366 gimple_set_op (gs, 3, label);
2370 /* Return the label used by conditional statement GS when its
2371 predicate evaluates to false. */
2373 static inline tree
2374 gimple_cond_false_label (const_gimple gs)
2376 GIMPLE_CHECK (gs, GIMPLE_COND);
2377 return gimple_op (gs, 3);
2381 /* Set the conditional COND_STMT to be of the form 'if (1 == 0)'. */
2383 static inline void
2384 gimple_cond_make_false (gimple gs)
2386 gimple_cond_set_lhs (gs, boolean_true_node);
2387 gimple_cond_set_rhs (gs, boolean_false_node);
2388 gs->gsbase.subcode = EQ_EXPR;
2392 /* Set the conditional COND_STMT to be of the form 'if (1 == 1)'. */
2394 static inline void
2395 gimple_cond_make_true (gimple gs)
2397 gimple_cond_set_lhs (gs, boolean_true_node);
2398 gimple_cond_set_rhs (gs, boolean_true_node);
2399 gs->gsbase.subcode = EQ_EXPR;
2402 /* Check if conditional statemente GS is of the form 'if (1 == 1)',
2403 'if (0 == 0)', 'if (1 != 0)' or 'if (0 != 1)' */
2405 static inline bool
2406 gimple_cond_true_p (const_gimple gs)
2408 tree lhs = gimple_cond_lhs (gs);
2409 tree rhs = gimple_cond_rhs (gs);
2410 enum tree_code code = gimple_cond_code (gs);
2412 if (lhs != boolean_true_node && lhs != boolean_false_node)
2413 return false;
2415 if (rhs != boolean_true_node && rhs != boolean_false_node)
2416 return false;
2418 if (code == NE_EXPR && lhs != rhs)
2419 return true;
2421 if (code == EQ_EXPR && lhs == rhs)
2422 return true;
2424 return false;
2427 /* Check if conditional statement GS is of the form 'if (1 != 1)',
2428 'if (0 != 0)', 'if (1 == 0)' or 'if (0 == 1)' */
2430 static inline bool
2431 gimple_cond_false_p (const_gimple gs)
2433 tree lhs = gimple_cond_lhs (gs);
2434 tree rhs = gimple_cond_rhs (gs);
2435 enum tree_code code = gimple_cond_code (gs);
2437 if (lhs != boolean_true_node && lhs != boolean_false_node)
2438 return false;
2440 if (rhs != boolean_true_node && rhs != boolean_false_node)
2441 return false;
2443 if (code == NE_EXPR && lhs == rhs)
2444 return true;
2446 if (code == EQ_EXPR && lhs != rhs)
2447 return true;
2449 return false;
2452 /* Check if conditional statement GS is of the form 'if (var != 0)' or
2453 'if (var == 1)' */
2455 static inline bool
2456 gimple_cond_single_var_p (gimple gs)
2458 if (gimple_cond_code (gs) == NE_EXPR
2459 && gimple_cond_rhs (gs) == boolean_false_node)
2460 return true;
2462 if (gimple_cond_code (gs) == EQ_EXPR
2463 && gimple_cond_rhs (gs) == boolean_true_node)
2464 return true;
2466 return false;
2469 /* Set the code, LHS and RHS of GIMPLE_COND STMT from CODE, LHS and RHS. */
2471 static inline void
2472 gimple_cond_set_condition (gimple stmt, enum tree_code code, tree lhs, tree rhs)
2474 gimple_cond_set_code (stmt, code);
2475 gimple_cond_set_lhs (stmt, lhs);
2476 gimple_cond_set_rhs (stmt, rhs);
2479 /* Return the LABEL_DECL node used by GIMPLE_LABEL statement GS. */
2481 static inline tree
2482 gimple_label_label (const_gimple gs)
2484 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2485 return gimple_op (gs, 0);
2489 /* Set LABEL to be the LABEL_DECL node used by GIMPLE_LABEL statement
2490 GS. */
2492 static inline void
2493 gimple_label_set_label (gimple gs, tree label)
2495 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2496 gcc_assert (TREE_CODE (label) == LABEL_DECL);
2497 gimple_set_op (gs, 0, label);
2501 /* Return the destination of the unconditional jump GS. */
2503 static inline tree
2504 gimple_goto_dest (const_gimple gs)
2506 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2507 return gimple_op (gs, 0);
2511 /* Set DEST to be the destination of the unconditonal jump GS. */
2513 static inline void
2514 gimple_goto_set_dest (gimple gs, tree dest)
2516 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2517 gcc_assert (is_gimple_operand (dest));
2518 gimple_set_op (gs, 0, dest);
2522 /* Return the variables declared in the GIMPLE_BIND statement GS. */
2524 static inline tree
2525 gimple_bind_vars (const_gimple gs)
2527 GIMPLE_CHECK (gs, GIMPLE_BIND);
2528 return gs->gimple_bind.vars;
2532 /* Set VARS to be the set of variables declared in the GIMPLE_BIND
2533 statement GS. */
2535 static inline void
2536 gimple_bind_set_vars (gimple gs, tree vars)
2538 GIMPLE_CHECK (gs, GIMPLE_BIND);
2539 gs->gimple_bind.vars = vars;
2543 /* Append VARS to the set of variables declared in the GIMPLE_BIND
2544 statement GS. */
2546 static inline void
2547 gimple_bind_append_vars (gimple gs, tree vars)
2549 GIMPLE_CHECK (gs, GIMPLE_BIND);
2550 gs->gimple_bind.vars = chainon (gs->gimple_bind.vars, vars);
2554 /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS. */
2556 static inline gimple_seq
2557 gimple_bind_body (gimple gs)
2559 GIMPLE_CHECK (gs, GIMPLE_BIND);
2560 return gs->gimple_bind.body;
2564 /* Set SEQ to be the GIMPLE sequence contained in the GIMPLE_BIND
2565 statement GS. */
2567 static inline void
2568 gimple_bind_set_body (gimple gs, gimple_seq seq)
2570 GIMPLE_CHECK (gs, GIMPLE_BIND);
2571 gs->gimple_bind.body = seq;
2575 /* Append a statement to the end of a GIMPLE_BIND's body. */
2577 static inline void
2578 gimple_bind_add_stmt (gimple gs, gimple stmt)
2580 GIMPLE_CHECK (gs, GIMPLE_BIND);
2581 gimple_seq_add_stmt (&gs->gimple_bind.body, stmt);
2585 /* Append a sequence of statements to the end of a GIMPLE_BIND's body. */
2587 static inline void
2588 gimple_bind_add_seq (gimple gs, gimple_seq seq)
2590 GIMPLE_CHECK (gs, GIMPLE_BIND);
2591 gimple_seq_add_seq (&gs->gimple_bind.body, seq);
2595 /* Return the TREE_BLOCK node associated with GIMPLE_BIND statement
2596 GS. This is analogous to the BIND_EXPR_BLOCK field in trees. */
2598 static inline tree
2599 gimple_bind_block (const_gimple gs)
2601 GIMPLE_CHECK (gs, GIMPLE_BIND);
2602 return gs->gimple_bind.block;
2606 /* Set BLOCK to be the TREE_BLOCK node associated with GIMPLE_BIND
2607 statement GS. */
2609 static inline void
2610 gimple_bind_set_block (gimple gs, tree block)
2612 GIMPLE_CHECK (gs, GIMPLE_BIND);
2613 gcc_assert (block == NULL_TREE || TREE_CODE (block) == BLOCK);
2614 gs->gimple_bind.block = block;
2618 /* Return the number of input operands for GIMPLE_ASM GS. */
2620 static inline unsigned
2621 gimple_asm_ninputs (const_gimple gs)
2623 GIMPLE_CHECK (gs, GIMPLE_ASM);
2624 return gs->gimple_asm.ni;
2628 /* Return the number of output operands for GIMPLE_ASM GS. */
2630 static inline unsigned
2631 gimple_asm_noutputs (const_gimple gs)
2633 GIMPLE_CHECK (gs, GIMPLE_ASM);
2634 return gs->gimple_asm.no;
2638 /* Return the number of clobber operands for GIMPLE_ASM GS. */
2640 static inline unsigned
2641 gimple_asm_nclobbers (const_gimple gs)
2643 GIMPLE_CHECK (gs, GIMPLE_ASM);
2644 return gs->gimple_asm.nc;
2648 /* Return input operand INDEX of GIMPLE_ASM GS. */
2650 static inline tree
2651 gimple_asm_input_op (const_gimple gs, unsigned index)
2653 GIMPLE_CHECK (gs, GIMPLE_ASM);
2654 gcc_assert (index <= gs->gimple_asm.ni);
2655 return gimple_op (gs, index);
2658 /* Return a pointer to input operand INDEX of GIMPLE_ASM GS. */
2660 static inline tree *
2661 gimple_asm_input_op_ptr (const_gimple gs, unsigned index)
2663 GIMPLE_CHECK (gs, GIMPLE_ASM);
2664 gcc_assert (index <= gs->gimple_asm.ni);
2665 return gimple_op_ptr (gs, index);
2669 /* Set IN_OP to be input operand INDEX in GIMPLE_ASM GS. */
2671 static inline void
2672 gimple_asm_set_input_op (gimple gs, unsigned index, tree in_op)
2674 GIMPLE_CHECK (gs, GIMPLE_ASM);
2675 gcc_assert (index <= gs->gimple_asm.ni);
2676 gcc_assert (TREE_CODE (in_op) == TREE_LIST);
2677 gimple_set_op (gs, index, in_op);
2681 /* Return output operand INDEX of GIMPLE_ASM GS. */
2683 static inline tree
2684 gimple_asm_output_op (const_gimple gs, unsigned index)
2686 GIMPLE_CHECK (gs, GIMPLE_ASM);
2687 gcc_assert (index <= gs->gimple_asm.no);
2688 return gimple_op (gs, index + gs->gimple_asm.ni);
2691 /* Return a pointer to output operand INDEX of GIMPLE_ASM GS. */
2693 static inline tree *
2694 gimple_asm_output_op_ptr (const_gimple gs, unsigned index)
2696 GIMPLE_CHECK (gs, GIMPLE_ASM);
2697 gcc_assert (index <= gs->gimple_asm.no);
2698 return gimple_op_ptr (gs, index + gs->gimple_asm.ni);
2702 /* Set OUT_OP to be output operand INDEX in GIMPLE_ASM GS. */
2704 static inline void
2705 gimple_asm_set_output_op (gimple gs, unsigned index, tree out_op)
2707 GIMPLE_CHECK (gs, GIMPLE_ASM);
2708 gcc_assert (index <= gs->gimple_asm.no);
2709 gcc_assert (TREE_CODE (out_op) == TREE_LIST);
2710 gimple_set_op (gs, index + gs->gimple_asm.ni, out_op);
2714 /* Return clobber operand INDEX of GIMPLE_ASM GS. */
2716 static inline tree
2717 gimple_asm_clobber_op (const_gimple gs, unsigned index)
2719 GIMPLE_CHECK (gs, GIMPLE_ASM);
2720 gcc_assert (index <= gs->gimple_asm.nc);
2721 return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no);
2725 /* Set CLOBBER_OP to be clobber operand INDEX in GIMPLE_ASM GS. */
2727 static inline void
2728 gimple_asm_set_clobber_op (gimple gs, unsigned index, tree clobber_op)
2730 GIMPLE_CHECK (gs, GIMPLE_ASM);
2731 gcc_assert (index <= gs->gimple_asm.nc);
2732 gcc_assert (TREE_CODE (clobber_op) == TREE_LIST);
2733 gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no, clobber_op);
2737 /* Return the string representing the assembly instruction in
2738 GIMPLE_ASM GS. */
2740 static inline const char *
2741 gimple_asm_string (const_gimple gs)
2743 GIMPLE_CHECK (gs, GIMPLE_ASM);
2744 return gs->gimple_asm.string;
2748 /* Return true if GS is an asm statement marked volatile. */
2750 static inline bool
2751 gimple_asm_volatile_p (const_gimple gs)
2753 GIMPLE_CHECK (gs, GIMPLE_ASM);
2754 return (gs->gsbase.subcode & GF_ASM_VOLATILE) != 0;
2758 /* If VOLATLE_P is true, mark asm statement GS as volatile. */
2760 static inline void
2761 gimple_asm_set_volatile (gimple gs, bool volatile_p)
2763 GIMPLE_CHECK (gs, GIMPLE_ASM);
2764 if (volatile_p)
2765 gs->gsbase.subcode |= GF_ASM_VOLATILE;
2766 else
2767 gs->gsbase.subcode &= ~GF_ASM_VOLATILE;
2771 /* If INPUT_P is true, mark asm GS as an ASM_INPUT. */
2773 static inline void
2774 gimple_asm_set_input (gimple gs, bool input_p)
2776 GIMPLE_CHECK (gs, GIMPLE_ASM);
2777 if (input_p)
2778 gs->gsbase.subcode |= GF_ASM_INPUT;
2779 else
2780 gs->gsbase.subcode &= ~GF_ASM_INPUT;
2784 /* Return true if asm GS is an ASM_INPUT. */
2786 static inline bool
2787 gimple_asm_input_p (const_gimple gs)
2789 GIMPLE_CHECK (gs, GIMPLE_ASM);
2790 return (gs->gsbase.subcode & GF_ASM_INPUT) != 0;
2794 /* Return the types handled by GIMPLE_CATCH statement GS. */
2796 static inline tree
2797 gimple_catch_types (const_gimple gs)
2799 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2800 return gs->gimple_catch.types;
2804 /* Return a pointer to the types handled by GIMPLE_CATCH statement GS. */
2806 static inline tree *
2807 gimple_catch_types_ptr (gimple gs)
2809 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2810 return &gs->gimple_catch.types;
2814 /* Return the GIMPLE sequence representing the body of the handler of
2815 GIMPLE_CATCH statement GS. */
2817 static inline gimple_seq
2818 gimple_catch_handler (gimple gs)
2820 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2821 return gs->gimple_catch.handler;
2825 /* Return a pointer to the GIMPLE sequence representing the body of
2826 the handler of GIMPLE_CATCH statement GS. */
2828 static inline gimple_seq *
2829 gimple_catch_handler_ptr (gimple gs)
2831 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2832 return &gs->gimple_catch.handler;
2836 /* Set T to be the set of types handled by GIMPLE_CATCH GS. */
2838 static inline void
2839 gimple_catch_set_types (gimple gs, tree t)
2841 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2842 gs->gimple_catch.types = t;
2846 /* Set HANDLER to be the body of GIMPLE_CATCH GS. */
2848 static inline void
2849 gimple_catch_set_handler (gimple gs, gimple_seq handler)
2851 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2852 gs->gimple_catch.handler = handler;
2856 /* Return the types handled by GIMPLE_EH_FILTER statement GS. */
2858 static inline tree
2859 gimple_eh_filter_types (const_gimple gs)
2861 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2862 return gs->gimple_eh_filter.types;
2866 /* Return a pointer to the types handled by GIMPLE_EH_FILTER statement
2867 GS. */
2869 static inline tree *
2870 gimple_eh_filter_types_ptr (gimple gs)
2872 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2873 return &gs->gimple_eh_filter.types;
2877 /* Return the sequence of statement to execute when GIMPLE_EH_FILTER
2878 statement fails. */
2880 static inline gimple_seq
2881 gimple_eh_filter_failure (gimple gs)
2883 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2884 return gs->gimple_eh_filter.failure;
2888 /* Set TYPES to be the set of types handled by GIMPLE_EH_FILTER GS. */
2890 static inline void
2891 gimple_eh_filter_set_types (gimple gs, tree types)
2893 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2894 gs->gimple_eh_filter.types = types;
2898 /* Set FAILURE to be the sequence of statements to execute on failure
2899 for GIMPLE_EH_FILTER GS. */
2901 static inline void
2902 gimple_eh_filter_set_failure (gimple gs, gimple_seq failure)
2904 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2905 gs->gimple_eh_filter.failure = failure;
2908 /* Return the EH_FILTER_MUST_NOT_THROW flag. */
2910 static inline bool
2912 gimple_eh_filter_must_not_throw (gimple gs)
2914 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2915 return gs->gsbase.subcode != 0;
2918 /* Set the EH_FILTER_MUST_NOT_THROW flag to the value MNTP. */
2920 static inline void
2921 gimple_eh_filter_set_must_not_throw (gimple gs, bool mntp)
2923 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2924 gs->gsbase.subcode = (unsigned int) mntp;
2928 /* GIMPLE_TRY accessors. */
2930 /* Return the kind of try block represented by GIMPLE_TRY GS. This is
2931 either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY. */
2933 static inline enum gimple_try_flags
2934 gimple_try_kind (const_gimple gs)
2936 GIMPLE_CHECK (gs, GIMPLE_TRY);
2937 return (enum gimple_try_flags) (gs->gsbase.subcode & GIMPLE_TRY_KIND);
2941 /* Set the kind of try block represented by GIMPLE_TRY GS. */
2943 static inline void
2944 gimple_try_set_kind (gimple gs, enum gimple_try_flags kind)
2946 GIMPLE_CHECK (gs, GIMPLE_TRY);
2947 gcc_assert (kind == GIMPLE_TRY_CATCH || kind == GIMPLE_TRY_FINALLY);
2948 if (gimple_try_kind (gs) != kind)
2949 gs->gsbase.subcode = (unsigned int) kind;
2953 /* Return the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2955 static inline bool
2956 gimple_try_catch_is_cleanup (const_gimple gs)
2958 gcc_assert (gimple_try_kind (gs) == GIMPLE_TRY_CATCH);
2959 return (gs->gsbase.subcode & GIMPLE_TRY_CATCH_IS_CLEANUP) != 0;
2963 /* Return the sequence of statements used as the body for GIMPLE_TRY GS. */
2965 static inline gimple_seq
2966 gimple_try_eval (gimple gs)
2968 GIMPLE_CHECK (gs, GIMPLE_TRY);
2969 return gs->gimple_try.eval;
2973 /* Return the sequence of statements used as the cleanup body for
2974 GIMPLE_TRY GS. */
2976 static inline gimple_seq
2977 gimple_try_cleanup (gimple gs)
2979 GIMPLE_CHECK (gs, GIMPLE_TRY);
2980 return gs->gimple_try.cleanup;
2984 /* Set the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2986 static inline void
2987 gimple_try_set_catch_is_cleanup (gimple g, bool catch_is_cleanup)
2989 gcc_assert (gimple_try_kind (g) == GIMPLE_TRY_CATCH);
2990 if (catch_is_cleanup)
2991 g->gsbase.subcode |= GIMPLE_TRY_CATCH_IS_CLEANUP;
2992 else
2993 g->gsbase.subcode &= ~GIMPLE_TRY_CATCH_IS_CLEANUP;
2997 /* Set EVAL to be the sequence of statements to use as the body for
2998 GIMPLE_TRY GS. */
3000 static inline void
3001 gimple_try_set_eval (gimple gs, gimple_seq eval)
3003 GIMPLE_CHECK (gs, GIMPLE_TRY);
3004 gs->gimple_try.eval = eval;
3008 /* Set CLEANUP to be the sequence of statements to use as the cleanup
3009 body for GIMPLE_TRY GS. */
3011 static inline void
3012 gimple_try_set_cleanup (gimple gs, gimple_seq cleanup)
3014 GIMPLE_CHECK (gs, GIMPLE_TRY);
3015 gs->gimple_try.cleanup = cleanup;
3019 /* Return the cleanup sequence for cleanup statement GS. */
3021 static inline gimple_seq
3022 gimple_wce_cleanup (gimple gs)
3024 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3025 return gs->gimple_wce.cleanup;
3029 /* Set CLEANUP to be the cleanup sequence for GS. */
3031 static inline void
3032 gimple_wce_set_cleanup (gimple gs, gimple_seq cleanup)
3034 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3035 gs->gimple_wce.cleanup = cleanup;
3039 /* Return the CLEANUP_EH_ONLY flag for a WCE tuple. */
3041 static inline bool
3042 gimple_wce_cleanup_eh_only (const_gimple gs)
3044 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3045 return gs->gsbase.subcode != 0;
3049 /* Set the CLEANUP_EH_ONLY flag for a WCE tuple. */
3051 static inline void
3052 gimple_wce_set_cleanup_eh_only (gimple gs, bool eh_only_p)
3054 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3055 gs->gsbase.subcode = (unsigned int) eh_only_p;
3059 /* Return the maximum number of arguments supported by GIMPLE_PHI GS. */
3061 static inline unsigned
3062 gimple_phi_capacity (const_gimple gs)
3064 GIMPLE_CHECK (gs, GIMPLE_PHI);
3065 return gs->gimple_phi.capacity;
3069 /* Return the number of arguments in GIMPLE_PHI GS. This must always
3070 be exactly the number of incoming edges for the basic block holding
3071 GS. */
3073 static inline unsigned
3074 gimple_phi_num_args (const_gimple gs)
3076 GIMPLE_CHECK (gs, GIMPLE_PHI);
3077 return gs->gimple_phi.nargs;
3081 /* Return the SSA name created by GIMPLE_PHI GS. */
3083 static inline tree
3084 gimple_phi_result (const_gimple gs)
3086 GIMPLE_CHECK (gs, GIMPLE_PHI);
3087 return gs->gimple_phi.result;
3090 /* Return a pointer to the SSA name created by GIMPLE_PHI GS. */
3092 static inline tree *
3093 gimple_phi_result_ptr (gimple gs)
3095 GIMPLE_CHECK (gs, GIMPLE_PHI);
3096 return &gs->gimple_phi.result;
3099 /* Set RESULT to be the SSA name created by GIMPLE_PHI GS. */
3101 static inline void
3102 gimple_phi_set_result (gimple gs, tree result)
3104 GIMPLE_CHECK (gs, GIMPLE_PHI);
3105 gs->gimple_phi.result = result;
3109 /* Return the PHI argument corresponding to incoming edge INDEX for
3110 GIMPLE_PHI GS. */
3112 static inline struct phi_arg_d *
3113 gimple_phi_arg (gimple gs, unsigned index)
3115 GIMPLE_CHECK (gs, GIMPLE_PHI);
3116 gcc_assert (index <= gs->gimple_phi.capacity);
3117 return &(gs->gimple_phi.args[index]);
3120 /* Set PHIARG to be the argument corresponding to incoming edge INDEX
3121 for GIMPLE_PHI GS. */
3123 static inline void
3124 gimple_phi_set_arg (gimple gs, unsigned index, struct phi_arg_d * phiarg)
3126 GIMPLE_CHECK (gs, GIMPLE_PHI);
3127 gcc_assert (index <= gs->gimple_phi.nargs);
3128 memcpy (gs->gimple_phi.args + index, phiarg, sizeof (struct phi_arg_d));
3131 /* Return the region number for GIMPLE_RESX GS. */
3133 static inline int
3134 gimple_resx_region (const_gimple gs)
3136 GIMPLE_CHECK (gs, GIMPLE_RESX);
3137 return gs->gimple_resx.region;
3140 /* Set REGION to be the region number for GIMPLE_RESX GS. */
3142 static inline void
3143 gimple_resx_set_region (gimple gs, int region)
3145 GIMPLE_CHECK (gs, GIMPLE_RESX);
3146 gs->gimple_resx.region = region;
3150 /* Return the number of labels associated with the switch statement GS. */
3152 static inline unsigned
3153 gimple_switch_num_labels (const_gimple gs)
3155 unsigned num_ops;
3156 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3157 num_ops = gimple_num_ops (gs);
3158 gcc_assert (num_ops > 1);
3159 return num_ops - 1;
3163 /* Set NLABELS to be the number of labels for the switch statement GS. */
3165 static inline void
3166 gimple_switch_set_num_labels (gimple g, unsigned nlabels)
3168 GIMPLE_CHECK (g, GIMPLE_SWITCH);
3169 gimple_set_num_ops (g, nlabels + 1);
3173 /* Return the index variable used by the switch statement GS. */
3175 static inline tree
3176 gimple_switch_index (const_gimple gs)
3178 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3179 return gimple_op (gs, 0);
3183 /* Return a pointer to the index variable for the switch statement GS. */
3185 static inline tree *
3186 gimple_switch_index_ptr (const_gimple gs)
3188 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3189 return gimple_op_ptr (gs, 0);
3193 /* Set INDEX to be the index variable for switch statement GS. */
3195 static inline void
3196 gimple_switch_set_index (gimple gs, tree index)
3198 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3199 gcc_assert (SSA_VAR_P (index) || CONSTANT_CLASS_P (index));
3200 gimple_set_op (gs, 0, index);
3204 /* Return the label numbered INDEX. The default label is 0, followed by any
3205 labels in a switch statement. */
3207 static inline tree
3208 gimple_switch_label (const_gimple gs, unsigned index)
3210 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3211 gcc_assert (gimple_num_ops (gs) > index + 1);
3212 return gimple_op (gs, index + 1);
3215 /* Set the label number INDEX to LABEL. 0 is always the default label. */
3217 static inline void
3218 gimple_switch_set_label (gimple gs, unsigned index, tree label)
3220 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3221 gcc_assert (gimple_num_ops (gs) > index + 1);
3222 gcc_assert (label == NULL_TREE || TREE_CODE (label) == CASE_LABEL_EXPR);
3223 gimple_set_op (gs, index + 1, label);
3226 /* Return the default label for a switch statement. */
3228 static inline tree
3229 gimple_switch_default_label (const_gimple gs)
3231 return gimple_switch_label (gs, 0);
3234 /* Set the default label for a switch statement. */
3236 static inline void
3237 gimple_switch_set_default_label (gimple gs, tree label)
3239 gimple_switch_set_label (gs, 0, label);
3243 /* Return the body for the OMP statement GS. */
3245 static inline gimple_seq
3246 gimple_omp_body (gimple gs)
3248 return gs->omp.body;
3251 /* Set BODY to be the body for the OMP statement GS. */
3253 static inline void
3254 gimple_omp_set_body (gimple gs, gimple_seq body)
3256 gs->omp.body = body;
3260 /* Return the name associated with OMP_CRITICAL statement GS. */
3262 static inline tree
3263 gimple_omp_critical_name (const_gimple gs)
3265 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3266 return gs->gimple_omp_critical.name;
3270 /* Return a pointer to the name associated with OMP critical statement GS. */
3272 static inline tree *
3273 gimple_omp_critical_name_ptr (gimple gs)
3275 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3276 return &gs->gimple_omp_critical.name;
3280 /* Set NAME to be the name associated with OMP critical statement GS. */
3282 static inline void
3283 gimple_omp_critical_set_name (gimple gs, tree name)
3285 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3286 gs->gimple_omp_critical.name = name;
3290 /* Return the clauses associated with OMP_FOR GS. */
3292 static inline tree
3293 gimple_omp_for_clauses (const_gimple gs)
3295 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3296 return gs->gimple_omp_for.clauses;
3300 /* Return a pointer to the OMP_FOR GS. */
3302 static inline tree *
3303 gimple_omp_for_clauses_ptr (gimple gs)
3305 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3306 return &gs->gimple_omp_for.clauses;
3310 /* Set CLAUSES to be the list of clauses associated with OMP_FOR GS. */
3312 static inline void
3313 gimple_omp_for_set_clauses (gimple gs, tree clauses)
3315 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3316 gs->gimple_omp_for.clauses = clauses;
3320 /* Get the collapse count of OMP_FOR GS. */
3322 static inline size_t
3323 gimple_omp_for_collapse (gimple gs)
3325 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3326 return gs->gimple_omp_for.collapse;
3330 /* Return the index variable for OMP_FOR GS. */
3332 static inline tree
3333 gimple_omp_for_index (const_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 /* Return a pointer to the index variable for OMP_FOR GS. */
3343 static inline tree *
3344 gimple_omp_for_index_ptr (gimple gs, size_t i)
3346 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3347 gcc_assert (i < gs->gimple_omp_for.collapse);
3348 return &gs->gimple_omp_for.iter[i].index;
3352 /* Set INDEX to be the index variable for OMP_FOR GS. */
3354 static inline void
3355 gimple_omp_for_set_index (gimple gs, size_t i, tree index)
3357 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3358 gcc_assert (i < gs->gimple_omp_for.collapse);
3359 gs->gimple_omp_for.iter[i].index = index;
3363 /* Return the initial value for OMP_FOR GS. */
3365 static inline tree
3366 gimple_omp_for_initial (const_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 /* Return a pointer to the initial value for OMP_FOR GS. */
3376 static inline tree *
3377 gimple_omp_for_initial_ptr (gimple gs, size_t i)
3379 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3380 gcc_assert (i < gs->gimple_omp_for.collapse);
3381 return &gs->gimple_omp_for.iter[i].initial;
3385 /* Set INITIAL to be the initial value for OMP_FOR GS. */
3387 static inline void
3388 gimple_omp_for_set_initial (gimple gs, size_t i, tree initial)
3390 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3391 gcc_assert (i < gs->gimple_omp_for.collapse);
3392 gs->gimple_omp_for.iter[i].initial = initial;
3396 /* Return the final value for OMP_FOR GS. */
3398 static inline tree
3399 gimple_omp_for_final (const_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 /* Return a pointer to the final value for OMP_FOR GS. */
3409 static inline tree *
3410 gimple_omp_for_final_ptr (gimple gs, size_t i)
3412 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3413 gcc_assert (i < gs->gimple_omp_for.collapse);
3414 return &gs->gimple_omp_for.iter[i].final;
3418 /* Set FINAL to be the final value for OMP_FOR GS. */
3420 static inline void
3421 gimple_omp_for_set_final (gimple gs, size_t i, tree final)
3423 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3424 gcc_assert (i < gs->gimple_omp_for.collapse);
3425 gs->gimple_omp_for.iter[i].final = final;
3429 /* Return the increment value for OMP_FOR GS. */
3431 static inline tree
3432 gimple_omp_for_incr (const_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 /* Return a pointer to the increment value for OMP_FOR GS. */
3442 static inline tree *
3443 gimple_omp_for_incr_ptr (gimple gs, size_t i)
3445 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3446 gcc_assert (i < gs->gimple_omp_for.collapse);
3447 return &gs->gimple_omp_for.iter[i].incr;
3451 /* Set INCR to be the increment value for OMP_FOR GS. */
3453 static inline void
3454 gimple_omp_for_set_incr (gimple gs, size_t i, tree incr)
3456 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3457 gcc_assert (i < gs->gimple_omp_for.collapse);
3458 gs->gimple_omp_for.iter[i].incr = incr;
3462 /* Return the sequence of statements to execute before the OMP_FOR
3463 statement GS starts. */
3465 static inline gimple_seq
3466 gimple_omp_for_pre_body (gimple gs)
3468 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3469 return gs->gimple_omp_for.pre_body;
3473 /* Set PRE_BODY to be the sequence of statements to execute before the
3474 OMP_FOR statement GS starts. */
3476 static inline void
3477 gimple_omp_for_set_pre_body (gimple gs, gimple_seq pre_body)
3479 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3480 gs->gimple_omp_for.pre_body = pre_body;
3484 /* Return the clauses associated with OMP_PARALLEL GS. */
3486 static inline tree
3487 gimple_omp_parallel_clauses (const_gimple gs)
3489 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3490 return gs->gimple_omp_parallel.clauses;
3494 /* Return a pointer to the clauses associated with OMP_PARALLEL GS. */
3496 static inline tree *
3497 gimple_omp_parallel_clauses_ptr (gimple gs)
3499 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3500 return &gs->gimple_omp_parallel.clauses;
3504 /* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL
3505 GS. */
3507 static inline void
3508 gimple_omp_parallel_set_clauses (gimple gs, tree clauses)
3510 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3511 gs->gimple_omp_parallel.clauses = clauses;
3515 /* Return the child function used to hold the body of OMP_PARALLEL GS. */
3517 static inline tree
3518 gimple_omp_parallel_child_fn (const_gimple gs)
3520 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3521 return gs->gimple_omp_parallel.child_fn;
3524 /* Return a pointer to the child function used to hold the body of
3525 OMP_PARALLEL GS. */
3527 static inline tree *
3528 gimple_omp_parallel_child_fn_ptr (gimple gs)
3530 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3531 return &gs->gimple_omp_parallel.child_fn;
3535 /* Set CHILD_FN to be the child function for OMP_PARALLEL GS. */
3537 static inline void
3538 gimple_omp_parallel_set_child_fn (gimple gs, tree child_fn)
3540 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3541 gs->gimple_omp_parallel.child_fn = child_fn;
3545 /* Return the artificial argument used to send variables and values
3546 from the parent to the children threads in OMP_PARALLEL GS. */
3548 static inline tree
3549 gimple_omp_parallel_data_arg (const_gimple gs)
3551 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3552 return gs->gimple_omp_parallel.data_arg;
3556 /* Return a pointer to the data argument for OMP_PARALLEL GS. */
3558 static inline tree *
3559 gimple_omp_parallel_data_arg_ptr (gimple gs)
3561 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3562 return &gs->gimple_omp_parallel.data_arg;
3566 /* Set DATA_ARG to be the data argument for OMP_PARALLEL GS. */
3568 static inline void
3569 gimple_omp_parallel_set_data_arg (gimple gs, tree data_arg)
3571 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3572 gs->gimple_omp_parallel.data_arg = data_arg;
3576 /* Return the clauses associated with OMP_TASK GS. */
3578 static inline tree
3579 gimple_omp_task_clauses (const_gimple gs)
3581 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3582 return gs->gimple_omp_parallel.clauses;
3586 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3588 static inline tree *
3589 gimple_omp_task_clauses_ptr (gimple gs)
3591 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3592 return &gs->gimple_omp_parallel.clauses;
3596 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3597 GS. */
3599 static inline void
3600 gimple_omp_task_set_clauses (gimple gs, tree clauses)
3602 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3603 gs->gimple_omp_parallel.clauses = clauses;
3607 /* Return the child function used to hold the body of OMP_TASK GS. */
3609 static inline tree
3610 gimple_omp_task_child_fn (const_gimple gs)
3612 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3613 return gs->gimple_omp_parallel.child_fn;
3616 /* Return a pointer to the child function used to hold the body of
3617 OMP_TASK GS. */
3619 static inline tree *
3620 gimple_omp_task_child_fn_ptr (gimple gs)
3622 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3623 return &gs->gimple_omp_parallel.child_fn;
3627 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3629 static inline void
3630 gimple_omp_task_set_child_fn (gimple gs, tree child_fn)
3632 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3633 gs->gimple_omp_parallel.child_fn = child_fn;
3637 /* Return the artificial argument used to send variables and values
3638 from the parent to the children threads in OMP_TASK GS. */
3640 static inline tree
3641 gimple_omp_task_data_arg (const_gimple gs)
3643 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3644 return gs->gimple_omp_parallel.data_arg;
3648 /* Return a pointer to the data argument for OMP_TASK GS. */
3650 static inline tree *
3651 gimple_omp_task_data_arg_ptr (gimple gs)
3653 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3654 return &gs->gimple_omp_parallel.data_arg;
3658 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3660 static inline void
3661 gimple_omp_task_set_data_arg (gimple gs, tree data_arg)
3663 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3664 gs->gimple_omp_parallel.data_arg = data_arg;
3668 /* Return the clauses associated with OMP_TASK GS. */
3670 static inline tree
3671 gimple_omp_taskreg_clauses (const_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 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3681 static inline tree *
3682 gimple_omp_taskreg_clauses_ptr (gimple gs)
3684 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3685 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3686 return &gs->gimple_omp_parallel.clauses;
3690 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3691 GS. */
3693 static inline void
3694 gimple_omp_taskreg_set_clauses (gimple gs, tree clauses)
3696 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3697 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3698 gs->gimple_omp_parallel.clauses = clauses;
3702 /* Return the child function used to hold the body of OMP_TASK GS. */
3704 static inline tree
3705 gimple_omp_taskreg_child_fn (const_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;
3712 /* Return a pointer to the child function used to hold the body of
3713 OMP_TASK GS. */
3715 static inline tree *
3716 gimple_omp_taskreg_child_fn_ptr (gimple gs)
3718 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3719 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3720 return &gs->gimple_omp_parallel.child_fn;
3724 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3726 static inline void
3727 gimple_omp_taskreg_set_child_fn (gimple gs, tree child_fn)
3729 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3730 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3731 gs->gimple_omp_parallel.child_fn = child_fn;
3735 /* Return the artificial argument used to send variables and values
3736 from the parent to the children threads in OMP_TASK GS. */
3738 static inline tree
3739 gimple_omp_taskreg_data_arg (const_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 /* Return a pointer to the data argument for OMP_TASK GS. */
3749 static inline tree *
3750 gimple_omp_taskreg_data_arg_ptr (gimple gs)
3752 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3753 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3754 return &gs->gimple_omp_parallel.data_arg;
3758 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3760 static inline void
3761 gimple_omp_taskreg_set_data_arg (gimple gs, tree data_arg)
3763 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3764 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3765 gs->gimple_omp_parallel.data_arg = data_arg;
3769 /* Return the copy function used to hold the body of OMP_TASK GS. */
3771 static inline tree
3772 gimple_omp_task_copy_fn (const_gimple gs)
3774 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3775 return gs->gimple_omp_task.copy_fn;
3778 /* Return a pointer to the copy function used to hold the body of
3779 OMP_TASK GS. */
3781 static inline tree *
3782 gimple_omp_task_copy_fn_ptr (gimple gs)
3784 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3785 return &gs->gimple_omp_task.copy_fn;
3789 /* Set CHILD_FN to be the copy function for OMP_TASK GS. */
3791 static inline void
3792 gimple_omp_task_set_copy_fn (gimple gs, tree copy_fn)
3794 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3795 gs->gimple_omp_task.copy_fn = copy_fn;
3799 /* Return size of the data block in bytes in OMP_TASK GS. */
3801 static inline tree
3802 gimple_omp_task_arg_size (const_gimple gs)
3804 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3805 return gs->gimple_omp_task.arg_size;
3809 /* Return a pointer to the data block size for OMP_TASK GS. */
3811 static inline tree *
3812 gimple_omp_task_arg_size_ptr (gimple gs)
3814 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3815 return &gs->gimple_omp_task.arg_size;
3819 /* Set ARG_SIZE to be the data block size for OMP_TASK GS. */
3821 static inline void
3822 gimple_omp_task_set_arg_size (gimple gs, tree arg_size)
3824 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3825 gs->gimple_omp_task.arg_size = arg_size;
3829 /* Return align of the data block in bytes in OMP_TASK GS. */
3831 static inline tree
3832 gimple_omp_task_arg_align (const_gimple gs)
3834 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3835 return gs->gimple_omp_task.arg_align;
3839 /* Return a pointer to the data block align for OMP_TASK GS. */
3841 static inline tree *
3842 gimple_omp_task_arg_align_ptr (gimple gs)
3844 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3845 return &gs->gimple_omp_task.arg_align;
3849 /* Set ARG_SIZE to be the data block align for OMP_TASK GS. */
3851 static inline void
3852 gimple_omp_task_set_arg_align (gimple gs, tree arg_align)
3854 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3855 gs->gimple_omp_task.arg_align = arg_align;
3859 /* Return the clauses associated with OMP_SINGLE GS. */
3861 static inline tree
3862 gimple_omp_single_clauses (const_gimple gs)
3864 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3865 return gs->gimple_omp_single.clauses;
3869 /* Return a pointer to the clauses associated with OMP_SINGLE GS. */
3871 static inline tree *
3872 gimple_omp_single_clauses_ptr (gimple gs)
3874 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3875 return &gs->gimple_omp_single.clauses;
3879 /* Set CLAUSES to be the clauses associated with OMP_SINGLE GS. */
3881 static inline void
3882 gimple_omp_single_set_clauses (gimple gs, tree clauses)
3884 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3885 gs->gimple_omp_single.clauses = clauses;
3889 /* Return the clauses associated with OMP_SECTIONS GS. */
3891 static inline tree
3892 gimple_omp_sections_clauses (const_gimple gs)
3894 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3895 return gs->gimple_omp_sections.clauses;
3899 /* Return a pointer to the clauses associated with OMP_SECTIONS GS. */
3901 static inline tree *
3902 gimple_omp_sections_clauses_ptr (gimple gs)
3904 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3905 return &gs->gimple_omp_sections.clauses;
3909 /* Set CLAUSES to be the set of clauses associated with OMP_SECTIONS
3910 GS. */
3912 static inline void
3913 gimple_omp_sections_set_clauses (gimple gs, tree clauses)
3915 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3916 gs->gimple_omp_sections.clauses = clauses;
3920 /* Return the control variable associated with the GIMPLE_OMP_SECTIONS
3921 in GS. */
3923 static inline tree
3924 gimple_omp_sections_control (const_gimple gs)
3926 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3927 return gs->gimple_omp_sections.control;
3931 /* Return a pointer to the clauses associated with the GIMPLE_OMP_SECTIONS
3932 GS. */
3934 static inline tree *
3935 gimple_omp_sections_control_ptr (gimple gs)
3937 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3938 return &gs->gimple_omp_sections.control;
3942 /* Set CONTROL to be the set of clauses associated with the
3943 GIMPLE_OMP_SECTIONS in GS. */
3945 static inline void
3946 gimple_omp_sections_set_control (gimple gs, tree control)
3948 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3949 gs->gimple_omp_sections.control = control;
3953 /* Set COND to be the condition code for OMP_FOR GS. */
3955 static inline void
3956 gimple_omp_for_set_cond (gimple gs, size_t i, enum tree_code cond)
3958 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3959 gcc_assert (TREE_CODE_CLASS (cond) == tcc_comparison);
3960 gcc_assert (i < gs->gimple_omp_for.collapse);
3961 gs->gimple_omp_for.iter[i].cond = cond;
3965 /* Return the condition code associated with OMP_FOR GS. */
3967 static inline enum tree_code
3968 gimple_omp_for_cond (const_gimple gs, size_t i)
3970 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3971 gcc_assert (i < gs->gimple_omp_for.collapse);
3972 return gs->gimple_omp_for.iter[i].cond;
3976 /* Set the value being stored in an atomic store. */
3978 static inline void
3979 gimple_omp_atomic_store_set_val (gimple g, tree val)
3981 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3982 g->gimple_omp_atomic_store.val = val;
3986 /* Return the value being stored in an atomic store. */
3988 static inline tree
3989 gimple_omp_atomic_store_val (const_gimple g)
3991 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3992 return g->gimple_omp_atomic_store.val;
3996 /* Return a pointer to the value being stored in an atomic store. */
3998 static inline tree *
3999 gimple_omp_atomic_store_val_ptr (gimple g)
4001 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4002 return &g->gimple_omp_atomic_store.val;
4006 /* Set the LHS of an atomic load. */
4008 static inline void
4009 gimple_omp_atomic_load_set_lhs (gimple g, tree lhs)
4011 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4012 g->gimple_omp_atomic_load.lhs = lhs;
4016 /* Get the LHS of an atomic load. */
4018 static inline tree
4019 gimple_omp_atomic_load_lhs (const_gimple g)
4021 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4022 return g->gimple_omp_atomic_load.lhs;
4026 /* Return a pointer to the LHS of an atomic load. */
4028 static inline tree *
4029 gimple_omp_atomic_load_lhs_ptr (gimple g)
4031 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4032 return &g->gimple_omp_atomic_load.lhs;
4036 /* Set the RHS of an atomic load. */
4038 static inline void
4039 gimple_omp_atomic_load_set_rhs (gimple g, tree rhs)
4041 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4042 g->gimple_omp_atomic_load.rhs = rhs;
4046 /* Get the RHS of an atomic load. */
4048 static inline tree
4049 gimple_omp_atomic_load_rhs (const_gimple g)
4051 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4052 return g->gimple_omp_atomic_load.rhs;
4056 /* Return a pointer to the RHS of an atomic load. */
4058 static inline tree *
4059 gimple_omp_atomic_load_rhs_ptr (gimple g)
4061 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4062 return &g->gimple_omp_atomic_load.rhs;
4066 /* Get the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4068 static inline tree
4069 gimple_omp_continue_control_def (const_gimple g)
4071 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4072 return g->gimple_omp_continue.control_def;
4075 /* The same as above, but return the address. */
4077 static inline tree *
4078 gimple_omp_continue_control_def_ptr (gimple g)
4080 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4081 return &g->gimple_omp_continue.control_def;
4084 /* Set the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4086 static inline void
4087 gimple_omp_continue_set_control_def (gimple g, tree def)
4089 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4090 g->gimple_omp_continue.control_def = def;
4094 /* Get the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4096 static inline tree
4097 gimple_omp_continue_control_use (const_gimple g)
4099 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4100 return g->gimple_omp_continue.control_use;
4104 /* The same as above, but return the address. */
4106 static inline tree *
4107 gimple_omp_continue_control_use_ptr (gimple g)
4109 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4110 return &g->gimple_omp_continue.control_use;
4114 /* Set the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4116 static inline void
4117 gimple_omp_continue_set_control_use (gimple g, tree use)
4119 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4120 g->gimple_omp_continue.control_use = use;
4124 /* Return a pointer to the return value for GIMPLE_RETURN GS. */
4126 static inline tree *
4127 gimple_return_retval_ptr (const_gimple gs)
4129 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4130 gcc_assert (gimple_num_ops (gs) == 1);
4131 return gimple_op_ptr (gs, 0);
4134 /* Return the return value for GIMPLE_RETURN GS. */
4136 static inline tree
4137 gimple_return_retval (const_gimple gs)
4139 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4140 gcc_assert (gimple_num_ops (gs) == 1);
4141 return gimple_op (gs, 0);
4145 /* Set RETVAL to be the return value for GIMPLE_RETURN GS. */
4147 static inline void
4148 gimple_return_set_retval (gimple gs, tree retval)
4150 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4151 gcc_assert (gimple_num_ops (gs) == 1);
4152 gcc_assert (retval == NULL_TREE
4153 || TREE_CODE (retval) == RESULT_DECL
4154 || is_gimple_val (retval));
4155 gimple_set_op (gs, 0, retval);
4159 /* Returns true when the gimple statment STMT is any of the OpenMP types. */
4161 static inline bool
4162 is_gimple_omp (const_gimple stmt)
4164 return (gimple_code (stmt) == GIMPLE_OMP_PARALLEL
4165 || gimple_code (stmt) == GIMPLE_OMP_TASK
4166 || gimple_code (stmt) == GIMPLE_OMP_FOR
4167 || gimple_code (stmt) == GIMPLE_OMP_SECTIONS
4168 || gimple_code (stmt) == GIMPLE_OMP_SECTIONS_SWITCH
4169 || gimple_code (stmt) == GIMPLE_OMP_SINGLE
4170 || gimple_code (stmt) == GIMPLE_OMP_SECTION
4171 || gimple_code (stmt) == GIMPLE_OMP_MASTER
4172 || gimple_code (stmt) == GIMPLE_OMP_ORDERED
4173 || gimple_code (stmt) == GIMPLE_OMP_CRITICAL
4174 || gimple_code (stmt) == GIMPLE_OMP_RETURN
4175 || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_LOAD
4176 || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_STORE
4177 || gimple_code (stmt) == GIMPLE_OMP_CONTINUE);
4181 /* Returns TRUE if statement G is a GIMPLE_NOP. */
4183 static inline bool
4184 gimple_nop_p (const_gimple g)
4186 return gimple_code (g) == GIMPLE_NOP;
4190 /* Return the new type set by GIMPLE_CHANGE_DYNAMIC_TYPE statement GS. */
4192 static inline tree
4193 gimple_cdt_new_type (gimple gs)
4195 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4196 return gimple_op (gs, 1);
4199 /* Return a pointer to the new type set by GIMPLE_CHANGE_DYNAMIC_TYPE
4200 statement GS. */
4202 static inline tree *
4203 gimple_cdt_new_type_ptr (gimple gs)
4205 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4206 return gimple_op_ptr (gs, 1);
4209 /* Set NEW_TYPE to be the type returned by GIMPLE_CHANGE_DYNAMIC_TYPE
4210 statement GS. */
4212 static inline void
4213 gimple_cdt_set_new_type (gimple gs, tree new_type)
4215 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4216 gcc_assert (TREE_CODE_CLASS (TREE_CODE (new_type)) == tcc_type);
4217 gimple_set_op (gs, 1, new_type);
4221 /* Return the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE statement GS. */
4223 static inline tree
4224 gimple_cdt_location (gimple gs)
4226 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4227 return gimple_op (gs, 0);
4231 /* Return a pointer to the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE
4232 statement GS. */
4234 static inline tree *
4235 gimple_cdt_location_ptr (gimple gs)
4237 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4238 return gimple_op_ptr (gs, 0);
4242 /* Set PTR to be the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE
4243 statement GS. */
4245 static inline void
4246 gimple_cdt_set_location (gimple gs, tree ptr)
4248 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4249 gimple_set_op (gs, 0, ptr);
4253 /* Return the predictor of GIMPLE_PREDICT statement GS. */
4255 static inline enum br_predictor
4256 gimple_predict_predictor (gimple gs)
4258 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4259 return (enum br_predictor) (gs->gsbase.subcode & ~GF_PREDICT_TAKEN);
4263 /* Set the predictor of GIMPLE_PREDICT statement GS to PREDICT. */
4265 static inline void
4266 gimple_predict_set_predictor (gimple gs, enum br_predictor predictor)
4268 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4269 gs->gsbase.subcode = (gs->gsbase.subcode & GF_PREDICT_TAKEN)
4270 | (unsigned) predictor;
4274 /* Return the outcome of GIMPLE_PREDICT statement GS. */
4276 static inline enum prediction
4277 gimple_predict_outcome (gimple gs)
4279 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4280 return (gs->gsbase.subcode & GF_PREDICT_TAKEN) ? TAKEN : NOT_TAKEN;
4284 /* Set the outcome of GIMPLE_PREDICT statement GS to OUTCOME. */
4286 static inline void
4287 gimple_predict_set_outcome (gimple gs, enum prediction outcome)
4289 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4290 if (outcome == TAKEN)
4291 gs->gsbase.subcode |= GF_PREDICT_TAKEN;
4292 else
4293 gs->gsbase.subcode &= ~GF_PREDICT_TAKEN;
4297 /* Return a new iterator pointing to GIMPLE_SEQ's first statement. */
4299 static inline gimple_stmt_iterator
4300 gsi_start (gimple_seq seq)
4302 gimple_stmt_iterator i;
4304 i.ptr = gimple_seq_first (seq);
4305 i.seq = seq;
4306 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4308 return i;
4312 /* Return a new iterator pointing to the first statement in basic block BB. */
4314 static inline gimple_stmt_iterator
4315 gsi_start_bb (basic_block bb)
4317 gimple_stmt_iterator i;
4318 gimple_seq seq;
4320 seq = bb_seq (bb);
4321 i.ptr = gimple_seq_first (seq);
4322 i.seq = seq;
4323 i.bb = bb;
4325 return i;
4329 /* Return a new iterator initially pointing to GIMPLE_SEQ's last statement. */
4331 static inline gimple_stmt_iterator
4332 gsi_last (gimple_seq seq)
4334 gimple_stmt_iterator i;
4336 i.ptr = gimple_seq_last (seq);
4337 i.seq = seq;
4338 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4340 return i;
4344 /* Return a new iterator pointing to the last statement in basic block BB. */
4346 static inline gimple_stmt_iterator
4347 gsi_last_bb (basic_block bb)
4349 gimple_stmt_iterator i;
4350 gimple_seq seq;
4352 seq = bb_seq (bb);
4353 i.ptr = gimple_seq_last (seq);
4354 i.seq = seq;
4355 i.bb = bb;
4357 return i;
4361 /* Return true if I is at the end of its sequence. */
4363 static inline bool
4364 gsi_end_p (gimple_stmt_iterator i)
4366 return i.ptr == NULL;
4370 /* Return true if I is one statement before the end of its sequence. */
4372 static inline bool
4373 gsi_one_before_end_p (gimple_stmt_iterator i)
4375 return i.ptr != NULL && i.ptr->next == NULL;
4379 /* Advance the iterator to the next gimple statement. */
4381 static inline void
4382 gsi_next (gimple_stmt_iterator *i)
4384 i->ptr = i->ptr->next;
4387 /* Advance the iterator to the previous gimple statement. */
4389 static inline void
4390 gsi_prev (gimple_stmt_iterator *i)
4392 i->ptr = i->ptr->prev;
4395 /* Return the current stmt. */
4397 static inline gimple
4398 gsi_stmt (gimple_stmt_iterator i)
4400 return i.ptr->stmt;
4403 /* Return a block statement iterator that points to the first non-label
4404 statement in block BB. */
4406 static inline gimple_stmt_iterator
4407 gsi_after_labels (basic_block bb)
4409 gimple_stmt_iterator gsi = gsi_start_bb (bb);
4411 while (!gsi_end_p (gsi) && gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL)
4412 gsi_next (&gsi);
4414 return gsi;
4417 /* Return a pointer to the current stmt.
4419 NOTE: You may want to use gsi_replace on the iterator itself,
4420 as this performs additional bookkeeping that will not be done
4421 if you simply assign through a pointer returned by gsi_stmt_ptr. */
4423 static inline gimple *
4424 gsi_stmt_ptr (gimple_stmt_iterator *i)
4426 return &i->ptr->stmt;
4430 /* Return the basic block associated with this iterator. */
4432 static inline basic_block
4433 gsi_bb (gimple_stmt_iterator i)
4435 return i.bb;
4439 /* Return the sequence associated with this iterator. */
4441 static inline gimple_seq
4442 gsi_seq (gimple_stmt_iterator i)
4444 return i.seq;
4448 enum gsi_iterator_update
4450 GSI_NEW_STMT, /* Only valid when single statement is added, move
4451 iterator to it. */
4452 GSI_SAME_STMT, /* Leave the iterator at the same statement. */
4453 GSI_CONTINUE_LINKING /* Move iterator to whatever position is suitable
4454 for linking other statements in the same
4455 direction. */
4458 /* In gimple-iterator.c */
4459 gimple_stmt_iterator gsi_start_phis (basic_block);
4460 gimple_seq gsi_split_seq_after (gimple_stmt_iterator);
4461 gimple_seq gsi_split_seq_before (gimple_stmt_iterator *);
4462 void gsi_replace (gimple_stmt_iterator *, gimple, bool);
4463 void gsi_insert_before (gimple_stmt_iterator *, gimple,
4464 enum gsi_iterator_update);
4465 void gsi_insert_before_without_update (gimple_stmt_iterator *, gimple,
4466 enum gsi_iterator_update);
4467 void gsi_insert_seq_before (gimple_stmt_iterator *, gimple_seq,
4468 enum gsi_iterator_update);
4469 void gsi_insert_seq_before_without_update (gimple_stmt_iterator *, gimple_seq,
4470 enum gsi_iterator_update);
4471 void gsi_insert_after (gimple_stmt_iterator *, gimple,
4472 enum gsi_iterator_update);
4473 void gsi_insert_after_without_update (gimple_stmt_iterator *, gimple,
4474 enum gsi_iterator_update);
4475 void gsi_insert_seq_after (gimple_stmt_iterator *, gimple_seq,
4476 enum gsi_iterator_update);
4477 void gsi_insert_seq_after_without_update (gimple_stmt_iterator *, gimple_seq,
4478 enum gsi_iterator_update);
4479 void gsi_remove (gimple_stmt_iterator *, bool);
4480 gimple_stmt_iterator gsi_for_stmt (gimple);
4481 void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *);
4482 void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *);
4483 void gsi_move_to_bb_end (gimple_stmt_iterator *, struct basic_block_def *);
4484 void gsi_insert_on_edge (edge, gimple);
4485 void gsi_insert_seq_on_edge (edge, gimple_seq);
4486 basic_block gsi_insert_on_edge_immediate (edge, gimple);
4487 basic_block gsi_insert_seq_on_edge_immediate (edge, gimple_seq);
4488 void gsi_commit_one_edge_insert (edge, basic_block *);
4489 void gsi_commit_edge_inserts (void);
4490 gimple gimple_call_copy_skip_args (gimple, bitmap);
4493 /* Convenience routines to walk all statements of a gimple function.
4494 Note that this is useful exclusively before the code is converted
4495 into SSA form. Once the program is in SSA form, the standard
4496 operand interface should be used to analyze/modify statements. */
4497 struct walk_stmt_info
4499 /* Points to the current statement being walked. */
4500 gimple_stmt_iterator gsi;
4502 /* Additional data that the callback functions may want to carry
4503 through the recursion. */
4504 void *info;
4506 /* Pointer map used to mark visited tree nodes when calling
4507 walk_tree on each operand. If set to NULL, duplicate tree nodes
4508 will be visited more than once. */
4509 struct pointer_set_t *pset;
4511 /* Indicates whether the operand being examined may be replaced
4512 with something that matches is_gimple_val (if true) or something
4513 slightly more complicated (if false). "Something" technically
4514 means the common subset of is_gimple_lvalue and is_gimple_rhs,
4515 but we never try to form anything more complicated than that, so
4516 we don't bother checking.
4518 Also note that CALLBACK should update this flag while walking the
4519 sub-expressions of a statement. For instance, when walking the
4520 statement 'foo (&var)', the flag VAL_ONLY will initially be set
4521 to true, however, when walking &var, the operand of that
4522 ADDR_EXPR does not need to be a GIMPLE value. */
4523 bool val_only;
4525 /* True if we are currently walking the LHS of an assignment. */
4526 bool is_lhs;
4528 /* Optional. Set to true by the callback functions if they made any
4529 changes. */
4530 bool changed;
4532 /* True if we're interested in location information. */
4533 bool want_locations;
4535 /* Operand returned by the callbacks. This is set when calling
4536 walk_gimple_seq. If the walk_stmt_fn or walk_tree_fn callback
4537 returns non-NULL, this field will contain the tree returned by
4538 the last callback. */
4539 tree callback_result;
4542 /* Callback for walk_gimple_stmt. Called for every statement found
4543 during traversal. The first argument points to the statement to
4544 walk. The second argument is a flag that the callback sets to
4545 'true' if it the callback handled all the operands and
4546 sub-statements of the statement (the default value of this flag is
4547 'false'). The third argument is an anonymous pointer to data
4548 to be used by the callback. */
4549 typedef tree (*walk_stmt_fn) (gimple_stmt_iterator *, bool *,
4550 struct walk_stmt_info *);
4552 gimple walk_gimple_seq (gimple_seq, walk_stmt_fn, walk_tree_fn,
4553 struct walk_stmt_info *);
4554 tree walk_gimple_stmt (gimple_stmt_iterator *, walk_stmt_fn, walk_tree_fn,
4555 struct walk_stmt_info *);
4556 tree walk_gimple_op (gimple, walk_tree_fn, struct walk_stmt_info *);
4558 #ifdef GATHER_STATISTICS
4559 /* Enum and arrays used for allocation stats. Keep in sync with
4560 gimple.c:gimple_alloc_kind_names. */
4561 enum gimple_alloc_kind
4563 gimple_alloc_kind_assign, /* Assignments. */
4564 gimple_alloc_kind_phi, /* PHI nodes. */
4565 gimple_alloc_kind_cond, /* Conditionals. */
4566 gimple_alloc_kind_seq, /* Sequences. */
4567 gimple_alloc_kind_rest, /* Everything else. */
4568 gimple_alloc_kind_all
4571 extern int gimple_alloc_counts[];
4572 extern int gimple_alloc_sizes[];
4574 /* Return the allocation kind for a given stmt CODE. */
4575 static inline enum gimple_alloc_kind
4576 gimple_alloc_kind (enum gimple_code code)
4578 switch (code)
4580 case GIMPLE_ASSIGN:
4581 return gimple_alloc_kind_assign;
4582 case GIMPLE_PHI:
4583 return gimple_alloc_kind_phi;
4584 case GIMPLE_COND:
4585 return gimple_alloc_kind_cond;
4586 default:
4587 return gimple_alloc_kind_rest;
4590 #endif /* GATHER_STATISTICS */
4592 extern void dump_gimple_statistics (void);
4594 #endif /* GCC_GIMPLE_H */