PR rtl-optimization/40209
[official-gcc.git] / gcc / gimple.h
blob2f16c60538a2089d01d84215a6eb63590e8ecc5e
1 /* Gimple IR definitions.
3 Copyright 2007, 2008, 2009 Free Software Foundation, Inc.
4 Contributed by Aldy Hernandez <aldyh@redhat.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #ifndef GCC_GIMPLE_H
23 #define GCC_GIMPLE_H
25 #include "pointer-set.h"
26 #include "vec.h"
27 #include "ggc.h"
28 #include "tm.h"
29 #include "hard-reg-set.h"
30 #include "basic-block.h"
31 #include "tree-ssa-operands.h"
33 DEF_VEC_P(gimple);
34 DEF_VEC_ALLOC_P(gimple,heap);
35 DEF_VEC_ALLOC_P(gimple,gc);
37 typedef gimple *gimple_p;
38 DEF_VEC_P(gimple_p);
39 DEF_VEC_ALLOC_P(gimple_p,heap);
41 DEF_VEC_P(gimple_seq);
42 DEF_VEC_ALLOC_P(gimple_seq,gc);
43 DEF_VEC_ALLOC_P(gimple_seq,heap);
45 /* For each block, the PHI nodes that need to be rewritten are stored into
46 these vectors. */
47 typedef VEC(gimple, heap) *gimple_vec;
48 DEF_VEC_P (gimple_vec);
49 DEF_VEC_ALLOC_P (gimple_vec, heap);
51 enum gimple_code {
52 #define DEFGSCODE(SYM, STRING, STRUCT) SYM,
53 #include "gimple.def"
54 #undef DEFGSCODE
55 LAST_AND_UNUSED_GIMPLE_CODE
58 extern const char *const gimple_code_name[];
59 extern const unsigned char gimple_rhs_class_table[];
61 /* Error out if a gimple tuple is addressed incorrectly. */
62 #if defined ENABLE_GIMPLE_CHECKING
63 extern void gimple_check_failed (const_gimple, const char *, int, \
64 const char *, enum gimple_code, \
65 enum tree_code) ATTRIBUTE_NORETURN;
67 #define GIMPLE_CHECK(GS, CODE) \
68 do { \
69 const_gimple __gs = (GS); \
70 if (gimple_code (__gs) != (CODE)) \
71 gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__, \
72 (CODE), ERROR_MARK); \
73 } while (0)
74 #else /* not ENABLE_GIMPLE_CHECKING */
75 #define GIMPLE_CHECK(GS, CODE) (void)0
76 #endif
78 /* Class of GIMPLE expressions suitable for the RHS of assignments. See
79 get_gimple_rhs_class. */
80 enum gimple_rhs_class
82 GIMPLE_INVALID_RHS, /* The expression cannot be used on the RHS. */
83 GIMPLE_BINARY_RHS, /* The expression is a binary operation. */
84 GIMPLE_UNARY_RHS, /* The expression is a unary operation. */
85 GIMPLE_SINGLE_RHS /* The expression is a single object (an SSA
86 name, a _DECL, a _REF, etc. */
89 /* Specific flags for individual GIMPLE statements. These flags are
90 always stored in gimple_statement_base.subcode and they may only be
91 defined for statement codes that do not use sub-codes.
93 Values for the masks can overlap as long as the overlapping values
94 are never used in the same statement class.
96 The maximum mask value that can be defined is 1 << 15 (i.e., each
97 statement code can hold up to 16 bitflags).
99 Keep this list sorted. */
100 enum gf_mask {
101 GF_ASM_INPUT = 1 << 0,
102 GF_ASM_VOLATILE = 1 << 1,
103 GF_CALL_CANNOT_INLINE = 1 << 0,
104 GF_CALL_FROM_THUNK = 1 << 1,
105 GF_CALL_RETURN_SLOT_OPT = 1 << 2,
106 GF_CALL_TAILCALL = 1 << 3,
107 GF_CALL_VA_ARG_PACK = 1 << 4,
108 GF_OMP_PARALLEL_COMBINED = 1 << 0,
110 /* True on an GIMPLE_OMP_RETURN statement if the return does not require
111 a thread synchronization via some sort of barrier. The exact barrier
112 that would otherwise be emitted is dependent on the OMP statement with
113 which this return is associated. */
114 GF_OMP_RETURN_NOWAIT = 1 << 0,
116 GF_OMP_SECTION_LAST = 1 << 0,
117 GF_PREDICT_TAKEN = 1 << 15
120 /* Masks for selecting a pass local flag (PLF) to work on. These
121 masks are used by gimple_set_plf and gimple_plf. */
122 enum plf_mask {
123 GF_PLF_1 = 1 << 0,
124 GF_PLF_2 = 1 << 1
127 /* A node in a gimple_seq_d. */
128 struct GTY((chain_next ("%h.next"), chain_prev ("%h.prev"))) gimple_seq_node_d {
129 gimple stmt;
130 struct gimple_seq_node_d *prev;
131 struct gimple_seq_node_d *next;
134 /* A double-linked sequence of gimple statements. */
135 struct GTY ((chain_next ("%h.next_free"))) gimple_seq_d {
136 /* First and last statements in the sequence. */
137 gimple_seq_node first;
138 gimple_seq_node last;
140 /* Sequences are created/destroyed frequently. To minimize
141 allocation activity, deallocated sequences are kept in a pool of
142 available sequences. This is the pointer to the next free
143 sequence in the pool. */
144 gimple_seq next_free;
148 /* Return the first node in GIMPLE sequence S. */
150 static inline gimple_seq_node
151 gimple_seq_first (const_gimple_seq s)
153 return s ? s->first : NULL;
157 /* Return the first statement in GIMPLE sequence S. */
159 static inline gimple
160 gimple_seq_first_stmt (const_gimple_seq s)
162 gimple_seq_node n = gimple_seq_first (s);
163 return (n) ? n->stmt : NULL;
167 /* Return the last node in GIMPLE sequence S. */
169 static inline gimple_seq_node
170 gimple_seq_last (const_gimple_seq s)
172 return s ? s->last : NULL;
176 /* Return the last statement in GIMPLE sequence S. */
178 static inline gimple
179 gimple_seq_last_stmt (const_gimple_seq s)
181 gimple_seq_node n = gimple_seq_last (s);
182 return (n) ? n->stmt : NULL;
186 /* Set the last node in GIMPLE sequence S to LAST. */
188 static inline void
189 gimple_seq_set_last (gimple_seq s, gimple_seq_node last)
191 s->last = last;
195 /* Set the first node in GIMPLE sequence S to FIRST. */
197 static inline void
198 gimple_seq_set_first (gimple_seq s, gimple_seq_node first)
200 s->first = first;
204 /* Return true if GIMPLE sequence S is empty. */
206 static inline bool
207 gimple_seq_empty_p (const_gimple_seq s)
209 return s == NULL || s->first == NULL;
213 void gimple_seq_add_stmt (gimple_seq *, gimple);
215 /* Allocate a new sequence and initialize its first element with STMT. */
217 static inline gimple_seq
218 gimple_seq_alloc_with_stmt (gimple stmt)
220 gimple_seq seq = NULL;
221 gimple_seq_add_stmt (&seq, stmt);
222 return seq;
226 /* Returns the sequence of statements in BB. */
228 static inline gimple_seq
229 bb_seq (const_basic_block bb)
231 return (!(bb->flags & BB_RTL) && bb->il.gimple) ? bb->il.gimple->seq : NULL;
235 /* Sets the sequence of statements in BB to SEQ. */
237 static inline void
238 set_bb_seq (basic_block bb, gimple_seq seq)
240 gcc_assert (!(bb->flags & BB_RTL));
241 bb->il.gimple->seq = seq;
244 /* Iterator object for GIMPLE statement sequences. */
246 typedef struct
248 /* Sequence node holding the current statement. */
249 gimple_seq_node ptr;
251 /* Sequence and basic block holding the statement. These fields
252 are necessary to handle edge cases such as when statement is
253 added to an empty basic block or when the last statement of a
254 block/sequence is removed. */
255 gimple_seq seq;
256 basic_block bb;
257 } gimple_stmt_iterator;
260 /* Data structure definitions for GIMPLE tuples. NOTE: word markers
261 are for 64 bit hosts. */
263 struct GTY(()) gimple_statement_base {
264 /* [ WORD 1 ]
265 Main identifying code for a tuple. */
266 ENUM_BITFIELD(gimple_code) code : 8;
268 /* Nonzero if a warning should not be emitted on this tuple. */
269 unsigned int no_warning : 1;
271 /* Nonzero if this tuple has been visited. Passes are responsible
272 for clearing this bit before using it. */
273 unsigned int visited : 1;
275 /* Nonzero if this tuple represents a non-temporal move. */
276 unsigned int nontemporal_move : 1;
278 /* Pass local flags. These flags are free for any pass to use as
279 they see fit. Passes should not assume that these flags contain
280 any useful value when the pass starts. Any initial state that
281 the pass requires should be set on entry to the pass. See
282 gimple_set_plf and gimple_plf for usage. */
283 unsigned int plf : 2;
285 /* Nonzero if this statement has been modified and needs to have its
286 operands rescanned. */
287 unsigned modified : 1;
289 /* Nonzero if this statement contains volatile operands. */
290 unsigned has_volatile_ops : 1;
292 /* Padding to get subcode to 16 bit alignment. */
293 unsigned pad : 1;
295 /* The SUBCODE field can be used for tuple-specific flags for tuples
296 that do not require subcodes. Note that SUBCODE should be at
297 least as wide as tree codes, as several tuples store tree codes
298 in there. */
299 unsigned int subcode : 16;
301 /* UID of this statement. This is used by passes that want to
302 assign IDs to statements. It must be assigned and used by each
303 pass. By default it should be assumed to contain garbage. */
304 unsigned uid;
306 /* [ WORD 2 ]
307 Locus information for debug info. */
308 location_t location;
310 /* Number of operands in this tuple. */
311 unsigned num_ops;
313 /* [ WORD 3 ]
314 Basic block holding this statement. */
315 struct basic_block_def *bb;
317 /* [ WORD 4 ]
318 Lexical block holding this statement. */
319 tree block;
323 /* Base structure for tuples with operands. */
325 struct GTY(()) gimple_statement_with_ops_base
327 /* [ WORD 1-4 ] */
328 struct gimple_statement_base gsbase;
330 /* [ WORD 5-6 ]
331 SSA operand vectors. NOTE: It should be possible to
332 amalgamate these vectors with the operand vector OP. However,
333 the SSA operand vectors are organized differently and contain
334 more information (like immediate use chaining). */
335 struct def_optype_d GTY((skip (""))) *def_ops;
336 struct use_optype_d GTY((skip (""))) *use_ops;
340 /* Statements that take register operands. */
342 struct GTY(()) gimple_statement_with_ops
344 /* [ WORD 1-6 ] */
345 struct gimple_statement_with_ops_base opbase;
347 /* [ WORD 7 ]
348 Operand vector. NOTE! This must always be the last field
349 of this structure. In particular, this means that this
350 structure cannot be embedded inside another one. */
351 tree GTY((length ("%h.opbase.gsbase.num_ops"))) op[1];
355 /* Base for statements that take both memory and register operands. */
357 struct GTY(()) gimple_statement_with_memory_ops_base
359 /* [ WORD 1-6 ] */
360 struct gimple_statement_with_ops_base opbase;
362 /* [ WORD 7-8 ]
363 Virtual operands for this statement. The GC will pick them
364 up via the ssa_names array. */
365 tree GTY((skip (""))) vdef;
366 tree GTY((skip (""))) vuse;
370 /* Statements that take both memory and register operands. */
372 struct GTY(()) gimple_statement_with_memory_ops
374 /* [ WORD 1-8 ] */
375 struct gimple_statement_with_memory_ops_base membase;
377 /* [ WORD 9 ]
378 Operand vector. NOTE! This must always be the last field
379 of this structure. In particular, this means that this
380 structure cannot be embedded inside another one. */
381 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
385 /* OpenMP statements (#pragma omp). */
387 struct GTY(()) gimple_statement_omp {
388 /* [ WORD 1-4 ] */
389 struct gimple_statement_base gsbase;
391 /* [ WORD 5 ] */
392 gimple_seq body;
396 /* GIMPLE_BIND */
398 struct GTY(()) gimple_statement_bind {
399 /* [ WORD 1-4 ] */
400 struct gimple_statement_base gsbase;
402 /* [ WORD 5 ]
403 Variables declared in this scope. */
404 tree vars;
406 /* [ WORD 6 ]
407 This is different than the BLOCK field in gimple_statement_base,
408 which is analogous to TREE_BLOCK (i.e., the lexical block holding
409 this statement). This field is the equivalent of BIND_EXPR_BLOCK
410 in tree land (i.e., the lexical scope defined by this bind). See
411 gimple-low.c. */
412 tree block;
414 /* [ WORD 7 ] */
415 gimple_seq body;
419 /* GIMPLE_CATCH */
421 struct GTY(()) gimple_statement_catch {
422 /* [ WORD 1-4 ] */
423 struct gimple_statement_base gsbase;
425 /* [ WORD 5 ] */
426 tree types;
428 /* [ WORD 6 ] */
429 gimple_seq handler;
433 /* GIMPLE_EH_FILTER */
435 struct GTY(()) gimple_statement_eh_filter {
436 /* [ WORD 1-4 ] */
437 struct gimple_statement_base gsbase;
439 /* Subcode: EH_FILTER_MUST_NOT_THROW. A boolean flag analogous to
440 the tree counterpart. */
442 /* [ WORD 5 ]
443 Filter types. */
444 tree types;
446 /* [ WORD 6 ]
447 Failure actions. */
448 gimple_seq failure;
452 /* GIMPLE_PHI */
454 struct GTY(()) gimple_statement_phi {
455 /* [ WORD 1-4 ] */
456 struct gimple_statement_base gsbase;
458 /* [ WORD 5 ] */
459 unsigned capacity;
460 unsigned nargs;
462 /* [ WORD 6 ] */
463 tree result;
465 /* [ WORD 7 ] */
466 struct phi_arg_d GTY ((length ("%h.nargs"))) args[1];
470 /* GIMPLE_RESX */
472 struct GTY(()) gimple_statement_resx {
473 /* [ WORD 1-4 ] */
474 struct gimple_statement_base gsbase;
476 /* [ WORD 5 ]
477 Exception region number. */
478 int region;
482 /* GIMPLE_TRY */
484 struct GTY(()) gimple_statement_try {
485 /* [ WORD 1-4 ] */
486 struct gimple_statement_base gsbase;
488 /* [ WORD 5 ]
489 Expression to evaluate. */
490 gimple_seq eval;
492 /* [ WORD 6 ]
493 Cleanup expression. */
494 gimple_seq cleanup;
497 /* Kind of GIMPLE_TRY statements. */
498 enum gimple_try_flags
500 /* A try/catch. */
501 GIMPLE_TRY_CATCH = 1 << 0,
503 /* A try/finally. */
504 GIMPLE_TRY_FINALLY = 1 << 1,
505 GIMPLE_TRY_KIND = GIMPLE_TRY_CATCH | GIMPLE_TRY_FINALLY,
507 /* Analogous to TRY_CATCH_IS_CLEANUP. */
508 GIMPLE_TRY_CATCH_IS_CLEANUP = 1 << 2
511 /* GIMPLE_WITH_CLEANUP_EXPR */
513 struct GTY(()) gimple_statement_wce {
514 /* [ WORD 1-4 ] */
515 struct gimple_statement_base gsbase;
517 /* Subcode: CLEANUP_EH_ONLY. True if the cleanup should only be
518 executed if an exception is thrown, not on normal exit of its
519 scope. This flag is analogous to the CLEANUP_EH_ONLY flag
520 in TARGET_EXPRs. */
522 /* [ WORD 5 ]
523 Cleanup expression. */
524 gimple_seq cleanup;
528 /* GIMPLE_ASM */
530 struct GTY(()) gimple_statement_asm
532 /* [ WORD 1-8 ] */
533 struct gimple_statement_with_memory_ops_base membase;
535 /* [ WORD 9 ]
536 __asm__ statement. */
537 const char *string;
539 /* [ WORD 10 ]
540 Number of inputs, outputs and clobbers. */
541 unsigned char ni;
542 unsigned char no;
543 unsigned short nc;
545 /* [ WORD 11 ]
546 Operand vector. NOTE! This must always be the last field
547 of this structure. In particular, this means that this
548 structure cannot be embedded inside another one. */
549 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
552 /* GIMPLE_OMP_CRITICAL */
554 struct GTY(()) gimple_statement_omp_critical {
555 /* [ WORD 1-5 ] */
556 struct gimple_statement_omp omp;
558 /* [ WORD 6 ]
559 Critical section name. */
560 tree name;
564 struct GTY(()) gimple_omp_for_iter {
565 /* Condition code. */
566 enum tree_code cond;
568 /* Index variable. */
569 tree index;
571 /* Initial value. */
572 tree initial;
574 /* Final value. */
575 tree final;
577 /* Increment. */
578 tree incr;
581 /* GIMPLE_OMP_FOR */
583 struct GTY(()) gimple_statement_omp_for {
584 /* [ WORD 1-5 ] */
585 struct gimple_statement_omp omp;
587 /* [ WORD 6 ] */
588 tree clauses;
590 /* [ WORD 7 ]
591 Number of elements in iter array. */
592 size_t collapse;
594 /* [ WORD 8 ] */
595 struct gimple_omp_for_iter * GTY((length ("%h.collapse"))) iter;
597 /* [ WORD 9 ]
598 Pre-body evaluated before the loop body begins. */
599 gimple_seq pre_body;
603 /* GIMPLE_OMP_PARALLEL */
605 struct GTY(()) gimple_statement_omp_parallel {
606 /* [ WORD 1-5 ] */
607 struct gimple_statement_omp omp;
609 /* [ WORD 6 ]
610 Clauses. */
611 tree clauses;
613 /* [ WORD 7 ]
614 Child function holding the body of the parallel region. */
615 tree child_fn;
617 /* [ WORD 8 ]
618 Shared data argument. */
619 tree data_arg;
623 /* GIMPLE_OMP_TASK */
625 struct GTY(()) gimple_statement_omp_task {
626 /* [ WORD 1-8 ] */
627 struct gimple_statement_omp_parallel par;
629 /* [ WORD 9 ]
630 Child function holding firstprivate initialization if needed. */
631 tree copy_fn;
633 /* [ WORD 10-11 ]
634 Size and alignment in bytes of the argument data block. */
635 tree arg_size;
636 tree arg_align;
640 /* GIMPLE_OMP_SECTION */
641 /* Uses struct gimple_statement_omp. */
644 /* GIMPLE_OMP_SECTIONS */
646 struct GTY(()) gimple_statement_omp_sections {
647 /* [ WORD 1-5 ] */
648 struct gimple_statement_omp omp;
650 /* [ WORD 6 ] */
651 tree clauses;
653 /* [ WORD 7 ]
654 The control variable used for deciding which of the sections to
655 execute. */
656 tree control;
659 /* GIMPLE_OMP_CONTINUE.
661 Note: This does not inherit from gimple_statement_omp, because we
662 do not need the body field. */
664 struct GTY(()) gimple_statement_omp_continue {
665 /* [ WORD 1-4 ] */
666 struct gimple_statement_base gsbase;
668 /* [ WORD 5 ] */
669 tree control_def;
671 /* [ WORD 6 ] */
672 tree control_use;
675 /* GIMPLE_OMP_SINGLE */
677 struct GTY(()) gimple_statement_omp_single {
678 /* [ WORD 1-5 ] */
679 struct gimple_statement_omp omp;
681 /* [ WORD 6 ] */
682 tree clauses;
686 /* GIMPLE_OMP_ATOMIC_LOAD.
687 Note: This is based on gimple_statement_base, not g_s_omp, because g_s_omp
688 contains a sequence, which we don't need here. */
690 struct GTY(()) gimple_statement_omp_atomic_load {
691 /* [ WORD 1-4 ] */
692 struct gimple_statement_base gsbase;
694 /* [ WORD 5-6 ] */
695 tree rhs, lhs;
698 /* GIMPLE_OMP_ATOMIC_STORE.
699 See note on GIMPLE_OMP_ATOMIC_LOAD. */
701 struct GTY(()) gimple_statement_omp_atomic_store {
702 /* [ WORD 1-4 ] */
703 struct gimple_statement_base gsbase;
705 /* [ WORD 5 ] */
706 tree val;
709 enum gimple_statement_structure_enum {
710 #define DEFGSSTRUCT(SYM, STRING) SYM,
711 #include "gsstruct.def"
712 #undef DEFGSSTRUCT
713 LAST_GSS_ENUM
717 /* Define the overall contents of a gimple tuple. It may be any of the
718 structures declared above for various types of tuples. */
720 union GTY ((desc ("gimple_statement_structure (&%h)"))) gimple_statement_d {
721 struct gimple_statement_base GTY ((tag ("GSS_BASE"))) gsbase;
722 struct gimple_statement_with_ops GTY ((tag ("GSS_WITH_OPS"))) gsops;
723 struct gimple_statement_with_memory_ops GTY ((tag ("GSS_WITH_MEM_OPS"))) gsmem;
724 struct gimple_statement_omp GTY ((tag ("GSS_OMP"))) omp;
725 struct gimple_statement_bind GTY ((tag ("GSS_BIND"))) gimple_bind;
726 struct gimple_statement_catch GTY ((tag ("GSS_CATCH"))) gimple_catch;
727 struct gimple_statement_eh_filter GTY ((tag ("GSS_EH_FILTER"))) gimple_eh_filter;
728 struct gimple_statement_phi GTY ((tag ("GSS_PHI"))) gimple_phi;
729 struct gimple_statement_resx GTY ((tag ("GSS_RESX"))) gimple_resx;
730 struct gimple_statement_try GTY ((tag ("GSS_TRY"))) gimple_try;
731 struct gimple_statement_wce GTY ((tag ("GSS_WCE"))) gimple_wce;
732 struct gimple_statement_asm GTY ((tag ("GSS_ASM"))) gimple_asm;
733 struct gimple_statement_omp_critical GTY ((tag ("GSS_OMP_CRITICAL"))) gimple_omp_critical;
734 struct gimple_statement_omp_for GTY ((tag ("GSS_OMP_FOR"))) gimple_omp_for;
735 struct gimple_statement_omp_parallel GTY ((tag ("GSS_OMP_PARALLEL"))) gimple_omp_parallel;
736 struct gimple_statement_omp_task GTY ((tag ("GSS_OMP_TASK"))) gimple_omp_task;
737 struct gimple_statement_omp_sections GTY ((tag ("GSS_OMP_SECTIONS"))) gimple_omp_sections;
738 struct gimple_statement_omp_single GTY ((tag ("GSS_OMP_SINGLE"))) gimple_omp_single;
739 struct gimple_statement_omp_continue GTY ((tag ("GSS_OMP_CONTINUE"))) gimple_omp_continue;
740 struct gimple_statement_omp_atomic_load GTY ((tag ("GSS_OMP_ATOMIC_LOAD"))) gimple_omp_atomic_load;
741 struct gimple_statement_omp_atomic_store GTY ((tag ("GSS_OMP_ATOMIC_STORE"))) gimple_omp_atomic_store;
744 /* In gimple.c. */
745 gimple gimple_build_return (tree);
747 gimple gimple_build_assign_stat (tree, tree MEM_STAT_DECL);
748 #define gimple_build_assign(l,r) gimple_build_assign_stat (l, r MEM_STAT_INFO)
750 void extract_ops_from_tree (tree, enum tree_code *, tree *, tree *);
752 gimple gimple_build_assign_with_ops_stat (enum tree_code, tree, tree,
753 tree MEM_STAT_DECL);
754 #define gimple_build_assign_with_ops(c,o1,o2,o3) \
755 gimple_build_assign_with_ops_stat (c, o1, o2, o3 MEM_STAT_INFO)
757 gimple gimple_build_call_vec (tree, VEC(tree, heap) *);
758 gimple gimple_build_call (tree, unsigned, ...);
759 gimple gimple_build_call_from_tree (tree);
760 gimple gimplify_assign (tree, tree, gimple_seq *);
761 gimple gimple_build_cond (enum tree_code, tree, tree, tree, tree);
762 gimple gimple_build_label (tree label);
763 gimple gimple_build_goto (tree dest);
764 gimple gimple_build_nop (void);
765 gimple gimple_build_bind (tree, gimple_seq, tree);
766 gimple gimple_build_asm (const char *, unsigned, unsigned, unsigned, ...);
767 gimple gimple_build_asm_vec (const char *, VEC(tree,gc) *, VEC(tree,gc) *,
768 VEC(tree,gc) *);
769 gimple gimple_build_catch (tree, gimple_seq);
770 gimple gimple_build_eh_filter (tree, gimple_seq);
771 gimple gimple_build_try (gimple_seq, gimple_seq, enum gimple_try_flags);
772 gimple gimple_build_wce (gimple_seq);
773 gimple gimple_build_resx (int);
774 gimple gimple_build_switch (unsigned, tree, tree, ...);
775 gimple gimple_build_switch_vec (tree, tree, VEC(tree,heap) *);
776 gimple gimple_build_omp_parallel (gimple_seq, tree, tree, tree);
777 gimple gimple_build_omp_task (gimple_seq, tree, tree, tree, tree, tree, tree);
778 gimple gimple_build_omp_for (gimple_seq, tree, size_t, gimple_seq);
779 gimple gimple_build_omp_critical (gimple_seq, tree);
780 gimple gimple_build_omp_section (gimple_seq);
781 gimple gimple_build_omp_continue (tree, tree);
782 gimple gimple_build_omp_master (gimple_seq);
783 gimple gimple_build_omp_return (bool);
784 gimple gimple_build_omp_ordered (gimple_seq);
785 gimple gimple_build_omp_sections (gimple_seq, tree);
786 gimple gimple_build_omp_sections_switch (void);
787 gimple gimple_build_omp_single (gimple_seq, tree);
788 gimple gimple_build_cdt (tree, tree);
789 gimple gimple_build_omp_atomic_load (tree, tree);
790 gimple gimple_build_omp_atomic_store (tree);
791 gimple gimple_build_predict (enum br_predictor, enum prediction);
792 enum gimple_statement_structure_enum gimple_statement_structure (gimple);
793 enum gimple_statement_structure_enum gss_for_assign (enum tree_code);
794 void sort_case_labels (VEC(tree,heap) *);
795 void gimple_set_body (tree, gimple_seq);
796 gimple_seq gimple_body (tree);
797 bool gimple_has_body_p (tree);
798 gimple_seq gimple_seq_alloc (void);
799 void gimple_seq_free (gimple_seq);
800 void gimple_seq_add_seq (gimple_seq *, gimple_seq);
801 gimple_seq gimple_seq_copy (gimple_seq);
802 int gimple_call_flags (const_gimple);
803 bool gimple_assign_copy_p (gimple);
804 bool gimple_assign_ssa_name_copy_p (gimple);
805 bool gimple_assign_single_p (gimple);
806 bool gimple_assign_unary_nop_p (gimple);
807 void gimple_set_bb (gimple, struct basic_block_def *);
808 tree gimple_fold (const_gimple);
809 void gimple_assign_set_rhs_from_tree (gimple_stmt_iterator *, tree);
810 void gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *, enum tree_code,
811 tree, tree);
812 tree gimple_get_lhs (const_gimple);
813 void gimple_set_lhs (gimple, tree);
814 gimple gimple_copy (gimple);
815 bool is_gimple_operand (const_tree);
816 void gimple_set_modified (gimple, bool);
817 void gimple_cond_get_ops_from_tree (tree, enum tree_code *, tree *, tree *);
818 gimple gimple_build_cond_from_tree (tree, tree, tree);
819 void gimple_cond_set_condition_from_tree (gimple, tree);
820 bool gimple_has_side_effects (const_gimple);
821 bool gimple_rhs_has_side_effects (const_gimple);
822 bool gimple_could_trap_p (gimple);
823 bool gimple_assign_rhs_could_trap_p (gimple);
824 void gimple_regimplify_operands (gimple, gimple_stmt_iterator *);
825 bool empty_body_p (gimple_seq);
826 unsigned get_gimple_rhs_num_ops (enum tree_code);
828 /* Returns true iff T is a valid GIMPLE statement. */
829 extern bool is_gimple_stmt (tree);
831 /* Returns true iff TYPE is a valid type for a scalar register variable. */
832 extern bool is_gimple_reg_type (tree);
833 /* Returns true iff T is a scalar register variable. */
834 extern bool is_gimple_reg (tree);
835 /* Returns true iff T is any sort of variable. */
836 extern bool is_gimple_variable (tree);
837 /* Returns true iff T is any sort of symbol. */
838 extern bool is_gimple_id (tree);
839 /* Returns true iff T is a variable or an INDIRECT_REF (of a variable). */
840 extern bool is_gimple_min_lval (tree);
841 /* Returns true iff T is something whose address can be taken. */
842 extern bool is_gimple_addressable (tree);
843 /* Returns true iff T is any valid GIMPLE lvalue. */
844 extern bool is_gimple_lvalue (tree);
846 /* Returns true iff T is a GIMPLE address. */
847 bool is_gimple_address (const_tree);
848 /* Returns true iff T is a GIMPLE invariant address. */
849 bool is_gimple_invariant_address (const_tree);
850 /* Returns true iff T is a GIMPLE invariant address at interprocedural
851 level. */
852 bool is_gimple_ip_invariant_address (const_tree);
853 /* Returns true iff T is a valid GIMPLE constant. */
854 bool is_gimple_constant (const_tree);
855 /* Returns true iff T is a GIMPLE restricted function invariant. */
856 extern bool is_gimple_min_invariant (const_tree);
857 /* Returns true iff T is a GIMPLE restricted interprecodural invariant. */
858 extern bool is_gimple_ip_invariant (const_tree);
859 /* Returns true iff T is a GIMPLE rvalue. */
860 extern bool is_gimple_val (tree);
861 /* Returns true iff T is a GIMPLE asm statement input. */
862 extern bool is_gimple_asm_val (tree);
863 /* Returns true iff T is a valid rhs for a MODIFY_EXPR where the LHS is a
864 GIMPLE temporary, a renamed user variable, or something else,
865 respectively. */
866 extern bool is_gimple_reg_rhs (tree);
867 extern bool is_gimple_mem_rhs (tree);
869 /* Returns true iff T is a valid if-statement condition. */
870 extern bool is_gimple_condexpr (tree);
872 /* Returns true iff T is a type conversion. */
873 extern bool is_gimple_cast (tree);
874 /* Returns true iff T is a variable that does not need to live in memory. */
875 extern bool is_gimple_non_addressable (tree t);
877 /* Returns true iff T is a valid call address expression. */
878 extern bool is_gimple_call_addr (tree);
879 /* If T makes a function call, returns the CALL_EXPR operand. */
880 extern tree get_call_expr_in (tree t);
882 extern void recalculate_side_effects (tree);
883 extern void count_uses_and_derefs (tree, gimple, unsigned *, unsigned *,
884 unsigned *);
885 extern bool walk_stmt_load_store_addr_ops (gimple, void *,
886 bool (*)(gimple, tree, void *),
887 bool (*)(gimple, tree, void *),
888 bool (*)(gimple, tree, void *));
889 extern bool walk_stmt_load_store_ops (gimple, void *,
890 bool (*)(gimple, tree, void *),
891 bool (*)(gimple, tree, void *));
892 extern bool gimple_ior_addresses_taken (bitmap, gimple);
894 /* In gimplify.c */
895 extern tree create_tmp_var_raw (tree, const char *);
896 extern tree create_tmp_var_name (const char *);
897 extern tree create_tmp_var (tree, const char *);
898 extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq *);
899 extern tree get_formal_tmp_var (tree, gimple_seq *);
900 extern void declare_vars (tree, gimple, bool);
901 extern void tree_annotate_all_with_location (tree *, location_t);
902 extern void annotate_all_with_location (gimple_seq, location_t);
904 /* Validation of GIMPLE expressions. Note that these predicates only check
905 the basic form of the expression, they don't recurse to make sure that
906 underlying nodes are also of the right form. */
907 typedef bool (*gimple_predicate)(tree);
910 /* FIXME we should deduce this from the predicate. */
911 enum fallback {
912 fb_none = 0, /* Do not generate a temporary. */
914 fb_rvalue = 1, /* Generate an rvalue to hold the result of a
915 gimplified expression. */
917 fb_lvalue = 2, /* Generate an lvalue to hold the result of a
918 gimplified expression. */
920 fb_mayfail = 4, /* Gimplification may fail. Error issued
921 afterwards. */
922 fb_either= fb_rvalue | fb_lvalue
925 typedef int fallback_t;
927 enum gimplify_status {
928 GS_ERROR = -2, /* Something Bad Seen. */
929 GS_UNHANDLED = -1, /* A langhook result for "I dunno". */
930 GS_OK = 0, /* We did something, maybe more to do. */
931 GS_ALL_DONE = 1 /* The expression is fully gimplified. */
934 struct gimplify_ctx
936 struct gimplify_ctx *prev_context;
938 VEC(gimple,heap) *bind_expr_stack;
939 tree temps;
940 gimple_seq conditional_cleanups;
941 tree exit_label;
942 tree return_temp;
944 VEC(tree,heap) *case_labels;
945 /* The formal temporary table. Should this be persistent? */
946 htab_t temp_htab;
948 int conditions;
949 bool save_stack;
950 bool into_ssa;
951 bool allow_rhs_cond_expr;
954 extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *,
955 bool (*) (tree), fallback_t);
956 extern void gimplify_type_sizes (tree, gimple_seq *);
957 extern void gimplify_one_sizepos (tree *, gimple_seq *);
958 extern bool gimplify_stmt (tree *, gimple_seq *);
959 extern gimple gimplify_body (tree *, tree, bool);
960 extern void push_gimplify_context (struct gimplify_ctx *);
961 extern void pop_gimplify_context (gimple);
962 extern void gimplify_and_add (tree, gimple_seq *);
964 /* Miscellaneous helpers. */
965 extern void gimple_add_tmp_var (tree);
966 extern gimple gimple_current_bind_expr (void);
967 extern VEC(gimple, heap) *gimple_bind_expr_stack (void);
968 extern tree voidify_wrapper_expr (tree, tree);
969 extern tree build_and_jump (tree *);
970 extern tree alloc_stmt_list (void);
971 extern void free_stmt_list (tree);
972 extern tree force_labels_r (tree *, int *, void *);
973 extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *,
974 gimple_seq *);
975 struct gimplify_omp_ctx;
976 extern void omp_firstprivatize_variable (struct gimplify_omp_ctx *, tree);
977 extern tree gimple_boolify (tree);
978 extern gimple_predicate rhs_predicate_for (tree);
979 extern tree canonicalize_cond_expr_cond (tree);
981 /* In omp-low.c. */
982 extern tree omp_reduction_init (tree, tree);
984 /* In tree-nested.c. */
985 extern void lower_nested_functions (tree);
986 extern void insert_field_into_struct (tree, tree);
988 /* In gimplify.c. */
989 extern void gimplify_function_tree (tree);
991 /* In cfgexpand.c. */
992 extern tree gimple_assign_rhs_to_tree (gimple);
994 /* In builtins.c */
995 extern bool validate_gimple_arglist (const_gimple, ...);
997 /* In tree-ssa.c */
998 extern bool tree_ssa_useless_type_conversion (tree);
999 extern tree tree_ssa_strip_useless_type_conversions (tree);
1000 extern bool useless_type_conversion_p (tree, tree);
1001 extern bool types_compatible_p (tree, tree);
1003 /* Return the code for GIMPLE statement G. */
1005 static inline enum gimple_code
1006 gimple_code (const_gimple g)
1008 return g->gsbase.code;
1012 /* Return true if statement G has sub-statements. This is only true for
1013 High GIMPLE statements. */
1015 static inline bool
1016 gimple_has_substatements (gimple g)
1018 switch (gimple_code (g))
1020 case GIMPLE_BIND:
1021 case GIMPLE_CATCH:
1022 case GIMPLE_EH_FILTER:
1023 case GIMPLE_TRY:
1024 case GIMPLE_OMP_FOR:
1025 case GIMPLE_OMP_MASTER:
1026 case GIMPLE_OMP_ORDERED:
1027 case GIMPLE_OMP_SECTION:
1028 case GIMPLE_OMP_PARALLEL:
1029 case GIMPLE_OMP_TASK:
1030 case GIMPLE_OMP_SECTIONS:
1031 case GIMPLE_OMP_SINGLE:
1032 case GIMPLE_OMP_CRITICAL:
1033 case GIMPLE_WITH_CLEANUP_EXPR:
1034 return true;
1036 default:
1037 return false;
1042 /* Return the basic block holding statement G. */
1044 static inline struct basic_block_def *
1045 gimple_bb (const_gimple g)
1047 return g->gsbase.bb;
1051 /* Return the lexical scope block holding statement G. */
1053 static inline tree
1054 gimple_block (const_gimple g)
1056 return g->gsbase.block;
1060 /* Set BLOCK to be the lexical scope block holding statement G. */
1062 static inline void
1063 gimple_set_block (gimple g, tree block)
1065 g->gsbase.block = block;
1069 /* Return location information for statement G. */
1071 static inline location_t
1072 gimple_location (const_gimple g)
1074 return g->gsbase.location;
1077 /* Return pointer to location information for statement G. */
1079 static inline const location_t *
1080 gimple_location_ptr (const_gimple g)
1082 return &g->gsbase.location;
1086 /* Set location information for statement G. */
1088 static inline void
1089 gimple_set_location (gimple g, location_t location)
1091 g->gsbase.location = location;
1095 /* Return true if G contains location information. */
1097 static inline bool
1098 gimple_has_location (const_gimple g)
1100 return gimple_location (g) != UNKNOWN_LOCATION;
1104 /* Return the file name of the location of STMT. */
1106 static inline const char *
1107 gimple_filename (const_gimple stmt)
1109 return LOCATION_FILE (gimple_location (stmt));
1113 /* Return the line number of the location of STMT. */
1115 static inline int
1116 gimple_lineno (const_gimple stmt)
1118 return LOCATION_LINE (gimple_location (stmt));
1122 /* Determine whether SEQ is a singleton. */
1124 static inline bool
1125 gimple_seq_singleton_p (gimple_seq seq)
1127 return ((gimple_seq_first (seq) != NULL)
1128 && (gimple_seq_first (seq) == gimple_seq_last (seq)));
1131 /* Return true if no warnings should be emitted for statement STMT. */
1133 static inline bool
1134 gimple_no_warning_p (const_gimple stmt)
1136 return stmt->gsbase.no_warning;
1139 /* Set the no_warning flag of STMT to NO_WARNING. */
1141 static inline void
1142 gimple_set_no_warning (gimple stmt, bool no_warning)
1144 stmt->gsbase.no_warning = (unsigned) no_warning;
1147 /* Set the visited status on statement STMT to VISITED_P. */
1149 static inline void
1150 gimple_set_visited (gimple stmt, bool visited_p)
1152 stmt->gsbase.visited = (unsigned) visited_p;
1156 /* Return the visited status for statement STMT. */
1158 static inline bool
1159 gimple_visited_p (gimple stmt)
1161 return stmt->gsbase.visited;
1165 /* Set pass local flag PLF on statement STMT to VAL_P. */
1167 static inline void
1168 gimple_set_plf (gimple stmt, enum plf_mask plf, bool val_p)
1170 if (val_p)
1171 stmt->gsbase.plf |= (unsigned int) plf;
1172 else
1173 stmt->gsbase.plf &= ~((unsigned int) plf);
1177 /* Return the value of pass local flag PLF on statement STMT. */
1179 static inline unsigned int
1180 gimple_plf (gimple stmt, enum plf_mask plf)
1182 return stmt->gsbase.plf & ((unsigned int) plf);
1186 /* Set the UID of statement. */
1188 static inline void
1189 gimple_set_uid (gimple g, unsigned uid)
1191 g->gsbase.uid = uid;
1195 /* Return the UID of statement. */
1197 static inline unsigned
1198 gimple_uid (const_gimple g)
1200 return g->gsbase.uid;
1204 /* Return true if GIMPLE statement G has register or memory operands. */
1206 static inline bool
1207 gimple_has_ops (const_gimple g)
1209 return gimple_code (g) >= GIMPLE_COND && gimple_code (g) <= GIMPLE_RETURN;
1213 /* Return true if GIMPLE statement G has memory operands. */
1215 static inline bool
1216 gimple_has_mem_ops (const_gimple g)
1218 return gimple_code (g) >= GIMPLE_ASSIGN && gimple_code (g) <= GIMPLE_RETURN;
1222 /* Return the set of DEF operands for statement G. */
1224 static inline struct def_optype_d *
1225 gimple_def_ops (const_gimple g)
1227 if (!gimple_has_ops (g))
1228 return NULL;
1229 return g->gsops.opbase.def_ops;
1233 /* Set DEF to be the set of DEF operands for statement G. */
1235 static inline void
1236 gimple_set_def_ops (gimple g, struct def_optype_d *def)
1238 gcc_assert (gimple_has_ops (g));
1239 g->gsops.opbase.def_ops = def;
1243 /* Return the set of USE operands for statement G. */
1245 static inline struct use_optype_d *
1246 gimple_use_ops (const_gimple g)
1248 if (!gimple_has_ops (g))
1249 return NULL;
1250 return g->gsops.opbase.use_ops;
1254 /* Set USE to be the set of USE operands for statement G. */
1256 static inline void
1257 gimple_set_use_ops (gimple g, struct use_optype_d *use)
1259 gcc_assert (gimple_has_ops (g));
1260 g->gsops.opbase.use_ops = use;
1264 /* Return the set of VUSE operand for statement G. */
1266 static inline use_operand_p
1267 gimple_vuse_op (const_gimple g)
1269 struct use_optype_d *ops;
1270 if (!gimple_has_mem_ops (g))
1271 return NULL_USE_OPERAND_P;
1272 ops = g->gsops.opbase.use_ops;
1273 if (ops
1274 && USE_OP_PTR (ops)->use == &g->gsmem.membase.vuse)
1275 return USE_OP_PTR (ops);
1276 return NULL_USE_OPERAND_P;
1279 /* Return the set of VDEF operand for statement G. */
1281 static inline def_operand_p
1282 gimple_vdef_op (const_gimple g)
1284 struct def_optype_d *ops;
1285 if (!gimple_has_mem_ops (g))
1286 return NULL_DEF_OPERAND_P;
1287 ops = g->gsops.opbase.def_ops;
1288 if (ops
1289 && DEF_OP_PTR (ops) == &g->gsmem.membase.vdef)
1290 return DEF_OP_PTR (ops);
1291 return NULL_DEF_OPERAND_P;
1295 /* Return the single VUSE operand of the statement G. */
1297 static inline tree
1298 gimple_vuse (const_gimple g)
1300 if (!gimple_has_mem_ops (g))
1301 return NULL_TREE;
1302 return g->gsmem.membase.vuse;
1305 /* Return the single VDEF operand of the statement G. */
1307 static inline tree
1308 gimple_vdef (const_gimple g)
1310 if (!gimple_has_mem_ops (g))
1311 return NULL_TREE;
1312 return g->gsmem.membase.vdef;
1315 /* Return the single VUSE operand of the statement G. */
1317 static inline tree *
1318 gimple_vuse_ptr (gimple g)
1320 if (!gimple_has_mem_ops (g))
1321 return NULL;
1322 return &g->gsmem.membase.vuse;
1325 /* Return the single VDEF operand of the statement G. */
1327 static inline tree *
1328 gimple_vdef_ptr (gimple g)
1330 if (!gimple_has_mem_ops (g))
1331 return NULL;
1332 return &g->gsmem.membase.vdef;
1335 /* Set the single VUSE operand of the statement G. */
1337 static inline void
1338 gimple_set_vuse (gimple g, tree vuse)
1340 gcc_assert (gimple_has_mem_ops (g));
1341 g->gsmem.membase.vuse = vuse;
1344 /* Set the single VDEF operand of the statement G. */
1346 static inline void
1347 gimple_set_vdef (gimple g, tree vdef)
1349 gcc_assert (gimple_has_mem_ops (g));
1350 g->gsmem.membase.vdef = vdef;
1354 /* Return true if statement G has operands and the modified field has
1355 been set. */
1357 static inline bool
1358 gimple_modified_p (const_gimple g)
1360 return (gimple_has_ops (g)) ? (bool) g->gsbase.modified : false;
1364 /* Return the tree code for the expression computed by STMT. This is
1365 only valid for GIMPLE_COND, GIMPLE_CALL and GIMPLE_ASSIGN. For
1366 GIMPLE_CALL, return CALL_EXPR as the expression code for
1367 consistency. This is useful when the caller needs to deal with the
1368 three kinds of computation that GIMPLE supports. */
1370 static inline enum tree_code
1371 gimple_expr_code (const_gimple stmt)
1373 enum gimple_code code = gimple_code (stmt);
1374 if (code == GIMPLE_ASSIGN || code == GIMPLE_COND)
1375 return (enum tree_code) stmt->gsbase.subcode;
1376 else if (code == GIMPLE_CALL)
1377 return CALL_EXPR;
1378 else
1379 gcc_unreachable ();
1383 /* Mark statement S as modified, and update it. */
1385 static inline void
1386 update_stmt (gimple s)
1388 if (gimple_has_ops (s))
1390 gimple_set_modified (s, true);
1391 update_stmt_operands (s);
1395 /* Update statement S if it has been optimized. */
1397 static inline void
1398 update_stmt_if_modified (gimple s)
1400 if (gimple_modified_p (s))
1401 update_stmt_operands (s);
1404 /* Return true if statement STMT contains volatile operands. */
1406 static inline bool
1407 gimple_has_volatile_ops (const_gimple stmt)
1409 if (gimple_has_mem_ops (stmt))
1410 return stmt->gsbase.has_volatile_ops;
1411 else
1412 return false;
1416 /* Set the HAS_VOLATILE_OPS flag to VOLATILEP. */
1418 static inline void
1419 gimple_set_has_volatile_ops (gimple stmt, bool volatilep)
1421 if (gimple_has_mem_ops (stmt))
1422 stmt->gsbase.has_volatile_ops = (unsigned) volatilep;
1426 /* Return true if statement STMT may access memory. */
1428 static inline bool
1429 gimple_references_memory_p (gimple stmt)
1431 return gimple_has_mem_ops (stmt) && gimple_vuse (stmt);
1435 /* Return the subcode for OMP statement S. */
1437 static inline unsigned
1438 gimple_omp_subcode (const_gimple s)
1440 gcc_assert (gimple_code (s) >= GIMPLE_OMP_ATOMIC_LOAD
1441 && gimple_code (s) <= GIMPLE_OMP_SINGLE);
1442 return s->gsbase.subcode;
1445 /* Set the subcode for OMP statement S to SUBCODE. */
1447 static inline void
1448 gimple_omp_set_subcode (gimple s, unsigned int subcode)
1450 /* We only have 16 bits for the subcode. Assert that we are not
1451 overflowing it. */
1452 gcc_assert (subcode < (1 << 16));
1453 s->gsbase.subcode = subcode;
1456 /* Set the nowait flag on OMP_RETURN statement S. */
1458 static inline void
1459 gimple_omp_return_set_nowait (gimple s)
1461 GIMPLE_CHECK (s, GIMPLE_OMP_RETURN);
1462 s->gsbase.subcode |= GF_OMP_RETURN_NOWAIT;
1466 /* Return true if OMP return statement G has the GF_OMP_RETURN_NOWAIT
1467 flag set. */
1469 static inline bool
1470 gimple_omp_return_nowait_p (const_gimple g)
1472 GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
1473 return (gimple_omp_subcode (g) & GF_OMP_RETURN_NOWAIT) != 0;
1477 /* Return true if OMP section statement G has the GF_OMP_SECTION_LAST
1478 flag set. */
1480 static inline bool
1481 gimple_omp_section_last_p (const_gimple g)
1483 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1484 return (gimple_omp_subcode (g) & GF_OMP_SECTION_LAST) != 0;
1488 /* Set the GF_OMP_SECTION_LAST flag on G. */
1490 static inline void
1491 gimple_omp_section_set_last (gimple g)
1493 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1494 g->gsbase.subcode |= GF_OMP_SECTION_LAST;
1498 /* Return true if OMP parallel statement G has the
1499 GF_OMP_PARALLEL_COMBINED flag set. */
1501 static inline bool
1502 gimple_omp_parallel_combined_p (const_gimple g)
1504 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1505 return (gimple_omp_subcode (g) & GF_OMP_PARALLEL_COMBINED) != 0;
1509 /* Set the GF_OMP_PARALLEL_COMBINED field in G depending on the boolean
1510 value of COMBINED_P. */
1512 static inline void
1513 gimple_omp_parallel_set_combined_p (gimple g, bool combined_p)
1515 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1516 if (combined_p)
1517 g->gsbase.subcode |= GF_OMP_PARALLEL_COMBINED;
1518 else
1519 g->gsbase.subcode &= ~GF_OMP_PARALLEL_COMBINED;
1523 /* Return the number of operands for statement GS. */
1525 static inline unsigned
1526 gimple_num_ops (const_gimple gs)
1528 return gs->gsbase.num_ops;
1532 /* Set the number of operands for statement GS. */
1534 static inline void
1535 gimple_set_num_ops (gimple gs, unsigned num_ops)
1537 gs->gsbase.num_ops = num_ops;
1541 /* Return the array of operands for statement GS. */
1543 static inline tree *
1544 gimple_ops (gimple gs)
1546 /* Offset in bytes to the location of the operand vector in every
1547 tuple structure. Defined in gimple.c */
1548 extern size_t const gimple_ops_offset_[];
1550 if (!gimple_has_ops (gs))
1551 return NULL;
1553 /* All the tuples have their operand vector at the very bottom
1554 of the structure. */
1555 return ((tree *) ((char *) gs + gimple_ops_offset_[gimple_code (gs)]));
1559 /* Return operand I for statement GS. */
1561 static inline tree
1562 gimple_op (const_gimple gs, unsigned i)
1564 if (gimple_has_ops (gs))
1566 gcc_assert (i < gimple_num_ops (gs));
1567 return gimple_ops (CONST_CAST_GIMPLE (gs))[i];
1569 else
1570 return NULL_TREE;
1573 /* Return a pointer to operand I for statement GS. */
1575 static inline tree *
1576 gimple_op_ptr (const_gimple gs, unsigned i)
1578 if (gimple_has_ops (gs))
1580 gcc_assert (i < gimple_num_ops (gs));
1581 return gimple_ops (CONST_CAST_GIMPLE (gs)) + i;
1583 else
1584 return NULL;
1587 /* Set operand I of statement GS to OP. */
1589 static inline void
1590 gimple_set_op (gimple gs, unsigned i, tree op)
1592 gcc_assert (gimple_has_ops (gs) && i < gimple_num_ops (gs));
1594 /* Note. It may be tempting to assert that OP matches
1595 is_gimple_operand, but that would be wrong. Different tuples
1596 accept slightly different sets of tree operands. Each caller
1597 should perform its own validation. */
1598 gimple_ops (gs)[i] = op;
1601 /* Return true if GS is a GIMPLE_ASSIGN. */
1603 static inline bool
1604 is_gimple_assign (const_gimple gs)
1606 return gimple_code (gs) == GIMPLE_ASSIGN;
1609 /* Determine if expression CODE is one of the valid expressions that can
1610 be used on the RHS of GIMPLE assignments. */
1612 static inline enum gimple_rhs_class
1613 get_gimple_rhs_class (enum tree_code code)
1615 return (enum gimple_rhs_class) gimple_rhs_class_table[(int) code];
1618 /* Return the LHS of assignment statement GS. */
1620 static inline tree
1621 gimple_assign_lhs (const_gimple gs)
1623 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1624 return gimple_op (gs, 0);
1628 /* Return a pointer to the LHS of assignment statement GS. */
1630 static inline tree *
1631 gimple_assign_lhs_ptr (const_gimple gs)
1633 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1634 return gimple_op_ptr (gs, 0);
1638 /* Set LHS to be the LHS operand of assignment statement GS. */
1640 static inline void
1641 gimple_assign_set_lhs (gimple gs, tree lhs)
1643 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1644 gcc_assert (is_gimple_operand (lhs));
1645 gimple_set_op (gs, 0, lhs);
1647 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1648 SSA_NAME_DEF_STMT (lhs) = gs;
1652 /* Return the first operand on the RHS of assignment statement GS. */
1654 static inline tree
1655 gimple_assign_rhs1 (const_gimple gs)
1657 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1658 return gimple_op (gs, 1);
1662 /* Return a pointer to the first operand on the RHS of assignment
1663 statement GS. */
1665 static inline tree *
1666 gimple_assign_rhs1_ptr (const_gimple gs)
1668 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1669 return gimple_op_ptr (gs, 1);
1672 /* Set RHS to be the first operand on the RHS of assignment statement GS. */
1674 static inline void
1675 gimple_assign_set_rhs1 (gimple gs, tree rhs)
1677 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1679 /* If there are 3 or more operands, the 2 operands on the RHS must be
1680 GIMPLE values. */
1681 if (gimple_num_ops (gs) >= 3)
1682 gcc_assert (is_gimple_val (rhs));
1683 else
1684 gcc_assert (is_gimple_operand (rhs));
1686 gimple_set_op (gs, 1, rhs);
1690 /* Return the second operand on the RHS of assignment statement GS.
1691 If GS does not have two operands, NULL is returned instead. */
1693 static inline tree
1694 gimple_assign_rhs2 (const_gimple gs)
1696 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1698 if (gimple_num_ops (gs) >= 3)
1699 return gimple_op (gs, 2);
1700 else
1701 return NULL_TREE;
1705 /* Return a pointer to the second operand on the RHS of assignment
1706 statement GS. */
1708 static inline tree *
1709 gimple_assign_rhs2_ptr (const_gimple gs)
1711 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1712 return gimple_op_ptr (gs, 2);
1716 /* Set RHS to be the second operand on the RHS of assignment statement GS. */
1718 static inline void
1719 gimple_assign_set_rhs2 (gimple gs, tree rhs)
1721 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1723 /* The 2 operands on the RHS must be GIMPLE values. */
1724 gcc_assert (is_gimple_val (rhs));
1726 gimple_set_op (gs, 2, rhs);
1729 /* Returns true if GS is a nontemporal move. */
1731 static inline bool
1732 gimple_assign_nontemporal_move_p (const_gimple gs)
1734 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1735 return gs->gsbase.nontemporal_move;
1738 /* Sets nontemporal move flag of GS to NONTEMPORAL. */
1740 static inline void
1741 gimple_assign_set_nontemporal_move (gimple gs, bool nontemporal)
1743 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1744 gs->gsbase.nontemporal_move = nontemporal;
1748 /* Return the code of the expression computed on the rhs of assignment
1749 statement GS. In case that the RHS is a single object, returns the
1750 tree code of the object. */
1752 static inline enum tree_code
1753 gimple_assign_rhs_code (const_gimple gs)
1755 enum tree_code code;
1756 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1758 code = gimple_expr_code (gs);
1759 if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS)
1760 code = TREE_CODE (gimple_assign_rhs1 (gs));
1762 return code;
1766 /* Set CODE to be the code for the expression computed on the RHS of
1767 assignment S. */
1769 static inline void
1770 gimple_assign_set_rhs_code (gimple s, enum tree_code code)
1772 GIMPLE_CHECK (s, GIMPLE_ASSIGN);
1773 s->gsbase.subcode = code;
1777 /* Return the gimple rhs class of the code of the expression computed on
1778 the rhs of assignment statement GS.
1779 This will never return GIMPLE_INVALID_RHS. */
1781 static inline enum gimple_rhs_class
1782 gimple_assign_rhs_class (const_gimple gs)
1784 return get_gimple_rhs_class (gimple_assign_rhs_code (gs));
1788 /* Return true if S is a type-cast assignment. */
1790 static inline bool
1791 gimple_assign_cast_p (gimple s)
1793 if (is_gimple_assign (s))
1795 enum tree_code sc = gimple_assign_rhs_code (s);
1796 return CONVERT_EXPR_CODE_P (sc)
1797 || sc == VIEW_CONVERT_EXPR
1798 || sc == FIX_TRUNC_EXPR;
1801 return false;
1805 /* Return true if GS is a GIMPLE_CALL. */
1807 static inline bool
1808 is_gimple_call (const_gimple gs)
1810 return gimple_code (gs) == GIMPLE_CALL;
1813 /* Return the LHS of call statement GS. */
1815 static inline tree
1816 gimple_call_lhs (const_gimple gs)
1818 GIMPLE_CHECK (gs, GIMPLE_CALL);
1819 return gimple_op (gs, 0);
1823 /* Return a pointer to the LHS of call statement GS. */
1825 static inline tree *
1826 gimple_call_lhs_ptr (const_gimple gs)
1828 GIMPLE_CHECK (gs, GIMPLE_CALL);
1829 return gimple_op_ptr (gs, 0);
1833 /* Set LHS to be the LHS operand of call statement GS. */
1835 static inline void
1836 gimple_call_set_lhs (gimple gs, tree lhs)
1838 GIMPLE_CHECK (gs, GIMPLE_CALL);
1839 gcc_assert (!lhs || is_gimple_operand (lhs));
1840 gimple_set_op (gs, 0, lhs);
1841 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1842 SSA_NAME_DEF_STMT (lhs) = gs;
1846 /* Return the tree node representing the function called by call
1847 statement GS. */
1849 static inline tree
1850 gimple_call_fn (const_gimple gs)
1852 GIMPLE_CHECK (gs, GIMPLE_CALL);
1853 return gimple_op (gs, 1);
1857 /* Return a pointer to the tree node representing the function called by call
1858 statement GS. */
1860 static inline tree *
1861 gimple_call_fn_ptr (const_gimple gs)
1863 GIMPLE_CHECK (gs, GIMPLE_CALL);
1864 return gimple_op_ptr (gs, 1);
1868 /* Set FN to be the function called by call statement GS. */
1870 static inline void
1871 gimple_call_set_fn (gimple gs, tree fn)
1873 GIMPLE_CHECK (gs, GIMPLE_CALL);
1874 gcc_assert (is_gimple_operand (fn));
1875 gimple_set_op (gs, 1, fn);
1879 /* Set FNDECL to be the function called by call statement GS. */
1881 static inline void
1882 gimple_call_set_fndecl (gimple gs, tree decl)
1884 GIMPLE_CHECK (gs, GIMPLE_CALL);
1885 gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
1886 gimple_set_op (gs, 1, build_fold_addr_expr_loc (gimple_location (gs), decl));
1890 /* If a given GIMPLE_CALL's callee is a FUNCTION_DECL, return it.
1891 Otherwise return NULL. This function is analogous to
1892 get_callee_fndecl in tree land. */
1894 static inline tree
1895 gimple_call_fndecl (const_gimple gs)
1897 tree addr = gimple_call_fn (gs);
1898 if (TREE_CODE (addr) == ADDR_EXPR)
1900 gcc_assert (TREE_CODE (TREE_OPERAND (addr, 0)) == FUNCTION_DECL);
1901 return TREE_OPERAND (addr, 0);
1903 return NULL_TREE;
1907 /* Return the type returned by call statement GS. */
1909 static inline tree
1910 gimple_call_return_type (const_gimple gs)
1912 tree fn = gimple_call_fn (gs);
1913 tree type = TREE_TYPE (fn);
1915 /* See through the pointer. */
1916 gcc_assert (POINTER_TYPE_P (type));
1917 type = TREE_TYPE (type);
1919 gcc_assert (TREE_CODE (type) == FUNCTION_TYPE
1920 || TREE_CODE (type) == METHOD_TYPE);
1922 /* The type returned by a FUNCTION_DECL is the type of its
1923 function type. */
1924 return TREE_TYPE (type);
1928 /* Return the static chain for call statement GS. */
1930 static inline tree
1931 gimple_call_chain (const_gimple gs)
1933 GIMPLE_CHECK (gs, GIMPLE_CALL);
1934 return gimple_op (gs, 2);
1938 /* Return a pointer to the static chain for call statement GS. */
1940 static inline tree *
1941 gimple_call_chain_ptr (const_gimple gs)
1943 GIMPLE_CHECK (gs, GIMPLE_CALL);
1944 return gimple_op_ptr (gs, 2);
1947 /* Set CHAIN to be the static chain for call statement GS. */
1949 static inline void
1950 gimple_call_set_chain (gimple gs, tree chain)
1952 GIMPLE_CHECK (gs, GIMPLE_CALL);
1953 gcc_assert (chain == NULL
1954 || TREE_CODE (chain) == ADDR_EXPR
1955 || SSA_VAR_P (chain));
1956 gimple_set_op (gs, 2, chain);
1960 /* Return the number of arguments used by call statement GS. */
1962 static inline unsigned
1963 gimple_call_num_args (const_gimple gs)
1965 unsigned num_ops;
1966 GIMPLE_CHECK (gs, GIMPLE_CALL);
1967 num_ops = gimple_num_ops (gs);
1968 gcc_assert (num_ops >= 3);
1969 return num_ops - 3;
1973 /* Return the argument at position INDEX for call statement GS. */
1975 static inline tree
1976 gimple_call_arg (const_gimple gs, unsigned index)
1978 GIMPLE_CHECK (gs, GIMPLE_CALL);
1979 return gimple_op (gs, index + 3);
1983 /* Return a pointer to the argument at position INDEX for call
1984 statement GS. */
1986 static inline tree *
1987 gimple_call_arg_ptr (const_gimple gs, unsigned index)
1989 GIMPLE_CHECK (gs, GIMPLE_CALL);
1990 return gimple_op_ptr (gs, index + 3);
1994 /* Set ARG to be the argument at position INDEX for call statement GS. */
1996 static inline void
1997 gimple_call_set_arg (gimple gs, unsigned index, tree arg)
1999 GIMPLE_CHECK (gs, GIMPLE_CALL);
2000 gcc_assert (is_gimple_operand (arg));
2001 gimple_set_op (gs, index + 3, arg);
2005 /* If TAIL_P is true, mark call statement S as being a tail call
2006 (i.e., a call just before the exit of a function). These calls are
2007 candidate for tail call optimization. */
2009 static inline void
2010 gimple_call_set_tail (gimple s, bool tail_p)
2012 GIMPLE_CHECK (s, GIMPLE_CALL);
2013 if (tail_p)
2014 s->gsbase.subcode |= GF_CALL_TAILCALL;
2015 else
2016 s->gsbase.subcode &= ~GF_CALL_TAILCALL;
2020 /* Return true if GIMPLE_CALL S is marked as a tail call. */
2022 static inline bool
2023 gimple_call_tail_p (gimple s)
2025 GIMPLE_CHECK (s, GIMPLE_CALL);
2026 return (s->gsbase.subcode & GF_CALL_TAILCALL) != 0;
2030 /* Set the inlinable status of GIMPLE_CALL S to INLINABLE_P. */
2032 static inline void
2033 gimple_call_set_cannot_inline (gimple s, bool inlinable_p)
2035 GIMPLE_CHECK (s, GIMPLE_CALL);
2036 if (inlinable_p)
2037 s->gsbase.subcode |= GF_CALL_CANNOT_INLINE;
2038 else
2039 s->gsbase.subcode &= ~GF_CALL_CANNOT_INLINE;
2043 /* Return true if GIMPLE_CALL S cannot be inlined. */
2045 static inline bool
2046 gimple_call_cannot_inline_p (gimple s)
2048 GIMPLE_CHECK (s, GIMPLE_CALL);
2049 return (s->gsbase.subcode & GF_CALL_CANNOT_INLINE) != 0;
2053 /* If RETURN_SLOT_OPT_P is true mark GIMPLE_CALL S as valid for return
2054 slot optimization. This transformation uses the target of the call
2055 expansion as the return slot for calls that return in memory. */
2057 static inline void
2058 gimple_call_set_return_slot_opt (gimple s, bool return_slot_opt_p)
2060 GIMPLE_CHECK (s, GIMPLE_CALL);
2061 if (return_slot_opt_p)
2062 s->gsbase.subcode |= GF_CALL_RETURN_SLOT_OPT;
2063 else
2064 s->gsbase.subcode &= ~GF_CALL_RETURN_SLOT_OPT;
2068 /* Return true if S is marked for return slot optimization. */
2070 static inline bool
2071 gimple_call_return_slot_opt_p (gimple s)
2073 GIMPLE_CHECK (s, GIMPLE_CALL);
2074 return (s->gsbase.subcode & GF_CALL_RETURN_SLOT_OPT) != 0;
2078 /* If FROM_THUNK_P is true, mark GIMPLE_CALL S as being the jump from a
2079 thunk to the thunked-to function. */
2081 static inline void
2082 gimple_call_set_from_thunk (gimple s, bool from_thunk_p)
2084 GIMPLE_CHECK (s, GIMPLE_CALL);
2085 if (from_thunk_p)
2086 s->gsbase.subcode |= GF_CALL_FROM_THUNK;
2087 else
2088 s->gsbase.subcode &= ~GF_CALL_FROM_THUNK;
2092 /* Return true if GIMPLE_CALL S is a jump from a thunk. */
2094 static inline bool
2095 gimple_call_from_thunk_p (gimple s)
2097 GIMPLE_CHECK (s, GIMPLE_CALL);
2098 return (s->gsbase.subcode & GF_CALL_FROM_THUNK) != 0;
2102 /* If PASS_ARG_PACK_P is true, GIMPLE_CALL S is a stdarg call that needs the
2103 argument pack in its argument list. */
2105 static inline void
2106 gimple_call_set_va_arg_pack (gimple s, bool pass_arg_pack_p)
2108 GIMPLE_CHECK (s, GIMPLE_CALL);
2109 if (pass_arg_pack_p)
2110 s->gsbase.subcode |= GF_CALL_VA_ARG_PACK;
2111 else
2112 s->gsbase.subcode &= ~GF_CALL_VA_ARG_PACK;
2116 /* Return true if GIMPLE_CALL S is a stdarg call that needs the
2117 argument pack in its argument list. */
2119 static inline bool
2120 gimple_call_va_arg_pack_p (gimple s)
2122 GIMPLE_CHECK (s, GIMPLE_CALL);
2123 return (s->gsbase.subcode & GF_CALL_VA_ARG_PACK) != 0;
2127 /* Return true if S is a noreturn call. */
2129 static inline bool
2130 gimple_call_noreturn_p (gimple s)
2132 GIMPLE_CHECK (s, GIMPLE_CALL);
2133 return (gimple_call_flags (s) & ECF_NORETURN) != 0;
2137 /* Return true if S is a nothrow call. */
2139 static inline bool
2140 gimple_call_nothrow_p (gimple s)
2142 GIMPLE_CHECK (s, GIMPLE_CALL);
2143 return (gimple_call_flags (s) & ECF_NOTHROW) != 0;
2147 /* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL. */
2149 static inline void
2150 gimple_call_copy_flags (gimple dest_call, gimple orig_call)
2152 GIMPLE_CHECK (dest_call, GIMPLE_CALL);
2153 GIMPLE_CHECK (orig_call, GIMPLE_CALL);
2154 dest_call->gsbase.subcode = orig_call->gsbase.subcode;
2158 /* Returns true if this is a GIMPLE_ASSIGN or a GIMPLE_CALL with a
2159 non-NULL lhs. */
2161 static inline bool
2162 gimple_has_lhs (gimple stmt)
2164 return (is_gimple_assign (stmt)
2165 || (is_gimple_call (stmt)
2166 && gimple_call_lhs (stmt) != NULL_TREE));
2170 /* Return the code of the predicate computed by conditional statement GS. */
2172 static inline enum tree_code
2173 gimple_cond_code (const_gimple gs)
2175 GIMPLE_CHECK (gs, GIMPLE_COND);
2176 return (enum tree_code) gs->gsbase.subcode;
2180 /* Set CODE to be the predicate code for the conditional statement GS. */
2182 static inline void
2183 gimple_cond_set_code (gimple gs, enum tree_code code)
2185 GIMPLE_CHECK (gs, GIMPLE_COND);
2186 gcc_assert (TREE_CODE_CLASS (code) == tcc_comparison);
2187 gs->gsbase.subcode = code;
2191 /* Return the LHS of the predicate computed by conditional statement GS. */
2193 static inline tree
2194 gimple_cond_lhs (const_gimple gs)
2196 GIMPLE_CHECK (gs, GIMPLE_COND);
2197 return gimple_op (gs, 0);
2200 /* Return the pointer to the LHS of the predicate computed by conditional
2201 statement GS. */
2203 static inline tree *
2204 gimple_cond_lhs_ptr (const_gimple gs)
2206 GIMPLE_CHECK (gs, GIMPLE_COND);
2207 return gimple_op_ptr (gs, 0);
2210 /* Set LHS to be the LHS operand of the predicate computed by
2211 conditional statement GS. */
2213 static inline void
2214 gimple_cond_set_lhs (gimple gs, tree lhs)
2216 GIMPLE_CHECK (gs, GIMPLE_COND);
2217 gcc_assert (is_gimple_operand (lhs));
2218 gimple_set_op (gs, 0, lhs);
2222 /* Return the RHS operand of the predicate computed by conditional GS. */
2224 static inline tree
2225 gimple_cond_rhs (const_gimple gs)
2227 GIMPLE_CHECK (gs, GIMPLE_COND);
2228 return gimple_op (gs, 1);
2231 /* Return the pointer to the RHS operand of the predicate computed by
2232 conditional GS. */
2234 static inline tree *
2235 gimple_cond_rhs_ptr (const_gimple gs)
2237 GIMPLE_CHECK (gs, GIMPLE_COND);
2238 return gimple_op_ptr (gs, 1);
2242 /* Set RHS to be the RHS operand of the predicate computed by
2243 conditional statement GS. */
2245 static inline void
2246 gimple_cond_set_rhs (gimple gs, tree rhs)
2248 GIMPLE_CHECK (gs, GIMPLE_COND);
2249 gcc_assert (is_gimple_operand (rhs));
2250 gimple_set_op (gs, 1, rhs);
2254 /* Return the label used by conditional statement GS when its
2255 predicate evaluates to true. */
2257 static inline tree
2258 gimple_cond_true_label (const_gimple gs)
2260 GIMPLE_CHECK (gs, GIMPLE_COND);
2261 return gimple_op (gs, 2);
2265 /* Set LABEL to be the label used by conditional statement GS when its
2266 predicate evaluates to true. */
2268 static inline void
2269 gimple_cond_set_true_label (gimple gs, tree label)
2271 GIMPLE_CHECK (gs, GIMPLE_COND);
2272 gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
2273 gimple_set_op (gs, 2, label);
2277 /* Set LABEL to be the label used by conditional statement GS when its
2278 predicate evaluates to false. */
2280 static inline void
2281 gimple_cond_set_false_label (gimple gs, tree label)
2283 GIMPLE_CHECK (gs, GIMPLE_COND);
2284 gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
2285 gimple_set_op (gs, 3, label);
2289 /* Return the label used by conditional statement GS when its
2290 predicate evaluates to false. */
2292 static inline tree
2293 gimple_cond_false_label (const_gimple gs)
2295 GIMPLE_CHECK (gs, GIMPLE_COND);
2296 return gimple_op (gs, 3);
2300 /* Set the conditional COND_STMT to be of the form 'if (1 == 0)'. */
2302 static inline void
2303 gimple_cond_make_false (gimple gs)
2305 gimple_cond_set_lhs (gs, boolean_true_node);
2306 gimple_cond_set_rhs (gs, boolean_false_node);
2307 gs->gsbase.subcode = EQ_EXPR;
2311 /* Set the conditional COND_STMT to be of the form 'if (1 == 1)'. */
2313 static inline void
2314 gimple_cond_make_true (gimple gs)
2316 gimple_cond_set_lhs (gs, boolean_true_node);
2317 gimple_cond_set_rhs (gs, boolean_true_node);
2318 gs->gsbase.subcode = EQ_EXPR;
2321 /* Check if conditional statemente GS is of the form 'if (1 == 1)',
2322 'if (0 == 0)', 'if (1 != 0)' or 'if (0 != 1)' */
2324 static inline bool
2325 gimple_cond_true_p (const_gimple gs)
2327 tree lhs = gimple_cond_lhs (gs);
2328 tree rhs = gimple_cond_rhs (gs);
2329 enum tree_code code = gimple_cond_code (gs);
2331 if (lhs != boolean_true_node && lhs != boolean_false_node)
2332 return false;
2334 if (rhs != boolean_true_node && rhs != boolean_false_node)
2335 return false;
2337 if (code == NE_EXPR && lhs != rhs)
2338 return true;
2340 if (code == EQ_EXPR && lhs == rhs)
2341 return true;
2343 return false;
2346 /* Check if conditional statement GS is of the form 'if (1 != 1)',
2347 'if (0 != 0)', 'if (1 == 0)' or 'if (0 == 1)' */
2349 static inline bool
2350 gimple_cond_false_p (const_gimple gs)
2352 tree lhs = gimple_cond_lhs (gs);
2353 tree rhs = gimple_cond_rhs (gs);
2354 enum tree_code code = gimple_cond_code (gs);
2356 if (lhs != boolean_true_node && lhs != boolean_false_node)
2357 return false;
2359 if (rhs != boolean_true_node && rhs != boolean_false_node)
2360 return false;
2362 if (code == NE_EXPR && lhs == rhs)
2363 return true;
2365 if (code == EQ_EXPR && lhs != rhs)
2366 return true;
2368 return false;
2371 /* Check if conditional statement GS is of the form 'if (var != 0)' or
2372 'if (var == 1)' */
2374 static inline bool
2375 gimple_cond_single_var_p (gimple gs)
2377 if (gimple_cond_code (gs) == NE_EXPR
2378 && gimple_cond_rhs (gs) == boolean_false_node)
2379 return true;
2381 if (gimple_cond_code (gs) == EQ_EXPR
2382 && gimple_cond_rhs (gs) == boolean_true_node)
2383 return true;
2385 return false;
2388 /* Set the code, LHS and RHS of GIMPLE_COND STMT from CODE, LHS and RHS. */
2390 static inline void
2391 gimple_cond_set_condition (gimple stmt, enum tree_code code, tree lhs, tree rhs)
2393 gimple_cond_set_code (stmt, code);
2394 gimple_cond_set_lhs (stmt, lhs);
2395 gimple_cond_set_rhs (stmt, rhs);
2398 /* Return the LABEL_DECL node used by GIMPLE_LABEL statement GS. */
2400 static inline tree
2401 gimple_label_label (const_gimple gs)
2403 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2404 return gimple_op (gs, 0);
2408 /* Set LABEL to be the LABEL_DECL node used by GIMPLE_LABEL statement
2409 GS. */
2411 static inline void
2412 gimple_label_set_label (gimple gs, tree label)
2414 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2415 gcc_assert (TREE_CODE (label) == LABEL_DECL);
2416 gimple_set_op (gs, 0, label);
2420 /* Return the destination of the unconditional jump GS. */
2422 static inline tree
2423 gimple_goto_dest (const_gimple gs)
2425 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2426 return gimple_op (gs, 0);
2430 /* Set DEST to be the destination of the unconditonal jump GS. */
2432 static inline void
2433 gimple_goto_set_dest (gimple gs, tree dest)
2435 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2436 gcc_assert (is_gimple_operand (dest));
2437 gimple_set_op (gs, 0, dest);
2441 /* Return the variables declared in the GIMPLE_BIND statement GS. */
2443 static inline tree
2444 gimple_bind_vars (const_gimple gs)
2446 GIMPLE_CHECK (gs, GIMPLE_BIND);
2447 return gs->gimple_bind.vars;
2451 /* Set VARS to be the set of variables declared in the GIMPLE_BIND
2452 statement GS. */
2454 static inline void
2455 gimple_bind_set_vars (gimple gs, tree vars)
2457 GIMPLE_CHECK (gs, GIMPLE_BIND);
2458 gs->gimple_bind.vars = vars;
2462 /* Append VARS to the set of variables declared in the GIMPLE_BIND
2463 statement GS. */
2465 static inline void
2466 gimple_bind_append_vars (gimple gs, tree vars)
2468 GIMPLE_CHECK (gs, GIMPLE_BIND);
2469 gs->gimple_bind.vars = chainon (gs->gimple_bind.vars, vars);
2473 /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS. */
2475 static inline gimple_seq
2476 gimple_bind_body (gimple gs)
2478 GIMPLE_CHECK (gs, GIMPLE_BIND);
2479 return gs->gimple_bind.body;
2483 /* Set SEQ to be the GIMPLE sequence contained in the GIMPLE_BIND
2484 statement GS. */
2486 static inline void
2487 gimple_bind_set_body (gimple gs, gimple_seq seq)
2489 GIMPLE_CHECK (gs, GIMPLE_BIND);
2490 gs->gimple_bind.body = seq;
2494 /* Append a statement to the end of a GIMPLE_BIND's body. */
2496 static inline void
2497 gimple_bind_add_stmt (gimple gs, gimple stmt)
2499 GIMPLE_CHECK (gs, GIMPLE_BIND);
2500 gimple_seq_add_stmt (&gs->gimple_bind.body, stmt);
2504 /* Append a sequence of statements to the end of a GIMPLE_BIND's body. */
2506 static inline void
2507 gimple_bind_add_seq (gimple gs, gimple_seq seq)
2509 GIMPLE_CHECK (gs, GIMPLE_BIND);
2510 gimple_seq_add_seq (&gs->gimple_bind.body, seq);
2514 /* Return the TREE_BLOCK node associated with GIMPLE_BIND statement
2515 GS. This is analogous to the BIND_EXPR_BLOCK field in trees. */
2517 static inline tree
2518 gimple_bind_block (const_gimple gs)
2520 GIMPLE_CHECK (gs, GIMPLE_BIND);
2521 return gs->gimple_bind.block;
2525 /* Set BLOCK to be the TREE_BLOCK node associated with GIMPLE_BIND
2526 statement GS. */
2528 static inline void
2529 gimple_bind_set_block (gimple gs, tree block)
2531 GIMPLE_CHECK (gs, GIMPLE_BIND);
2532 gcc_assert (block == NULL_TREE || TREE_CODE (block) == BLOCK);
2533 gs->gimple_bind.block = block;
2537 /* Return the number of input operands for GIMPLE_ASM GS. */
2539 static inline unsigned
2540 gimple_asm_ninputs (const_gimple gs)
2542 GIMPLE_CHECK (gs, GIMPLE_ASM);
2543 return gs->gimple_asm.ni;
2547 /* Return the number of output operands for GIMPLE_ASM GS. */
2549 static inline unsigned
2550 gimple_asm_noutputs (const_gimple gs)
2552 GIMPLE_CHECK (gs, GIMPLE_ASM);
2553 return gs->gimple_asm.no;
2557 /* Return the number of clobber operands for GIMPLE_ASM GS. */
2559 static inline unsigned
2560 gimple_asm_nclobbers (const_gimple gs)
2562 GIMPLE_CHECK (gs, GIMPLE_ASM);
2563 return gs->gimple_asm.nc;
2567 /* Return input operand INDEX of GIMPLE_ASM GS. */
2569 static inline tree
2570 gimple_asm_input_op (const_gimple gs, unsigned index)
2572 GIMPLE_CHECK (gs, GIMPLE_ASM);
2573 gcc_assert (index <= gs->gimple_asm.ni);
2574 return gimple_op (gs, index);
2577 /* Return a pointer to input operand INDEX of GIMPLE_ASM GS. */
2579 static inline tree *
2580 gimple_asm_input_op_ptr (const_gimple gs, unsigned index)
2582 GIMPLE_CHECK (gs, GIMPLE_ASM);
2583 gcc_assert (index <= gs->gimple_asm.ni);
2584 return gimple_op_ptr (gs, index);
2588 /* Set IN_OP to be input operand INDEX in GIMPLE_ASM GS. */
2590 static inline void
2591 gimple_asm_set_input_op (gimple gs, unsigned index, tree in_op)
2593 GIMPLE_CHECK (gs, GIMPLE_ASM);
2594 gcc_assert (index <= gs->gimple_asm.ni);
2595 gcc_assert (TREE_CODE (in_op) == TREE_LIST);
2596 gimple_set_op (gs, index, in_op);
2600 /* Return output operand INDEX of GIMPLE_ASM GS. */
2602 static inline tree
2603 gimple_asm_output_op (const_gimple gs, unsigned index)
2605 GIMPLE_CHECK (gs, GIMPLE_ASM);
2606 gcc_assert (index <= gs->gimple_asm.no);
2607 return gimple_op (gs, index + gs->gimple_asm.ni);
2610 /* Return a pointer to output operand INDEX of GIMPLE_ASM GS. */
2612 static inline tree *
2613 gimple_asm_output_op_ptr (const_gimple gs, unsigned index)
2615 GIMPLE_CHECK (gs, GIMPLE_ASM);
2616 gcc_assert (index <= gs->gimple_asm.no);
2617 return gimple_op_ptr (gs, index + gs->gimple_asm.ni);
2621 /* Set OUT_OP to be output operand INDEX in GIMPLE_ASM GS. */
2623 static inline void
2624 gimple_asm_set_output_op (gimple gs, unsigned index, tree out_op)
2626 GIMPLE_CHECK (gs, GIMPLE_ASM);
2627 gcc_assert (index <= gs->gimple_asm.no);
2628 gcc_assert (TREE_CODE (out_op) == TREE_LIST);
2629 gimple_set_op (gs, index + gs->gimple_asm.ni, out_op);
2633 /* Return clobber operand INDEX of GIMPLE_ASM GS. */
2635 static inline tree
2636 gimple_asm_clobber_op (const_gimple gs, unsigned index)
2638 GIMPLE_CHECK (gs, GIMPLE_ASM);
2639 gcc_assert (index <= gs->gimple_asm.nc);
2640 return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no);
2644 /* Set CLOBBER_OP to be clobber operand INDEX in GIMPLE_ASM GS. */
2646 static inline void
2647 gimple_asm_set_clobber_op (gimple gs, unsigned index, tree clobber_op)
2649 GIMPLE_CHECK (gs, GIMPLE_ASM);
2650 gcc_assert (index <= gs->gimple_asm.nc);
2651 gcc_assert (TREE_CODE (clobber_op) == TREE_LIST);
2652 gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no, clobber_op);
2656 /* Return the string representing the assembly instruction in
2657 GIMPLE_ASM GS. */
2659 static inline const char *
2660 gimple_asm_string (const_gimple gs)
2662 GIMPLE_CHECK (gs, GIMPLE_ASM);
2663 return gs->gimple_asm.string;
2667 /* Return true if GS is an asm statement marked volatile. */
2669 static inline bool
2670 gimple_asm_volatile_p (const_gimple gs)
2672 GIMPLE_CHECK (gs, GIMPLE_ASM);
2673 return (gs->gsbase.subcode & GF_ASM_VOLATILE) != 0;
2677 /* If VOLATLE_P is true, mark asm statement GS as volatile. */
2679 static inline void
2680 gimple_asm_set_volatile (gimple gs, bool volatile_p)
2682 GIMPLE_CHECK (gs, GIMPLE_ASM);
2683 if (volatile_p)
2684 gs->gsbase.subcode |= GF_ASM_VOLATILE;
2685 else
2686 gs->gsbase.subcode &= ~GF_ASM_VOLATILE;
2690 /* If INPUT_P is true, mark asm GS as an ASM_INPUT. */
2692 static inline void
2693 gimple_asm_set_input (gimple gs, bool input_p)
2695 GIMPLE_CHECK (gs, GIMPLE_ASM);
2696 if (input_p)
2697 gs->gsbase.subcode |= GF_ASM_INPUT;
2698 else
2699 gs->gsbase.subcode &= ~GF_ASM_INPUT;
2703 /* Return true if asm GS is an ASM_INPUT. */
2705 static inline bool
2706 gimple_asm_input_p (const_gimple gs)
2708 GIMPLE_CHECK (gs, GIMPLE_ASM);
2709 return (gs->gsbase.subcode & GF_ASM_INPUT) != 0;
2713 /* Return the types handled by GIMPLE_CATCH statement GS. */
2715 static inline tree
2716 gimple_catch_types (const_gimple gs)
2718 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2719 return gs->gimple_catch.types;
2723 /* Return a pointer to the types handled by GIMPLE_CATCH statement GS. */
2725 static inline tree *
2726 gimple_catch_types_ptr (gimple gs)
2728 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2729 return &gs->gimple_catch.types;
2733 /* Return the GIMPLE sequence representing the body of the handler of
2734 GIMPLE_CATCH statement GS. */
2736 static inline gimple_seq
2737 gimple_catch_handler (gimple gs)
2739 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2740 return gs->gimple_catch.handler;
2744 /* Return a pointer to the GIMPLE sequence representing the body of
2745 the handler of GIMPLE_CATCH statement GS. */
2747 static inline gimple_seq *
2748 gimple_catch_handler_ptr (gimple gs)
2750 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2751 return &gs->gimple_catch.handler;
2755 /* Set T to be the set of types handled by GIMPLE_CATCH GS. */
2757 static inline void
2758 gimple_catch_set_types (gimple gs, tree t)
2760 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2761 gs->gimple_catch.types = t;
2765 /* Set HANDLER to be the body of GIMPLE_CATCH GS. */
2767 static inline void
2768 gimple_catch_set_handler (gimple gs, gimple_seq handler)
2770 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2771 gs->gimple_catch.handler = handler;
2775 /* Return the types handled by GIMPLE_EH_FILTER statement GS. */
2777 static inline tree
2778 gimple_eh_filter_types (const_gimple gs)
2780 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2781 return gs->gimple_eh_filter.types;
2785 /* Return a pointer to the types handled by GIMPLE_EH_FILTER statement
2786 GS. */
2788 static inline tree *
2789 gimple_eh_filter_types_ptr (gimple gs)
2791 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2792 return &gs->gimple_eh_filter.types;
2796 /* Return the sequence of statement to execute when GIMPLE_EH_FILTER
2797 statement fails. */
2799 static inline gimple_seq
2800 gimple_eh_filter_failure (gimple gs)
2802 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2803 return gs->gimple_eh_filter.failure;
2807 /* Set TYPES to be the set of types handled by GIMPLE_EH_FILTER GS. */
2809 static inline void
2810 gimple_eh_filter_set_types (gimple gs, tree types)
2812 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2813 gs->gimple_eh_filter.types = types;
2817 /* Set FAILURE to be the sequence of statements to execute on failure
2818 for GIMPLE_EH_FILTER GS. */
2820 static inline void
2821 gimple_eh_filter_set_failure (gimple gs, gimple_seq failure)
2823 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2824 gs->gimple_eh_filter.failure = failure;
2827 /* Return the EH_FILTER_MUST_NOT_THROW flag. */
2829 static inline bool
2831 gimple_eh_filter_must_not_throw (gimple gs)
2833 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2834 return gs->gsbase.subcode != 0;
2837 /* Set the EH_FILTER_MUST_NOT_THROW flag to the value MNTP. */
2839 static inline void
2840 gimple_eh_filter_set_must_not_throw (gimple gs, bool mntp)
2842 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2843 gs->gsbase.subcode = (unsigned int) mntp;
2847 /* GIMPLE_TRY accessors. */
2849 /* Return the kind of try block represented by GIMPLE_TRY GS. This is
2850 either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY. */
2852 static inline enum gimple_try_flags
2853 gimple_try_kind (const_gimple gs)
2855 GIMPLE_CHECK (gs, GIMPLE_TRY);
2856 return (enum gimple_try_flags) (gs->gsbase.subcode & GIMPLE_TRY_KIND);
2860 /* Set the kind of try block represented by GIMPLE_TRY GS. */
2862 static inline void
2863 gimple_try_set_kind (gimple gs, enum gimple_try_flags kind)
2865 GIMPLE_CHECK (gs, GIMPLE_TRY);
2866 gcc_assert (kind == GIMPLE_TRY_CATCH || kind == GIMPLE_TRY_FINALLY);
2867 if (gimple_try_kind (gs) != kind)
2868 gs->gsbase.subcode = (unsigned int) kind;
2872 /* Return the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2874 static inline bool
2875 gimple_try_catch_is_cleanup (const_gimple gs)
2877 gcc_assert (gimple_try_kind (gs) == GIMPLE_TRY_CATCH);
2878 return (gs->gsbase.subcode & GIMPLE_TRY_CATCH_IS_CLEANUP) != 0;
2882 /* Return the sequence of statements used as the body for GIMPLE_TRY GS. */
2884 static inline gimple_seq
2885 gimple_try_eval (gimple gs)
2887 GIMPLE_CHECK (gs, GIMPLE_TRY);
2888 return gs->gimple_try.eval;
2892 /* Return the sequence of statements used as the cleanup body for
2893 GIMPLE_TRY GS. */
2895 static inline gimple_seq
2896 gimple_try_cleanup (gimple gs)
2898 GIMPLE_CHECK (gs, GIMPLE_TRY);
2899 return gs->gimple_try.cleanup;
2903 /* Set the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2905 static inline void
2906 gimple_try_set_catch_is_cleanup (gimple g, bool catch_is_cleanup)
2908 gcc_assert (gimple_try_kind (g) == GIMPLE_TRY_CATCH);
2909 if (catch_is_cleanup)
2910 g->gsbase.subcode |= GIMPLE_TRY_CATCH_IS_CLEANUP;
2911 else
2912 g->gsbase.subcode &= ~GIMPLE_TRY_CATCH_IS_CLEANUP;
2916 /* Set EVAL to be the sequence of statements to use as the body for
2917 GIMPLE_TRY GS. */
2919 static inline void
2920 gimple_try_set_eval (gimple gs, gimple_seq eval)
2922 GIMPLE_CHECK (gs, GIMPLE_TRY);
2923 gs->gimple_try.eval = eval;
2927 /* Set CLEANUP to be the sequence of statements to use as the cleanup
2928 body for GIMPLE_TRY GS. */
2930 static inline void
2931 gimple_try_set_cleanup (gimple gs, gimple_seq cleanup)
2933 GIMPLE_CHECK (gs, GIMPLE_TRY);
2934 gs->gimple_try.cleanup = cleanup;
2938 /* Return the cleanup sequence for cleanup statement GS. */
2940 static inline gimple_seq
2941 gimple_wce_cleanup (gimple gs)
2943 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
2944 return gs->gimple_wce.cleanup;
2948 /* Set CLEANUP to be the cleanup sequence for GS. */
2950 static inline void
2951 gimple_wce_set_cleanup (gimple gs, gimple_seq cleanup)
2953 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
2954 gs->gimple_wce.cleanup = cleanup;
2958 /* Return the CLEANUP_EH_ONLY flag for a WCE tuple. */
2960 static inline bool
2961 gimple_wce_cleanup_eh_only (const_gimple gs)
2963 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
2964 return gs->gsbase.subcode != 0;
2968 /* Set the CLEANUP_EH_ONLY flag for a WCE tuple. */
2970 static inline void
2971 gimple_wce_set_cleanup_eh_only (gimple gs, bool eh_only_p)
2973 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
2974 gs->gsbase.subcode = (unsigned int) eh_only_p;
2978 /* Return the maximum number of arguments supported by GIMPLE_PHI GS. */
2980 static inline unsigned
2981 gimple_phi_capacity (const_gimple gs)
2983 GIMPLE_CHECK (gs, GIMPLE_PHI);
2984 return gs->gimple_phi.capacity;
2988 /* Return the number of arguments in GIMPLE_PHI GS. This must always
2989 be exactly the number of incoming edges for the basic block holding
2990 GS. */
2992 static inline unsigned
2993 gimple_phi_num_args (const_gimple gs)
2995 GIMPLE_CHECK (gs, GIMPLE_PHI);
2996 return gs->gimple_phi.nargs;
3000 /* Return the SSA name created by GIMPLE_PHI GS. */
3002 static inline tree
3003 gimple_phi_result (const_gimple gs)
3005 GIMPLE_CHECK (gs, GIMPLE_PHI);
3006 return gs->gimple_phi.result;
3009 /* Return a pointer to the SSA name created by GIMPLE_PHI GS. */
3011 static inline tree *
3012 gimple_phi_result_ptr (gimple gs)
3014 GIMPLE_CHECK (gs, GIMPLE_PHI);
3015 return &gs->gimple_phi.result;
3018 /* Set RESULT to be the SSA name created by GIMPLE_PHI GS. */
3020 static inline void
3021 gimple_phi_set_result (gimple gs, tree result)
3023 GIMPLE_CHECK (gs, GIMPLE_PHI);
3024 gs->gimple_phi.result = result;
3028 /* Return the PHI argument corresponding to incoming edge INDEX for
3029 GIMPLE_PHI GS. */
3031 static inline struct phi_arg_d *
3032 gimple_phi_arg (gimple gs, unsigned index)
3034 GIMPLE_CHECK (gs, GIMPLE_PHI);
3035 gcc_assert (index <= gs->gimple_phi.capacity);
3036 return &(gs->gimple_phi.args[index]);
3039 /* Set PHIARG to be the argument corresponding to incoming edge INDEX
3040 for GIMPLE_PHI GS. */
3042 static inline void
3043 gimple_phi_set_arg (gimple gs, unsigned index, struct phi_arg_d * phiarg)
3045 GIMPLE_CHECK (gs, GIMPLE_PHI);
3046 gcc_assert (index <= gs->gimple_phi.nargs);
3047 memcpy (gs->gimple_phi.args + index, phiarg, sizeof (struct phi_arg_d));
3050 /* Return the region number for GIMPLE_RESX GS. */
3052 static inline int
3053 gimple_resx_region (const_gimple gs)
3055 GIMPLE_CHECK (gs, GIMPLE_RESX);
3056 return gs->gimple_resx.region;
3059 /* Set REGION to be the region number for GIMPLE_RESX GS. */
3061 static inline void
3062 gimple_resx_set_region (gimple gs, int region)
3064 GIMPLE_CHECK (gs, GIMPLE_RESX);
3065 gs->gimple_resx.region = region;
3069 /* Return the number of labels associated with the switch statement GS. */
3071 static inline unsigned
3072 gimple_switch_num_labels (const_gimple gs)
3074 unsigned num_ops;
3075 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3076 num_ops = gimple_num_ops (gs);
3077 gcc_assert (num_ops > 1);
3078 return num_ops - 1;
3082 /* Set NLABELS to be the number of labels for the switch statement GS. */
3084 static inline void
3085 gimple_switch_set_num_labels (gimple g, unsigned nlabels)
3087 GIMPLE_CHECK (g, GIMPLE_SWITCH);
3088 gimple_set_num_ops (g, nlabels + 1);
3092 /* Return the index variable used by the switch statement GS. */
3094 static inline tree
3095 gimple_switch_index (const_gimple gs)
3097 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3098 return gimple_op (gs, 0);
3102 /* Return a pointer to the index variable for the switch statement GS. */
3104 static inline tree *
3105 gimple_switch_index_ptr (const_gimple gs)
3107 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3108 return gimple_op_ptr (gs, 0);
3112 /* Set INDEX to be the index variable for switch statement GS. */
3114 static inline void
3115 gimple_switch_set_index (gimple gs, tree index)
3117 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3118 gcc_assert (SSA_VAR_P (index) || CONSTANT_CLASS_P (index));
3119 gimple_set_op (gs, 0, index);
3123 /* Return the label numbered INDEX. The default label is 0, followed by any
3124 labels in a switch statement. */
3126 static inline tree
3127 gimple_switch_label (const_gimple gs, unsigned index)
3129 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3130 gcc_assert (gimple_num_ops (gs) > index + 1);
3131 return gimple_op (gs, index + 1);
3134 /* Set the label number INDEX to LABEL. 0 is always the default label. */
3136 static inline void
3137 gimple_switch_set_label (gimple gs, unsigned index, tree label)
3139 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3140 gcc_assert (gimple_num_ops (gs) > index + 1);
3141 gcc_assert (label == NULL_TREE || TREE_CODE (label) == CASE_LABEL_EXPR);
3142 gimple_set_op (gs, index + 1, label);
3145 /* Return the default label for a switch statement. */
3147 static inline tree
3148 gimple_switch_default_label (const_gimple gs)
3150 return gimple_switch_label (gs, 0);
3153 /* Set the default label for a switch statement. */
3155 static inline void
3156 gimple_switch_set_default_label (gimple gs, tree label)
3158 gimple_switch_set_label (gs, 0, label);
3162 /* Return the body for the OMP statement GS. */
3164 static inline gimple_seq
3165 gimple_omp_body (gimple gs)
3167 return gs->omp.body;
3170 /* Set BODY to be the body for the OMP statement GS. */
3172 static inline void
3173 gimple_omp_set_body (gimple gs, gimple_seq body)
3175 gs->omp.body = body;
3179 /* Return the name associated with OMP_CRITICAL statement GS. */
3181 static inline tree
3182 gimple_omp_critical_name (const_gimple gs)
3184 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3185 return gs->gimple_omp_critical.name;
3189 /* Return a pointer to the name associated with OMP critical statement GS. */
3191 static inline tree *
3192 gimple_omp_critical_name_ptr (gimple gs)
3194 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3195 return &gs->gimple_omp_critical.name;
3199 /* Set NAME to be the name associated with OMP critical statement GS. */
3201 static inline void
3202 gimple_omp_critical_set_name (gimple gs, tree name)
3204 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3205 gs->gimple_omp_critical.name = name;
3209 /* Return the clauses associated with OMP_FOR GS. */
3211 static inline tree
3212 gimple_omp_for_clauses (const_gimple gs)
3214 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3215 return gs->gimple_omp_for.clauses;
3219 /* Return a pointer to the OMP_FOR GS. */
3221 static inline tree *
3222 gimple_omp_for_clauses_ptr (gimple gs)
3224 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3225 return &gs->gimple_omp_for.clauses;
3229 /* Set CLAUSES to be the list of clauses associated with OMP_FOR GS. */
3231 static inline void
3232 gimple_omp_for_set_clauses (gimple gs, tree clauses)
3234 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3235 gs->gimple_omp_for.clauses = clauses;
3239 /* Get the collapse count of OMP_FOR GS. */
3241 static inline size_t
3242 gimple_omp_for_collapse (gimple gs)
3244 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3245 return gs->gimple_omp_for.collapse;
3249 /* Return the index variable for OMP_FOR GS. */
3251 static inline tree
3252 gimple_omp_for_index (const_gimple gs, size_t i)
3254 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3255 gcc_assert (i < gs->gimple_omp_for.collapse);
3256 return gs->gimple_omp_for.iter[i].index;
3260 /* Return a pointer to the index variable for OMP_FOR GS. */
3262 static inline tree *
3263 gimple_omp_for_index_ptr (gimple gs, size_t i)
3265 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3266 gcc_assert (i < gs->gimple_omp_for.collapse);
3267 return &gs->gimple_omp_for.iter[i].index;
3271 /* Set INDEX to be the index variable for OMP_FOR GS. */
3273 static inline void
3274 gimple_omp_for_set_index (gimple gs, size_t i, tree index)
3276 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3277 gcc_assert (i < gs->gimple_omp_for.collapse);
3278 gs->gimple_omp_for.iter[i].index = index;
3282 /* Return the initial value for OMP_FOR GS. */
3284 static inline tree
3285 gimple_omp_for_initial (const_gimple gs, size_t i)
3287 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3288 gcc_assert (i < gs->gimple_omp_for.collapse);
3289 return gs->gimple_omp_for.iter[i].initial;
3293 /* Return a pointer to the initial value for OMP_FOR GS. */
3295 static inline tree *
3296 gimple_omp_for_initial_ptr (gimple gs, size_t i)
3298 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3299 gcc_assert (i < gs->gimple_omp_for.collapse);
3300 return &gs->gimple_omp_for.iter[i].initial;
3304 /* Set INITIAL to be the initial value for OMP_FOR GS. */
3306 static inline void
3307 gimple_omp_for_set_initial (gimple gs, size_t i, tree initial)
3309 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3310 gcc_assert (i < gs->gimple_omp_for.collapse);
3311 gs->gimple_omp_for.iter[i].initial = initial;
3315 /* Return the final value for OMP_FOR GS. */
3317 static inline tree
3318 gimple_omp_for_final (const_gimple gs, size_t i)
3320 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3321 gcc_assert (i < gs->gimple_omp_for.collapse);
3322 return gs->gimple_omp_for.iter[i].final;
3326 /* Return a pointer to the final value for OMP_FOR GS. */
3328 static inline tree *
3329 gimple_omp_for_final_ptr (gimple gs, size_t i)
3331 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3332 gcc_assert (i < gs->gimple_omp_for.collapse);
3333 return &gs->gimple_omp_for.iter[i].final;
3337 /* Set FINAL to be the final value for OMP_FOR GS. */
3339 static inline void
3340 gimple_omp_for_set_final (gimple gs, size_t i, tree final)
3342 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3343 gcc_assert (i < gs->gimple_omp_for.collapse);
3344 gs->gimple_omp_for.iter[i].final = final;
3348 /* Return the increment value for OMP_FOR GS. */
3350 static inline tree
3351 gimple_omp_for_incr (const_gimple gs, size_t i)
3353 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3354 gcc_assert (i < gs->gimple_omp_for.collapse);
3355 return gs->gimple_omp_for.iter[i].incr;
3359 /* Return a pointer to the increment value for OMP_FOR GS. */
3361 static inline tree *
3362 gimple_omp_for_incr_ptr (gimple gs, size_t i)
3364 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3365 gcc_assert (i < gs->gimple_omp_for.collapse);
3366 return &gs->gimple_omp_for.iter[i].incr;
3370 /* Set INCR to be the increment value for OMP_FOR GS. */
3372 static inline void
3373 gimple_omp_for_set_incr (gimple gs, size_t i, tree incr)
3375 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3376 gcc_assert (i < gs->gimple_omp_for.collapse);
3377 gs->gimple_omp_for.iter[i].incr = incr;
3381 /* Return the sequence of statements to execute before the OMP_FOR
3382 statement GS starts. */
3384 static inline gimple_seq
3385 gimple_omp_for_pre_body (gimple gs)
3387 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3388 return gs->gimple_omp_for.pre_body;
3392 /* Set PRE_BODY to be the sequence of statements to execute before the
3393 OMP_FOR statement GS starts. */
3395 static inline void
3396 gimple_omp_for_set_pre_body (gimple gs, gimple_seq pre_body)
3398 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3399 gs->gimple_omp_for.pre_body = pre_body;
3403 /* Return the clauses associated with OMP_PARALLEL GS. */
3405 static inline tree
3406 gimple_omp_parallel_clauses (const_gimple gs)
3408 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3409 return gs->gimple_omp_parallel.clauses;
3413 /* Return a pointer to the clauses associated with OMP_PARALLEL GS. */
3415 static inline tree *
3416 gimple_omp_parallel_clauses_ptr (gimple gs)
3418 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3419 return &gs->gimple_omp_parallel.clauses;
3423 /* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL
3424 GS. */
3426 static inline void
3427 gimple_omp_parallel_set_clauses (gimple gs, tree clauses)
3429 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3430 gs->gimple_omp_parallel.clauses = clauses;
3434 /* Return the child function used to hold the body of OMP_PARALLEL GS. */
3436 static inline tree
3437 gimple_omp_parallel_child_fn (const_gimple gs)
3439 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3440 return gs->gimple_omp_parallel.child_fn;
3443 /* Return a pointer to the child function used to hold the body of
3444 OMP_PARALLEL GS. */
3446 static inline tree *
3447 gimple_omp_parallel_child_fn_ptr (gimple gs)
3449 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3450 return &gs->gimple_omp_parallel.child_fn;
3454 /* Set CHILD_FN to be the child function for OMP_PARALLEL GS. */
3456 static inline void
3457 gimple_omp_parallel_set_child_fn (gimple gs, tree child_fn)
3459 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3460 gs->gimple_omp_parallel.child_fn = child_fn;
3464 /* Return the artificial argument used to send variables and values
3465 from the parent to the children threads in OMP_PARALLEL GS. */
3467 static inline tree
3468 gimple_omp_parallel_data_arg (const_gimple gs)
3470 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3471 return gs->gimple_omp_parallel.data_arg;
3475 /* Return a pointer to the data argument for OMP_PARALLEL GS. */
3477 static inline tree *
3478 gimple_omp_parallel_data_arg_ptr (gimple gs)
3480 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3481 return &gs->gimple_omp_parallel.data_arg;
3485 /* Set DATA_ARG to be the data argument for OMP_PARALLEL GS. */
3487 static inline void
3488 gimple_omp_parallel_set_data_arg (gimple gs, tree data_arg)
3490 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3491 gs->gimple_omp_parallel.data_arg = data_arg;
3495 /* Return the clauses associated with OMP_TASK GS. */
3497 static inline tree
3498 gimple_omp_task_clauses (const_gimple gs)
3500 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3501 return gs->gimple_omp_parallel.clauses;
3505 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3507 static inline tree *
3508 gimple_omp_task_clauses_ptr (gimple gs)
3510 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3511 return &gs->gimple_omp_parallel.clauses;
3515 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3516 GS. */
3518 static inline void
3519 gimple_omp_task_set_clauses (gimple gs, tree clauses)
3521 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3522 gs->gimple_omp_parallel.clauses = clauses;
3526 /* Return the child function used to hold the body of OMP_TASK GS. */
3528 static inline tree
3529 gimple_omp_task_child_fn (const_gimple gs)
3531 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3532 return gs->gimple_omp_parallel.child_fn;
3535 /* Return a pointer to the child function used to hold the body of
3536 OMP_TASK GS. */
3538 static inline tree *
3539 gimple_omp_task_child_fn_ptr (gimple gs)
3541 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3542 return &gs->gimple_omp_parallel.child_fn;
3546 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3548 static inline void
3549 gimple_omp_task_set_child_fn (gimple gs, tree child_fn)
3551 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3552 gs->gimple_omp_parallel.child_fn = child_fn;
3556 /* Return the artificial argument used to send variables and values
3557 from the parent to the children threads in OMP_TASK GS. */
3559 static inline tree
3560 gimple_omp_task_data_arg (const_gimple gs)
3562 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3563 return gs->gimple_omp_parallel.data_arg;
3567 /* Return a pointer to the data argument for OMP_TASK GS. */
3569 static inline tree *
3570 gimple_omp_task_data_arg_ptr (gimple gs)
3572 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3573 return &gs->gimple_omp_parallel.data_arg;
3577 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3579 static inline void
3580 gimple_omp_task_set_data_arg (gimple gs, tree data_arg)
3582 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3583 gs->gimple_omp_parallel.data_arg = data_arg;
3587 /* Return the clauses associated with OMP_TASK GS. */
3589 static inline tree
3590 gimple_omp_taskreg_clauses (const_gimple gs)
3592 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3593 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3594 return gs->gimple_omp_parallel.clauses;
3598 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3600 static inline tree *
3601 gimple_omp_taskreg_clauses_ptr (gimple gs)
3603 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3604 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3605 return &gs->gimple_omp_parallel.clauses;
3609 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3610 GS. */
3612 static inline void
3613 gimple_omp_taskreg_set_clauses (gimple gs, tree clauses)
3615 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3616 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3617 gs->gimple_omp_parallel.clauses = clauses;
3621 /* Return the child function used to hold the body of OMP_TASK GS. */
3623 static inline tree
3624 gimple_omp_taskreg_child_fn (const_gimple gs)
3626 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3627 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3628 return gs->gimple_omp_parallel.child_fn;
3631 /* Return a pointer to the child function used to hold the body of
3632 OMP_TASK GS. */
3634 static inline tree *
3635 gimple_omp_taskreg_child_fn_ptr (gimple gs)
3637 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3638 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3639 return &gs->gimple_omp_parallel.child_fn;
3643 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3645 static inline void
3646 gimple_omp_taskreg_set_child_fn (gimple gs, tree child_fn)
3648 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3649 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3650 gs->gimple_omp_parallel.child_fn = child_fn;
3654 /* Return the artificial argument used to send variables and values
3655 from the parent to the children threads in OMP_TASK GS. */
3657 static inline tree
3658 gimple_omp_taskreg_data_arg (const_gimple gs)
3660 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3661 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3662 return gs->gimple_omp_parallel.data_arg;
3666 /* Return a pointer to the data argument for OMP_TASK GS. */
3668 static inline tree *
3669 gimple_omp_taskreg_data_arg_ptr (gimple gs)
3671 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3672 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3673 return &gs->gimple_omp_parallel.data_arg;
3677 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3679 static inline void
3680 gimple_omp_taskreg_set_data_arg (gimple gs, tree data_arg)
3682 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3683 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3684 gs->gimple_omp_parallel.data_arg = data_arg;
3688 /* Return the copy function used to hold the body of OMP_TASK GS. */
3690 static inline tree
3691 gimple_omp_task_copy_fn (const_gimple gs)
3693 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3694 return gs->gimple_omp_task.copy_fn;
3697 /* Return a pointer to the copy function used to hold the body of
3698 OMP_TASK GS. */
3700 static inline tree *
3701 gimple_omp_task_copy_fn_ptr (gimple gs)
3703 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3704 return &gs->gimple_omp_task.copy_fn;
3708 /* Set CHILD_FN to be the copy function for OMP_TASK GS. */
3710 static inline void
3711 gimple_omp_task_set_copy_fn (gimple gs, tree copy_fn)
3713 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3714 gs->gimple_omp_task.copy_fn = copy_fn;
3718 /* Return size of the data block in bytes in OMP_TASK GS. */
3720 static inline tree
3721 gimple_omp_task_arg_size (const_gimple gs)
3723 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3724 return gs->gimple_omp_task.arg_size;
3728 /* Return a pointer to the data block size for OMP_TASK GS. */
3730 static inline tree *
3731 gimple_omp_task_arg_size_ptr (gimple gs)
3733 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3734 return &gs->gimple_omp_task.arg_size;
3738 /* Set ARG_SIZE to be the data block size for OMP_TASK GS. */
3740 static inline void
3741 gimple_omp_task_set_arg_size (gimple gs, tree arg_size)
3743 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3744 gs->gimple_omp_task.arg_size = arg_size;
3748 /* Return align of the data block in bytes in OMP_TASK GS. */
3750 static inline tree
3751 gimple_omp_task_arg_align (const_gimple gs)
3753 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3754 return gs->gimple_omp_task.arg_align;
3758 /* Return a pointer to the data block align for OMP_TASK GS. */
3760 static inline tree *
3761 gimple_omp_task_arg_align_ptr (gimple gs)
3763 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3764 return &gs->gimple_omp_task.arg_align;
3768 /* Set ARG_SIZE to be the data block align for OMP_TASK GS. */
3770 static inline void
3771 gimple_omp_task_set_arg_align (gimple gs, tree arg_align)
3773 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3774 gs->gimple_omp_task.arg_align = arg_align;
3778 /* Return the clauses associated with OMP_SINGLE GS. */
3780 static inline tree
3781 gimple_omp_single_clauses (const_gimple gs)
3783 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3784 return gs->gimple_omp_single.clauses;
3788 /* Return a pointer to the clauses associated with OMP_SINGLE GS. */
3790 static inline tree *
3791 gimple_omp_single_clauses_ptr (gimple gs)
3793 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3794 return &gs->gimple_omp_single.clauses;
3798 /* Set CLAUSES to be the clauses associated with OMP_SINGLE GS. */
3800 static inline void
3801 gimple_omp_single_set_clauses (gimple gs, tree clauses)
3803 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3804 gs->gimple_omp_single.clauses = clauses;
3808 /* Return the clauses associated with OMP_SECTIONS GS. */
3810 static inline tree
3811 gimple_omp_sections_clauses (const_gimple gs)
3813 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3814 return gs->gimple_omp_sections.clauses;
3818 /* Return a pointer to the clauses associated with OMP_SECTIONS GS. */
3820 static inline tree *
3821 gimple_omp_sections_clauses_ptr (gimple gs)
3823 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3824 return &gs->gimple_omp_sections.clauses;
3828 /* Set CLAUSES to be the set of clauses associated with OMP_SECTIONS
3829 GS. */
3831 static inline void
3832 gimple_omp_sections_set_clauses (gimple gs, tree clauses)
3834 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3835 gs->gimple_omp_sections.clauses = clauses;
3839 /* Return the control variable associated with the GIMPLE_OMP_SECTIONS
3840 in GS. */
3842 static inline tree
3843 gimple_omp_sections_control (const_gimple gs)
3845 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3846 return gs->gimple_omp_sections.control;
3850 /* Return a pointer to the clauses associated with the GIMPLE_OMP_SECTIONS
3851 GS. */
3853 static inline tree *
3854 gimple_omp_sections_control_ptr (gimple gs)
3856 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3857 return &gs->gimple_omp_sections.control;
3861 /* Set CONTROL to be the set of clauses associated with the
3862 GIMPLE_OMP_SECTIONS in GS. */
3864 static inline void
3865 gimple_omp_sections_set_control (gimple gs, tree control)
3867 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3868 gs->gimple_omp_sections.control = control;
3872 /* Set COND to be the condition code for OMP_FOR GS. */
3874 static inline void
3875 gimple_omp_for_set_cond (gimple gs, size_t i, enum tree_code cond)
3877 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3878 gcc_assert (TREE_CODE_CLASS (cond) == tcc_comparison);
3879 gcc_assert (i < gs->gimple_omp_for.collapse);
3880 gs->gimple_omp_for.iter[i].cond = cond;
3884 /* Return the condition code associated with OMP_FOR GS. */
3886 static inline enum tree_code
3887 gimple_omp_for_cond (const_gimple gs, size_t i)
3889 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3890 gcc_assert (i < gs->gimple_omp_for.collapse);
3891 return gs->gimple_omp_for.iter[i].cond;
3895 /* Set the value being stored in an atomic store. */
3897 static inline void
3898 gimple_omp_atomic_store_set_val (gimple g, tree val)
3900 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3901 g->gimple_omp_atomic_store.val = val;
3905 /* Return the value being stored in an atomic store. */
3907 static inline tree
3908 gimple_omp_atomic_store_val (const_gimple g)
3910 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3911 return g->gimple_omp_atomic_store.val;
3915 /* Return a pointer to the value being stored in an atomic store. */
3917 static inline tree *
3918 gimple_omp_atomic_store_val_ptr (gimple g)
3920 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3921 return &g->gimple_omp_atomic_store.val;
3925 /* Set the LHS of an atomic load. */
3927 static inline void
3928 gimple_omp_atomic_load_set_lhs (gimple g, tree lhs)
3930 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
3931 g->gimple_omp_atomic_load.lhs = lhs;
3935 /* Get the LHS of an atomic load. */
3937 static inline tree
3938 gimple_omp_atomic_load_lhs (const_gimple g)
3940 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
3941 return g->gimple_omp_atomic_load.lhs;
3945 /* Return a pointer to the LHS of an atomic load. */
3947 static inline tree *
3948 gimple_omp_atomic_load_lhs_ptr (gimple g)
3950 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
3951 return &g->gimple_omp_atomic_load.lhs;
3955 /* Set the RHS of an atomic load. */
3957 static inline void
3958 gimple_omp_atomic_load_set_rhs (gimple g, tree rhs)
3960 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
3961 g->gimple_omp_atomic_load.rhs = rhs;
3965 /* Get the RHS of an atomic load. */
3967 static inline tree
3968 gimple_omp_atomic_load_rhs (const_gimple g)
3970 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
3971 return g->gimple_omp_atomic_load.rhs;
3975 /* Return a pointer to the RHS of an atomic load. */
3977 static inline tree *
3978 gimple_omp_atomic_load_rhs_ptr (gimple g)
3980 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
3981 return &g->gimple_omp_atomic_load.rhs;
3985 /* Get the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
3987 static inline tree
3988 gimple_omp_continue_control_def (const_gimple g)
3990 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
3991 return g->gimple_omp_continue.control_def;
3994 /* The same as above, but return the address. */
3996 static inline tree *
3997 gimple_omp_continue_control_def_ptr (gimple g)
3999 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4000 return &g->gimple_omp_continue.control_def;
4003 /* Set the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4005 static inline void
4006 gimple_omp_continue_set_control_def (gimple g, tree def)
4008 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4009 g->gimple_omp_continue.control_def = def;
4013 /* Get the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4015 static inline tree
4016 gimple_omp_continue_control_use (const_gimple g)
4018 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4019 return g->gimple_omp_continue.control_use;
4023 /* The same as above, but return the address. */
4025 static inline tree *
4026 gimple_omp_continue_control_use_ptr (gimple g)
4028 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4029 return &g->gimple_omp_continue.control_use;
4033 /* Set the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4035 static inline void
4036 gimple_omp_continue_set_control_use (gimple g, tree use)
4038 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4039 g->gimple_omp_continue.control_use = use;
4043 /* Return a pointer to the return value for GIMPLE_RETURN GS. */
4045 static inline tree *
4046 gimple_return_retval_ptr (const_gimple gs)
4048 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4049 gcc_assert (gimple_num_ops (gs) == 1);
4050 return gimple_op_ptr (gs, 0);
4053 /* Return the return value for GIMPLE_RETURN GS. */
4055 static inline tree
4056 gimple_return_retval (const_gimple gs)
4058 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4059 gcc_assert (gimple_num_ops (gs) == 1);
4060 return gimple_op (gs, 0);
4064 /* Set RETVAL to be the return value for GIMPLE_RETURN GS. */
4066 static inline void
4067 gimple_return_set_retval (gimple gs, tree retval)
4069 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4070 gcc_assert (gimple_num_ops (gs) == 1);
4071 gcc_assert (retval == NULL_TREE
4072 || TREE_CODE (retval) == RESULT_DECL
4073 || is_gimple_val (retval));
4074 gimple_set_op (gs, 0, retval);
4078 /* Returns true when the gimple statment STMT is any of the OpenMP types. */
4080 static inline bool
4081 is_gimple_omp (const_gimple stmt)
4083 return (gimple_code (stmt) == GIMPLE_OMP_PARALLEL
4084 || gimple_code (stmt) == GIMPLE_OMP_TASK
4085 || gimple_code (stmt) == GIMPLE_OMP_FOR
4086 || gimple_code (stmt) == GIMPLE_OMP_SECTIONS
4087 || gimple_code (stmt) == GIMPLE_OMP_SECTIONS_SWITCH
4088 || gimple_code (stmt) == GIMPLE_OMP_SINGLE
4089 || gimple_code (stmt) == GIMPLE_OMP_SECTION
4090 || gimple_code (stmt) == GIMPLE_OMP_MASTER
4091 || gimple_code (stmt) == GIMPLE_OMP_ORDERED
4092 || gimple_code (stmt) == GIMPLE_OMP_CRITICAL
4093 || gimple_code (stmt) == GIMPLE_OMP_RETURN
4094 || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_LOAD
4095 || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_STORE
4096 || gimple_code (stmt) == GIMPLE_OMP_CONTINUE);
4100 /* Returns TRUE if statement G is a GIMPLE_NOP. */
4102 static inline bool
4103 gimple_nop_p (const_gimple g)
4105 return gimple_code (g) == GIMPLE_NOP;
4109 /* Return the predictor of GIMPLE_PREDICT statement GS. */
4111 static inline enum br_predictor
4112 gimple_predict_predictor (gimple gs)
4114 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4115 return (enum br_predictor) (gs->gsbase.subcode & ~GF_PREDICT_TAKEN);
4119 /* Set the predictor of GIMPLE_PREDICT statement GS to PREDICT. */
4121 static inline void
4122 gimple_predict_set_predictor (gimple gs, enum br_predictor predictor)
4124 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4125 gs->gsbase.subcode = (gs->gsbase.subcode & GF_PREDICT_TAKEN)
4126 | (unsigned) predictor;
4130 /* Return the outcome of GIMPLE_PREDICT statement GS. */
4132 static inline enum prediction
4133 gimple_predict_outcome (gimple gs)
4135 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4136 return (gs->gsbase.subcode & GF_PREDICT_TAKEN) ? TAKEN : NOT_TAKEN;
4140 /* Set the outcome of GIMPLE_PREDICT statement GS to OUTCOME. */
4142 static inline void
4143 gimple_predict_set_outcome (gimple gs, enum prediction outcome)
4145 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4146 if (outcome == TAKEN)
4147 gs->gsbase.subcode |= GF_PREDICT_TAKEN;
4148 else
4149 gs->gsbase.subcode &= ~GF_PREDICT_TAKEN;
4153 /* Return the type of the main expression computed by STMT. Return
4154 void_type_node if the statement computes nothing. */
4156 static inline tree
4157 gimple_expr_type (const_gimple stmt)
4159 enum gimple_code code = gimple_code (stmt);
4161 if (code == GIMPLE_ASSIGN || code == GIMPLE_CALL)
4163 tree type;
4164 /* In general we want to pass out a type that can be substituted
4165 for both the RHS and the LHS types if there is a possibly
4166 useless conversion involved. That means returning the
4167 original RHS type as far as we can reconstruct it. */
4168 if (code == GIMPLE_CALL)
4169 type = gimple_call_return_type (stmt);
4170 else
4171 switch (gimple_assign_rhs_code (stmt))
4173 case POINTER_PLUS_EXPR:
4174 type = TREE_TYPE (gimple_assign_rhs1 (stmt));
4175 break;
4177 default:
4178 /* As fallback use the type of the LHS. */
4179 type = TREE_TYPE (gimple_get_lhs (stmt));
4180 break;
4182 return type;
4184 else if (code == GIMPLE_COND)
4185 return boolean_type_node;
4186 else
4187 return void_type_node;
4191 /* Return a new iterator pointing to GIMPLE_SEQ's first statement. */
4193 static inline gimple_stmt_iterator
4194 gsi_start (gimple_seq seq)
4196 gimple_stmt_iterator i;
4198 i.ptr = gimple_seq_first (seq);
4199 i.seq = seq;
4200 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4202 return i;
4206 /* Return a new iterator pointing to the first statement in basic block BB. */
4208 static inline gimple_stmt_iterator
4209 gsi_start_bb (basic_block bb)
4211 gimple_stmt_iterator i;
4212 gimple_seq seq;
4214 seq = bb_seq (bb);
4215 i.ptr = gimple_seq_first (seq);
4216 i.seq = seq;
4217 i.bb = bb;
4219 return i;
4223 /* Return a new iterator initially pointing to GIMPLE_SEQ's last statement. */
4225 static inline gimple_stmt_iterator
4226 gsi_last (gimple_seq seq)
4228 gimple_stmt_iterator i;
4230 i.ptr = gimple_seq_last (seq);
4231 i.seq = seq;
4232 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4234 return i;
4238 /* Return a new iterator pointing to the last statement in basic block BB. */
4240 static inline gimple_stmt_iterator
4241 gsi_last_bb (basic_block bb)
4243 gimple_stmt_iterator i;
4244 gimple_seq seq;
4246 seq = bb_seq (bb);
4247 i.ptr = gimple_seq_last (seq);
4248 i.seq = seq;
4249 i.bb = bb;
4251 return i;
4255 /* Return true if I is at the end of its sequence. */
4257 static inline bool
4258 gsi_end_p (gimple_stmt_iterator i)
4260 return i.ptr == NULL;
4264 /* Return true if I is one statement before the end of its sequence. */
4266 static inline bool
4267 gsi_one_before_end_p (gimple_stmt_iterator i)
4269 return i.ptr != NULL && i.ptr->next == NULL;
4273 /* Advance the iterator to the next gimple statement. */
4275 static inline void
4276 gsi_next (gimple_stmt_iterator *i)
4278 i->ptr = i->ptr->next;
4281 /* Advance the iterator to the previous gimple statement. */
4283 static inline void
4284 gsi_prev (gimple_stmt_iterator *i)
4286 i->ptr = i->ptr->prev;
4289 /* Return the current stmt. */
4291 static inline gimple
4292 gsi_stmt (gimple_stmt_iterator i)
4294 return i.ptr->stmt;
4297 /* Return a block statement iterator that points to the first non-label
4298 statement in block BB. */
4300 static inline gimple_stmt_iterator
4301 gsi_after_labels (basic_block bb)
4303 gimple_stmt_iterator gsi = gsi_start_bb (bb);
4305 while (!gsi_end_p (gsi) && gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL)
4306 gsi_next (&gsi);
4308 return gsi;
4311 /* Return a pointer to the current stmt.
4313 NOTE: You may want to use gsi_replace on the iterator itself,
4314 as this performs additional bookkeeping that will not be done
4315 if you simply assign through a pointer returned by gsi_stmt_ptr. */
4317 static inline gimple *
4318 gsi_stmt_ptr (gimple_stmt_iterator *i)
4320 return &i->ptr->stmt;
4324 /* Return the basic block associated with this iterator. */
4326 static inline basic_block
4327 gsi_bb (gimple_stmt_iterator i)
4329 return i.bb;
4333 /* Return the sequence associated with this iterator. */
4335 static inline gimple_seq
4336 gsi_seq (gimple_stmt_iterator i)
4338 return i.seq;
4342 enum gsi_iterator_update
4344 GSI_NEW_STMT, /* Only valid when single statement is added, move
4345 iterator to it. */
4346 GSI_SAME_STMT, /* Leave the iterator at the same statement. */
4347 GSI_CONTINUE_LINKING /* Move iterator to whatever position is suitable
4348 for linking other statements in the same
4349 direction. */
4352 /* In gimple-iterator.c */
4353 gimple_stmt_iterator gsi_start_phis (basic_block);
4354 gimple_seq gsi_split_seq_after (gimple_stmt_iterator);
4355 gimple_seq gsi_split_seq_before (gimple_stmt_iterator *);
4356 void gsi_replace (gimple_stmt_iterator *, gimple, bool);
4357 void gsi_insert_before (gimple_stmt_iterator *, gimple,
4358 enum gsi_iterator_update);
4359 void gsi_insert_before_without_update (gimple_stmt_iterator *, gimple,
4360 enum gsi_iterator_update);
4361 void gsi_insert_seq_before (gimple_stmt_iterator *, gimple_seq,
4362 enum gsi_iterator_update);
4363 void gsi_insert_seq_before_without_update (gimple_stmt_iterator *, gimple_seq,
4364 enum gsi_iterator_update);
4365 void gsi_insert_after (gimple_stmt_iterator *, gimple,
4366 enum gsi_iterator_update);
4367 void gsi_insert_after_without_update (gimple_stmt_iterator *, gimple,
4368 enum gsi_iterator_update);
4369 void gsi_insert_seq_after (gimple_stmt_iterator *, gimple_seq,
4370 enum gsi_iterator_update);
4371 void gsi_insert_seq_after_without_update (gimple_stmt_iterator *, gimple_seq,
4372 enum gsi_iterator_update);
4373 void gsi_remove (gimple_stmt_iterator *, bool);
4374 gimple_stmt_iterator gsi_for_stmt (gimple);
4375 void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *);
4376 void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *);
4377 void gsi_move_to_bb_end (gimple_stmt_iterator *, struct basic_block_def *);
4378 void gsi_insert_on_edge (edge, gimple);
4379 void gsi_insert_seq_on_edge (edge, gimple_seq);
4380 basic_block gsi_insert_on_edge_immediate (edge, gimple);
4381 basic_block gsi_insert_seq_on_edge_immediate (edge, gimple_seq);
4382 void gsi_commit_one_edge_insert (edge, basic_block *);
4383 void gsi_commit_edge_inserts (void);
4384 gimple gimple_call_copy_skip_args (gimple, bitmap);
4387 /* Convenience routines to walk all statements of a gimple function.
4388 Note that this is useful exclusively before the code is converted
4389 into SSA form. Once the program is in SSA form, the standard
4390 operand interface should be used to analyze/modify statements. */
4391 struct walk_stmt_info
4393 /* Points to the current statement being walked. */
4394 gimple_stmt_iterator gsi;
4396 /* Additional data that the callback functions may want to carry
4397 through the recursion. */
4398 void *info;
4400 /* Pointer map used to mark visited tree nodes when calling
4401 walk_tree on each operand. If set to NULL, duplicate tree nodes
4402 will be visited more than once. */
4403 struct pointer_set_t *pset;
4405 /* Indicates whether the operand being examined may be replaced
4406 with something that matches is_gimple_val (if true) or something
4407 slightly more complicated (if false). "Something" technically
4408 means the common subset of is_gimple_lvalue and is_gimple_rhs,
4409 but we never try to form anything more complicated than that, so
4410 we don't bother checking.
4412 Also note that CALLBACK should update this flag while walking the
4413 sub-expressions of a statement. For instance, when walking the
4414 statement 'foo (&var)', the flag VAL_ONLY will initially be set
4415 to true, however, when walking &var, the operand of that
4416 ADDR_EXPR does not need to be a GIMPLE value. */
4417 bool val_only;
4419 /* True if we are currently walking the LHS of an assignment. */
4420 bool is_lhs;
4422 /* Optional. Set to true by the callback functions if they made any
4423 changes. */
4424 bool changed;
4426 /* True if we're interested in location information. */
4427 bool want_locations;
4429 /* Operand returned by the callbacks. This is set when calling
4430 walk_gimple_seq. If the walk_stmt_fn or walk_tree_fn callback
4431 returns non-NULL, this field will contain the tree returned by
4432 the last callback. */
4433 tree callback_result;
4436 /* Callback for walk_gimple_stmt. Called for every statement found
4437 during traversal. The first argument points to the statement to
4438 walk. The second argument is a flag that the callback sets to
4439 'true' if it the callback handled all the operands and
4440 sub-statements of the statement (the default value of this flag is
4441 'false'). The third argument is an anonymous pointer to data
4442 to be used by the callback. */
4443 typedef tree (*walk_stmt_fn) (gimple_stmt_iterator *, bool *,
4444 struct walk_stmt_info *);
4446 gimple walk_gimple_seq (gimple_seq, walk_stmt_fn, walk_tree_fn,
4447 struct walk_stmt_info *);
4448 tree walk_gimple_stmt (gimple_stmt_iterator *, walk_stmt_fn, walk_tree_fn,
4449 struct walk_stmt_info *);
4450 tree walk_gimple_op (gimple, walk_tree_fn, struct walk_stmt_info *);
4452 #ifdef GATHER_STATISTICS
4453 /* Enum and arrays used for allocation stats. Keep in sync with
4454 gimple.c:gimple_alloc_kind_names. */
4455 enum gimple_alloc_kind
4457 gimple_alloc_kind_assign, /* Assignments. */
4458 gimple_alloc_kind_phi, /* PHI nodes. */
4459 gimple_alloc_kind_cond, /* Conditionals. */
4460 gimple_alloc_kind_seq, /* Sequences. */
4461 gimple_alloc_kind_rest, /* Everything else. */
4462 gimple_alloc_kind_all
4465 extern int gimple_alloc_counts[];
4466 extern int gimple_alloc_sizes[];
4468 /* Return the allocation kind for a given stmt CODE. */
4469 static inline enum gimple_alloc_kind
4470 gimple_alloc_kind (enum gimple_code code)
4472 switch (code)
4474 case GIMPLE_ASSIGN:
4475 return gimple_alloc_kind_assign;
4476 case GIMPLE_PHI:
4477 return gimple_alloc_kind_phi;
4478 case GIMPLE_COND:
4479 return gimple_alloc_kind_cond;
4480 default:
4481 return gimple_alloc_kind_rest;
4484 #endif /* GATHER_STATISTICS */
4486 extern void dump_gimple_statistics (void);
4488 #endif /* GCC_GIMPLE_H */