gimple.h (struct gimple_statement_base): Document the restrictions on its use.
[official-gcc.git] / gcc / gimple.h
blob7760e247aa9e8b3f9bc1f814e0d02223efcb2fb5
1 /* Gimple IR definitions.
3 Copyright 2007, 2008 Free Software Foundation, Inc.
4 Contributed by Aldy Hernandez <aldyh@redhat.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #ifndef GCC_GIMPLE_H
23 #define GCC_GIMPLE_H
25 #include "pointer-set.h"
26 #include "vec.h"
27 #include "ggc.h"
28 #include "tm.h"
29 #include "hard-reg-set.h"
30 #include "basic-block.h"
31 #include "tree-ssa-operands.h"
33 DEF_VEC_P(gimple);
34 DEF_VEC_ALLOC_P(gimple,heap);
35 DEF_VEC_ALLOC_P(gimple,gc);
37 DEF_VEC_P(gimple_seq);
38 DEF_VEC_ALLOC_P(gimple_seq,gc);
39 DEF_VEC_ALLOC_P(gimple_seq,heap);
41 /* For each block, the PHI nodes that need to be rewritten are stored into
42 these vectors. */
43 typedef VEC(gimple, heap) *gimple_vec;
44 DEF_VEC_P (gimple_vec);
45 DEF_VEC_ALLOC_P (gimple_vec, heap);
47 enum gimple_code {
48 #define DEFGSCODE(SYM, STRING, STRUCT) SYM,
49 #include "gimple.def"
50 #undef DEFGSCODE
51 LAST_AND_UNUSED_GIMPLE_CODE
54 extern const char *const gimple_code_name[];
55 extern const unsigned char gimple_rhs_class_table[];
57 /* Error out if a gimple tuple is addressed incorrectly. */
58 #if defined ENABLE_GIMPLE_CHECKING
59 extern void gimple_check_failed (const_gimple, const char *, int, \
60 const char *, enum gimple_code, \
61 enum tree_code) ATTRIBUTE_NORETURN;
63 #define GIMPLE_CHECK(GS, CODE) \
64 do { \
65 const_gimple __gs = (GS); \
66 if (gimple_code (__gs) != (CODE)) \
67 gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__, \
68 (CODE), 0); \
69 } while (0)
70 #else /* not ENABLE_GIMPLE_CHECKING */
71 #define GIMPLE_CHECK(GS, CODE) (void)0
72 #endif
74 /* Class of GIMPLE expressions suitable for the RHS of assignments. See
75 get_gimple_rhs_class. */
76 enum gimple_rhs_class
78 GIMPLE_INVALID_RHS, /* The expression cannot be used on the RHS. */
79 GIMPLE_BINARY_RHS, /* The expression is a binary operation. */
80 GIMPLE_UNARY_RHS, /* The expression is a unary operation. */
81 GIMPLE_SINGLE_RHS /* The expression is a single object (an SSA
82 name, a _DECL, a _REF, etc. */
85 /* Specific flags for individual GIMPLE statements. These flags are
86 always stored in gimple_statement_base.subcode and they may only be
87 defined for statement codes that do not use sub-codes.
89 Values for the masks can overlap as long as the overlapping values
90 are never used in the same statement class.
92 The maximum mask value that can be defined is 1 << 15 (i.e., each
93 statement code can hold up to 16 bitflags).
95 Keep this list sorted. */
96 enum gf_mask {
97 GF_ASM_INPUT = 1 << 0,
98 GF_ASM_VOLATILE = 1 << 1,
99 GF_CALL_CANNOT_INLINE = 1 << 0,
100 GF_CALL_FROM_THUNK = 1 << 1,
101 GF_CALL_RETURN_SLOT_OPT = 1 << 2,
102 GF_CALL_TAILCALL = 1 << 3,
103 GF_CALL_VA_ARG_PACK = 1 << 4,
104 GF_OMP_PARALLEL_COMBINED = 1 << 0,
106 /* True on an GIMPLE_OMP_RETURN statement if the return does not require
107 a thread synchronization via some sort of barrier. The exact barrier
108 that would otherwise be emitted is dependent on the OMP statement with
109 which this return is associated. */
110 GF_OMP_RETURN_NOWAIT = 1 << 0,
112 GF_OMP_SECTION_LAST = 1 << 0,
113 GF_PREDICT_TAKEN = 1 << 15
116 /* Masks for selecting a pass local flag (PLF) to work on. These
117 masks are used by gimple_set_plf and gimple_plf. */
118 enum plf_mask {
119 GF_PLF_1 = 1 << 0,
120 GF_PLF_2 = 1 << 1
123 /* A node in a gimple_seq_d. */
124 struct gimple_seq_node_d GTY((chain_next ("%h.next"), chain_prev ("%h.prev")))
126 gimple stmt;
127 struct gimple_seq_node_d *prev;
128 struct gimple_seq_node_d *next;
131 /* A double-linked sequence of gimple statements. */
132 struct gimple_seq_d GTY ((chain_next ("%h.next_free")))
134 /* First and last statements in the sequence. */
135 gimple_seq_node first;
136 gimple_seq_node last;
138 /* Sequences are created/destroyed frequently. To minimize
139 allocation activity, deallocated sequences are kept in a pool of
140 available sequences. This is the pointer to the next free
141 sequence in the pool. */
142 gimple_seq next_free;
146 /* Return the first node in GIMPLE sequence S. */
148 static inline gimple_seq_node
149 gimple_seq_first (const_gimple_seq s)
151 return s ? s->first : NULL;
155 /* Return the first statement in GIMPLE sequence S. */
157 static inline gimple
158 gimple_seq_first_stmt (const_gimple_seq s)
160 gimple_seq_node n = gimple_seq_first (s);
161 return (n) ? n->stmt : NULL;
165 /* Return the last node in GIMPLE sequence S. */
167 static inline gimple_seq_node
168 gimple_seq_last (const_gimple_seq s)
170 return s ? s->last : NULL;
174 /* Return the last statement in GIMPLE sequence S. */
176 static inline gimple
177 gimple_seq_last_stmt (const_gimple_seq s)
179 gimple_seq_node n = gimple_seq_last (s);
180 return (n) ? n->stmt : NULL;
184 /* Set the last node in GIMPLE sequence S to LAST. */
186 static inline void
187 gimple_seq_set_last (gimple_seq s, gimple_seq_node last)
189 s->last = last;
193 /* Set the first node in GIMPLE sequence S to FIRST. */
195 static inline void
196 gimple_seq_set_first (gimple_seq s, gimple_seq_node first)
198 s->first = first;
202 /* Return true if GIMPLE sequence S is empty. */
204 static inline bool
205 gimple_seq_empty_p (const_gimple_seq s)
207 return s == NULL || s->first == NULL;
211 void gimple_seq_add_stmt (gimple_seq *, gimple);
213 /* Allocate a new sequence and initialize its first element with STMT. */
215 static inline gimple_seq
216 gimple_seq_alloc_with_stmt (gimple stmt)
218 gimple_seq seq = NULL;
219 gimple_seq_add_stmt (&seq, stmt);
220 return seq;
224 /* Returns the sequence of statements in BB. */
226 static inline gimple_seq
227 bb_seq (const_basic_block bb)
229 return (!(bb->flags & BB_RTL) && bb->il.gimple) ? bb->il.gimple->seq : NULL;
233 /* Sets the sequence of statements in BB to SEQ. */
235 static inline void
236 set_bb_seq (basic_block bb, gimple_seq seq)
238 gcc_assert (!(bb->flags & BB_RTL));
239 bb->il.gimple->seq = seq;
242 /* Iterator object for GIMPLE statement sequences. */
244 typedef struct
246 /* Sequence node holding the current statement. */
247 gimple_seq_node ptr;
249 /* Sequence and basic block holding the statement. These fields
250 are necessary to handle edge cases such as when statement is
251 added to an empty basic block or when the last statement of a
252 block/sequence is removed. */
253 gimple_seq seq;
254 basic_block bb;
255 } gimple_stmt_iterator;
258 /* Data structure definitions for GIMPLE tuples. NOTE: word markers
259 are for 64 bit hosts. */
261 struct gimple_statement_base GTY(())
263 /* [ WORD 1 ]
264 Main identifying code for a tuple. */
265 ENUM_BITFIELD(gimple_code) code : 8;
267 /* Nonzero if a warning should not be emitted on this tuple. */
268 unsigned int no_warning : 1;
270 /* Nonzero if this tuple has been visited. Passes are responsible
271 for clearing this bit before using it. */
272 unsigned int visited : 1;
274 /* Nonzero if this tuple represents a non-temporal move. */
275 unsigned int nontemporal_move : 1;
277 /* Pass local flags. These flags are free for any pass to use as
278 they see fit. Passes should not assume that these flags contain
279 any useful value when the pass starts. Any initial state that
280 the pass requires should be set on entry to the pass. See
281 gimple_set_plf and gimple_plf for usage. */
282 unsigned int plf : 2;
284 /* Nonzero if this statement has been modified and needs to have its
285 operands rescanned. */
286 unsigned modified : 1;
288 /* Nonzero if this statement contains volatile operands. */
289 unsigned has_volatile_ops : 1;
291 /* Nonzero if this statement contains memory refernces. */
292 unsigned references_memory_p : 1;
294 /* The SUBCODE field can be used for tuple-specific flags for tuples
295 that do not require subcodes. Note that SUBCODE should be at
296 least as wide as tree codes, as several tuples store tree codes
297 in there. */
298 unsigned int subcode : 16;
300 /* UID of this statement. This is used by passes that want to
301 assign IDs to statements. It must be assigned and used by each
302 pass. By default it should be assumed to contain garbage. */
303 unsigned uid;
305 /* [ WORD 2 ]
306 Locus information for debug info. */
307 location_t location;
309 /* Number of operands in this tuple. */
310 unsigned num_ops;
312 /* [ WORD 3 ]
313 Basic block holding this statement. */
314 struct basic_block_def *bb;
316 /* [ WORD 4 ]
317 Lexical block holding this statement. */
318 tree block;
322 /* Base structure for tuples with operands. */
324 struct gimple_statement_with_ops_base GTY(())
326 /* [ WORD 1-4 ] */
327 struct gimple_statement_base gsbase;
329 /* [ WORD 5 ]
330 Symbols whose addresses are taken by this statement (i.e., they
331 appear inside ADDR_EXPR nodes). */
332 bitmap GTY((skip (""))) addresses_taken;
334 /* [ WORD 6-7 ]
335 SSA operand vectors. NOTE: It should be possible to
336 amalgamate these vectors with the operand vector OP. However,
337 the SSA operand vectors are organized differently and contain
338 more information (like immediate use chaining). */
339 struct def_optype_d GTY((skip (""))) *def_ops;
340 struct use_optype_d GTY((skip (""))) *use_ops;
344 /* Statements that take register operands. */
346 struct gimple_statement_with_ops GTY(())
348 /* [ WORD 1-7 ] */
349 struct gimple_statement_with_ops_base opbase;
351 /* [ WORD 8 ]
352 Operand vector. NOTE! This must always be the last field
353 of this structure. In particular, this means that this
354 structure cannot be embedded inside another one. */
355 tree GTY((length ("%h.opbase.gsbase.num_ops"))) op[1];
359 /* Base for statements that take both memory and register operands. */
361 struct gimple_statement_with_memory_ops_base GTY(())
363 /* [ WORD 1-7 ] */
364 struct gimple_statement_with_ops_base opbase;
366 /* [ WORD 8-9 ]
367 Vectors for virtual operands. */
368 struct voptype_d GTY((skip (""))) *vdef_ops;
369 struct voptype_d GTY((skip (""))) *vuse_ops;
371 /* [ WORD 9-10 ]
372 Symbols stored/loaded by this statement. */
373 bitmap GTY((skip (""))) stores;
374 bitmap GTY((skip (""))) loads;
378 /* Statements that take both memory and register operands. */
380 struct gimple_statement_with_memory_ops GTY(())
382 /* [ WORD 1-10 ] */
383 struct gimple_statement_with_memory_ops_base membase;
385 /* [ WORD 11 ]
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-10 ] */
549 struct gimple_statement_with_memory_ops_base membase;
551 /* [ WORD 11 ]
552 __asm__ statement. */
553 const char *string;
555 /* [ WORD 12 ]
556 Number of inputs, outputs and clobbers. */
557 unsigned char ni;
558 unsigned char no;
559 unsigned short nc;
561 /* [ WORD 13 ]
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 if T is a GIMPLE temporary variable, false otherwise. */
863 extern bool is_gimple_formal_tmp_var (tree);
864 /* Returns true if T is a GIMPLE temporary register variable. */
865 extern bool is_gimple_formal_tmp_reg (tree);
866 /* Returns true iff T is any sort of variable. */
867 extern bool is_gimple_variable (tree);
868 /* Returns true iff T is any sort of symbol. */
869 extern bool is_gimple_id (tree);
870 /* Returns true iff T is a variable or an INDIRECT_REF (of a variable). */
871 extern bool is_gimple_min_lval (tree);
872 /* Returns true iff T is something whose address can be taken. */
873 extern bool is_gimple_addressable (tree);
874 /* Returns true iff T is any valid GIMPLE lvalue. */
875 extern bool is_gimple_lvalue (tree);
877 /* Returns true iff T is a GIMPLE address. */
878 bool is_gimple_address (const_tree);
879 /* Returns true iff T is a GIMPLE invariant address. */
880 bool is_gimple_invariant_address (const_tree);
881 /* Returns true iff T is a GIMPLE invariant address at interprocedural
882 level. */
883 bool is_gimple_ip_invariant_address (const_tree);
884 /* Returns true iff T is a valid GIMPLE constant. */
885 bool is_gimple_constant (const_tree);
886 /* Returns true iff T is a GIMPLE restricted function invariant. */
887 extern bool is_gimple_min_invariant (const_tree);
888 /* Returns true iff T is a GIMPLE restricted interprecodural invariant. */
889 extern bool is_gimple_ip_invariant (const_tree);
890 /* Returns true iff T is a GIMPLE rvalue. */
891 extern bool is_gimple_val (tree);
892 /* Returns true iff T is a GIMPLE asm statement input. */
893 extern bool is_gimple_asm_val (tree);
894 /* Returns true iff T is a valid rhs for a MODIFY_EXPR where the LHS is a
895 GIMPLE temporary, a renamed user variable, or something else,
896 respectively. */
897 extern bool is_gimple_formal_tmp_rhs (tree);
898 extern bool is_gimple_reg_rhs (tree);
899 extern bool is_gimple_mem_rhs (tree);
901 /* Returns true iff T is a valid if-statement condition. */
902 extern bool is_gimple_condexpr (tree);
904 /* Returns true iff T is a type conversion. */
905 extern bool is_gimple_cast (tree);
906 /* Returns true iff T is a variable that does not need to live in memory. */
907 extern bool is_gimple_non_addressable (tree t);
909 /* Returns true iff T is a valid call address expression. */
910 extern bool is_gimple_call_addr (tree);
911 /* If T makes a function call, returns the CALL_EXPR operand. */
912 extern tree get_call_expr_in (tree t);
914 extern void recalculate_side_effects (tree);
916 /* In gimplify.c */
917 extern tree create_tmp_var_raw (tree, const char *);
918 extern tree create_tmp_var_name (const char *);
919 extern tree create_tmp_var (tree, const char *);
920 extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq *);
921 extern tree get_formal_tmp_var (tree, gimple_seq *);
922 extern void declare_vars (tree, gimple, bool);
923 extern void tree_annotate_all_with_location (tree *, location_t);
924 extern void annotate_all_with_location (gimple_seq, location_t);
926 /* Validation of GIMPLE expressions. Note that these predicates only check
927 the basic form of the expression, they don't recurse to make sure that
928 underlying nodes are also of the right form. */
929 typedef bool (*gimple_predicate)(tree);
932 /* FIXME we should deduce this from the predicate. */
933 typedef enum fallback_t {
934 fb_none = 0, /* Do not generate a temporary. */
936 fb_rvalue = 1, /* Generate an rvalue to hold the result of a
937 gimplified expression. */
939 fb_lvalue = 2, /* Generate an lvalue to hold the result of a
940 gimplified expression. */
942 fb_mayfail = 4, /* Gimplification may fail. Error issued
943 afterwards. */
944 fb_either= fb_rvalue | fb_lvalue
945 } fallback_t;
947 enum gimplify_status {
948 GS_ERROR = -2, /* Something Bad Seen. */
949 GS_UNHANDLED = -1, /* A langhook result for "I dunno". */
950 GS_OK = 0, /* We did something, maybe more to do. */
951 GS_ALL_DONE = 1 /* The expression is fully gimplified. */
954 struct gimplify_ctx
956 struct gimplify_ctx *prev_context;
958 VEC(gimple,heap) *bind_expr_stack;
959 tree temps;
960 gimple_seq conditional_cleanups;
961 tree exit_label;
962 tree return_temp;
964 VEC(tree,heap) *case_labels;
965 /* The formal temporary table. Should this be persistent? */
966 htab_t temp_htab;
968 int conditions;
969 bool save_stack;
970 bool into_ssa;
971 bool allow_rhs_cond_expr;
974 extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *,
975 bool (*) (tree), fallback_t);
976 extern void gimplify_type_sizes (tree, gimple_seq *);
977 extern void gimplify_one_sizepos (tree *, gimple_seq *);
978 extern bool gimplify_stmt (tree *, gimple_seq *);
979 extern gimple gimplify_body (tree *, tree, bool);
980 extern void push_gimplify_context (struct gimplify_ctx *);
981 extern void pop_gimplify_context (gimple);
982 extern void gimplify_and_add (tree, gimple_seq *);
984 /* Miscellaneous helpers. */
985 extern void gimple_add_tmp_var (tree);
986 extern gimple gimple_current_bind_expr (void);
987 extern VEC(gimple, heap) *gimple_bind_expr_stack (void);
988 extern tree voidify_wrapper_expr (tree, tree);
989 extern tree build_and_jump (tree *);
990 extern tree alloc_stmt_list (void);
991 extern void free_stmt_list (tree);
992 extern tree force_labels_r (tree *, int *, void *);
993 extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *,
994 gimple_seq *);
995 struct gimplify_omp_ctx;
996 extern void omp_firstprivatize_variable (struct gimplify_omp_ctx *, tree);
997 extern tree gimple_boolify (tree);
998 extern gimple_predicate rhs_predicate_for (tree);
999 extern tree canonicalize_cond_expr_cond (tree);
1001 /* In omp-low.c. */
1002 extern void diagnose_omp_structured_block_errors (tree);
1003 extern tree omp_reduction_init (tree, tree);
1005 /* In tree-nested.c. */
1006 extern void lower_nested_functions (tree);
1007 extern void insert_field_into_struct (tree, tree);
1009 /* In gimplify.c. */
1010 extern void gimplify_function_tree (tree);
1012 /* In cfgexpand.c. */
1013 extern tree gimple_assign_rhs_to_tree (gimple);
1015 /* In builtins.c */
1016 extern bool validate_gimple_arglist (const_gimple, ...);
1018 /* In tree-ssa-operands.c */
1019 extern void gimple_add_to_addresses_taken (gimple, tree);
1021 /* In tree-ssa.c */
1022 extern bool tree_ssa_useless_type_conversion (tree);
1023 extern bool useless_type_conversion_p (tree, tree);
1024 extern bool types_compatible_p (tree, tree);
1026 /* Return the code for GIMPLE statement G. */
1028 static inline enum gimple_code
1029 gimple_code (const_gimple g)
1031 return g->gsbase.code;
1035 /* Return true if statement G has sub-statements. This is only true for
1036 High GIMPLE statements. */
1038 static inline bool
1039 gimple_has_substatements (gimple g)
1041 switch (gimple_code (g))
1043 case GIMPLE_BIND:
1044 case GIMPLE_CATCH:
1045 case GIMPLE_EH_FILTER:
1046 case GIMPLE_TRY:
1047 case GIMPLE_OMP_FOR:
1048 case GIMPLE_OMP_MASTER:
1049 case GIMPLE_OMP_ORDERED:
1050 case GIMPLE_OMP_SECTION:
1051 case GIMPLE_OMP_PARALLEL:
1052 case GIMPLE_OMP_TASK:
1053 case GIMPLE_OMP_SECTIONS:
1054 case GIMPLE_OMP_SINGLE:
1055 case GIMPLE_OMP_CRITICAL:
1056 case GIMPLE_WITH_CLEANUP_EXPR:
1057 return true;
1059 default:
1060 return false;
1065 /* Return the basic block holding statement G. */
1067 static inline struct basic_block_def *
1068 gimple_bb (const_gimple g)
1070 return g->gsbase.bb;
1074 /* Return the lexical scope block holding statement G. */
1076 static inline tree
1077 gimple_block (const_gimple g)
1079 return g->gsbase.block;
1083 /* Set BLOCK to be the lexical scope block holding statement G. */
1085 static inline void
1086 gimple_set_block (gimple g, tree block)
1088 g->gsbase.block = block;
1092 /* Return location information for statement G. */
1094 static inline location_t
1095 gimple_location (const_gimple g)
1097 return g->gsbase.location;
1100 /* Return pointer to location information for statement G. */
1102 static inline const location_t *
1103 gimple_location_ptr (const_gimple g)
1105 return &g->gsbase.location;
1109 /* Set location information for statement G. */
1111 static inline void
1112 gimple_set_location (gimple g, location_t location)
1114 g->gsbase.location = location;
1118 /* Return true if G contains location information. */
1120 static inline bool
1121 gimple_has_location (const_gimple g)
1123 return gimple_location (g) != UNKNOWN_LOCATION;
1127 /* Return the file name of the location of STMT. */
1129 static inline const char *
1130 gimple_filename (const_gimple stmt)
1132 return LOCATION_FILE (gimple_location (stmt));
1136 /* Return the line number of the location of STMT. */
1138 static inline int
1139 gimple_lineno (const_gimple stmt)
1141 return LOCATION_LINE (gimple_location (stmt));
1145 /* Determine whether SEQ is a singleton. */
1147 static inline bool
1148 gimple_seq_singleton_p (gimple_seq seq)
1150 return ((gimple_seq_first (seq) != NULL)
1151 && (gimple_seq_first (seq) == gimple_seq_last (seq)));
1154 /* Return true if no warnings should be emitted for statement STMT. */
1156 static inline bool
1157 gimple_no_warning_p (const_gimple stmt)
1159 return stmt->gsbase.no_warning;
1162 /* Set the no_warning flag of STMT to NO_WARNING. */
1164 static inline void
1165 gimple_set_no_warning (gimple stmt, bool no_warning)
1167 stmt->gsbase.no_warning = (unsigned) no_warning;
1170 /* Set the visited status on statement STMT to VISITED_P. */
1172 static inline void
1173 gimple_set_visited (gimple stmt, bool visited_p)
1175 stmt->gsbase.visited = (unsigned) visited_p;
1179 /* Return the visited status for statement STMT. */
1181 static inline bool
1182 gimple_visited_p (gimple stmt)
1184 return stmt->gsbase.visited;
1188 /* Set pass local flag PLF on statement STMT to VAL_P. */
1190 static inline void
1191 gimple_set_plf (gimple stmt, enum plf_mask plf, bool val_p)
1193 if (val_p)
1194 stmt->gsbase.plf |= (unsigned int) plf;
1195 else
1196 stmt->gsbase.plf &= ~((unsigned int) plf);
1200 /* Return the value of pass local flag PLF on statement STMT. */
1202 static inline unsigned int
1203 gimple_plf (gimple stmt, enum plf_mask plf)
1205 return stmt->gsbase.plf & ((unsigned int) plf);
1209 /* Set the UID of statement. */
1211 static inline void
1212 gimple_set_uid (gimple g, unsigned uid)
1214 g->gsbase.uid = uid;
1218 /* Return the UID of statement. */
1220 static inline unsigned
1221 gimple_uid (const_gimple g)
1223 return g->gsbase.uid;
1227 /* Return true if GIMPLE statement G has register or memory operands. */
1229 static inline bool
1230 gimple_has_ops (const_gimple g)
1232 return gimple_code (g) >= GIMPLE_COND && gimple_code (g) <= GIMPLE_RETURN;
1236 /* Return true if GIMPLE statement G has memory operands. */
1238 static inline bool
1239 gimple_has_mem_ops (const_gimple g)
1241 return gimple_code (g) >= GIMPLE_ASSIGN && gimple_code (g) <= GIMPLE_RETURN;
1244 /* Return the set of addresses taken by statement G. */
1246 static inline bitmap
1247 gimple_addresses_taken (const_gimple g)
1249 if (gimple_has_ops (g))
1250 return g->gsops.opbase.addresses_taken;
1251 else
1252 return NULL;
1256 /* Return a pointer to the set of addresses taken by statement G. */
1258 static inline bitmap *
1259 gimple_addresses_taken_ptr (gimple g)
1261 if (gimple_has_ops (g))
1262 return &g->gsops.opbase.addresses_taken;
1263 else
1264 return NULL;
1268 /* Set B to be the set of addresses taken by statement G. The
1269 previous set is freed. */
1271 static inline void
1272 gimple_set_addresses_taken (gimple g, bitmap b)
1274 gcc_assert (gimple_has_ops (g));
1275 BITMAP_FREE (g->gsops.opbase.addresses_taken);
1276 g->gsops.opbase.addresses_taken = b;
1280 /* Return the set of DEF operands for statement G. */
1282 static inline struct def_optype_d *
1283 gimple_def_ops (const_gimple g)
1285 if (!gimple_has_ops (g))
1286 return NULL;
1287 return g->gsops.opbase.def_ops;
1291 /* Set DEF to be the set of DEF operands for statement G. */
1293 static inline void
1294 gimple_set_def_ops (gimple g, struct def_optype_d *def)
1296 gcc_assert (gimple_has_ops (g));
1297 g->gsops.opbase.def_ops = def;
1301 /* Return the set of USE operands for statement G. */
1303 static inline struct use_optype_d *
1304 gimple_use_ops (const_gimple g)
1306 if (!gimple_has_ops (g))
1307 return NULL;
1308 return g->gsops.opbase.use_ops;
1312 /* Set USE to be the set of USE operands for statement G. */
1314 static inline void
1315 gimple_set_use_ops (gimple g, struct use_optype_d *use)
1317 gcc_assert (gimple_has_ops (g));
1318 g->gsops.opbase.use_ops = use;
1322 /* Return the set of VUSE operands for statement G. */
1324 static inline struct voptype_d *
1325 gimple_vuse_ops (const_gimple g)
1327 if (!gimple_has_mem_ops (g))
1328 return NULL;
1329 return g->gsmem.membase.vuse_ops;
1333 /* Set OPS to be the set of VUSE operands for statement G. */
1335 static inline void
1336 gimple_set_vuse_ops (gimple g, struct voptype_d *ops)
1338 gcc_assert (gimple_has_mem_ops (g));
1339 g->gsmem.membase.vuse_ops = ops;
1343 /* Return the set of VDEF operands for statement G. */
1345 static inline struct voptype_d *
1346 gimple_vdef_ops (const_gimple g)
1348 if (!gimple_has_mem_ops (g))
1349 return NULL;
1350 return g->gsmem.membase.vdef_ops;
1354 /* Set OPS to be the set of VDEF operands for statement G. */
1356 static inline void
1357 gimple_set_vdef_ops (gimple g, struct voptype_d *ops)
1359 gcc_assert (gimple_has_mem_ops (g));
1360 g->gsmem.membase.vdef_ops = ops;
1364 /* Return the set of symbols loaded by statement G. Each element of the
1365 set is the DECL_UID of the corresponding symbol. */
1367 static inline bitmap
1368 gimple_loaded_syms (const_gimple g)
1370 if (!gimple_has_mem_ops (g))
1371 return NULL;
1372 return g->gsmem.membase.loads;
1376 /* Return the set of symbols stored by statement G. Each element of
1377 the set is the DECL_UID of the corresponding symbol. */
1379 static inline bitmap
1380 gimple_stored_syms (const_gimple g)
1382 if (!gimple_has_mem_ops (g))
1383 return NULL;
1384 return g->gsmem.membase.stores;
1388 /* Return true if statement G has operands and the modified field has
1389 been set. */
1391 static inline bool
1392 gimple_modified_p (const_gimple g)
1394 return (gimple_has_ops (g)) ? (bool) g->gsbase.modified : false;
1397 /* Return the type of the main expression computed by STMT. Return
1398 void_type_node if the statement computes nothing. */
1400 static inline tree
1401 gimple_expr_type (const_gimple stmt)
1403 enum gimple_code code = gimple_code (stmt);
1405 if (code == GIMPLE_ASSIGN || code == GIMPLE_CALL)
1407 tree type = TREE_TYPE (gimple_get_lhs (stmt));
1408 /* Integral sub-types are never the type of the expression,
1409 but they still can be the type of the result as the base
1410 type (in which expressions are computed) is trivially
1411 convertible to one of its sub-types. So always return
1412 the base type here. */
1413 if (INTEGRAL_TYPE_P (type)
1414 && TREE_TYPE (type)
1415 /* But only if they are trivially convertible. */
1416 && useless_type_conversion_p (type, TREE_TYPE (type)))
1417 type = TREE_TYPE (type);
1418 return type;
1420 else if (code == GIMPLE_COND)
1421 return boolean_type_node;
1422 else
1423 return void_type_node;
1427 /* Return the tree code for the expression computed by STMT. This is
1428 only valid for GIMPLE_COND, GIMPLE_CALL and GIMPLE_ASSIGN. For
1429 GIMPLE_CALL, return CALL_EXPR as the expression code for
1430 consistency. This is useful when the caller needs to deal with the
1431 three kinds of computation that GIMPLE supports. */
1433 static inline enum tree_code
1434 gimple_expr_code (const_gimple stmt)
1436 enum gimple_code code = gimple_code (stmt);
1437 if (code == GIMPLE_ASSIGN || code == GIMPLE_COND)
1438 return (enum tree_code) stmt->gsbase.subcode;
1439 else if (code == GIMPLE_CALL)
1440 return CALL_EXPR;
1441 else
1442 gcc_unreachable ();
1446 /* Mark statement S as modified, and update it. */
1448 static inline void
1449 update_stmt (gimple s)
1451 if (gimple_has_ops (s))
1453 gimple_set_modified (s, true);
1454 update_stmt_operands (s);
1458 /* Update statement S if it has been optimized. */
1460 static inline void
1461 update_stmt_if_modified (gimple s)
1463 if (gimple_modified_p (s))
1464 update_stmt_operands (s);
1467 /* Return true if statement STMT contains volatile operands. */
1469 static inline bool
1470 gimple_has_volatile_ops (const_gimple stmt)
1472 if (gimple_has_mem_ops (stmt))
1473 return stmt->gsbase.has_volatile_ops;
1474 else
1475 return false;
1479 /* Set the HAS_VOLATILE_OPS flag to VOLATILEP. */
1481 static inline void
1482 gimple_set_has_volatile_ops (gimple stmt, bool volatilep)
1484 if (gimple_has_mem_ops (stmt))
1485 stmt->gsbase.has_volatile_ops = (unsigned) volatilep;
1489 /* Return true if statement STMT may access memory. */
1491 static inline bool
1492 gimple_references_memory_p (gimple stmt)
1494 return gimple_has_mem_ops (stmt) && stmt->gsbase.references_memory_p;
1498 /* Set the REFERENCES_MEMORY_P flag for STMT to MEM_P. */
1500 static inline void
1501 gimple_set_references_memory (gimple stmt, bool mem_p)
1503 if (gimple_has_mem_ops (stmt))
1504 stmt->gsbase.references_memory_p = (unsigned) mem_p;
1507 /* Return the subcode for OMP statement S. */
1509 static inline unsigned
1510 gimple_omp_subcode (const_gimple s)
1512 gcc_assert (gimple_code (s) >= GIMPLE_OMP_ATOMIC_LOAD
1513 && gimple_code (s) <= GIMPLE_OMP_SINGLE);
1514 return s->gsbase.subcode;
1517 /* Set the subcode for OMP statement S to SUBCODE. */
1519 static inline void
1520 gimple_omp_set_subcode (gimple s, unsigned int subcode)
1522 /* We only have 16 bits for the subcode. Assert that we are not
1523 overflowing it. */
1524 gcc_assert (subcode < (1 << 16));
1525 s->gsbase.subcode = subcode;
1528 /* Set the nowait flag on OMP_RETURN statement S. */
1530 static inline void
1531 gimple_omp_return_set_nowait (gimple s)
1533 GIMPLE_CHECK (s, GIMPLE_OMP_RETURN);
1534 s->gsbase.subcode |= GF_OMP_RETURN_NOWAIT;
1538 /* Return true if OMP return statement G has the GF_OMP_RETURN_NOWAIT
1539 flag set. */
1541 static inline bool
1542 gimple_omp_return_nowait_p (const_gimple g)
1544 GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
1545 return (gimple_omp_subcode (g) & GF_OMP_RETURN_NOWAIT) != 0;
1549 /* Return true if OMP section statement G has the GF_OMP_SECTION_LAST
1550 flag set. */
1552 static inline bool
1553 gimple_omp_section_last_p (const_gimple g)
1555 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1556 return (gimple_omp_subcode (g) & GF_OMP_SECTION_LAST) != 0;
1560 /* Set the GF_OMP_SECTION_LAST flag on G. */
1562 static inline void
1563 gimple_omp_section_set_last (gimple g)
1565 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1566 g->gsbase.subcode |= GF_OMP_SECTION_LAST;
1570 /* Return true if OMP parallel statement G has the
1571 GF_OMP_PARALLEL_COMBINED flag set. */
1573 static inline bool
1574 gimple_omp_parallel_combined_p (const_gimple g)
1576 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1577 return (gimple_omp_subcode (g) & GF_OMP_PARALLEL_COMBINED) != 0;
1581 /* Set the GF_OMP_PARALLEL_COMBINED field in G depending on the boolean
1582 value of COMBINED_P. */
1584 static inline void
1585 gimple_omp_parallel_set_combined_p (gimple g, bool combined_p)
1587 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1588 if (combined_p)
1589 g->gsbase.subcode |= GF_OMP_PARALLEL_COMBINED;
1590 else
1591 g->gsbase.subcode &= ~GF_OMP_PARALLEL_COMBINED;
1595 /* Return the number of operands for statement GS. */
1597 static inline unsigned
1598 gimple_num_ops (const_gimple gs)
1600 return gs->gsbase.num_ops;
1604 /* Set the number of operands for statement GS. */
1606 static inline void
1607 gimple_set_num_ops (gimple gs, unsigned num_ops)
1609 gs->gsbase.num_ops = num_ops;
1613 /* Return the array of operands for statement GS. */
1615 static inline tree *
1616 gimple_ops (gimple gs)
1618 /* Offset in bytes to the location of the operand vector in every
1619 tuple structure. Defined in gimple.c */
1620 extern size_t const gimple_ops_offset_[];
1622 if (!gimple_has_ops (gs))
1623 return NULL;
1625 /* All the tuples have their operand vector at the very bottom
1626 of the structure. */
1627 return ((tree *) ((char *) gs + gimple_ops_offset_[gimple_code (gs)]));
1631 /* Return operand I for statement GS. */
1633 static inline tree
1634 gimple_op (const_gimple gs, unsigned i)
1636 if (gimple_has_ops (gs))
1638 gcc_assert (i < gimple_num_ops (gs));
1639 return gimple_ops (CONST_CAST_GIMPLE (gs))[i];
1641 else
1642 return NULL_TREE;
1645 /* Return a pointer to operand I for statement GS. */
1647 static inline tree *
1648 gimple_op_ptr (const_gimple gs, unsigned i)
1650 if (gimple_has_ops (gs))
1652 gcc_assert (i < gimple_num_ops (gs));
1653 return gimple_ops (CONST_CAST_GIMPLE (gs)) + i;
1655 else
1656 return NULL;
1659 /* Set operand I of statement GS to OP. */
1661 static inline void
1662 gimple_set_op (gimple gs, unsigned i, tree op)
1664 gcc_assert (gimple_has_ops (gs) && i < gimple_num_ops (gs));
1666 /* Note. It may be tempting to assert that OP matches
1667 is_gimple_operand, but that would be wrong. Different tuples
1668 accept slightly different sets of tree operands. Each caller
1669 should perform its own validation. */
1670 gimple_ops (gs)[i] = op;
1673 /* Return true if GS is a GIMPLE_ASSIGN. */
1675 static inline bool
1676 is_gimple_assign (const_gimple gs)
1678 return gimple_code (gs) == GIMPLE_ASSIGN;
1681 /* Determine if expression CODE is one of the valid expressions that can
1682 be used on the RHS of GIMPLE assignments. */
1684 static inline enum gimple_rhs_class
1685 get_gimple_rhs_class (enum tree_code code)
1687 return (enum gimple_rhs_class) gimple_rhs_class_table[(int) code];
1690 /* Return the LHS of assignment statement GS. */
1692 static inline tree
1693 gimple_assign_lhs (const_gimple gs)
1695 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1696 return gimple_op (gs, 0);
1700 /* Return a pointer to the LHS of assignment statement GS. */
1702 static inline tree *
1703 gimple_assign_lhs_ptr (const_gimple gs)
1705 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1706 return gimple_op_ptr (gs, 0);
1710 /* Set LHS to be the LHS operand of assignment statement GS. */
1712 static inline void
1713 gimple_assign_set_lhs (gimple gs, tree lhs)
1715 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1716 gcc_assert (is_gimple_operand (lhs));
1717 gimple_set_op (gs, 0, lhs);
1719 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1720 SSA_NAME_DEF_STMT (lhs) = gs;
1724 /* Return the first operand on the RHS of assignment statement GS. */
1726 static inline tree
1727 gimple_assign_rhs1 (const_gimple gs)
1729 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1730 return gimple_op (gs, 1);
1734 /* Return a pointer to the first operand on the RHS of assignment
1735 statement GS. */
1737 static inline tree *
1738 gimple_assign_rhs1_ptr (const_gimple gs)
1740 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1741 return gimple_op_ptr (gs, 1);
1744 /* Set RHS to be the first operand on the RHS of assignment statement GS. */
1746 static inline void
1747 gimple_assign_set_rhs1 (gimple gs, tree rhs)
1749 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1751 /* If there are 3 or more operands, the 2 operands on the RHS must be
1752 GIMPLE values. */
1753 if (gimple_num_ops (gs) >= 3)
1754 gcc_assert (is_gimple_val (rhs));
1755 else
1756 gcc_assert (is_gimple_operand (rhs));
1758 gimple_set_op (gs, 1, rhs);
1762 /* Return the second operand on the RHS of assignment statement GS.
1763 If GS does not have two operands, NULL is returned instead. */
1765 static inline tree
1766 gimple_assign_rhs2 (const_gimple gs)
1768 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1770 if (gimple_num_ops (gs) >= 3)
1771 return gimple_op (gs, 2);
1772 else
1773 return NULL_TREE;
1777 /* Return a pointer to the second operand on the RHS of assignment
1778 statement GS. */
1780 static inline tree *
1781 gimple_assign_rhs2_ptr (const_gimple gs)
1783 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1784 return gimple_op_ptr (gs, 2);
1788 /* Set RHS to be the second operand on the RHS of assignment statement GS. */
1790 static inline void
1791 gimple_assign_set_rhs2 (gimple gs, tree rhs)
1793 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1795 /* The 2 operands on the RHS must be GIMPLE values. */
1796 gcc_assert (is_gimple_val (rhs));
1798 gimple_set_op (gs, 2, rhs);
1801 /* Returns true if GS is a nontemporal move. */
1803 static inline bool
1804 gimple_assign_nontemporal_move_p (const_gimple gs)
1806 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1807 return gs->gsbase.nontemporal_move;
1810 /* Sets nontemporal move flag of GS to NONTEMPORAL. */
1812 static inline void
1813 gimple_assign_set_nontemporal_move (gimple gs, bool nontemporal)
1815 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1816 gs->gsbase.nontemporal_move = nontemporal;
1820 /* Return the code of the expression computed on the rhs of assignment
1821 statement GS. In case that the RHS is a single object, returns the
1822 tree code of the object. */
1824 static inline enum tree_code
1825 gimple_assign_rhs_code (const_gimple gs)
1827 enum tree_code code;
1828 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1830 code = gimple_expr_code (gs);
1831 if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS)
1832 code = TREE_CODE (gimple_assign_rhs1 (gs));
1834 return code;
1838 /* Set CODE to be the code for the expression computed on the RHS of
1839 assignment S. */
1841 static inline void
1842 gimple_assign_set_rhs_code (gimple s, enum tree_code code)
1844 GIMPLE_CHECK (s, GIMPLE_ASSIGN);
1845 s->gsbase.subcode = code;
1849 /* Return the gimple rhs class of the code of the expression computed on
1850 the rhs of assignment statement GS.
1851 This will never return GIMPLE_INVALID_RHS. */
1853 static inline enum gimple_rhs_class
1854 gimple_assign_rhs_class (const_gimple gs)
1856 return get_gimple_rhs_class (gimple_assign_rhs_code (gs));
1860 /* Return true if S is a type-cast assignment. */
1862 static inline bool
1863 gimple_assign_cast_p (gimple s)
1865 if (is_gimple_assign (s))
1867 enum tree_code sc = gimple_assign_rhs_code (s);
1868 return CONVERT_EXPR_CODE_P (sc)
1869 || sc == VIEW_CONVERT_EXPR
1870 || sc == FIX_TRUNC_EXPR;
1873 return false;
1877 /* Return true if GS is a GIMPLE_CALL. */
1879 static inline bool
1880 is_gimple_call (const_gimple gs)
1882 return gimple_code (gs) == GIMPLE_CALL;
1885 /* Return the LHS of call statement GS. */
1887 static inline tree
1888 gimple_call_lhs (const_gimple gs)
1890 GIMPLE_CHECK (gs, GIMPLE_CALL);
1891 return gimple_op (gs, 0);
1895 /* Return a pointer to the LHS of call statement GS. */
1897 static inline tree *
1898 gimple_call_lhs_ptr (const_gimple gs)
1900 GIMPLE_CHECK (gs, GIMPLE_CALL);
1901 return gimple_op_ptr (gs, 0);
1905 /* Set LHS to be the LHS operand of call statement GS. */
1907 static inline void
1908 gimple_call_set_lhs (gimple gs, tree lhs)
1910 GIMPLE_CHECK (gs, GIMPLE_CALL);
1911 gcc_assert (!lhs || is_gimple_operand (lhs));
1912 gimple_set_op (gs, 0, lhs);
1913 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1914 SSA_NAME_DEF_STMT (lhs) = gs;
1918 /* Return the tree node representing the function called by call
1919 statement GS. */
1921 static inline tree
1922 gimple_call_fn (const_gimple gs)
1924 GIMPLE_CHECK (gs, GIMPLE_CALL);
1925 return gimple_op (gs, 1);
1929 /* Return a pointer to the tree node representing the function called by call
1930 statement GS. */
1932 static inline tree *
1933 gimple_call_fn_ptr (const_gimple gs)
1935 GIMPLE_CHECK (gs, GIMPLE_CALL);
1936 return gimple_op_ptr (gs, 1);
1940 /* Set FN to be the function called by call statement GS. */
1942 static inline void
1943 gimple_call_set_fn (gimple gs, tree fn)
1945 GIMPLE_CHECK (gs, GIMPLE_CALL);
1946 gcc_assert (is_gimple_operand (fn));
1947 gimple_set_op (gs, 1, fn);
1951 /* Set FNDECL to be the function called by call statement GS. */
1953 static inline void
1954 gimple_call_set_fndecl (gimple gs, tree decl)
1956 GIMPLE_CHECK (gs, GIMPLE_CALL);
1957 gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
1958 gimple_set_op (gs, 1, build_fold_addr_expr (decl));
1962 /* If a given GIMPLE_CALL's callee is a FUNCTION_DECL, return it.
1963 Otherwise return NULL. This function is analogous to
1964 get_callee_fndecl in tree land. */
1966 static inline tree
1967 gimple_call_fndecl (const_gimple gs)
1969 tree addr = gimple_call_fn (gs);
1970 if (TREE_CODE (addr) == ADDR_EXPR)
1972 gcc_assert (TREE_CODE (TREE_OPERAND (addr, 0)) == FUNCTION_DECL);
1973 return TREE_OPERAND (addr, 0);
1975 return NULL_TREE;
1979 /* Return the type returned by call statement GS. */
1981 static inline tree
1982 gimple_call_return_type (const_gimple gs)
1984 tree fn = gimple_call_fn (gs);
1985 tree type = TREE_TYPE (fn);
1987 /* See through the pointer. */
1988 gcc_assert (POINTER_TYPE_P (type));
1989 type = TREE_TYPE (type);
1991 gcc_assert (TREE_CODE (type) == FUNCTION_TYPE
1992 || TREE_CODE (type) == METHOD_TYPE);
1994 /* The type returned by a FUNCTION_DECL is the type of its
1995 function type. */
1996 return TREE_TYPE (type);
2000 /* Return the static chain for call statement GS. */
2002 static inline tree
2003 gimple_call_chain (const_gimple gs)
2005 GIMPLE_CHECK (gs, GIMPLE_CALL);
2006 return gimple_op (gs, 2);
2010 /* Return a pointer to the static chain for call statement GS. */
2012 static inline tree *
2013 gimple_call_chain_ptr (const_gimple gs)
2015 GIMPLE_CHECK (gs, GIMPLE_CALL);
2016 return gimple_op_ptr (gs, 2);
2019 /* Set CHAIN to be the static chain for call statement GS. */
2021 static inline void
2022 gimple_call_set_chain (gimple gs, tree chain)
2024 GIMPLE_CHECK (gs, GIMPLE_CALL);
2025 gcc_assert (chain == NULL
2026 || TREE_CODE (chain) == ADDR_EXPR
2027 || SSA_VAR_P (chain));
2028 gimple_set_op (gs, 2, chain);
2032 /* Return the number of arguments used by call statement GS. */
2034 static inline unsigned
2035 gimple_call_num_args (const_gimple gs)
2037 unsigned num_ops;
2038 GIMPLE_CHECK (gs, GIMPLE_CALL);
2039 num_ops = gimple_num_ops (gs);
2040 gcc_assert (num_ops >= 3);
2041 return num_ops - 3;
2045 /* Return the argument at position INDEX for call statement GS. */
2047 static inline tree
2048 gimple_call_arg (const_gimple gs, unsigned index)
2050 GIMPLE_CHECK (gs, GIMPLE_CALL);
2051 return gimple_op (gs, index + 3);
2055 /* Return a pointer to the argument at position INDEX for call
2056 statement GS. */
2058 static inline tree *
2059 gimple_call_arg_ptr (const_gimple gs, unsigned index)
2061 GIMPLE_CHECK (gs, GIMPLE_CALL);
2062 return gimple_op_ptr (gs, index + 3);
2066 /* Set ARG to be the argument at position INDEX for call statement GS. */
2068 static inline void
2069 gimple_call_set_arg (gimple gs, unsigned index, tree arg)
2071 GIMPLE_CHECK (gs, GIMPLE_CALL);
2072 gcc_assert (is_gimple_operand (arg));
2073 gimple_set_op (gs, index + 3, arg);
2077 /* If TAIL_P is true, mark call statement S as being a tail call
2078 (i.e., a call just before the exit of a function). These calls are
2079 candidate for tail call optimization. */
2081 static inline void
2082 gimple_call_set_tail (gimple s, bool tail_p)
2084 GIMPLE_CHECK (s, GIMPLE_CALL);
2085 if (tail_p)
2086 s->gsbase.subcode |= GF_CALL_TAILCALL;
2087 else
2088 s->gsbase.subcode &= ~GF_CALL_TAILCALL;
2092 /* Return true if GIMPLE_CALL S is marked as a tail call. */
2094 static inline bool
2095 gimple_call_tail_p (gimple s)
2097 GIMPLE_CHECK (s, GIMPLE_CALL);
2098 return (s->gsbase.subcode & GF_CALL_TAILCALL) != 0;
2102 /* Set the inlinable status of GIMPLE_CALL S to INLINABLE_P. */
2104 static inline void
2105 gimple_call_set_cannot_inline (gimple s, bool inlinable_p)
2107 GIMPLE_CHECK (s, GIMPLE_CALL);
2108 if (inlinable_p)
2109 s->gsbase.subcode |= GF_CALL_CANNOT_INLINE;
2110 else
2111 s->gsbase.subcode &= ~GF_CALL_CANNOT_INLINE;
2115 /* Return true if GIMPLE_CALL S cannot be inlined. */
2117 static inline bool
2118 gimple_call_cannot_inline_p (gimple s)
2120 GIMPLE_CHECK (s, GIMPLE_CALL);
2121 return (s->gsbase.subcode & GF_CALL_CANNOT_INLINE) != 0;
2125 /* If RETURN_SLOT_OPT_P is true mark GIMPLE_CALL S as valid for return
2126 slot optimization. This transformation uses the target of the call
2127 expansion as the return slot for calls that return in memory. */
2129 static inline void
2130 gimple_call_set_return_slot_opt (gimple s, bool return_slot_opt_p)
2132 GIMPLE_CHECK (s, GIMPLE_CALL);
2133 if (return_slot_opt_p)
2134 s->gsbase.subcode |= GF_CALL_RETURN_SLOT_OPT;
2135 else
2136 s->gsbase.subcode &= ~GF_CALL_RETURN_SLOT_OPT;
2140 /* Return true if S is marked for return slot optimization. */
2142 static inline bool
2143 gimple_call_return_slot_opt_p (gimple s)
2145 GIMPLE_CHECK (s, GIMPLE_CALL);
2146 return (s->gsbase.subcode & GF_CALL_RETURN_SLOT_OPT) != 0;
2150 /* If FROM_THUNK_P is true, mark GIMPLE_CALL S as being the jump from a
2151 thunk to the thunked-to function. */
2153 static inline void
2154 gimple_call_set_from_thunk (gimple s, bool from_thunk_p)
2156 GIMPLE_CHECK (s, GIMPLE_CALL);
2157 if (from_thunk_p)
2158 s->gsbase.subcode |= GF_CALL_FROM_THUNK;
2159 else
2160 s->gsbase.subcode &= ~GF_CALL_FROM_THUNK;
2164 /* Return true if GIMPLE_CALL S is a jump from a thunk. */
2166 static inline bool
2167 gimple_call_from_thunk_p (gimple s)
2169 GIMPLE_CHECK (s, GIMPLE_CALL);
2170 return (s->gsbase.subcode & GF_CALL_FROM_THUNK) != 0;
2174 /* If PASS_ARG_PACK_P is true, GIMPLE_CALL S is a stdarg call that needs the
2175 argument pack in its argument list. */
2177 static inline void
2178 gimple_call_set_va_arg_pack (gimple s, bool pass_arg_pack_p)
2180 GIMPLE_CHECK (s, GIMPLE_CALL);
2181 if (pass_arg_pack_p)
2182 s->gsbase.subcode |= GF_CALL_VA_ARG_PACK;
2183 else
2184 s->gsbase.subcode &= ~GF_CALL_VA_ARG_PACK;
2188 /* Return true if GIMPLE_CALL S is a stdarg call that needs the
2189 argument pack in its argument list. */
2191 static inline bool
2192 gimple_call_va_arg_pack_p (gimple s)
2194 GIMPLE_CHECK (s, GIMPLE_CALL);
2195 return (s->gsbase.subcode & GF_CALL_VA_ARG_PACK) != 0;
2199 /* Return true if S is a noreturn call. */
2201 static inline bool
2202 gimple_call_noreturn_p (gimple s)
2204 GIMPLE_CHECK (s, GIMPLE_CALL);
2205 return (gimple_call_flags (s) & ECF_NORETURN) != 0;
2209 /* Return true if S is a nothrow call. */
2211 static inline bool
2212 gimple_call_nothrow_p (gimple s)
2214 GIMPLE_CHECK (s, GIMPLE_CALL);
2215 return (gimple_call_flags (s) & ECF_NOTHROW) != 0;
2219 /* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL. */
2221 static inline void
2222 gimple_call_copy_flags (gimple dest_call, gimple orig_call)
2224 GIMPLE_CHECK (dest_call, GIMPLE_CALL);
2225 GIMPLE_CHECK (orig_call, GIMPLE_CALL);
2226 dest_call->gsbase.subcode = orig_call->gsbase.subcode;
2230 /* Returns true if this is a GIMPLE_ASSIGN or a GIMPLE_CALL with a
2231 non-NULL lhs. */
2233 static inline bool
2234 gimple_has_lhs (gimple stmt)
2236 return (is_gimple_assign (stmt)
2237 || (is_gimple_call (stmt)
2238 && gimple_call_lhs (stmt) != NULL_TREE));
2242 /* Return the code of the predicate computed by conditional statement GS. */
2244 static inline enum tree_code
2245 gimple_cond_code (const_gimple gs)
2247 GIMPLE_CHECK (gs, GIMPLE_COND);
2248 return gs->gsbase.subcode;
2252 /* Set CODE to be the predicate code for the conditional statement GS. */
2254 static inline void
2255 gimple_cond_set_code (gimple gs, enum tree_code code)
2257 GIMPLE_CHECK (gs, GIMPLE_COND);
2258 gcc_assert (TREE_CODE_CLASS (code) == tcc_comparison);
2259 gs->gsbase.subcode = code;
2263 /* Return the LHS of the predicate computed by conditional statement GS. */
2265 static inline tree
2266 gimple_cond_lhs (const_gimple gs)
2268 GIMPLE_CHECK (gs, GIMPLE_COND);
2269 return gimple_op (gs, 0);
2272 /* Return the pointer to the LHS of the predicate computed by conditional
2273 statement GS. */
2275 static inline tree *
2276 gimple_cond_lhs_ptr (const_gimple gs)
2278 GIMPLE_CHECK (gs, GIMPLE_COND);
2279 return gimple_op_ptr (gs, 0);
2282 /* Set LHS to be the LHS operand of the predicate computed by
2283 conditional statement GS. */
2285 static inline void
2286 gimple_cond_set_lhs (gimple gs, tree lhs)
2288 GIMPLE_CHECK (gs, GIMPLE_COND);
2289 gcc_assert (is_gimple_operand (lhs));
2290 gimple_set_op (gs, 0, lhs);
2294 /* Return the RHS operand of the predicate computed by conditional GS. */
2296 static inline tree
2297 gimple_cond_rhs (const_gimple gs)
2299 GIMPLE_CHECK (gs, GIMPLE_COND);
2300 return gimple_op (gs, 1);
2303 /* Return the pointer to the RHS operand of the predicate computed by
2304 conditional GS. */
2306 static inline tree *
2307 gimple_cond_rhs_ptr (const_gimple gs)
2309 GIMPLE_CHECK (gs, GIMPLE_COND);
2310 return gimple_op_ptr (gs, 1);
2314 /* Set RHS to be the RHS operand of the predicate computed by
2315 conditional statement GS. */
2317 static inline void
2318 gimple_cond_set_rhs (gimple gs, tree rhs)
2320 GIMPLE_CHECK (gs, GIMPLE_COND);
2321 gcc_assert (is_gimple_operand (rhs));
2322 gimple_set_op (gs, 1, rhs);
2326 /* Return the label used by conditional statement GS when its
2327 predicate evaluates to true. */
2329 static inline tree
2330 gimple_cond_true_label (const_gimple gs)
2332 GIMPLE_CHECK (gs, GIMPLE_COND);
2333 return gimple_op (gs, 2);
2337 /* Set LABEL to be the label used by conditional statement GS when its
2338 predicate evaluates to true. */
2340 static inline void
2341 gimple_cond_set_true_label (gimple gs, tree label)
2343 GIMPLE_CHECK (gs, GIMPLE_COND);
2344 gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
2345 gimple_set_op (gs, 2, label);
2349 /* Set LABEL to be the label used by conditional statement GS when its
2350 predicate evaluates to false. */
2352 static inline void
2353 gimple_cond_set_false_label (gimple gs, tree label)
2355 GIMPLE_CHECK (gs, GIMPLE_COND);
2356 gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
2357 gimple_set_op (gs, 3, label);
2361 /* Return the label used by conditional statement GS when its
2362 predicate evaluates to false. */
2364 static inline tree
2365 gimple_cond_false_label (const_gimple gs)
2367 GIMPLE_CHECK (gs, GIMPLE_COND);
2368 return gimple_op (gs, 3);
2372 /* Set the conditional COND_STMT to be of the form 'if (1 == 0)'. */
2374 static inline void
2375 gimple_cond_make_false (gimple gs)
2377 gimple_cond_set_lhs (gs, boolean_true_node);
2378 gimple_cond_set_rhs (gs, boolean_false_node);
2379 gs->gsbase.subcode = EQ_EXPR;
2383 /* Set the conditional COND_STMT to be of the form 'if (1 == 1)'. */
2385 static inline void
2386 gimple_cond_make_true (gimple gs)
2388 gimple_cond_set_lhs (gs, boolean_true_node);
2389 gimple_cond_set_rhs (gs, boolean_true_node);
2390 gs->gsbase.subcode = EQ_EXPR;
2393 /* Check if conditional statemente GS is of the form 'if (1 == 1)',
2394 'if (0 == 0)', 'if (1 != 0)' or 'if (0 != 1)' */
2396 static inline bool
2397 gimple_cond_true_p (const_gimple gs)
2399 tree lhs = gimple_cond_lhs (gs);
2400 tree rhs = gimple_cond_rhs (gs);
2401 enum tree_code code = gimple_cond_code (gs);
2403 if (lhs != boolean_true_node && lhs != boolean_false_node)
2404 return false;
2406 if (rhs != boolean_true_node && rhs != boolean_false_node)
2407 return false;
2409 if (code == NE_EXPR && lhs != rhs)
2410 return true;
2412 if (code == EQ_EXPR && lhs == rhs)
2413 return true;
2415 return false;
2418 /* Check if conditional statement GS is of the form 'if (1 != 1)',
2419 'if (0 != 0)', 'if (1 == 0)' or 'if (0 == 1)' */
2421 static inline bool
2422 gimple_cond_false_p (const_gimple gs)
2424 tree lhs = gimple_cond_lhs (gs);
2425 tree rhs = gimple_cond_rhs (gs);
2426 enum tree_code code = gimple_cond_code (gs);
2428 if (lhs != boolean_true_node && lhs != boolean_false_node)
2429 return false;
2431 if (rhs != boolean_true_node && rhs != boolean_false_node)
2432 return false;
2434 if (code == NE_EXPR && lhs == rhs)
2435 return true;
2437 if (code == EQ_EXPR && lhs != rhs)
2438 return true;
2440 return false;
2443 /* Check if conditional statement GS is of the form 'if (var != 0)' or
2444 'if (var == 1)' */
2446 static inline bool
2447 gimple_cond_single_var_p (gimple gs)
2449 if (gimple_cond_code (gs) == NE_EXPR
2450 && gimple_cond_rhs (gs) == boolean_false_node)
2451 return true;
2453 if (gimple_cond_code (gs) == EQ_EXPR
2454 && gimple_cond_rhs (gs) == boolean_true_node)
2455 return true;
2457 return false;
2460 /* Set the code, LHS and RHS of GIMPLE_COND STMT from CODE, LHS and RHS. */
2462 static inline void
2463 gimple_cond_set_condition (gimple stmt, enum tree_code code, tree lhs, tree rhs)
2465 gimple_cond_set_code (stmt, code);
2466 gimple_cond_set_lhs (stmt, lhs);
2467 gimple_cond_set_rhs (stmt, rhs);
2470 /* Return the LABEL_DECL node used by GIMPLE_LABEL statement GS. */
2472 static inline tree
2473 gimple_label_label (const_gimple gs)
2475 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2476 return gimple_op (gs, 0);
2480 /* Set LABEL to be the LABEL_DECL node used by GIMPLE_LABEL statement
2481 GS. */
2483 static inline void
2484 gimple_label_set_label (gimple gs, tree label)
2486 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2487 gcc_assert (TREE_CODE (label) == LABEL_DECL);
2488 gimple_set_op (gs, 0, label);
2492 /* Return the destination of the unconditional jump GS. */
2494 static inline tree
2495 gimple_goto_dest (const_gimple gs)
2497 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2498 return gimple_op (gs, 0);
2502 /* Set DEST to be the destination of the unconditonal jump GS. */
2504 static inline void
2505 gimple_goto_set_dest (gimple gs, tree dest)
2507 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2508 gcc_assert (is_gimple_operand (dest));
2509 gimple_set_op (gs, 0, dest);
2513 /* Return the variables declared in the GIMPLE_BIND statement GS. */
2515 static inline tree
2516 gimple_bind_vars (const_gimple gs)
2518 GIMPLE_CHECK (gs, GIMPLE_BIND);
2519 return gs->gimple_bind.vars;
2523 /* Set VARS to be the set of variables declared in the GIMPLE_BIND
2524 statement GS. */
2526 static inline void
2527 gimple_bind_set_vars (gimple gs, tree vars)
2529 GIMPLE_CHECK (gs, GIMPLE_BIND);
2530 gs->gimple_bind.vars = vars;
2534 /* Append VARS to the set of variables declared in the GIMPLE_BIND
2535 statement GS. */
2537 static inline void
2538 gimple_bind_append_vars (gimple gs, tree vars)
2540 GIMPLE_CHECK (gs, GIMPLE_BIND);
2541 gs->gimple_bind.vars = chainon (gs->gimple_bind.vars, vars);
2545 /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS. */
2547 static inline gimple_seq
2548 gimple_bind_body (gimple gs)
2550 GIMPLE_CHECK (gs, GIMPLE_BIND);
2551 return gs->gimple_bind.body;
2555 /* Set SEQ to be the GIMPLE sequence contained in the GIMPLE_BIND
2556 statement GS. */
2558 static inline void
2559 gimple_bind_set_body (gimple gs, gimple_seq seq)
2561 GIMPLE_CHECK (gs, GIMPLE_BIND);
2562 gs->gimple_bind.body = seq;
2566 /* Append a statement to the end of a GIMPLE_BIND's body. */
2568 static inline void
2569 gimple_bind_add_stmt (gimple gs, gimple stmt)
2571 GIMPLE_CHECK (gs, GIMPLE_BIND);
2572 gimple_seq_add_stmt (&gs->gimple_bind.body, stmt);
2576 /* Append a sequence of statements to the end of a GIMPLE_BIND's body. */
2578 static inline void
2579 gimple_bind_add_seq (gimple gs, gimple_seq seq)
2581 GIMPLE_CHECK (gs, GIMPLE_BIND);
2582 gimple_seq_add_seq (&gs->gimple_bind.body, seq);
2586 /* Return the TREE_BLOCK node associated with GIMPLE_BIND statement
2587 GS. This is analogous to the BIND_EXPR_BLOCK field in trees. */
2589 static inline tree
2590 gimple_bind_block (const_gimple gs)
2592 GIMPLE_CHECK (gs, GIMPLE_BIND);
2593 return gs->gimple_bind.block;
2597 /* Set BLOCK to be the TREE_BLOCK node associated with GIMPLE_BIND
2598 statement GS. */
2600 static inline void
2601 gimple_bind_set_block (gimple gs, tree block)
2603 GIMPLE_CHECK (gs, GIMPLE_BIND);
2604 gcc_assert (block == NULL_TREE || TREE_CODE (block) == BLOCK);
2605 gs->gimple_bind.block = block;
2609 /* Return the number of input operands for GIMPLE_ASM GS. */
2611 static inline unsigned
2612 gimple_asm_ninputs (const_gimple gs)
2614 GIMPLE_CHECK (gs, GIMPLE_ASM);
2615 return gs->gimple_asm.ni;
2619 /* Return the number of output operands for GIMPLE_ASM GS. */
2621 static inline unsigned
2622 gimple_asm_noutputs (const_gimple gs)
2624 GIMPLE_CHECK (gs, GIMPLE_ASM);
2625 return gs->gimple_asm.no;
2629 /* Return the number of clobber operands for GIMPLE_ASM GS. */
2631 static inline unsigned
2632 gimple_asm_nclobbers (const_gimple gs)
2634 GIMPLE_CHECK (gs, GIMPLE_ASM);
2635 return gs->gimple_asm.nc;
2639 /* Return input operand INDEX of GIMPLE_ASM GS. */
2641 static inline tree
2642 gimple_asm_input_op (const_gimple gs, unsigned index)
2644 GIMPLE_CHECK (gs, GIMPLE_ASM);
2645 gcc_assert (index <= gs->gimple_asm.ni);
2646 return gimple_op (gs, index);
2649 /* Return a pointer to input operand INDEX of GIMPLE_ASM GS. */
2651 static inline tree *
2652 gimple_asm_input_op_ptr (const_gimple gs, unsigned index)
2654 GIMPLE_CHECK (gs, GIMPLE_ASM);
2655 gcc_assert (index <= gs->gimple_asm.ni);
2656 return gimple_op_ptr (gs, index);
2660 /* Set IN_OP to be input operand INDEX in GIMPLE_ASM GS. */
2662 static inline void
2663 gimple_asm_set_input_op (gimple gs, unsigned index, tree in_op)
2665 GIMPLE_CHECK (gs, GIMPLE_ASM);
2666 gcc_assert (index <= gs->gimple_asm.ni);
2667 gcc_assert (TREE_CODE (in_op) == TREE_LIST);
2668 gimple_set_op (gs, index, in_op);
2672 /* Return output operand INDEX of GIMPLE_ASM GS. */
2674 static inline tree
2675 gimple_asm_output_op (const_gimple gs, unsigned index)
2677 GIMPLE_CHECK (gs, GIMPLE_ASM);
2678 gcc_assert (index <= gs->gimple_asm.no);
2679 return gimple_op (gs, index + gs->gimple_asm.ni);
2682 /* Return a pointer to output operand INDEX of GIMPLE_ASM GS. */
2684 static inline tree *
2685 gimple_asm_output_op_ptr (const_gimple gs, unsigned index)
2687 GIMPLE_CHECK (gs, GIMPLE_ASM);
2688 gcc_assert (index <= gs->gimple_asm.no);
2689 return gimple_op_ptr (gs, index + gs->gimple_asm.ni);
2693 /* Set OUT_OP to be output operand INDEX in GIMPLE_ASM GS. */
2695 static inline void
2696 gimple_asm_set_output_op (gimple gs, unsigned index, tree out_op)
2698 GIMPLE_CHECK (gs, GIMPLE_ASM);
2699 gcc_assert (index <= gs->gimple_asm.no);
2700 gcc_assert (TREE_CODE (out_op) == TREE_LIST);
2701 gimple_set_op (gs, index + gs->gimple_asm.ni, out_op);
2705 /* Return clobber operand INDEX of GIMPLE_ASM GS. */
2707 static inline tree
2708 gimple_asm_clobber_op (const_gimple gs, unsigned index)
2710 GIMPLE_CHECK (gs, GIMPLE_ASM);
2711 gcc_assert (index <= gs->gimple_asm.nc);
2712 return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no);
2716 /* Set CLOBBER_OP to be clobber operand INDEX in GIMPLE_ASM GS. */
2718 static inline void
2719 gimple_asm_set_clobber_op (gimple gs, unsigned index, tree clobber_op)
2721 GIMPLE_CHECK (gs, GIMPLE_ASM);
2722 gcc_assert (index <= gs->gimple_asm.nc);
2723 gcc_assert (TREE_CODE (clobber_op) == TREE_LIST);
2724 gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no, clobber_op);
2728 /* Return the string representing the assembly instruction in
2729 GIMPLE_ASM GS. */
2731 static inline const char *
2732 gimple_asm_string (const_gimple gs)
2734 GIMPLE_CHECK (gs, GIMPLE_ASM);
2735 return gs->gimple_asm.string;
2739 /* Return true if GS is an asm statement marked volatile. */
2741 static inline bool
2742 gimple_asm_volatile_p (const_gimple gs)
2744 GIMPLE_CHECK (gs, GIMPLE_ASM);
2745 return (gs->gsbase.subcode & GF_ASM_VOLATILE) != 0;
2749 /* If VOLATLE_P is true, mark asm statement GS as volatile. */
2751 static inline void
2752 gimple_asm_set_volatile (gimple gs, bool volatile_p)
2754 GIMPLE_CHECK (gs, GIMPLE_ASM);
2755 if (volatile_p)
2756 gs->gsbase.subcode |= GF_ASM_VOLATILE;
2757 else
2758 gs->gsbase.subcode &= ~GF_ASM_VOLATILE;
2762 /* If INPUT_P is true, mark asm GS as an ASM_INPUT. */
2764 static inline void
2765 gimple_asm_set_input (gimple gs, bool input_p)
2767 GIMPLE_CHECK (gs, GIMPLE_ASM);
2768 if (input_p)
2769 gs->gsbase.subcode |= GF_ASM_INPUT;
2770 else
2771 gs->gsbase.subcode &= ~GF_ASM_INPUT;
2775 /* Return true if asm GS is an ASM_INPUT. */
2777 static inline bool
2778 gimple_asm_input_p (const_gimple gs)
2780 GIMPLE_CHECK (gs, GIMPLE_ASM);
2781 return (gs->gsbase.subcode & GF_ASM_INPUT) != 0;
2785 /* Return the types handled by GIMPLE_CATCH statement GS. */
2787 static inline tree
2788 gimple_catch_types (const_gimple gs)
2790 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2791 return gs->gimple_catch.types;
2795 /* Return a pointer to the types handled by GIMPLE_CATCH statement GS. */
2797 static inline tree *
2798 gimple_catch_types_ptr (gimple gs)
2800 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2801 return &gs->gimple_catch.types;
2805 /* Return the GIMPLE sequence representing the body of the handler of
2806 GIMPLE_CATCH statement GS. */
2808 static inline gimple_seq
2809 gimple_catch_handler (gimple gs)
2811 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2812 return gs->gimple_catch.handler;
2816 /* Return a pointer to the GIMPLE sequence representing the body of
2817 the handler of GIMPLE_CATCH statement GS. */
2819 static inline gimple_seq *
2820 gimple_catch_handler_ptr (gimple gs)
2822 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2823 return &gs->gimple_catch.handler;
2827 /* Set T to be the set of types handled by GIMPLE_CATCH GS. */
2829 static inline void
2830 gimple_catch_set_types (gimple gs, tree t)
2832 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2833 gs->gimple_catch.types = t;
2837 /* Set HANDLER to be the body of GIMPLE_CATCH GS. */
2839 static inline void
2840 gimple_catch_set_handler (gimple gs, gimple_seq handler)
2842 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2843 gs->gimple_catch.handler = handler;
2847 /* Return the types handled by GIMPLE_EH_FILTER statement GS. */
2849 static inline tree
2850 gimple_eh_filter_types (const_gimple gs)
2852 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2853 return gs->gimple_eh_filter.types;
2857 /* Return a pointer to the types handled by GIMPLE_EH_FILTER statement
2858 GS. */
2860 static inline tree *
2861 gimple_eh_filter_types_ptr (gimple gs)
2863 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2864 return &gs->gimple_eh_filter.types;
2868 /* Return the sequence of statement to execute when GIMPLE_EH_FILTER
2869 statement fails. */
2871 static inline gimple_seq
2872 gimple_eh_filter_failure (gimple gs)
2874 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2875 return gs->gimple_eh_filter.failure;
2879 /* Set TYPES to be the set of types handled by GIMPLE_EH_FILTER GS. */
2881 static inline void
2882 gimple_eh_filter_set_types (gimple gs, tree types)
2884 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2885 gs->gimple_eh_filter.types = types;
2889 /* Set FAILURE to be the sequence of statements to execute on failure
2890 for GIMPLE_EH_FILTER GS. */
2892 static inline void
2893 gimple_eh_filter_set_failure (gimple gs, gimple_seq failure)
2895 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2896 gs->gimple_eh_filter.failure = failure;
2899 /* Return the EH_FILTER_MUST_NOT_THROW flag. */
2901 static inline bool
2903 gimple_eh_filter_must_not_throw (gimple gs)
2905 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2906 return gs->gsbase.subcode != 0;
2909 /* Set the EH_FILTER_MUST_NOT_THROW flag to the value MNTP. */
2911 static inline void
2912 gimple_eh_filter_set_must_not_throw (gimple gs, bool mntp)
2914 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2915 gs->gsbase.subcode = (unsigned int) mntp;
2919 /* GIMPLE_TRY accessors. */
2921 /* Return the kind of try block represented by GIMPLE_TRY GS. This is
2922 either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY. */
2924 static inline enum gimple_try_flags
2925 gimple_try_kind (const_gimple gs)
2927 GIMPLE_CHECK (gs, GIMPLE_TRY);
2928 return (enum gimple_try_flags) (gs->gsbase.subcode & GIMPLE_TRY_KIND);
2932 /* Set the kind of try block represented by GIMPLE_TRY GS. */
2934 static inline void
2935 gimple_try_set_kind (gimple gs, enum gimple_try_flags kind)
2937 GIMPLE_CHECK (gs, GIMPLE_TRY);
2938 gcc_assert (kind == GIMPLE_TRY_CATCH || kind == GIMPLE_TRY_FINALLY);
2939 if (gimple_try_kind (gs) != kind)
2940 gs->gsbase.subcode = (unsigned int) kind;
2944 /* Return the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2946 static inline bool
2947 gimple_try_catch_is_cleanup (const_gimple gs)
2949 gcc_assert (gimple_try_kind (gs) == GIMPLE_TRY_CATCH);
2950 return (gs->gsbase.subcode & GIMPLE_TRY_CATCH_IS_CLEANUP) != 0;
2954 /* Return the sequence of statements used as the body for GIMPLE_TRY GS. */
2956 static inline gimple_seq
2957 gimple_try_eval (gimple gs)
2959 GIMPLE_CHECK (gs, GIMPLE_TRY);
2960 return gs->gimple_try.eval;
2964 /* Return the sequence of statements used as the cleanup body for
2965 GIMPLE_TRY GS. */
2967 static inline gimple_seq
2968 gimple_try_cleanup (gimple gs)
2970 GIMPLE_CHECK (gs, GIMPLE_TRY);
2971 return gs->gimple_try.cleanup;
2975 /* Set the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2977 static inline void
2978 gimple_try_set_catch_is_cleanup (gimple g, bool catch_is_cleanup)
2980 gcc_assert (gimple_try_kind (g) == GIMPLE_TRY_CATCH);
2981 if (catch_is_cleanup)
2982 g->gsbase.subcode |= GIMPLE_TRY_CATCH_IS_CLEANUP;
2983 else
2984 g->gsbase.subcode &= ~GIMPLE_TRY_CATCH_IS_CLEANUP;
2988 /* Set EVAL to be the sequence of statements to use as the body for
2989 GIMPLE_TRY GS. */
2991 static inline void
2992 gimple_try_set_eval (gimple gs, gimple_seq eval)
2994 GIMPLE_CHECK (gs, GIMPLE_TRY);
2995 gs->gimple_try.eval = eval;
2999 /* Set CLEANUP to be the sequence of statements to use as the cleanup
3000 body for GIMPLE_TRY GS. */
3002 static inline void
3003 gimple_try_set_cleanup (gimple gs, gimple_seq cleanup)
3005 GIMPLE_CHECK (gs, GIMPLE_TRY);
3006 gs->gimple_try.cleanup = cleanup;
3010 /* Return the cleanup sequence for cleanup statement GS. */
3012 static inline gimple_seq
3013 gimple_wce_cleanup (gimple gs)
3015 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3016 return gs->gimple_wce.cleanup;
3020 /* Set CLEANUP to be the cleanup sequence for GS. */
3022 static inline void
3023 gimple_wce_set_cleanup (gimple gs, gimple_seq cleanup)
3025 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3026 gs->gimple_wce.cleanup = cleanup;
3030 /* Return the CLEANUP_EH_ONLY flag for a WCE tuple. */
3032 static inline bool
3033 gimple_wce_cleanup_eh_only (const_gimple gs)
3035 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3036 return gs->gsbase.subcode != 0;
3040 /* Set the CLEANUP_EH_ONLY flag for a WCE tuple. */
3042 static inline void
3043 gimple_wce_set_cleanup_eh_only (gimple gs, bool eh_only_p)
3045 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3046 gs->gsbase.subcode = (unsigned int) eh_only_p;
3050 /* Return the maximum number of arguments supported by GIMPLE_PHI GS. */
3052 static inline unsigned
3053 gimple_phi_capacity (const_gimple gs)
3055 GIMPLE_CHECK (gs, GIMPLE_PHI);
3056 return gs->gimple_phi.capacity;
3060 /* Return the number of arguments in GIMPLE_PHI GS. This must always
3061 be exactly the number of incoming edges for the basic block holding
3062 GS. */
3064 static inline unsigned
3065 gimple_phi_num_args (const_gimple gs)
3067 GIMPLE_CHECK (gs, GIMPLE_PHI);
3068 return gs->gimple_phi.nargs;
3072 /* Return the SSA name created by GIMPLE_PHI GS. */
3074 static inline tree
3075 gimple_phi_result (const_gimple gs)
3077 GIMPLE_CHECK (gs, GIMPLE_PHI);
3078 return gs->gimple_phi.result;
3081 /* Return a pointer to the SSA name created by GIMPLE_PHI GS. */
3083 static inline tree *
3084 gimple_phi_result_ptr (gimple gs)
3086 GIMPLE_CHECK (gs, GIMPLE_PHI);
3087 return &gs->gimple_phi.result;
3090 /* Set RESULT to be the SSA name created by GIMPLE_PHI GS. */
3092 static inline void
3093 gimple_phi_set_result (gimple gs, tree result)
3095 GIMPLE_CHECK (gs, GIMPLE_PHI);
3096 gs->gimple_phi.result = result;
3100 /* Return the PHI argument corresponding to incoming edge INDEX for
3101 GIMPLE_PHI GS. */
3103 static inline struct phi_arg_d *
3104 gimple_phi_arg (gimple gs, unsigned index)
3106 GIMPLE_CHECK (gs, GIMPLE_PHI);
3107 gcc_assert (index <= gs->gimple_phi.capacity);
3108 return &(gs->gimple_phi.args[index]);
3111 /* Set PHIARG to be the argument corresponding to incoming edge INDEX
3112 for GIMPLE_PHI GS. */
3114 static inline void
3115 gimple_phi_set_arg (gimple gs, unsigned index, struct phi_arg_d * phiarg)
3117 GIMPLE_CHECK (gs, GIMPLE_PHI);
3118 gcc_assert (index <= gs->gimple_phi.nargs);
3119 memcpy (gs->gimple_phi.args + index, phiarg, sizeof (struct phi_arg_d));
3122 /* Return the region number for GIMPLE_RESX GS. */
3124 static inline int
3125 gimple_resx_region (const_gimple gs)
3127 GIMPLE_CHECK (gs, GIMPLE_RESX);
3128 return gs->gimple_resx.region;
3131 /* Set REGION to be the region number for GIMPLE_RESX GS. */
3133 static inline void
3134 gimple_resx_set_region (gimple gs, int region)
3136 GIMPLE_CHECK (gs, GIMPLE_RESX);
3137 gs->gimple_resx.region = region;
3141 /* Return the number of labels associated with the switch statement GS. */
3143 static inline unsigned
3144 gimple_switch_num_labels (const_gimple gs)
3146 unsigned num_ops;
3147 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3148 num_ops = gimple_num_ops (gs);
3149 gcc_assert (num_ops > 1);
3150 return num_ops - 1;
3154 /* Set NLABELS to be the number of labels for the switch statement GS. */
3156 static inline void
3157 gimple_switch_set_num_labels (gimple g, unsigned nlabels)
3159 GIMPLE_CHECK (g, GIMPLE_SWITCH);
3160 gimple_set_num_ops (g, nlabels + 1);
3164 /* Return the index variable used by the switch statement GS. */
3166 static inline tree
3167 gimple_switch_index (const_gimple gs)
3169 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3170 return gimple_op (gs, 0);
3174 /* Return a pointer to the index variable for the switch statement GS. */
3176 static inline tree *
3177 gimple_switch_index_ptr (const_gimple gs)
3179 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3180 return gimple_op_ptr (gs, 0);
3184 /* Set INDEX to be the index variable for switch statement GS. */
3186 static inline void
3187 gimple_switch_set_index (gimple gs, tree index)
3189 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3190 gcc_assert (SSA_VAR_P (index) || CONSTANT_CLASS_P (index));
3191 gimple_set_op (gs, 0, index);
3195 /* Return the label numbered INDEX. The default label is 0, followed by any
3196 labels in a switch statement. */
3198 static inline tree
3199 gimple_switch_label (const_gimple gs, unsigned index)
3201 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3202 gcc_assert (gimple_num_ops (gs) > index + 1);
3203 return gimple_op (gs, index + 1);
3206 /* Set the label number INDEX to LABEL. 0 is always the default label. */
3208 static inline void
3209 gimple_switch_set_label (gimple gs, unsigned index, tree label)
3211 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3212 gcc_assert (gimple_num_ops (gs) > index + 1);
3213 gcc_assert (label == NULL_TREE || TREE_CODE (label) == CASE_LABEL_EXPR);
3214 gimple_set_op (gs, index + 1, label);
3217 /* Return the default label for a switch statement. */
3219 static inline tree
3220 gimple_switch_default_label (const_gimple gs)
3222 return gimple_switch_label (gs, 0);
3225 /* Set the default label for a switch statement. */
3227 static inline void
3228 gimple_switch_set_default_label (gimple gs, tree label)
3230 gimple_switch_set_label (gs, 0, label);
3234 /* Return the body for the OMP statement GS. */
3236 static inline gimple_seq
3237 gimple_omp_body (gimple gs)
3239 return gs->omp.body;
3242 /* Set BODY to be the body for the OMP statement GS. */
3244 static inline void
3245 gimple_omp_set_body (gimple gs, gimple_seq body)
3247 gs->omp.body = body;
3251 /* Return the name associated with OMP_CRITICAL statement GS. */
3253 static inline tree
3254 gimple_omp_critical_name (const_gimple gs)
3256 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3257 return gs->gimple_omp_critical.name;
3261 /* Return a pointer to the name associated with OMP critical statement GS. */
3263 static inline tree *
3264 gimple_omp_critical_name_ptr (gimple gs)
3266 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3267 return &gs->gimple_omp_critical.name;
3271 /* Set NAME to be the name associated with OMP critical statement GS. */
3273 static inline void
3274 gimple_omp_critical_set_name (gimple gs, tree name)
3276 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3277 gs->gimple_omp_critical.name = name;
3281 /* Return the clauses associated with OMP_FOR GS. */
3283 static inline tree
3284 gimple_omp_for_clauses (const_gimple gs)
3286 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3287 return gs->gimple_omp_for.clauses;
3291 /* Return a pointer to the OMP_FOR GS. */
3293 static inline tree *
3294 gimple_omp_for_clauses_ptr (gimple gs)
3296 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3297 return &gs->gimple_omp_for.clauses;
3301 /* Set CLAUSES to be the list of clauses associated with OMP_FOR GS. */
3303 static inline void
3304 gimple_omp_for_set_clauses (gimple gs, tree clauses)
3306 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3307 gs->gimple_omp_for.clauses = clauses;
3311 /* Get the collapse count of OMP_FOR GS. */
3313 static inline size_t
3314 gimple_omp_for_collapse (gimple gs)
3316 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3317 return gs->gimple_omp_for.collapse;
3321 /* Return the index variable for OMP_FOR GS. */
3323 static inline tree
3324 gimple_omp_for_index (const_gimple gs, size_t i)
3326 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3327 gcc_assert (i < gs->gimple_omp_for.collapse);
3328 return gs->gimple_omp_for.iter[i].index;
3332 /* Return a pointer to the index variable for OMP_FOR GS. */
3334 static inline tree *
3335 gimple_omp_for_index_ptr (gimple gs, size_t i)
3337 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3338 gcc_assert (i < gs->gimple_omp_for.collapse);
3339 return &gs->gimple_omp_for.iter[i].index;
3343 /* Set INDEX to be the index variable for OMP_FOR GS. */
3345 static inline void
3346 gimple_omp_for_set_index (gimple gs, size_t i, tree index)
3348 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3349 gcc_assert (i < gs->gimple_omp_for.collapse);
3350 gs->gimple_omp_for.iter[i].index = index;
3354 /* Return the initial value for OMP_FOR GS. */
3356 static inline tree
3357 gimple_omp_for_initial (const_gimple gs, size_t i)
3359 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3360 gcc_assert (i < gs->gimple_omp_for.collapse);
3361 return gs->gimple_omp_for.iter[i].initial;
3365 /* Return a pointer to the initial value for OMP_FOR GS. */
3367 static inline tree *
3368 gimple_omp_for_initial_ptr (gimple gs, size_t i)
3370 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3371 gcc_assert (i < gs->gimple_omp_for.collapse);
3372 return &gs->gimple_omp_for.iter[i].initial;
3376 /* Set INITIAL to be the initial value for OMP_FOR GS. */
3378 static inline void
3379 gimple_omp_for_set_initial (gimple gs, size_t i, tree initial)
3381 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3382 gcc_assert (i < gs->gimple_omp_for.collapse);
3383 gs->gimple_omp_for.iter[i].initial = initial;
3387 /* Return the final value for OMP_FOR GS. */
3389 static inline tree
3390 gimple_omp_for_final (const_gimple gs, size_t i)
3392 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3393 gcc_assert (i < gs->gimple_omp_for.collapse);
3394 return gs->gimple_omp_for.iter[i].final;
3398 /* Return a pointer to the final value for OMP_FOR GS. */
3400 static inline tree *
3401 gimple_omp_for_final_ptr (gimple gs, size_t i)
3403 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3404 gcc_assert (i < gs->gimple_omp_for.collapse);
3405 return &gs->gimple_omp_for.iter[i].final;
3409 /* Set FINAL to be the final value for OMP_FOR GS. */
3411 static inline void
3412 gimple_omp_for_set_final (gimple gs, size_t i, tree final)
3414 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3415 gcc_assert (i < gs->gimple_omp_for.collapse);
3416 gs->gimple_omp_for.iter[i].final = final;
3420 /* Return the increment value for OMP_FOR GS. */
3422 static inline tree
3423 gimple_omp_for_incr (const_gimple gs, size_t i)
3425 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3426 gcc_assert (i < gs->gimple_omp_for.collapse);
3427 return gs->gimple_omp_for.iter[i].incr;
3431 /* Return a pointer to the increment value for OMP_FOR GS. */
3433 static inline tree *
3434 gimple_omp_for_incr_ptr (gimple gs, size_t i)
3436 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3437 gcc_assert (i < gs->gimple_omp_for.collapse);
3438 return &gs->gimple_omp_for.iter[i].incr;
3442 /* Set INCR to be the increment value for OMP_FOR GS. */
3444 static inline void
3445 gimple_omp_for_set_incr (gimple gs, size_t i, tree incr)
3447 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3448 gcc_assert (i < gs->gimple_omp_for.collapse);
3449 gs->gimple_omp_for.iter[i].incr = incr;
3453 /* Return the sequence of statements to execute before the OMP_FOR
3454 statement GS starts. */
3456 static inline gimple_seq
3457 gimple_omp_for_pre_body (gimple gs)
3459 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3460 return gs->gimple_omp_for.pre_body;
3464 /* Set PRE_BODY to be the sequence of statements to execute before the
3465 OMP_FOR statement GS starts. */
3467 static inline void
3468 gimple_omp_for_set_pre_body (gimple gs, gimple_seq pre_body)
3470 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3471 gs->gimple_omp_for.pre_body = pre_body;
3475 /* Return the clauses associated with OMP_PARALLEL GS. */
3477 static inline tree
3478 gimple_omp_parallel_clauses (const_gimple gs)
3480 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3481 return gs->gimple_omp_parallel.clauses;
3485 /* Return a pointer to the clauses associated with OMP_PARALLEL GS. */
3487 static inline tree *
3488 gimple_omp_parallel_clauses_ptr (gimple gs)
3490 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3491 return &gs->gimple_omp_parallel.clauses;
3495 /* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL
3496 GS. */
3498 static inline void
3499 gimple_omp_parallel_set_clauses (gimple gs, tree clauses)
3501 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3502 gs->gimple_omp_parallel.clauses = clauses;
3506 /* Return the child function used to hold the body of OMP_PARALLEL GS. */
3508 static inline tree
3509 gimple_omp_parallel_child_fn (const_gimple gs)
3511 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3512 return gs->gimple_omp_parallel.child_fn;
3515 /* Return a pointer to the child function used to hold the body of
3516 OMP_PARALLEL GS. */
3518 static inline tree *
3519 gimple_omp_parallel_child_fn_ptr (gimple gs)
3521 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3522 return &gs->gimple_omp_parallel.child_fn;
3526 /* Set CHILD_FN to be the child function for OMP_PARALLEL GS. */
3528 static inline void
3529 gimple_omp_parallel_set_child_fn (gimple gs, tree child_fn)
3531 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3532 gs->gimple_omp_parallel.child_fn = child_fn;
3536 /* Return the artificial argument used to send variables and values
3537 from the parent to the children threads in OMP_PARALLEL GS. */
3539 static inline tree
3540 gimple_omp_parallel_data_arg (const_gimple gs)
3542 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3543 return gs->gimple_omp_parallel.data_arg;
3547 /* Return a pointer to the data argument for OMP_PARALLEL GS. */
3549 static inline tree *
3550 gimple_omp_parallel_data_arg_ptr (gimple gs)
3552 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3553 return &gs->gimple_omp_parallel.data_arg;
3557 /* Set DATA_ARG to be the data argument for OMP_PARALLEL GS. */
3559 static inline void
3560 gimple_omp_parallel_set_data_arg (gimple gs, tree data_arg)
3562 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3563 gs->gimple_omp_parallel.data_arg = data_arg;
3567 /* Return the clauses associated with OMP_TASK GS. */
3569 static inline tree
3570 gimple_omp_task_clauses (const_gimple gs)
3572 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3573 return gs->gimple_omp_parallel.clauses;
3577 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3579 static inline tree *
3580 gimple_omp_task_clauses_ptr (gimple gs)
3582 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3583 return &gs->gimple_omp_parallel.clauses;
3587 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3588 GS. */
3590 static inline void
3591 gimple_omp_task_set_clauses (gimple gs, tree clauses)
3593 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3594 gs->gimple_omp_parallel.clauses = clauses;
3598 /* Return the child function used to hold the body of OMP_TASK GS. */
3600 static inline tree
3601 gimple_omp_task_child_fn (const_gimple gs)
3603 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3604 return gs->gimple_omp_parallel.child_fn;
3607 /* Return a pointer to the child function used to hold the body of
3608 OMP_TASK GS. */
3610 static inline tree *
3611 gimple_omp_task_child_fn_ptr (gimple gs)
3613 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3614 return &gs->gimple_omp_parallel.child_fn;
3618 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3620 static inline void
3621 gimple_omp_task_set_child_fn (gimple gs, tree child_fn)
3623 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3624 gs->gimple_omp_parallel.child_fn = child_fn;
3628 /* Return the artificial argument used to send variables and values
3629 from the parent to the children threads in OMP_TASK GS. */
3631 static inline tree
3632 gimple_omp_task_data_arg (const_gimple gs)
3634 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3635 return gs->gimple_omp_parallel.data_arg;
3639 /* Return a pointer to the data argument for OMP_TASK GS. */
3641 static inline tree *
3642 gimple_omp_task_data_arg_ptr (gimple gs)
3644 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3645 return &gs->gimple_omp_parallel.data_arg;
3649 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3651 static inline void
3652 gimple_omp_task_set_data_arg (gimple gs, tree data_arg)
3654 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3655 gs->gimple_omp_parallel.data_arg = data_arg;
3659 /* Return the clauses associated with OMP_TASK GS. */
3661 static inline tree
3662 gimple_omp_taskreg_clauses (const_gimple gs)
3664 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3665 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3666 return gs->gimple_omp_parallel.clauses;
3670 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3672 static inline tree *
3673 gimple_omp_taskreg_clauses_ptr (gimple gs)
3675 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3676 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3677 return &gs->gimple_omp_parallel.clauses;
3681 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3682 GS. */
3684 static inline void
3685 gimple_omp_taskreg_set_clauses (gimple gs, tree clauses)
3687 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3688 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3689 gs->gimple_omp_parallel.clauses = clauses;
3693 /* Return the child function used to hold the body of OMP_TASK GS. */
3695 static inline tree
3696 gimple_omp_taskreg_child_fn (const_gimple gs)
3698 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3699 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3700 return gs->gimple_omp_parallel.child_fn;
3703 /* Return a pointer to the child function used to hold the body of
3704 OMP_TASK GS. */
3706 static inline tree *
3707 gimple_omp_taskreg_child_fn_ptr (gimple gs)
3709 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3710 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3711 return &gs->gimple_omp_parallel.child_fn;
3715 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3717 static inline void
3718 gimple_omp_taskreg_set_child_fn (gimple gs, tree child_fn)
3720 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3721 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3722 gs->gimple_omp_parallel.child_fn = child_fn;
3726 /* Return the artificial argument used to send variables and values
3727 from the parent to the children threads in OMP_TASK GS. */
3729 static inline tree
3730 gimple_omp_taskreg_data_arg (const_gimple gs)
3732 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3733 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3734 return gs->gimple_omp_parallel.data_arg;
3738 /* Return a pointer to the data argument for OMP_TASK GS. */
3740 static inline tree *
3741 gimple_omp_taskreg_data_arg_ptr (gimple gs)
3743 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3744 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3745 return &gs->gimple_omp_parallel.data_arg;
3749 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3751 static inline void
3752 gimple_omp_taskreg_set_data_arg (gimple gs, tree data_arg)
3754 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3755 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3756 gs->gimple_omp_parallel.data_arg = data_arg;
3760 /* Return the copy function used to hold the body of OMP_TASK GS. */
3762 static inline tree
3763 gimple_omp_task_copy_fn (const_gimple gs)
3765 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3766 return gs->gimple_omp_task.copy_fn;
3769 /* Return a pointer to the copy function used to hold the body of
3770 OMP_TASK GS. */
3772 static inline tree *
3773 gimple_omp_task_copy_fn_ptr (gimple gs)
3775 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3776 return &gs->gimple_omp_task.copy_fn;
3780 /* Set CHILD_FN to be the copy function for OMP_TASK GS. */
3782 static inline void
3783 gimple_omp_task_set_copy_fn (gimple gs, tree copy_fn)
3785 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3786 gs->gimple_omp_task.copy_fn = copy_fn;
3790 /* Return size of the data block in bytes in OMP_TASK GS. */
3792 static inline tree
3793 gimple_omp_task_arg_size (const_gimple gs)
3795 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3796 return gs->gimple_omp_task.arg_size;
3800 /* Return a pointer to the data block size for OMP_TASK GS. */
3802 static inline tree *
3803 gimple_omp_task_arg_size_ptr (gimple gs)
3805 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3806 return &gs->gimple_omp_task.arg_size;
3810 /* Set ARG_SIZE to be the data block size for OMP_TASK GS. */
3812 static inline void
3813 gimple_omp_task_set_arg_size (gimple gs, tree arg_size)
3815 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3816 gs->gimple_omp_task.arg_size = arg_size;
3820 /* Return align of the data block in bytes in OMP_TASK GS. */
3822 static inline tree
3823 gimple_omp_task_arg_align (const_gimple gs)
3825 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3826 return gs->gimple_omp_task.arg_align;
3830 /* Return a pointer to the data block align for OMP_TASK GS. */
3832 static inline tree *
3833 gimple_omp_task_arg_align_ptr (gimple gs)
3835 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3836 return &gs->gimple_omp_task.arg_align;
3840 /* Set ARG_SIZE to be the data block align for OMP_TASK GS. */
3842 static inline void
3843 gimple_omp_task_set_arg_align (gimple gs, tree arg_align)
3845 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3846 gs->gimple_omp_task.arg_align = arg_align;
3850 /* Return the clauses associated with OMP_SINGLE GS. */
3852 static inline tree
3853 gimple_omp_single_clauses (const_gimple gs)
3855 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3856 return gs->gimple_omp_single.clauses;
3860 /* Return a pointer to the clauses associated with OMP_SINGLE GS. */
3862 static inline tree *
3863 gimple_omp_single_clauses_ptr (gimple gs)
3865 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3866 return &gs->gimple_omp_single.clauses;
3870 /* Set CLAUSES to be the clauses associated with OMP_SINGLE GS. */
3872 static inline void
3873 gimple_omp_single_set_clauses (gimple gs, tree clauses)
3875 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3876 gs->gimple_omp_single.clauses = clauses;
3880 /* Return the clauses associated with OMP_SECTIONS GS. */
3882 static inline tree
3883 gimple_omp_sections_clauses (const_gimple gs)
3885 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3886 return gs->gimple_omp_sections.clauses;
3890 /* Return a pointer to the clauses associated with OMP_SECTIONS GS. */
3892 static inline tree *
3893 gimple_omp_sections_clauses_ptr (gimple gs)
3895 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3896 return &gs->gimple_omp_sections.clauses;
3900 /* Set CLAUSES to be the set of clauses associated with OMP_SECTIONS
3901 GS. */
3903 static inline void
3904 gimple_omp_sections_set_clauses (gimple gs, tree clauses)
3906 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3907 gs->gimple_omp_sections.clauses = clauses;
3911 /* Return the control variable associated with the GIMPLE_OMP_SECTIONS
3912 in GS. */
3914 static inline tree
3915 gimple_omp_sections_control (const_gimple gs)
3917 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3918 return gs->gimple_omp_sections.control;
3922 /* Return a pointer to the clauses associated with the GIMPLE_OMP_SECTIONS
3923 GS. */
3925 static inline tree *
3926 gimple_omp_sections_control_ptr (gimple gs)
3928 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3929 return &gs->gimple_omp_sections.control;
3933 /* Set CONTROL to be the set of clauses associated with the
3934 GIMPLE_OMP_SECTIONS in GS. */
3936 static inline void
3937 gimple_omp_sections_set_control (gimple gs, tree control)
3939 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3940 gs->gimple_omp_sections.control = control;
3944 /* Set COND to be the condition code for OMP_FOR GS. */
3946 static inline void
3947 gimple_omp_for_set_cond (gimple gs, size_t i, enum tree_code cond)
3949 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3950 gcc_assert (TREE_CODE_CLASS (cond) == tcc_comparison);
3951 gcc_assert (i < gs->gimple_omp_for.collapse);
3952 gs->gimple_omp_for.iter[i].cond = cond;
3956 /* Return the condition code associated with OMP_FOR GS. */
3958 static inline enum tree_code
3959 gimple_omp_for_cond (const_gimple gs, size_t i)
3961 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3962 gcc_assert (i < gs->gimple_omp_for.collapse);
3963 return gs->gimple_omp_for.iter[i].cond;
3967 /* Set the value being stored in an atomic store. */
3969 static inline void
3970 gimple_omp_atomic_store_set_val (gimple g, tree val)
3972 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3973 g->gimple_omp_atomic_store.val = val;
3977 /* Return the value being stored in an atomic store. */
3979 static inline tree
3980 gimple_omp_atomic_store_val (const_gimple g)
3982 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3983 return g->gimple_omp_atomic_store.val;
3987 /* Return a pointer to the value being stored in an atomic store. */
3989 static inline tree *
3990 gimple_omp_atomic_store_val_ptr (gimple g)
3992 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3993 return &g->gimple_omp_atomic_store.val;
3997 /* Set the LHS of an atomic load. */
3999 static inline void
4000 gimple_omp_atomic_load_set_lhs (gimple g, tree lhs)
4002 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4003 g->gimple_omp_atomic_load.lhs = lhs;
4007 /* Get the LHS of an atomic load. */
4009 static inline tree
4010 gimple_omp_atomic_load_lhs (const_gimple g)
4012 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4013 return g->gimple_omp_atomic_load.lhs;
4017 /* Return a pointer to the LHS of an atomic load. */
4019 static inline tree *
4020 gimple_omp_atomic_load_lhs_ptr (gimple g)
4022 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4023 return &g->gimple_omp_atomic_load.lhs;
4027 /* Set the RHS of an atomic load. */
4029 static inline void
4030 gimple_omp_atomic_load_set_rhs (gimple g, tree rhs)
4032 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4033 g->gimple_omp_atomic_load.rhs = rhs;
4037 /* Get the RHS of an atomic load. */
4039 static inline tree
4040 gimple_omp_atomic_load_rhs (const_gimple g)
4042 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4043 return g->gimple_omp_atomic_load.rhs;
4047 /* Return a pointer to the RHS of an atomic load. */
4049 static inline tree *
4050 gimple_omp_atomic_load_rhs_ptr (gimple g)
4052 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4053 return &g->gimple_omp_atomic_load.rhs;
4057 /* Get the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4059 static inline tree
4060 gimple_omp_continue_control_def (const_gimple g)
4062 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4063 return g->gimple_omp_continue.control_def;
4066 /* The same as above, but return the address. */
4068 static inline tree *
4069 gimple_omp_continue_control_def_ptr (gimple g)
4071 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4072 return &g->gimple_omp_continue.control_def;
4075 /* Set the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4077 static inline void
4078 gimple_omp_continue_set_control_def (gimple g, tree def)
4080 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4081 g->gimple_omp_continue.control_def = def;
4085 /* Get the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4087 static inline tree
4088 gimple_omp_continue_control_use (const_gimple g)
4090 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4091 return g->gimple_omp_continue.control_use;
4095 /* The same as above, but return the address. */
4097 static inline tree *
4098 gimple_omp_continue_control_use_ptr (gimple g)
4100 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4101 return &g->gimple_omp_continue.control_use;
4105 /* Set the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4107 static inline void
4108 gimple_omp_continue_set_control_use (gimple g, tree use)
4110 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4111 g->gimple_omp_continue.control_use = use;
4115 /* Return a pointer to the return value for GIMPLE_RETURN GS. */
4117 static inline tree *
4118 gimple_return_retval_ptr (const_gimple gs)
4120 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4121 gcc_assert (gimple_num_ops (gs) == 1);
4122 return gimple_op_ptr (gs, 0);
4125 /* Return the return value for GIMPLE_RETURN GS. */
4127 static inline tree
4128 gimple_return_retval (const_gimple gs)
4130 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4131 gcc_assert (gimple_num_ops (gs) == 1);
4132 return gimple_op (gs, 0);
4136 /* Set RETVAL to be the return value for GIMPLE_RETURN GS. */
4138 static inline void
4139 gimple_return_set_retval (gimple gs, tree retval)
4141 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4142 gcc_assert (gimple_num_ops (gs) == 1);
4143 gcc_assert (retval == NULL_TREE
4144 || TREE_CODE (retval) == RESULT_DECL
4145 || is_gimple_val (retval));
4146 gimple_set_op (gs, 0, retval);
4150 /* Returns true when the gimple statment STMT is any of the OpenMP types. */
4152 static inline bool
4153 is_gimple_omp (const_gimple stmt)
4155 return (gimple_code (stmt) == GIMPLE_OMP_PARALLEL
4156 || gimple_code (stmt) == GIMPLE_OMP_TASK
4157 || gimple_code (stmt) == GIMPLE_OMP_FOR
4158 || gimple_code (stmt) == GIMPLE_OMP_SECTIONS
4159 || gimple_code (stmt) == GIMPLE_OMP_SECTIONS_SWITCH
4160 || gimple_code (stmt) == GIMPLE_OMP_SINGLE
4161 || gimple_code (stmt) == GIMPLE_OMP_SECTION
4162 || gimple_code (stmt) == GIMPLE_OMP_MASTER
4163 || gimple_code (stmt) == GIMPLE_OMP_ORDERED
4164 || gimple_code (stmt) == GIMPLE_OMP_CRITICAL
4165 || gimple_code (stmt) == GIMPLE_OMP_RETURN
4166 || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_LOAD
4167 || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_STORE
4168 || gimple_code (stmt) == GIMPLE_OMP_CONTINUE);
4172 /* Returns TRUE if statement G is a GIMPLE_NOP. */
4174 static inline bool
4175 gimple_nop_p (const_gimple g)
4177 return gimple_code (g) == GIMPLE_NOP;
4181 /* Return the new type set by GIMPLE_CHANGE_DYNAMIC_TYPE statement GS. */
4183 static inline tree
4184 gimple_cdt_new_type (gimple gs)
4186 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4187 return gimple_op (gs, 1);
4190 /* Return a pointer to the new type set by GIMPLE_CHANGE_DYNAMIC_TYPE
4191 statement GS. */
4193 static inline tree *
4194 gimple_cdt_new_type_ptr (gimple gs)
4196 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4197 return gimple_op_ptr (gs, 1);
4200 /* Set NEW_TYPE to be the type returned by GIMPLE_CHANGE_DYNAMIC_TYPE
4201 statement GS. */
4203 static inline void
4204 gimple_cdt_set_new_type (gimple gs, tree new_type)
4206 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4207 gcc_assert (TREE_CODE_CLASS (TREE_CODE (new_type)) == tcc_type);
4208 gimple_set_op (gs, 1, new_type);
4212 /* Return the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE statement GS. */
4214 static inline tree
4215 gimple_cdt_location (gimple gs)
4217 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4218 return gimple_op (gs, 0);
4222 /* Return a pointer to the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE
4223 statement GS. */
4225 static inline tree *
4226 gimple_cdt_location_ptr (gimple gs)
4228 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4229 return gimple_op_ptr (gs, 0);
4233 /* Set PTR to be the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE
4234 statement GS. */
4236 static inline void
4237 gimple_cdt_set_location (gimple gs, tree ptr)
4239 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4240 gimple_set_op (gs, 0, ptr);
4244 /* Return the predictor of GIMPLE_PREDICT statement GS. */
4246 static inline enum br_predictor
4247 gimple_predict_predictor (gimple gs)
4249 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4250 return (enum br_predictor) (gs->gsbase.subcode & ~GF_PREDICT_TAKEN);
4254 /* Set the predictor of GIMPLE_PREDICT statement GS to PREDICT. */
4256 static inline void
4257 gimple_predict_set_predictor (gimple gs, enum br_predictor predictor)
4259 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4260 gs->gsbase.subcode = (gs->gsbase.subcode & GF_PREDICT_TAKEN)
4261 | (unsigned) predictor;
4265 /* Return the outcome of GIMPLE_PREDICT statement GS. */
4267 static inline enum prediction
4268 gimple_predict_outcome (gimple gs)
4270 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4271 return (gs->gsbase.subcode & GF_PREDICT_TAKEN) ? TAKEN : NOT_TAKEN;
4275 /* Set the outcome of GIMPLE_PREDICT statement GS to OUTCOME. */
4277 static inline void
4278 gimple_predict_set_outcome (gimple gs, enum prediction outcome)
4280 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4281 if (outcome == TAKEN)
4282 gs->gsbase.subcode |= GF_PREDICT_TAKEN;
4283 else
4284 gs->gsbase.subcode &= ~GF_PREDICT_TAKEN;
4288 /* Return a new iterator pointing to GIMPLE_SEQ's first statement. */
4290 static inline gimple_stmt_iterator
4291 gsi_start (gimple_seq seq)
4293 gimple_stmt_iterator i;
4295 i.ptr = gimple_seq_first (seq);
4296 i.seq = seq;
4297 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4299 return i;
4303 /* Return a new iterator pointing to the first statement in basic block BB. */
4305 static inline gimple_stmt_iterator
4306 gsi_start_bb (basic_block bb)
4308 gimple_stmt_iterator i;
4309 gimple_seq seq;
4311 seq = bb_seq (bb);
4312 i.ptr = gimple_seq_first (seq);
4313 i.seq = seq;
4314 i.bb = bb;
4316 return i;
4320 /* Return a new iterator initially pointing to GIMPLE_SEQ's last statement. */
4322 static inline gimple_stmt_iterator
4323 gsi_last (gimple_seq seq)
4325 gimple_stmt_iterator i;
4327 i.ptr = gimple_seq_last (seq);
4328 i.seq = seq;
4329 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4331 return i;
4335 /* Return a new iterator pointing to the last statement in basic block BB. */
4337 static inline gimple_stmt_iterator
4338 gsi_last_bb (basic_block bb)
4340 gimple_stmt_iterator i;
4341 gimple_seq seq;
4343 seq = bb_seq (bb);
4344 i.ptr = gimple_seq_last (seq);
4345 i.seq = seq;
4346 i.bb = bb;
4348 return i;
4352 /* Return true if I is at the end of its sequence. */
4354 static inline bool
4355 gsi_end_p (gimple_stmt_iterator i)
4357 return i.ptr == NULL;
4361 /* Return true if I is one statement before the end of its sequence. */
4363 static inline bool
4364 gsi_one_before_end_p (gimple_stmt_iterator i)
4366 return i.ptr != NULL && i.ptr->next == NULL;
4370 /* Advance the iterator to the next gimple statement. */
4372 static inline void
4373 gsi_next (gimple_stmt_iterator *i)
4375 i->ptr = i->ptr->next;
4378 /* Advance the iterator to the previous gimple statement. */
4380 static inline void
4381 gsi_prev (gimple_stmt_iterator *i)
4383 i->ptr = i->ptr->prev;
4386 /* Return the current stmt. */
4388 static inline gimple
4389 gsi_stmt (gimple_stmt_iterator i)
4391 return i.ptr->stmt;
4394 /* Return a block statement iterator that points to the first non-label
4395 statement in block BB. */
4397 static inline gimple_stmt_iterator
4398 gsi_after_labels (basic_block bb)
4400 gimple_stmt_iterator gsi = gsi_start_bb (bb);
4402 while (!gsi_end_p (gsi) && gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL)
4403 gsi_next (&gsi);
4405 return gsi;
4408 /* Return a pointer to the current stmt.
4410 NOTE: You may want to use gsi_replace on the iterator itself,
4411 as this performs additional bookkeeping that will not be done
4412 if you simply assign through a pointer returned by gsi_stmt_ptr. */
4414 static inline gimple *
4415 gsi_stmt_ptr (gimple_stmt_iterator *i)
4417 return &i->ptr->stmt;
4421 /* Return the basic block associated with this iterator. */
4423 static inline basic_block
4424 gsi_bb (gimple_stmt_iterator i)
4426 return i.bb;
4430 /* Return the sequence associated with this iterator. */
4432 static inline gimple_seq
4433 gsi_seq (gimple_stmt_iterator i)
4435 return i.seq;
4439 enum gsi_iterator_update
4441 GSI_NEW_STMT, /* Only valid when single statement is added, move
4442 iterator to it. */
4443 GSI_SAME_STMT, /* Leave the iterator at the same statement. */
4444 GSI_CONTINUE_LINKING /* Move iterator to whatever position is suitable
4445 for linking other statements in the same
4446 direction. */
4449 /* In gimple-iterator.c */
4450 gimple_stmt_iterator gsi_start_phis (basic_block);
4451 gimple_seq gsi_split_seq_after (gimple_stmt_iterator);
4452 gimple_seq gsi_split_seq_before (gimple_stmt_iterator *);
4453 void gsi_replace (gimple_stmt_iterator *, gimple, bool);
4454 void gsi_insert_before (gimple_stmt_iterator *, gimple,
4455 enum gsi_iterator_update);
4456 void gsi_insert_before_without_update (gimple_stmt_iterator *, gimple,
4457 enum gsi_iterator_update);
4458 void gsi_insert_seq_before (gimple_stmt_iterator *, gimple_seq,
4459 enum gsi_iterator_update);
4460 void gsi_insert_seq_before_without_update (gimple_stmt_iterator *, gimple_seq,
4461 enum gsi_iterator_update);
4462 void gsi_insert_after (gimple_stmt_iterator *, gimple,
4463 enum gsi_iterator_update);
4464 void gsi_insert_after_without_update (gimple_stmt_iterator *, gimple,
4465 enum gsi_iterator_update);
4466 void gsi_insert_seq_after (gimple_stmt_iterator *, gimple_seq,
4467 enum gsi_iterator_update);
4468 void gsi_insert_seq_after_without_update (gimple_stmt_iterator *, gimple_seq,
4469 enum gsi_iterator_update);
4470 void gsi_remove (gimple_stmt_iterator *, bool);
4471 gimple_stmt_iterator gsi_for_stmt (gimple);
4472 void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *);
4473 void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *);
4474 void gsi_move_to_bb_end (gimple_stmt_iterator *, struct basic_block_def *);
4475 void gsi_insert_on_edge (edge, gimple);
4476 void gsi_insert_seq_on_edge (edge, gimple_seq);
4477 basic_block gsi_insert_on_edge_immediate (edge, gimple);
4478 basic_block gsi_insert_seq_on_edge_immediate (edge, gimple_seq);
4479 void gsi_commit_one_edge_insert (edge, basic_block *);
4480 void gsi_commit_edge_inserts (void);
4481 gimple gimple_call_copy_skip_args (gimple, bitmap);
4484 /* Convenience routines to walk all statements of a gimple function.
4485 Note that this is useful exclusively before the code is converted
4486 into SSA form. Once the program is in SSA form, the standard
4487 operand interface should be used to analyze/modify statements. */
4488 struct walk_stmt_info
4490 /* Points to the current statement being walked. */
4491 gimple_stmt_iterator gsi;
4493 /* Additional data that the callback functions may want to carry
4494 through the recursion. */
4495 void *info;
4497 /* Pointer map used to mark visited tree nodes when calling
4498 walk_tree on each operand. If set to NULL, duplicate tree nodes
4499 will be visited more than once. */
4500 struct pointer_set_t *pset;
4502 /* Indicates whether the operand being examined may be replaced
4503 with something that matches is_gimple_val (if true) or something
4504 slightly more complicated (if false). "Something" technically
4505 means the common subset of is_gimple_lvalue and is_gimple_rhs,
4506 but we never try to form anything more complicated than that, so
4507 we don't bother checking.
4509 Also note that CALLBACK should update this flag while walking the
4510 sub-expressions of a statement. For instance, when walking the
4511 statement 'foo (&var)', the flag VAL_ONLY will initially be set
4512 to true, however, when walking &var, the operand of that
4513 ADDR_EXPR does not need to be a GIMPLE value. */
4514 bool val_only;
4516 /* True if we are currently walking the LHS of an assignment. */
4517 bool is_lhs;
4519 /* Optional. Set to true by the callback functions if they made any
4520 changes. */
4521 bool changed;
4523 /* True if we're interested in location information. */
4524 bool want_locations;
4526 /* Operand returned by the callbacks. This is set when calling
4527 walk_gimple_seq. If the walk_stmt_fn or walk_tree_fn callback
4528 returns non-NULL, this field will contain the tree returned by
4529 the last callback. */
4530 tree callback_result;
4533 /* Callback for walk_gimple_stmt. Called for every statement found
4534 during traversal. The first argument points to the statement to
4535 walk. The second argument is a flag that the callback sets to
4536 'true' if it the callback handled all the operands and
4537 sub-statements of the statement (the default value of this flag is
4538 'false'). The third argument is an anonymous pointer to data
4539 to be used by the callback. */
4540 typedef tree (*walk_stmt_fn) (gimple_stmt_iterator *, bool *,
4541 struct walk_stmt_info *);
4543 gimple walk_gimple_seq (gimple_seq, walk_stmt_fn, walk_tree_fn,
4544 struct walk_stmt_info *);
4545 tree walk_gimple_stmt (gimple_stmt_iterator *, walk_stmt_fn, walk_tree_fn,
4546 struct walk_stmt_info *);
4547 tree walk_gimple_op (gimple, walk_tree_fn, struct walk_stmt_info *);
4549 #ifdef GATHER_STATISTICS
4550 /* Enum and arrays used for allocation stats. Keep in sync with
4551 gimple.c:gimple_alloc_kind_names. */
4552 enum gimple_alloc_kind
4554 gimple_alloc_kind_assign, /* Assignments. */
4555 gimple_alloc_kind_phi, /* PHI nodes. */
4556 gimple_alloc_kind_cond, /* Conditionals. */
4557 gimple_alloc_kind_seq, /* Sequences. */
4558 gimple_alloc_kind_rest, /* Everything else. */
4559 gimple_alloc_kind_all
4562 extern int gimple_alloc_counts[];
4563 extern int gimple_alloc_sizes[];
4565 /* Return the allocation kind for a given stmt CODE. */
4566 static inline enum gimple_alloc_kind
4567 gimple_alloc_kind (enum gimple_code code)
4569 switch (code)
4571 case GIMPLE_ASSIGN:
4572 return gimple_alloc_kind_assign;
4573 case GIMPLE_PHI:
4574 return gimple_alloc_kind_phi;
4575 case GIMPLE_COND:
4576 return gimple_alloc_kind_cond;
4577 default:
4578 return gimple_alloc_kind_rest;
4581 #endif /* GATHER_STATISTICS */
4583 extern void dump_gimple_statistics (void);
4585 #endif /* GCC_GIMPLE_H */