PR target/35485
[official-gcc.git] / gcc / gimple.h
bloba6947c33405d7ab272b13bd6e85309d1f5dad8e3
1 /* Gimple IR definitions.
3 Copyright 2007, 2008 Free Software Foundation, Inc.
4 Contributed by Aldy Hernandez <aldyh@redhat.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #ifndef GCC_GIMPLE_H
23 #define GCC_GIMPLE_H
25 #include "pointer-set.h"
26 #include "vec.h"
27 #include "ggc.h"
28 #include "tm.h"
29 #include "hard-reg-set.h"
30 #include "basic-block.h"
31 #include "tree-ssa-operands.h"
33 DEF_VEC_P(gimple);
34 DEF_VEC_ALLOC_P(gimple,heap);
35 DEF_VEC_ALLOC_P(gimple,gc);
37 DEF_VEC_P(gimple_seq);
38 DEF_VEC_ALLOC_P(gimple_seq,gc);
39 DEF_VEC_ALLOC_P(gimple_seq,heap);
41 /* For each block, the PHI nodes that need to be rewritten are stored into
42 these vectors. */
43 typedef VEC(gimple, heap) *gimple_vec;
44 DEF_VEC_P (gimple_vec);
45 DEF_VEC_ALLOC_P (gimple_vec, heap);
47 enum gimple_code {
48 #define DEFGSCODE(SYM, STRING, STRUCT) SYM,
49 #include "gimple.def"
50 #undef DEFGSCODE
51 LAST_AND_UNUSED_GIMPLE_CODE
54 extern const char *const gimple_code_name[];
55 extern const unsigned char gimple_rhs_class_table[];
57 /* Error out if a gimple tuple is addressed incorrectly. */
58 #if defined ENABLE_GIMPLE_CHECKING
59 extern void gimple_check_failed (const_gimple, const char *, int, \
60 const char *, enum gimple_code, \
61 enum tree_code) ATTRIBUTE_NORETURN;
62 extern void gimple_range_check_failed (const_gimple, const char *, int, \
63 const char *, enum gimple_code, \
64 enum gimple_code) ATTRIBUTE_NORETURN;
66 #define GIMPLE_CHECK(GS, CODE) \
67 do { \
68 const_gimple __gs = (GS); \
69 if (gimple_code (__gs) != (CODE)) \
70 gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__, \
71 (CODE), 0); \
72 } while (0)
73 #else /* not ENABLE_GIMPLE_CHECKING */
74 #define GIMPLE_CHECK(GS, CODE) (void)0
75 #endif
77 /* Class of GIMPLE expressions suitable for the RHS of assignments. See
78 get_gimple_rhs_class. */
79 enum gimple_rhs_class
81 GIMPLE_INVALID_RHS, /* The expression cannot be used on the RHS. */
82 GIMPLE_BINARY_RHS, /* The expression is a binary operation. */
83 GIMPLE_UNARY_RHS, /* The expression is a unary operation. */
84 GIMPLE_SINGLE_RHS /* The expression is a single object (an SSA
85 name, a _DECL, a _REF, etc. */
88 /* Specific flags for individual GIMPLE statements. These flags are
89 always stored in gimple_statement_base.subcode and they may only be
90 defined for statement codes that do not use sub-codes.
92 Values for the masks can overlap as long as the overlapping values
93 are never used in the same statement class.
95 The maximum mask value that can be defined is 1 << 15 (i.e., each
96 statement code can hold up to 16 bitflags).
98 Keep this list sorted. */
99 enum gf_mask {
100 GF_ASM_INPUT = 1 << 0,
101 GF_ASM_VOLATILE = 1 << 1,
102 GF_CALL_CANNOT_INLINE = 1 << 0,
103 GF_CALL_FROM_THUNK = 1 << 1,
104 GF_CALL_RETURN_SLOT_OPT = 1 << 2,
105 GF_CALL_TAILCALL = 1 << 3,
106 GF_CALL_VA_ARG_PACK = 1 << 4,
107 GF_OMP_PARALLEL_COMBINED = 1 << 0,
109 /* True on an GIMPLE_OMP_RETURN statement if the return does not require
110 a thread synchronization via some sort of barrier. The exact barrier
111 that would otherwise be emitted is dependent on the OMP statement with
112 which this return is associated. */
113 GF_OMP_RETURN_NOWAIT = 1 << 0,
115 GF_OMP_SECTION_LAST = 1 << 0,
116 GF_PREDICT_TAKEN = 1 << 15
119 /* Masks for selecting a pass local flag (PLF) to work on. These
120 masks are used by gimple_set_plf and gimple_plf. */
121 enum plf_mask {
122 GF_PLF_1 = 1 << 0,
123 GF_PLF_2 = 1 << 1
126 /* A node in a gimple_seq_d. */
127 struct gimple_seq_node_d GTY((chain_next ("%h.next"), chain_prev ("%h.prev")))
129 gimple stmt;
130 struct gimple_seq_node_d *prev;
131 struct gimple_seq_node_d *next;
134 /* A double-linked sequence of gimple statements. */
135 struct gimple_seq_d GTY ((chain_next ("%h.next_free")))
137 /* First and last statements in the sequence. */
138 gimple_seq_node first;
139 gimple_seq_node last;
141 /* Sequences are created/destroyed frequently. To minimize
142 allocation activity, deallocated sequences are kept in a pool of
143 available sequences. This is the pointer to the next free
144 sequence in the pool. */
145 gimple_seq next_free;
149 /* Return the first node in GIMPLE sequence S. */
151 static inline gimple_seq_node
152 gimple_seq_first (const_gimple_seq s)
154 return s ? s->first : NULL;
158 /* Return the first statement in GIMPLE sequence S. */
160 static inline gimple
161 gimple_seq_first_stmt (const_gimple_seq s)
163 gimple_seq_node n = gimple_seq_first (s);
164 return (n) ? n->stmt : NULL;
168 /* Return the last node in GIMPLE sequence S. */
170 static inline gimple_seq_node
171 gimple_seq_last (const_gimple_seq s)
173 return s ? s->last : NULL;
177 /* Return the last statement in GIMPLE sequence S. */
179 static inline gimple
180 gimple_seq_last_stmt (const_gimple_seq s)
182 gimple_seq_node n = gimple_seq_last (s);
183 return (n) ? n->stmt : NULL;
187 /* Set the last node in GIMPLE sequence S to LAST. */
189 static inline void
190 gimple_seq_set_last (gimple_seq s, gimple_seq_node last)
192 s->last = last;
196 /* Set the first node in GIMPLE sequence S to FIRST. */
198 static inline void
199 gimple_seq_set_first (gimple_seq s, gimple_seq_node first)
201 s->first = first;
205 /* Return true if GIMPLE sequence S is empty. */
207 static inline bool
208 gimple_seq_empty_p (const_gimple_seq s)
210 return s == NULL || s->first == NULL;
214 void gimple_seq_add_stmt (gimple_seq *, gimple);
216 /* Allocate a new sequence and initialize its first element with STMT. */
218 static inline gimple_seq
219 gimple_seq_alloc_with_stmt (gimple stmt)
221 gimple_seq seq = NULL;
222 gimple_seq_add_stmt (&seq, stmt);
223 return seq;
227 /* Returns the sequence of statements in BB. */
229 static inline gimple_seq
230 bb_seq (const_basic_block bb)
232 return (!(bb->flags & BB_RTL) && bb->il.gimple) ? bb->il.gimple->seq : NULL;
236 /* Sets the sequence of statements in BB to SEQ. */
238 static inline void
239 set_bb_seq (basic_block bb, gimple_seq seq)
241 gcc_assert (!(bb->flags & BB_RTL));
242 bb->il.gimple->seq = seq;
245 /* Iterator object for GIMPLE statement sequences. */
247 typedef struct
249 /* Sequence node holding the current statement. */
250 gimple_seq_node ptr;
252 /* Sequence and basic block holding the statement. These fields
253 are necessary to handle edge cases such as when statement is
254 added to an empty basic block or when the last statement of a
255 block/sequence is removed. */
256 gimple_seq seq;
257 basic_block bb;
258 } gimple_stmt_iterator;
261 /* Data structure definitions for GIMPLE tuples. NOTE: word markers
262 are for 64 bit hosts. */
264 struct gimple_statement_base GTY(())
266 /* [ WORD 1 ]
267 Main identifying code for a tuple. */
268 ENUM_BITFIELD(gimple_code) code : 8;
270 /* Nonzero if a warning should not be emitted on this tuple. */
271 unsigned int no_warning : 1;
273 /* Nonzero if this tuple has been visited. Passes are responsible
274 for clearing this bit before using it. */
275 unsigned int visited : 1;
277 /* Nonzero if this tuple represents a non-temporal move. */
278 unsigned int nontemporal_move : 1;
280 /* Pass local flags. These flags are free for any pass to use as
281 they see fit. Passes should not assume that these flags contain
282 any useful value when the pass starts. Any initial state that
283 the pass requires should be set on entry to the pass. See
284 gimple_set_plf and gimple_plf for usage. */
285 unsigned int plf : 2;
287 /* Nonzero if this statement has been modified and needs to have its
288 operands rescanned. */
289 unsigned modified : 1;
291 /* Nonzero if this statement contains volatile operands. */
292 unsigned has_volatile_ops : 1;
294 /* Nonzero if this statement contains memory refernces. */
295 unsigned references_memory_p : 1;
297 /* The SUBCODE field can be used for tuple-specific flags for tuples
298 that do not require subcodes. Note that SUBCODE should be at
299 least as wide as tree codes, as several tuples store tree codes
300 in there. */
301 unsigned int subcode : 16;
303 /* UID of this statement. */
304 unsigned uid;
306 /* [ WORD 2 ]
307 Locus information for debug info. */
308 location_t location;
310 /* Number of operands in this tuple. */
311 unsigned num_ops;
313 /* [ WORD 3 ]
314 Basic block holding this statement. */
315 struct basic_block_def *bb;
317 /* [ WORD 4 ]
318 Lexical block holding this statement. */
319 tree block;
323 /* Base structure for tuples with operands. */
325 struct gimple_statement_with_ops_base GTY(())
327 /* [ WORD 1-4 ] */
328 struct gimple_statement_base gsbase;
330 /* [ WORD 5 ]
331 Symbols whose addresses are taken by this statement (i.e., they
332 appear inside ADDR_EXPR nodes). */
333 bitmap GTY((skip (""))) addresses_taken;
335 /* [ WORD 6-7 ]
336 SSA operand vectors. NOTE: It should be possible to
337 amalgamate these vectors with the operand vector OP. However,
338 the SSA operand vectors are organized differently and contain
339 more information (like immediate use chaining). */
340 struct def_optype_d GTY((skip (""))) *def_ops;
341 struct use_optype_d GTY((skip (""))) *use_ops;
345 /* Statements that take register operands. */
347 struct gimple_statement_with_ops GTY(())
349 /* [ WORD 1-7 ] */
350 struct gimple_statement_with_ops_base opbase;
352 /* [ WORD 8 ]
353 Operand vector. NOTE! This must always be the last field
354 of this structure. In particular, this means that this
355 structure cannot be embedded inside another one. */
356 tree GTY((length ("%h.opbase.gsbase.num_ops"))) op[1];
360 /* Base for statements that take both memory and register operands. */
362 struct gimple_statement_with_memory_ops_base GTY(())
364 /* [ WORD 1-7 ] */
365 struct gimple_statement_with_ops_base opbase;
367 /* [ WORD 8-9 ]
368 Vectors for virtual operands. */
369 struct voptype_d GTY((skip (""))) *vdef_ops;
370 struct voptype_d GTY((skip (""))) *vuse_ops;
372 /* [ WORD 9-10 ]
373 Symbols stored/loaded by this statement. */
374 bitmap GTY((skip (""))) stores;
375 bitmap GTY((skip (""))) loads;
379 /* Statements that take both memory and register operands. */
381 struct gimple_statement_with_memory_ops GTY(())
383 /* [ WORD 1-10 ] */
384 struct gimple_statement_with_memory_ops_base membase;
386 /* [ WORD 11 ]
387 Operand vector. NOTE! This must always be the last field
388 of this structure. In particular, this means that this
389 structure cannot be embedded inside another one. */
390 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
394 /* OpenMP statements (#pragma omp). */
396 struct gimple_statement_omp GTY(())
398 /* [ WORD 1-4 ] */
399 struct gimple_statement_base gsbase;
401 /* [ WORD 5 ] */
402 gimple_seq body;
406 /* GIMPLE_BIND */
408 struct gimple_statement_bind GTY(())
410 /* [ WORD 1-4 ] */
411 struct gimple_statement_base gsbase;
413 /* [ WORD 5 ]
414 Variables declared in this scope. */
415 tree vars;
417 /* [ WORD 6 ]
418 This is different than the BLOCK field in gimple_statement_base,
419 which is analogous to TREE_BLOCK (i.e., the lexical block holding
420 this statement). This field is the equivalent of BIND_EXPR_BLOCK
421 in tree land (i.e., the lexical scope defined by this bind). See
422 gimple-low.c. */
423 tree block;
425 /* [ WORD 7 ] */
426 gimple_seq body;
430 /* GIMPLE_CATCH */
432 struct gimple_statement_catch GTY(())
434 /* [ WORD 1-4 ] */
435 struct gimple_statement_base gsbase;
437 /* [ WORD 5 ] */
438 tree types;
440 /* [ WORD 6 ] */
441 gimple_seq handler;
445 /* GIMPLE_EH_FILTER */
447 struct gimple_statement_eh_filter GTY(())
449 /* [ WORD 1-4 ] */
450 struct gimple_statement_base gsbase;
452 /* Subcode: EH_FILTER_MUST_NOT_THROW. A boolean flag analogous to
453 the tree counterpart. */
455 /* [ WORD 5 ]
456 Filter types. */
457 tree types;
459 /* [ WORD 6 ]
460 Failure actions. */
461 gimple_seq failure;
465 /* GIMPLE_PHI */
467 struct gimple_statement_phi GTY(())
469 /* [ WORD 1-4 ] */
470 struct gimple_statement_base gsbase;
472 /* [ WORD 5 ] */
473 unsigned capacity;
474 unsigned nargs;
476 /* [ WORD 6 ] */
477 tree result;
479 /* [ WORD 7 ] */
480 struct phi_arg_d GTY ((length ("%h.nargs"))) args[1];
484 /* GIMPLE_RESX */
486 struct gimple_statement_resx GTY(())
488 /* [ WORD 1-4 ] */
489 struct gimple_statement_base gsbase;
491 /* [ WORD 5 ]
492 Exception region number. */
493 int region;
497 /* GIMPLE_TRY */
499 struct gimple_statement_try GTY(())
501 /* [ WORD 1-4 ] */
502 struct gimple_statement_base gsbase;
504 /* [ WORD 5 ]
505 Expression to evaluate. */
506 gimple_seq eval;
508 /* [ WORD 6 ]
509 Cleanup expression. */
510 gimple_seq cleanup;
513 /* Kind of GIMPLE_TRY statements. */
514 enum gimple_try_flags
516 /* A try/catch. */
517 GIMPLE_TRY_CATCH = 1 << 0,
519 /* A try/finally. */
520 GIMPLE_TRY_FINALLY = 1 << 1,
521 GIMPLE_TRY_KIND = GIMPLE_TRY_CATCH | GIMPLE_TRY_FINALLY,
523 /* Analogous to TRY_CATCH_IS_CLEANUP. */
524 GIMPLE_TRY_CATCH_IS_CLEANUP = 1 << 2
527 /* GIMPLE_WITH_CLEANUP_EXPR */
529 struct gimple_statement_wce GTY(())
531 /* [ WORD 1-4 ] */
532 struct gimple_statement_base gsbase;
534 /* Subcode: CLEANUP_EH_ONLY. True if the cleanup should only be
535 executed if an exception is thrown, not on normal exit of its
536 scope. This flag is analogous to the CLEANUP_EH_ONLY flag
537 in TARGET_EXPRs. */
539 /* [ WORD 5 ]
540 Cleanup expression. */
541 gimple_seq cleanup;
545 /* GIMPLE_ASM */
547 struct gimple_statement_asm GTY(())
549 /* [ WORD 1-10 ] */
550 struct gimple_statement_with_memory_ops_base membase;
552 /* [ WORD 11 ]
553 __asm__ statement. */
554 const char *string;
556 /* [ WORD 12 ]
557 Number of inputs, outputs and clobbers. */
558 unsigned char ni;
559 unsigned char no;
560 unsigned short nc;
562 /* [ WORD 13 ]
563 Operand vector. NOTE! This must always be the last field
564 of this structure. In particular, this means that this
565 structure cannot be embedded inside another one. */
566 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
569 /* GIMPLE_OMP_CRITICAL */
571 struct gimple_statement_omp_critical GTY(())
573 /* [ WORD 1-5 ] */
574 struct gimple_statement_omp omp;
576 /* [ WORD 6 ]
577 Critical section name. */
578 tree name;
582 struct gimple_omp_for_iter GTY(())
584 /* Condition code. */
585 enum tree_code cond;
587 /* Index variable. */
588 tree index;
590 /* Initial value. */
591 tree initial;
593 /* Final value. */
594 tree final;
596 /* Increment. */
597 tree incr;
600 /* GIMPLE_OMP_FOR */
602 struct gimple_statement_omp_for GTY(())
604 /* [ WORD 1-5 ] */
605 struct gimple_statement_omp omp;
607 /* [ WORD 6 ] */
608 tree clauses;
610 /* [ WORD 7 ]
611 Number of elements in iter array. */
612 size_t collapse;
614 /* [ WORD 8 ] */
615 struct gimple_omp_for_iter * GTY((length ("%h.collapse"))) iter;
617 /* [ WORD 9 ]
618 Pre-body evaluated before the loop body begins. */
619 gimple_seq pre_body;
623 /* GIMPLE_OMP_PARALLEL */
625 struct gimple_statement_omp_parallel GTY(())
627 /* [ WORD 1-5 ] */
628 struct gimple_statement_omp omp;
630 /* [ WORD 6 ]
631 Clauses. */
632 tree clauses;
634 /* [ WORD 7 ]
635 Child function holding the body of the parallel region. */
636 tree child_fn;
638 /* [ WORD 8 ]
639 Shared data argument. */
640 tree data_arg;
644 /* GIMPLE_OMP_TASK */
646 struct gimple_statement_omp_task GTY(())
648 /* [ WORD 1-8 ] */
649 struct gimple_statement_omp_parallel par;
651 /* [ WORD 9 ]
652 Child function holding firstprivate initialization if needed. */
653 tree copy_fn;
655 /* [ WORD 10-11 ]
656 Size and alignment in bytes of the argument data block. */
657 tree arg_size;
658 tree arg_align;
662 /* GIMPLE_OMP_SECTION */
663 /* Uses struct gimple_statement_omp. */
666 /* GIMPLE_OMP_SECTIONS */
668 struct gimple_statement_omp_sections GTY(())
670 /* [ WORD 1-5 ] */
671 struct gimple_statement_omp omp;
673 /* [ WORD 6 ] */
674 tree clauses;
676 /* [ WORD 7 ]
677 The control variable used for deciding which of the sections to
678 execute. */
679 tree control;
682 /* GIMPLE_OMP_CONTINUE.
684 Note: This does not inherit from gimple_statement_omp, because we
685 do not need the body field. */
687 struct gimple_statement_omp_continue GTY(())
689 /* [ WORD 1-4 ] */
690 struct gimple_statement_base gsbase;
692 /* [ WORD 5 ] */
693 tree control_def;
695 /* [ WORD 6 ] */
696 tree control_use;
699 /* GIMPLE_OMP_SINGLE */
701 struct gimple_statement_omp_single GTY(())
703 /* [ WORD 1-5 ] */
704 struct gimple_statement_omp omp;
706 /* [ WORD 6 ] */
707 tree clauses;
711 /* GIMPLE_OMP_ATOMIC_LOAD.
712 Note: This is based on gimple_statement_base, not g_s_omp, because g_s_omp
713 contains a sequence, which we don't need here. */
715 struct gimple_statement_omp_atomic_load GTY(())
717 /* [ WORD 1-4 ] */
718 struct gimple_statement_base gsbase;
720 /* [ WORD 5-6 ] */
721 tree rhs, lhs;
724 /* GIMPLE_OMP_ATOMIC_STORE.
725 See note on GIMPLE_OMP_ATOMIC_LOAD. */
727 struct gimple_statement_omp_atomic_store GTY(())
729 /* [ WORD 1-4 ] */
730 struct gimple_statement_base gsbase;
732 /* [ WORD 5 ] */
733 tree val;
736 enum gimple_statement_structure_enum {
737 #define DEFGSSTRUCT(SYM, STRING) SYM,
738 #include "gsstruct.def"
739 #undef DEFGSSTRUCT
740 LAST_GSS_ENUM
744 /* Define the overall contents of a gimple tuple. It may be any of the
745 structures declared above for various types of tuples. */
747 union gimple_statement_d GTY ((desc ("gimple_statement_structure (&%h)")))
749 struct gimple_statement_base GTY ((tag ("GSS_BASE"))) gsbase;
750 struct gimple_statement_with_ops GTY ((tag ("GSS_WITH_OPS"))) gsops;
751 struct gimple_statement_with_memory_ops GTY ((tag ("GSS_WITH_MEM_OPS"))) gsmem;
752 struct gimple_statement_omp GTY ((tag ("GSS_OMP"))) omp;
753 struct gimple_statement_bind GTY ((tag ("GSS_BIND"))) gimple_bind;
754 struct gimple_statement_catch GTY ((tag ("GSS_CATCH"))) gimple_catch;
755 struct gimple_statement_eh_filter GTY ((tag ("GSS_EH_FILTER"))) gimple_eh_filter;
756 struct gimple_statement_phi GTY ((tag ("GSS_PHI"))) gimple_phi;
757 struct gimple_statement_resx GTY ((tag ("GSS_RESX"))) gimple_resx;
758 struct gimple_statement_try GTY ((tag ("GSS_TRY"))) gimple_try;
759 struct gimple_statement_wce GTY ((tag ("GSS_WCE"))) gimple_wce;
760 struct gimple_statement_asm GTY ((tag ("GSS_ASM"))) gimple_asm;
761 struct gimple_statement_omp_critical GTY ((tag ("GSS_OMP_CRITICAL"))) gimple_omp_critical;
762 struct gimple_statement_omp_for GTY ((tag ("GSS_OMP_FOR"))) gimple_omp_for;
763 struct gimple_statement_omp_parallel GTY ((tag ("GSS_OMP_PARALLEL"))) gimple_omp_parallel;
764 struct gimple_statement_omp_task GTY ((tag ("GSS_OMP_TASK"))) gimple_omp_task;
765 struct gimple_statement_omp_sections GTY ((tag ("GSS_OMP_SECTIONS"))) gimple_omp_sections;
766 struct gimple_statement_omp_single GTY ((tag ("GSS_OMP_SINGLE"))) gimple_omp_single;
767 struct gimple_statement_omp_continue GTY ((tag ("GSS_OMP_CONTINUE"))) gimple_omp_continue;
768 struct gimple_statement_omp_atomic_load GTY ((tag ("GSS_OMP_ATOMIC_LOAD"))) gimple_omp_atomic_load;
769 struct gimple_statement_omp_atomic_store GTY ((tag ("GSS_OMP_ATOMIC_STORE"))) gimple_omp_atomic_store;
772 /* In gimple.c. */
773 gimple gimple_build_return (tree);
775 gimple gimple_build_assign_stat (tree, tree MEM_STAT_DECL);
776 #define gimple_build_assign(l,r) gimple_build_assign_stat (l, r MEM_STAT_INFO)
778 void extract_ops_from_tree (tree, enum tree_code *, tree *, tree *);
780 gimple gimple_build_assign_with_ops_stat (enum tree_code, tree, tree,
781 tree MEM_STAT_DECL);
782 #define gimple_build_assign_with_ops(c,o1,o2,o3) \
783 gimple_build_assign_with_ops_stat (c, o1, o2, o3 MEM_STAT_INFO)
785 gimple gimple_build_call_vec (tree, VEC(tree, heap) *);
786 gimple gimple_build_call (tree, unsigned, ...);
787 gimple gimple_build_call_from_tree (tree);
788 gimple gimplify_assign (tree, tree, gimple_seq *);
789 gimple gimple_build_cond (enum tree_code, tree, tree, tree, tree);
790 gimple gimple_build_label (tree label);
791 gimple gimple_build_goto (tree dest);
792 gimple gimple_build_nop (void);
793 gimple gimple_build_bind (tree, gimple_seq, tree);
794 gimple gimple_build_asm (const char *, unsigned, unsigned, unsigned, ...);
795 gimple gimple_build_asm_vec (const char *, VEC(tree,gc) *, VEC(tree,gc) *,
796 VEC(tree,gc) *);
797 gimple gimple_build_catch (tree, gimple_seq);
798 gimple gimple_build_eh_filter (tree, gimple_seq);
799 gimple gimple_build_try (gimple_seq, gimple_seq, unsigned int);
800 gimple gimple_build_wce (gimple_seq);
801 gimple gimple_build_resx (int);
802 gimple gimple_build_switch (unsigned, tree, tree, ...);
803 gimple gimple_build_switch_vec (tree, tree, VEC(tree,heap) *);
804 gimple gimple_build_omp_parallel (gimple_seq, tree, tree, tree);
805 gimple gimple_build_omp_task (gimple_seq, tree, tree, tree, tree, tree, tree);
806 gimple gimple_build_omp_for (gimple_seq, tree, size_t, gimple_seq);
807 gimple gimple_build_omp_critical (gimple_seq, tree);
808 gimple gimple_build_omp_section (gimple_seq);
809 gimple gimple_build_omp_continue (tree, tree);
810 gimple gimple_build_omp_master (gimple_seq);
811 gimple gimple_build_omp_return (bool);
812 gimple gimple_build_omp_ordered (gimple_seq);
813 gimple gimple_build_omp_sections (gimple_seq, tree);
814 gimple gimple_build_omp_sections_switch (void);
815 gimple gimple_build_omp_single (gimple_seq, tree);
816 gimple gimple_build_cdt (tree, tree);
817 gimple gimple_build_omp_atomic_load (tree, tree);
818 gimple gimple_build_omp_atomic_store (tree);
819 gimple gimple_build_predict (enum br_predictor, enum prediction);
820 enum gimple_statement_structure_enum gimple_statement_structure (gimple);
821 enum gimple_statement_structure_enum gss_for_assign (enum tree_code);
822 void sort_case_labels (VEC(tree,heap) *);
823 void gimple_set_body (tree, gimple_seq);
824 gimple_seq gimple_body (tree);
825 bool gimple_has_body_p (tree);
826 gimple_seq gimple_seq_alloc (void);
827 void gimple_seq_free (gimple_seq);
828 void gimple_seq_add_seq (gimple_seq *, gimple_seq);
829 gimple_seq gimple_seq_copy (gimple_seq);
830 int gimple_call_flags (const_gimple);
831 bool gimple_assign_copy_p (gimple);
832 bool gimple_assign_ssa_name_copy_p (gimple);
833 bool gimple_assign_single_p (gimple);
834 bool gimple_assign_unary_nop_p (gimple);
835 void gimple_set_bb (gimple, struct basic_block_def *);
836 tree gimple_fold (const_gimple);
837 void gimple_assign_set_rhs_from_tree (gimple_stmt_iterator *, tree);
838 void gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *, enum tree_code,
839 tree, tree);
840 tree gimple_get_lhs (const_gimple);
841 void gimple_set_lhs (gimple, tree);
842 gimple gimple_copy (gimple);
843 bool is_gimple_operand (const_tree);
844 void gimple_set_modified (gimple, bool);
845 void gimple_cond_get_ops_from_tree (tree, enum tree_code *, tree *, tree *);
846 gimple gimple_build_cond_from_tree (tree, tree, tree);
847 void gimple_cond_set_condition_from_tree (gimple, tree);
848 bool gimple_has_side_effects (const_gimple);
849 bool gimple_rhs_has_side_effects (const_gimple);
850 bool gimple_could_trap_p (gimple);
851 bool gimple_assign_rhs_could_trap_p (gimple);
852 void gimple_regimplify_operands (gimple, gimple_stmt_iterator *);
853 bool empty_body_p (gimple_seq);
854 unsigned get_gimple_rhs_num_ops (enum tree_code);
856 /* Returns true iff T is a valid GIMPLE statement. */
857 extern bool is_gimple_stmt (tree);
859 /* Returns true iff TYPE is a valid type for a scalar register variable. */
860 extern bool is_gimple_reg_type (tree);
861 /* Returns true iff T is a scalar register variable. */
862 extern bool is_gimple_reg (tree);
863 /* Returns true if T is a GIMPLE temporary variable, false otherwise. */
864 extern bool is_gimple_formal_tmp_var (tree);
865 /* Returns true if T is a GIMPLE temporary register variable. */
866 extern bool is_gimple_formal_tmp_reg (tree);
867 /* Returns true iff T is any sort of variable. */
868 extern bool is_gimple_variable (tree);
869 /* Returns true iff T is any sort of symbol. */
870 extern bool is_gimple_id (tree);
871 /* Returns true iff T is a variable or an INDIRECT_REF (of a variable). */
872 extern bool is_gimple_min_lval (tree);
873 /* Returns true iff T is something whose address can be taken. */
874 extern bool is_gimple_addressable (tree);
875 /* Returns true iff T is any valid GIMPLE lvalue. */
876 extern bool is_gimple_lvalue (tree);
878 /* Returns true iff T is a GIMPLE address. */
879 bool is_gimple_address (const_tree);
880 /* Returns true iff T is a GIMPLE invariant address. */
881 bool is_gimple_invariant_address (const_tree);
882 /* Returns true iff T is a GIMPLE invariant address at interprocedural
883 level. */
884 bool is_gimple_ip_invariant_address (const_tree);
885 /* Returns true iff T is a valid GIMPLE constant. */
886 bool is_gimple_constant (const_tree);
887 /* Returns true iff T is a GIMPLE restricted function invariant. */
888 extern bool is_gimple_min_invariant (const_tree);
889 /* Returns true iff T is a GIMPLE restricted interprecodural invariant. */
890 extern bool is_gimple_ip_invariant (const_tree);
891 /* Returns true iff T is a GIMPLE rvalue. */
892 extern bool is_gimple_val (tree);
893 /* Returns true iff T is a GIMPLE asm statement input. */
894 extern bool is_gimple_asm_val (tree);
895 /* Returns true iff T is a valid rhs for a MODIFY_EXPR where the LHS is a
896 GIMPLE temporary, a renamed user variable, or something else,
897 respectively. */
898 extern bool is_gimple_formal_tmp_rhs (tree);
899 extern bool is_gimple_reg_rhs (tree);
900 extern bool is_gimple_mem_rhs (tree);
902 /* Returns true iff T is a valid if-statement condition. */
903 extern bool is_gimple_condexpr (tree);
905 /* Returns true iff T is a type conversion. */
906 extern bool is_gimple_cast (tree);
907 /* Returns true iff T is a variable that does not need to live in memory. */
908 extern bool is_gimple_non_addressable (tree t);
910 /* Returns true iff T is a valid call address expression. */
911 extern bool is_gimple_call_addr (tree);
912 /* If T makes a function call, returns the CALL_EXPR operand. */
913 extern tree get_call_expr_in (tree t);
915 extern void recalculate_side_effects (tree);
917 /* In gimplify.c */
918 extern tree create_tmp_var_raw (tree, const char *);
919 extern tree create_tmp_var_name (const char *);
920 extern tree create_tmp_var (tree, const char *);
921 extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq *);
922 extern tree get_formal_tmp_var (tree, gimple_seq *);
923 extern void declare_vars (tree, gimple, bool);
924 extern void tree_annotate_all_with_location (tree *, location_t);
925 extern void annotate_all_with_location (gimple_seq, location_t);
927 /* Validation of GIMPLE expressions. Note that these predicates only check
928 the basic form of the expression, they don't recurse to make sure that
929 underlying nodes are also of the right form. */
930 typedef bool (*gimple_predicate)(tree);
933 /* FIXME we should deduce this from the predicate. */
934 typedef enum fallback_t {
935 fb_none = 0, /* Do not generate a temporary. */
937 fb_rvalue = 1, /* Generate an rvalue to hold the result of a
938 gimplified expression. */
940 fb_lvalue = 2, /* Generate an lvalue to hold the result of a
941 gimplified expression. */
943 fb_mayfail = 4, /* Gimplification may fail. Error issued
944 afterwards. */
945 fb_either= fb_rvalue | fb_lvalue
946 } fallback_t;
948 enum gimplify_status {
949 GS_ERROR = -2, /* Something Bad Seen. */
950 GS_UNHANDLED = -1, /* A langhook result for "I dunno". */
951 GS_OK = 0, /* We did something, maybe more to do. */
952 GS_ALL_DONE = 1 /* The expression is fully gimplified. */
955 struct gimplify_ctx
957 struct gimplify_ctx *prev_context;
959 VEC(gimple,heap) *bind_expr_stack;
960 tree temps;
961 gimple_seq conditional_cleanups;
962 tree exit_label;
963 tree return_temp;
965 VEC(tree,heap) *case_labels;
966 /* The formal temporary table. Should this be persistent? */
967 htab_t temp_htab;
969 int conditions;
970 bool save_stack;
971 bool into_ssa;
972 bool allow_rhs_cond_expr;
975 extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *,
976 bool (*) (tree), fallback_t);
977 extern void gimplify_type_sizes (tree, gimple_seq *);
978 extern void gimplify_one_sizepos (tree *, gimple_seq *);
979 extern bool gimplify_stmt (tree *, gimple_seq *);
980 extern gimple gimplify_body (tree *, tree, bool);
981 extern void push_gimplify_context (struct gimplify_ctx *);
982 extern void pop_gimplify_context (gimple);
983 extern void gimplify_and_add (tree, gimple_seq *);
985 /* Miscellaneous helpers. */
986 extern void gimple_add_tmp_var (tree);
987 extern gimple gimple_current_bind_expr (void);
988 extern VEC(gimple, heap) *gimple_bind_expr_stack (void);
989 extern tree voidify_wrapper_expr (tree, tree);
990 extern tree build_and_jump (tree *);
991 extern tree alloc_stmt_list (void);
992 extern void free_stmt_list (tree);
993 extern tree force_labels_r (tree *, int *, void *);
994 extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *,
995 gimple_seq *);
996 struct gimplify_omp_ctx;
997 extern void omp_firstprivatize_variable (struct gimplify_omp_ctx *, tree);
998 extern tree gimple_boolify (tree);
999 extern gimple_predicate rhs_predicate_for (tree);
1000 extern tree canonicalize_cond_expr_cond (tree);
1002 /* In omp-low.c. */
1003 extern void diagnose_omp_structured_block_errors (tree);
1004 extern tree omp_reduction_init (tree, tree);
1006 /* In tree-nested.c. */
1007 extern void lower_nested_functions (tree);
1008 extern void insert_field_into_struct (tree, tree);
1010 /* In gimplify.c. */
1011 extern void gimplify_function_tree (tree);
1013 /* In cfgexpand.c. */
1014 extern tree gimple_assign_rhs_to_tree (gimple);
1016 /* In builtins.c */
1017 extern bool validate_gimple_arglist (const_gimple, ...);
1019 /* In tree-ssa-operands.c */
1020 extern void gimple_add_to_addresses_taken (gimple, tree);
1022 /* In tree-ssa.c */
1023 extern bool tree_ssa_useless_type_conversion (tree);
1024 extern bool useless_type_conversion_p (tree, tree);
1025 extern bool types_compatible_p (tree, tree);
1027 /* Return the code for GIMPLE statement G. */
1029 static inline enum gimple_code
1030 gimple_code (const_gimple g)
1032 return g->gsbase.code;
1036 /* Return true if statement G has sub-statements. This is only true for
1037 High GIMPLE statements. */
1039 static inline bool
1040 gimple_has_substatements (gimple g)
1042 switch (gimple_code (g))
1044 case GIMPLE_BIND:
1045 case GIMPLE_CATCH:
1046 case GIMPLE_EH_FILTER:
1047 case GIMPLE_TRY:
1048 case GIMPLE_OMP_FOR:
1049 case GIMPLE_OMP_MASTER:
1050 case GIMPLE_OMP_ORDERED:
1051 case GIMPLE_OMP_SECTION:
1052 case GIMPLE_OMP_PARALLEL:
1053 case GIMPLE_OMP_TASK:
1054 case GIMPLE_OMP_SECTIONS:
1055 case GIMPLE_OMP_SINGLE:
1056 case GIMPLE_OMP_CRITICAL:
1057 case GIMPLE_WITH_CLEANUP_EXPR:
1058 return true;
1060 default:
1061 return false;
1066 /* Return the basic block holding statement G. */
1068 static inline struct basic_block_def *
1069 gimple_bb (const_gimple g)
1071 return g->gsbase.bb;
1075 /* Return the lexical scope block holding statement G. */
1077 static inline tree
1078 gimple_block (const_gimple g)
1080 return g->gsbase.block;
1084 /* Set BLOCK to be the lexical scope block holding statement G. */
1086 static inline void
1087 gimple_set_block (gimple g, tree block)
1089 g->gsbase.block = block;
1093 /* Return location information for statement G. */
1095 static inline location_t
1096 gimple_location (const_gimple g)
1098 return g->gsbase.location;
1101 /* Return pointer to location information for statement G. */
1103 static inline const location_t *
1104 gimple_location_ptr (const_gimple g)
1106 return &g->gsbase.location;
1110 /* Set location information for statement G. */
1112 static inline void
1113 gimple_set_location (gimple g, location_t location)
1115 g->gsbase.location = location;
1119 /* Return true if G contains location information. */
1121 static inline bool
1122 gimple_has_location (const_gimple g)
1124 return gimple_location (g) != UNKNOWN_LOCATION;
1128 /* Return the file name of the location of STMT. */
1130 static inline const char *
1131 gimple_filename (const_gimple stmt)
1133 return LOCATION_FILE (gimple_location (stmt));
1137 /* Return the line number of the location of STMT. */
1139 static inline int
1140 gimple_lineno (const_gimple stmt)
1142 return LOCATION_LINE (gimple_location (stmt));
1146 /* Determine whether SEQ is a singleton. */
1148 static inline bool
1149 gimple_seq_singleton_p (gimple_seq seq)
1151 return ((gimple_seq_first (seq) != NULL)
1152 && (gimple_seq_first (seq) == gimple_seq_last (seq)));
1155 /* Return true if no warnings should be emitted for statement STMT. */
1157 static inline bool
1158 gimple_no_warning_p (const_gimple stmt)
1160 return stmt->gsbase.no_warning;
1163 /* Set the no_warning flag of STMT to NO_WARNING. */
1165 static inline void
1166 gimple_set_no_warning (gimple stmt, bool no_warning)
1168 stmt->gsbase.no_warning = (unsigned) no_warning;
1171 /* Set the visited status on statement STMT to VISITED_P. */
1173 static inline void
1174 gimple_set_visited (gimple stmt, bool visited_p)
1176 stmt->gsbase.visited = (unsigned) visited_p;
1180 /* Return the visited status for statement STMT. */
1182 static inline bool
1183 gimple_visited_p (gimple stmt)
1185 return stmt->gsbase.visited;
1189 /* Set pass local flag PLF on statement STMT to VAL_P. */
1191 static inline void
1192 gimple_set_plf (gimple stmt, enum plf_mask plf, bool val_p)
1194 if (val_p)
1195 stmt->gsbase.plf |= (unsigned int) plf;
1196 else
1197 stmt->gsbase.plf &= ~((unsigned int) plf);
1201 /* Return the value of pass local flag PLF on statement STMT. */
1203 static inline unsigned int
1204 gimple_plf (gimple stmt, enum plf_mask plf)
1206 return stmt->gsbase.plf & ((unsigned int) plf);
1210 /* Set the uid of statement */
1212 static inline void
1213 gimple_set_uid (gimple g, unsigned uid)
1215 g->gsbase.uid = uid;
1219 /* Return the uid of statement */
1221 static inline unsigned
1222 gimple_uid (const_gimple g)
1224 return g->gsbase.uid;
1228 /* Return true if GIMPLE statement G has register or memory operands. */
1230 static inline bool
1231 gimple_has_ops (const_gimple g)
1233 return gimple_code (g) >= GIMPLE_COND && gimple_code (g) <= GIMPLE_RETURN;
1237 /* Return true if GIMPLE statement G has memory operands. */
1239 static inline bool
1240 gimple_has_mem_ops (const_gimple g)
1242 return gimple_code (g) >= GIMPLE_ASSIGN && gimple_code (g) <= GIMPLE_RETURN;
1245 /* Return the set of addresses taken by statement G. */
1247 static inline bitmap
1248 gimple_addresses_taken (const_gimple g)
1250 if (gimple_has_ops (g))
1251 return g->gsops.opbase.addresses_taken;
1252 else
1253 return NULL;
1257 /* Return a pointer to the set of addresses taken by statement G. */
1259 static inline bitmap *
1260 gimple_addresses_taken_ptr (gimple g)
1262 if (gimple_has_ops (g))
1263 return &g->gsops.opbase.addresses_taken;
1264 else
1265 return NULL;
1269 /* Set B to be the set of addresses taken by statement G. The
1270 previous set is freed. */
1272 static inline void
1273 gimple_set_addresses_taken (gimple g, bitmap b)
1275 gcc_assert (gimple_has_ops (g));
1276 BITMAP_FREE (g->gsops.opbase.addresses_taken);
1277 g->gsops.opbase.addresses_taken = b;
1281 /* Return the set of DEF operands for statement G. */
1283 static inline struct def_optype_d *
1284 gimple_def_ops (const_gimple g)
1286 if (!gimple_has_ops (g))
1287 return NULL;
1288 return g->gsops.opbase.def_ops;
1292 /* Set DEF to be the set of DEF operands for statement G. */
1294 static inline void
1295 gimple_set_def_ops (gimple g, struct def_optype_d *def)
1297 gcc_assert (gimple_has_ops (g));
1298 g->gsops.opbase.def_ops = def;
1302 /* Return the set of USE operands for statement G. */
1304 static inline struct use_optype_d *
1305 gimple_use_ops (const_gimple g)
1307 if (!gimple_has_ops (g))
1308 return NULL;
1309 return g->gsops.opbase.use_ops;
1313 /* Set USE to be the set of USE operands for statement G. */
1315 static inline void
1316 gimple_set_use_ops (gimple g, struct use_optype_d *use)
1318 gcc_assert (gimple_has_ops (g));
1319 g->gsops.opbase.use_ops = use;
1323 /* Return the set of VUSE operands for statement G. */
1325 static inline struct voptype_d *
1326 gimple_vuse_ops (const_gimple g)
1328 if (!gimple_has_mem_ops (g))
1329 return NULL;
1330 return g->gsmem.membase.vuse_ops;
1334 /* Set OPS to be the set of VUSE operands for statement G. */
1336 static inline void
1337 gimple_set_vuse_ops (gimple g, struct voptype_d *ops)
1339 gcc_assert (gimple_has_mem_ops (g));
1340 g->gsmem.membase.vuse_ops = ops;
1344 /* Return the set of VDEF operands for statement G. */
1346 static inline struct voptype_d *
1347 gimple_vdef_ops (const_gimple g)
1349 if (!gimple_has_mem_ops (g))
1350 return NULL;
1351 return g->gsmem.membase.vdef_ops;
1355 /* Set OPS to be the set of VDEF operands for statement G. */
1357 static inline void
1358 gimple_set_vdef_ops (gimple g, struct voptype_d *ops)
1360 gcc_assert (gimple_has_mem_ops (g));
1361 g->gsmem.membase.vdef_ops = ops;
1365 /* Return the set of symbols loaded by statement G. Each element of the
1366 set is the DECL_UID of the corresponding symbol. */
1368 static inline bitmap
1369 gimple_loaded_syms (const_gimple g)
1371 if (!gimple_has_mem_ops (g))
1372 return NULL;
1373 return g->gsmem.membase.loads;
1377 /* Return the set of symbols stored by statement G. Each element of
1378 the set is the DECL_UID of the corresponding symbol. */
1380 static inline bitmap
1381 gimple_stored_syms (const_gimple g)
1383 if (!gimple_has_mem_ops (g))
1384 return NULL;
1385 return g->gsmem.membase.stores;
1389 /* Return true if statement G has operands and the modified field has
1390 been set. */
1392 static inline bool
1393 gimple_modified_p (const_gimple g)
1395 return (gimple_has_ops (g)) ? (bool) g->gsbase.modified : false;
1398 /* Return the type of the main expression computed by STMT. Return
1399 void_type_node if the statement computes nothing. */
1401 static inline tree
1402 gimple_expr_type (const_gimple stmt)
1404 enum gimple_code code = gimple_code (stmt);
1406 if (code == GIMPLE_ASSIGN || code == GIMPLE_CALL)
1408 tree type = TREE_TYPE (gimple_get_lhs (stmt));
1409 /* Integral sub-types are never the type of the expression,
1410 but they still can be the type of the result as the base
1411 type (in which expressions are computed) is trivially
1412 convertible to one of its sub-types. So always return
1413 the base type here. */
1414 if (INTEGRAL_TYPE_P (type)
1415 && TREE_TYPE (type)
1416 /* But only if they are trivially convertible. */
1417 && useless_type_conversion_p (type, TREE_TYPE (type)))
1418 type = TREE_TYPE (type);
1419 return type;
1421 else if (code == GIMPLE_COND)
1422 return boolean_type_node;
1423 else
1424 return void_type_node;
1428 /* Return the tree code for the expression computed by STMT. This is
1429 only valid for GIMPLE_COND, GIMPLE_CALL and GIMPLE_ASSIGN. For
1430 GIMPLE_CALL, return CALL_EXPR as the expression code for
1431 consistency. This is useful when the caller needs to deal with the
1432 three kinds of computation that GIMPLE supports. */
1434 static inline enum tree_code
1435 gimple_expr_code (const_gimple stmt)
1437 enum gimple_code code = gimple_code (stmt);
1438 if (code == GIMPLE_ASSIGN || code == GIMPLE_COND)
1439 return (enum tree_code) stmt->gsbase.subcode;
1440 else if (code == GIMPLE_CALL)
1441 return CALL_EXPR;
1442 else
1443 gcc_unreachable ();
1447 /* Mark statement S as modified, and update it. */
1449 static inline void
1450 update_stmt (gimple s)
1452 if (gimple_has_ops (s))
1454 gimple_set_modified (s, true);
1455 update_stmt_operands (s);
1459 /* Update statement S if it has been optimized. */
1461 static inline void
1462 update_stmt_if_modified (gimple s)
1464 if (gimple_modified_p (s))
1465 update_stmt_operands (s);
1468 /* Return true if statement STMT contains volatile operands. */
1470 static inline bool
1471 gimple_has_volatile_ops (const_gimple stmt)
1473 if (gimple_has_mem_ops (stmt))
1474 return stmt->gsbase.has_volatile_ops;
1475 else
1476 return false;
1480 /* Set the HAS_VOLATILE_OPS flag to VOLATILEP. */
1482 static inline void
1483 gimple_set_has_volatile_ops (gimple stmt, bool volatilep)
1485 if (gimple_has_mem_ops (stmt))
1486 stmt->gsbase.has_volatile_ops = (unsigned) volatilep;
1490 /* Return true if statement STMT may access memory. */
1492 static inline bool
1493 gimple_references_memory_p (gimple stmt)
1495 return gimple_has_mem_ops (stmt) && stmt->gsbase.references_memory_p;
1499 /* Set the REFERENCES_MEMORY_P flag for STMT to MEM_P. */
1501 static inline void
1502 gimple_set_references_memory (gimple stmt, bool mem_p)
1504 if (gimple_has_mem_ops (stmt))
1505 stmt->gsbase.references_memory_p = (unsigned) mem_p;
1508 /* Return the subcode for OMP statement S. */
1510 static inline unsigned
1511 gimple_omp_subcode (const_gimple s)
1513 gcc_assert (gimple_code (s) >= GIMPLE_OMP_ATOMIC_LOAD
1514 && gimple_code (s) <= GIMPLE_OMP_SINGLE);
1515 return s->gsbase.subcode;
1518 /* Set the subcode for OMP statement S to SUBCODE. */
1520 static inline void
1521 gimple_omp_set_subcode (gimple s, unsigned int subcode)
1523 /* We only have 16 bits for the subcode. Assert that we are not
1524 overflowing it. */
1525 gcc_assert (subcode < (1 << 16));
1526 s->gsbase.subcode = subcode;
1529 /* Set the nowait flag on OMP_RETURN statement S. */
1531 static inline void
1532 gimple_omp_return_set_nowait (gimple s)
1534 GIMPLE_CHECK (s, GIMPLE_OMP_RETURN);
1535 s->gsbase.subcode |= GF_OMP_RETURN_NOWAIT;
1539 /* Return true if OMP return statement G has the GF_OMP_RETURN_NOWAIT
1540 flag set. */
1542 static inline bool
1543 gimple_omp_return_nowait_p (const_gimple g)
1545 GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
1546 return (gimple_omp_subcode (g) & GF_OMP_RETURN_NOWAIT) != 0;
1550 /* Return true if OMP section statement G has the GF_OMP_SECTION_LAST
1551 flag set. */
1553 static inline bool
1554 gimple_omp_section_last_p (const_gimple g)
1556 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1557 return (gimple_omp_subcode (g) & GF_OMP_SECTION_LAST) != 0;
1561 /* Set the GF_OMP_SECTION_LAST flag on G. */
1563 static inline void
1564 gimple_omp_section_set_last (gimple g)
1566 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1567 g->gsbase.subcode |= GF_OMP_SECTION_LAST;
1571 /* Return true if OMP parallel statement G has the
1572 GF_OMP_PARALLEL_COMBINED flag set. */
1574 static inline bool
1575 gimple_omp_parallel_combined_p (const_gimple g)
1577 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1578 return (gimple_omp_subcode (g) & GF_OMP_PARALLEL_COMBINED) != 0;
1582 /* Set the GF_OMP_PARALLEL_COMBINED field in G depending on the boolean
1583 value of COMBINED_P. */
1585 static inline void
1586 gimple_omp_parallel_set_combined_p (gimple g, bool combined_p)
1588 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1589 if (combined_p)
1590 g->gsbase.subcode |= GF_OMP_PARALLEL_COMBINED;
1591 else
1592 g->gsbase.subcode &= ~GF_OMP_PARALLEL_COMBINED;
1596 /* Return the number of operands for statement GS. */
1598 static inline unsigned
1599 gimple_num_ops (const_gimple gs)
1601 return gs->gsbase.num_ops;
1605 /* Set the number of operands for statement GS. */
1607 static inline void
1608 gimple_set_num_ops (gimple gs, unsigned num_ops)
1610 gs->gsbase.num_ops = num_ops;
1614 /* Return the array of operands for statement GS. */
1616 static inline tree *
1617 gimple_ops (gimple gs)
1619 /* Offset in bytes to the location of the operand vector in every
1620 tuple structure. Defined in gimple.c */
1621 extern size_t const gimple_ops_offset_[];
1623 if (!gimple_has_ops (gs))
1624 return NULL;
1626 /* All the tuples have their operand vector at the very bottom
1627 of the structure. */
1628 return ((tree *) ((char *) gs + gimple_ops_offset_[gimple_code (gs)]));
1632 /* Return operand I for statement GS. */
1634 static inline tree
1635 gimple_op (const_gimple gs, unsigned i)
1637 if (gimple_has_ops (gs))
1639 gcc_assert (i < gimple_num_ops (gs));
1640 return gimple_ops (CONST_CAST_GIMPLE (gs))[i];
1642 else
1643 return NULL_TREE;
1646 /* Return a pointer to operand I for statement GS. */
1648 static inline tree *
1649 gimple_op_ptr (const_gimple gs, unsigned i)
1651 if (gimple_has_ops (gs))
1653 gcc_assert (i < gimple_num_ops (gs));
1654 return gimple_ops (CONST_CAST_GIMPLE (gs)) + i;
1656 else
1657 return NULL;
1660 /* Set operand I of statement GS to OP. */
1662 static inline void
1663 gimple_set_op (gimple gs, unsigned i, tree op)
1665 gcc_assert (gimple_has_ops (gs) && i < gimple_num_ops (gs));
1667 /* Note. It may be tempting to assert that OP matches
1668 is_gimple_operand, but that would be wrong. Different tuples
1669 accept slightly different sets of tree operands. Each caller
1670 should perform its own validation. */
1671 gimple_ops (gs)[i] = op;
1674 /* Return true if GS is a GIMPLE_ASSIGN. */
1676 static inline bool
1677 is_gimple_assign (const_gimple gs)
1679 return gimple_code (gs) == GIMPLE_ASSIGN;
1682 /* Determine if expression CODE is one of the valid expressions that can
1683 be used on the RHS of GIMPLE assignments. */
1685 static inline enum gimple_rhs_class
1686 get_gimple_rhs_class (enum tree_code code)
1688 return (enum gimple_rhs_class) gimple_rhs_class_table[(int) code];
1691 /* Return the LHS of assignment statement GS. */
1693 static inline tree
1694 gimple_assign_lhs (const_gimple gs)
1696 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1697 return gimple_op (gs, 0);
1701 /* Return a pointer to the LHS of assignment statement GS. */
1703 static inline tree *
1704 gimple_assign_lhs_ptr (const_gimple gs)
1706 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1707 return gimple_op_ptr (gs, 0);
1711 /* Set LHS to be the LHS operand of assignment statement GS. */
1713 static inline void
1714 gimple_assign_set_lhs (gimple gs, tree lhs)
1716 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1717 gcc_assert (is_gimple_operand (lhs));
1718 gimple_set_op (gs, 0, lhs);
1720 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1721 SSA_NAME_DEF_STMT (lhs) = gs;
1725 /* Return the first operand on the RHS of assignment statement GS. */
1727 static inline tree
1728 gimple_assign_rhs1 (const_gimple gs)
1730 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1731 return gimple_op (gs, 1);
1735 /* Return a pointer to the first operand on the RHS of assignment
1736 statement GS. */
1738 static inline tree *
1739 gimple_assign_rhs1_ptr (const_gimple gs)
1741 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1742 return gimple_op_ptr (gs, 1);
1745 /* Set RHS to be the first operand on the RHS of assignment statement GS. */
1747 static inline void
1748 gimple_assign_set_rhs1 (gimple gs, tree rhs)
1750 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1752 /* If there are 3 or more operands, the 2 operands on the RHS must be
1753 GIMPLE values. */
1754 if (gimple_num_ops (gs) >= 3)
1755 gcc_assert (is_gimple_val (rhs));
1756 else
1757 gcc_assert (is_gimple_operand (rhs));
1759 gimple_set_op (gs, 1, rhs);
1763 /* Return the second operand on the RHS of assignment statement GS.
1764 If GS does not have two operands, NULL is returned instead. */
1766 static inline tree
1767 gimple_assign_rhs2 (const_gimple gs)
1769 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1771 if (gimple_num_ops (gs) >= 3)
1772 return gimple_op (gs, 2);
1773 else
1774 return NULL_TREE;
1778 /* Return a pointer to the second operand on the RHS of assignment
1779 statement GS. */
1781 static inline tree *
1782 gimple_assign_rhs2_ptr (const_gimple gs)
1784 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1785 return gimple_op_ptr (gs, 2);
1789 /* Set RHS to be the second operand on the RHS of assignment statement GS. */
1791 static inline void
1792 gimple_assign_set_rhs2 (gimple gs, tree rhs)
1794 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1796 /* The 2 operands on the RHS must be GIMPLE values. */
1797 gcc_assert (is_gimple_val (rhs));
1799 gimple_set_op (gs, 2, rhs);
1802 /* Returns true if GS is a nontemporal move. */
1804 static inline bool
1805 gimple_assign_nontemporal_move_p (const_gimple gs)
1807 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1808 return gs->gsbase.nontemporal_move;
1811 /* Sets nontemporal move flag of GS to NONTEMPORAL. */
1813 static inline void
1814 gimple_assign_set_nontemporal_move (gimple gs, bool nontemporal)
1816 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1817 gs->gsbase.nontemporal_move = nontemporal;
1821 /* Return the code of the expression computed on the rhs of assignment
1822 statement GS. In case that the RHS is a single object, returns the
1823 tree code of the object. */
1825 static inline enum tree_code
1826 gimple_assign_rhs_code (const_gimple gs)
1828 enum tree_code code;
1829 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1831 code = gimple_expr_code (gs);
1832 if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS)
1833 code = TREE_CODE (gimple_assign_rhs1 (gs));
1835 return code;
1839 /* Set CODE to be the code for the expression computed on the RHS of
1840 assignment S. */
1842 static inline void
1843 gimple_assign_set_rhs_code (gimple s, enum tree_code code)
1845 GIMPLE_CHECK (s, GIMPLE_ASSIGN);
1846 s->gsbase.subcode = code;
1850 /* Return the gimple rhs class of the code of the expression computed on
1851 the rhs of assignment statement GS.
1852 This will never return GIMPLE_INVALID_RHS. */
1854 static inline enum gimple_rhs_class
1855 gimple_assign_rhs_class (const_gimple gs)
1857 return get_gimple_rhs_class (gimple_assign_rhs_code (gs));
1861 /* Return true if S is a type-cast assignment. */
1863 static inline bool
1864 gimple_assign_cast_p (gimple s)
1866 if (is_gimple_assign (s))
1868 enum tree_code sc = gimple_assign_rhs_code (s);
1869 return CONVERT_EXPR_CODE_P (sc)
1870 || sc == VIEW_CONVERT_EXPR
1871 || sc == FIX_TRUNC_EXPR;
1874 return false;
1878 /* Return true if GS is a GIMPLE_CALL. */
1880 static inline bool
1881 is_gimple_call (const_gimple gs)
1883 return gimple_code (gs) == GIMPLE_CALL;
1886 /* Return the LHS of call statement GS. */
1888 static inline tree
1889 gimple_call_lhs (const_gimple gs)
1891 GIMPLE_CHECK (gs, GIMPLE_CALL);
1892 return gimple_op (gs, 0);
1896 /* Return a pointer to the LHS of call statement GS. */
1898 static inline tree *
1899 gimple_call_lhs_ptr (const_gimple gs)
1901 GIMPLE_CHECK (gs, GIMPLE_CALL);
1902 return gimple_op_ptr (gs, 0);
1906 /* Set LHS to be the LHS operand of call statement GS. */
1908 static inline void
1909 gimple_call_set_lhs (gimple gs, tree lhs)
1911 GIMPLE_CHECK (gs, GIMPLE_CALL);
1912 gcc_assert (!lhs || is_gimple_operand (lhs));
1913 gimple_set_op (gs, 0, lhs);
1914 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1915 SSA_NAME_DEF_STMT (lhs) = gs;
1919 /* Return the tree node representing the function called by call
1920 statement GS. */
1922 static inline tree
1923 gimple_call_fn (const_gimple gs)
1925 GIMPLE_CHECK (gs, GIMPLE_CALL);
1926 return gimple_op (gs, 1);
1930 /* Return a pointer to the tree node representing the function called by call
1931 statement GS. */
1933 static inline tree *
1934 gimple_call_fn_ptr (const_gimple gs)
1936 GIMPLE_CHECK (gs, GIMPLE_CALL);
1937 return gimple_op_ptr (gs, 1);
1941 /* Set FN to be the function called by call statement GS. */
1943 static inline void
1944 gimple_call_set_fn (gimple gs, tree fn)
1946 GIMPLE_CHECK (gs, GIMPLE_CALL);
1947 gcc_assert (is_gimple_operand (fn));
1948 gimple_set_op (gs, 1, fn);
1952 /* Set FNDECL to be the function called by call statement GS. */
1954 static inline void
1955 gimple_call_set_fndecl (gimple gs, tree decl)
1957 GIMPLE_CHECK (gs, GIMPLE_CALL);
1958 gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
1959 gimple_set_op (gs, 1, build_fold_addr_expr (decl));
1963 /* If a given GIMPLE_CALL's callee is a FUNCTION_DECL, return it.
1964 Otherwise return NULL. This function is analogous to
1965 get_callee_fndecl in tree land. */
1967 static inline tree
1968 gimple_call_fndecl (const_gimple gs)
1970 tree addr = gimple_call_fn (gs);
1971 if (TREE_CODE (addr) == ADDR_EXPR)
1973 gcc_assert (TREE_CODE (TREE_OPERAND (addr, 0)) == FUNCTION_DECL);
1974 return TREE_OPERAND (addr, 0);
1976 return NULL_TREE;
1980 /* Return the type returned by call statement GS. */
1982 static inline tree
1983 gimple_call_return_type (const_gimple gs)
1985 tree fn = gimple_call_fn (gs);
1986 tree type = TREE_TYPE (fn);
1988 /* See through the pointer. */
1989 gcc_assert (POINTER_TYPE_P (type));
1990 type = TREE_TYPE (type);
1992 gcc_assert (TREE_CODE (type) == FUNCTION_TYPE
1993 || TREE_CODE (type) == METHOD_TYPE);
1995 /* The type returned by a FUNCTION_DECL is the type of its
1996 function type. */
1997 return TREE_TYPE (type);
2001 /* Return the static chain for call statement GS. */
2003 static inline tree
2004 gimple_call_chain (const_gimple gs)
2006 GIMPLE_CHECK (gs, GIMPLE_CALL);
2007 return gimple_op (gs, 2);
2011 /* Return a pointer to the static chain for call statement GS. */
2013 static inline tree *
2014 gimple_call_chain_ptr (const_gimple gs)
2016 GIMPLE_CHECK (gs, GIMPLE_CALL);
2017 return gimple_op_ptr (gs, 2);
2020 /* Set CHAIN to be the static chain for call statement GS. */
2022 static inline void
2023 gimple_call_set_chain (gimple gs, tree chain)
2025 GIMPLE_CHECK (gs, GIMPLE_CALL);
2026 gcc_assert (chain == NULL
2027 || TREE_CODE (chain) == ADDR_EXPR
2028 || SSA_VAR_P (chain));
2029 gimple_set_op (gs, 2, chain);
2033 /* Return the number of arguments used by call statement GS. */
2035 static inline unsigned
2036 gimple_call_num_args (const_gimple gs)
2038 unsigned num_ops;
2039 GIMPLE_CHECK (gs, GIMPLE_CALL);
2040 num_ops = gimple_num_ops (gs);
2041 gcc_assert (num_ops >= 3);
2042 return num_ops - 3;
2046 /* Return the argument at position INDEX for call statement GS. */
2048 static inline tree
2049 gimple_call_arg (const_gimple gs, unsigned index)
2051 GIMPLE_CHECK (gs, GIMPLE_CALL);
2052 return gimple_op (gs, index + 3);
2056 /* Return a pointer to the argument at position INDEX for call
2057 statement GS. */
2059 static inline tree *
2060 gimple_call_arg_ptr (const_gimple gs, unsigned index)
2062 GIMPLE_CHECK (gs, GIMPLE_CALL);
2063 return gimple_op_ptr (gs, index + 3);
2067 /* Set ARG to be the argument at position INDEX for call statement GS. */
2069 static inline void
2070 gimple_call_set_arg (gimple gs, unsigned index, tree arg)
2072 GIMPLE_CHECK (gs, GIMPLE_CALL);
2073 gcc_assert (is_gimple_operand (arg));
2074 gimple_set_op (gs, index + 3, arg);
2078 /* If TAIL_P is true, mark call statement S as being a tail call
2079 (i.e., a call just before the exit of a function). These calls are
2080 candidate for tail call optimization. */
2082 static inline void
2083 gimple_call_set_tail (gimple s, bool tail_p)
2085 GIMPLE_CHECK (s, GIMPLE_CALL);
2086 if (tail_p)
2087 s->gsbase.subcode |= GF_CALL_TAILCALL;
2088 else
2089 s->gsbase.subcode &= ~GF_CALL_TAILCALL;
2093 /* Return true if GIMPLE_CALL S is marked as a tail call. */
2095 static inline bool
2096 gimple_call_tail_p (gimple s)
2098 GIMPLE_CHECK (s, GIMPLE_CALL);
2099 return (s->gsbase.subcode & GF_CALL_TAILCALL) != 0;
2103 /* Set the inlinable status of GIMPLE_CALL S to INLINABLE_P. */
2105 static inline void
2106 gimple_call_set_cannot_inline (gimple s, bool inlinable_p)
2108 GIMPLE_CHECK (s, GIMPLE_CALL);
2109 if (inlinable_p)
2110 s->gsbase.subcode |= GF_CALL_CANNOT_INLINE;
2111 else
2112 s->gsbase.subcode &= ~GF_CALL_CANNOT_INLINE;
2116 /* Return true if GIMPLE_CALL S cannot be inlined. */
2118 static inline bool
2119 gimple_call_cannot_inline_p (gimple s)
2121 GIMPLE_CHECK (s, GIMPLE_CALL);
2122 return (s->gsbase.subcode & GF_CALL_CANNOT_INLINE) != 0;
2126 /* If RETURN_SLOT_OPT_P is true mark GIMPLE_CALL S as valid for return
2127 slot optimization. This transformation uses the target of the call
2128 expansion as the return slot for calls that return in memory. */
2130 static inline void
2131 gimple_call_set_return_slot_opt (gimple s, bool return_slot_opt_p)
2133 GIMPLE_CHECK (s, GIMPLE_CALL);
2134 if (return_slot_opt_p)
2135 s->gsbase.subcode |= GF_CALL_RETURN_SLOT_OPT;
2136 else
2137 s->gsbase.subcode &= ~GF_CALL_RETURN_SLOT_OPT;
2141 /* Return true if S is marked for return slot optimization. */
2143 static inline bool
2144 gimple_call_return_slot_opt_p (gimple s)
2146 GIMPLE_CHECK (s, GIMPLE_CALL);
2147 return (s->gsbase.subcode & GF_CALL_RETURN_SLOT_OPT) != 0;
2151 /* If FROM_THUNK_P is true, mark GIMPLE_CALL S as being the jump from a
2152 thunk to the thunked-to function. */
2154 static inline void
2155 gimple_call_set_from_thunk (gimple s, bool from_thunk_p)
2157 GIMPLE_CHECK (s, GIMPLE_CALL);
2158 if (from_thunk_p)
2159 s->gsbase.subcode |= GF_CALL_FROM_THUNK;
2160 else
2161 s->gsbase.subcode &= ~GF_CALL_FROM_THUNK;
2165 /* Return true if GIMPLE_CALL S is a jump from a thunk. */
2167 static inline bool
2168 gimple_call_from_thunk_p (gimple s)
2170 GIMPLE_CHECK (s, GIMPLE_CALL);
2171 return (s->gsbase.subcode & GF_CALL_FROM_THUNK) != 0;
2175 /* If PASS_ARG_PACK_P is true, GIMPLE_CALL S is a stdarg call that needs the
2176 argument pack in its argument list. */
2178 static inline void
2179 gimple_call_set_va_arg_pack (gimple s, bool pass_arg_pack_p)
2181 GIMPLE_CHECK (s, GIMPLE_CALL);
2182 if (pass_arg_pack_p)
2183 s->gsbase.subcode |= GF_CALL_VA_ARG_PACK;
2184 else
2185 s->gsbase.subcode &= ~GF_CALL_VA_ARG_PACK;
2189 /* Return true if GIMPLE_CALL S is a stdarg call that needs the
2190 argument pack in its argument list. */
2192 static inline bool
2193 gimple_call_va_arg_pack_p (gimple s)
2195 GIMPLE_CHECK (s, GIMPLE_CALL);
2196 return (s->gsbase.subcode & GF_CALL_VA_ARG_PACK) != 0;
2200 /* Return true if S is a noreturn call. */
2202 static inline bool
2203 gimple_call_noreturn_p (gimple s)
2205 GIMPLE_CHECK (s, GIMPLE_CALL);
2206 return (gimple_call_flags (s) & ECF_NORETURN) != 0;
2210 /* Return true if S is a nothrow call. */
2212 static inline bool
2213 gimple_call_nothrow_p (gimple s)
2215 GIMPLE_CHECK (s, GIMPLE_CALL);
2216 return (gimple_call_flags (s) & ECF_NOTHROW) != 0;
2220 /* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL. */
2222 static inline void
2223 gimple_call_copy_flags (gimple dest_call, gimple orig_call)
2225 GIMPLE_CHECK (dest_call, GIMPLE_CALL);
2226 GIMPLE_CHECK (orig_call, GIMPLE_CALL);
2227 dest_call->gsbase.subcode = orig_call->gsbase.subcode;
2231 /* Returns true if this is a GIMPLE_ASSIGN or a GIMPLE_CALL with a
2232 non-NULL lhs. */
2234 static inline bool
2235 gimple_has_lhs (gimple stmt)
2237 return (is_gimple_assign (stmt)
2238 || (is_gimple_call (stmt)
2239 && gimple_call_lhs (stmt) != NULL_TREE));
2243 /* Return the code of the predicate computed by conditional statement GS. */
2245 static inline enum tree_code
2246 gimple_cond_code (const_gimple gs)
2248 GIMPLE_CHECK (gs, GIMPLE_COND);
2249 return gs->gsbase.subcode;
2253 /* Set CODE to be the predicate code for the conditional statement GS. */
2255 static inline void
2256 gimple_cond_set_code (gimple gs, enum tree_code code)
2258 GIMPLE_CHECK (gs, GIMPLE_COND);
2259 gcc_assert (TREE_CODE_CLASS (code) == tcc_comparison);
2260 gs->gsbase.subcode = code;
2264 /* Return the LHS of the predicate computed by conditional statement GS. */
2266 static inline tree
2267 gimple_cond_lhs (const_gimple gs)
2269 GIMPLE_CHECK (gs, GIMPLE_COND);
2270 return gimple_op (gs, 0);
2273 /* Return the pointer to the LHS of the predicate computed by conditional
2274 statement GS. */
2276 static inline tree *
2277 gimple_cond_lhs_ptr (const_gimple gs)
2279 GIMPLE_CHECK (gs, GIMPLE_COND);
2280 return gimple_op_ptr (gs, 0);
2283 /* Set LHS to be the LHS operand of the predicate computed by
2284 conditional statement GS. */
2286 static inline void
2287 gimple_cond_set_lhs (gimple gs, tree lhs)
2289 GIMPLE_CHECK (gs, GIMPLE_COND);
2290 gcc_assert (is_gimple_operand (lhs));
2291 gimple_set_op (gs, 0, lhs);
2295 /* Return the RHS operand of the predicate computed by conditional GS. */
2297 static inline tree
2298 gimple_cond_rhs (const_gimple gs)
2300 GIMPLE_CHECK (gs, GIMPLE_COND);
2301 return gimple_op (gs, 1);
2304 /* Return the pointer to the RHS operand of the predicate computed by
2305 conditional GS. */
2307 static inline tree *
2308 gimple_cond_rhs_ptr (const_gimple gs)
2310 GIMPLE_CHECK (gs, GIMPLE_COND);
2311 return gimple_op_ptr (gs, 1);
2315 /* Set RHS to be the RHS operand of the predicate computed by
2316 conditional statement GS. */
2318 static inline void
2319 gimple_cond_set_rhs (gimple gs, tree rhs)
2321 GIMPLE_CHECK (gs, GIMPLE_COND);
2322 gcc_assert (is_gimple_operand (rhs));
2323 gimple_set_op (gs, 1, rhs);
2327 /* Return the label used by conditional statement GS when its
2328 predicate evaluates to true. */
2330 static inline tree
2331 gimple_cond_true_label (const_gimple gs)
2333 GIMPLE_CHECK (gs, GIMPLE_COND);
2334 return gimple_op (gs, 2);
2338 /* Set LABEL to be the label used by conditional statement GS when its
2339 predicate evaluates to true. */
2341 static inline void
2342 gimple_cond_set_true_label (gimple gs, tree label)
2344 GIMPLE_CHECK (gs, GIMPLE_COND);
2345 gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
2346 gimple_set_op (gs, 2, label);
2350 /* Set LABEL to be the label used by conditional statement GS when its
2351 predicate evaluates to false. */
2353 static inline void
2354 gimple_cond_set_false_label (gimple gs, tree label)
2356 GIMPLE_CHECK (gs, GIMPLE_COND);
2357 gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
2358 gimple_set_op (gs, 3, label);
2362 /* Return the label used by conditional statement GS when its
2363 predicate evaluates to false. */
2365 static inline tree
2366 gimple_cond_false_label (const_gimple gs)
2368 GIMPLE_CHECK (gs, GIMPLE_COND);
2369 return gimple_op (gs, 3);
2373 /* Set the conditional COND_STMT to be of the form 'if (1 == 0)'. */
2375 static inline void
2376 gimple_cond_make_false (gimple gs)
2378 gimple_cond_set_lhs (gs, boolean_true_node);
2379 gimple_cond_set_rhs (gs, boolean_false_node);
2380 gs->gsbase.subcode = EQ_EXPR;
2384 /* Set the conditional COND_STMT to be of the form 'if (1 == 1)'. */
2386 static inline void
2387 gimple_cond_make_true (gimple gs)
2389 gimple_cond_set_lhs (gs, boolean_true_node);
2390 gimple_cond_set_rhs (gs, boolean_true_node);
2391 gs->gsbase.subcode = EQ_EXPR;
2394 /* Check if conditional statemente GS is of the form 'if (1 == 1)',
2395 'if (0 == 0)', 'if (1 != 0)' or 'if (0 != 1)' */
2397 static inline bool
2398 gimple_cond_true_p (const_gimple gs)
2400 tree lhs = gimple_cond_lhs (gs);
2401 tree rhs = gimple_cond_rhs (gs);
2402 enum tree_code code = gimple_cond_code (gs);
2404 if (lhs != boolean_true_node && lhs != boolean_false_node)
2405 return false;
2407 if (rhs != boolean_true_node && rhs != boolean_false_node)
2408 return false;
2410 if (code == NE_EXPR && lhs != rhs)
2411 return true;
2413 if (code == EQ_EXPR && lhs == rhs)
2414 return true;
2416 return false;
2419 /* Check if conditional statement GS is of the form 'if (1 != 1)',
2420 'if (0 != 0)', 'if (1 == 0)' or 'if (0 == 1)' */
2422 static inline bool
2423 gimple_cond_false_p (const_gimple gs)
2425 tree lhs = gimple_cond_lhs (gs);
2426 tree rhs = gimple_cond_rhs (gs);
2427 enum tree_code code = gimple_cond_code (gs);
2429 if (lhs != boolean_true_node && lhs != boolean_false_node)
2430 return false;
2432 if (rhs != boolean_true_node && rhs != boolean_false_node)
2433 return false;
2435 if (code == NE_EXPR && lhs == rhs)
2436 return true;
2438 if (code == EQ_EXPR && lhs != rhs)
2439 return true;
2441 return false;
2444 /* Check if conditional statement GS is of the form 'if (var != 0)' or
2445 'if (var == 1)' */
2447 static inline bool
2448 gimple_cond_single_var_p (gimple gs)
2450 if (gimple_cond_code (gs) == NE_EXPR
2451 && gimple_cond_rhs (gs) == boolean_false_node)
2452 return true;
2454 if (gimple_cond_code (gs) == EQ_EXPR
2455 && gimple_cond_rhs (gs) == boolean_true_node)
2456 return true;
2458 return false;
2461 /* Set the code, LHS and RHS of GIMPLE_COND STMT from CODE, LHS and RHS. */
2463 static inline void
2464 gimple_cond_set_condition (gimple stmt, enum tree_code code, tree lhs, tree rhs)
2466 gimple_cond_set_code (stmt, code);
2467 gimple_cond_set_lhs (stmt, lhs);
2468 gimple_cond_set_rhs (stmt, rhs);
2471 /* Return the LABEL_DECL node used by GIMPLE_LABEL statement GS. */
2473 static inline tree
2474 gimple_label_label (const_gimple gs)
2476 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2477 return gimple_op (gs, 0);
2481 /* Set LABEL to be the LABEL_DECL node used by GIMPLE_LABEL statement
2482 GS. */
2484 static inline void
2485 gimple_label_set_label (gimple gs, tree label)
2487 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2488 gcc_assert (TREE_CODE (label) == LABEL_DECL);
2489 gimple_set_op (gs, 0, label);
2493 /* Return the destination of the unconditional jump GS. */
2495 static inline tree
2496 gimple_goto_dest (const_gimple gs)
2498 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2499 return gimple_op (gs, 0);
2503 /* Set DEST to be the destination of the unconditonal jump GS. */
2505 static inline void
2506 gimple_goto_set_dest (gimple gs, tree dest)
2508 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2509 gcc_assert (is_gimple_operand (dest));
2510 gimple_set_op (gs, 0, dest);
2514 /* Return the variables declared in the GIMPLE_BIND statement GS. */
2516 static inline tree
2517 gimple_bind_vars (const_gimple gs)
2519 GIMPLE_CHECK (gs, GIMPLE_BIND);
2520 return gs->gimple_bind.vars;
2524 /* Set VARS to be the set of variables declared in the GIMPLE_BIND
2525 statement GS. */
2527 static inline void
2528 gimple_bind_set_vars (gimple gs, tree vars)
2530 GIMPLE_CHECK (gs, GIMPLE_BIND);
2531 gs->gimple_bind.vars = vars;
2535 /* Append VARS to the set of variables declared in the GIMPLE_BIND
2536 statement GS. */
2538 static inline void
2539 gimple_bind_append_vars (gimple gs, tree vars)
2541 GIMPLE_CHECK (gs, GIMPLE_BIND);
2542 gs->gimple_bind.vars = chainon (gs->gimple_bind.vars, vars);
2546 /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS. */
2548 static inline gimple_seq
2549 gimple_bind_body (gimple gs)
2551 GIMPLE_CHECK (gs, GIMPLE_BIND);
2552 return gs->gimple_bind.body;
2556 /* Set SEQ to be the GIMPLE sequence contained in the GIMPLE_BIND
2557 statement GS. */
2559 static inline void
2560 gimple_bind_set_body (gimple gs, gimple_seq seq)
2562 GIMPLE_CHECK (gs, GIMPLE_BIND);
2563 gs->gimple_bind.body = seq;
2567 /* Append a statement to the end of a GIMPLE_BIND's body. */
2569 static inline void
2570 gimple_bind_add_stmt (gimple gs, gimple stmt)
2572 GIMPLE_CHECK (gs, GIMPLE_BIND);
2573 gimple_seq_add_stmt (&gs->gimple_bind.body, stmt);
2577 /* Append a sequence of statements to the end of a GIMPLE_BIND's body. */
2579 static inline void
2580 gimple_bind_add_seq (gimple gs, gimple_seq seq)
2582 GIMPLE_CHECK (gs, GIMPLE_BIND);
2583 gimple_seq_add_seq (&gs->gimple_bind.body, seq);
2587 /* Return the TREE_BLOCK node associated with GIMPLE_BIND statement
2588 GS. This is analogous to the BIND_EXPR_BLOCK field in trees. */
2590 static inline tree
2591 gimple_bind_block (const_gimple gs)
2593 GIMPLE_CHECK (gs, GIMPLE_BIND);
2594 return gs->gimple_bind.block;
2598 /* Set BLOCK to be the TREE_BLOCK node associated with GIMPLE_BIND
2599 statement GS. */
2601 static inline void
2602 gimple_bind_set_block (gimple gs, tree block)
2604 GIMPLE_CHECK (gs, GIMPLE_BIND);
2605 gcc_assert (block == NULL_TREE || TREE_CODE (block) == BLOCK);
2606 gs->gimple_bind.block = block;
2610 /* Return the number of input operands for GIMPLE_ASM GS. */
2612 static inline unsigned
2613 gimple_asm_ninputs (const_gimple gs)
2615 GIMPLE_CHECK (gs, GIMPLE_ASM);
2616 return gs->gimple_asm.ni;
2620 /* Return the number of output operands for GIMPLE_ASM GS. */
2622 static inline unsigned
2623 gimple_asm_noutputs (const_gimple gs)
2625 GIMPLE_CHECK (gs, GIMPLE_ASM);
2626 return gs->gimple_asm.no;
2630 /* Return the number of clobber operands for GIMPLE_ASM GS. */
2632 static inline unsigned
2633 gimple_asm_nclobbers (const_gimple gs)
2635 GIMPLE_CHECK (gs, GIMPLE_ASM);
2636 return gs->gimple_asm.nc;
2640 /* Return input operand INDEX of GIMPLE_ASM GS. */
2642 static inline tree
2643 gimple_asm_input_op (const_gimple gs, unsigned index)
2645 GIMPLE_CHECK (gs, GIMPLE_ASM);
2646 gcc_assert (index <= gs->gimple_asm.ni);
2647 return gimple_op (gs, index);
2650 /* Return a pointer to input operand INDEX of GIMPLE_ASM GS. */
2652 static inline tree *
2653 gimple_asm_input_op_ptr (const_gimple gs, unsigned index)
2655 GIMPLE_CHECK (gs, GIMPLE_ASM);
2656 gcc_assert (index <= gs->gimple_asm.ni);
2657 return gimple_op_ptr (gs, index);
2661 /* Set IN_OP to be input operand INDEX in GIMPLE_ASM GS. */
2663 static inline void
2664 gimple_asm_set_input_op (gimple gs, unsigned index, tree in_op)
2666 GIMPLE_CHECK (gs, GIMPLE_ASM);
2667 gcc_assert (index <= gs->gimple_asm.ni);
2668 gcc_assert (TREE_CODE (in_op) == TREE_LIST);
2669 gimple_set_op (gs, index, in_op);
2673 /* Return output operand INDEX of GIMPLE_ASM GS. */
2675 static inline tree
2676 gimple_asm_output_op (const_gimple gs, unsigned index)
2678 GIMPLE_CHECK (gs, GIMPLE_ASM);
2679 gcc_assert (index <= gs->gimple_asm.no);
2680 return gimple_op (gs, index + gs->gimple_asm.ni);
2683 /* Return a pointer to output operand INDEX of GIMPLE_ASM GS. */
2685 static inline tree *
2686 gimple_asm_output_op_ptr (const_gimple gs, unsigned index)
2688 GIMPLE_CHECK (gs, GIMPLE_ASM);
2689 gcc_assert (index <= gs->gimple_asm.no);
2690 return gimple_op_ptr (gs, index + gs->gimple_asm.ni);
2694 /* Set OUT_OP to be output operand INDEX in GIMPLE_ASM GS. */
2696 static inline void
2697 gimple_asm_set_output_op (gimple gs, unsigned index, tree out_op)
2699 GIMPLE_CHECK (gs, GIMPLE_ASM);
2700 gcc_assert (index <= gs->gimple_asm.no);
2701 gcc_assert (TREE_CODE (out_op) == TREE_LIST);
2702 gimple_set_op (gs, index + gs->gimple_asm.ni, out_op);
2706 /* Return clobber operand INDEX of GIMPLE_ASM GS. */
2708 static inline tree
2709 gimple_asm_clobber_op (const_gimple gs, unsigned index)
2711 GIMPLE_CHECK (gs, GIMPLE_ASM);
2712 gcc_assert (index <= gs->gimple_asm.nc);
2713 return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no);
2717 /* Set CLOBBER_OP to be clobber operand INDEX in GIMPLE_ASM GS. */
2719 static inline void
2720 gimple_asm_set_clobber_op (gimple gs, unsigned index, tree clobber_op)
2722 GIMPLE_CHECK (gs, GIMPLE_ASM);
2723 gcc_assert (index <= gs->gimple_asm.nc);
2724 gcc_assert (TREE_CODE (clobber_op) == TREE_LIST);
2725 gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no, clobber_op);
2729 /* Return the string representing the assembly instruction in
2730 GIMPLE_ASM GS. */
2732 static inline const char *
2733 gimple_asm_string (const_gimple gs)
2735 GIMPLE_CHECK (gs, GIMPLE_ASM);
2736 return gs->gimple_asm.string;
2740 /* Return true if GS is an asm statement marked volatile. */
2742 static inline bool
2743 gimple_asm_volatile_p (const_gimple gs)
2745 GIMPLE_CHECK (gs, GIMPLE_ASM);
2746 return (gs->gsbase.subcode & GF_ASM_VOLATILE) != 0;
2750 /* If VOLATLE_P is true, mark asm statement GS as volatile. */
2752 static inline void
2753 gimple_asm_set_volatile (gimple gs, bool volatile_p)
2755 GIMPLE_CHECK (gs, GIMPLE_ASM);
2756 if (volatile_p)
2757 gs->gsbase.subcode |= GF_ASM_VOLATILE;
2758 else
2759 gs->gsbase.subcode &= ~GF_ASM_VOLATILE;
2763 /* If INPUT_P is true, mark asm GS as an ASM_INPUT. */
2765 static inline void
2766 gimple_asm_set_input (gimple gs, bool input_p)
2768 GIMPLE_CHECK (gs, GIMPLE_ASM);
2769 if (input_p)
2770 gs->gsbase.subcode |= GF_ASM_INPUT;
2771 else
2772 gs->gsbase.subcode &= ~GF_ASM_INPUT;
2776 /* Return true if asm GS is an ASM_INPUT. */
2778 static inline bool
2779 gimple_asm_input_p (const_gimple gs)
2781 GIMPLE_CHECK (gs, GIMPLE_ASM);
2782 return (gs->gsbase.subcode & GF_ASM_INPUT) != 0;
2786 /* Return the types handled by GIMPLE_CATCH statement GS. */
2788 static inline tree
2789 gimple_catch_types (const_gimple gs)
2791 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2792 return gs->gimple_catch.types;
2796 /* Return a pointer to the types handled by GIMPLE_CATCH statement GS. */
2798 static inline tree *
2799 gimple_catch_types_ptr (gimple gs)
2801 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2802 return &gs->gimple_catch.types;
2806 /* Return the GIMPLE sequence representing the body of the handler of
2807 GIMPLE_CATCH statement GS. */
2809 static inline gimple_seq
2810 gimple_catch_handler (gimple gs)
2812 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2813 return gs->gimple_catch.handler;
2817 /* Return a pointer to the GIMPLE sequence representing the body of
2818 the handler of GIMPLE_CATCH statement GS. */
2820 static inline gimple_seq *
2821 gimple_catch_handler_ptr (gimple gs)
2823 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2824 return &gs->gimple_catch.handler;
2828 /* Set T to be the set of types handled by GIMPLE_CATCH GS. */
2830 static inline void
2831 gimple_catch_set_types (gimple gs, tree t)
2833 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2834 gs->gimple_catch.types = t;
2838 /* Set HANDLER to be the body of GIMPLE_CATCH GS. */
2840 static inline void
2841 gimple_catch_set_handler (gimple gs, gimple_seq handler)
2843 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2844 gs->gimple_catch.handler = handler;
2848 /* Return the types handled by GIMPLE_EH_FILTER statement GS. */
2850 static inline tree
2851 gimple_eh_filter_types (const_gimple gs)
2853 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2854 return gs->gimple_eh_filter.types;
2858 /* Return a pointer to the types handled by GIMPLE_EH_FILTER statement
2859 GS. */
2861 static inline tree *
2862 gimple_eh_filter_types_ptr (gimple gs)
2864 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2865 return &gs->gimple_eh_filter.types;
2869 /* Return the sequence of statement to execute when GIMPLE_EH_FILTER
2870 statement fails. */
2872 static inline gimple_seq
2873 gimple_eh_filter_failure (gimple gs)
2875 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2876 return gs->gimple_eh_filter.failure;
2880 /* Set TYPES to be the set of types handled by GIMPLE_EH_FILTER GS. */
2882 static inline void
2883 gimple_eh_filter_set_types (gimple gs, tree types)
2885 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2886 gs->gimple_eh_filter.types = types;
2890 /* Set FAILURE to be the sequence of statements to execute on failure
2891 for GIMPLE_EH_FILTER GS. */
2893 static inline void
2894 gimple_eh_filter_set_failure (gimple gs, gimple_seq failure)
2896 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2897 gs->gimple_eh_filter.failure = failure;
2900 /* Return the EH_FILTER_MUST_NOT_THROW flag. */
2902 static inline bool
2904 gimple_eh_filter_must_not_throw (gimple gs)
2906 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2907 return gs->gsbase.subcode != 0;
2910 /* Set the EH_FILTER_MUST_NOT_THROW flag to the value MNTP. */
2912 static inline void
2913 gimple_eh_filter_set_must_not_throw (gimple gs, bool mntp)
2915 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2916 gs->gsbase.subcode = (unsigned int) mntp;
2920 /* GIMPLE_TRY accessors. */
2922 /* Return the kind of try block represented by GIMPLE_TRY GS. This is
2923 either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY. */
2925 static inline enum gimple_try_flags
2926 gimple_try_kind (const_gimple gs)
2928 GIMPLE_CHECK (gs, GIMPLE_TRY);
2929 return (enum gimple_try_flags) (gs->gsbase.subcode & GIMPLE_TRY_KIND);
2933 /* Set the kind of try block represented by GIMPLE_TRY GS. */
2935 static inline void
2936 gimple_try_set_kind (gimple gs, enum gimple_try_flags kind)
2938 GIMPLE_CHECK (gs, GIMPLE_TRY);
2939 gcc_assert (kind == GIMPLE_TRY_CATCH || kind == GIMPLE_TRY_FINALLY);
2940 if (gimple_try_kind (gs) != kind)
2941 gs->gsbase.subcode = (unsigned int) kind;
2945 /* Return the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2947 static inline bool
2948 gimple_try_catch_is_cleanup (const_gimple gs)
2950 gcc_assert (gimple_try_kind (gs) == GIMPLE_TRY_CATCH);
2951 return (gs->gsbase.subcode & GIMPLE_TRY_CATCH_IS_CLEANUP) != 0;
2955 /* Return the sequence of statements used as the body for GIMPLE_TRY GS. */
2957 static inline gimple_seq
2958 gimple_try_eval (gimple gs)
2960 GIMPLE_CHECK (gs, GIMPLE_TRY);
2961 return gs->gimple_try.eval;
2965 /* Return the sequence of statements used as the cleanup body for
2966 GIMPLE_TRY GS. */
2968 static inline gimple_seq
2969 gimple_try_cleanup (gimple gs)
2971 GIMPLE_CHECK (gs, GIMPLE_TRY);
2972 return gs->gimple_try.cleanup;
2976 /* Set the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2978 static inline void
2979 gimple_try_set_catch_is_cleanup (gimple g, bool catch_is_cleanup)
2981 gcc_assert (gimple_try_kind (g) == GIMPLE_TRY_CATCH);
2982 if (catch_is_cleanup)
2983 g->gsbase.subcode |= GIMPLE_TRY_CATCH_IS_CLEANUP;
2984 else
2985 g->gsbase.subcode &= ~GIMPLE_TRY_CATCH_IS_CLEANUP;
2989 /* Set EVAL to be the sequence of statements to use as the body for
2990 GIMPLE_TRY GS. */
2992 static inline void
2993 gimple_try_set_eval (gimple gs, gimple_seq eval)
2995 GIMPLE_CHECK (gs, GIMPLE_TRY);
2996 gs->gimple_try.eval = eval;
3000 /* Set CLEANUP to be the sequence of statements to use as the cleanup
3001 body for GIMPLE_TRY GS. */
3003 static inline void
3004 gimple_try_set_cleanup (gimple gs, gimple_seq cleanup)
3006 GIMPLE_CHECK (gs, GIMPLE_TRY);
3007 gs->gimple_try.cleanup = cleanup;
3011 /* Return the cleanup sequence for cleanup statement GS. */
3013 static inline gimple_seq
3014 gimple_wce_cleanup (gimple gs)
3016 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3017 return gs->gimple_wce.cleanup;
3021 /* Set CLEANUP to be the cleanup sequence for GS. */
3023 static inline void
3024 gimple_wce_set_cleanup (gimple gs, gimple_seq cleanup)
3026 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3027 gs->gimple_wce.cleanup = cleanup;
3031 /* Return the CLEANUP_EH_ONLY flag for a WCE tuple. */
3033 static inline bool
3034 gimple_wce_cleanup_eh_only (const_gimple gs)
3036 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3037 return gs->gsbase.subcode != 0;
3041 /* Set the CLEANUP_EH_ONLY flag for a WCE tuple. */
3043 static inline void
3044 gimple_wce_set_cleanup_eh_only (gimple gs, bool eh_only_p)
3046 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3047 gs->gsbase.subcode = (unsigned int) eh_only_p;
3051 /* Return the maximum number of arguments supported by GIMPLE_PHI GS. */
3053 static inline unsigned
3054 gimple_phi_capacity (const_gimple gs)
3056 GIMPLE_CHECK (gs, GIMPLE_PHI);
3057 return gs->gimple_phi.capacity;
3061 /* Return the number of arguments in GIMPLE_PHI GS. This must always
3062 be exactly the number of incoming edges for the basic block holding
3063 GS. */
3065 static inline unsigned
3066 gimple_phi_num_args (const_gimple gs)
3068 GIMPLE_CHECK (gs, GIMPLE_PHI);
3069 return gs->gimple_phi.nargs;
3073 /* Return the SSA name created by GIMPLE_PHI GS. */
3075 static inline tree
3076 gimple_phi_result (const_gimple gs)
3078 GIMPLE_CHECK (gs, GIMPLE_PHI);
3079 return gs->gimple_phi.result;
3082 /* Return a pointer to the SSA name created by GIMPLE_PHI GS. */
3084 static inline tree *
3085 gimple_phi_result_ptr (gimple gs)
3087 GIMPLE_CHECK (gs, GIMPLE_PHI);
3088 return &gs->gimple_phi.result;
3091 /* Set RESULT to be the SSA name created by GIMPLE_PHI GS. */
3093 static inline void
3094 gimple_phi_set_result (gimple gs, tree result)
3096 GIMPLE_CHECK (gs, GIMPLE_PHI);
3097 gs->gimple_phi.result = result;
3101 /* Return the PHI argument corresponding to incoming edge INDEX for
3102 GIMPLE_PHI GS. */
3104 static inline struct phi_arg_d *
3105 gimple_phi_arg (gimple gs, unsigned index)
3107 GIMPLE_CHECK (gs, GIMPLE_PHI);
3108 gcc_assert (index <= gs->gimple_phi.capacity);
3109 return &(gs->gimple_phi.args[index]);
3112 /* Set PHIARG to be the argument corresponding to incoming edge INDEX
3113 for GIMPLE_PHI GS. */
3115 static inline void
3116 gimple_phi_set_arg (gimple gs, unsigned index, struct phi_arg_d * phiarg)
3118 GIMPLE_CHECK (gs, GIMPLE_PHI);
3119 gcc_assert (index <= gs->gimple_phi.nargs);
3120 memcpy (gs->gimple_phi.args + index, phiarg, sizeof (struct phi_arg_d));
3123 /* Return the region number for GIMPLE_RESX GS. */
3125 static inline int
3126 gimple_resx_region (const_gimple gs)
3128 GIMPLE_CHECK (gs, GIMPLE_RESX);
3129 return gs->gimple_resx.region;
3132 /* Set REGION to be the region number for GIMPLE_RESX GS. */
3134 static inline void
3135 gimple_resx_set_region (gimple gs, int region)
3137 GIMPLE_CHECK (gs, GIMPLE_RESX);
3138 gs->gimple_resx.region = region;
3142 /* Return the number of labels associated with the switch statement GS. */
3144 static inline unsigned
3145 gimple_switch_num_labels (const_gimple gs)
3147 unsigned num_ops;
3148 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3149 num_ops = gimple_num_ops (gs);
3150 gcc_assert (num_ops > 1);
3151 return num_ops - 1;
3155 /* Set NLABELS to be the number of labels for the switch statement GS. */
3157 static inline void
3158 gimple_switch_set_num_labels (gimple g, unsigned nlabels)
3160 GIMPLE_CHECK (g, GIMPLE_SWITCH);
3161 gimple_set_num_ops (g, nlabels + 1);
3165 /* Return the index variable used by the switch statement GS. */
3167 static inline tree
3168 gimple_switch_index (const_gimple gs)
3170 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3171 return gimple_op (gs, 0);
3175 /* Return a pointer to the index variable for the switch statement GS. */
3177 static inline tree *
3178 gimple_switch_index_ptr (const_gimple gs)
3180 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3181 return gimple_op_ptr (gs, 0);
3185 /* Set INDEX to be the index variable for switch statement GS. */
3187 static inline void
3188 gimple_switch_set_index (gimple gs, tree index)
3190 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3191 gcc_assert (SSA_VAR_P (index) || CONSTANT_CLASS_P (index));
3192 gimple_set_op (gs, 0, index);
3196 /* Return the label numbered INDEX. The default label is 0, followed by any
3197 labels in a switch statement. */
3199 static inline tree
3200 gimple_switch_label (const_gimple gs, unsigned index)
3202 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3203 gcc_assert (gimple_num_ops (gs) > index + 1);
3204 return gimple_op (gs, index + 1);
3207 /* Set the label number INDEX to LABEL. 0 is always the default label. */
3209 static inline void
3210 gimple_switch_set_label (gimple gs, unsigned index, tree label)
3212 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3213 gcc_assert (gimple_num_ops (gs) > index + 1);
3214 gcc_assert (label == NULL_TREE || TREE_CODE (label) == CASE_LABEL_EXPR);
3215 gimple_set_op (gs, index + 1, label);
3218 /* Return the default label for a switch statement. */
3220 static inline tree
3221 gimple_switch_default_label (const_gimple gs)
3223 return gimple_switch_label (gs, 0);
3226 /* Set the default label for a switch statement. */
3228 static inline void
3229 gimple_switch_set_default_label (gimple gs, tree label)
3231 gimple_switch_set_label (gs, 0, label);
3235 /* Return the body for the OMP statement GS. */
3237 static inline gimple_seq
3238 gimple_omp_body (gimple gs)
3240 return gs->omp.body;
3243 /* Set BODY to be the body for the OMP statement GS. */
3245 static inline void
3246 gimple_omp_set_body (gimple gs, gimple_seq body)
3248 gs->omp.body = body;
3252 /* Return the name associated with OMP_CRITICAL statement GS. */
3254 static inline tree
3255 gimple_omp_critical_name (const_gimple gs)
3257 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3258 return gs->gimple_omp_critical.name;
3262 /* Return a pointer to the name associated with OMP critical statement GS. */
3264 static inline tree *
3265 gimple_omp_critical_name_ptr (gimple gs)
3267 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3268 return &gs->gimple_omp_critical.name;
3272 /* Set NAME to be the name associated with OMP critical statement GS. */
3274 static inline void
3275 gimple_omp_critical_set_name (gimple gs, tree name)
3277 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3278 gs->gimple_omp_critical.name = name;
3282 /* Return the clauses associated with OMP_FOR GS. */
3284 static inline tree
3285 gimple_omp_for_clauses (const_gimple gs)
3287 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3288 return gs->gimple_omp_for.clauses;
3292 /* Return a pointer to the OMP_FOR GS. */
3294 static inline tree *
3295 gimple_omp_for_clauses_ptr (gimple gs)
3297 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3298 return &gs->gimple_omp_for.clauses;
3302 /* Set CLAUSES to be the list of clauses associated with OMP_FOR GS. */
3304 static inline void
3305 gimple_omp_for_set_clauses (gimple gs, tree clauses)
3307 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3308 gs->gimple_omp_for.clauses = clauses;
3312 /* Get the collapse count of OMP_FOR GS. */
3314 static inline size_t
3315 gimple_omp_for_collapse (gimple gs)
3317 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3318 return gs->gimple_omp_for.collapse;
3322 /* Return the index variable for OMP_FOR GS. */
3324 static inline tree
3325 gimple_omp_for_index (const_gimple gs, size_t i)
3327 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3328 gcc_assert (i < gs->gimple_omp_for.collapse);
3329 return gs->gimple_omp_for.iter[i].index;
3333 /* Return a pointer to the index variable for OMP_FOR GS. */
3335 static inline tree *
3336 gimple_omp_for_index_ptr (gimple gs, size_t i)
3338 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3339 gcc_assert (i < gs->gimple_omp_for.collapse);
3340 return &gs->gimple_omp_for.iter[i].index;
3344 /* Set INDEX to be the index variable for OMP_FOR GS. */
3346 static inline void
3347 gimple_omp_for_set_index (gimple gs, size_t i, tree index)
3349 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3350 gcc_assert (i < gs->gimple_omp_for.collapse);
3351 gs->gimple_omp_for.iter[i].index = index;
3355 /* Return the initial value for OMP_FOR GS. */
3357 static inline tree
3358 gimple_omp_for_initial (const_gimple gs, size_t i)
3360 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3361 gcc_assert (i < gs->gimple_omp_for.collapse);
3362 return gs->gimple_omp_for.iter[i].initial;
3366 /* Return a pointer to the initial value for OMP_FOR GS. */
3368 static inline tree *
3369 gimple_omp_for_initial_ptr (gimple gs, size_t i)
3371 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3372 gcc_assert (i < gs->gimple_omp_for.collapse);
3373 return &gs->gimple_omp_for.iter[i].initial;
3377 /* Set INITIAL to be the initial value for OMP_FOR GS. */
3379 static inline void
3380 gimple_omp_for_set_initial (gimple gs, size_t i, tree initial)
3382 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3383 gcc_assert (i < gs->gimple_omp_for.collapse);
3384 gs->gimple_omp_for.iter[i].initial = initial;
3388 /* Return the final value for OMP_FOR GS. */
3390 static inline tree
3391 gimple_omp_for_final (const_gimple gs, size_t i)
3393 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3394 gcc_assert (i < gs->gimple_omp_for.collapse);
3395 return gs->gimple_omp_for.iter[i].final;
3399 /* Return a pointer to the final value for OMP_FOR GS. */
3401 static inline tree *
3402 gimple_omp_for_final_ptr (gimple gs, size_t i)
3404 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3405 gcc_assert (i < gs->gimple_omp_for.collapse);
3406 return &gs->gimple_omp_for.iter[i].final;
3410 /* Set FINAL to be the final value for OMP_FOR GS. */
3412 static inline void
3413 gimple_omp_for_set_final (gimple gs, size_t i, tree final)
3415 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3416 gcc_assert (i < gs->gimple_omp_for.collapse);
3417 gs->gimple_omp_for.iter[i].final = final;
3421 /* Return the increment value for OMP_FOR GS. */
3423 static inline tree
3424 gimple_omp_for_incr (const_gimple gs, size_t i)
3426 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3427 gcc_assert (i < gs->gimple_omp_for.collapse);
3428 return gs->gimple_omp_for.iter[i].incr;
3432 /* Return a pointer to the increment value for OMP_FOR GS. */
3434 static inline tree *
3435 gimple_omp_for_incr_ptr (gimple gs, size_t i)
3437 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3438 gcc_assert (i < gs->gimple_omp_for.collapse);
3439 return &gs->gimple_omp_for.iter[i].incr;
3443 /* Set INCR to be the increment value for OMP_FOR GS. */
3445 static inline void
3446 gimple_omp_for_set_incr (gimple gs, size_t i, tree incr)
3448 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3449 gcc_assert (i < gs->gimple_omp_for.collapse);
3450 gs->gimple_omp_for.iter[i].incr = incr;
3454 /* Return the sequence of statements to execute before the OMP_FOR
3455 statement GS starts. */
3457 static inline gimple_seq
3458 gimple_omp_for_pre_body (gimple gs)
3460 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3461 return gs->gimple_omp_for.pre_body;
3465 /* Set PRE_BODY to be the sequence of statements to execute before the
3466 OMP_FOR statement GS starts. */
3468 static inline void
3469 gimple_omp_for_set_pre_body (gimple gs, gimple_seq pre_body)
3471 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3472 gs->gimple_omp_for.pre_body = pre_body;
3476 /* Return the clauses associated with OMP_PARALLEL GS. */
3478 static inline tree
3479 gimple_omp_parallel_clauses (const_gimple gs)
3481 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3482 return gs->gimple_omp_parallel.clauses;
3486 /* Return a pointer to the clauses associated with OMP_PARALLEL GS. */
3488 static inline tree *
3489 gimple_omp_parallel_clauses_ptr (gimple gs)
3491 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3492 return &gs->gimple_omp_parallel.clauses;
3496 /* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL
3497 GS. */
3499 static inline void
3500 gimple_omp_parallel_set_clauses (gimple gs, tree clauses)
3502 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3503 gs->gimple_omp_parallel.clauses = clauses;
3507 /* Return the child function used to hold the body of OMP_PARALLEL GS. */
3509 static inline tree
3510 gimple_omp_parallel_child_fn (const_gimple gs)
3512 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3513 return gs->gimple_omp_parallel.child_fn;
3516 /* Return a pointer to the child function used to hold the body of
3517 OMP_PARALLEL GS. */
3519 static inline tree *
3520 gimple_omp_parallel_child_fn_ptr (gimple gs)
3522 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3523 return &gs->gimple_omp_parallel.child_fn;
3527 /* Set CHILD_FN to be the child function for OMP_PARALLEL GS. */
3529 static inline void
3530 gimple_omp_parallel_set_child_fn (gimple gs, tree child_fn)
3532 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3533 gs->gimple_omp_parallel.child_fn = child_fn;
3537 /* Return the artificial argument used to send variables and values
3538 from the parent to the children threads in OMP_PARALLEL GS. */
3540 static inline tree
3541 gimple_omp_parallel_data_arg (const_gimple gs)
3543 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3544 return gs->gimple_omp_parallel.data_arg;
3548 /* Return a pointer to the data argument for OMP_PARALLEL GS. */
3550 static inline tree *
3551 gimple_omp_parallel_data_arg_ptr (gimple gs)
3553 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3554 return &gs->gimple_omp_parallel.data_arg;
3558 /* Set DATA_ARG to be the data argument for OMP_PARALLEL GS. */
3560 static inline void
3561 gimple_omp_parallel_set_data_arg (gimple gs, tree data_arg)
3563 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3564 gs->gimple_omp_parallel.data_arg = data_arg;
3568 /* Return the clauses associated with OMP_TASK GS. */
3570 static inline tree
3571 gimple_omp_task_clauses (const_gimple gs)
3573 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3574 return gs->gimple_omp_parallel.clauses;
3578 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3580 static inline tree *
3581 gimple_omp_task_clauses_ptr (gimple gs)
3583 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3584 return &gs->gimple_omp_parallel.clauses;
3588 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3589 GS. */
3591 static inline void
3592 gimple_omp_task_set_clauses (gimple gs, tree clauses)
3594 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3595 gs->gimple_omp_parallel.clauses = clauses;
3599 /* Return the child function used to hold the body of OMP_TASK GS. */
3601 static inline tree
3602 gimple_omp_task_child_fn (const_gimple gs)
3604 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3605 return gs->gimple_omp_parallel.child_fn;
3608 /* Return a pointer to the child function used to hold the body of
3609 OMP_TASK GS. */
3611 static inline tree *
3612 gimple_omp_task_child_fn_ptr (gimple gs)
3614 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3615 return &gs->gimple_omp_parallel.child_fn;
3619 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3621 static inline void
3622 gimple_omp_task_set_child_fn (gimple gs, tree child_fn)
3624 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3625 gs->gimple_omp_parallel.child_fn = child_fn;
3629 /* Return the artificial argument used to send variables and values
3630 from the parent to the children threads in OMP_TASK GS. */
3632 static inline tree
3633 gimple_omp_task_data_arg (const_gimple gs)
3635 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3636 return gs->gimple_omp_parallel.data_arg;
3640 /* Return a pointer to the data argument for OMP_TASK GS. */
3642 static inline tree *
3643 gimple_omp_task_data_arg_ptr (gimple gs)
3645 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3646 return &gs->gimple_omp_parallel.data_arg;
3650 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3652 static inline void
3653 gimple_omp_task_set_data_arg (gimple gs, tree data_arg)
3655 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3656 gs->gimple_omp_parallel.data_arg = data_arg;
3660 /* Return the clauses associated with OMP_TASK GS. */
3662 static inline tree
3663 gimple_omp_taskreg_clauses (const_gimple gs)
3665 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3666 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3667 return gs->gimple_omp_parallel.clauses;
3671 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3673 static inline tree *
3674 gimple_omp_taskreg_clauses_ptr (gimple gs)
3676 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3677 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3678 return &gs->gimple_omp_parallel.clauses;
3682 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3683 GS. */
3685 static inline void
3686 gimple_omp_taskreg_set_clauses (gimple gs, tree clauses)
3688 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3689 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3690 gs->gimple_omp_parallel.clauses = clauses;
3694 /* Return the child function used to hold the body of OMP_TASK GS. */
3696 static inline tree
3697 gimple_omp_taskreg_child_fn (const_gimple gs)
3699 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3700 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3701 return gs->gimple_omp_parallel.child_fn;
3704 /* Return a pointer to the child function used to hold the body of
3705 OMP_TASK GS. */
3707 static inline tree *
3708 gimple_omp_taskreg_child_fn_ptr (gimple gs)
3710 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3711 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3712 return &gs->gimple_omp_parallel.child_fn;
3716 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3718 static inline void
3719 gimple_omp_taskreg_set_child_fn (gimple gs, tree child_fn)
3721 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3722 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3723 gs->gimple_omp_parallel.child_fn = child_fn;
3727 /* Return the artificial argument used to send variables and values
3728 from the parent to the children threads in OMP_TASK GS. */
3730 static inline tree
3731 gimple_omp_taskreg_data_arg (const_gimple gs)
3733 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3734 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3735 return gs->gimple_omp_parallel.data_arg;
3739 /* Return a pointer to the data argument for OMP_TASK GS. */
3741 static inline tree *
3742 gimple_omp_taskreg_data_arg_ptr (gimple gs)
3744 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3745 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3746 return &gs->gimple_omp_parallel.data_arg;
3750 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3752 static inline void
3753 gimple_omp_taskreg_set_data_arg (gimple gs, tree data_arg)
3755 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3756 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3757 gs->gimple_omp_parallel.data_arg = data_arg;
3761 /* Return the copy function used to hold the body of OMP_TASK GS. */
3763 static inline tree
3764 gimple_omp_task_copy_fn (const_gimple gs)
3766 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3767 return gs->gimple_omp_task.copy_fn;
3770 /* Return a pointer to the copy function used to hold the body of
3771 OMP_TASK GS. */
3773 static inline tree *
3774 gimple_omp_task_copy_fn_ptr (gimple gs)
3776 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3777 return &gs->gimple_omp_task.copy_fn;
3781 /* Set CHILD_FN to be the copy function for OMP_TASK GS. */
3783 static inline void
3784 gimple_omp_task_set_copy_fn (gimple gs, tree copy_fn)
3786 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3787 gs->gimple_omp_task.copy_fn = copy_fn;
3791 /* Return size of the data block in bytes in OMP_TASK GS. */
3793 static inline tree
3794 gimple_omp_task_arg_size (const_gimple gs)
3796 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3797 return gs->gimple_omp_task.arg_size;
3801 /* Return a pointer to the data block size for OMP_TASK GS. */
3803 static inline tree *
3804 gimple_omp_task_arg_size_ptr (gimple gs)
3806 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3807 return &gs->gimple_omp_task.arg_size;
3811 /* Set ARG_SIZE to be the data block size for OMP_TASK GS. */
3813 static inline void
3814 gimple_omp_task_set_arg_size (gimple gs, tree arg_size)
3816 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3817 gs->gimple_omp_task.arg_size = arg_size;
3821 /* Return align of the data block in bytes in OMP_TASK GS. */
3823 static inline tree
3824 gimple_omp_task_arg_align (const_gimple gs)
3826 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3827 return gs->gimple_omp_task.arg_align;
3831 /* Return a pointer to the data block align for OMP_TASK GS. */
3833 static inline tree *
3834 gimple_omp_task_arg_align_ptr (gimple gs)
3836 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3837 return &gs->gimple_omp_task.arg_align;
3841 /* Set ARG_SIZE to be the data block align for OMP_TASK GS. */
3843 static inline void
3844 gimple_omp_task_set_arg_align (gimple gs, tree arg_align)
3846 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3847 gs->gimple_omp_task.arg_align = arg_align;
3851 /* Return the clauses associated with OMP_SINGLE GS. */
3853 static inline tree
3854 gimple_omp_single_clauses (const_gimple gs)
3856 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3857 return gs->gimple_omp_single.clauses;
3861 /* Return a pointer to the clauses associated with OMP_SINGLE GS. */
3863 static inline tree *
3864 gimple_omp_single_clauses_ptr (gimple gs)
3866 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3867 return &gs->gimple_omp_single.clauses;
3871 /* Set CLAUSES to be the clauses associated with OMP_SINGLE GS. */
3873 static inline void
3874 gimple_omp_single_set_clauses (gimple gs, tree clauses)
3876 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3877 gs->gimple_omp_single.clauses = clauses;
3881 /* Return the clauses associated with OMP_SECTIONS GS. */
3883 static inline tree
3884 gimple_omp_sections_clauses (const_gimple gs)
3886 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3887 return gs->gimple_omp_sections.clauses;
3891 /* Return a pointer to the clauses associated with OMP_SECTIONS GS. */
3893 static inline tree *
3894 gimple_omp_sections_clauses_ptr (gimple gs)
3896 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3897 return &gs->gimple_omp_sections.clauses;
3901 /* Set CLAUSES to be the set of clauses associated with OMP_SECTIONS
3902 GS. */
3904 static inline void
3905 gimple_omp_sections_set_clauses (gimple gs, tree clauses)
3907 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3908 gs->gimple_omp_sections.clauses = clauses;
3912 /* Return the control variable associated with the GIMPLE_OMP_SECTIONS
3913 in GS. */
3915 static inline tree
3916 gimple_omp_sections_control (const_gimple gs)
3918 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3919 return gs->gimple_omp_sections.control;
3923 /* Return a pointer to the clauses associated with the GIMPLE_OMP_SECTIONS
3924 GS. */
3926 static inline tree *
3927 gimple_omp_sections_control_ptr (gimple gs)
3929 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3930 return &gs->gimple_omp_sections.control;
3934 /* Set CONTROL to be the set of clauses associated with the
3935 GIMPLE_OMP_SECTIONS in GS. */
3937 static inline void
3938 gimple_omp_sections_set_control (gimple gs, tree control)
3940 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3941 gs->gimple_omp_sections.control = control;
3945 /* Set COND to be the condition code for OMP_FOR GS. */
3947 static inline void
3948 gimple_omp_for_set_cond (gimple gs, size_t i, enum tree_code cond)
3950 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3951 gcc_assert (TREE_CODE_CLASS (cond) == tcc_comparison);
3952 gcc_assert (i < gs->gimple_omp_for.collapse);
3953 gs->gimple_omp_for.iter[i].cond = cond;
3957 /* Return the condition code associated with OMP_FOR GS. */
3959 static inline enum tree_code
3960 gimple_omp_for_cond (const_gimple gs, size_t i)
3962 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3963 gcc_assert (i < gs->gimple_omp_for.collapse);
3964 return gs->gimple_omp_for.iter[i].cond;
3968 /* Set the value being stored in an atomic store. */
3970 static inline void
3971 gimple_omp_atomic_store_set_val (gimple g, tree val)
3973 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3974 g->gimple_omp_atomic_store.val = val;
3978 /* Return the value being stored in an atomic store. */
3980 static inline tree
3981 gimple_omp_atomic_store_val (const_gimple g)
3983 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3984 return g->gimple_omp_atomic_store.val;
3988 /* Return a pointer to the value being stored in an atomic store. */
3990 static inline tree *
3991 gimple_omp_atomic_store_val_ptr (gimple g)
3993 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3994 return &g->gimple_omp_atomic_store.val;
3998 /* Set the LHS of an atomic load. */
4000 static inline void
4001 gimple_omp_atomic_load_set_lhs (gimple g, tree lhs)
4003 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4004 g->gimple_omp_atomic_load.lhs = lhs;
4008 /* Get the LHS of an atomic load. */
4010 static inline tree
4011 gimple_omp_atomic_load_lhs (const_gimple g)
4013 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4014 return g->gimple_omp_atomic_load.lhs;
4018 /* Return a pointer to the LHS of an atomic load. */
4020 static inline tree *
4021 gimple_omp_atomic_load_lhs_ptr (gimple g)
4023 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4024 return &g->gimple_omp_atomic_load.lhs;
4028 /* Set the RHS of an atomic load. */
4030 static inline void
4031 gimple_omp_atomic_load_set_rhs (gimple g, tree rhs)
4033 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4034 g->gimple_omp_atomic_load.rhs = rhs;
4038 /* Get the RHS of an atomic load. */
4040 static inline tree
4041 gimple_omp_atomic_load_rhs (const_gimple g)
4043 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4044 return g->gimple_omp_atomic_load.rhs;
4048 /* Return a pointer to the RHS of an atomic load. */
4050 static inline tree *
4051 gimple_omp_atomic_load_rhs_ptr (gimple g)
4053 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4054 return &g->gimple_omp_atomic_load.rhs;
4058 /* Get the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4060 static inline tree
4061 gimple_omp_continue_control_def (const_gimple g)
4063 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4064 return g->gimple_omp_continue.control_def;
4067 /* The same as above, but return the address. */
4069 static inline tree *
4070 gimple_omp_continue_control_def_ptr (gimple g)
4072 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4073 return &g->gimple_omp_continue.control_def;
4076 /* Set the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4078 static inline void
4079 gimple_omp_continue_set_control_def (gimple g, tree def)
4081 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4082 g->gimple_omp_continue.control_def = def;
4086 /* Get the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4088 static inline tree
4089 gimple_omp_continue_control_use (const_gimple g)
4091 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4092 return g->gimple_omp_continue.control_use;
4096 /* The same as above, but return the address. */
4098 static inline tree *
4099 gimple_omp_continue_control_use_ptr (gimple g)
4101 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4102 return &g->gimple_omp_continue.control_use;
4106 /* Set the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4108 static inline void
4109 gimple_omp_continue_set_control_use (gimple g, tree use)
4111 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4112 g->gimple_omp_continue.control_use = use;
4116 /* Return a pointer to the return value for GIMPLE_RETURN GS. */
4118 static inline tree *
4119 gimple_return_retval_ptr (const_gimple gs)
4121 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4122 gcc_assert (gimple_num_ops (gs) == 1);
4123 return gimple_op_ptr (gs, 0);
4126 /* Return the return value for GIMPLE_RETURN GS. */
4128 static inline tree
4129 gimple_return_retval (const_gimple gs)
4131 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4132 gcc_assert (gimple_num_ops (gs) == 1);
4133 return gimple_op (gs, 0);
4137 /* Set RETVAL to be the return value for GIMPLE_RETURN GS. */
4139 static inline void
4140 gimple_return_set_retval (gimple gs, tree retval)
4142 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4143 gcc_assert (gimple_num_ops (gs) == 1);
4144 gcc_assert (retval == NULL_TREE
4145 || TREE_CODE (retval) == RESULT_DECL
4146 || is_gimple_val (retval));
4147 gimple_set_op (gs, 0, retval);
4151 /* Returns true when the gimple statment STMT is any of the OpenMP types. */
4153 static inline bool
4154 is_gimple_omp (const_gimple stmt)
4156 return (gimple_code (stmt) == GIMPLE_OMP_PARALLEL
4157 || gimple_code (stmt) == GIMPLE_OMP_TASK
4158 || gimple_code (stmt) == GIMPLE_OMP_FOR
4159 || gimple_code (stmt) == GIMPLE_OMP_SECTIONS
4160 || gimple_code (stmt) == GIMPLE_OMP_SECTIONS_SWITCH
4161 || gimple_code (stmt) == GIMPLE_OMP_SINGLE
4162 || gimple_code (stmt) == GIMPLE_OMP_SECTION
4163 || gimple_code (stmt) == GIMPLE_OMP_MASTER
4164 || gimple_code (stmt) == GIMPLE_OMP_ORDERED
4165 || gimple_code (stmt) == GIMPLE_OMP_CRITICAL
4166 || gimple_code (stmt) == GIMPLE_OMP_RETURN
4167 || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_LOAD
4168 || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_STORE
4169 || gimple_code (stmt) == GIMPLE_OMP_CONTINUE);
4173 /* Returns TRUE if statement G is a GIMPLE_NOP. */
4175 static inline bool
4176 gimple_nop_p (const_gimple g)
4178 return gimple_code (g) == GIMPLE_NOP;
4182 /* Return the new type set by GIMPLE_CHANGE_DYNAMIC_TYPE statement GS. */
4184 static inline tree
4185 gimple_cdt_new_type (gimple gs)
4187 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4188 return gimple_op (gs, 1);
4191 /* Return a pointer to the new type set by GIMPLE_CHANGE_DYNAMIC_TYPE
4192 statement GS. */
4194 static inline tree *
4195 gimple_cdt_new_type_ptr (gimple gs)
4197 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4198 return gimple_op_ptr (gs, 1);
4201 /* Set NEW_TYPE to be the type returned by GIMPLE_CHANGE_DYNAMIC_TYPE
4202 statement GS. */
4204 static inline void
4205 gimple_cdt_set_new_type (gimple gs, tree new_type)
4207 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4208 gcc_assert (TREE_CODE_CLASS (TREE_CODE (new_type)) == tcc_type);
4209 gimple_set_op (gs, 1, new_type);
4213 /* Return the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE statement GS. */
4215 static inline tree
4216 gimple_cdt_location (gimple gs)
4218 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4219 return gimple_op (gs, 0);
4223 /* Return a pointer to the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE
4224 statement GS. */
4226 static inline tree *
4227 gimple_cdt_location_ptr (gimple gs)
4229 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4230 return gimple_op_ptr (gs, 0);
4234 /* Set PTR to be the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE
4235 statement GS. */
4237 static inline void
4238 gimple_cdt_set_location (gimple gs, tree ptr)
4240 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4241 gimple_set_op (gs, 0, ptr);
4245 /* Return the predictor of GIMPLE_PREDICT statement GS. */
4247 static inline enum br_predictor
4248 gimple_predict_predictor (gimple gs)
4250 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4251 return (enum br_predictor) (gs->gsbase.subcode & ~GF_PREDICT_TAKEN);
4255 /* Set the predictor of GIMPLE_PREDICT statement GS to PREDICT. */
4257 static inline void
4258 gimple_predict_set_predictor (gimple gs, enum br_predictor predictor)
4260 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4261 gs->gsbase.subcode = (gs->gsbase.subcode & GF_PREDICT_TAKEN)
4262 | (unsigned) predictor;
4266 /* Return the outcome of GIMPLE_PREDICT statement GS. */
4268 static inline enum prediction
4269 gimple_predict_outcome (gimple gs)
4271 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4272 return (gs->gsbase.subcode & GF_PREDICT_TAKEN) ? TAKEN : NOT_TAKEN;
4276 /* Set the outcome of GIMPLE_PREDICT statement GS to OUTCOME. */
4278 static inline void
4279 gimple_predict_set_outcome (gimple gs, enum prediction outcome)
4281 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4282 if (outcome == TAKEN)
4283 gs->gsbase.subcode |= GF_PREDICT_TAKEN;
4284 else
4285 gs->gsbase.subcode &= ~GF_PREDICT_TAKEN;
4289 /* Return a new iterator pointing to GIMPLE_SEQ's first statement. */
4291 static inline gimple_stmt_iterator
4292 gsi_start (gimple_seq seq)
4294 gimple_stmt_iterator i;
4296 i.ptr = gimple_seq_first (seq);
4297 i.seq = seq;
4298 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4300 return i;
4304 /* Return a new iterator pointing to the first statement in basic block BB. */
4306 static inline gimple_stmt_iterator
4307 gsi_start_bb (basic_block bb)
4309 gimple_stmt_iterator i;
4310 gimple_seq seq;
4312 seq = bb_seq (bb);
4313 i.ptr = gimple_seq_first (seq);
4314 i.seq = seq;
4315 i.bb = bb;
4317 return i;
4321 /* Return a new iterator initially pointing to GIMPLE_SEQ's last statement. */
4323 static inline gimple_stmt_iterator
4324 gsi_last (gimple_seq seq)
4326 gimple_stmt_iterator i;
4328 i.ptr = gimple_seq_last (seq);
4329 i.seq = seq;
4330 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4332 return i;
4336 /* Return a new iterator pointing to the last statement in basic block BB. */
4338 static inline gimple_stmt_iterator
4339 gsi_last_bb (basic_block bb)
4341 gimple_stmt_iterator i;
4342 gimple_seq seq;
4344 seq = bb_seq (bb);
4345 i.ptr = gimple_seq_last (seq);
4346 i.seq = seq;
4347 i.bb = bb;
4349 return i;
4353 /* Return true if I is at the end of its sequence. */
4355 static inline bool
4356 gsi_end_p (gimple_stmt_iterator i)
4358 return i.ptr == NULL;
4362 /* Return true if I is one statement before the end of its sequence. */
4364 static inline bool
4365 gsi_one_before_end_p (gimple_stmt_iterator i)
4367 return i.ptr != NULL && i.ptr->next == NULL;
4371 /* Advance the iterator to the next gimple statement. */
4373 static inline void
4374 gsi_next (gimple_stmt_iterator *i)
4376 i->ptr = i->ptr->next;
4379 /* Advance the iterator to the previous gimple statement. */
4381 static inline void
4382 gsi_prev (gimple_stmt_iterator *i)
4384 i->ptr = i->ptr->prev;
4387 /* Return the current stmt. */
4389 static inline gimple
4390 gsi_stmt (gimple_stmt_iterator i)
4392 return i.ptr->stmt;
4395 /* Return a block statement iterator that points to the first non-label
4396 statement in block BB. */
4398 static inline gimple_stmt_iterator
4399 gsi_after_labels (basic_block bb)
4401 gimple_stmt_iterator gsi = gsi_start_bb (bb);
4403 while (!gsi_end_p (gsi) && gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL)
4404 gsi_next (&gsi);
4406 return gsi;
4409 /* Return a pointer to the current stmt.
4411 NOTE: You may want to use gsi_replace on the iterator itself,
4412 as this performs additional bookkeeping that will not be done
4413 if you simply assign through a pointer returned by gsi_stmt_ptr. */
4415 static inline gimple *
4416 gsi_stmt_ptr (gimple_stmt_iterator *i)
4418 return &i->ptr->stmt;
4422 /* Return the basic block associated with this iterator. */
4424 static inline basic_block
4425 gsi_bb (gimple_stmt_iterator i)
4427 return i.bb;
4431 /* Return the sequence associated with this iterator. */
4433 static inline gimple_seq
4434 gsi_seq (gimple_stmt_iterator i)
4436 return i.seq;
4440 enum gsi_iterator_update
4442 GSI_NEW_STMT, /* Only valid when single statement is added, move
4443 iterator to it. */
4444 GSI_SAME_STMT, /* Leave the iterator at the same statement. */
4445 GSI_CONTINUE_LINKING /* Move iterator to whatever position is suitable
4446 for linking other statements in the same
4447 direction. */
4450 /* In gimple-iterator.c */
4451 gimple_stmt_iterator gsi_start_phis (basic_block);
4452 gimple_seq gsi_split_seq_after (gimple_stmt_iterator);
4453 gimple_seq gsi_split_seq_before (gimple_stmt_iterator *);
4454 void gsi_replace (gimple_stmt_iterator *, gimple, bool);
4455 void gsi_insert_before (gimple_stmt_iterator *, gimple,
4456 enum gsi_iterator_update);
4457 void gsi_insert_before_without_update (gimple_stmt_iterator *, gimple,
4458 enum gsi_iterator_update);
4459 void gsi_insert_seq_before (gimple_stmt_iterator *, gimple_seq,
4460 enum gsi_iterator_update);
4461 void gsi_insert_seq_before_without_update (gimple_stmt_iterator *, gimple_seq,
4462 enum gsi_iterator_update);
4463 void gsi_insert_after (gimple_stmt_iterator *, gimple,
4464 enum gsi_iterator_update);
4465 void gsi_insert_after_without_update (gimple_stmt_iterator *, gimple,
4466 enum gsi_iterator_update);
4467 void gsi_insert_seq_after (gimple_stmt_iterator *, gimple_seq,
4468 enum gsi_iterator_update);
4469 void gsi_insert_seq_after_without_update (gimple_stmt_iterator *, gimple_seq,
4470 enum gsi_iterator_update);
4471 void gsi_remove (gimple_stmt_iterator *, bool);
4472 gimple_stmt_iterator gsi_for_stmt (gimple);
4473 void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *);
4474 void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *);
4475 void gsi_move_to_bb_end (gimple_stmt_iterator *, struct basic_block_def *);
4476 void gsi_insert_on_edge (edge, gimple);
4477 void gsi_insert_seq_on_edge (edge, gimple_seq);
4478 basic_block gsi_insert_on_edge_immediate (edge, gimple);
4479 basic_block gsi_insert_seq_on_edge_immediate (edge, gimple_seq);
4480 void gsi_commit_one_edge_insert (edge, basic_block *);
4481 void gsi_commit_edge_inserts (void);
4482 gimple gimple_call_copy_skip_args (gimple, bitmap);
4485 /* Convenience routines to walk all statements of a gimple function.
4486 Note that this is useful exclusively before the code is converted
4487 into SSA form. Once the program is in SSA form, the standard
4488 operand interface should be used to analyze/modify statements. */
4489 struct walk_stmt_info
4491 /* Points to the current statement being walked. */
4492 gimple_stmt_iterator gsi;
4494 /* Additional data that the callback functions may want to carry
4495 through the recursion. */
4496 void *info;
4498 /* Pointer map used to mark visited tree nodes when calling
4499 walk_tree on each operand. If set to NULL, duplicate tree nodes
4500 will be visited more than once. */
4501 struct pointer_set_t *pset;
4503 /* Indicates whether the operand being examined may be replaced
4504 with something that matches is_gimple_val (if true) or something
4505 slightly more complicated (if false). "Something" technically
4506 means the common subset of is_gimple_lvalue and is_gimple_rhs,
4507 but we never try to form anything more complicated than that, so
4508 we don't bother checking.
4510 Also note that CALLBACK should update this flag while walking the
4511 sub-expressions of a statement. For instance, when walking the
4512 statement 'foo (&var)', the flag VAL_ONLY will initially be set
4513 to true, however, when walking &var, the operand of that
4514 ADDR_EXPR does not need to be a GIMPLE value. */
4515 bool val_only;
4517 /* True if we are currently walking the LHS of an assignment. */
4518 bool is_lhs;
4520 /* Optional. Set to true by the callback functions if they made any
4521 changes. */
4522 bool changed;
4524 /* True if we're interested in location information. */
4525 bool want_locations;
4527 /* Operand returned by the callbacks. This is set when calling
4528 walk_gimple_seq. If the walk_stmt_fn or walk_tree_fn callback
4529 returns non-NULL, this field will contain the tree returned by
4530 the last callback. */
4531 tree callback_result;
4534 /* Callback for walk_gimple_stmt. Called for every statement found
4535 during traversal. The first argument points to the statement to
4536 walk. The second argument is a flag that the callback sets to
4537 'true' if it the callback handled all the operands and
4538 sub-statements of the statement (the default value of this flag is
4539 'false'). The third argument is an anonymous pointer to data
4540 to be used by the callback. */
4541 typedef tree (*walk_stmt_fn) (gimple_stmt_iterator *, bool *,
4542 struct walk_stmt_info *);
4544 gimple walk_gimple_seq (gimple_seq, walk_stmt_fn, walk_tree_fn,
4545 struct walk_stmt_info *);
4546 tree walk_gimple_stmt (gimple_stmt_iterator *, walk_stmt_fn, walk_tree_fn,
4547 struct walk_stmt_info *);
4548 tree walk_gimple_op (gimple, walk_tree_fn, struct walk_stmt_info *);
4550 #ifdef GATHER_STATISTICS
4551 /* Enum and arrays used for allocation stats. Keep in sync with
4552 gimple.c:gimple_alloc_kind_names. */
4553 enum gimple_alloc_kind
4555 gimple_alloc_kind_assign, /* Assignments. */
4556 gimple_alloc_kind_phi, /* PHI nodes. */
4557 gimple_alloc_kind_cond, /* Conditionals. */
4558 gimple_alloc_kind_seq, /* Sequences. */
4559 gimple_alloc_kind_rest, /* Everything else. */
4560 gimple_alloc_kind_all
4563 extern int gimple_alloc_counts[];
4564 extern int gimple_alloc_sizes[];
4566 /* Return the allocation kind for a given stmt CODE. */
4567 static inline enum gimple_alloc_kind
4568 gimple_alloc_kind (enum gimple_code code)
4570 switch (code)
4572 case GIMPLE_ASSIGN:
4573 return gimple_alloc_kind_assign;
4574 case GIMPLE_PHI:
4575 return gimple_alloc_kind_phi;
4576 case GIMPLE_COND:
4577 return gimple_alloc_kind_cond;
4578 default:
4579 return gimple_alloc_kind_rest;
4582 #endif /* GATHER_STATISTICS */
4584 extern void dump_gimple_statistics (void);
4586 #endif /* GCC_GIMPLE_H */