2009-04-16 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / gimple.h
blob2d5ee0fd9b4c104b44dce68c9971895b1fd29403
1 /* Gimple IR definitions.
3 Copyright 2007, 2008, 2009 Free Software Foundation, Inc.
4 Contributed by Aldy Hernandez <aldyh@redhat.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #ifndef GCC_GIMPLE_H
23 #define GCC_GIMPLE_H
25 #include "pointer-set.h"
26 #include "vec.h"
27 #include "ggc.h"
28 #include "tm.h"
29 #include "hard-reg-set.h"
30 #include "basic-block.h"
31 #include "tree-ssa-operands.h"
33 DEF_VEC_P(gimple);
34 DEF_VEC_ALLOC_P(gimple,heap);
35 DEF_VEC_ALLOC_P(gimple,gc);
37 typedef gimple *gimple_p;
38 DEF_VEC_P(gimple_p);
39 DEF_VEC_ALLOC_P(gimple_p,heap);
41 DEF_VEC_P(gimple_seq);
42 DEF_VEC_ALLOC_P(gimple_seq,gc);
43 DEF_VEC_ALLOC_P(gimple_seq,heap);
45 /* For each block, the PHI nodes that need to be rewritten are stored into
46 these vectors. */
47 typedef VEC(gimple, heap) *gimple_vec;
48 DEF_VEC_P (gimple_vec);
49 DEF_VEC_ALLOC_P (gimple_vec, heap);
51 enum gimple_code {
52 #define DEFGSCODE(SYM, STRING, STRUCT) SYM,
53 #include "gimple.def"
54 #undef DEFGSCODE
55 LAST_AND_UNUSED_GIMPLE_CODE
58 extern const char *const gimple_code_name[];
59 extern const unsigned char gimple_rhs_class_table[];
61 /* Error out if a gimple tuple is addressed incorrectly. */
62 #if defined ENABLE_GIMPLE_CHECKING
63 extern void gimple_check_failed (const_gimple, const char *, int, \
64 const char *, enum gimple_code, \
65 enum tree_code) ATTRIBUTE_NORETURN;
67 #define GIMPLE_CHECK(GS, CODE) \
68 do { \
69 const_gimple __gs = (GS); \
70 if (gimple_code (__gs) != (CODE)) \
71 gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__, \
72 (CODE), 0); \
73 } while (0)
74 #else /* not ENABLE_GIMPLE_CHECKING */
75 #define GIMPLE_CHECK(GS, CODE) (void)0
76 #endif
78 /* Class of GIMPLE expressions suitable for the RHS of assignments. See
79 get_gimple_rhs_class. */
80 enum gimple_rhs_class
82 GIMPLE_INVALID_RHS, /* The expression cannot be used on the RHS. */
83 GIMPLE_BINARY_RHS, /* The expression is a binary operation. */
84 GIMPLE_UNARY_RHS, /* The expression is a unary operation. */
85 GIMPLE_SINGLE_RHS /* The expression is a single object (an SSA
86 name, a _DECL, a _REF, etc. */
89 /* Specific flags for individual GIMPLE statements. These flags are
90 always stored in gimple_statement_base.subcode and they may only be
91 defined for statement codes that do not use sub-codes.
93 Values for the masks can overlap as long as the overlapping values
94 are never used in the same statement class.
96 The maximum mask value that can be defined is 1 << 15 (i.e., each
97 statement code can hold up to 16 bitflags).
99 Keep this list sorted. */
100 enum gf_mask {
101 GF_ASM_INPUT = 1 << 0,
102 GF_ASM_VOLATILE = 1 << 1,
103 GF_CALL_CANNOT_INLINE = 1 << 0,
104 GF_CALL_FROM_THUNK = 1 << 1,
105 GF_CALL_RETURN_SLOT_OPT = 1 << 2,
106 GF_CALL_TAILCALL = 1 << 3,
107 GF_CALL_VA_ARG_PACK = 1 << 4,
108 GF_OMP_PARALLEL_COMBINED = 1 << 0,
110 /* True on an GIMPLE_OMP_RETURN statement if the return does not require
111 a thread synchronization via some sort of barrier. The exact barrier
112 that would otherwise be emitted is dependent on the OMP statement with
113 which this return is associated. */
114 GF_OMP_RETURN_NOWAIT = 1 << 0,
116 GF_OMP_SECTION_LAST = 1 << 0,
117 GF_PREDICT_TAKEN = 1 << 15
120 /* Masks for selecting a pass local flag (PLF) to work on. These
121 masks are used by gimple_set_plf and gimple_plf. */
122 enum plf_mask {
123 GF_PLF_1 = 1 << 0,
124 GF_PLF_2 = 1 << 1
127 /* A node in a gimple_seq_d. */
128 struct gimple_seq_node_d GTY((chain_next ("%h.next"), chain_prev ("%h.prev")))
130 gimple stmt;
131 struct gimple_seq_node_d *prev;
132 struct gimple_seq_node_d *next;
135 /* A double-linked sequence of gimple statements. */
136 struct gimple_seq_d GTY ((chain_next ("%h.next_free")))
138 /* First and last statements in the sequence. */
139 gimple_seq_node first;
140 gimple_seq_node last;
142 /* Sequences are created/destroyed frequently. To minimize
143 allocation activity, deallocated sequences are kept in a pool of
144 available sequences. This is the pointer to the next free
145 sequence in the pool. */
146 gimple_seq next_free;
150 /* Return the first node in GIMPLE sequence S. */
152 static inline gimple_seq_node
153 gimple_seq_first (const_gimple_seq s)
155 return s ? s->first : NULL;
159 /* Return the first statement in GIMPLE sequence S. */
161 static inline gimple
162 gimple_seq_first_stmt (const_gimple_seq s)
164 gimple_seq_node n = gimple_seq_first (s);
165 return (n) ? n->stmt : NULL;
169 /* Return the last node in GIMPLE sequence S. */
171 static inline gimple_seq_node
172 gimple_seq_last (const_gimple_seq s)
174 return s ? s->last : NULL;
178 /* Return the last statement in GIMPLE sequence S. */
180 static inline gimple
181 gimple_seq_last_stmt (const_gimple_seq s)
183 gimple_seq_node n = gimple_seq_last (s);
184 return (n) ? n->stmt : NULL;
188 /* Set the last node in GIMPLE sequence S to LAST. */
190 static inline void
191 gimple_seq_set_last (gimple_seq s, gimple_seq_node last)
193 s->last = last;
197 /* Set the first node in GIMPLE sequence S to FIRST. */
199 static inline void
200 gimple_seq_set_first (gimple_seq s, gimple_seq_node first)
202 s->first = first;
206 /* Return true if GIMPLE sequence S is empty. */
208 static inline bool
209 gimple_seq_empty_p (const_gimple_seq s)
211 return s == NULL || s->first == NULL;
215 void gimple_seq_add_stmt (gimple_seq *, gimple);
217 /* Allocate a new sequence and initialize its first element with STMT. */
219 static inline gimple_seq
220 gimple_seq_alloc_with_stmt (gimple stmt)
222 gimple_seq seq = NULL;
223 gimple_seq_add_stmt (&seq, stmt);
224 return seq;
228 /* Returns the sequence of statements in BB. */
230 static inline gimple_seq
231 bb_seq (const_basic_block bb)
233 return (!(bb->flags & BB_RTL) && bb->il.gimple) ? bb->il.gimple->seq : NULL;
237 /* Sets the sequence of statements in BB to SEQ. */
239 static inline void
240 set_bb_seq (basic_block bb, gimple_seq seq)
242 gcc_assert (!(bb->flags & BB_RTL));
243 bb->il.gimple->seq = seq;
246 /* Iterator object for GIMPLE statement sequences. */
248 typedef struct
250 /* Sequence node holding the current statement. */
251 gimple_seq_node ptr;
253 /* Sequence and basic block holding the statement. These fields
254 are necessary to handle edge cases such as when statement is
255 added to an empty basic block or when the last statement of a
256 block/sequence is removed. */
257 gimple_seq seq;
258 basic_block bb;
259 } gimple_stmt_iterator;
262 /* Data structure definitions for GIMPLE tuples. NOTE: word markers
263 are for 64 bit hosts. */
265 struct gimple_statement_base GTY(())
267 /* [ WORD 1 ]
268 Main identifying code for a tuple. */
269 ENUM_BITFIELD(gimple_code) code : 8;
271 /* Nonzero if a warning should not be emitted on this tuple. */
272 unsigned int no_warning : 1;
274 /* Nonzero if this tuple has been visited. Passes are responsible
275 for clearing this bit before using it. */
276 unsigned int visited : 1;
278 /* Nonzero if this tuple represents a non-temporal move. */
279 unsigned int nontemporal_move : 1;
281 /* Pass local flags. These flags are free for any pass to use as
282 they see fit. Passes should not assume that these flags contain
283 any useful value when the pass starts. Any initial state that
284 the pass requires should be set on entry to the pass. See
285 gimple_set_plf and gimple_plf for usage. */
286 unsigned int plf : 2;
288 /* Nonzero if this statement has been modified and needs to have its
289 operands rescanned. */
290 unsigned modified : 1;
292 /* Nonzero if this statement contains volatile operands. */
293 unsigned has_volatile_ops : 1;
295 /* Padding to get subcode to 16 bit alignment. */
296 unsigned pad : 1;
298 /* The SUBCODE field can be used for tuple-specific flags for tuples
299 that do not require subcodes. Note that SUBCODE should be at
300 least as wide as tree codes, as several tuples store tree codes
301 in there. */
302 unsigned int subcode : 16;
304 /* UID of this statement. This is used by passes that want to
305 assign IDs to statements. It must be assigned and used by each
306 pass. By default it should be assumed to contain garbage. */
307 unsigned uid;
309 /* [ WORD 2 ]
310 Locus information for debug info. */
311 location_t location;
313 /* Number of operands in this tuple. */
314 unsigned num_ops;
316 /* [ WORD 3 ]
317 Basic block holding this statement. */
318 struct basic_block_def *bb;
320 /* [ WORD 4 ]
321 Lexical block holding this statement. */
322 tree block;
326 /* Base structure for tuples with operands. */
328 struct gimple_statement_with_ops_base GTY(())
330 /* [ WORD 1-4 ] */
331 struct gimple_statement_base gsbase;
333 /* [ WORD 5-6 ]
334 SSA operand vectors. NOTE: It should be possible to
335 amalgamate these vectors with the operand vector OP. However,
336 the SSA operand vectors are organized differently and contain
337 more information (like immediate use chaining). */
338 struct def_optype_d GTY((skip (""))) *def_ops;
339 struct use_optype_d GTY((skip (""))) *use_ops;
343 /* Statements that take register operands. */
345 struct gimple_statement_with_ops GTY(())
347 /* [ WORD 1-6 ] */
348 struct gimple_statement_with_ops_base opbase;
350 /* [ WORD 7 ]
351 Operand vector. NOTE! This must always be the last field
352 of this structure. In particular, this means that this
353 structure cannot be embedded inside another one. */
354 tree GTY((length ("%h.opbase.gsbase.num_ops"))) op[1];
358 /* Base for statements that take both memory and register operands. */
360 struct gimple_statement_with_memory_ops_base GTY(())
362 /* [ WORD 1-6 ] */
363 struct gimple_statement_with_ops_base opbase;
365 /* [ WORD 7-8 ]
366 Virtual operands for this statement. The GC will pick them
367 up via the ssa_names array. */
368 tree GTY((skip (""))) vdef;
369 tree GTY((skip (""))) vuse;
373 /* Statements that take both memory and register operands. */
375 struct gimple_statement_with_memory_ops GTY(())
377 /* [ WORD 1-8 ] */
378 struct gimple_statement_with_memory_ops_base membase;
380 /* [ WORD 9 ]
381 Operand vector. NOTE! This must always be the last field
382 of this structure. In particular, this means that this
383 structure cannot be embedded inside another one. */
384 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
388 /* OpenMP statements (#pragma omp). */
390 struct gimple_statement_omp GTY(())
392 /* [ WORD 1-4 ] */
393 struct gimple_statement_base gsbase;
395 /* [ WORD 5 ] */
396 gimple_seq body;
400 /* GIMPLE_BIND */
402 struct gimple_statement_bind GTY(())
404 /* [ WORD 1-4 ] */
405 struct gimple_statement_base gsbase;
407 /* [ WORD 5 ]
408 Variables declared in this scope. */
409 tree vars;
411 /* [ WORD 6 ]
412 This is different than the BLOCK field in gimple_statement_base,
413 which is analogous to TREE_BLOCK (i.e., the lexical block holding
414 this statement). This field is the equivalent of BIND_EXPR_BLOCK
415 in tree land (i.e., the lexical scope defined by this bind). See
416 gimple-low.c. */
417 tree block;
419 /* [ WORD 7 ] */
420 gimple_seq body;
424 /* GIMPLE_CATCH */
426 struct gimple_statement_catch GTY(())
428 /* [ WORD 1-4 ] */
429 struct gimple_statement_base gsbase;
431 /* [ WORD 5 ] */
432 tree types;
434 /* [ WORD 6 ] */
435 gimple_seq handler;
439 /* GIMPLE_EH_FILTER */
441 struct gimple_statement_eh_filter GTY(())
443 /* [ WORD 1-4 ] */
444 struct gimple_statement_base gsbase;
446 /* Subcode: EH_FILTER_MUST_NOT_THROW. A boolean flag analogous to
447 the tree counterpart. */
449 /* [ WORD 5 ]
450 Filter types. */
451 tree types;
453 /* [ WORD 6 ]
454 Failure actions. */
455 gimple_seq failure;
459 /* GIMPLE_PHI */
461 struct gimple_statement_phi GTY(())
463 /* [ WORD 1-4 ] */
464 struct gimple_statement_base gsbase;
466 /* [ WORD 5 ] */
467 unsigned capacity;
468 unsigned nargs;
470 /* [ WORD 6 ] */
471 tree result;
473 /* [ WORD 7 ] */
474 struct phi_arg_d GTY ((length ("%h.nargs"))) args[1];
478 /* GIMPLE_RESX */
480 struct gimple_statement_resx GTY(())
482 /* [ WORD 1-4 ] */
483 struct gimple_statement_base gsbase;
485 /* [ WORD 5 ]
486 Exception region number. */
487 int region;
491 /* GIMPLE_TRY */
493 struct gimple_statement_try GTY(())
495 /* [ WORD 1-4 ] */
496 struct gimple_statement_base gsbase;
498 /* [ WORD 5 ]
499 Expression to evaluate. */
500 gimple_seq eval;
502 /* [ WORD 6 ]
503 Cleanup expression. */
504 gimple_seq cleanup;
507 /* Kind of GIMPLE_TRY statements. */
508 enum gimple_try_flags
510 /* A try/catch. */
511 GIMPLE_TRY_CATCH = 1 << 0,
513 /* A try/finally. */
514 GIMPLE_TRY_FINALLY = 1 << 1,
515 GIMPLE_TRY_KIND = GIMPLE_TRY_CATCH | GIMPLE_TRY_FINALLY,
517 /* Analogous to TRY_CATCH_IS_CLEANUP. */
518 GIMPLE_TRY_CATCH_IS_CLEANUP = 1 << 2
521 /* GIMPLE_WITH_CLEANUP_EXPR */
523 struct gimple_statement_wce GTY(())
525 /* [ WORD 1-4 ] */
526 struct gimple_statement_base gsbase;
528 /* Subcode: CLEANUP_EH_ONLY. True if the cleanup should only be
529 executed if an exception is thrown, not on normal exit of its
530 scope. This flag is analogous to the CLEANUP_EH_ONLY flag
531 in TARGET_EXPRs. */
533 /* [ WORD 5 ]
534 Cleanup expression. */
535 gimple_seq cleanup;
539 /* GIMPLE_ASM */
541 struct gimple_statement_asm GTY(())
543 /* [ WORD 1-8 ] */
544 struct gimple_statement_with_memory_ops_base membase;
546 /* [ WORD 9 ]
547 __asm__ statement. */
548 const char *string;
550 /* [ WORD 10 ]
551 Number of inputs, outputs and clobbers. */
552 unsigned char ni;
553 unsigned char no;
554 unsigned short nc;
556 /* [ WORD 11 ]
557 Operand vector. NOTE! This must always be the last field
558 of this structure. In particular, this means that this
559 structure cannot be embedded inside another one. */
560 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
563 /* GIMPLE_OMP_CRITICAL */
565 struct gimple_statement_omp_critical GTY(())
567 /* [ WORD 1-5 ] */
568 struct gimple_statement_omp omp;
570 /* [ WORD 6 ]
571 Critical section name. */
572 tree name;
576 struct gimple_omp_for_iter GTY(())
578 /* Condition code. */
579 enum tree_code cond;
581 /* Index variable. */
582 tree index;
584 /* Initial value. */
585 tree initial;
587 /* Final value. */
588 tree final;
590 /* Increment. */
591 tree incr;
594 /* GIMPLE_OMP_FOR */
596 struct gimple_statement_omp_for GTY(())
598 /* [ WORD 1-5 ] */
599 struct gimple_statement_omp omp;
601 /* [ WORD 6 ] */
602 tree clauses;
604 /* [ WORD 7 ]
605 Number of elements in iter array. */
606 size_t collapse;
608 /* [ WORD 8 ] */
609 struct gimple_omp_for_iter * GTY((length ("%h.collapse"))) iter;
611 /* [ WORD 9 ]
612 Pre-body evaluated before the loop body begins. */
613 gimple_seq pre_body;
617 /* GIMPLE_OMP_PARALLEL */
619 struct gimple_statement_omp_parallel GTY(())
621 /* [ WORD 1-5 ] */
622 struct gimple_statement_omp omp;
624 /* [ WORD 6 ]
625 Clauses. */
626 tree clauses;
628 /* [ WORD 7 ]
629 Child function holding the body of the parallel region. */
630 tree child_fn;
632 /* [ WORD 8 ]
633 Shared data argument. */
634 tree data_arg;
638 /* GIMPLE_OMP_TASK */
640 struct gimple_statement_omp_task GTY(())
642 /* [ WORD 1-8 ] */
643 struct gimple_statement_omp_parallel par;
645 /* [ WORD 9 ]
646 Child function holding firstprivate initialization if needed. */
647 tree copy_fn;
649 /* [ WORD 10-11 ]
650 Size and alignment in bytes of the argument data block. */
651 tree arg_size;
652 tree arg_align;
656 /* GIMPLE_OMP_SECTION */
657 /* Uses struct gimple_statement_omp. */
660 /* GIMPLE_OMP_SECTIONS */
662 struct gimple_statement_omp_sections GTY(())
664 /* [ WORD 1-5 ] */
665 struct gimple_statement_omp omp;
667 /* [ WORD 6 ] */
668 tree clauses;
670 /* [ WORD 7 ]
671 The control variable used for deciding which of the sections to
672 execute. */
673 tree control;
676 /* GIMPLE_OMP_CONTINUE.
678 Note: This does not inherit from gimple_statement_omp, because we
679 do not need the body field. */
681 struct gimple_statement_omp_continue GTY(())
683 /* [ WORD 1-4 ] */
684 struct gimple_statement_base gsbase;
686 /* [ WORD 5 ] */
687 tree control_def;
689 /* [ WORD 6 ] */
690 tree control_use;
693 /* GIMPLE_OMP_SINGLE */
695 struct gimple_statement_omp_single GTY(())
697 /* [ WORD 1-5 ] */
698 struct gimple_statement_omp omp;
700 /* [ WORD 6 ] */
701 tree clauses;
705 /* GIMPLE_OMP_ATOMIC_LOAD.
706 Note: This is based on gimple_statement_base, not g_s_omp, because g_s_omp
707 contains a sequence, which we don't need here. */
709 struct gimple_statement_omp_atomic_load GTY(())
711 /* [ WORD 1-4 ] */
712 struct gimple_statement_base gsbase;
714 /* [ WORD 5-6 ] */
715 tree rhs, lhs;
718 /* GIMPLE_OMP_ATOMIC_STORE.
719 See note on GIMPLE_OMP_ATOMIC_LOAD. */
721 struct gimple_statement_omp_atomic_store GTY(())
723 /* [ WORD 1-4 ] */
724 struct gimple_statement_base gsbase;
726 /* [ WORD 5 ] */
727 tree val;
730 enum gimple_statement_structure_enum {
731 #define DEFGSSTRUCT(SYM, STRING) SYM,
732 #include "gsstruct.def"
733 #undef DEFGSSTRUCT
734 LAST_GSS_ENUM
738 /* Define the overall contents of a gimple tuple. It may be any of the
739 structures declared above for various types of tuples. */
741 union gimple_statement_d GTY ((desc ("gimple_statement_structure (&%h)")))
743 struct gimple_statement_base GTY ((tag ("GSS_BASE"))) gsbase;
744 struct gimple_statement_with_ops GTY ((tag ("GSS_WITH_OPS"))) gsops;
745 struct gimple_statement_with_memory_ops GTY ((tag ("GSS_WITH_MEM_OPS"))) gsmem;
746 struct gimple_statement_omp GTY ((tag ("GSS_OMP"))) omp;
747 struct gimple_statement_bind GTY ((tag ("GSS_BIND"))) gimple_bind;
748 struct gimple_statement_catch GTY ((tag ("GSS_CATCH"))) gimple_catch;
749 struct gimple_statement_eh_filter GTY ((tag ("GSS_EH_FILTER"))) gimple_eh_filter;
750 struct gimple_statement_phi GTY ((tag ("GSS_PHI"))) gimple_phi;
751 struct gimple_statement_resx GTY ((tag ("GSS_RESX"))) gimple_resx;
752 struct gimple_statement_try GTY ((tag ("GSS_TRY"))) gimple_try;
753 struct gimple_statement_wce GTY ((tag ("GSS_WCE"))) gimple_wce;
754 struct gimple_statement_asm GTY ((tag ("GSS_ASM"))) gimple_asm;
755 struct gimple_statement_omp_critical GTY ((tag ("GSS_OMP_CRITICAL"))) gimple_omp_critical;
756 struct gimple_statement_omp_for GTY ((tag ("GSS_OMP_FOR"))) gimple_omp_for;
757 struct gimple_statement_omp_parallel GTY ((tag ("GSS_OMP_PARALLEL"))) gimple_omp_parallel;
758 struct gimple_statement_omp_task GTY ((tag ("GSS_OMP_TASK"))) gimple_omp_task;
759 struct gimple_statement_omp_sections GTY ((tag ("GSS_OMP_SECTIONS"))) gimple_omp_sections;
760 struct gimple_statement_omp_single GTY ((tag ("GSS_OMP_SINGLE"))) gimple_omp_single;
761 struct gimple_statement_omp_continue GTY ((tag ("GSS_OMP_CONTINUE"))) gimple_omp_continue;
762 struct gimple_statement_omp_atomic_load GTY ((tag ("GSS_OMP_ATOMIC_LOAD"))) gimple_omp_atomic_load;
763 struct gimple_statement_omp_atomic_store GTY ((tag ("GSS_OMP_ATOMIC_STORE"))) gimple_omp_atomic_store;
766 /* In gimple.c. */
767 gimple gimple_build_return (tree);
769 gimple gimple_build_assign_stat (tree, tree MEM_STAT_DECL);
770 #define gimple_build_assign(l,r) gimple_build_assign_stat (l, r MEM_STAT_INFO)
772 void extract_ops_from_tree (tree, enum tree_code *, tree *, tree *);
774 gimple gimple_build_assign_with_ops_stat (enum tree_code, tree, tree,
775 tree MEM_STAT_DECL);
776 #define gimple_build_assign_with_ops(c,o1,o2,o3) \
777 gimple_build_assign_with_ops_stat (c, o1, o2, o3 MEM_STAT_INFO)
779 gimple gimple_build_call_vec (tree, VEC(tree, heap) *);
780 gimple gimple_build_call (tree, unsigned, ...);
781 gimple gimple_build_call_from_tree (tree);
782 gimple gimplify_assign (tree, tree, gimple_seq *);
783 gimple gimple_build_cond (enum tree_code, tree, tree, tree, tree);
784 gimple gimple_build_label (tree label);
785 gimple gimple_build_goto (tree dest);
786 gimple gimple_build_nop (void);
787 gimple gimple_build_bind (tree, gimple_seq, tree);
788 gimple gimple_build_asm (const char *, unsigned, unsigned, unsigned, ...);
789 gimple gimple_build_asm_vec (const char *, VEC(tree,gc) *, VEC(tree,gc) *,
790 VEC(tree,gc) *);
791 gimple gimple_build_catch (tree, gimple_seq);
792 gimple gimple_build_eh_filter (tree, gimple_seq);
793 gimple gimple_build_try (gimple_seq, gimple_seq, enum gimple_try_flags);
794 gimple gimple_build_wce (gimple_seq);
795 gimple gimple_build_resx (int);
796 gimple gimple_build_switch (unsigned, tree, tree, ...);
797 gimple gimple_build_switch_vec (tree, tree, VEC(tree,heap) *);
798 gimple gimple_build_omp_parallel (gimple_seq, tree, tree, tree);
799 gimple gimple_build_omp_task (gimple_seq, tree, tree, tree, tree, tree, tree);
800 gimple gimple_build_omp_for (gimple_seq, tree, size_t, gimple_seq);
801 gimple gimple_build_omp_critical (gimple_seq, tree);
802 gimple gimple_build_omp_section (gimple_seq);
803 gimple gimple_build_omp_continue (tree, tree);
804 gimple gimple_build_omp_master (gimple_seq);
805 gimple gimple_build_omp_return (bool);
806 gimple gimple_build_omp_ordered (gimple_seq);
807 gimple gimple_build_omp_sections (gimple_seq, tree);
808 gimple gimple_build_omp_sections_switch (void);
809 gimple gimple_build_omp_single (gimple_seq, tree);
810 gimple gimple_build_cdt (tree, tree);
811 gimple gimple_build_omp_atomic_load (tree, tree);
812 gimple gimple_build_omp_atomic_store (tree);
813 gimple gimple_build_predict (enum br_predictor, enum prediction);
814 enum gimple_statement_structure_enum gimple_statement_structure (gimple);
815 enum gimple_statement_structure_enum gss_for_assign (enum tree_code);
816 void sort_case_labels (VEC(tree,heap) *);
817 void gimple_set_body (tree, gimple_seq);
818 gimple_seq gimple_body (tree);
819 bool gimple_has_body_p (tree);
820 gimple_seq gimple_seq_alloc (void);
821 void gimple_seq_free (gimple_seq);
822 void gimple_seq_add_seq (gimple_seq *, gimple_seq);
823 gimple_seq gimple_seq_copy (gimple_seq);
824 int gimple_call_flags (const_gimple);
825 bool gimple_assign_copy_p (gimple);
826 bool gimple_assign_ssa_name_copy_p (gimple);
827 bool gimple_assign_single_p (gimple);
828 bool gimple_assign_unary_nop_p (gimple);
829 void gimple_set_bb (gimple, struct basic_block_def *);
830 tree gimple_fold (const_gimple);
831 void gimple_assign_set_rhs_from_tree (gimple_stmt_iterator *, tree);
832 void gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *, enum tree_code,
833 tree, tree);
834 tree gimple_get_lhs (const_gimple);
835 void gimple_set_lhs (gimple, tree);
836 gimple gimple_copy (gimple);
837 bool is_gimple_operand (const_tree);
838 void gimple_set_modified (gimple, bool);
839 void gimple_cond_get_ops_from_tree (tree, enum tree_code *, tree *, tree *);
840 gimple gimple_build_cond_from_tree (tree, tree, tree);
841 void gimple_cond_set_condition_from_tree (gimple, tree);
842 bool gimple_has_side_effects (const_gimple);
843 bool gimple_rhs_has_side_effects (const_gimple);
844 bool gimple_could_trap_p (gimple);
845 bool gimple_assign_rhs_could_trap_p (gimple);
846 void gimple_regimplify_operands (gimple, gimple_stmt_iterator *);
847 bool empty_body_p (gimple_seq);
848 unsigned get_gimple_rhs_num_ops (enum tree_code);
850 /* Returns true iff T is a valid GIMPLE statement. */
851 extern bool is_gimple_stmt (tree);
853 /* Returns true iff TYPE is a valid type for a scalar register variable. */
854 extern bool is_gimple_reg_type (tree);
855 /* Returns true iff T is a scalar register variable. */
856 extern bool is_gimple_reg (tree);
857 /* Returns true iff T is any sort of variable. */
858 extern bool is_gimple_variable (tree);
859 /* Returns true iff T is any sort of symbol. */
860 extern bool is_gimple_id (tree);
861 /* Returns true iff T is a variable or an INDIRECT_REF (of a variable). */
862 extern bool is_gimple_min_lval (tree);
863 /* Returns true iff T is something whose address can be taken. */
864 extern bool is_gimple_addressable (tree);
865 /* Returns true iff T is any valid GIMPLE lvalue. */
866 extern bool is_gimple_lvalue (tree);
868 /* Returns true iff T is a GIMPLE address. */
869 bool is_gimple_address (const_tree);
870 /* Returns true iff T is a GIMPLE invariant address. */
871 bool is_gimple_invariant_address (const_tree);
872 /* Returns true iff T is a GIMPLE invariant address at interprocedural
873 level. */
874 bool is_gimple_ip_invariant_address (const_tree);
875 /* Returns true iff T is a valid GIMPLE constant. */
876 bool is_gimple_constant (const_tree);
877 /* Returns true iff T is a GIMPLE restricted function invariant. */
878 extern bool is_gimple_min_invariant (const_tree);
879 /* Returns true iff T is a GIMPLE restricted interprecodural invariant. */
880 extern bool is_gimple_ip_invariant (const_tree);
881 /* Returns true iff T is a GIMPLE rvalue. */
882 extern bool is_gimple_val (tree);
883 /* Returns true iff T is a GIMPLE asm statement input. */
884 extern bool is_gimple_asm_val (tree);
885 /* Returns true iff T is a valid rhs for a MODIFY_EXPR where the LHS is a
886 GIMPLE temporary, a renamed user variable, or something else,
887 respectively. */
888 extern bool is_gimple_reg_rhs (tree);
889 extern bool is_gimple_mem_rhs (tree);
891 /* Returns true iff T is a valid if-statement condition. */
892 extern bool is_gimple_condexpr (tree);
894 /* Returns true iff T is a type conversion. */
895 extern bool is_gimple_cast (tree);
896 /* Returns true iff T is a variable that does not need to live in memory. */
897 extern bool is_gimple_non_addressable (tree t);
899 /* Returns true iff T is a valid call address expression. */
900 extern bool is_gimple_call_addr (tree);
901 /* If T makes a function call, returns the CALL_EXPR operand. */
902 extern tree get_call_expr_in (tree t);
904 extern void recalculate_side_effects (tree);
905 extern void count_uses_and_derefs (tree, gimple, unsigned *, unsigned *,
906 unsigned *);
907 extern bool walk_stmt_load_store_addr_ops (gimple, void *,
908 bool (*)(gimple, tree, void *),
909 bool (*)(gimple, tree, void *),
910 bool (*)(gimple, tree, void *));
911 extern bool walk_stmt_load_store_ops (gimple, void *,
912 bool (*)(gimple, tree, void *),
913 bool (*)(gimple, tree, void *));
914 extern bool gimple_ior_addresses_taken (bitmap, gimple);
916 /* In gimplify.c */
917 extern tree create_tmp_var_raw (tree, const char *);
918 extern tree create_tmp_var_name (const char *);
919 extern tree create_tmp_var (tree, const char *);
920 extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq *);
921 extern tree get_formal_tmp_var (tree, gimple_seq *);
922 extern void declare_vars (tree, gimple, bool);
923 extern void tree_annotate_all_with_location (tree *, location_t);
924 extern void annotate_all_with_location (gimple_seq, location_t);
926 /* Validation of GIMPLE expressions. Note that these predicates only check
927 the basic form of the expression, they don't recurse to make sure that
928 underlying nodes are also of the right form. */
929 typedef bool (*gimple_predicate)(tree);
932 /* FIXME we should deduce this from the predicate. */
933 typedef enum fallback_t {
934 fb_none = 0, /* Do not generate a temporary. */
936 fb_rvalue = 1, /* Generate an rvalue to hold the result of a
937 gimplified expression. */
939 fb_lvalue = 2, /* Generate an lvalue to hold the result of a
940 gimplified expression. */
942 fb_mayfail = 4, /* Gimplification may fail. Error issued
943 afterwards. */
944 fb_either= fb_rvalue | fb_lvalue
945 } fallback_t;
947 enum gimplify_status {
948 GS_ERROR = -2, /* Something Bad Seen. */
949 GS_UNHANDLED = -1, /* A langhook result for "I dunno". */
950 GS_OK = 0, /* We did something, maybe more to do. */
951 GS_ALL_DONE = 1 /* The expression is fully gimplified. */
954 struct gimplify_ctx
956 struct gimplify_ctx *prev_context;
958 VEC(gimple,heap) *bind_expr_stack;
959 tree temps;
960 gimple_seq conditional_cleanups;
961 tree exit_label;
962 tree return_temp;
964 VEC(tree,heap) *case_labels;
965 /* The formal temporary table. Should this be persistent? */
966 htab_t temp_htab;
968 int conditions;
969 bool save_stack;
970 bool into_ssa;
971 bool allow_rhs_cond_expr;
974 extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *,
975 bool (*) (tree), fallback_t);
976 extern void gimplify_type_sizes (tree, gimple_seq *);
977 extern void gimplify_one_sizepos (tree *, gimple_seq *);
978 extern bool gimplify_stmt (tree *, gimple_seq *);
979 extern gimple gimplify_body (tree *, tree, bool);
980 extern void push_gimplify_context (struct gimplify_ctx *);
981 extern void pop_gimplify_context (gimple);
982 extern void gimplify_and_add (tree, gimple_seq *);
984 /* Miscellaneous helpers. */
985 extern void gimple_add_tmp_var (tree);
986 extern gimple gimple_current_bind_expr (void);
987 extern VEC(gimple, heap) *gimple_bind_expr_stack (void);
988 extern tree voidify_wrapper_expr (tree, tree);
989 extern tree build_and_jump (tree *);
990 extern tree alloc_stmt_list (void);
991 extern void free_stmt_list (tree);
992 extern tree force_labels_r (tree *, int *, void *);
993 extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *,
994 gimple_seq *);
995 struct gimplify_omp_ctx;
996 extern void omp_firstprivatize_variable (struct gimplify_omp_ctx *, tree);
997 extern tree gimple_boolify (tree);
998 extern gimple_predicate rhs_predicate_for (tree);
999 extern tree canonicalize_cond_expr_cond (tree);
1001 /* In omp-low.c. */
1002 extern void diagnose_omp_structured_block_errors (tree);
1003 extern tree omp_reduction_init (tree, tree);
1005 /* In tree-nested.c. */
1006 extern void lower_nested_functions (tree);
1007 extern void insert_field_into_struct (tree, tree);
1009 /* In gimplify.c. */
1010 extern void gimplify_function_tree (tree);
1012 /* In cfgexpand.c. */
1013 extern tree gimple_assign_rhs_to_tree (gimple);
1015 /* In builtins.c */
1016 extern bool validate_gimple_arglist (const_gimple, ...);
1018 /* In tree-ssa.c */
1019 extern bool tree_ssa_useless_type_conversion (tree);
1020 extern bool useless_type_conversion_p (tree, tree);
1021 extern bool types_compatible_p (tree, tree);
1023 /* Return the code for GIMPLE statement G. */
1025 static inline enum gimple_code
1026 gimple_code (const_gimple g)
1028 return g->gsbase.code;
1032 /* Return true if statement G has sub-statements. This is only true for
1033 High GIMPLE statements. */
1035 static inline bool
1036 gimple_has_substatements (gimple g)
1038 switch (gimple_code (g))
1040 case GIMPLE_BIND:
1041 case GIMPLE_CATCH:
1042 case GIMPLE_EH_FILTER:
1043 case GIMPLE_TRY:
1044 case GIMPLE_OMP_FOR:
1045 case GIMPLE_OMP_MASTER:
1046 case GIMPLE_OMP_ORDERED:
1047 case GIMPLE_OMP_SECTION:
1048 case GIMPLE_OMP_PARALLEL:
1049 case GIMPLE_OMP_TASK:
1050 case GIMPLE_OMP_SECTIONS:
1051 case GIMPLE_OMP_SINGLE:
1052 case GIMPLE_OMP_CRITICAL:
1053 case GIMPLE_WITH_CLEANUP_EXPR:
1054 return true;
1056 default:
1057 return false;
1062 /* Return the basic block holding statement G. */
1064 static inline struct basic_block_def *
1065 gimple_bb (const_gimple g)
1067 return g->gsbase.bb;
1071 /* Return the lexical scope block holding statement G. */
1073 static inline tree
1074 gimple_block (const_gimple g)
1076 return g->gsbase.block;
1080 /* Set BLOCK to be the lexical scope block holding statement G. */
1082 static inline void
1083 gimple_set_block (gimple g, tree block)
1085 g->gsbase.block = block;
1089 /* Return location information for statement G. */
1091 static inline location_t
1092 gimple_location (const_gimple g)
1094 return g->gsbase.location;
1097 /* Return pointer to location information for statement G. */
1099 static inline const location_t *
1100 gimple_location_ptr (const_gimple g)
1102 return &g->gsbase.location;
1106 /* Set location information for statement G. */
1108 static inline void
1109 gimple_set_location (gimple g, location_t location)
1111 g->gsbase.location = location;
1115 /* Return true if G contains location information. */
1117 static inline bool
1118 gimple_has_location (const_gimple g)
1120 return gimple_location (g) != UNKNOWN_LOCATION;
1124 /* Return the file name of the location of STMT. */
1126 static inline const char *
1127 gimple_filename (const_gimple stmt)
1129 return LOCATION_FILE (gimple_location (stmt));
1133 /* Return the line number of the location of STMT. */
1135 static inline int
1136 gimple_lineno (const_gimple stmt)
1138 return LOCATION_LINE (gimple_location (stmt));
1142 /* Determine whether SEQ is a singleton. */
1144 static inline bool
1145 gimple_seq_singleton_p (gimple_seq seq)
1147 return ((gimple_seq_first (seq) != NULL)
1148 && (gimple_seq_first (seq) == gimple_seq_last (seq)));
1151 /* Return true if no warnings should be emitted for statement STMT. */
1153 static inline bool
1154 gimple_no_warning_p (const_gimple stmt)
1156 return stmt->gsbase.no_warning;
1159 /* Set the no_warning flag of STMT to NO_WARNING. */
1161 static inline void
1162 gimple_set_no_warning (gimple stmt, bool no_warning)
1164 stmt->gsbase.no_warning = (unsigned) no_warning;
1167 /* Set the visited status on statement STMT to VISITED_P. */
1169 static inline void
1170 gimple_set_visited (gimple stmt, bool visited_p)
1172 stmt->gsbase.visited = (unsigned) visited_p;
1176 /* Return the visited status for statement STMT. */
1178 static inline bool
1179 gimple_visited_p (gimple stmt)
1181 return stmt->gsbase.visited;
1185 /* Set pass local flag PLF on statement STMT to VAL_P. */
1187 static inline void
1188 gimple_set_plf (gimple stmt, enum plf_mask plf, bool val_p)
1190 if (val_p)
1191 stmt->gsbase.plf |= (unsigned int) plf;
1192 else
1193 stmt->gsbase.plf &= ~((unsigned int) plf);
1197 /* Return the value of pass local flag PLF on statement STMT. */
1199 static inline unsigned int
1200 gimple_plf (gimple stmt, enum plf_mask plf)
1202 return stmt->gsbase.plf & ((unsigned int) plf);
1206 /* Set the UID of statement. */
1208 static inline void
1209 gimple_set_uid (gimple g, unsigned uid)
1211 g->gsbase.uid = uid;
1215 /* Return the UID of statement. */
1217 static inline unsigned
1218 gimple_uid (const_gimple g)
1220 return g->gsbase.uid;
1224 /* Return true if GIMPLE statement G has register or memory operands. */
1226 static inline bool
1227 gimple_has_ops (const_gimple g)
1229 return gimple_code (g) >= GIMPLE_COND && gimple_code (g) <= GIMPLE_RETURN;
1233 /* Return true if GIMPLE statement G has memory operands. */
1235 static inline bool
1236 gimple_has_mem_ops (const_gimple g)
1238 return gimple_code (g) >= GIMPLE_ASSIGN && gimple_code (g) <= GIMPLE_RETURN;
1242 /* Return the set of DEF operands for statement G. */
1244 static inline struct def_optype_d *
1245 gimple_def_ops (const_gimple g)
1247 if (!gimple_has_ops (g))
1248 return NULL;
1249 return g->gsops.opbase.def_ops;
1253 /* Set DEF to be the set of DEF operands for statement G. */
1255 static inline void
1256 gimple_set_def_ops (gimple g, struct def_optype_d *def)
1258 gcc_assert (gimple_has_ops (g));
1259 g->gsops.opbase.def_ops = def;
1263 /* Return the set of USE operands for statement G. */
1265 static inline struct use_optype_d *
1266 gimple_use_ops (const_gimple g)
1268 if (!gimple_has_ops (g))
1269 return NULL;
1270 return g->gsops.opbase.use_ops;
1274 /* Set USE to be the set of USE operands for statement G. */
1276 static inline void
1277 gimple_set_use_ops (gimple g, struct use_optype_d *use)
1279 gcc_assert (gimple_has_ops (g));
1280 g->gsops.opbase.use_ops = use;
1284 /* Return the set of VUSE operand for statement G. */
1286 static inline use_operand_p
1287 gimple_vuse_op (const_gimple g)
1289 struct use_optype_d *ops;
1290 if (!gimple_has_mem_ops (g))
1291 return NULL_USE_OPERAND_P;
1292 ops = g->gsops.opbase.use_ops;
1293 if (ops
1294 && USE_OP_PTR (ops)->use == &g->gsmem.membase.vuse)
1295 return USE_OP_PTR (ops);
1296 return NULL_USE_OPERAND_P;
1299 /* Return the set of VDEF operand for statement G. */
1301 static inline def_operand_p
1302 gimple_vdef_op (const_gimple g)
1304 struct def_optype_d *ops;
1305 if (!gimple_has_mem_ops (g))
1306 return NULL_DEF_OPERAND_P;
1307 ops = g->gsops.opbase.def_ops;
1308 if (ops
1309 && DEF_OP_PTR (ops) == &g->gsmem.membase.vdef)
1310 return DEF_OP_PTR (ops);
1311 return NULL_DEF_OPERAND_P;
1315 /* Return the single VUSE operand of the statement G. */
1317 static inline tree
1318 gimple_vuse (const_gimple g)
1320 if (!gimple_has_mem_ops (g))
1321 return NULL_TREE;
1322 return g->gsmem.membase.vuse;
1325 /* Return the single VDEF operand of the statement G. */
1327 static inline tree
1328 gimple_vdef (const_gimple g)
1330 if (!gimple_has_mem_ops (g))
1331 return NULL_TREE;
1332 return g->gsmem.membase.vdef;
1335 /* Return the single VUSE operand of the statement G. */
1337 static inline tree *
1338 gimple_vuse_ptr (gimple g)
1340 if (!gimple_has_mem_ops (g))
1341 return NULL;
1342 return &g->gsmem.membase.vuse;
1345 /* Return the single VDEF operand of the statement G. */
1347 static inline tree *
1348 gimple_vdef_ptr (gimple g)
1350 if (!gimple_has_mem_ops (g))
1351 return NULL;
1352 return &g->gsmem.membase.vdef;
1355 /* Set the single VUSE operand of the statement G. */
1357 static inline void
1358 gimple_set_vuse (gimple g, tree vuse)
1360 gcc_assert (gimple_has_mem_ops (g));
1361 g->gsmem.membase.vuse = vuse;
1364 /* Set the single VDEF operand of the statement G. */
1366 static inline void
1367 gimple_set_vdef (gimple g, tree vdef)
1369 gcc_assert (gimple_has_mem_ops (g));
1370 g->gsmem.membase.vdef = vdef;
1374 /* Return true if statement G has operands and the modified field has
1375 been set. */
1377 static inline bool
1378 gimple_modified_p (const_gimple g)
1380 return (gimple_has_ops (g)) ? (bool) g->gsbase.modified : false;
1383 /* Return the type of the main expression computed by STMT. Return
1384 void_type_node if the statement computes nothing. */
1386 static inline tree
1387 gimple_expr_type (const_gimple stmt)
1389 enum gimple_code code = gimple_code (stmt);
1391 if (code == GIMPLE_ASSIGN || code == GIMPLE_CALL)
1393 tree type = TREE_TYPE (gimple_get_lhs (stmt));
1394 /* Integral sub-types are never the type of the expression,
1395 but they still can be the type of the result as the base
1396 type (in which expressions are computed) is trivially
1397 convertible to one of its sub-types. So always return
1398 the base type here. */
1399 if (INTEGRAL_TYPE_P (type)
1400 && TREE_TYPE (type)
1401 /* But only if they are trivially convertible. */
1402 && useless_type_conversion_p (type, TREE_TYPE (type)))
1403 type = TREE_TYPE (type);
1404 return type;
1406 else if (code == GIMPLE_COND)
1407 return boolean_type_node;
1408 else
1409 return void_type_node;
1413 /* Return the tree code for the expression computed by STMT. This is
1414 only valid for GIMPLE_COND, GIMPLE_CALL and GIMPLE_ASSIGN. For
1415 GIMPLE_CALL, return CALL_EXPR as the expression code for
1416 consistency. This is useful when the caller needs to deal with the
1417 three kinds of computation that GIMPLE supports. */
1419 static inline enum tree_code
1420 gimple_expr_code (const_gimple stmt)
1422 enum gimple_code code = gimple_code (stmt);
1423 if (code == GIMPLE_ASSIGN || code == GIMPLE_COND)
1424 return (enum tree_code) stmt->gsbase.subcode;
1425 else if (code == GIMPLE_CALL)
1426 return CALL_EXPR;
1427 else
1428 gcc_unreachable ();
1432 /* Mark statement S as modified, and update it. */
1434 static inline void
1435 update_stmt (gimple s)
1437 if (gimple_has_ops (s))
1439 gimple_set_modified (s, true);
1440 update_stmt_operands (s);
1444 /* Update statement S if it has been optimized. */
1446 static inline void
1447 update_stmt_if_modified (gimple s)
1449 if (gimple_modified_p (s))
1450 update_stmt_operands (s);
1453 /* Return true if statement STMT contains volatile operands. */
1455 static inline bool
1456 gimple_has_volatile_ops (const_gimple stmt)
1458 if (gimple_has_mem_ops (stmt))
1459 return stmt->gsbase.has_volatile_ops;
1460 else
1461 return false;
1465 /* Set the HAS_VOLATILE_OPS flag to VOLATILEP. */
1467 static inline void
1468 gimple_set_has_volatile_ops (gimple stmt, bool volatilep)
1470 if (gimple_has_mem_ops (stmt))
1471 stmt->gsbase.has_volatile_ops = (unsigned) volatilep;
1475 /* Return true if statement STMT may access memory. */
1477 static inline bool
1478 gimple_references_memory_p (gimple stmt)
1480 return gimple_has_mem_ops (stmt) && gimple_vuse (stmt);
1484 /* Return the subcode for OMP statement S. */
1486 static inline unsigned
1487 gimple_omp_subcode (const_gimple s)
1489 gcc_assert (gimple_code (s) >= GIMPLE_OMP_ATOMIC_LOAD
1490 && gimple_code (s) <= GIMPLE_OMP_SINGLE);
1491 return s->gsbase.subcode;
1494 /* Set the subcode for OMP statement S to SUBCODE. */
1496 static inline void
1497 gimple_omp_set_subcode (gimple s, unsigned int subcode)
1499 /* We only have 16 bits for the subcode. Assert that we are not
1500 overflowing it. */
1501 gcc_assert (subcode < (1 << 16));
1502 s->gsbase.subcode = subcode;
1505 /* Set the nowait flag on OMP_RETURN statement S. */
1507 static inline void
1508 gimple_omp_return_set_nowait (gimple s)
1510 GIMPLE_CHECK (s, GIMPLE_OMP_RETURN);
1511 s->gsbase.subcode |= GF_OMP_RETURN_NOWAIT;
1515 /* Return true if OMP return statement G has the GF_OMP_RETURN_NOWAIT
1516 flag set. */
1518 static inline bool
1519 gimple_omp_return_nowait_p (const_gimple g)
1521 GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
1522 return (gimple_omp_subcode (g) & GF_OMP_RETURN_NOWAIT) != 0;
1526 /* Return true if OMP section statement G has the GF_OMP_SECTION_LAST
1527 flag set. */
1529 static inline bool
1530 gimple_omp_section_last_p (const_gimple g)
1532 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1533 return (gimple_omp_subcode (g) & GF_OMP_SECTION_LAST) != 0;
1537 /* Set the GF_OMP_SECTION_LAST flag on G. */
1539 static inline void
1540 gimple_omp_section_set_last (gimple g)
1542 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1543 g->gsbase.subcode |= GF_OMP_SECTION_LAST;
1547 /* Return true if OMP parallel statement G has the
1548 GF_OMP_PARALLEL_COMBINED flag set. */
1550 static inline bool
1551 gimple_omp_parallel_combined_p (const_gimple g)
1553 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1554 return (gimple_omp_subcode (g) & GF_OMP_PARALLEL_COMBINED) != 0;
1558 /* Set the GF_OMP_PARALLEL_COMBINED field in G depending on the boolean
1559 value of COMBINED_P. */
1561 static inline void
1562 gimple_omp_parallel_set_combined_p (gimple g, bool combined_p)
1564 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1565 if (combined_p)
1566 g->gsbase.subcode |= GF_OMP_PARALLEL_COMBINED;
1567 else
1568 g->gsbase.subcode &= ~GF_OMP_PARALLEL_COMBINED;
1572 /* Return the number of operands for statement GS. */
1574 static inline unsigned
1575 gimple_num_ops (const_gimple gs)
1577 return gs->gsbase.num_ops;
1581 /* Set the number of operands for statement GS. */
1583 static inline void
1584 gimple_set_num_ops (gimple gs, unsigned num_ops)
1586 gs->gsbase.num_ops = num_ops;
1590 /* Return the array of operands for statement GS. */
1592 static inline tree *
1593 gimple_ops (gimple gs)
1595 /* Offset in bytes to the location of the operand vector in every
1596 tuple structure. Defined in gimple.c */
1597 extern size_t const gimple_ops_offset_[];
1599 if (!gimple_has_ops (gs))
1600 return NULL;
1602 /* All the tuples have their operand vector at the very bottom
1603 of the structure. */
1604 return ((tree *) ((char *) gs + gimple_ops_offset_[gimple_code (gs)]));
1608 /* Return operand I for statement GS. */
1610 static inline tree
1611 gimple_op (const_gimple gs, unsigned i)
1613 if (gimple_has_ops (gs))
1615 gcc_assert (i < gimple_num_ops (gs));
1616 return gimple_ops (CONST_CAST_GIMPLE (gs))[i];
1618 else
1619 return NULL_TREE;
1622 /* Return a pointer to operand I for statement GS. */
1624 static inline tree *
1625 gimple_op_ptr (const_gimple gs, unsigned i)
1627 if (gimple_has_ops (gs))
1629 gcc_assert (i < gimple_num_ops (gs));
1630 return gimple_ops (CONST_CAST_GIMPLE (gs)) + i;
1632 else
1633 return NULL;
1636 /* Set operand I of statement GS to OP. */
1638 static inline void
1639 gimple_set_op (gimple gs, unsigned i, tree op)
1641 gcc_assert (gimple_has_ops (gs) && i < gimple_num_ops (gs));
1643 /* Note. It may be tempting to assert that OP matches
1644 is_gimple_operand, but that would be wrong. Different tuples
1645 accept slightly different sets of tree operands. Each caller
1646 should perform its own validation. */
1647 gimple_ops (gs)[i] = op;
1650 /* Return true if GS is a GIMPLE_ASSIGN. */
1652 static inline bool
1653 is_gimple_assign (const_gimple gs)
1655 return gimple_code (gs) == GIMPLE_ASSIGN;
1658 /* Determine if expression CODE is one of the valid expressions that can
1659 be used on the RHS of GIMPLE assignments. */
1661 static inline enum gimple_rhs_class
1662 get_gimple_rhs_class (enum tree_code code)
1664 return (enum gimple_rhs_class) gimple_rhs_class_table[(int) code];
1667 /* Return the LHS of assignment statement GS. */
1669 static inline tree
1670 gimple_assign_lhs (const_gimple gs)
1672 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1673 return gimple_op (gs, 0);
1677 /* Return a pointer to the LHS of assignment statement GS. */
1679 static inline tree *
1680 gimple_assign_lhs_ptr (const_gimple gs)
1682 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1683 return gimple_op_ptr (gs, 0);
1687 /* Set LHS to be the LHS operand of assignment statement GS. */
1689 static inline void
1690 gimple_assign_set_lhs (gimple gs, tree lhs)
1692 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1693 gcc_assert (is_gimple_operand (lhs));
1694 gimple_set_op (gs, 0, lhs);
1696 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1697 SSA_NAME_DEF_STMT (lhs) = gs;
1701 /* Return the first operand on the RHS of assignment statement GS. */
1703 static inline tree
1704 gimple_assign_rhs1 (const_gimple gs)
1706 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1707 return gimple_op (gs, 1);
1711 /* Return a pointer to the first operand on the RHS of assignment
1712 statement GS. */
1714 static inline tree *
1715 gimple_assign_rhs1_ptr (const_gimple gs)
1717 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1718 return gimple_op_ptr (gs, 1);
1721 /* Set RHS to be the first operand on the RHS of assignment statement GS. */
1723 static inline void
1724 gimple_assign_set_rhs1 (gimple gs, tree rhs)
1726 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1728 /* If there are 3 or more operands, the 2 operands on the RHS must be
1729 GIMPLE values. */
1730 if (gimple_num_ops (gs) >= 3)
1731 gcc_assert (is_gimple_val (rhs));
1732 else
1733 gcc_assert (is_gimple_operand (rhs));
1735 gimple_set_op (gs, 1, rhs);
1739 /* Return the second operand on the RHS of assignment statement GS.
1740 If GS does not have two operands, NULL is returned instead. */
1742 static inline tree
1743 gimple_assign_rhs2 (const_gimple gs)
1745 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1747 if (gimple_num_ops (gs) >= 3)
1748 return gimple_op (gs, 2);
1749 else
1750 return NULL_TREE;
1754 /* Return a pointer to the second operand on the RHS of assignment
1755 statement GS. */
1757 static inline tree *
1758 gimple_assign_rhs2_ptr (const_gimple gs)
1760 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1761 return gimple_op_ptr (gs, 2);
1765 /* Set RHS to be the second operand on the RHS of assignment statement GS. */
1767 static inline void
1768 gimple_assign_set_rhs2 (gimple gs, tree rhs)
1770 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1772 /* The 2 operands on the RHS must be GIMPLE values. */
1773 gcc_assert (is_gimple_val (rhs));
1775 gimple_set_op (gs, 2, rhs);
1778 /* Returns true if GS is a nontemporal move. */
1780 static inline bool
1781 gimple_assign_nontemporal_move_p (const_gimple gs)
1783 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1784 return gs->gsbase.nontemporal_move;
1787 /* Sets nontemporal move flag of GS to NONTEMPORAL. */
1789 static inline void
1790 gimple_assign_set_nontemporal_move (gimple gs, bool nontemporal)
1792 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1793 gs->gsbase.nontemporal_move = nontemporal;
1797 /* Return the code of the expression computed on the rhs of assignment
1798 statement GS. In case that the RHS is a single object, returns the
1799 tree code of the object. */
1801 static inline enum tree_code
1802 gimple_assign_rhs_code (const_gimple gs)
1804 enum tree_code code;
1805 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1807 code = gimple_expr_code (gs);
1808 if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS)
1809 code = TREE_CODE (gimple_assign_rhs1 (gs));
1811 return code;
1815 /* Set CODE to be the code for the expression computed on the RHS of
1816 assignment S. */
1818 static inline void
1819 gimple_assign_set_rhs_code (gimple s, enum tree_code code)
1821 GIMPLE_CHECK (s, GIMPLE_ASSIGN);
1822 s->gsbase.subcode = code;
1826 /* Return the gimple rhs class of the code of the expression computed on
1827 the rhs of assignment statement GS.
1828 This will never return GIMPLE_INVALID_RHS. */
1830 static inline enum gimple_rhs_class
1831 gimple_assign_rhs_class (const_gimple gs)
1833 return get_gimple_rhs_class (gimple_assign_rhs_code (gs));
1837 /* Return true if S is a type-cast assignment. */
1839 static inline bool
1840 gimple_assign_cast_p (gimple s)
1842 if (is_gimple_assign (s))
1844 enum tree_code sc = gimple_assign_rhs_code (s);
1845 return CONVERT_EXPR_CODE_P (sc)
1846 || sc == VIEW_CONVERT_EXPR
1847 || sc == FIX_TRUNC_EXPR;
1850 return false;
1854 /* Return true if GS is a GIMPLE_CALL. */
1856 static inline bool
1857 is_gimple_call (const_gimple gs)
1859 return gimple_code (gs) == GIMPLE_CALL;
1862 /* Return the LHS of call statement GS. */
1864 static inline tree
1865 gimple_call_lhs (const_gimple gs)
1867 GIMPLE_CHECK (gs, GIMPLE_CALL);
1868 return gimple_op (gs, 0);
1872 /* Return a pointer to the LHS of call statement GS. */
1874 static inline tree *
1875 gimple_call_lhs_ptr (const_gimple gs)
1877 GIMPLE_CHECK (gs, GIMPLE_CALL);
1878 return gimple_op_ptr (gs, 0);
1882 /* Set LHS to be the LHS operand of call statement GS. */
1884 static inline void
1885 gimple_call_set_lhs (gimple gs, tree lhs)
1887 GIMPLE_CHECK (gs, GIMPLE_CALL);
1888 gcc_assert (!lhs || is_gimple_operand (lhs));
1889 gimple_set_op (gs, 0, lhs);
1890 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1891 SSA_NAME_DEF_STMT (lhs) = gs;
1895 /* Return the tree node representing the function called by call
1896 statement GS. */
1898 static inline tree
1899 gimple_call_fn (const_gimple gs)
1901 GIMPLE_CHECK (gs, GIMPLE_CALL);
1902 return gimple_op (gs, 1);
1906 /* Return a pointer to the tree node representing the function called by call
1907 statement GS. */
1909 static inline tree *
1910 gimple_call_fn_ptr (const_gimple gs)
1912 GIMPLE_CHECK (gs, GIMPLE_CALL);
1913 return gimple_op_ptr (gs, 1);
1917 /* Set FN to be the function called by call statement GS. */
1919 static inline void
1920 gimple_call_set_fn (gimple gs, tree fn)
1922 GIMPLE_CHECK (gs, GIMPLE_CALL);
1923 gcc_assert (is_gimple_operand (fn));
1924 gimple_set_op (gs, 1, fn);
1928 /* Set FNDECL to be the function called by call statement GS. */
1930 static inline void
1931 gimple_call_set_fndecl (gimple gs, tree decl)
1933 GIMPLE_CHECK (gs, GIMPLE_CALL);
1934 gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
1935 gimple_set_op (gs, 1, build_fold_addr_expr (decl));
1939 /* If a given GIMPLE_CALL's callee is a FUNCTION_DECL, return it.
1940 Otherwise return NULL. This function is analogous to
1941 get_callee_fndecl in tree land. */
1943 static inline tree
1944 gimple_call_fndecl (const_gimple gs)
1946 tree addr = gimple_call_fn (gs);
1947 if (TREE_CODE (addr) == ADDR_EXPR)
1949 gcc_assert (TREE_CODE (TREE_OPERAND (addr, 0)) == FUNCTION_DECL);
1950 return TREE_OPERAND (addr, 0);
1952 return NULL_TREE;
1956 /* Return the type returned by call statement GS. */
1958 static inline tree
1959 gimple_call_return_type (const_gimple gs)
1961 tree fn = gimple_call_fn (gs);
1962 tree type = TREE_TYPE (fn);
1964 /* See through the pointer. */
1965 gcc_assert (POINTER_TYPE_P (type));
1966 type = TREE_TYPE (type);
1968 gcc_assert (TREE_CODE (type) == FUNCTION_TYPE
1969 || TREE_CODE (type) == METHOD_TYPE);
1971 /* The type returned by a FUNCTION_DECL is the type of its
1972 function type. */
1973 return TREE_TYPE (type);
1977 /* Return the static chain for call statement GS. */
1979 static inline tree
1980 gimple_call_chain (const_gimple gs)
1982 GIMPLE_CHECK (gs, GIMPLE_CALL);
1983 return gimple_op (gs, 2);
1987 /* Return a pointer to the static chain for call statement GS. */
1989 static inline tree *
1990 gimple_call_chain_ptr (const_gimple gs)
1992 GIMPLE_CHECK (gs, GIMPLE_CALL);
1993 return gimple_op_ptr (gs, 2);
1996 /* Set CHAIN to be the static chain for call statement GS. */
1998 static inline void
1999 gimple_call_set_chain (gimple gs, tree chain)
2001 GIMPLE_CHECK (gs, GIMPLE_CALL);
2002 gcc_assert (chain == NULL
2003 || TREE_CODE (chain) == ADDR_EXPR
2004 || SSA_VAR_P (chain));
2005 gimple_set_op (gs, 2, chain);
2009 /* Return the number of arguments used by call statement GS. */
2011 static inline unsigned
2012 gimple_call_num_args (const_gimple gs)
2014 unsigned num_ops;
2015 GIMPLE_CHECK (gs, GIMPLE_CALL);
2016 num_ops = gimple_num_ops (gs);
2017 gcc_assert (num_ops >= 3);
2018 return num_ops - 3;
2022 /* Return the argument at position INDEX for call statement GS. */
2024 static inline tree
2025 gimple_call_arg (const_gimple gs, unsigned index)
2027 GIMPLE_CHECK (gs, GIMPLE_CALL);
2028 return gimple_op (gs, index + 3);
2032 /* Return a pointer to the argument at position INDEX for call
2033 statement GS. */
2035 static inline tree *
2036 gimple_call_arg_ptr (const_gimple gs, unsigned index)
2038 GIMPLE_CHECK (gs, GIMPLE_CALL);
2039 return gimple_op_ptr (gs, index + 3);
2043 /* Set ARG to be the argument at position INDEX for call statement GS. */
2045 static inline void
2046 gimple_call_set_arg (gimple gs, unsigned index, tree arg)
2048 GIMPLE_CHECK (gs, GIMPLE_CALL);
2049 gcc_assert (is_gimple_operand (arg));
2050 gimple_set_op (gs, index + 3, arg);
2054 /* If TAIL_P is true, mark call statement S as being a tail call
2055 (i.e., a call just before the exit of a function). These calls are
2056 candidate for tail call optimization. */
2058 static inline void
2059 gimple_call_set_tail (gimple s, bool tail_p)
2061 GIMPLE_CHECK (s, GIMPLE_CALL);
2062 if (tail_p)
2063 s->gsbase.subcode |= GF_CALL_TAILCALL;
2064 else
2065 s->gsbase.subcode &= ~GF_CALL_TAILCALL;
2069 /* Return true if GIMPLE_CALL S is marked as a tail call. */
2071 static inline bool
2072 gimple_call_tail_p (gimple s)
2074 GIMPLE_CHECK (s, GIMPLE_CALL);
2075 return (s->gsbase.subcode & GF_CALL_TAILCALL) != 0;
2079 /* Set the inlinable status of GIMPLE_CALL S to INLINABLE_P. */
2081 static inline void
2082 gimple_call_set_cannot_inline (gimple s, bool inlinable_p)
2084 GIMPLE_CHECK (s, GIMPLE_CALL);
2085 if (inlinable_p)
2086 s->gsbase.subcode |= GF_CALL_CANNOT_INLINE;
2087 else
2088 s->gsbase.subcode &= ~GF_CALL_CANNOT_INLINE;
2092 /* Return true if GIMPLE_CALL S cannot be inlined. */
2094 static inline bool
2095 gimple_call_cannot_inline_p (gimple s)
2097 GIMPLE_CHECK (s, GIMPLE_CALL);
2098 return (s->gsbase.subcode & GF_CALL_CANNOT_INLINE) != 0;
2102 /* If RETURN_SLOT_OPT_P is true mark GIMPLE_CALL S as valid for return
2103 slot optimization. This transformation uses the target of the call
2104 expansion as the return slot for calls that return in memory. */
2106 static inline void
2107 gimple_call_set_return_slot_opt (gimple s, bool return_slot_opt_p)
2109 GIMPLE_CHECK (s, GIMPLE_CALL);
2110 if (return_slot_opt_p)
2111 s->gsbase.subcode |= GF_CALL_RETURN_SLOT_OPT;
2112 else
2113 s->gsbase.subcode &= ~GF_CALL_RETURN_SLOT_OPT;
2117 /* Return true if S is marked for return slot optimization. */
2119 static inline bool
2120 gimple_call_return_slot_opt_p (gimple s)
2122 GIMPLE_CHECK (s, GIMPLE_CALL);
2123 return (s->gsbase.subcode & GF_CALL_RETURN_SLOT_OPT) != 0;
2127 /* If FROM_THUNK_P is true, mark GIMPLE_CALL S as being the jump from a
2128 thunk to the thunked-to function. */
2130 static inline void
2131 gimple_call_set_from_thunk (gimple s, bool from_thunk_p)
2133 GIMPLE_CHECK (s, GIMPLE_CALL);
2134 if (from_thunk_p)
2135 s->gsbase.subcode |= GF_CALL_FROM_THUNK;
2136 else
2137 s->gsbase.subcode &= ~GF_CALL_FROM_THUNK;
2141 /* Return true if GIMPLE_CALL S is a jump from a thunk. */
2143 static inline bool
2144 gimple_call_from_thunk_p (gimple s)
2146 GIMPLE_CHECK (s, GIMPLE_CALL);
2147 return (s->gsbase.subcode & GF_CALL_FROM_THUNK) != 0;
2151 /* If PASS_ARG_PACK_P is true, GIMPLE_CALL S is a stdarg call that needs the
2152 argument pack in its argument list. */
2154 static inline void
2155 gimple_call_set_va_arg_pack (gimple s, bool pass_arg_pack_p)
2157 GIMPLE_CHECK (s, GIMPLE_CALL);
2158 if (pass_arg_pack_p)
2159 s->gsbase.subcode |= GF_CALL_VA_ARG_PACK;
2160 else
2161 s->gsbase.subcode &= ~GF_CALL_VA_ARG_PACK;
2165 /* Return true if GIMPLE_CALL S is a stdarg call that needs the
2166 argument pack in its argument list. */
2168 static inline bool
2169 gimple_call_va_arg_pack_p (gimple s)
2171 GIMPLE_CHECK (s, GIMPLE_CALL);
2172 return (s->gsbase.subcode & GF_CALL_VA_ARG_PACK) != 0;
2176 /* Return true if S is a noreturn call. */
2178 static inline bool
2179 gimple_call_noreturn_p (gimple s)
2181 GIMPLE_CHECK (s, GIMPLE_CALL);
2182 return (gimple_call_flags (s) & ECF_NORETURN) != 0;
2186 /* Return true if S is a nothrow call. */
2188 static inline bool
2189 gimple_call_nothrow_p (gimple s)
2191 GIMPLE_CHECK (s, GIMPLE_CALL);
2192 return (gimple_call_flags (s) & ECF_NOTHROW) != 0;
2196 /* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL. */
2198 static inline void
2199 gimple_call_copy_flags (gimple dest_call, gimple orig_call)
2201 GIMPLE_CHECK (dest_call, GIMPLE_CALL);
2202 GIMPLE_CHECK (orig_call, GIMPLE_CALL);
2203 dest_call->gsbase.subcode = orig_call->gsbase.subcode;
2207 /* Returns true if this is a GIMPLE_ASSIGN or a GIMPLE_CALL with a
2208 non-NULL lhs. */
2210 static inline bool
2211 gimple_has_lhs (gimple stmt)
2213 return (is_gimple_assign (stmt)
2214 || (is_gimple_call (stmt)
2215 && gimple_call_lhs (stmt) != NULL_TREE));
2219 /* Return the code of the predicate computed by conditional statement GS. */
2221 static inline enum tree_code
2222 gimple_cond_code (const_gimple gs)
2224 GIMPLE_CHECK (gs, GIMPLE_COND);
2225 return gs->gsbase.subcode;
2229 /* Set CODE to be the predicate code for the conditional statement GS. */
2231 static inline void
2232 gimple_cond_set_code (gimple gs, enum tree_code code)
2234 GIMPLE_CHECK (gs, GIMPLE_COND);
2235 gcc_assert (TREE_CODE_CLASS (code) == tcc_comparison);
2236 gs->gsbase.subcode = code;
2240 /* Return the LHS of the predicate computed by conditional statement GS. */
2242 static inline tree
2243 gimple_cond_lhs (const_gimple gs)
2245 GIMPLE_CHECK (gs, GIMPLE_COND);
2246 return gimple_op (gs, 0);
2249 /* Return the pointer to the LHS of the predicate computed by conditional
2250 statement GS. */
2252 static inline tree *
2253 gimple_cond_lhs_ptr (const_gimple gs)
2255 GIMPLE_CHECK (gs, GIMPLE_COND);
2256 return gimple_op_ptr (gs, 0);
2259 /* Set LHS to be the LHS operand of the predicate computed by
2260 conditional statement GS. */
2262 static inline void
2263 gimple_cond_set_lhs (gimple gs, tree lhs)
2265 GIMPLE_CHECK (gs, GIMPLE_COND);
2266 gcc_assert (is_gimple_operand (lhs));
2267 gimple_set_op (gs, 0, lhs);
2271 /* Return the RHS operand of the predicate computed by conditional GS. */
2273 static inline tree
2274 gimple_cond_rhs (const_gimple gs)
2276 GIMPLE_CHECK (gs, GIMPLE_COND);
2277 return gimple_op (gs, 1);
2280 /* Return the pointer to the RHS operand of the predicate computed by
2281 conditional GS. */
2283 static inline tree *
2284 gimple_cond_rhs_ptr (const_gimple gs)
2286 GIMPLE_CHECK (gs, GIMPLE_COND);
2287 return gimple_op_ptr (gs, 1);
2291 /* Set RHS to be the RHS operand of the predicate computed by
2292 conditional statement GS. */
2294 static inline void
2295 gimple_cond_set_rhs (gimple gs, tree rhs)
2297 GIMPLE_CHECK (gs, GIMPLE_COND);
2298 gcc_assert (is_gimple_operand (rhs));
2299 gimple_set_op (gs, 1, rhs);
2303 /* Return the label used by conditional statement GS when its
2304 predicate evaluates to true. */
2306 static inline tree
2307 gimple_cond_true_label (const_gimple gs)
2309 GIMPLE_CHECK (gs, GIMPLE_COND);
2310 return gimple_op (gs, 2);
2314 /* Set LABEL to be the label used by conditional statement GS when its
2315 predicate evaluates to true. */
2317 static inline void
2318 gimple_cond_set_true_label (gimple gs, tree label)
2320 GIMPLE_CHECK (gs, GIMPLE_COND);
2321 gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
2322 gimple_set_op (gs, 2, label);
2326 /* Set LABEL to be the label used by conditional statement GS when its
2327 predicate evaluates to false. */
2329 static inline void
2330 gimple_cond_set_false_label (gimple gs, tree label)
2332 GIMPLE_CHECK (gs, GIMPLE_COND);
2333 gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
2334 gimple_set_op (gs, 3, label);
2338 /* Return the label used by conditional statement GS when its
2339 predicate evaluates to false. */
2341 static inline tree
2342 gimple_cond_false_label (const_gimple gs)
2344 GIMPLE_CHECK (gs, GIMPLE_COND);
2345 return gimple_op (gs, 3);
2349 /* Set the conditional COND_STMT to be of the form 'if (1 == 0)'. */
2351 static inline void
2352 gimple_cond_make_false (gimple gs)
2354 gimple_cond_set_lhs (gs, boolean_true_node);
2355 gimple_cond_set_rhs (gs, boolean_false_node);
2356 gs->gsbase.subcode = EQ_EXPR;
2360 /* Set the conditional COND_STMT to be of the form 'if (1 == 1)'. */
2362 static inline void
2363 gimple_cond_make_true (gimple gs)
2365 gimple_cond_set_lhs (gs, boolean_true_node);
2366 gimple_cond_set_rhs (gs, boolean_true_node);
2367 gs->gsbase.subcode = EQ_EXPR;
2370 /* Check if conditional statemente GS is of the form 'if (1 == 1)',
2371 'if (0 == 0)', 'if (1 != 0)' or 'if (0 != 1)' */
2373 static inline bool
2374 gimple_cond_true_p (const_gimple gs)
2376 tree lhs = gimple_cond_lhs (gs);
2377 tree rhs = gimple_cond_rhs (gs);
2378 enum tree_code code = gimple_cond_code (gs);
2380 if (lhs != boolean_true_node && lhs != boolean_false_node)
2381 return false;
2383 if (rhs != boolean_true_node && rhs != boolean_false_node)
2384 return false;
2386 if (code == NE_EXPR && lhs != rhs)
2387 return true;
2389 if (code == EQ_EXPR && lhs == rhs)
2390 return true;
2392 return false;
2395 /* Check if conditional statement GS is of the form 'if (1 != 1)',
2396 'if (0 != 0)', 'if (1 == 0)' or 'if (0 == 1)' */
2398 static inline bool
2399 gimple_cond_false_p (const_gimple gs)
2401 tree lhs = gimple_cond_lhs (gs);
2402 tree rhs = gimple_cond_rhs (gs);
2403 enum tree_code code = gimple_cond_code (gs);
2405 if (lhs != boolean_true_node && lhs != boolean_false_node)
2406 return false;
2408 if (rhs != boolean_true_node && rhs != boolean_false_node)
2409 return false;
2411 if (code == NE_EXPR && lhs == rhs)
2412 return true;
2414 if (code == EQ_EXPR && lhs != rhs)
2415 return true;
2417 return false;
2420 /* Check if conditional statement GS is of the form 'if (var != 0)' or
2421 'if (var == 1)' */
2423 static inline bool
2424 gimple_cond_single_var_p (gimple gs)
2426 if (gimple_cond_code (gs) == NE_EXPR
2427 && gimple_cond_rhs (gs) == boolean_false_node)
2428 return true;
2430 if (gimple_cond_code (gs) == EQ_EXPR
2431 && gimple_cond_rhs (gs) == boolean_true_node)
2432 return true;
2434 return false;
2437 /* Set the code, LHS and RHS of GIMPLE_COND STMT from CODE, LHS and RHS. */
2439 static inline void
2440 gimple_cond_set_condition (gimple stmt, enum tree_code code, tree lhs, tree rhs)
2442 gimple_cond_set_code (stmt, code);
2443 gimple_cond_set_lhs (stmt, lhs);
2444 gimple_cond_set_rhs (stmt, rhs);
2447 /* Return the LABEL_DECL node used by GIMPLE_LABEL statement GS. */
2449 static inline tree
2450 gimple_label_label (const_gimple gs)
2452 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2453 return gimple_op (gs, 0);
2457 /* Set LABEL to be the LABEL_DECL node used by GIMPLE_LABEL statement
2458 GS. */
2460 static inline void
2461 gimple_label_set_label (gimple gs, tree label)
2463 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2464 gcc_assert (TREE_CODE (label) == LABEL_DECL);
2465 gimple_set_op (gs, 0, label);
2469 /* Return the destination of the unconditional jump GS. */
2471 static inline tree
2472 gimple_goto_dest (const_gimple gs)
2474 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2475 return gimple_op (gs, 0);
2479 /* Set DEST to be the destination of the unconditonal jump GS. */
2481 static inline void
2482 gimple_goto_set_dest (gimple gs, tree dest)
2484 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2485 gcc_assert (is_gimple_operand (dest));
2486 gimple_set_op (gs, 0, dest);
2490 /* Return the variables declared in the GIMPLE_BIND statement GS. */
2492 static inline tree
2493 gimple_bind_vars (const_gimple gs)
2495 GIMPLE_CHECK (gs, GIMPLE_BIND);
2496 return gs->gimple_bind.vars;
2500 /* Set VARS to be the set of variables declared in the GIMPLE_BIND
2501 statement GS. */
2503 static inline void
2504 gimple_bind_set_vars (gimple gs, tree vars)
2506 GIMPLE_CHECK (gs, GIMPLE_BIND);
2507 gs->gimple_bind.vars = vars;
2511 /* Append VARS to the set of variables declared in the GIMPLE_BIND
2512 statement GS. */
2514 static inline void
2515 gimple_bind_append_vars (gimple gs, tree vars)
2517 GIMPLE_CHECK (gs, GIMPLE_BIND);
2518 gs->gimple_bind.vars = chainon (gs->gimple_bind.vars, vars);
2522 /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS. */
2524 static inline gimple_seq
2525 gimple_bind_body (gimple gs)
2527 GIMPLE_CHECK (gs, GIMPLE_BIND);
2528 return gs->gimple_bind.body;
2532 /* Set SEQ to be the GIMPLE sequence contained in the GIMPLE_BIND
2533 statement GS. */
2535 static inline void
2536 gimple_bind_set_body (gimple gs, gimple_seq seq)
2538 GIMPLE_CHECK (gs, GIMPLE_BIND);
2539 gs->gimple_bind.body = seq;
2543 /* Append a statement to the end of a GIMPLE_BIND's body. */
2545 static inline void
2546 gimple_bind_add_stmt (gimple gs, gimple stmt)
2548 GIMPLE_CHECK (gs, GIMPLE_BIND);
2549 gimple_seq_add_stmt (&gs->gimple_bind.body, stmt);
2553 /* Append a sequence of statements to the end of a GIMPLE_BIND's body. */
2555 static inline void
2556 gimple_bind_add_seq (gimple gs, gimple_seq seq)
2558 GIMPLE_CHECK (gs, GIMPLE_BIND);
2559 gimple_seq_add_seq (&gs->gimple_bind.body, seq);
2563 /* Return the TREE_BLOCK node associated with GIMPLE_BIND statement
2564 GS. This is analogous to the BIND_EXPR_BLOCK field in trees. */
2566 static inline tree
2567 gimple_bind_block (const_gimple gs)
2569 GIMPLE_CHECK (gs, GIMPLE_BIND);
2570 return gs->gimple_bind.block;
2574 /* Set BLOCK to be the TREE_BLOCK node associated with GIMPLE_BIND
2575 statement GS. */
2577 static inline void
2578 gimple_bind_set_block (gimple gs, tree block)
2580 GIMPLE_CHECK (gs, GIMPLE_BIND);
2581 gcc_assert (block == NULL_TREE || TREE_CODE (block) == BLOCK);
2582 gs->gimple_bind.block = block;
2586 /* Return the number of input operands for GIMPLE_ASM GS. */
2588 static inline unsigned
2589 gimple_asm_ninputs (const_gimple gs)
2591 GIMPLE_CHECK (gs, GIMPLE_ASM);
2592 return gs->gimple_asm.ni;
2596 /* Return the number of output operands for GIMPLE_ASM GS. */
2598 static inline unsigned
2599 gimple_asm_noutputs (const_gimple gs)
2601 GIMPLE_CHECK (gs, GIMPLE_ASM);
2602 return gs->gimple_asm.no;
2606 /* Return the number of clobber operands for GIMPLE_ASM GS. */
2608 static inline unsigned
2609 gimple_asm_nclobbers (const_gimple gs)
2611 GIMPLE_CHECK (gs, GIMPLE_ASM);
2612 return gs->gimple_asm.nc;
2616 /* Return input operand INDEX of GIMPLE_ASM GS. */
2618 static inline tree
2619 gimple_asm_input_op (const_gimple gs, unsigned index)
2621 GIMPLE_CHECK (gs, GIMPLE_ASM);
2622 gcc_assert (index <= gs->gimple_asm.ni);
2623 return gimple_op (gs, index);
2626 /* Return a pointer to input operand INDEX of GIMPLE_ASM GS. */
2628 static inline tree *
2629 gimple_asm_input_op_ptr (const_gimple gs, unsigned index)
2631 GIMPLE_CHECK (gs, GIMPLE_ASM);
2632 gcc_assert (index <= gs->gimple_asm.ni);
2633 return gimple_op_ptr (gs, index);
2637 /* Set IN_OP to be input operand INDEX in GIMPLE_ASM GS. */
2639 static inline void
2640 gimple_asm_set_input_op (gimple gs, unsigned index, tree in_op)
2642 GIMPLE_CHECK (gs, GIMPLE_ASM);
2643 gcc_assert (index <= gs->gimple_asm.ni);
2644 gcc_assert (TREE_CODE (in_op) == TREE_LIST);
2645 gimple_set_op (gs, index, in_op);
2649 /* Return output operand INDEX of GIMPLE_ASM GS. */
2651 static inline tree
2652 gimple_asm_output_op (const_gimple gs, unsigned index)
2654 GIMPLE_CHECK (gs, GIMPLE_ASM);
2655 gcc_assert (index <= gs->gimple_asm.no);
2656 return gimple_op (gs, index + gs->gimple_asm.ni);
2659 /* Return a pointer to output operand INDEX of GIMPLE_ASM GS. */
2661 static inline tree *
2662 gimple_asm_output_op_ptr (const_gimple gs, unsigned index)
2664 GIMPLE_CHECK (gs, GIMPLE_ASM);
2665 gcc_assert (index <= gs->gimple_asm.no);
2666 return gimple_op_ptr (gs, index + gs->gimple_asm.ni);
2670 /* Set OUT_OP to be output operand INDEX in GIMPLE_ASM GS. */
2672 static inline void
2673 gimple_asm_set_output_op (gimple gs, unsigned index, tree out_op)
2675 GIMPLE_CHECK (gs, GIMPLE_ASM);
2676 gcc_assert (index <= gs->gimple_asm.no);
2677 gcc_assert (TREE_CODE (out_op) == TREE_LIST);
2678 gimple_set_op (gs, index + gs->gimple_asm.ni, out_op);
2682 /* Return clobber operand INDEX of GIMPLE_ASM GS. */
2684 static inline tree
2685 gimple_asm_clobber_op (const_gimple gs, unsigned index)
2687 GIMPLE_CHECK (gs, GIMPLE_ASM);
2688 gcc_assert (index <= gs->gimple_asm.nc);
2689 return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no);
2693 /* Set CLOBBER_OP to be clobber operand INDEX in GIMPLE_ASM GS. */
2695 static inline void
2696 gimple_asm_set_clobber_op (gimple gs, unsigned index, tree clobber_op)
2698 GIMPLE_CHECK (gs, GIMPLE_ASM);
2699 gcc_assert (index <= gs->gimple_asm.nc);
2700 gcc_assert (TREE_CODE (clobber_op) == TREE_LIST);
2701 gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no, clobber_op);
2705 /* Return the string representing the assembly instruction in
2706 GIMPLE_ASM GS. */
2708 static inline const char *
2709 gimple_asm_string (const_gimple gs)
2711 GIMPLE_CHECK (gs, GIMPLE_ASM);
2712 return gs->gimple_asm.string;
2716 /* Return true if GS is an asm statement marked volatile. */
2718 static inline bool
2719 gimple_asm_volatile_p (const_gimple gs)
2721 GIMPLE_CHECK (gs, GIMPLE_ASM);
2722 return (gs->gsbase.subcode & GF_ASM_VOLATILE) != 0;
2726 /* If VOLATLE_P is true, mark asm statement GS as volatile. */
2728 static inline void
2729 gimple_asm_set_volatile (gimple gs, bool volatile_p)
2731 GIMPLE_CHECK (gs, GIMPLE_ASM);
2732 if (volatile_p)
2733 gs->gsbase.subcode |= GF_ASM_VOLATILE;
2734 else
2735 gs->gsbase.subcode &= ~GF_ASM_VOLATILE;
2739 /* If INPUT_P is true, mark asm GS as an ASM_INPUT. */
2741 static inline void
2742 gimple_asm_set_input (gimple gs, bool input_p)
2744 GIMPLE_CHECK (gs, GIMPLE_ASM);
2745 if (input_p)
2746 gs->gsbase.subcode |= GF_ASM_INPUT;
2747 else
2748 gs->gsbase.subcode &= ~GF_ASM_INPUT;
2752 /* Return true if asm GS is an ASM_INPUT. */
2754 static inline bool
2755 gimple_asm_input_p (const_gimple gs)
2757 GIMPLE_CHECK (gs, GIMPLE_ASM);
2758 return (gs->gsbase.subcode & GF_ASM_INPUT) != 0;
2762 /* Return the types handled by GIMPLE_CATCH statement GS. */
2764 static inline tree
2765 gimple_catch_types (const_gimple gs)
2767 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2768 return gs->gimple_catch.types;
2772 /* Return a pointer to the types handled by GIMPLE_CATCH statement GS. */
2774 static inline tree *
2775 gimple_catch_types_ptr (gimple gs)
2777 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2778 return &gs->gimple_catch.types;
2782 /* Return the GIMPLE sequence representing the body of the handler of
2783 GIMPLE_CATCH statement GS. */
2785 static inline gimple_seq
2786 gimple_catch_handler (gimple gs)
2788 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2789 return gs->gimple_catch.handler;
2793 /* Return a pointer to the GIMPLE sequence representing the body of
2794 the handler of GIMPLE_CATCH statement GS. */
2796 static inline gimple_seq *
2797 gimple_catch_handler_ptr (gimple gs)
2799 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2800 return &gs->gimple_catch.handler;
2804 /* Set T to be the set of types handled by GIMPLE_CATCH GS. */
2806 static inline void
2807 gimple_catch_set_types (gimple gs, tree t)
2809 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2810 gs->gimple_catch.types = t;
2814 /* Set HANDLER to be the body of GIMPLE_CATCH GS. */
2816 static inline void
2817 gimple_catch_set_handler (gimple gs, gimple_seq handler)
2819 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2820 gs->gimple_catch.handler = handler;
2824 /* Return the types handled by GIMPLE_EH_FILTER statement GS. */
2826 static inline tree
2827 gimple_eh_filter_types (const_gimple gs)
2829 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2830 return gs->gimple_eh_filter.types;
2834 /* Return a pointer to the types handled by GIMPLE_EH_FILTER statement
2835 GS. */
2837 static inline tree *
2838 gimple_eh_filter_types_ptr (gimple gs)
2840 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2841 return &gs->gimple_eh_filter.types;
2845 /* Return the sequence of statement to execute when GIMPLE_EH_FILTER
2846 statement fails. */
2848 static inline gimple_seq
2849 gimple_eh_filter_failure (gimple gs)
2851 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2852 return gs->gimple_eh_filter.failure;
2856 /* Set TYPES to be the set of types handled by GIMPLE_EH_FILTER GS. */
2858 static inline void
2859 gimple_eh_filter_set_types (gimple gs, tree types)
2861 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2862 gs->gimple_eh_filter.types = types;
2866 /* Set FAILURE to be the sequence of statements to execute on failure
2867 for GIMPLE_EH_FILTER GS. */
2869 static inline void
2870 gimple_eh_filter_set_failure (gimple gs, gimple_seq failure)
2872 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2873 gs->gimple_eh_filter.failure = failure;
2876 /* Return the EH_FILTER_MUST_NOT_THROW flag. */
2878 static inline bool
2880 gimple_eh_filter_must_not_throw (gimple gs)
2882 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2883 return gs->gsbase.subcode != 0;
2886 /* Set the EH_FILTER_MUST_NOT_THROW flag to the value MNTP. */
2888 static inline void
2889 gimple_eh_filter_set_must_not_throw (gimple gs, bool mntp)
2891 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2892 gs->gsbase.subcode = (unsigned int) mntp;
2896 /* GIMPLE_TRY accessors. */
2898 /* Return the kind of try block represented by GIMPLE_TRY GS. This is
2899 either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY. */
2901 static inline enum gimple_try_flags
2902 gimple_try_kind (const_gimple gs)
2904 GIMPLE_CHECK (gs, GIMPLE_TRY);
2905 return (enum gimple_try_flags) (gs->gsbase.subcode & GIMPLE_TRY_KIND);
2909 /* Set the kind of try block represented by GIMPLE_TRY GS. */
2911 static inline void
2912 gimple_try_set_kind (gimple gs, enum gimple_try_flags kind)
2914 GIMPLE_CHECK (gs, GIMPLE_TRY);
2915 gcc_assert (kind == GIMPLE_TRY_CATCH || kind == GIMPLE_TRY_FINALLY);
2916 if (gimple_try_kind (gs) != kind)
2917 gs->gsbase.subcode = (unsigned int) kind;
2921 /* Return the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2923 static inline bool
2924 gimple_try_catch_is_cleanup (const_gimple gs)
2926 gcc_assert (gimple_try_kind (gs) == GIMPLE_TRY_CATCH);
2927 return (gs->gsbase.subcode & GIMPLE_TRY_CATCH_IS_CLEANUP) != 0;
2931 /* Return the sequence of statements used as the body for GIMPLE_TRY GS. */
2933 static inline gimple_seq
2934 gimple_try_eval (gimple gs)
2936 GIMPLE_CHECK (gs, GIMPLE_TRY);
2937 return gs->gimple_try.eval;
2941 /* Return the sequence of statements used as the cleanup body for
2942 GIMPLE_TRY GS. */
2944 static inline gimple_seq
2945 gimple_try_cleanup (gimple gs)
2947 GIMPLE_CHECK (gs, GIMPLE_TRY);
2948 return gs->gimple_try.cleanup;
2952 /* Set the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2954 static inline void
2955 gimple_try_set_catch_is_cleanup (gimple g, bool catch_is_cleanup)
2957 gcc_assert (gimple_try_kind (g) == GIMPLE_TRY_CATCH);
2958 if (catch_is_cleanup)
2959 g->gsbase.subcode |= GIMPLE_TRY_CATCH_IS_CLEANUP;
2960 else
2961 g->gsbase.subcode &= ~GIMPLE_TRY_CATCH_IS_CLEANUP;
2965 /* Set EVAL to be the sequence of statements to use as the body for
2966 GIMPLE_TRY GS. */
2968 static inline void
2969 gimple_try_set_eval (gimple gs, gimple_seq eval)
2971 GIMPLE_CHECK (gs, GIMPLE_TRY);
2972 gs->gimple_try.eval = eval;
2976 /* Set CLEANUP to be the sequence of statements to use as the cleanup
2977 body for GIMPLE_TRY GS. */
2979 static inline void
2980 gimple_try_set_cleanup (gimple gs, gimple_seq cleanup)
2982 GIMPLE_CHECK (gs, GIMPLE_TRY);
2983 gs->gimple_try.cleanup = cleanup;
2987 /* Return the cleanup sequence for cleanup statement GS. */
2989 static inline gimple_seq
2990 gimple_wce_cleanup (gimple gs)
2992 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
2993 return gs->gimple_wce.cleanup;
2997 /* Set CLEANUP to be the cleanup sequence for GS. */
2999 static inline void
3000 gimple_wce_set_cleanup (gimple gs, gimple_seq cleanup)
3002 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3003 gs->gimple_wce.cleanup = cleanup;
3007 /* Return the CLEANUP_EH_ONLY flag for a WCE tuple. */
3009 static inline bool
3010 gimple_wce_cleanup_eh_only (const_gimple gs)
3012 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3013 return gs->gsbase.subcode != 0;
3017 /* Set the CLEANUP_EH_ONLY flag for a WCE tuple. */
3019 static inline void
3020 gimple_wce_set_cleanup_eh_only (gimple gs, bool eh_only_p)
3022 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3023 gs->gsbase.subcode = (unsigned int) eh_only_p;
3027 /* Return the maximum number of arguments supported by GIMPLE_PHI GS. */
3029 static inline unsigned
3030 gimple_phi_capacity (const_gimple gs)
3032 GIMPLE_CHECK (gs, GIMPLE_PHI);
3033 return gs->gimple_phi.capacity;
3037 /* Return the number of arguments in GIMPLE_PHI GS. This must always
3038 be exactly the number of incoming edges for the basic block holding
3039 GS. */
3041 static inline unsigned
3042 gimple_phi_num_args (const_gimple gs)
3044 GIMPLE_CHECK (gs, GIMPLE_PHI);
3045 return gs->gimple_phi.nargs;
3049 /* Return the SSA name created by GIMPLE_PHI GS. */
3051 static inline tree
3052 gimple_phi_result (const_gimple gs)
3054 GIMPLE_CHECK (gs, GIMPLE_PHI);
3055 return gs->gimple_phi.result;
3058 /* Return a pointer to the SSA name created by GIMPLE_PHI GS. */
3060 static inline tree *
3061 gimple_phi_result_ptr (gimple gs)
3063 GIMPLE_CHECK (gs, GIMPLE_PHI);
3064 return &gs->gimple_phi.result;
3067 /* Set RESULT to be the SSA name created by GIMPLE_PHI GS. */
3069 static inline void
3070 gimple_phi_set_result (gimple gs, tree result)
3072 GIMPLE_CHECK (gs, GIMPLE_PHI);
3073 gs->gimple_phi.result = result;
3077 /* Return the PHI argument corresponding to incoming edge INDEX for
3078 GIMPLE_PHI GS. */
3080 static inline struct phi_arg_d *
3081 gimple_phi_arg (gimple gs, unsigned index)
3083 GIMPLE_CHECK (gs, GIMPLE_PHI);
3084 gcc_assert (index <= gs->gimple_phi.capacity);
3085 return &(gs->gimple_phi.args[index]);
3088 /* Set PHIARG to be the argument corresponding to incoming edge INDEX
3089 for GIMPLE_PHI GS. */
3091 static inline void
3092 gimple_phi_set_arg (gimple gs, unsigned index, struct phi_arg_d * phiarg)
3094 GIMPLE_CHECK (gs, GIMPLE_PHI);
3095 gcc_assert (index <= gs->gimple_phi.nargs);
3096 memcpy (gs->gimple_phi.args + index, phiarg, sizeof (struct phi_arg_d));
3099 /* Return the region number for GIMPLE_RESX GS. */
3101 static inline int
3102 gimple_resx_region (const_gimple gs)
3104 GIMPLE_CHECK (gs, GIMPLE_RESX);
3105 return gs->gimple_resx.region;
3108 /* Set REGION to be the region number for GIMPLE_RESX GS. */
3110 static inline void
3111 gimple_resx_set_region (gimple gs, int region)
3113 GIMPLE_CHECK (gs, GIMPLE_RESX);
3114 gs->gimple_resx.region = region;
3118 /* Return the number of labels associated with the switch statement GS. */
3120 static inline unsigned
3121 gimple_switch_num_labels (const_gimple gs)
3123 unsigned num_ops;
3124 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3125 num_ops = gimple_num_ops (gs);
3126 gcc_assert (num_ops > 1);
3127 return num_ops - 1;
3131 /* Set NLABELS to be the number of labels for the switch statement GS. */
3133 static inline void
3134 gimple_switch_set_num_labels (gimple g, unsigned nlabels)
3136 GIMPLE_CHECK (g, GIMPLE_SWITCH);
3137 gimple_set_num_ops (g, nlabels + 1);
3141 /* Return the index variable used by the switch statement GS. */
3143 static inline tree
3144 gimple_switch_index (const_gimple gs)
3146 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3147 return gimple_op (gs, 0);
3151 /* Return a pointer to the index variable for the switch statement GS. */
3153 static inline tree *
3154 gimple_switch_index_ptr (const_gimple gs)
3156 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3157 return gimple_op_ptr (gs, 0);
3161 /* Set INDEX to be the index variable for switch statement GS. */
3163 static inline void
3164 gimple_switch_set_index (gimple gs, tree index)
3166 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3167 gcc_assert (SSA_VAR_P (index) || CONSTANT_CLASS_P (index));
3168 gimple_set_op (gs, 0, index);
3172 /* Return the label numbered INDEX. The default label is 0, followed by any
3173 labels in a switch statement. */
3175 static inline tree
3176 gimple_switch_label (const_gimple gs, unsigned index)
3178 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3179 gcc_assert (gimple_num_ops (gs) > index + 1);
3180 return gimple_op (gs, index + 1);
3183 /* Set the label number INDEX to LABEL. 0 is always the default label. */
3185 static inline void
3186 gimple_switch_set_label (gimple gs, unsigned index, tree label)
3188 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3189 gcc_assert (gimple_num_ops (gs) > index + 1);
3190 gcc_assert (label == NULL_TREE || TREE_CODE (label) == CASE_LABEL_EXPR);
3191 gimple_set_op (gs, index + 1, label);
3194 /* Return the default label for a switch statement. */
3196 static inline tree
3197 gimple_switch_default_label (const_gimple gs)
3199 return gimple_switch_label (gs, 0);
3202 /* Set the default label for a switch statement. */
3204 static inline void
3205 gimple_switch_set_default_label (gimple gs, tree label)
3207 gimple_switch_set_label (gs, 0, label);
3211 /* Return the body for the OMP statement GS. */
3213 static inline gimple_seq
3214 gimple_omp_body (gimple gs)
3216 return gs->omp.body;
3219 /* Set BODY to be the body for the OMP statement GS. */
3221 static inline void
3222 gimple_omp_set_body (gimple gs, gimple_seq body)
3224 gs->omp.body = body;
3228 /* Return the name associated with OMP_CRITICAL statement GS. */
3230 static inline tree
3231 gimple_omp_critical_name (const_gimple gs)
3233 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3234 return gs->gimple_omp_critical.name;
3238 /* Return a pointer to the name associated with OMP critical statement GS. */
3240 static inline tree *
3241 gimple_omp_critical_name_ptr (gimple gs)
3243 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3244 return &gs->gimple_omp_critical.name;
3248 /* Set NAME to be the name associated with OMP critical statement GS. */
3250 static inline void
3251 gimple_omp_critical_set_name (gimple gs, tree name)
3253 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3254 gs->gimple_omp_critical.name = name;
3258 /* Return the clauses associated with OMP_FOR GS. */
3260 static inline tree
3261 gimple_omp_for_clauses (const_gimple gs)
3263 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3264 return gs->gimple_omp_for.clauses;
3268 /* Return a pointer to the OMP_FOR GS. */
3270 static inline tree *
3271 gimple_omp_for_clauses_ptr (gimple gs)
3273 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3274 return &gs->gimple_omp_for.clauses;
3278 /* Set CLAUSES to be the list of clauses associated with OMP_FOR GS. */
3280 static inline void
3281 gimple_omp_for_set_clauses (gimple gs, tree clauses)
3283 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3284 gs->gimple_omp_for.clauses = clauses;
3288 /* Get the collapse count of OMP_FOR GS. */
3290 static inline size_t
3291 gimple_omp_for_collapse (gimple gs)
3293 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3294 return gs->gimple_omp_for.collapse;
3298 /* Return the index variable for OMP_FOR GS. */
3300 static inline tree
3301 gimple_omp_for_index (const_gimple gs, size_t i)
3303 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3304 gcc_assert (i < gs->gimple_omp_for.collapse);
3305 return gs->gimple_omp_for.iter[i].index;
3309 /* Return a pointer to the index variable for OMP_FOR GS. */
3311 static inline tree *
3312 gimple_omp_for_index_ptr (gimple gs, size_t i)
3314 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3315 gcc_assert (i < gs->gimple_omp_for.collapse);
3316 return &gs->gimple_omp_for.iter[i].index;
3320 /* Set INDEX to be the index variable for OMP_FOR GS. */
3322 static inline void
3323 gimple_omp_for_set_index (gimple gs, size_t i, tree index)
3325 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3326 gcc_assert (i < gs->gimple_omp_for.collapse);
3327 gs->gimple_omp_for.iter[i].index = index;
3331 /* Return the initial value for OMP_FOR GS. */
3333 static inline tree
3334 gimple_omp_for_initial (const_gimple gs, size_t i)
3336 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3337 gcc_assert (i < gs->gimple_omp_for.collapse);
3338 return gs->gimple_omp_for.iter[i].initial;
3342 /* Return a pointer to the initial value for OMP_FOR GS. */
3344 static inline tree *
3345 gimple_omp_for_initial_ptr (gimple gs, size_t i)
3347 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3348 gcc_assert (i < gs->gimple_omp_for.collapse);
3349 return &gs->gimple_omp_for.iter[i].initial;
3353 /* Set INITIAL to be the initial value for OMP_FOR GS. */
3355 static inline void
3356 gimple_omp_for_set_initial (gimple gs, size_t i, tree initial)
3358 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3359 gcc_assert (i < gs->gimple_omp_for.collapse);
3360 gs->gimple_omp_for.iter[i].initial = initial;
3364 /* Return the final value for OMP_FOR GS. */
3366 static inline tree
3367 gimple_omp_for_final (const_gimple gs, size_t i)
3369 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3370 gcc_assert (i < gs->gimple_omp_for.collapse);
3371 return gs->gimple_omp_for.iter[i].final;
3375 /* Return a pointer to the final value for OMP_FOR GS. */
3377 static inline tree *
3378 gimple_omp_for_final_ptr (gimple gs, size_t i)
3380 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3381 gcc_assert (i < gs->gimple_omp_for.collapse);
3382 return &gs->gimple_omp_for.iter[i].final;
3386 /* Set FINAL to be the final value for OMP_FOR GS. */
3388 static inline void
3389 gimple_omp_for_set_final (gimple gs, size_t i, tree final)
3391 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3392 gcc_assert (i < gs->gimple_omp_for.collapse);
3393 gs->gimple_omp_for.iter[i].final = final;
3397 /* Return the increment value for OMP_FOR GS. */
3399 static inline tree
3400 gimple_omp_for_incr (const_gimple gs, size_t i)
3402 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3403 gcc_assert (i < gs->gimple_omp_for.collapse);
3404 return gs->gimple_omp_for.iter[i].incr;
3408 /* Return a pointer to the increment value for OMP_FOR GS. */
3410 static inline tree *
3411 gimple_omp_for_incr_ptr (gimple gs, size_t i)
3413 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3414 gcc_assert (i < gs->gimple_omp_for.collapse);
3415 return &gs->gimple_omp_for.iter[i].incr;
3419 /* Set INCR to be the increment value for OMP_FOR GS. */
3421 static inline void
3422 gimple_omp_for_set_incr (gimple gs, size_t i, tree incr)
3424 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3425 gcc_assert (i < gs->gimple_omp_for.collapse);
3426 gs->gimple_omp_for.iter[i].incr = incr;
3430 /* Return the sequence of statements to execute before the OMP_FOR
3431 statement GS starts. */
3433 static inline gimple_seq
3434 gimple_omp_for_pre_body (gimple gs)
3436 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3437 return gs->gimple_omp_for.pre_body;
3441 /* Set PRE_BODY to be the sequence of statements to execute before the
3442 OMP_FOR statement GS starts. */
3444 static inline void
3445 gimple_omp_for_set_pre_body (gimple gs, gimple_seq pre_body)
3447 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3448 gs->gimple_omp_for.pre_body = pre_body;
3452 /* Return the clauses associated with OMP_PARALLEL GS. */
3454 static inline tree
3455 gimple_omp_parallel_clauses (const_gimple gs)
3457 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3458 return gs->gimple_omp_parallel.clauses;
3462 /* Return a pointer to the clauses associated with OMP_PARALLEL GS. */
3464 static inline tree *
3465 gimple_omp_parallel_clauses_ptr (gimple gs)
3467 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3468 return &gs->gimple_omp_parallel.clauses;
3472 /* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL
3473 GS. */
3475 static inline void
3476 gimple_omp_parallel_set_clauses (gimple gs, tree clauses)
3478 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3479 gs->gimple_omp_parallel.clauses = clauses;
3483 /* Return the child function used to hold the body of OMP_PARALLEL GS. */
3485 static inline tree
3486 gimple_omp_parallel_child_fn (const_gimple gs)
3488 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3489 return gs->gimple_omp_parallel.child_fn;
3492 /* Return a pointer to the child function used to hold the body of
3493 OMP_PARALLEL GS. */
3495 static inline tree *
3496 gimple_omp_parallel_child_fn_ptr (gimple gs)
3498 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3499 return &gs->gimple_omp_parallel.child_fn;
3503 /* Set CHILD_FN to be the child function for OMP_PARALLEL GS. */
3505 static inline void
3506 gimple_omp_parallel_set_child_fn (gimple gs, tree child_fn)
3508 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3509 gs->gimple_omp_parallel.child_fn = child_fn;
3513 /* Return the artificial argument used to send variables and values
3514 from the parent to the children threads in OMP_PARALLEL GS. */
3516 static inline tree
3517 gimple_omp_parallel_data_arg (const_gimple gs)
3519 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3520 return gs->gimple_omp_parallel.data_arg;
3524 /* Return a pointer to the data argument for OMP_PARALLEL GS. */
3526 static inline tree *
3527 gimple_omp_parallel_data_arg_ptr (gimple gs)
3529 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3530 return &gs->gimple_omp_parallel.data_arg;
3534 /* Set DATA_ARG to be the data argument for OMP_PARALLEL GS. */
3536 static inline void
3537 gimple_omp_parallel_set_data_arg (gimple gs, tree data_arg)
3539 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3540 gs->gimple_omp_parallel.data_arg = data_arg;
3544 /* Return the clauses associated with OMP_TASK GS. */
3546 static inline tree
3547 gimple_omp_task_clauses (const_gimple gs)
3549 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3550 return gs->gimple_omp_parallel.clauses;
3554 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3556 static inline tree *
3557 gimple_omp_task_clauses_ptr (gimple gs)
3559 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3560 return &gs->gimple_omp_parallel.clauses;
3564 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3565 GS. */
3567 static inline void
3568 gimple_omp_task_set_clauses (gimple gs, tree clauses)
3570 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3571 gs->gimple_omp_parallel.clauses = clauses;
3575 /* Return the child function used to hold the body of OMP_TASK GS. */
3577 static inline tree
3578 gimple_omp_task_child_fn (const_gimple gs)
3580 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3581 return gs->gimple_omp_parallel.child_fn;
3584 /* Return a pointer to the child function used to hold the body of
3585 OMP_TASK GS. */
3587 static inline tree *
3588 gimple_omp_task_child_fn_ptr (gimple gs)
3590 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3591 return &gs->gimple_omp_parallel.child_fn;
3595 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3597 static inline void
3598 gimple_omp_task_set_child_fn (gimple gs, tree child_fn)
3600 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3601 gs->gimple_omp_parallel.child_fn = child_fn;
3605 /* Return the artificial argument used to send variables and values
3606 from the parent to the children threads in OMP_TASK GS. */
3608 static inline tree
3609 gimple_omp_task_data_arg (const_gimple gs)
3611 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3612 return gs->gimple_omp_parallel.data_arg;
3616 /* Return a pointer to the data argument for OMP_TASK GS. */
3618 static inline tree *
3619 gimple_omp_task_data_arg_ptr (gimple gs)
3621 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3622 return &gs->gimple_omp_parallel.data_arg;
3626 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3628 static inline void
3629 gimple_omp_task_set_data_arg (gimple gs, tree data_arg)
3631 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3632 gs->gimple_omp_parallel.data_arg = data_arg;
3636 /* Return the clauses associated with OMP_TASK GS. */
3638 static inline tree
3639 gimple_omp_taskreg_clauses (const_gimple gs)
3641 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3642 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3643 return gs->gimple_omp_parallel.clauses;
3647 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3649 static inline tree *
3650 gimple_omp_taskreg_clauses_ptr (gimple gs)
3652 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3653 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3654 return &gs->gimple_omp_parallel.clauses;
3658 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3659 GS. */
3661 static inline void
3662 gimple_omp_taskreg_set_clauses (gimple gs, tree clauses)
3664 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3665 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3666 gs->gimple_omp_parallel.clauses = clauses;
3670 /* Return the child function used to hold the body of OMP_TASK GS. */
3672 static inline tree
3673 gimple_omp_taskreg_child_fn (const_gimple gs)
3675 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3676 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3677 return gs->gimple_omp_parallel.child_fn;
3680 /* Return a pointer to the child function used to hold the body of
3681 OMP_TASK GS. */
3683 static inline tree *
3684 gimple_omp_taskreg_child_fn_ptr (gimple gs)
3686 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3687 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3688 return &gs->gimple_omp_parallel.child_fn;
3692 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3694 static inline void
3695 gimple_omp_taskreg_set_child_fn (gimple gs, tree child_fn)
3697 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3698 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3699 gs->gimple_omp_parallel.child_fn = child_fn;
3703 /* Return the artificial argument used to send variables and values
3704 from the parent to the children threads in OMP_TASK GS. */
3706 static inline tree
3707 gimple_omp_taskreg_data_arg (const_gimple gs)
3709 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3710 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3711 return gs->gimple_omp_parallel.data_arg;
3715 /* Return a pointer to the data argument for OMP_TASK GS. */
3717 static inline tree *
3718 gimple_omp_taskreg_data_arg_ptr (gimple gs)
3720 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3721 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3722 return &gs->gimple_omp_parallel.data_arg;
3726 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3728 static inline void
3729 gimple_omp_taskreg_set_data_arg (gimple gs, tree data_arg)
3731 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3732 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3733 gs->gimple_omp_parallel.data_arg = data_arg;
3737 /* Return the copy function used to hold the body of OMP_TASK GS. */
3739 static inline tree
3740 gimple_omp_task_copy_fn (const_gimple gs)
3742 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3743 return gs->gimple_omp_task.copy_fn;
3746 /* Return a pointer to the copy function used to hold the body of
3747 OMP_TASK GS. */
3749 static inline tree *
3750 gimple_omp_task_copy_fn_ptr (gimple gs)
3752 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3753 return &gs->gimple_omp_task.copy_fn;
3757 /* Set CHILD_FN to be the copy function for OMP_TASK GS. */
3759 static inline void
3760 gimple_omp_task_set_copy_fn (gimple gs, tree copy_fn)
3762 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3763 gs->gimple_omp_task.copy_fn = copy_fn;
3767 /* Return size of the data block in bytes in OMP_TASK GS. */
3769 static inline tree
3770 gimple_omp_task_arg_size (const_gimple gs)
3772 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3773 return gs->gimple_omp_task.arg_size;
3777 /* Return a pointer to the data block size for OMP_TASK GS. */
3779 static inline tree *
3780 gimple_omp_task_arg_size_ptr (gimple gs)
3782 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3783 return &gs->gimple_omp_task.arg_size;
3787 /* Set ARG_SIZE to be the data block size for OMP_TASK GS. */
3789 static inline void
3790 gimple_omp_task_set_arg_size (gimple gs, tree arg_size)
3792 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3793 gs->gimple_omp_task.arg_size = arg_size;
3797 /* Return align of the data block in bytes in OMP_TASK GS. */
3799 static inline tree
3800 gimple_omp_task_arg_align (const_gimple gs)
3802 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3803 return gs->gimple_omp_task.arg_align;
3807 /* Return a pointer to the data block align for OMP_TASK GS. */
3809 static inline tree *
3810 gimple_omp_task_arg_align_ptr (gimple gs)
3812 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3813 return &gs->gimple_omp_task.arg_align;
3817 /* Set ARG_SIZE to be the data block align for OMP_TASK GS. */
3819 static inline void
3820 gimple_omp_task_set_arg_align (gimple gs, tree arg_align)
3822 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3823 gs->gimple_omp_task.arg_align = arg_align;
3827 /* Return the clauses associated with OMP_SINGLE GS. */
3829 static inline tree
3830 gimple_omp_single_clauses (const_gimple gs)
3832 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3833 return gs->gimple_omp_single.clauses;
3837 /* Return a pointer to the clauses associated with OMP_SINGLE GS. */
3839 static inline tree *
3840 gimple_omp_single_clauses_ptr (gimple gs)
3842 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3843 return &gs->gimple_omp_single.clauses;
3847 /* Set CLAUSES to be the clauses associated with OMP_SINGLE GS. */
3849 static inline void
3850 gimple_omp_single_set_clauses (gimple gs, tree clauses)
3852 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3853 gs->gimple_omp_single.clauses = clauses;
3857 /* Return the clauses associated with OMP_SECTIONS GS. */
3859 static inline tree
3860 gimple_omp_sections_clauses (const_gimple gs)
3862 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3863 return gs->gimple_omp_sections.clauses;
3867 /* Return a pointer to the clauses associated with OMP_SECTIONS GS. */
3869 static inline tree *
3870 gimple_omp_sections_clauses_ptr (gimple gs)
3872 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3873 return &gs->gimple_omp_sections.clauses;
3877 /* Set CLAUSES to be the set of clauses associated with OMP_SECTIONS
3878 GS. */
3880 static inline void
3881 gimple_omp_sections_set_clauses (gimple gs, tree clauses)
3883 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3884 gs->gimple_omp_sections.clauses = clauses;
3888 /* Return the control variable associated with the GIMPLE_OMP_SECTIONS
3889 in GS. */
3891 static inline tree
3892 gimple_omp_sections_control (const_gimple gs)
3894 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3895 return gs->gimple_omp_sections.control;
3899 /* Return a pointer to the clauses associated with the GIMPLE_OMP_SECTIONS
3900 GS. */
3902 static inline tree *
3903 gimple_omp_sections_control_ptr (gimple gs)
3905 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3906 return &gs->gimple_omp_sections.control;
3910 /* Set CONTROL to be the set of clauses associated with the
3911 GIMPLE_OMP_SECTIONS in GS. */
3913 static inline void
3914 gimple_omp_sections_set_control (gimple gs, tree control)
3916 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3917 gs->gimple_omp_sections.control = control;
3921 /* Set COND to be the condition code for OMP_FOR GS. */
3923 static inline void
3924 gimple_omp_for_set_cond (gimple gs, size_t i, enum tree_code cond)
3926 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3927 gcc_assert (TREE_CODE_CLASS (cond) == tcc_comparison);
3928 gcc_assert (i < gs->gimple_omp_for.collapse);
3929 gs->gimple_omp_for.iter[i].cond = cond;
3933 /* Return the condition code associated with OMP_FOR GS. */
3935 static inline enum tree_code
3936 gimple_omp_for_cond (const_gimple gs, size_t i)
3938 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3939 gcc_assert (i < gs->gimple_omp_for.collapse);
3940 return gs->gimple_omp_for.iter[i].cond;
3944 /* Set the value being stored in an atomic store. */
3946 static inline void
3947 gimple_omp_atomic_store_set_val (gimple g, tree val)
3949 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3950 g->gimple_omp_atomic_store.val = val;
3954 /* Return the value being stored in an atomic store. */
3956 static inline tree
3957 gimple_omp_atomic_store_val (const_gimple g)
3959 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3960 return g->gimple_omp_atomic_store.val;
3964 /* Return a pointer to the value being stored in an atomic store. */
3966 static inline tree *
3967 gimple_omp_atomic_store_val_ptr (gimple g)
3969 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3970 return &g->gimple_omp_atomic_store.val;
3974 /* Set the LHS of an atomic load. */
3976 static inline void
3977 gimple_omp_atomic_load_set_lhs (gimple g, tree lhs)
3979 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
3980 g->gimple_omp_atomic_load.lhs = lhs;
3984 /* Get the LHS of an atomic load. */
3986 static inline tree
3987 gimple_omp_atomic_load_lhs (const_gimple g)
3989 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
3990 return g->gimple_omp_atomic_load.lhs;
3994 /* Return a pointer to the LHS of an atomic load. */
3996 static inline tree *
3997 gimple_omp_atomic_load_lhs_ptr (gimple g)
3999 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4000 return &g->gimple_omp_atomic_load.lhs;
4004 /* Set the RHS of an atomic load. */
4006 static inline void
4007 gimple_omp_atomic_load_set_rhs (gimple g, tree rhs)
4009 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4010 g->gimple_omp_atomic_load.rhs = rhs;
4014 /* Get the RHS of an atomic load. */
4016 static inline tree
4017 gimple_omp_atomic_load_rhs (const_gimple g)
4019 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4020 return g->gimple_omp_atomic_load.rhs;
4024 /* Return a pointer to the RHS of an atomic load. */
4026 static inline tree *
4027 gimple_omp_atomic_load_rhs_ptr (gimple g)
4029 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4030 return &g->gimple_omp_atomic_load.rhs;
4034 /* Get the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4036 static inline tree
4037 gimple_omp_continue_control_def (const_gimple g)
4039 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4040 return g->gimple_omp_continue.control_def;
4043 /* The same as above, but return the address. */
4045 static inline tree *
4046 gimple_omp_continue_control_def_ptr (gimple g)
4048 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4049 return &g->gimple_omp_continue.control_def;
4052 /* Set the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4054 static inline void
4055 gimple_omp_continue_set_control_def (gimple g, tree def)
4057 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4058 g->gimple_omp_continue.control_def = def;
4062 /* Get the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4064 static inline tree
4065 gimple_omp_continue_control_use (const_gimple g)
4067 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4068 return g->gimple_omp_continue.control_use;
4072 /* The same as above, but return the address. */
4074 static inline tree *
4075 gimple_omp_continue_control_use_ptr (gimple g)
4077 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4078 return &g->gimple_omp_continue.control_use;
4082 /* Set the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4084 static inline void
4085 gimple_omp_continue_set_control_use (gimple g, tree use)
4087 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4088 g->gimple_omp_continue.control_use = use;
4092 /* Return a pointer to the return value for GIMPLE_RETURN GS. */
4094 static inline tree *
4095 gimple_return_retval_ptr (const_gimple gs)
4097 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4098 gcc_assert (gimple_num_ops (gs) == 1);
4099 return gimple_op_ptr (gs, 0);
4102 /* Return the return value for GIMPLE_RETURN GS. */
4104 static inline tree
4105 gimple_return_retval (const_gimple gs)
4107 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4108 gcc_assert (gimple_num_ops (gs) == 1);
4109 return gimple_op (gs, 0);
4113 /* Set RETVAL to be the return value for GIMPLE_RETURN GS. */
4115 static inline void
4116 gimple_return_set_retval (gimple gs, tree retval)
4118 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4119 gcc_assert (gimple_num_ops (gs) == 1);
4120 gcc_assert (retval == NULL_TREE
4121 || TREE_CODE (retval) == RESULT_DECL
4122 || is_gimple_val (retval));
4123 gimple_set_op (gs, 0, retval);
4127 /* Returns true when the gimple statment STMT is any of the OpenMP types. */
4129 static inline bool
4130 is_gimple_omp (const_gimple stmt)
4132 return (gimple_code (stmt) == GIMPLE_OMP_PARALLEL
4133 || gimple_code (stmt) == GIMPLE_OMP_TASK
4134 || gimple_code (stmt) == GIMPLE_OMP_FOR
4135 || gimple_code (stmt) == GIMPLE_OMP_SECTIONS
4136 || gimple_code (stmt) == GIMPLE_OMP_SECTIONS_SWITCH
4137 || gimple_code (stmt) == GIMPLE_OMP_SINGLE
4138 || gimple_code (stmt) == GIMPLE_OMP_SECTION
4139 || gimple_code (stmt) == GIMPLE_OMP_MASTER
4140 || gimple_code (stmt) == GIMPLE_OMP_ORDERED
4141 || gimple_code (stmt) == GIMPLE_OMP_CRITICAL
4142 || gimple_code (stmt) == GIMPLE_OMP_RETURN
4143 || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_LOAD
4144 || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_STORE
4145 || gimple_code (stmt) == GIMPLE_OMP_CONTINUE);
4149 /* Returns TRUE if statement G is a GIMPLE_NOP. */
4151 static inline bool
4152 gimple_nop_p (const_gimple g)
4154 return gimple_code (g) == GIMPLE_NOP;
4158 /* Return the new type set by GIMPLE_CHANGE_DYNAMIC_TYPE statement GS. */
4160 static inline tree
4161 gimple_cdt_new_type (gimple gs)
4163 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4164 return gimple_op (gs, 1);
4167 /* Return a pointer to the new type set by GIMPLE_CHANGE_DYNAMIC_TYPE
4168 statement GS. */
4170 static inline tree *
4171 gimple_cdt_new_type_ptr (gimple gs)
4173 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4174 return gimple_op_ptr (gs, 1);
4177 /* Set NEW_TYPE to be the type returned by GIMPLE_CHANGE_DYNAMIC_TYPE
4178 statement GS. */
4180 static inline void
4181 gimple_cdt_set_new_type (gimple gs, tree new_type)
4183 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4184 gcc_assert (TREE_CODE_CLASS (TREE_CODE (new_type)) == tcc_type);
4185 gimple_set_op (gs, 1, new_type);
4189 /* Return the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE statement GS. */
4191 static inline tree
4192 gimple_cdt_location (gimple gs)
4194 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4195 return gimple_op (gs, 0);
4199 /* Return a pointer to the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE
4200 statement GS. */
4202 static inline tree *
4203 gimple_cdt_location_ptr (gimple gs)
4205 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4206 return gimple_op_ptr (gs, 0);
4210 /* Set PTR to be the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE
4211 statement GS. */
4213 static inline void
4214 gimple_cdt_set_location (gimple gs, tree ptr)
4216 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4217 gimple_set_op (gs, 0, ptr);
4221 /* Return the predictor of GIMPLE_PREDICT statement GS. */
4223 static inline enum br_predictor
4224 gimple_predict_predictor (gimple gs)
4226 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4227 return (enum br_predictor) (gs->gsbase.subcode & ~GF_PREDICT_TAKEN);
4231 /* Set the predictor of GIMPLE_PREDICT statement GS to PREDICT. */
4233 static inline void
4234 gimple_predict_set_predictor (gimple gs, enum br_predictor predictor)
4236 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4237 gs->gsbase.subcode = (gs->gsbase.subcode & GF_PREDICT_TAKEN)
4238 | (unsigned) predictor;
4242 /* Return the outcome of GIMPLE_PREDICT statement GS. */
4244 static inline enum prediction
4245 gimple_predict_outcome (gimple gs)
4247 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4248 return (gs->gsbase.subcode & GF_PREDICT_TAKEN) ? TAKEN : NOT_TAKEN;
4252 /* Set the outcome of GIMPLE_PREDICT statement GS to OUTCOME. */
4254 static inline void
4255 gimple_predict_set_outcome (gimple gs, enum prediction outcome)
4257 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4258 if (outcome == TAKEN)
4259 gs->gsbase.subcode |= GF_PREDICT_TAKEN;
4260 else
4261 gs->gsbase.subcode &= ~GF_PREDICT_TAKEN;
4265 /* Return a new iterator pointing to GIMPLE_SEQ's first statement. */
4267 static inline gimple_stmt_iterator
4268 gsi_start (gimple_seq seq)
4270 gimple_stmt_iterator i;
4272 i.ptr = gimple_seq_first (seq);
4273 i.seq = seq;
4274 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4276 return i;
4280 /* Return a new iterator pointing to the first statement in basic block BB. */
4282 static inline gimple_stmt_iterator
4283 gsi_start_bb (basic_block bb)
4285 gimple_stmt_iterator i;
4286 gimple_seq seq;
4288 seq = bb_seq (bb);
4289 i.ptr = gimple_seq_first (seq);
4290 i.seq = seq;
4291 i.bb = bb;
4293 return i;
4297 /* Return a new iterator initially pointing to GIMPLE_SEQ's last statement. */
4299 static inline gimple_stmt_iterator
4300 gsi_last (gimple_seq seq)
4302 gimple_stmt_iterator i;
4304 i.ptr = gimple_seq_last (seq);
4305 i.seq = seq;
4306 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4308 return i;
4312 /* Return a new iterator pointing to the last statement in basic block BB. */
4314 static inline gimple_stmt_iterator
4315 gsi_last_bb (basic_block bb)
4317 gimple_stmt_iterator i;
4318 gimple_seq seq;
4320 seq = bb_seq (bb);
4321 i.ptr = gimple_seq_last (seq);
4322 i.seq = seq;
4323 i.bb = bb;
4325 return i;
4329 /* Return true if I is at the end of its sequence. */
4331 static inline bool
4332 gsi_end_p (gimple_stmt_iterator i)
4334 return i.ptr == NULL;
4338 /* Return true if I is one statement before the end of its sequence. */
4340 static inline bool
4341 gsi_one_before_end_p (gimple_stmt_iterator i)
4343 return i.ptr != NULL && i.ptr->next == NULL;
4347 /* Advance the iterator to the next gimple statement. */
4349 static inline void
4350 gsi_next (gimple_stmt_iterator *i)
4352 i->ptr = i->ptr->next;
4355 /* Advance the iterator to the previous gimple statement. */
4357 static inline void
4358 gsi_prev (gimple_stmt_iterator *i)
4360 i->ptr = i->ptr->prev;
4363 /* Return the current stmt. */
4365 static inline gimple
4366 gsi_stmt (gimple_stmt_iterator i)
4368 return i.ptr->stmt;
4371 /* Return a block statement iterator that points to the first non-label
4372 statement in block BB. */
4374 static inline gimple_stmt_iterator
4375 gsi_after_labels (basic_block bb)
4377 gimple_stmt_iterator gsi = gsi_start_bb (bb);
4379 while (!gsi_end_p (gsi) && gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL)
4380 gsi_next (&gsi);
4382 return gsi;
4385 /* Return a pointer to the current stmt.
4387 NOTE: You may want to use gsi_replace on the iterator itself,
4388 as this performs additional bookkeeping that will not be done
4389 if you simply assign through a pointer returned by gsi_stmt_ptr. */
4391 static inline gimple *
4392 gsi_stmt_ptr (gimple_stmt_iterator *i)
4394 return &i->ptr->stmt;
4398 /* Return the basic block associated with this iterator. */
4400 static inline basic_block
4401 gsi_bb (gimple_stmt_iterator i)
4403 return i.bb;
4407 /* Return the sequence associated with this iterator. */
4409 static inline gimple_seq
4410 gsi_seq (gimple_stmt_iterator i)
4412 return i.seq;
4416 enum gsi_iterator_update
4418 GSI_NEW_STMT, /* Only valid when single statement is added, move
4419 iterator to it. */
4420 GSI_SAME_STMT, /* Leave the iterator at the same statement. */
4421 GSI_CONTINUE_LINKING /* Move iterator to whatever position is suitable
4422 for linking other statements in the same
4423 direction. */
4426 /* In gimple-iterator.c */
4427 gimple_stmt_iterator gsi_start_phis (basic_block);
4428 gimple_seq gsi_split_seq_after (gimple_stmt_iterator);
4429 gimple_seq gsi_split_seq_before (gimple_stmt_iterator *);
4430 void gsi_replace (gimple_stmt_iterator *, gimple, bool);
4431 void gsi_insert_before (gimple_stmt_iterator *, gimple,
4432 enum gsi_iterator_update);
4433 void gsi_insert_before_without_update (gimple_stmt_iterator *, gimple,
4434 enum gsi_iterator_update);
4435 void gsi_insert_seq_before (gimple_stmt_iterator *, gimple_seq,
4436 enum gsi_iterator_update);
4437 void gsi_insert_seq_before_without_update (gimple_stmt_iterator *, gimple_seq,
4438 enum gsi_iterator_update);
4439 void gsi_insert_after (gimple_stmt_iterator *, gimple,
4440 enum gsi_iterator_update);
4441 void gsi_insert_after_without_update (gimple_stmt_iterator *, gimple,
4442 enum gsi_iterator_update);
4443 void gsi_insert_seq_after (gimple_stmt_iterator *, gimple_seq,
4444 enum gsi_iterator_update);
4445 void gsi_insert_seq_after_without_update (gimple_stmt_iterator *, gimple_seq,
4446 enum gsi_iterator_update);
4447 void gsi_remove (gimple_stmt_iterator *, bool);
4448 gimple_stmt_iterator gsi_for_stmt (gimple);
4449 void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *);
4450 void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *);
4451 void gsi_move_to_bb_end (gimple_stmt_iterator *, struct basic_block_def *);
4452 void gsi_insert_on_edge (edge, gimple);
4453 void gsi_insert_seq_on_edge (edge, gimple_seq);
4454 basic_block gsi_insert_on_edge_immediate (edge, gimple);
4455 basic_block gsi_insert_seq_on_edge_immediate (edge, gimple_seq);
4456 void gsi_commit_one_edge_insert (edge, basic_block *);
4457 void gsi_commit_edge_inserts (void);
4458 gimple gimple_call_copy_skip_args (gimple, bitmap);
4461 /* Convenience routines to walk all statements of a gimple function.
4462 Note that this is useful exclusively before the code is converted
4463 into SSA form. Once the program is in SSA form, the standard
4464 operand interface should be used to analyze/modify statements. */
4465 struct walk_stmt_info
4467 /* Points to the current statement being walked. */
4468 gimple_stmt_iterator gsi;
4470 /* Additional data that the callback functions may want to carry
4471 through the recursion. */
4472 void *info;
4474 /* Pointer map used to mark visited tree nodes when calling
4475 walk_tree on each operand. If set to NULL, duplicate tree nodes
4476 will be visited more than once. */
4477 struct pointer_set_t *pset;
4479 /* Indicates whether the operand being examined may be replaced
4480 with something that matches is_gimple_val (if true) or something
4481 slightly more complicated (if false). "Something" technically
4482 means the common subset of is_gimple_lvalue and is_gimple_rhs,
4483 but we never try to form anything more complicated than that, so
4484 we don't bother checking.
4486 Also note that CALLBACK should update this flag while walking the
4487 sub-expressions of a statement. For instance, when walking the
4488 statement 'foo (&var)', the flag VAL_ONLY will initially be set
4489 to true, however, when walking &var, the operand of that
4490 ADDR_EXPR does not need to be a GIMPLE value. */
4491 bool val_only;
4493 /* True if we are currently walking the LHS of an assignment. */
4494 bool is_lhs;
4496 /* Optional. Set to true by the callback functions if they made any
4497 changes. */
4498 bool changed;
4500 /* True if we're interested in location information. */
4501 bool want_locations;
4503 /* Operand returned by the callbacks. This is set when calling
4504 walk_gimple_seq. If the walk_stmt_fn or walk_tree_fn callback
4505 returns non-NULL, this field will contain the tree returned by
4506 the last callback. */
4507 tree callback_result;
4510 /* Callback for walk_gimple_stmt. Called for every statement found
4511 during traversal. The first argument points to the statement to
4512 walk. The second argument is a flag that the callback sets to
4513 'true' if it the callback handled all the operands and
4514 sub-statements of the statement (the default value of this flag is
4515 'false'). The third argument is an anonymous pointer to data
4516 to be used by the callback. */
4517 typedef tree (*walk_stmt_fn) (gimple_stmt_iterator *, bool *,
4518 struct walk_stmt_info *);
4520 gimple walk_gimple_seq (gimple_seq, walk_stmt_fn, walk_tree_fn,
4521 struct walk_stmt_info *);
4522 tree walk_gimple_stmt (gimple_stmt_iterator *, walk_stmt_fn, walk_tree_fn,
4523 struct walk_stmt_info *);
4524 tree walk_gimple_op (gimple, walk_tree_fn, struct walk_stmt_info *);
4526 #ifdef GATHER_STATISTICS
4527 /* Enum and arrays used for allocation stats. Keep in sync with
4528 gimple.c:gimple_alloc_kind_names. */
4529 enum gimple_alloc_kind
4531 gimple_alloc_kind_assign, /* Assignments. */
4532 gimple_alloc_kind_phi, /* PHI nodes. */
4533 gimple_alloc_kind_cond, /* Conditionals. */
4534 gimple_alloc_kind_seq, /* Sequences. */
4535 gimple_alloc_kind_rest, /* Everything else. */
4536 gimple_alloc_kind_all
4539 extern int gimple_alloc_counts[];
4540 extern int gimple_alloc_sizes[];
4542 /* Return the allocation kind for a given stmt CODE. */
4543 static inline enum gimple_alloc_kind
4544 gimple_alloc_kind (enum gimple_code code)
4546 switch (code)
4548 case GIMPLE_ASSIGN:
4549 return gimple_alloc_kind_assign;
4550 case GIMPLE_PHI:
4551 return gimple_alloc_kind_phi;
4552 case GIMPLE_COND:
4553 return gimple_alloc_kind_cond;
4554 default:
4555 return gimple_alloc_kind_rest;
4558 #endif /* GATHER_STATISTICS */
4560 extern void dump_gimple_statistics (void);
4562 #endif /* GCC_GIMPLE_H */