1 /* Gimple IR definitions.
3 Copyright 2007, 2008, 2009 Free Software Foundation, Inc.
4 Contributed by Aldy Hernandez <aldyh@redhat.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
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
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/>. */
25 #include "pointer-set.h"
29 #include "hard-reg-set.h"
30 #include "basic-block.h"
31 #include "tree-ssa-operands.h"
34 DEF_VEC_ALLOC_P(gimple,heap);
35 DEF_VEC_ALLOC_P(gimple,gc);
37 typedef gimple *gimple_p;
39 DEF_VEC_ALLOC_P(gimple_p,heap);
41 DEF_VEC_P(gimple_seq);
42 DEF_VEC_ALLOC_P(gimple_seq,gc);
43 DEF_VEC_ALLOC_P(gimple_seq,heap);
45 /* For each block, the PHI nodes that need to be rewritten are stored into
47 typedef VEC(gimple, heap) *gimple_vec;
48 DEF_VEC_P (gimple_vec);
49 DEF_VEC_ALLOC_P (gimple_vec, heap);
52 #define DEFGSCODE(SYM, STRING, STRUCT) SYM,
55 LAST_AND_UNUSED_GIMPLE_CODE
58 extern const char *const gimple_code_name[];
59 extern const unsigned char gimple_rhs_class_table[];
61 /* Error out if a gimple tuple is addressed incorrectly. */
62 #if defined ENABLE_GIMPLE_CHECKING
63 extern void gimple_check_failed (const_gimple, const char *, int, \
64 const char *, enum gimple_code, \
65 enum tree_code) ATTRIBUTE_NORETURN;
67 #define GIMPLE_CHECK(GS, CODE) \
69 const_gimple __gs = (GS); \
70 if (gimple_code (__gs) != (CODE)) \
71 gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__, \
72 (CODE), ERROR_MARK); \
74 #else /* not ENABLE_GIMPLE_CHECKING */
75 #define GIMPLE_CHECK(GS, CODE) (void)0
78 /* Class of GIMPLE expressions suitable for the RHS of assignments. See
79 get_gimple_rhs_class. */
82 GIMPLE_INVALID_RHS, /* The expression cannot be used on the RHS. */
83 GIMPLE_BINARY_RHS, /* The expression is a binary operation. */
84 GIMPLE_UNARY_RHS, /* The expression is a unary operation. */
85 GIMPLE_SINGLE_RHS /* The expression is a single object (an SSA
86 name, a _DECL, a _REF, etc. */
89 /* Specific flags for individual GIMPLE statements. These flags are
90 always stored in gimple_statement_base.subcode and they may only be
91 defined for statement codes that do not use sub-codes.
93 Values for the masks can overlap as long as the overlapping values
94 are never used in the same statement class.
96 The maximum mask value that can be defined is 1 << 15 (i.e., each
97 statement code can hold up to 16 bitflags).
99 Keep this list sorted. */
101 GF_ASM_INPUT = 1 << 0,
102 GF_ASM_VOLATILE = 1 << 1,
103 GF_CALL_CANNOT_INLINE = 1 << 0,
104 GF_CALL_FROM_THUNK = 1 << 1,
105 GF_CALL_RETURN_SLOT_OPT = 1 << 2,
106 GF_CALL_TAILCALL = 1 << 3,
107 GF_CALL_VA_ARG_PACK = 1 << 4,
108 GF_OMP_PARALLEL_COMBINED = 1 << 0,
110 /* True on an GIMPLE_OMP_RETURN statement if the return does not require
111 a thread synchronization via some sort of barrier. The exact barrier
112 that would otherwise be emitted is dependent on the OMP statement with
113 which this return is associated. */
114 GF_OMP_RETURN_NOWAIT = 1 << 0,
116 GF_OMP_SECTION_LAST = 1 << 0,
117 GF_PREDICT_TAKEN = 1 << 15
120 /* Currently, there's only one type of gimple debug stmt. Others are
121 envisioned, for example, to enable the generation of is_stmt notes
122 in line number information, to mark sequence points, etc. This
123 subcode is to be used to tell them apart. */
124 enum gimple_debug_subcode {
125 GIMPLE_DEBUG_BIND = 0
128 /* Masks for selecting a pass local flag (PLF) to work on. These
129 masks are used by gimple_set_plf and gimple_plf. */
135 /* A node in a gimple_seq_d. */
136 struct GTY((chain_next ("%h.next"), chain_prev ("%h.prev"))) gimple_seq_node_d {
138 struct gimple_seq_node_d *prev;
139 struct gimple_seq_node_d *next;
142 /* A double-linked sequence of gimple statements. */
143 struct GTY ((chain_next ("%h.next_free"))) gimple_seq_d {
144 /* First and last statements in the sequence. */
145 gimple_seq_node first;
146 gimple_seq_node last;
148 /* Sequences are created/destroyed frequently. To minimize
149 allocation activity, deallocated sequences are kept in a pool of
150 available sequences. This is the pointer to the next free
151 sequence in the pool. */
152 gimple_seq next_free;
156 /* Return the first node in GIMPLE sequence S. */
158 static inline gimple_seq_node
159 gimple_seq_first (const_gimple_seq s)
161 return s ? s->first : NULL;
165 /* Return the first statement in GIMPLE sequence S. */
168 gimple_seq_first_stmt (const_gimple_seq s)
170 gimple_seq_node n = gimple_seq_first (s);
171 return (n) ? n->stmt : NULL;
175 /* Return the last node in GIMPLE sequence S. */
177 static inline gimple_seq_node
178 gimple_seq_last (const_gimple_seq s)
180 return s ? s->last : NULL;
184 /* Return the last statement in GIMPLE sequence S. */
187 gimple_seq_last_stmt (const_gimple_seq s)
189 gimple_seq_node n = gimple_seq_last (s);
190 return (n) ? n->stmt : NULL;
194 /* Set the last node in GIMPLE sequence S to LAST. */
197 gimple_seq_set_last (gimple_seq s, gimple_seq_node last)
203 /* Set the first node in GIMPLE sequence S to FIRST. */
206 gimple_seq_set_first (gimple_seq s, gimple_seq_node first)
212 /* Return true if GIMPLE sequence S is empty. */
215 gimple_seq_empty_p (const_gimple_seq s)
217 return s == NULL || s->first == NULL;
221 void gimple_seq_add_stmt (gimple_seq *, gimple);
223 /* Allocate a new sequence and initialize its first element with STMT. */
225 static inline gimple_seq
226 gimple_seq_alloc_with_stmt (gimple stmt)
228 gimple_seq seq = NULL;
229 gimple_seq_add_stmt (&seq, stmt);
234 /* Returns the sequence of statements in BB. */
236 static inline gimple_seq
237 bb_seq (const_basic_block bb)
239 return (!(bb->flags & BB_RTL) && bb->il.gimple) ? bb->il.gimple->seq : NULL;
243 /* Sets the sequence of statements in BB to SEQ. */
246 set_bb_seq (basic_block bb, gimple_seq seq)
248 gcc_assert (!(bb->flags & BB_RTL));
249 bb->il.gimple->seq = seq;
252 /* Iterator object for GIMPLE statement sequences. */
256 /* Sequence node holding the current statement. */
259 /* Sequence and basic block holding the statement. These fields
260 are necessary to handle edge cases such as when statement is
261 added to an empty basic block or when the last statement of a
262 block/sequence is removed. */
265 } gimple_stmt_iterator;
268 /* Data structure definitions for GIMPLE tuples. NOTE: word markers
269 are for 64 bit hosts. */
271 struct GTY(()) gimple_statement_base {
273 Main identifying code for a tuple. */
274 ENUM_BITFIELD(gimple_code) code : 8;
276 /* Nonzero if a warning should not be emitted on this tuple. */
277 unsigned int no_warning : 1;
279 /* Nonzero if this tuple has been visited. Passes are responsible
280 for clearing this bit before using it. */
281 unsigned int visited : 1;
283 /* Nonzero if this tuple represents a non-temporal move. */
284 unsigned int nontemporal_move : 1;
286 /* Pass local flags. These flags are free for any pass to use as
287 they see fit. Passes should not assume that these flags contain
288 any useful value when the pass starts. Any initial state that
289 the pass requires should be set on entry to the pass. See
290 gimple_set_plf and gimple_plf for usage. */
291 unsigned int plf : 2;
293 /* Nonzero if this statement has been modified and needs to have its
294 operands rescanned. */
295 unsigned modified : 1;
297 /* Nonzero if this statement contains volatile operands. */
298 unsigned has_volatile_ops : 1;
300 /* Padding to get subcode to 16 bit alignment. */
303 /* The SUBCODE field can be used for tuple-specific flags for tuples
304 that do not require subcodes. Note that SUBCODE should be at
305 least as wide as tree codes, as several tuples store tree codes
307 unsigned int subcode : 16;
309 /* UID of this statement. This is used by passes that want to
310 assign IDs to statements. It must be assigned and used by each
311 pass. By default it should be assumed to contain garbage. */
315 Locus information for debug info. */
318 /* Number of operands in this tuple. */
322 Basic block holding this statement. */
323 struct basic_block_def *bb;
326 Lexical block holding this statement. */
331 /* Base structure for tuples with operands. */
333 struct GTY(()) gimple_statement_with_ops_base
336 struct gimple_statement_base gsbase;
339 SSA operand vectors. NOTE: It should be possible to
340 amalgamate these vectors with the operand vector OP. However,
341 the SSA operand vectors are organized differently and contain
342 more information (like immediate use chaining). */
343 struct def_optype_d GTY((skip (""))) *def_ops;
344 struct use_optype_d GTY((skip (""))) *use_ops;
348 /* Statements that take register operands. */
350 struct GTY(()) gimple_statement_with_ops
353 struct gimple_statement_with_ops_base opbase;
356 Operand vector. NOTE! This must always be the last field
357 of this structure. In particular, this means that this
358 structure cannot be embedded inside another one. */
359 tree GTY((length ("%h.opbase.gsbase.num_ops"))) op[1];
363 /* Base for statements that take both memory and register operands. */
365 struct GTY(()) gimple_statement_with_memory_ops_base
368 struct gimple_statement_with_ops_base opbase;
371 Virtual operands for this statement. The GC will pick them
372 up via the ssa_names array. */
373 tree GTY((skip (""))) vdef;
374 tree GTY((skip (""))) vuse;
378 /* Statements that take both memory and register operands. */
380 struct GTY(()) gimple_statement_with_memory_ops
383 struct gimple_statement_with_memory_ops_base membase;
386 Operand vector. NOTE! This must always be the last field
387 of this structure. In particular, this means that this
388 structure cannot be embedded inside another one. */
389 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
393 /* OpenMP statements (#pragma omp). */
395 struct GTY(()) gimple_statement_omp {
397 struct gimple_statement_base gsbase;
406 struct GTY(()) gimple_statement_bind {
408 struct gimple_statement_base gsbase;
411 Variables declared in this scope. */
415 This is different than the BLOCK field in gimple_statement_base,
416 which is analogous to TREE_BLOCK (i.e., the lexical block holding
417 this statement). This field is the equivalent of BIND_EXPR_BLOCK
418 in tree land (i.e., the lexical scope defined by this bind). See
429 struct GTY(()) gimple_statement_catch {
431 struct gimple_statement_base gsbase;
441 /* GIMPLE_EH_FILTER */
443 struct GTY(()) gimple_statement_eh_filter {
445 struct gimple_statement_base gsbase;
447 /* Subcode: EH_FILTER_MUST_NOT_THROW. A boolean flag analogous to
448 the tree counterpart. */
462 struct GTY(()) gimple_statement_phi {
464 struct gimple_statement_base gsbase;
474 struct phi_arg_d GTY ((length ("%h.nargs"))) args[1];
480 struct GTY(()) gimple_statement_resx {
482 struct gimple_statement_base gsbase;
485 Exception region number. */
492 struct GTY(()) gimple_statement_try {
494 struct gimple_statement_base gsbase;
497 Expression to evaluate. */
501 Cleanup expression. */
505 /* Kind of GIMPLE_TRY statements. */
506 enum gimple_try_flags
509 GIMPLE_TRY_CATCH = 1 << 0,
512 GIMPLE_TRY_FINALLY = 1 << 1,
513 GIMPLE_TRY_KIND = GIMPLE_TRY_CATCH | GIMPLE_TRY_FINALLY,
515 /* Analogous to TRY_CATCH_IS_CLEANUP. */
516 GIMPLE_TRY_CATCH_IS_CLEANUP = 1 << 2
519 /* GIMPLE_WITH_CLEANUP_EXPR */
521 struct GTY(()) gimple_statement_wce {
523 struct gimple_statement_base gsbase;
525 /* Subcode: CLEANUP_EH_ONLY. True if the cleanup should only be
526 executed if an exception is thrown, not on normal exit of its
527 scope. This flag is analogous to the CLEANUP_EH_ONLY flag
531 Cleanup expression. */
538 struct GTY(()) gimple_statement_asm
541 struct gimple_statement_with_memory_ops_base membase;
544 __asm__ statement. */
548 Number of inputs, outputs and clobbers. */
554 Operand vector. NOTE! This must always be the last field
555 of this structure. In particular, this means that this
556 structure cannot be embedded inside another one. */
557 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
560 /* GIMPLE_OMP_CRITICAL */
562 struct GTY(()) gimple_statement_omp_critical {
564 struct gimple_statement_omp omp;
567 Critical section name. */
572 struct GTY(()) gimple_omp_for_iter {
573 /* Condition code. */
576 /* Index variable. */
591 struct GTY(()) gimple_statement_omp_for {
593 struct gimple_statement_omp omp;
599 Number of elements in iter array. */
603 struct gimple_omp_for_iter * GTY((length ("%h.collapse"))) iter;
606 Pre-body evaluated before the loop body begins. */
611 /* GIMPLE_OMP_PARALLEL */
613 struct GTY(()) gimple_statement_omp_parallel {
615 struct gimple_statement_omp omp;
622 Child function holding the body of the parallel region. */
626 Shared data argument. */
631 /* GIMPLE_OMP_TASK */
633 struct GTY(()) gimple_statement_omp_task {
635 struct gimple_statement_omp_parallel par;
638 Child function holding firstprivate initialization if needed. */
642 Size and alignment in bytes of the argument data block. */
648 /* GIMPLE_OMP_SECTION */
649 /* Uses struct gimple_statement_omp. */
652 /* GIMPLE_OMP_SECTIONS */
654 struct GTY(()) gimple_statement_omp_sections {
656 struct gimple_statement_omp omp;
662 The control variable used for deciding which of the sections to
667 /* GIMPLE_OMP_CONTINUE.
669 Note: This does not inherit from gimple_statement_omp, because we
670 do not need the body field. */
672 struct GTY(()) gimple_statement_omp_continue {
674 struct gimple_statement_base gsbase;
683 /* GIMPLE_OMP_SINGLE */
685 struct GTY(()) gimple_statement_omp_single {
687 struct gimple_statement_omp omp;
694 /* GIMPLE_OMP_ATOMIC_LOAD.
695 Note: This is based on gimple_statement_base, not g_s_omp, because g_s_omp
696 contains a sequence, which we don't need here. */
698 struct GTY(()) gimple_statement_omp_atomic_load {
700 struct gimple_statement_base gsbase;
706 /* GIMPLE_OMP_ATOMIC_STORE.
707 See note on GIMPLE_OMP_ATOMIC_LOAD. */
709 struct GTY(()) gimple_statement_omp_atomic_store {
711 struct gimple_statement_base gsbase;
717 #define DEFGSSTRUCT(SYM, STRUCT, HAS_TREE_OP) SYM,
718 enum gimple_statement_structure_enum {
719 #include "gsstruct.def"
725 /* Define the overall contents of a gimple tuple. It may be any of the
726 structures declared above for various types of tuples. */
728 union GTY ((desc ("gimple_statement_structure (&%h)"))) gimple_statement_d {
729 struct gimple_statement_base GTY ((tag ("GSS_BASE"))) gsbase;
730 struct gimple_statement_with_ops GTY ((tag ("GSS_WITH_OPS"))) gsops;
731 struct gimple_statement_with_memory_ops GTY ((tag ("GSS_WITH_MEM_OPS"))) gsmem;
732 struct gimple_statement_omp GTY ((tag ("GSS_OMP"))) omp;
733 struct gimple_statement_bind GTY ((tag ("GSS_BIND"))) gimple_bind;
734 struct gimple_statement_catch GTY ((tag ("GSS_CATCH"))) gimple_catch;
735 struct gimple_statement_eh_filter GTY ((tag ("GSS_EH_FILTER"))) gimple_eh_filter;
736 struct gimple_statement_phi GTY ((tag ("GSS_PHI"))) gimple_phi;
737 struct gimple_statement_resx GTY ((tag ("GSS_RESX"))) gimple_resx;
738 struct gimple_statement_try GTY ((tag ("GSS_TRY"))) gimple_try;
739 struct gimple_statement_wce GTY ((tag ("GSS_WCE"))) gimple_wce;
740 struct gimple_statement_asm GTY ((tag ("GSS_ASM"))) gimple_asm;
741 struct gimple_statement_omp_critical GTY ((tag ("GSS_OMP_CRITICAL"))) gimple_omp_critical;
742 struct gimple_statement_omp_for GTY ((tag ("GSS_OMP_FOR"))) gimple_omp_for;
743 struct gimple_statement_omp_parallel GTY ((tag ("GSS_OMP_PARALLEL"))) gimple_omp_parallel;
744 struct gimple_statement_omp_task GTY ((tag ("GSS_OMP_TASK"))) gimple_omp_task;
745 struct gimple_statement_omp_sections GTY ((tag ("GSS_OMP_SECTIONS"))) gimple_omp_sections;
746 struct gimple_statement_omp_single GTY ((tag ("GSS_OMP_SINGLE"))) gimple_omp_single;
747 struct gimple_statement_omp_continue GTY ((tag ("GSS_OMP_CONTINUE"))) gimple_omp_continue;
748 struct gimple_statement_omp_atomic_load GTY ((tag ("GSS_OMP_ATOMIC_LOAD"))) gimple_omp_atomic_load;
749 struct gimple_statement_omp_atomic_store GTY ((tag ("GSS_OMP_ATOMIC_STORE"))) gimple_omp_atomic_store;
754 /* Offset in bytes to the location of the operand vector.
755 Zero if there is no operand vector for this tuple structure. */
756 extern size_t const gimple_ops_offset_[];
758 /* Map GIMPLE codes to GSS codes. */
759 extern enum gimple_statement_structure_enum const gss_for_code_[];
761 gimple gimple_build_return (tree);
763 gimple gimple_build_assign_stat (tree, tree MEM_STAT_DECL);
764 #define gimple_build_assign(l,r) gimple_build_assign_stat (l, r MEM_STAT_INFO)
766 void extract_ops_from_tree (tree, enum tree_code *, tree *, tree *);
768 gimple gimple_build_assign_with_ops_stat (enum tree_code, tree, tree,
770 #define gimple_build_assign_with_ops(c,o1,o2,o3) \
771 gimple_build_assign_with_ops_stat (c, o1, o2, o3 MEM_STAT_INFO)
773 gimple gimple_build_debug_bind_stat (tree, tree, gimple MEM_STAT_DECL);
774 #define gimple_build_debug_bind(var,val,stmt) \
775 gimple_build_debug_bind_stat ((var), (val), (stmt) MEM_STAT_INFO)
777 gimple gimple_build_call_vec (tree, VEC(tree, heap) *);
778 gimple gimple_build_call (tree, unsigned, ...);
779 gimple gimple_build_call_from_tree (tree);
780 gimple gimplify_assign (tree, tree, gimple_seq *);
781 gimple gimple_build_cond (enum tree_code, tree, tree, tree, tree);
782 gimple gimple_build_label (tree label);
783 gimple gimple_build_goto (tree dest);
784 gimple gimple_build_nop (void);
785 gimple gimple_build_bind (tree, gimple_seq, tree);
786 gimple gimple_build_asm (const char *, unsigned, unsigned, unsigned, ...);
787 gimple gimple_build_asm_vec (const char *, VEC(tree,gc) *, VEC(tree,gc) *,
789 gimple gimple_build_catch (tree, gimple_seq);
790 gimple gimple_build_eh_filter (tree, gimple_seq);
791 gimple gimple_build_try (gimple_seq, gimple_seq, enum gimple_try_flags);
792 gimple gimple_build_wce (gimple_seq);
793 gimple gimple_build_resx (int);
794 gimple gimple_build_switch (unsigned, tree, tree, ...);
795 gimple gimple_build_switch_vec (tree, tree, VEC(tree,heap) *);
796 gimple gimple_build_omp_parallel (gimple_seq, tree, tree, tree);
797 gimple gimple_build_omp_task (gimple_seq, tree, tree, tree, tree, tree, tree);
798 gimple gimple_build_omp_for (gimple_seq, tree, size_t, gimple_seq);
799 gimple gimple_build_omp_critical (gimple_seq, tree);
800 gimple gimple_build_omp_section (gimple_seq);
801 gimple gimple_build_omp_continue (tree, tree);
802 gimple gimple_build_omp_master (gimple_seq);
803 gimple gimple_build_omp_return (bool);
804 gimple gimple_build_omp_ordered (gimple_seq);
805 gimple gimple_build_omp_sections (gimple_seq, tree);
806 gimple gimple_build_omp_sections_switch (void);
807 gimple gimple_build_omp_single (gimple_seq, tree);
808 gimple gimple_build_cdt (tree, tree);
809 gimple gimple_build_omp_atomic_load (tree, tree);
810 gimple gimple_build_omp_atomic_store (tree);
811 gimple gimple_build_predict (enum br_predictor, enum prediction);
812 enum gimple_statement_structure_enum gss_for_assign (enum tree_code);
813 void sort_case_labels (VEC(tree,heap) *);
814 void gimple_set_body (tree, gimple_seq);
815 gimple_seq gimple_body (tree);
816 bool gimple_has_body_p (tree);
817 gimple_seq gimple_seq_alloc (void);
818 void gimple_seq_free (gimple_seq);
819 void gimple_seq_add_seq (gimple_seq *, gimple_seq);
820 gimple_seq gimple_seq_copy (gimple_seq);
821 int gimple_call_flags (const_gimple);
822 bool gimple_assign_copy_p (gimple);
823 bool gimple_assign_ssa_name_copy_p (gimple);
824 bool gimple_assign_single_p (gimple);
825 bool gimple_assign_unary_nop_p (gimple);
826 void gimple_set_bb (gimple, struct basic_block_def *);
827 tree gimple_fold (const_gimple);
828 void gimple_assign_set_rhs_from_tree (gimple_stmt_iterator *, tree);
829 void gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *, enum tree_code,
831 tree gimple_get_lhs (const_gimple);
832 void gimple_set_lhs (gimple, tree);
833 gimple gimple_copy (gimple);
834 bool is_gimple_operand (const_tree);
835 void gimple_set_modified (gimple, bool);
836 void gimple_cond_get_ops_from_tree (tree, enum tree_code *, tree *, tree *);
837 gimple gimple_build_cond_from_tree (tree, tree, tree);
838 void gimple_cond_set_condition_from_tree (gimple, tree);
839 bool gimple_has_side_effects (const_gimple);
840 bool gimple_rhs_has_side_effects (const_gimple);
841 bool gimple_could_trap_p (gimple);
842 bool gimple_assign_rhs_could_trap_p (gimple);
843 void gimple_regimplify_operands (gimple, gimple_stmt_iterator *);
844 bool empty_body_p (gimple_seq);
845 unsigned get_gimple_rhs_num_ops (enum tree_code);
846 const char *gimple_decl_printable_name (tree, int);
847 tree gimple_fold_obj_type_ref (tree, tree);
849 /* Returns true iff T is a valid GIMPLE statement. */
850 extern bool is_gimple_stmt (tree);
852 /* Returns true iff TYPE is a valid type for a scalar register variable. */
853 extern bool is_gimple_reg_type (tree);
854 /* Returns true iff T is a scalar register variable. */
855 extern bool is_gimple_reg (tree);
856 /* Returns true iff T is any sort of variable. */
857 extern bool is_gimple_variable (tree);
858 /* Returns true iff T is any sort of symbol. */
859 extern bool is_gimple_id (tree);
860 /* Returns true iff T is a variable or an INDIRECT_REF (of a variable). */
861 extern bool is_gimple_min_lval (tree);
862 /* Returns true iff T is something whose address can be taken. */
863 extern bool is_gimple_addressable (tree);
864 /* Returns true iff T is any valid GIMPLE lvalue. */
865 extern bool is_gimple_lvalue (tree);
867 /* Returns true iff T is a GIMPLE address. */
868 bool is_gimple_address (const_tree);
869 /* Returns true iff T is a GIMPLE invariant address. */
870 bool is_gimple_invariant_address (const_tree);
871 /* Returns true iff T is a GIMPLE invariant address at interprocedural
873 bool is_gimple_ip_invariant_address (const_tree);
874 /* Returns true iff T is a valid GIMPLE constant. */
875 bool is_gimple_constant (const_tree);
876 /* Returns true iff T is a GIMPLE restricted function invariant. */
877 extern bool is_gimple_min_invariant (const_tree);
878 /* Returns true iff T is a GIMPLE restricted interprecodural invariant. */
879 extern bool is_gimple_ip_invariant (const_tree);
880 /* Returns true iff T is a GIMPLE rvalue. */
881 extern bool is_gimple_val (tree);
882 /* Returns true iff T is a GIMPLE asm statement input. */
883 extern bool is_gimple_asm_val (tree);
884 /* Returns true iff T is a valid rhs for a MODIFY_EXPR where the LHS is a
885 GIMPLE temporary, a renamed user variable, or something else,
887 extern bool is_gimple_reg_rhs (tree);
888 extern bool is_gimple_mem_rhs (tree);
890 /* Returns true iff T is a valid if-statement condition. */
891 extern bool is_gimple_condexpr (tree);
893 /* Returns true iff T is a type conversion. */
894 extern bool is_gimple_cast (tree);
895 /* Returns true iff T is a variable that does not need to live in memory. */
896 extern bool is_gimple_non_addressable (tree t);
898 /* Returns true iff T is a valid call address expression. */
899 extern bool is_gimple_call_addr (tree);
900 /* If T makes a function call, returns the CALL_EXPR operand. */
901 extern tree get_call_expr_in (tree t);
903 extern void recalculate_side_effects (tree);
904 extern void count_uses_and_derefs (tree, gimple, unsigned *, unsigned *,
906 extern bool walk_stmt_load_store_addr_ops (gimple, void *,
907 bool (*)(gimple, tree, void *),
908 bool (*)(gimple, tree, void *),
909 bool (*)(gimple, tree, void *));
910 extern bool walk_stmt_load_store_ops (gimple, void *,
911 bool (*)(gimple, tree, void *),
912 bool (*)(gimple, tree, void *));
913 extern bool gimple_ior_addresses_taken (bitmap, gimple);
916 extern tree create_tmp_var_raw (tree, const char *);
917 extern tree create_tmp_var_name (const char *);
918 extern tree create_tmp_var (tree, const char *);
919 extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq *);
920 extern tree get_formal_tmp_var (tree, gimple_seq *);
921 extern void declare_vars (tree, gimple, bool);
922 extern void tree_annotate_all_with_location (tree *, location_t);
923 extern void annotate_all_with_location (gimple_seq, location_t);
925 /* Validation of GIMPLE expressions. Note that these predicates only check
926 the basic form of the expression, they don't recurse to make sure that
927 underlying nodes are also of the right form. */
928 typedef bool (*gimple_predicate)(tree);
931 /* FIXME we should deduce this from the predicate. */
933 fb_none = 0, /* Do not generate a temporary. */
935 fb_rvalue = 1, /* Generate an rvalue to hold the result of a
936 gimplified expression. */
938 fb_lvalue = 2, /* Generate an lvalue to hold the result of a
939 gimplified expression. */
941 fb_mayfail = 4, /* Gimplification may fail. Error issued
943 fb_either= fb_rvalue | fb_lvalue
946 typedef int 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. */
957 struct gimplify_ctx *prev_context;
959 VEC(gimple,heap) *bind_expr_stack;
961 gimple_seq conditional_cleanups;
965 VEC(tree,heap) *case_labels;
966 /* The formal temporary table. Should this be persistent? */
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 *,
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);
1003 extern tree omp_reduction_init (tree, tree);
1005 /* In tree-nested.c. */
1006 extern void lower_nested_functions (tree);
1007 extern void insert_field_into_struct (tree, tree);
1009 /* In gimplify.c. */
1010 extern void gimplify_function_tree (tree);
1012 /* In cfgexpand.c. */
1013 extern tree gimple_assign_rhs_to_tree (gimple);
1016 extern bool validate_gimple_arglist (const_gimple, ...);
1019 extern bool tree_ssa_useless_type_conversion (tree);
1020 extern tree tree_ssa_strip_useless_type_conversions (tree);
1021 extern bool useless_type_conversion_p (tree, tree);
1022 extern bool types_compatible_p (tree, tree);
1024 /* Return the code for GIMPLE statement G. */
1026 static inline enum gimple_code
1027 gimple_code (const_gimple g)
1029 return g->gsbase.code;
1033 /* Return the GSS code used by a GIMPLE code. */
1035 static inline enum gimple_statement_structure_enum
1036 gss_for_code (enum gimple_code code)
1038 gcc_assert ((unsigned int)code < LAST_AND_UNUSED_GIMPLE_CODE);
1039 return gss_for_code_[code];
1043 /* Return which GSS code is used by GS. */
1045 static inline enum gimple_statement_structure_enum
1046 gimple_statement_structure (gimple gs)
1048 return gss_for_code (gimple_code (gs));
1052 /* Return true if statement G has sub-statements. This is only true for
1053 High GIMPLE statements. */
1056 gimple_has_substatements (gimple g)
1058 switch (gimple_code (g))
1062 case GIMPLE_EH_FILTER:
1064 case GIMPLE_OMP_FOR:
1065 case GIMPLE_OMP_MASTER:
1066 case GIMPLE_OMP_ORDERED:
1067 case GIMPLE_OMP_SECTION:
1068 case GIMPLE_OMP_PARALLEL:
1069 case GIMPLE_OMP_TASK:
1070 case GIMPLE_OMP_SECTIONS:
1071 case GIMPLE_OMP_SINGLE:
1072 case GIMPLE_OMP_CRITICAL:
1073 case GIMPLE_WITH_CLEANUP_EXPR:
1082 /* Return the basic block holding statement G. */
1084 static inline struct basic_block_def *
1085 gimple_bb (const_gimple g)
1087 return g->gsbase.bb;
1091 /* Return the lexical scope block holding statement G. */
1094 gimple_block (const_gimple g)
1096 return g->gsbase.block;
1100 /* Set BLOCK to be the lexical scope block holding statement G. */
1103 gimple_set_block (gimple g, tree block)
1105 g->gsbase.block = block;
1109 /* Return location information for statement G. */
1111 static inline location_t
1112 gimple_location (const_gimple g)
1114 return g->gsbase.location;
1117 /* Return pointer to location information for statement G. */
1119 static inline const location_t *
1120 gimple_location_ptr (const_gimple g)
1122 return &g->gsbase.location;
1126 /* Set location information for statement G. */
1129 gimple_set_location (gimple g, location_t location)
1131 g->gsbase.location = location;
1135 /* Return true if G contains location information. */
1138 gimple_has_location (const_gimple g)
1140 return gimple_location (g) != UNKNOWN_LOCATION;
1144 /* Return the file name of the location of STMT. */
1146 static inline const char *
1147 gimple_filename (const_gimple stmt)
1149 return LOCATION_FILE (gimple_location (stmt));
1153 /* Return the line number of the location of STMT. */
1156 gimple_lineno (const_gimple stmt)
1158 return LOCATION_LINE (gimple_location (stmt));
1162 /* Determine whether SEQ is a singleton. */
1165 gimple_seq_singleton_p (gimple_seq seq)
1167 return ((gimple_seq_first (seq) != NULL)
1168 && (gimple_seq_first (seq) == gimple_seq_last (seq)));
1171 /* Return true if no warnings should be emitted for statement STMT. */
1174 gimple_no_warning_p (const_gimple stmt)
1176 return stmt->gsbase.no_warning;
1179 /* Set the no_warning flag of STMT to NO_WARNING. */
1182 gimple_set_no_warning (gimple stmt, bool no_warning)
1184 stmt->gsbase.no_warning = (unsigned) no_warning;
1187 /* Set the visited status on statement STMT to VISITED_P. */
1190 gimple_set_visited (gimple stmt, bool visited_p)
1192 stmt->gsbase.visited = (unsigned) visited_p;
1196 /* Return the visited status for statement STMT. */
1199 gimple_visited_p (gimple stmt)
1201 return stmt->gsbase.visited;
1205 /* Set pass local flag PLF on statement STMT to VAL_P. */
1208 gimple_set_plf (gimple stmt, enum plf_mask plf, bool val_p)
1211 stmt->gsbase.plf |= (unsigned int) plf;
1213 stmt->gsbase.plf &= ~((unsigned int) plf);
1217 /* Return the value of pass local flag PLF on statement STMT. */
1219 static inline unsigned int
1220 gimple_plf (gimple stmt, enum plf_mask plf)
1222 return stmt->gsbase.plf & ((unsigned int) plf);
1226 /* Set the UID of statement. */
1229 gimple_set_uid (gimple g, unsigned uid)
1231 g->gsbase.uid = uid;
1235 /* Return the UID of statement. */
1237 static inline unsigned
1238 gimple_uid (const_gimple g)
1240 return g->gsbase.uid;
1244 /* Return true if GIMPLE statement G has register or memory operands. */
1247 gimple_has_ops (const_gimple g)
1249 return gimple_code (g) >= GIMPLE_COND && gimple_code (g) <= GIMPLE_RETURN;
1253 /* Return true if GIMPLE statement G has memory operands. */
1256 gimple_has_mem_ops (const_gimple g)
1258 return gimple_code (g) >= GIMPLE_ASSIGN && gimple_code (g) <= GIMPLE_RETURN;
1262 /* Return the set of DEF operands for statement G. */
1264 static inline struct def_optype_d *
1265 gimple_def_ops (const_gimple g)
1267 if (!gimple_has_ops (g))
1269 return g->gsops.opbase.def_ops;
1273 /* Set DEF to be the set of DEF operands for statement G. */
1276 gimple_set_def_ops (gimple g, struct def_optype_d *def)
1278 gcc_assert (gimple_has_ops (g));
1279 g->gsops.opbase.def_ops = def;
1283 /* Return the set of USE operands for statement G. */
1285 static inline struct use_optype_d *
1286 gimple_use_ops (const_gimple g)
1288 if (!gimple_has_ops (g))
1290 return g->gsops.opbase.use_ops;
1294 /* Set USE to be the set of USE operands for statement G. */
1297 gimple_set_use_ops (gimple g, struct use_optype_d *use)
1299 gcc_assert (gimple_has_ops (g));
1300 g->gsops.opbase.use_ops = use;
1304 /* Return the set of VUSE operand for statement G. */
1306 static inline use_operand_p
1307 gimple_vuse_op (const_gimple g)
1309 struct use_optype_d *ops;
1310 if (!gimple_has_mem_ops (g))
1311 return NULL_USE_OPERAND_P;
1312 ops = g->gsops.opbase.use_ops;
1314 && USE_OP_PTR (ops)->use == &g->gsmem.membase.vuse)
1315 return USE_OP_PTR (ops);
1316 return NULL_USE_OPERAND_P;
1319 /* Return the set of VDEF operand for statement G. */
1321 static inline def_operand_p
1322 gimple_vdef_op (const_gimple g)
1324 struct def_optype_d *ops;
1325 if (!gimple_has_mem_ops (g))
1326 return NULL_DEF_OPERAND_P;
1327 ops = g->gsops.opbase.def_ops;
1329 && DEF_OP_PTR (ops) == &g->gsmem.membase.vdef)
1330 return DEF_OP_PTR (ops);
1331 return NULL_DEF_OPERAND_P;
1335 /* Return the single VUSE operand of the statement G. */
1338 gimple_vuse (const_gimple g)
1340 if (!gimple_has_mem_ops (g))
1342 return g->gsmem.membase.vuse;
1345 /* Return the single VDEF operand of the statement G. */
1348 gimple_vdef (const_gimple g)
1350 if (!gimple_has_mem_ops (g))
1352 return g->gsmem.membase.vdef;
1355 /* Return the single VUSE operand of the statement G. */
1357 static inline tree *
1358 gimple_vuse_ptr (gimple g)
1360 if (!gimple_has_mem_ops (g))
1362 return &g->gsmem.membase.vuse;
1365 /* Return the single VDEF operand of the statement G. */
1367 static inline tree *
1368 gimple_vdef_ptr (gimple g)
1370 if (!gimple_has_mem_ops (g))
1372 return &g->gsmem.membase.vdef;
1375 /* Set the single VUSE operand of the statement G. */
1378 gimple_set_vuse (gimple g, tree vuse)
1380 gcc_assert (gimple_has_mem_ops (g));
1381 g->gsmem.membase.vuse = vuse;
1384 /* Set the single VDEF operand of the statement G. */
1387 gimple_set_vdef (gimple g, tree vdef)
1389 gcc_assert (gimple_has_mem_ops (g));
1390 g->gsmem.membase.vdef = vdef;
1394 /* Return true if statement G has operands and the modified field has
1398 gimple_modified_p (const_gimple g)
1400 return (gimple_has_ops (g)) ? (bool) g->gsbase.modified : false;
1404 /* Return the tree code for the expression computed by STMT. This is
1405 only valid for GIMPLE_COND, GIMPLE_CALL and GIMPLE_ASSIGN. For
1406 GIMPLE_CALL, return CALL_EXPR as the expression code for
1407 consistency. This is useful when the caller needs to deal with the
1408 three kinds of computation that GIMPLE supports. */
1410 static inline enum tree_code
1411 gimple_expr_code (const_gimple stmt)
1413 enum gimple_code code = gimple_code (stmt);
1414 if (code == GIMPLE_ASSIGN || code == GIMPLE_COND)
1415 return (enum tree_code) stmt->gsbase.subcode;
1416 else if (code == GIMPLE_CALL)
1423 /* Mark statement S as modified, and update it. */
1426 update_stmt (gimple s)
1428 if (gimple_has_ops (s))
1430 gimple_set_modified (s, true);
1431 update_stmt_operands (s);
1435 /* Update statement S if it has been optimized. */
1438 update_stmt_if_modified (gimple s)
1440 if (gimple_modified_p (s))
1441 update_stmt_operands (s);
1444 /* Return true if statement STMT contains volatile operands. */
1447 gimple_has_volatile_ops (const_gimple stmt)
1449 if (gimple_has_mem_ops (stmt))
1450 return stmt->gsbase.has_volatile_ops;
1456 /* Set the HAS_VOLATILE_OPS flag to VOLATILEP. */
1459 gimple_set_has_volatile_ops (gimple stmt, bool volatilep)
1461 if (gimple_has_mem_ops (stmt))
1462 stmt->gsbase.has_volatile_ops = (unsigned) volatilep;
1466 /* Return true if statement STMT may access memory. */
1469 gimple_references_memory_p (gimple stmt)
1471 return gimple_has_mem_ops (stmt) && gimple_vuse (stmt);
1475 /* Return the subcode for OMP statement S. */
1477 static inline unsigned
1478 gimple_omp_subcode (const_gimple s)
1480 gcc_assert (gimple_code (s) >= GIMPLE_OMP_ATOMIC_LOAD
1481 && gimple_code (s) <= GIMPLE_OMP_SINGLE);
1482 return s->gsbase.subcode;
1485 /* Set the subcode for OMP statement S to SUBCODE. */
1488 gimple_omp_set_subcode (gimple s, unsigned int subcode)
1490 /* We only have 16 bits for the subcode. Assert that we are not
1492 gcc_assert (subcode < (1 << 16));
1493 s->gsbase.subcode = subcode;
1496 /* Set the nowait flag on OMP_RETURN statement S. */
1499 gimple_omp_return_set_nowait (gimple s)
1501 GIMPLE_CHECK (s, GIMPLE_OMP_RETURN);
1502 s->gsbase.subcode |= GF_OMP_RETURN_NOWAIT;
1506 /* Return true if OMP return statement G has the GF_OMP_RETURN_NOWAIT
1510 gimple_omp_return_nowait_p (const_gimple g)
1512 GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
1513 return (gimple_omp_subcode (g) & GF_OMP_RETURN_NOWAIT) != 0;
1517 /* Return true if OMP section statement G has the GF_OMP_SECTION_LAST
1521 gimple_omp_section_last_p (const_gimple g)
1523 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1524 return (gimple_omp_subcode (g) & GF_OMP_SECTION_LAST) != 0;
1528 /* Set the GF_OMP_SECTION_LAST flag on G. */
1531 gimple_omp_section_set_last (gimple g)
1533 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1534 g->gsbase.subcode |= GF_OMP_SECTION_LAST;
1538 /* Return true if OMP parallel statement G has the
1539 GF_OMP_PARALLEL_COMBINED flag set. */
1542 gimple_omp_parallel_combined_p (const_gimple g)
1544 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1545 return (gimple_omp_subcode (g) & GF_OMP_PARALLEL_COMBINED) != 0;
1549 /* Set the GF_OMP_PARALLEL_COMBINED field in G depending on the boolean
1550 value of COMBINED_P. */
1553 gimple_omp_parallel_set_combined_p (gimple g, bool combined_p)
1555 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1557 g->gsbase.subcode |= GF_OMP_PARALLEL_COMBINED;
1559 g->gsbase.subcode &= ~GF_OMP_PARALLEL_COMBINED;
1563 /* Return the number of operands for statement GS. */
1565 static inline unsigned
1566 gimple_num_ops (const_gimple gs)
1568 return gs->gsbase.num_ops;
1572 /* Set the number of operands for statement GS. */
1575 gimple_set_num_ops (gimple gs, unsigned num_ops)
1577 gs->gsbase.num_ops = num_ops;
1581 /* Return the array of operands for statement GS. */
1583 static inline tree *
1584 gimple_ops (gimple gs)
1588 /* All the tuples have their operand vector at the very bottom
1589 of the structure. Note that those structures that do not
1590 have an operand vector have a zero offset. */
1591 off = gimple_ops_offset_[gimple_statement_structure (gs)];
1592 gcc_assert (off != 0);
1594 return (tree *) ((char *) gs + off);
1598 /* Return operand I for statement GS. */
1601 gimple_op (const_gimple gs, unsigned i)
1603 if (gimple_has_ops (gs))
1605 gcc_assert (i < gimple_num_ops (gs));
1606 return gimple_ops (CONST_CAST_GIMPLE (gs))[i];
1612 /* Return a pointer to operand I for statement GS. */
1614 static inline tree *
1615 gimple_op_ptr (const_gimple gs, unsigned i)
1617 if (gimple_has_ops (gs))
1619 gcc_assert (i < gimple_num_ops (gs));
1620 return gimple_ops (CONST_CAST_GIMPLE (gs)) + i;
1626 /* Set operand I of statement GS to OP. */
1629 gimple_set_op (gimple gs, unsigned i, tree op)
1631 gcc_assert (gimple_has_ops (gs) && i < gimple_num_ops (gs));
1633 /* Note. It may be tempting to assert that OP matches
1634 is_gimple_operand, but that would be wrong. Different tuples
1635 accept slightly different sets of tree operands. Each caller
1636 should perform its own validation. */
1637 gimple_ops (gs)[i] = op;
1640 /* Return true if GS is a GIMPLE_ASSIGN. */
1643 is_gimple_assign (const_gimple gs)
1645 return gimple_code (gs) == GIMPLE_ASSIGN;
1648 /* Determine if expression CODE is one of the valid expressions that can
1649 be used on the RHS of GIMPLE assignments. */
1651 static inline enum gimple_rhs_class
1652 get_gimple_rhs_class (enum tree_code code)
1654 return (enum gimple_rhs_class) gimple_rhs_class_table[(int) code];
1657 /* Return the LHS of assignment statement GS. */
1660 gimple_assign_lhs (const_gimple gs)
1662 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1663 return gimple_op (gs, 0);
1667 /* Return a pointer to the LHS of assignment statement GS. */
1669 static inline tree *
1670 gimple_assign_lhs_ptr (const_gimple gs)
1672 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1673 return gimple_op_ptr (gs, 0);
1677 /* Set LHS to be the LHS operand of assignment statement GS. */
1680 gimple_assign_set_lhs (gimple gs, tree lhs)
1682 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1683 gcc_assert (is_gimple_operand (lhs));
1684 gimple_set_op (gs, 0, lhs);
1686 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1687 SSA_NAME_DEF_STMT (lhs) = gs;
1691 /* Return the first operand on the RHS of assignment statement GS. */
1694 gimple_assign_rhs1 (const_gimple gs)
1696 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1697 return gimple_op (gs, 1);
1701 /* Return a pointer to the first operand on the RHS of assignment
1704 static inline tree *
1705 gimple_assign_rhs1_ptr (const_gimple gs)
1707 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1708 return gimple_op_ptr (gs, 1);
1711 /* Set RHS to be the first operand on the RHS of assignment statement GS. */
1714 gimple_assign_set_rhs1 (gimple gs, tree rhs)
1716 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1718 /* If there are 3 or more operands, the 2 operands on the RHS must be
1720 if (gimple_num_ops (gs) >= 3)
1721 gcc_assert (is_gimple_val (rhs));
1723 gcc_assert (is_gimple_operand (rhs));
1725 gimple_set_op (gs, 1, rhs);
1729 /* Return the second operand on the RHS of assignment statement GS.
1730 If GS does not have two operands, NULL is returned instead. */
1733 gimple_assign_rhs2 (const_gimple gs)
1735 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1737 if (gimple_num_ops (gs) >= 3)
1738 return gimple_op (gs, 2);
1744 /* Return a pointer to the second operand on the RHS of assignment
1747 static inline tree *
1748 gimple_assign_rhs2_ptr (const_gimple gs)
1750 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1751 return gimple_op_ptr (gs, 2);
1755 /* Set RHS to be the second operand on the RHS of assignment statement GS. */
1758 gimple_assign_set_rhs2 (gimple gs, tree rhs)
1760 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1762 /* The 2 operands on the RHS must be GIMPLE values. */
1763 gcc_assert (is_gimple_val (rhs));
1765 gimple_set_op (gs, 2, rhs);
1768 /* Returns true if GS is a nontemporal move. */
1771 gimple_assign_nontemporal_move_p (const_gimple gs)
1773 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1774 return gs->gsbase.nontemporal_move;
1777 /* Sets nontemporal move flag of GS to NONTEMPORAL. */
1780 gimple_assign_set_nontemporal_move (gimple gs, bool nontemporal)
1782 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1783 gs->gsbase.nontemporal_move = nontemporal;
1787 /* Return the code of the expression computed on the rhs of assignment
1788 statement GS. In case that the RHS is a single object, returns the
1789 tree code of the object. */
1791 static inline enum tree_code
1792 gimple_assign_rhs_code (const_gimple gs)
1794 enum tree_code code;
1795 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1797 code = gimple_expr_code (gs);
1798 if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS)
1799 code = TREE_CODE (gimple_assign_rhs1 (gs));
1805 /* Set CODE to be the code for the expression computed on the RHS of
1809 gimple_assign_set_rhs_code (gimple s, enum tree_code code)
1811 GIMPLE_CHECK (s, GIMPLE_ASSIGN);
1812 s->gsbase.subcode = code;
1816 /* Return the gimple rhs class of the code of the expression computed on
1817 the rhs of assignment statement GS.
1818 This will never return GIMPLE_INVALID_RHS. */
1820 static inline enum gimple_rhs_class
1821 gimple_assign_rhs_class (const_gimple gs)
1823 return get_gimple_rhs_class (gimple_assign_rhs_code (gs));
1827 /* Return true if S is a type-cast assignment. */
1830 gimple_assign_cast_p (gimple s)
1832 if (is_gimple_assign (s))
1834 enum tree_code sc = gimple_assign_rhs_code (s);
1835 return CONVERT_EXPR_CODE_P (sc)
1836 || sc == VIEW_CONVERT_EXPR
1837 || sc == FIX_TRUNC_EXPR;
1844 /* Return true if GS is a GIMPLE_CALL. */
1847 is_gimple_call (const_gimple gs)
1849 return gimple_code (gs) == GIMPLE_CALL;
1852 /* Return the LHS of call statement GS. */
1855 gimple_call_lhs (const_gimple gs)
1857 GIMPLE_CHECK (gs, GIMPLE_CALL);
1858 return gimple_op (gs, 0);
1862 /* Return a pointer to the LHS of call statement GS. */
1864 static inline tree *
1865 gimple_call_lhs_ptr (const_gimple gs)
1867 GIMPLE_CHECK (gs, GIMPLE_CALL);
1868 return gimple_op_ptr (gs, 0);
1872 /* Set LHS to be the LHS operand of call statement GS. */
1875 gimple_call_set_lhs (gimple gs, tree lhs)
1877 GIMPLE_CHECK (gs, GIMPLE_CALL);
1878 gcc_assert (!lhs || is_gimple_operand (lhs));
1879 gimple_set_op (gs, 0, lhs);
1880 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1881 SSA_NAME_DEF_STMT (lhs) = gs;
1885 /* Return the tree node representing the function called by call
1889 gimple_call_fn (const_gimple gs)
1891 GIMPLE_CHECK (gs, GIMPLE_CALL);
1892 return gimple_op (gs, 1);
1896 /* Return a pointer to the tree node representing the function called by call
1899 static inline tree *
1900 gimple_call_fn_ptr (const_gimple gs)
1902 GIMPLE_CHECK (gs, GIMPLE_CALL);
1903 return gimple_op_ptr (gs, 1);
1907 /* Set FN to be the function called by call statement GS. */
1910 gimple_call_set_fn (gimple gs, tree fn)
1912 GIMPLE_CHECK (gs, GIMPLE_CALL);
1913 gcc_assert (is_gimple_operand (fn));
1914 gimple_set_op (gs, 1, fn);
1918 /* Set FNDECL to be the function called by call statement GS. */
1921 gimple_call_set_fndecl (gimple gs, tree decl)
1923 GIMPLE_CHECK (gs, GIMPLE_CALL);
1924 gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
1925 gimple_set_op (gs, 1, build_fold_addr_expr_loc (gimple_location (gs), decl));
1929 /* If a given GIMPLE_CALL's callee is a FUNCTION_DECL, return it.
1930 Otherwise return NULL. This function is analogous to
1931 get_callee_fndecl in tree land. */
1934 gimple_call_fndecl (const_gimple gs)
1936 tree addr = gimple_call_fn (gs);
1937 if (TREE_CODE (addr) == ADDR_EXPR)
1939 gcc_assert (TREE_CODE (TREE_OPERAND (addr, 0)) == FUNCTION_DECL);
1940 return TREE_OPERAND (addr, 0);
1946 /* Return the type returned by call statement GS. */
1949 gimple_call_return_type (const_gimple gs)
1951 tree fn = gimple_call_fn (gs);
1952 tree type = TREE_TYPE (fn);
1954 /* See through the pointer. */
1955 gcc_assert (POINTER_TYPE_P (type));
1956 type = TREE_TYPE (type);
1958 gcc_assert (TREE_CODE (type) == FUNCTION_TYPE
1959 || TREE_CODE (type) == METHOD_TYPE);
1961 /* The type returned by a FUNCTION_DECL is the type of its
1963 return TREE_TYPE (type);
1967 /* Return the static chain for call statement GS. */
1970 gimple_call_chain (const_gimple gs)
1972 GIMPLE_CHECK (gs, GIMPLE_CALL);
1973 return gimple_op (gs, 2);
1977 /* Return a pointer to the static chain for call statement GS. */
1979 static inline tree *
1980 gimple_call_chain_ptr (const_gimple gs)
1982 GIMPLE_CHECK (gs, GIMPLE_CALL);
1983 return gimple_op_ptr (gs, 2);
1986 /* Set CHAIN to be the static chain for call statement GS. */
1989 gimple_call_set_chain (gimple gs, tree chain)
1991 GIMPLE_CHECK (gs, GIMPLE_CALL);
1992 gcc_assert (chain == NULL
1993 || TREE_CODE (chain) == ADDR_EXPR
1994 || SSA_VAR_P (chain));
1995 gimple_set_op (gs, 2, chain);
1999 /* Return the number of arguments used by call statement GS. */
2001 static inline unsigned
2002 gimple_call_num_args (const_gimple gs)
2005 GIMPLE_CHECK (gs, GIMPLE_CALL);
2006 num_ops = gimple_num_ops (gs);
2007 gcc_assert (num_ops >= 3);
2012 /* Return the argument at position INDEX for call statement GS. */
2015 gimple_call_arg (const_gimple gs, unsigned index)
2017 GIMPLE_CHECK (gs, GIMPLE_CALL);
2018 return gimple_op (gs, index + 3);
2022 /* Return a pointer to the argument at position INDEX for call
2025 static inline tree *
2026 gimple_call_arg_ptr (const_gimple gs, unsigned index)
2028 GIMPLE_CHECK (gs, GIMPLE_CALL);
2029 return gimple_op_ptr (gs, index + 3);
2033 /* Set ARG to be the argument at position INDEX for call statement GS. */
2036 gimple_call_set_arg (gimple gs, unsigned index, tree arg)
2038 GIMPLE_CHECK (gs, GIMPLE_CALL);
2039 gcc_assert (is_gimple_operand (arg));
2040 gimple_set_op (gs, index + 3, arg);
2044 /* If TAIL_P is true, mark call statement S as being a tail call
2045 (i.e., a call just before the exit of a function). These calls are
2046 candidate for tail call optimization. */
2049 gimple_call_set_tail (gimple s, bool tail_p)
2051 GIMPLE_CHECK (s, GIMPLE_CALL);
2053 s->gsbase.subcode |= GF_CALL_TAILCALL;
2055 s->gsbase.subcode &= ~GF_CALL_TAILCALL;
2059 /* Return true if GIMPLE_CALL S is marked as a tail call. */
2062 gimple_call_tail_p (gimple s)
2064 GIMPLE_CHECK (s, GIMPLE_CALL);
2065 return (s->gsbase.subcode & GF_CALL_TAILCALL) != 0;
2069 /* Set the inlinable status of GIMPLE_CALL S to INLINABLE_P. */
2072 gimple_call_set_cannot_inline (gimple s, bool inlinable_p)
2074 GIMPLE_CHECK (s, GIMPLE_CALL);
2076 s->gsbase.subcode |= GF_CALL_CANNOT_INLINE;
2078 s->gsbase.subcode &= ~GF_CALL_CANNOT_INLINE;
2082 /* Return true if GIMPLE_CALL S cannot be inlined. */
2085 gimple_call_cannot_inline_p (gimple s)
2087 GIMPLE_CHECK (s, GIMPLE_CALL);
2088 return (s->gsbase.subcode & GF_CALL_CANNOT_INLINE) != 0;
2092 /* If RETURN_SLOT_OPT_P is true mark GIMPLE_CALL S as valid for return
2093 slot optimization. This transformation uses the target of the call
2094 expansion as the return slot for calls that return in memory. */
2097 gimple_call_set_return_slot_opt (gimple s, bool return_slot_opt_p)
2099 GIMPLE_CHECK (s, GIMPLE_CALL);
2100 if (return_slot_opt_p)
2101 s->gsbase.subcode |= GF_CALL_RETURN_SLOT_OPT;
2103 s->gsbase.subcode &= ~GF_CALL_RETURN_SLOT_OPT;
2107 /* Return true if S is marked for return slot optimization. */
2110 gimple_call_return_slot_opt_p (gimple s)
2112 GIMPLE_CHECK (s, GIMPLE_CALL);
2113 return (s->gsbase.subcode & GF_CALL_RETURN_SLOT_OPT) != 0;
2117 /* If FROM_THUNK_P is true, mark GIMPLE_CALL S as being the jump from a
2118 thunk to the thunked-to function. */
2121 gimple_call_set_from_thunk (gimple s, bool from_thunk_p)
2123 GIMPLE_CHECK (s, GIMPLE_CALL);
2125 s->gsbase.subcode |= GF_CALL_FROM_THUNK;
2127 s->gsbase.subcode &= ~GF_CALL_FROM_THUNK;
2131 /* Return true if GIMPLE_CALL S is a jump from a thunk. */
2134 gimple_call_from_thunk_p (gimple s)
2136 GIMPLE_CHECK (s, GIMPLE_CALL);
2137 return (s->gsbase.subcode & GF_CALL_FROM_THUNK) != 0;
2141 /* If PASS_ARG_PACK_P is true, GIMPLE_CALL S is a stdarg call that needs the
2142 argument pack in its argument list. */
2145 gimple_call_set_va_arg_pack (gimple s, bool pass_arg_pack_p)
2147 GIMPLE_CHECK (s, GIMPLE_CALL);
2148 if (pass_arg_pack_p)
2149 s->gsbase.subcode |= GF_CALL_VA_ARG_PACK;
2151 s->gsbase.subcode &= ~GF_CALL_VA_ARG_PACK;
2155 /* Return true if GIMPLE_CALL S is a stdarg call that needs the
2156 argument pack in its argument list. */
2159 gimple_call_va_arg_pack_p (gimple s)
2161 GIMPLE_CHECK (s, GIMPLE_CALL);
2162 return (s->gsbase.subcode & GF_CALL_VA_ARG_PACK) != 0;
2166 /* Return true if S is a noreturn call. */
2169 gimple_call_noreturn_p (gimple s)
2171 GIMPLE_CHECK (s, GIMPLE_CALL);
2172 return (gimple_call_flags (s) & ECF_NORETURN) != 0;
2176 /* Return true if S is a nothrow call. */
2179 gimple_call_nothrow_p (gimple s)
2181 GIMPLE_CHECK (s, GIMPLE_CALL);
2182 return (gimple_call_flags (s) & ECF_NOTHROW) != 0;
2186 /* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL. */
2189 gimple_call_copy_flags (gimple dest_call, gimple orig_call)
2191 GIMPLE_CHECK (dest_call, GIMPLE_CALL);
2192 GIMPLE_CHECK (orig_call, GIMPLE_CALL);
2193 dest_call->gsbase.subcode = orig_call->gsbase.subcode;
2197 /* Returns true if this is a GIMPLE_ASSIGN or a GIMPLE_CALL with a
2201 gimple_has_lhs (gimple stmt)
2203 return (is_gimple_assign (stmt)
2204 || (is_gimple_call (stmt)
2205 && gimple_call_lhs (stmt) != NULL_TREE));
2209 /* Return the code of the predicate computed by conditional statement GS. */
2211 static inline enum tree_code
2212 gimple_cond_code (const_gimple gs)
2214 GIMPLE_CHECK (gs, GIMPLE_COND);
2215 return (enum tree_code) gs->gsbase.subcode;
2219 /* Set CODE to be the predicate code for the conditional statement GS. */
2222 gimple_cond_set_code (gimple gs, enum tree_code code)
2224 GIMPLE_CHECK (gs, GIMPLE_COND);
2225 gcc_assert (TREE_CODE_CLASS (code) == tcc_comparison);
2226 gs->gsbase.subcode = code;
2230 /* Return the LHS of the predicate computed by conditional statement GS. */
2233 gimple_cond_lhs (const_gimple gs)
2235 GIMPLE_CHECK (gs, GIMPLE_COND);
2236 return gimple_op (gs, 0);
2239 /* Return the pointer to the LHS of the predicate computed by conditional
2242 static inline tree *
2243 gimple_cond_lhs_ptr (const_gimple gs)
2245 GIMPLE_CHECK (gs, GIMPLE_COND);
2246 return gimple_op_ptr (gs, 0);
2249 /* Set LHS to be the LHS operand of the predicate computed by
2250 conditional statement GS. */
2253 gimple_cond_set_lhs (gimple gs, tree lhs)
2255 GIMPLE_CHECK (gs, GIMPLE_COND);
2256 gcc_assert (is_gimple_operand (lhs));
2257 gimple_set_op (gs, 0, lhs);
2261 /* Return the RHS operand of the predicate computed by conditional GS. */
2264 gimple_cond_rhs (const_gimple gs)
2266 GIMPLE_CHECK (gs, GIMPLE_COND);
2267 return gimple_op (gs, 1);
2270 /* Return the pointer to the RHS operand of the predicate computed by
2273 static inline tree *
2274 gimple_cond_rhs_ptr (const_gimple gs)
2276 GIMPLE_CHECK (gs, GIMPLE_COND);
2277 return gimple_op_ptr (gs, 1);
2281 /* Set RHS to be the RHS operand of the predicate computed by
2282 conditional statement GS. */
2285 gimple_cond_set_rhs (gimple gs, tree rhs)
2287 GIMPLE_CHECK (gs, GIMPLE_COND);
2288 gcc_assert (is_gimple_operand (rhs));
2289 gimple_set_op (gs, 1, rhs);
2293 /* Return the label used by conditional statement GS when its
2294 predicate evaluates to true. */
2297 gimple_cond_true_label (const_gimple gs)
2299 GIMPLE_CHECK (gs, GIMPLE_COND);
2300 return gimple_op (gs, 2);
2304 /* Set LABEL to be the label used by conditional statement GS when its
2305 predicate evaluates to true. */
2308 gimple_cond_set_true_label (gimple gs, tree label)
2310 GIMPLE_CHECK (gs, GIMPLE_COND);
2311 gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
2312 gimple_set_op (gs, 2, label);
2316 /* Set LABEL to be the label used by conditional statement GS when its
2317 predicate evaluates to false. */
2320 gimple_cond_set_false_label (gimple gs, tree label)
2322 GIMPLE_CHECK (gs, GIMPLE_COND);
2323 gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
2324 gimple_set_op (gs, 3, label);
2328 /* Return the label used by conditional statement GS when its
2329 predicate evaluates to false. */
2332 gimple_cond_false_label (const_gimple gs)
2334 GIMPLE_CHECK (gs, GIMPLE_COND);
2335 return gimple_op (gs, 3);
2339 /* Set the conditional COND_STMT to be of the form 'if (1 == 0)'. */
2342 gimple_cond_make_false (gimple gs)
2344 gimple_cond_set_lhs (gs, boolean_true_node);
2345 gimple_cond_set_rhs (gs, boolean_false_node);
2346 gs->gsbase.subcode = EQ_EXPR;
2350 /* Set the conditional COND_STMT to be of the form 'if (1 == 1)'. */
2353 gimple_cond_make_true (gimple gs)
2355 gimple_cond_set_lhs (gs, boolean_true_node);
2356 gimple_cond_set_rhs (gs, boolean_true_node);
2357 gs->gsbase.subcode = EQ_EXPR;
2360 /* Check if conditional statemente GS is of the form 'if (1 == 1)',
2361 'if (0 == 0)', 'if (1 != 0)' or 'if (0 != 1)' */
2364 gimple_cond_true_p (const_gimple gs)
2366 tree lhs = gimple_cond_lhs (gs);
2367 tree rhs = gimple_cond_rhs (gs);
2368 enum tree_code code = gimple_cond_code (gs);
2370 if (lhs != boolean_true_node && lhs != boolean_false_node)
2373 if (rhs != boolean_true_node && rhs != boolean_false_node)
2376 if (code == NE_EXPR && lhs != rhs)
2379 if (code == EQ_EXPR && lhs == rhs)
2385 /* Check if conditional statement GS is of the form 'if (1 != 1)',
2386 'if (0 != 0)', 'if (1 == 0)' or 'if (0 == 1)' */
2389 gimple_cond_false_p (const_gimple gs)
2391 tree lhs = gimple_cond_lhs (gs);
2392 tree rhs = gimple_cond_rhs (gs);
2393 enum tree_code code = gimple_cond_code (gs);
2395 if (lhs != boolean_true_node && lhs != boolean_false_node)
2398 if (rhs != boolean_true_node && rhs != boolean_false_node)
2401 if (code == NE_EXPR && lhs == rhs)
2404 if (code == EQ_EXPR && lhs != rhs)
2410 /* Check if conditional statement GS is of the form 'if (var != 0)' or
2414 gimple_cond_single_var_p (gimple gs)
2416 if (gimple_cond_code (gs) == NE_EXPR
2417 && gimple_cond_rhs (gs) == boolean_false_node)
2420 if (gimple_cond_code (gs) == EQ_EXPR
2421 && gimple_cond_rhs (gs) == boolean_true_node)
2427 /* Set the code, LHS and RHS of GIMPLE_COND STMT from CODE, LHS and RHS. */
2430 gimple_cond_set_condition (gimple stmt, enum tree_code code, tree lhs, tree rhs)
2432 gimple_cond_set_code (stmt, code);
2433 gimple_cond_set_lhs (stmt, lhs);
2434 gimple_cond_set_rhs (stmt, rhs);
2437 /* Return the LABEL_DECL node used by GIMPLE_LABEL statement GS. */
2440 gimple_label_label (const_gimple gs)
2442 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2443 return gimple_op (gs, 0);
2447 /* Set LABEL to be the LABEL_DECL node used by GIMPLE_LABEL statement
2451 gimple_label_set_label (gimple gs, tree label)
2453 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2454 gcc_assert (TREE_CODE (label) == LABEL_DECL);
2455 gimple_set_op (gs, 0, label);
2459 /* Return the destination of the unconditional jump GS. */
2462 gimple_goto_dest (const_gimple gs)
2464 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2465 return gimple_op (gs, 0);
2469 /* Set DEST to be the destination of the unconditonal jump GS. */
2472 gimple_goto_set_dest (gimple gs, tree dest)
2474 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2475 gcc_assert (is_gimple_operand (dest));
2476 gimple_set_op (gs, 0, dest);
2480 /* Return the variables declared in the GIMPLE_BIND statement GS. */
2483 gimple_bind_vars (const_gimple gs)
2485 GIMPLE_CHECK (gs, GIMPLE_BIND);
2486 return gs->gimple_bind.vars;
2490 /* Set VARS to be the set of variables declared in the GIMPLE_BIND
2494 gimple_bind_set_vars (gimple gs, tree vars)
2496 GIMPLE_CHECK (gs, GIMPLE_BIND);
2497 gs->gimple_bind.vars = vars;
2501 /* Append VARS to the set of variables declared in the GIMPLE_BIND
2505 gimple_bind_append_vars (gimple gs, tree vars)
2507 GIMPLE_CHECK (gs, GIMPLE_BIND);
2508 gs->gimple_bind.vars = chainon (gs->gimple_bind.vars, vars);
2512 /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS. */
2514 static inline gimple_seq
2515 gimple_bind_body (gimple gs)
2517 GIMPLE_CHECK (gs, GIMPLE_BIND);
2518 return gs->gimple_bind.body;
2522 /* Set SEQ to be the GIMPLE sequence contained in the GIMPLE_BIND
2526 gimple_bind_set_body (gimple gs, gimple_seq seq)
2528 GIMPLE_CHECK (gs, GIMPLE_BIND);
2529 gs->gimple_bind.body = seq;
2533 /* Append a statement to the end of a GIMPLE_BIND's body. */
2536 gimple_bind_add_stmt (gimple gs, gimple stmt)
2538 GIMPLE_CHECK (gs, GIMPLE_BIND);
2539 gimple_seq_add_stmt (&gs->gimple_bind.body, stmt);
2543 /* Append a sequence of statements to the end of a GIMPLE_BIND's body. */
2546 gimple_bind_add_seq (gimple gs, gimple_seq seq)
2548 GIMPLE_CHECK (gs, GIMPLE_BIND);
2549 gimple_seq_add_seq (&gs->gimple_bind.body, seq);
2553 /* Return the TREE_BLOCK node associated with GIMPLE_BIND statement
2554 GS. This is analogous to the BIND_EXPR_BLOCK field in trees. */
2557 gimple_bind_block (const_gimple gs)
2559 GIMPLE_CHECK (gs, GIMPLE_BIND);
2560 return gs->gimple_bind.block;
2564 /* Set BLOCK to be the TREE_BLOCK node associated with GIMPLE_BIND
2568 gimple_bind_set_block (gimple gs, tree block)
2570 GIMPLE_CHECK (gs, GIMPLE_BIND);
2571 gcc_assert (block == NULL_TREE || TREE_CODE (block) == BLOCK);
2572 gs->gimple_bind.block = block;
2576 /* Return the number of input operands for GIMPLE_ASM GS. */
2578 static inline unsigned
2579 gimple_asm_ninputs (const_gimple gs)
2581 GIMPLE_CHECK (gs, GIMPLE_ASM);
2582 return gs->gimple_asm.ni;
2586 /* Return the number of output operands for GIMPLE_ASM GS. */
2588 static inline unsigned
2589 gimple_asm_noutputs (const_gimple gs)
2591 GIMPLE_CHECK (gs, GIMPLE_ASM);
2592 return gs->gimple_asm.no;
2596 /* Return the number of clobber operands for GIMPLE_ASM GS. */
2598 static inline unsigned
2599 gimple_asm_nclobbers (const_gimple gs)
2601 GIMPLE_CHECK (gs, GIMPLE_ASM);
2602 return gs->gimple_asm.nc;
2606 /* Return input operand INDEX of GIMPLE_ASM GS. */
2609 gimple_asm_input_op (const_gimple gs, unsigned index)
2611 GIMPLE_CHECK (gs, GIMPLE_ASM);
2612 gcc_assert (index <= gs->gimple_asm.ni);
2613 return gimple_op (gs, index);
2616 /* Return a pointer to input operand INDEX of GIMPLE_ASM GS. */
2618 static inline tree *
2619 gimple_asm_input_op_ptr (const_gimple gs, unsigned index)
2621 GIMPLE_CHECK (gs, GIMPLE_ASM);
2622 gcc_assert (index <= gs->gimple_asm.ni);
2623 return gimple_op_ptr (gs, index);
2627 /* Set IN_OP to be input operand INDEX in GIMPLE_ASM GS. */
2630 gimple_asm_set_input_op (gimple gs, unsigned index, tree in_op)
2632 GIMPLE_CHECK (gs, GIMPLE_ASM);
2633 gcc_assert (index <= gs->gimple_asm.ni);
2634 gcc_assert (TREE_CODE (in_op) == TREE_LIST);
2635 gimple_set_op (gs, index, in_op);
2639 /* Return output operand INDEX of GIMPLE_ASM GS. */
2642 gimple_asm_output_op (const_gimple gs, unsigned index)
2644 GIMPLE_CHECK (gs, GIMPLE_ASM);
2645 gcc_assert (index <= gs->gimple_asm.no);
2646 return gimple_op (gs, index + gs->gimple_asm.ni);
2649 /* Return a pointer to output operand INDEX of GIMPLE_ASM GS. */
2651 static inline tree *
2652 gimple_asm_output_op_ptr (const_gimple gs, unsigned index)
2654 GIMPLE_CHECK (gs, GIMPLE_ASM);
2655 gcc_assert (index <= gs->gimple_asm.no);
2656 return gimple_op_ptr (gs, index + gs->gimple_asm.ni);
2660 /* Set OUT_OP to be output operand INDEX in GIMPLE_ASM GS. */
2663 gimple_asm_set_output_op (gimple gs, unsigned index, tree out_op)
2665 GIMPLE_CHECK (gs, GIMPLE_ASM);
2666 gcc_assert (index <= gs->gimple_asm.no);
2667 gcc_assert (TREE_CODE (out_op) == TREE_LIST);
2668 gimple_set_op (gs, index + gs->gimple_asm.ni, out_op);
2672 /* Return clobber operand INDEX of GIMPLE_ASM GS. */
2675 gimple_asm_clobber_op (const_gimple gs, unsigned index)
2677 GIMPLE_CHECK (gs, GIMPLE_ASM);
2678 gcc_assert (index <= gs->gimple_asm.nc);
2679 return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no);
2683 /* Set CLOBBER_OP to be clobber operand INDEX in GIMPLE_ASM GS. */
2686 gimple_asm_set_clobber_op (gimple gs, unsigned index, tree clobber_op)
2688 GIMPLE_CHECK (gs, GIMPLE_ASM);
2689 gcc_assert (index <= gs->gimple_asm.nc);
2690 gcc_assert (TREE_CODE (clobber_op) == TREE_LIST);
2691 gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no, clobber_op);
2695 /* Return the string representing the assembly instruction in
2698 static inline const char *
2699 gimple_asm_string (const_gimple gs)
2701 GIMPLE_CHECK (gs, GIMPLE_ASM);
2702 return gs->gimple_asm.string;
2706 /* Return true if GS is an asm statement marked volatile. */
2709 gimple_asm_volatile_p (const_gimple gs)
2711 GIMPLE_CHECK (gs, GIMPLE_ASM);
2712 return (gs->gsbase.subcode & GF_ASM_VOLATILE) != 0;
2716 /* If VOLATLE_P is true, mark asm statement GS as volatile. */
2719 gimple_asm_set_volatile (gimple gs, bool volatile_p)
2721 GIMPLE_CHECK (gs, GIMPLE_ASM);
2723 gs->gsbase.subcode |= GF_ASM_VOLATILE;
2725 gs->gsbase.subcode &= ~GF_ASM_VOLATILE;
2729 /* If INPUT_P is true, mark asm GS as an ASM_INPUT. */
2732 gimple_asm_set_input (gimple gs, bool input_p)
2734 GIMPLE_CHECK (gs, GIMPLE_ASM);
2736 gs->gsbase.subcode |= GF_ASM_INPUT;
2738 gs->gsbase.subcode &= ~GF_ASM_INPUT;
2742 /* Return true if asm GS is an ASM_INPUT. */
2745 gimple_asm_input_p (const_gimple gs)
2747 GIMPLE_CHECK (gs, GIMPLE_ASM);
2748 return (gs->gsbase.subcode & GF_ASM_INPUT) != 0;
2752 /* Return the types handled by GIMPLE_CATCH statement GS. */
2755 gimple_catch_types (const_gimple gs)
2757 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2758 return gs->gimple_catch.types;
2762 /* Return a pointer to the types handled by GIMPLE_CATCH statement GS. */
2764 static inline tree *
2765 gimple_catch_types_ptr (gimple gs)
2767 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2768 return &gs->gimple_catch.types;
2772 /* Return the GIMPLE sequence representing the body of the handler of
2773 GIMPLE_CATCH statement GS. */
2775 static inline gimple_seq
2776 gimple_catch_handler (gimple gs)
2778 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2779 return gs->gimple_catch.handler;
2783 /* Return a pointer to the GIMPLE sequence representing the body of
2784 the handler of GIMPLE_CATCH statement GS. */
2786 static inline gimple_seq *
2787 gimple_catch_handler_ptr (gimple gs)
2789 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2790 return &gs->gimple_catch.handler;
2794 /* Set T to be the set of types handled by GIMPLE_CATCH GS. */
2797 gimple_catch_set_types (gimple gs, tree t)
2799 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2800 gs->gimple_catch.types = t;
2804 /* Set HANDLER to be the body of GIMPLE_CATCH GS. */
2807 gimple_catch_set_handler (gimple gs, gimple_seq handler)
2809 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2810 gs->gimple_catch.handler = handler;
2814 /* Return the types handled by GIMPLE_EH_FILTER statement GS. */
2817 gimple_eh_filter_types (const_gimple gs)
2819 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2820 return gs->gimple_eh_filter.types;
2824 /* Return a pointer to the types handled by GIMPLE_EH_FILTER statement
2827 static inline tree *
2828 gimple_eh_filter_types_ptr (gimple gs)
2830 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2831 return &gs->gimple_eh_filter.types;
2835 /* Return the sequence of statement to execute when GIMPLE_EH_FILTER
2838 static inline gimple_seq
2839 gimple_eh_filter_failure (gimple gs)
2841 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2842 return gs->gimple_eh_filter.failure;
2846 /* Set TYPES to be the set of types handled by GIMPLE_EH_FILTER GS. */
2849 gimple_eh_filter_set_types (gimple gs, tree types)
2851 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2852 gs->gimple_eh_filter.types = types;
2856 /* Set FAILURE to be the sequence of statements to execute on failure
2857 for GIMPLE_EH_FILTER GS. */
2860 gimple_eh_filter_set_failure (gimple gs, gimple_seq failure)
2862 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2863 gs->gimple_eh_filter.failure = failure;
2866 /* Return the EH_FILTER_MUST_NOT_THROW flag. */
2870 gimple_eh_filter_must_not_throw (gimple gs)
2872 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2873 return gs->gsbase.subcode != 0;
2876 /* Set the EH_FILTER_MUST_NOT_THROW flag to the value MNTP. */
2879 gimple_eh_filter_set_must_not_throw (gimple gs, bool mntp)
2881 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2882 gs->gsbase.subcode = (unsigned int) mntp;
2886 /* GIMPLE_TRY accessors. */
2888 /* Return the kind of try block represented by GIMPLE_TRY GS. This is
2889 either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY. */
2891 static inline enum gimple_try_flags
2892 gimple_try_kind (const_gimple gs)
2894 GIMPLE_CHECK (gs, GIMPLE_TRY);
2895 return (enum gimple_try_flags) (gs->gsbase.subcode & GIMPLE_TRY_KIND);
2899 /* Set the kind of try block represented by GIMPLE_TRY GS. */
2902 gimple_try_set_kind (gimple gs, enum gimple_try_flags kind)
2904 GIMPLE_CHECK (gs, GIMPLE_TRY);
2905 gcc_assert (kind == GIMPLE_TRY_CATCH || kind == GIMPLE_TRY_FINALLY);
2906 if (gimple_try_kind (gs) != kind)
2907 gs->gsbase.subcode = (unsigned int) kind;
2911 /* Return the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2914 gimple_try_catch_is_cleanup (const_gimple gs)
2916 gcc_assert (gimple_try_kind (gs) == GIMPLE_TRY_CATCH);
2917 return (gs->gsbase.subcode & GIMPLE_TRY_CATCH_IS_CLEANUP) != 0;
2921 /* Return the sequence of statements used as the body for GIMPLE_TRY GS. */
2923 static inline gimple_seq
2924 gimple_try_eval (gimple gs)
2926 GIMPLE_CHECK (gs, GIMPLE_TRY);
2927 return gs->gimple_try.eval;
2931 /* Return the sequence of statements used as the cleanup body for
2934 static inline gimple_seq
2935 gimple_try_cleanup (gimple gs)
2937 GIMPLE_CHECK (gs, GIMPLE_TRY);
2938 return gs->gimple_try.cleanup;
2942 /* Set the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2945 gimple_try_set_catch_is_cleanup (gimple g, bool catch_is_cleanup)
2947 gcc_assert (gimple_try_kind (g) == GIMPLE_TRY_CATCH);
2948 if (catch_is_cleanup)
2949 g->gsbase.subcode |= GIMPLE_TRY_CATCH_IS_CLEANUP;
2951 g->gsbase.subcode &= ~GIMPLE_TRY_CATCH_IS_CLEANUP;
2955 /* Set EVAL to be the sequence of statements to use as the body for
2959 gimple_try_set_eval (gimple gs, gimple_seq eval)
2961 GIMPLE_CHECK (gs, GIMPLE_TRY);
2962 gs->gimple_try.eval = eval;
2966 /* Set CLEANUP to be the sequence of statements to use as the cleanup
2967 body for GIMPLE_TRY GS. */
2970 gimple_try_set_cleanup (gimple gs, gimple_seq cleanup)
2972 GIMPLE_CHECK (gs, GIMPLE_TRY);
2973 gs->gimple_try.cleanup = cleanup;
2977 /* Return the cleanup sequence for cleanup statement GS. */
2979 static inline gimple_seq
2980 gimple_wce_cleanup (gimple gs)
2982 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
2983 return gs->gimple_wce.cleanup;
2987 /* Set CLEANUP to be the cleanup sequence for GS. */
2990 gimple_wce_set_cleanup (gimple gs, gimple_seq cleanup)
2992 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
2993 gs->gimple_wce.cleanup = cleanup;
2997 /* Return the CLEANUP_EH_ONLY flag for a WCE tuple. */
3000 gimple_wce_cleanup_eh_only (const_gimple gs)
3002 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3003 return gs->gsbase.subcode != 0;
3007 /* Set the CLEANUP_EH_ONLY flag for a WCE tuple. */
3010 gimple_wce_set_cleanup_eh_only (gimple gs, bool eh_only_p)
3012 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3013 gs->gsbase.subcode = (unsigned int) eh_only_p;
3017 /* Return the maximum number of arguments supported by GIMPLE_PHI GS. */
3019 static inline unsigned
3020 gimple_phi_capacity (const_gimple gs)
3022 GIMPLE_CHECK (gs, GIMPLE_PHI);
3023 return gs->gimple_phi.capacity;
3027 /* Return the number of arguments in GIMPLE_PHI GS. This must always
3028 be exactly the number of incoming edges for the basic block holding
3031 static inline unsigned
3032 gimple_phi_num_args (const_gimple gs)
3034 GIMPLE_CHECK (gs, GIMPLE_PHI);
3035 return gs->gimple_phi.nargs;
3039 /* Return the SSA name created by GIMPLE_PHI GS. */
3042 gimple_phi_result (const_gimple gs)
3044 GIMPLE_CHECK (gs, GIMPLE_PHI);
3045 return gs->gimple_phi.result;
3048 /* Return a pointer to the SSA name created by GIMPLE_PHI GS. */
3050 static inline tree *
3051 gimple_phi_result_ptr (gimple gs)
3053 GIMPLE_CHECK (gs, GIMPLE_PHI);
3054 return &gs->gimple_phi.result;
3057 /* Set RESULT to be the SSA name created by GIMPLE_PHI GS. */
3060 gimple_phi_set_result (gimple gs, tree result)
3062 GIMPLE_CHECK (gs, GIMPLE_PHI);
3063 gs->gimple_phi.result = result;
3067 /* Return the PHI argument corresponding to incoming edge INDEX for
3070 static inline struct phi_arg_d *
3071 gimple_phi_arg (gimple gs, unsigned index)
3073 GIMPLE_CHECK (gs, GIMPLE_PHI);
3074 gcc_assert (index <= gs->gimple_phi.capacity);
3075 return &(gs->gimple_phi.args[index]);
3078 /* Set PHIARG to be the argument corresponding to incoming edge INDEX
3079 for GIMPLE_PHI GS. */
3082 gimple_phi_set_arg (gimple gs, unsigned index, struct phi_arg_d * phiarg)
3084 GIMPLE_CHECK (gs, GIMPLE_PHI);
3085 gcc_assert (index <= gs->gimple_phi.nargs);
3086 memcpy (gs->gimple_phi.args + index, phiarg, sizeof (struct phi_arg_d));
3089 /* Return the region number for GIMPLE_RESX GS. */
3092 gimple_resx_region (const_gimple gs)
3094 GIMPLE_CHECK (gs, GIMPLE_RESX);
3095 return gs->gimple_resx.region;
3098 /* Set REGION to be the region number for GIMPLE_RESX GS. */
3101 gimple_resx_set_region (gimple gs, int region)
3103 GIMPLE_CHECK (gs, GIMPLE_RESX);
3104 gs->gimple_resx.region = region;
3108 /* Return the number of labels associated with the switch statement GS. */
3110 static inline unsigned
3111 gimple_switch_num_labels (const_gimple gs)
3114 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3115 num_ops = gimple_num_ops (gs);
3116 gcc_assert (num_ops > 1);
3121 /* Set NLABELS to be the number of labels for the switch statement GS. */
3124 gimple_switch_set_num_labels (gimple g, unsigned nlabels)
3126 GIMPLE_CHECK (g, GIMPLE_SWITCH);
3127 gimple_set_num_ops (g, nlabels + 1);
3131 /* Return the index variable used by the switch statement GS. */
3134 gimple_switch_index (const_gimple gs)
3136 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3137 return gimple_op (gs, 0);
3141 /* Return a pointer to the index variable for the switch statement GS. */
3143 static inline tree *
3144 gimple_switch_index_ptr (const_gimple gs)
3146 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3147 return gimple_op_ptr (gs, 0);
3151 /* Set INDEX to be the index variable for switch statement GS. */
3154 gimple_switch_set_index (gimple gs, tree index)
3156 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3157 gcc_assert (SSA_VAR_P (index) || CONSTANT_CLASS_P (index));
3158 gimple_set_op (gs, 0, index);
3162 /* Return the label numbered INDEX. The default label is 0, followed by any
3163 labels in a switch statement. */
3166 gimple_switch_label (const_gimple gs, unsigned index)
3168 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3169 gcc_assert (gimple_num_ops (gs) > index + 1);
3170 return gimple_op (gs, index + 1);
3173 /* Set the label number INDEX to LABEL. 0 is always the default label. */
3176 gimple_switch_set_label (gimple gs, unsigned index, tree label)
3178 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3179 gcc_assert (gimple_num_ops (gs) > index + 1);
3180 gcc_assert (label == NULL_TREE || TREE_CODE (label) == CASE_LABEL_EXPR);
3181 gimple_set_op (gs, index + 1, label);
3184 /* Return the default label for a switch statement. */
3187 gimple_switch_default_label (const_gimple gs)
3189 return gimple_switch_label (gs, 0);
3192 /* Set the default label for a switch statement. */
3195 gimple_switch_set_default_label (gimple gs, tree label)
3197 gimple_switch_set_label (gs, 0, label);
3200 /* Return true if GS is a GIMPLE_DEBUG statement. */
3203 is_gimple_debug (const_gimple gs)
3205 return gimple_code (gs) == GIMPLE_DEBUG;
3208 /* Return true if S is a GIMPLE_DEBUG BIND statement. */
3211 gimple_debug_bind_p (const_gimple s)
3213 if (is_gimple_debug (s))
3214 return s->gsbase.subcode == GIMPLE_DEBUG_BIND;
3219 /* Return the variable bound in a GIMPLE_DEBUG bind statement. */
3222 gimple_debug_bind_get_var (gimple dbg)
3224 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3225 gcc_assert (gimple_debug_bind_p (dbg));
3226 return gimple_op (dbg, 0);
3229 /* Return the value bound to the variable in a GIMPLE_DEBUG bind
3233 gimple_debug_bind_get_value (gimple dbg)
3235 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3236 gcc_assert (gimple_debug_bind_p (dbg));
3237 return gimple_op (dbg, 1);
3240 /* Return a pointer to the value bound to the variable in a
3241 GIMPLE_DEBUG bind statement. */
3243 static inline tree *
3244 gimple_debug_bind_get_value_ptr (gimple dbg)
3246 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3247 gcc_assert (gimple_debug_bind_p (dbg));
3248 return gimple_op_ptr (dbg, 1);
3251 /* Set the variable bound in a GIMPLE_DEBUG bind statement. */
3254 gimple_debug_bind_set_var (gimple dbg, tree var)
3256 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3257 gcc_assert (gimple_debug_bind_p (dbg));
3258 gimple_set_op (dbg, 0, var);
3261 /* Set the value bound to the variable in a GIMPLE_DEBUG bind
3265 gimple_debug_bind_set_value (gimple dbg, tree value)
3267 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3268 gcc_assert (gimple_debug_bind_p (dbg));
3269 gimple_set_op (dbg, 1, value);
3272 /* The second operand of a GIMPLE_DEBUG_BIND, when the value was
3274 #define GIMPLE_DEBUG_BIND_NOVALUE NULL_TREE /* error_mark_node */
3276 /* Remove the value bound to the variable in a GIMPLE_DEBUG bind
3280 gimple_debug_bind_reset_value (gimple dbg)
3282 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3283 gcc_assert (gimple_debug_bind_p (dbg));
3284 gimple_set_op (dbg, 1, GIMPLE_DEBUG_BIND_NOVALUE);
3287 /* Return true if the GIMPLE_DEBUG bind statement is bound to a
3291 gimple_debug_bind_has_value_p (gimple dbg)
3293 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3294 gcc_assert (gimple_debug_bind_p (dbg));
3295 return gimple_op (dbg, 1) != GIMPLE_DEBUG_BIND_NOVALUE;
3298 #undef GIMPLE_DEBUG_BIND_NOVALUE
3300 /* Return the body for the OMP statement GS. */
3302 static inline gimple_seq
3303 gimple_omp_body (gimple gs)
3305 return gs->omp.body;
3308 /* Set BODY to be the body for the OMP statement GS. */
3311 gimple_omp_set_body (gimple gs, gimple_seq body)
3313 gs->omp.body = body;
3317 /* Return the name associated with OMP_CRITICAL statement GS. */
3320 gimple_omp_critical_name (const_gimple gs)
3322 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3323 return gs->gimple_omp_critical.name;
3327 /* Return a pointer to the name associated with OMP critical statement GS. */
3329 static inline tree *
3330 gimple_omp_critical_name_ptr (gimple gs)
3332 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3333 return &gs->gimple_omp_critical.name;
3337 /* Set NAME to be the name associated with OMP critical statement GS. */
3340 gimple_omp_critical_set_name (gimple gs, tree name)
3342 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3343 gs->gimple_omp_critical.name = name;
3347 /* Return the clauses associated with OMP_FOR GS. */
3350 gimple_omp_for_clauses (const_gimple gs)
3352 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3353 return gs->gimple_omp_for.clauses;
3357 /* Return a pointer to the OMP_FOR GS. */
3359 static inline tree *
3360 gimple_omp_for_clauses_ptr (gimple gs)
3362 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3363 return &gs->gimple_omp_for.clauses;
3367 /* Set CLAUSES to be the list of clauses associated with OMP_FOR GS. */
3370 gimple_omp_for_set_clauses (gimple gs, tree clauses)
3372 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3373 gs->gimple_omp_for.clauses = clauses;
3377 /* Get the collapse count of OMP_FOR GS. */
3379 static inline size_t
3380 gimple_omp_for_collapse (gimple gs)
3382 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3383 return gs->gimple_omp_for.collapse;
3387 /* Return the index variable for OMP_FOR GS. */
3390 gimple_omp_for_index (const_gimple gs, size_t i)
3392 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3393 gcc_assert (i < gs->gimple_omp_for.collapse);
3394 return gs->gimple_omp_for.iter[i].index;
3398 /* Return a pointer to the index variable for OMP_FOR GS. */
3400 static inline tree *
3401 gimple_omp_for_index_ptr (gimple gs, size_t i)
3403 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3404 gcc_assert (i < gs->gimple_omp_for.collapse);
3405 return &gs->gimple_omp_for.iter[i].index;
3409 /* Set INDEX to be the index variable for OMP_FOR GS. */
3412 gimple_omp_for_set_index (gimple gs, size_t i, tree index)
3414 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3415 gcc_assert (i < gs->gimple_omp_for.collapse);
3416 gs->gimple_omp_for.iter[i].index = index;
3420 /* Return the initial value for OMP_FOR GS. */
3423 gimple_omp_for_initial (const_gimple gs, size_t i)
3425 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3426 gcc_assert (i < gs->gimple_omp_for.collapse);
3427 return gs->gimple_omp_for.iter[i].initial;
3431 /* Return a pointer to the initial value for OMP_FOR GS. */
3433 static inline tree *
3434 gimple_omp_for_initial_ptr (gimple gs, size_t i)
3436 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3437 gcc_assert (i < gs->gimple_omp_for.collapse);
3438 return &gs->gimple_omp_for.iter[i].initial;
3442 /* Set INITIAL to be the initial value for OMP_FOR GS. */
3445 gimple_omp_for_set_initial (gimple gs, size_t i, tree initial)
3447 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3448 gcc_assert (i < gs->gimple_omp_for.collapse);
3449 gs->gimple_omp_for.iter[i].initial = initial;
3453 /* Return the final value for OMP_FOR GS. */
3456 gimple_omp_for_final (const_gimple gs, size_t i)
3458 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3459 gcc_assert (i < gs->gimple_omp_for.collapse);
3460 return gs->gimple_omp_for.iter[i].final;
3464 /* Return a pointer to the final value for OMP_FOR GS. */
3466 static inline tree *
3467 gimple_omp_for_final_ptr (gimple gs, size_t i)
3469 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3470 gcc_assert (i < gs->gimple_omp_for.collapse);
3471 return &gs->gimple_omp_for.iter[i].final;
3475 /* Set FINAL to be the final value for OMP_FOR GS. */
3478 gimple_omp_for_set_final (gimple gs, size_t i, tree final)
3480 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3481 gcc_assert (i < gs->gimple_omp_for.collapse);
3482 gs->gimple_omp_for.iter[i].final = final;
3486 /* Return the increment value for OMP_FOR GS. */
3489 gimple_omp_for_incr (const_gimple gs, size_t i)
3491 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3492 gcc_assert (i < gs->gimple_omp_for.collapse);
3493 return gs->gimple_omp_for.iter[i].incr;
3497 /* Return a pointer to the increment value for OMP_FOR GS. */
3499 static inline tree *
3500 gimple_omp_for_incr_ptr (gimple gs, size_t i)
3502 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3503 gcc_assert (i < gs->gimple_omp_for.collapse);
3504 return &gs->gimple_omp_for.iter[i].incr;
3508 /* Set INCR to be the increment value for OMP_FOR GS. */
3511 gimple_omp_for_set_incr (gimple gs, size_t i, tree incr)
3513 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3514 gcc_assert (i < gs->gimple_omp_for.collapse);
3515 gs->gimple_omp_for.iter[i].incr = incr;
3519 /* Return the sequence of statements to execute before the OMP_FOR
3520 statement GS starts. */
3522 static inline gimple_seq
3523 gimple_omp_for_pre_body (gimple gs)
3525 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3526 return gs->gimple_omp_for.pre_body;
3530 /* Set PRE_BODY to be the sequence of statements to execute before the
3531 OMP_FOR statement GS starts. */
3534 gimple_omp_for_set_pre_body (gimple gs, gimple_seq pre_body)
3536 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3537 gs->gimple_omp_for.pre_body = pre_body;
3541 /* Return the clauses associated with OMP_PARALLEL GS. */
3544 gimple_omp_parallel_clauses (const_gimple gs)
3546 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3547 return gs->gimple_omp_parallel.clauses;
3551 /* Return a pointer to the clauses associated with OMP_PARALLEL GS. */
3553 static inline tree *
3554 gimple_omp_parallel_clauses_ptr (gimple gs)
3556 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3557 return &gs->gimple_omp_parallel.clauses;
3561 /* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL
3565 gimple_omp_parallel_set_clauses (gimple gs, tree clauses)
3567 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3568 gs->gimple_omp_parallel.clauses = clauses;
3572 /* Return the child function used to hold the body of OMP_PARALLEL GS. */
3575 gimple_omp_parallel_child_fn (const_gimple gs)
3577 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3578 return gs->gimple_omp_parallel.child_fn;
3581 /* Return a pointer to the child function used to hold the body of
3584 static inline tree *
3585 gimple_omp_parallel_child_fn_ptr (gimple gs)
3587 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3588 return &gs->gimple_omp_parallel.child_fn;
3592 /* Set CHILD_FN to be the child function for OMP_PARALLEL GS. */
3595 gimple_omp_parallel_set_child_fn (gimple gs, tree child_fn)
3597 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3598 gs->gimple_omp_parallel.child_fn = child_fn;
3602 /* Return the artificial argument used to send variables and values
3603 from the parent to the children threads in OMP_PARALLEL GS. */
3606 gimple_omp_parallel_data_arg (const_gimple gs)
3608 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3609 return gs->gimple_omp_parallel.data_arg;
3613 /* Return a pointer to the data argument for OMP_PARALLEL GS. */
3615 static inline tree *
3616 gimple_omp_parallel_data_arg_ptr (gimple gs)
3618 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3619 return &gs->gimple_omp_parallel.data_arg;
3623 /* Set DATA_ARG to be the data argument for OMP_PARALLEL GS. */
3626 gimple_omp_parallel_set_data_arg (gimple gs, tree data_arg)
3628 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3629 gs->gimple_omp_parallel.data_arg = data_arg;
3633 /* Return the clauses associated with OMP_TASK GS. */
3636 gimple_omp_task_clauses (const_gimple gs)
3638 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3639 return gs->gimple_omp_parallel.clauses;
3643 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3645 static inline tree *
3646 gimple_omp_task_clauses_ptr (gimple gs)
3648 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3649 return &gs->gimple_omp_parallel.clauses;
3653 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3657 gimple_omp_task_set_clauses (gimple gs, tree clauses)
3659 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3660 gs->gimple_omp_parallel.clauses = clauses;
3664 /* Return the child function used to hold the body of OMP_TASK GS. */
3667 gimple_omp_task_child_fn (const_gimple gs)
3669 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3670 return gs->gimple_omp_parallel.child_fn;
3673 /* Return a pointer to the child function used to hold the body of
3676 static inline tree *
3677 gimple_omp_task_child_fn_ptr (gimple gs)
3679 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3680 return &gs->gimple_omp_parallel.child_fn;
3684 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3687 gimple_omp_task_set_child_fn (gimple gs, tree child_fn)
3689 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3690 gs->gimple_omp_parallel.child_fn = child_fn;
3694 /* Return the artificial argument used to send variables and values
3695 from the parent to the children threads in OMP_TASK GS. */
3698 gimple_omp_task_data_arg (const_gimple gs)
3700 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3701 return gs->gimple_omp_parallel.data_arg;
3705 /* Return a pointer to the data argument for OMP_TASK GS. */
3707 static inline tree *
3708 gimple_omp_task_data_arg_ptr (gimple gs)
3710 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3711 return &gs->gimple_omp_parallel.data_arg;
3715 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3718 gimple_omp_task_set_data_arg (gimple gs, tree data_arg)
3720 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3721 gs->gimple_omp_parallel.data_arg = data_arg;
3725 /* Return the clauses associated with OMP_TASK GS. */
3728 gimple_omp_taskreg_clauses (const_gimple gs)
3730 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3731 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3732 return gs->gimple_omp_parallel.clauses;
3736 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3738 static inline tree *
3739 gimple_omp_taskreg_clauses_ptr (gimple gs)
3741 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3742 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3743 return &gs->gimple_omp_parallel.clauses;
3747 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3751 gimple_omp_taskreg_set_clauses (gimple gs, tree clauses)
3753 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3754 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3755 gs->gimple_omp_parallel.clauses = clauses;
3759 /* Return the child function used to hold the body of OMP_TASK GS. */
3762 gimple_omp_taskreg_child_fn (const_gimple gs)
3764 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3765 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3766 return gs->gimple_omp_parallel.child_fn;
3769 /* Return a pointer to the child function used to hold the body of
3772 static inline tree *
3773 gimple_omp_taskreg_child_fn_ptr (gimple gs)
3775 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3776 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3777 return &gs->gimple_omp_parallel.child_fn;
3781 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3784 gimple_omp_taskreg_set_child_fn (gimple gs, tree child_fn)
3786 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3787 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3788 gs->gimple_omp_parallel.child_fn = child_fn;
3792 /* Return the artificial argument used to send variables and values
3793 from the parent to the children threads in OMP_TASK GS. */
3796 gimple_omp_taskreg_data_arg (const_gimple gs)
3798 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3799 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3800 return gs->gimple_omp_parallel.data_arg;
3804 /* Return a pointer to the data argument for OMP_TASK GS. */
3806 static inline tree *
3807 gimple_omp_taskreg_data_arg_ptr (gimple gs)
3809 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3810 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3811 return &gs->gimple_omp_parallel.data_arg;
3815 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3818 gimple_omp_taskreg_set_data_arg (gimple gs, tree data_arg)
3820 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3821 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3822 gs->gimple_omp_parallel.data_arg = data_arg;
3826 /* Return the copy function used to hold the body of OMP_TASK GS. */
3829 gimple_omp_task_copy_fn (const_gimple gs)
3831 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3832 return gs->gimple_omp_task.copy_fn;
3835 /* Return a pointer to the copy function used to hold the body of
3838 static inline tree *
3839 gimple_omp_task_copy_fn_ptr (gimple gs)
3841 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3842 return &gs->gimple_omp_task.copy_fn;
3846 /* Set CHILD_FN to be the copy function for OMP_TASK GS. */
3849 gimple_omp_task_set_copy_fn (gimple gs, tree copy_fn)
3851 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3852 gs->gimple_omp_task.copy_fn = copy_fn;
3856 /* Return size of the data block in bytes in OMP_TASK GS. */
3859 gimple_omp_task_arg_size (const_gimple gs)
3861 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3862 return gs->gimple_omp_task.arg_size;
3866 /* Return a pointer to the data block size for OMP_TASK GS. */
3868 static inline tree *
3869 gimple_omp_task_arg_size_ptr (gimple gs)
3871 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3872 return &gs->gimple_omp_task.arg_size;
3876 /* Set ARG_SIZE to be the data block size for OMP_TASK GS. */
3879 gimple_omp_task_set_arg_size (gimple gs, tree arg_size)
3881 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3882 gs->gimple_omp_task.arg_size = arg_size;
3886 /* Return align of the data block in bytes in OMP_TASK GS. */
3889 gimple_omp_task_arg_align (const_gimple gs)
3891 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3892 return gs->gimple_omp_task.arg_align;
3896 /* Return a pointer to the data block align for OMP_TASK GS. */
3898 static inline tree *
3899 gimple_omp_task_arg_align_ptr (gimple gs)
3901 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3902 return &gs->gimple_omp_task.arg_align;
3906 /* Set ARG_SIZE to be the data block align for OMP_TASK GS. */
3909 gimple_omp_task_set_arg_align (gimple gs, tree arg_align)
3911 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3912 gs->gimple_omp_task.arg_align = arg_align;
3916 /* Return the clauses associated with OMP_SINGLE GS. */
3919 gimple_omp_single_clauses (const_gimple gs)
3921 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3922 return gs->gimple_omp_single.clauses;
3926 /* Return a pointer to the clauses associated with OMP_SINGLE GS. */
3928 static inline tree *
3929 gimple_omp_single_clauses_ptr (gimple gs)
3931 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3932 return &gs->gimple_omp_single.clauses;
3936 /* Set CLAUSES to be the clauses associated with OMP_SINGLE GS. */
3939 gimple_omp_single_set_clauses (gimple gs, tree clauses)
3941 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3942 gs->gimple_omp_single.clauses = clauses;
3946 /* Return the clauses associated with OMP_SECTIONS GS. */
3949 gimple_omp_sections_clauses (const_gimple gs)
3951 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3952 return gs->gimple_omp_sections.clauses;
3956 /* Return a pointer to the clauses associated with OMP_SECTIONS GS. */
3958 static inline tree *
3959 gimple_omp_sections_clauses_ptr (gimple gs)
3961 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3962 return &gs->gimple_omp_sections.clauses;
3966 /* Set CLAUSES to be the set of clauses associated with OMP_SECTIONS
3970 gimple_omp_sections_set_clauses (gimple gs, tree clauses)
3972 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3973 gs->gimple_omp_sections.clauses = clauses;
3977 /* Return the control variable associated with the GIMPLE_OMP_SECTIONS
3981 gimple_omp_sections_control (const_gimple gs)
3983 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3984 return gs->gimple_omp_sections.control;
3988 /* Return a pointer to the clauses associated with the GIMPLE_OMP_SECTIONS
3991 static inline tree *
3992 gimple_omp_sections_control_ptr (gimple gs)
3994 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3995 return &gs->gimple_omp_sections.control;
3999 /* Set CONTROL to be the set of clauses associated with the
4000 GIMPLE_OMP_SECTIONS in GS. */
4003 gimple_omp_sections_set_control (gimple gs, tree control)
4005 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4006 gs->gimple_omp_sections.control = control;
4010 /* Set COND to be the condition code for OMP_FOR GS. */
4013 gimple_omp_for_set_cond (gimple gs, size_t i, enum tree_code cond)
4015 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4016 gcc_assert (TREE_CODE_CLASS (cond) == tcc_comparison);
4017 gcc_assert (i < gs->gimple_omp_for.collapse);
4018 gs->gimple_omp_for.iter[i].cond = cond;
4022 /* Return the condition code associated with OMP_FOR GS. */
4024 static inline enum tree_code
4025 gimple_omp_for_cond (const_gimple gs, size_t i)
4027 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4028 gcc_assert (i < gs->gimple_omp_for.collapse);
4029 return gs->gimple_omp_for.iter[i].cond;
4033 /* Set the value being stored in an atomic store. */
4036 gimple_omp_atomic_store_set_val (gimple g, tree val)
4038 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4039 g->gimple_omp_atomic_store.val = val;
4043 /* Return the value being stored in an atomic store. */
4046 gimple_omp_atomic_store_val (const_gimple g)
4048 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4049 return g->gimple_omp_atomic_store.val;
4053 /* Return a pointer to the value being stored in an atomic store. */
4055 static inline tree *
4056 gimple_omp_atomic_store_val_ptr (gimple g)
4058 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4059 return &g->gimple_omp_atomic_store.val;
4063 /* Set the LHS of an atomic load. */
4066 gimple_omp_atomic_load_set_lhs (gimple g, tree lhs)
4068 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4069 g->gimple_omp_atomic_load.lhs = lhs;
4073 /* Get the LHS of an atomic load. */
4076 gimple_omp_atomic_load_lhs (const_gimple g)
4078 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4079 return g->gimple_omp_atomic_load.lhs;
4083 /* Return a pointer to the LHS of an atomic load. */
4085 static inline tree *
4086 gimple_omp_atomic_load_lhs_ptr (gimple g)
4088 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4089 return &g->gimple_omp_atomic_load.lhs;
4093 /* Set the RHS of an atomic load. */
4096 gimple_omp_atomic_load_set_rhs (gimple g, tree rhs)
4098 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4099 g->gimple_omp_atomic_load.rhs = rhs;
4103 /* Get the RHS of an atomic load. */
4106 gimple_omp_atomic_load_rhs (const_gimple g)
4108 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4109 return g->gimple_omp_atomic_load.rhs;
4113 /* Return a pointer to the RHS of an atomic load. */
4115 static inline tree *
4116 gimple_omp_atomic_load_rhs_ptr (gimple g)
4118 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4119 return &g->gimple_omp_atomic_load.rhs;
4123 /* Get the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4126 gimple_omp_continue_control_def (const_gimple g)
4128 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4129 return g->gimple_omp_continue.control_def;
4132 /* The same as above, but return the address. */
4134 static inline tree *
4135 gimple_omp_continue_control_def_ptr (gimple g)
4137 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4138 return &g->gimple_omp_continue.control_def;
4141 /* Set the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4144 gimple_omp_continue_set_control_def (gimple g, tree def)
4146 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4147 g->gimple_omp_continue.control_def = def;
4151 /* Get the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4154 gimple_omp_continue_control_use (const_gimple g)
4156 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4157 return g->gimple_omp_continue.control_use;
4161 /* The same as above, but return the address. */
4163 static inline tree *
4164 gimple_omp_continue_control_use_ptr (gimple g)
4166 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4167 return &g->gimple_omp_continue.control_use;
4171 /* Set the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4174 gimple_omp_continue_set_control_use (gimple g, tree use)
4176 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4177 g->gimple_omp_continue.control_use = use;
4181 /* Return a pointer to the return value for GIMPLE_RETURN GS. */
4183 static inline tree *
4184 gimple_return_retval_ptr (const_gimple gs)
4186 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4187 gcc_assert (gimple_num_ops (gs) == 1);
4188 return gimple_op_ptr (gs, 0);
4191 /* Return the return value for GIMPLE_RETURN GS. */
4194 gimple_return_retval (const_gimple gs)
4196 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4197 gcc_assert (gimple_num_ops (gs) == 1);
4198 return gimple_op (gs, 0);
4202 /* Set RETVAL to be the return value for GIMPLE_RETURN GS. */
4205 gimple_return_set_retval (gimple gs, tree retval)
4207 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4208 gcc_assert (gimple_num_ops (gs) == 1);
4209 gcc_assert (retval == NULL_TREE
4210 || TREE_CODE (retval) == RESULT_DECL
4211 || is_gimple_val (retval));
4212 gimple_set_op (gs, 0, retval);
4216 /* Returns true when the gimple statment STMT is any of the OpenMP types. */
4218 #define CASE_GIMPLE_OMP \
4219 case GIMPLE_OMP_PARALLEL: \
4220 case GIMPLE_OMP_TASK: \
4221 case GIMPLE_OMP_FOR: \
4222 case GIMPLE_OMP_SECTIONS: \
4223 case GIMPLE_OMP_SECTIONS_SWITCH: \
4224 case GIMPLE_OMP_SINGLE: \
4225 case GIMPLE_OMP_SECTION: \
4226 case GIMPLE_OMP_MASTER: \
4227 case GIMPLE_OMP_ORDERED: \
4228 case GIMPLE_OMP_CRITICAL: \
4229 case GIMPLE_OMP_RETURN: \
4230 case GIMPLE_OMP_ATOMIC_LOAD: \
4231 case GIMPLE_OMP_ATOMIC_STORE: \
4232 case GIMPLE_OMP_CONTINUE
4235 is_gimple_omp (const_gimple stmt)
4237 switch (gimple_code (stmt))
4247 /* Returns TRUE if statement G is a GIMPLE_NOP. */
4250 gimple_nop_p (const_gimple g)
4252 return gimple_code (g) == GIMPLE_NOP;
4256 /* Return the predictor of GIMPLE_PREDICT statement GS. */
4258 static inline enum br_predictor
4259 gimple_predict_predictor (gimple gs)
4261 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4262 return (enum br_predictor) (gs->gsbase.subcode & ~GF_PREDICT_TAKEN);
4266 /* Set the predictor of GIMPLE_PREDICT statement GS to PREDICT. */
4269 gimple_predict_set_predictor (gimple gs, enum br_predictor predictor)
4271 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4272 gs->gsbase.subcode = (gs->gsbase.subcode & GF_PREDICT_TAKEN)
4273 | (unsigned) predictor;
4277 /* Return the outcome of GIMPLE_PREDICT statement GS. */
4279 static inline enum prediction
4280 gimple_predict_outcome (gimple gs)
4282 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4283 return (gs->gsbase.subcode & GF_PREDICT_TAKEN) ? TAKEN : NOT_TAKEN;
4287 /* Set the outcome of GIMPLE_PREDICT statement GS to OUTCOME. */
4290 gimple_predict_set_outcome (gimple gs, enum prediction outcome)
4292 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4293 if (outcome == TAKEN)
4294 gs->gsbase.subcode |= GF_PREDICT_TAKEN;
4296 gs->gsbase.subcode &= ~GF_PREDICT_TAKEN;
4300 /* Return the type of the main expression computed by STMT. Return
4301 void_type_node if the statement computes nothing. */
4304 gimple_expr_type (const_gimple stmt)
4306 enum gimple_code code = gimple_code (stmt);
4308 if (code == GIMPLE_ASSIGN || code == GIMPLE_CALL)
4311 /* In general we want to pass out a type that can be substituted
4312 for both the RHS and the LHS types if there is a possibly
4313 useless conversion involved. That means returning the
4314 original RHS type as far as we can reconstruct it. */
4315 if (code == GIMPLE_CALL)
4316 type = gimple_call_return_type (stmt);
4318 switch (gimple_assign_rhs_code (stmt))
4320 case POINTER_PLUS_EXPR:
4321 type = TREE_TYPE (gimple_assign_rhs1 (stmt));
4325 /* As fallback use the type of the LHS. */
4326 type = TREE_TYPE (gimple_get_lhs (stmt));
4331 else if (code == GIMPLE_COND)
4332 return boolean_type_node;
4334 return void_type_node;
4338 /* Return a new iterator pointing to GIMPLE_SEQ's first statement. */
4340 static inline gimple_stmt_iterator
4341 gsi_start (gimple_seq seq)
4343 gimple_stmt_iterator i;
4345 i.ptr = gimple_seq_first (seq);
4347 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4353 /* Return a new iterator pointing to the first statement in basic block BB. */
4355 static inline gimple_stmt_iterator
4356 gsi_start_bb (basic_block bb)
4358 gimple_stmt_iterator i;
4362 i.ptr = gimple_seq_first (seq);
4370 /* Return a new iterator initially pointing to GIMPLE_SEQ's last statement. */
4372 static inline gimple_stmt_iterator
4373 gsi_last (gimple_seq seq)
4375 gimple_stmt_iterator i;
4377 i.ptr = gimple_seq_last (seq);
4379 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4385 /* Return a new iterator pointing to the last statement in basic block BB. */
4387 static inline gimple_stmt_iterator
4388 gsi_last_bb (basic_block bb)
4390 gimple_stmt_iterator i;
4394 i.ptr = gimple_seq_last (seq);
4402 /* Return true if I is at the end of its sequence. */
4405 gsi_end_p (gimple_stmt_iterator i)
4407 return i.ptr == NULL;
4411 /* Return true if I is one statement before the end of its sequence. */
4414 gsi_one_before_end_p (gimple_stmt_iterator i)
4416 return i.ptr != NULL && i.ptr->next == NULL;
4420 /* Advance the iterator to the next gimple statement. */
4423 gsi_next (gimple_stmt_iterator *i)
4425 i->ptr = i->ptr->next;
4428 /* Advance the iterator to the previous gimple statement. */
4431 gsi_prev (gimple_stmt_iterator *i)
4433 i->ptr = i->ptr->prev;
4436 /* Return the current stmt. */
4438 static inline gimple
4439 gsi_stmt (gimple_stmt_iterator i)
4444 /* Return a block statement iterator that points to the first non-label
4445 statement in block BB. */
4447 static inline gimple_stmt_iterator
4448 gsi_after_labels (basic_block bb)
4450 gimple_stmt_iterator gsi = gsi_start_bb (bb);
4452 while (!gsi_end_p (gsi) && gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL)
4458 /* Advance the iterator to the next non-debug gimple statement. */
4461 gsi_next_nondebug (gimple_stmt_iterator *i)
4467 while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
4470 /* Advance the iterator to the next non-debug gimple statement. */
4473 gsi_prev_nondebug (gimple_stmt_iterator *i)
4479 while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
4482 /* Return a new iterator pointing to the first non-debug statement in
4485 static inline gimple_stmt_iterator
4486 gsi_start_nondebug_bb (basic_block bb)
4488 gimple_stmt_iterator i = gsi_start_bb (bb);
4490 if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
4491 gsi_next_nondebug (&i);
4496 /* Return a new iterator pointing to the last non-debug statement in
4499 static inline gimple_stmt_iterator
4500 gsi_last_nondebug_bb (basic_block bb)
4502 gimple_stmt_iterator i = gsi_last_bb (bb);
4504 if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
4505 gsi_prev_nondebug (&i);
4510 /* Return a pointer to the current stmt.
4512 NOTE: You may want to use gsi_replace on the iterator itself,
4513 as this performs additional bookkeeping that will not be done
4514 if you simply assign through a pointer returned by gsi_stmt_ptr. */
4516 static inline gimple *
4517 gsi_stmt_ptr (gimple_stmt_iterator *i)
4519 return &i->ptr->stmt;
4523 /* Return the basic block associated with this iterator. */
4525 static inline basic_block
4526 gsi_bb (gimple_stmt_iterator i)
4532 /* Return the sequence associated with this iterator. */
4534 static inline gimple_seq
4535 gsi_seq (gimple_stmt_iterator i)
4541 enum gsi_iterator_update
4543 GSI_NEW_STMT, /* Only valid when single statement is added, move
4545 GSI_SAME_STMT, /* Leave the iterator at the same statement. */
4546 GSI_CONTINUE_LINKING /* Move iterator to whatever position is suitable
4547 for linking other statements in the same
4551 /* In gimple-iterator.c */
4552 gimple_stmt_iterator gsi_start_phis (basic_block);
4553 gimple_seq gsi_split_seq_after (gimple_stmt_iterator);
4554 gimple_seq gsi_split_seq_before (gimple_stmt_iterator *);
4555 void gsi_replace (gimple_stmt_iterator *, gimple, bool);
4556 void gsi_insert_before (gimple_stmt_iterator *, gimple,
4557 enum gsi_iterator_update);
4558 void gsi_insert_before_without_update (gimple_stmt_iterator *, gimple,
4559 enum gsi_iterator_update);
4560 void gsi_insert_seq_before (gimple_stmt_iterator *, gimple_seq,
4561 enum gsi_iterator_update);
4562 void gsi_insert_seq_before_without_update (gimple_stmt_iterator *, gimple_seq,
4563 enum gsi_iterator_update);
4564 void gsi_insert_after (gimple_stmt_iterator *, gimple,
4565 enum gsi_iterator_update);
4566 void gsi_insert_after_without_update (gimple_stmt_iterator *, gimple,
4567 enum gsi_iterator_update);
4568 void gsi_insert_seq_after (gimple_stmt_iterator *, gimple_seq,
4569 enum gsi_iterator_update);
4570 void gsi_insert_seq_after_without_update (gimple_stmt_iterator *, gimple_seq,
4571 enum gsi_iterator_update);
4572 void gsi_remove (gimple_stmt_iterator *, bool);
4573 gimple_stmt_iterator gsi_for_stmt (gimple);
4574 void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *);
4575 void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *);
4576 void gsi_move_to_bb_end (gimple_stmt_iterator *, struct basic_block_def *);
4577 void gsi_insert_on_edge (edge, gimple);
4578 void gsi_insert_seq_on_edge (edge, gimple_seq);
4579 basic_block gsi_insert_on_edge_immediate (edge, gimple);
4580 basic_block gsi_insert_seq_on_edge_immediate (edge, gimple_seq);
4581 void gsi_commit_one_edge_insert (edge, basic_block *);
4582 void gsi_commit_edge_inserts (void);
4583 gimple gimple_call_copy_skip_args (gimple, bitmap);
4586 /* Convenience routines to walk all statements of a gimple function.
4587 Note that this is useful exclusively before the code is converted
4588 into SSA form. Once the program is in SSA form, the standard
4589 operand interface should be used to analyze/modify statements. */
4590 struct walk_stmt_info
4592 /* Points to the current statement being walked. */
4593 gimple_stmt_iterator gsi;
4595 /* Additional data that the callback functions may want to carry
4596 through the recursion. */
4599 /* Pointer map used to mark visited tree nodes when calling
4600 walk_tree on each operand. If set to NULL, duplicate tree nodes
4601 will be visited more than once. */
4602 struct pointer_set_t *pset;
4604 /* Indicates whether the operand being examined may be replaced
4605 with something that matches is_gimple_val (if true) or something
4606 slightly more complicated (if false). "Something" technically
4607 means the common subset of is_gimple_lvalue and is_gimple_rhs,
4608 but we never try to form anything more complicated than that, so
4609 we don't bother checking.
4611 Also note that CALLBACK should update this flag while walking the
4612 sub-expressions of a statement. For instance, when walking the
4613 statement 'foo (&var)', the flag VAL_ONLY will initially be set
4614 to true, however, when walking &var, the operand of that
4615 ADDR_EXPR does not need to be a GIMPLE value. */
4618 /* True if we are currently walking the LHS of an assignment. */
4621 /* Optional. Set to true by the callback functions if they made any
4625 /* True if we're interested in location information. */
4626 bool want_locations;
4628 /* Operand returned by the callbacks. This is set when calling
4629 walk_gimple_seq. If the walk_stmt_fn or walk_tree_fn callback
4630 returns non-NULL, this field will contain the tree returned by
4631 the last callback. */
4632 tree callback_result;
4635 /* Callback for walk_gimple_stmt. Called for every statement found
4636 during traversal. The first argument points to the statement to
4637 walk. The second argument is a flag that the callback sets to
4638 'true' if it the callback handled all the operands and
4639 sub-statements of the statement (the default value of this flag is
4640 'false'). The third argument is an anonymous pointer to data
4641 to be used by the callback. */
4642 typedef tree (*walk_stmt_fn) (gimple_stmt_iterator *, bool *,
4643 struct walk_stmt_info *);
4645 gimple walk_gimple_seq (gimple_seq, walk_stmt_fn, walk_tree_fn,
4646 struct walk_stmt_info *);
4647 tree walk_gimple_stmt (gimple_stmt_iterator *, walk_stmt_fn, walk_tree_fn,
4648 struct walk_stmt_info *);
4649 tree walk_gimple_op (gimple, walk_tree_fn, struct walk_stmt_info *);
4651 #ifdef GATHER_STATISTICS
4652 /* Enum and arrays used for allocation stats. Keep in sync with
4653 gimple.c:gimple_alloc_kind_names. */
4654 enum gimple_alloc_kind
4656 gimple_alloc_kind_assign, /* Assignments. */
4657 gimple_alloc_kind_phi, /* PHI nodes. */
4658 gimple_alloc_kind_cond, /* Conditionals. */
4659 gimple_alloc_kind_seq, /* Sequences. */
4660 gimple_alloc_kind_rest, /* Everything else. */
4661 gimple_alloc_kind_all
4664 extern int gimple_alloc_counts[];
4665 extern int gimple_alloc_sizes[];
4667 /* Return the allocation kind for a given stmt CODE. */
4668 static inline enum gimple_alloc_kind
4669 gimple_alloc_kind (enum gimple_code code)
4674 return gimple_alloc_kind_assign;
4676 return gimple_alloc_kind_phi;
4678 return gimple_alloc_kind_cond;
4680 return gimple_alloc_kind_rest;
4683 #endif /* GATHER_STATISTICS */
4685 extern void dump_gimple_statistics (void);
4687 #endif /* GCC_GIMPLE_H */