1 /* Gimple IR definitions.
3 Copyright 2007, 2008 Free Software Foundation, Inc.
4 Contributed by Aldy Hernandez <aldyh@redhat.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
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 DEF_VEC_P(gimple_seq);
38 DEF_VEC_ALLOC_P(gimple_seq,gc);
39 DEF_VEC_ALLOC_P(gimple_seq,heap);
42 #define DEFGSCODE(SYM, STRING, STRUCT) SYM,
45 LAST_AND_UNUSED_GIMPLE_CODE
48 extern const char *const gimple_code_name[];
49 extern const unsigned char gimple_rhs_class_table[];
51 /* Error out if a gimple tuple is addressed incorrectly. */
52 #if defined ENABLE_GIMPLE_CHECKING
53 extern void gimple_check_failed (const_gimple, const char *, int, \
54 const char *, enum gimple_code, \
55 enum tree_code) ATTRIBUTE_NORETURN;
56 extern void gimple_range_check_failed (const_gimple, const char *, int, \
57 const char *, enum gimple_code, \
58 enum gimple_code) ATTRIBUTE_NORETURN;
60 #define GIMPLE_CHECK(GS, CODE) \
62 const_gimple __gs = (GS); \
63 if (gimple_code (__gs) != (CODE)) \
64 gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__, \
67 #else /* not ENABLE_GIMPLE_CHECKING */
68 #define GIMPLE_CHECK(GS, CODE) (void)0
71 /* Class of GIMPLE expressions suitable for the RHS of assignments. See
72 get_gimple_rhs_class. */
75 GIMPLE_INVALID_RHS, /* The expression cannot be used on the RHS. */
76 GIMPLE_BINARY_RHS, /* The expression is a binary operation. */
77 GIMPLE_UNARY_RHS, /* The expression is a unary operation. */
78 GIMPLE_SINGLE_RHS /* The expression is a single object (an SSA
79 name, a _DECL, a _REF, etc. */
82 /* Specific flags for individual GIMPLE statements. These flags are
83 always stored in gimple_statement_base.subcode and they may only be
84 defined for statement codes that do not use sub-codes.
86 Values for the masks can overlap as long as the overlapping values
87 are never used in the same statement class.
89 The maximum mask value that can be defined is 1 << 15 (i.e., each
90 statement code can hold up to 16 bitflags).
92 Keep this list sorted. */
94 GF_ASM_INPUT = 1 << 0,
95 GF_ASM_VOLATILE = 1 << 1,
96 GF_CALL_CANNOT_INLINE = 1 << 0,
97 GF_CALL_FROM_THUNK = 1 << 1,
98 GF_CALL_RETURN_SLOT_OPT = 1 << 2,
99 GF_CALL_TAILCALL = 1 << 3,
100 GF_CALL_VA_ARG_PACK = 1 << 4,
101 GF_OMP_PARALLEL_COMBINED = 1 << 0,
103 /* True on an GIMPLE_OMP_RETURN statement if the return does not require
104 a thread synchronization via some sort of barrier. The exact barrier
105 that would otherwise be emitted is dependent on the OMP statement with
106 which this return is associated. */
107 GF_OMP_RETURN_NOWAIT = 1 << 0,
109 GF_OMP_SECTION_LAST = 1 << 0,
110 GF_PREDICT_TAKEN = 1 << 15
113 /* Masks for selecting a pass local flag (PLF) to work on. These
114 masks are used by gimple_set_plf and gimple_plf. */
120 /* A node in a gimple_seq_d. */
121 struct gimple_seq_node_d GTY((chain_next ("%h.next"), chain_prev ("%h.prev")))
124 struct gimple_seq_node_d *prev;
125 struct gimple_seq_node_d *next;
128 /* A double-linked sequence of gimple statements. */
129 struct gimple_seq_d GTY ((chain_next ("%h.next_free")))
131 /* First and last statements in the sequence. */
132 gimple_seq_node first;
133 gimple_seq_node last;
135 /* Sequences are created/destroyed frequently. To minimize
136 allocation activity, deallocated sequences are kept in a pool of
137 available sequences. This is the pointer to the next free
138 sequence in the pool. */
139 gimple_seq next_free;
143 /* Return the first node in GIMPLE sequence S. */
145 static inline gimple_seq_node
146 gimple_seq_first (const_gimple_seq s)
148 return s ? s->first : NULL;
152 /* Return the first statement in GIMPLE sequence S. */
155 gimple_seq_first_stmt (const_gimple_seq s)
157 gimple_seq_node n = gimple_seq_first (s);
158 return (n) ? n->stmt : NULL;
162 /* Return the last node in GIMPLE sequence S. */
164 static inline gimple_seq_node
165 gimple_seq_last (const_gimple_seq s)
167 return s ? s->last : NULL;
171 /* Return the last statement in GIMPLE sequence S. */
174 gimple_seq_last_stmt (const_gimple_seq s)
176 gimple_seq_node n = gimple_seq_last (s);
177 return (n) ? n->stmt : NULL;
181 /* Set the last node in GIMPLE sequence S to LAST. */
184 gimple_seq_set_last (gimple_seq s, gimple_seq_node last)
190 /* Set the first node in GIMPLE sequence S to FIRST. */
193 gimple_seq_set_first (gimple_seq s, gimple_seq_node first)
199 /* Return true if GIMPLE sequence S is empty. */
202 gimple_seq_empty_p (const_gimple_seq s)
204 return s == NULL || s->first == NULL;
208 void gimple_seq_add_stmt (gimple_seq *, gimple);
210 /* Allocate a new sequence and initialize its first element with STMT. */
212 static inline gimple_seq
213 gimple_seq_alloc_with_stmt (gimple stmt)
215 gimple_seq seq = NULL;
216 gimple_seq_add_stmt (&seq, stmt);
221 /* Returns the sequence of statements in BB. */
223 static inline gimple_seq
224 bb_seq (const_basic_block bb)
226 return (!(bb->flags & BB_RTL) && bb->il.gimple) ? bb->il.gimple->seq : NULL;
230 /* Sets the sequence of statements in BB to SEQ. */
233 set_bb_seq (basic_block bb, gimple_seq seq)
235 gcc_assert (!(bb->flags & BB_RTL));
236 bb->il.gimple->seq = seq;
239 /* Iterator object for GIMPLE statement sequences. */
243 /* Sequence node holding the current statement. */
246 /* Sequence and basic block holding the statement. These fields
247 are necessary to handle edge cases such as when statement is
248 added to an empty basic block or when the last statement of a
249 block/sequence is removed. */
252 } gimple_stmt_iterator;
255 /* Data structure definitions for GIMPLE tuples. NOTE: word markers
256 are for 64 bit hosts. */
258 struct gimple_statement_base GTY(())
261 Main identifying code for a tuple. */
262 ENUM_BITFIELD(gimple_code) code : 8;
264 /* Nonzero if a warning should not be emitted on this tuple. */
265 unsigned int no_warning : 1;
267 /* Nonzero if this tuple has been visited. Passes are responsible
268 for clearing this bit before using it. */
269 unsigned int visited : 1;
271 /* Nonzero if this tuple represents a non-temporal move. */
272 unsigned int nontemporal_move : 1;
274 /* Pass local flags. These flags are free for any pass to use as
275 they see fit. Passes should not assume that these flags contain
276 any useful value when the pass starts. Any initial state that
277 the pass requires should be set on entry to the pass. See
278 gimple_set_plf and gimple_plf for usage. */
279 unsigned int plf : 2;
281 /* Nonzero if this statement has been modified and needs to have its
282 operands rescanned. */
283 unsigned modified : 1;
285 /* Nonzero if this statement contains volatile operands. */
286 unsigned has_volatile_ops : 1;
288 /* Nonzero if this statement contains memory refernces. */
289 unsigned references_memory_p : 1;
291 /* The SUBCODE field can be used for tuple-specific flags for tuples
292 that do not require subcodes. Note that SUBCODE should be at
293 least as wide as tree codes, as several tuples store tree codes
295 unsigned int subcode : 16;
297 /* UID of this statement. */
301 Locus information for debug info. */
304 /* Number of operands in this tuple. */
308 Basic block holding this statement. */
309 struct basic_block_def *bb;
312 Lexical block holding this statement. */
317 /* Base structure for tuples with operands. */
319 struct gimple_statement_with_ops_base GTY(())
322 struct gimple_statement_base gsbase;
325 Symbols whose addresses are taken by this statement (i.e., they
326 appear inside ADDR_EXPR nodes). */
327 bitmap GTY((skip (""))) addresses_taken;
330 SSA operand vectors. NOTE: It should be possible to
331 amalgamate these vectors with the operand vector OP. However,
332 the SSA operand vectors are organized differently and contain
333 more information (like immediate use chaining). */
334 struct def_optype_d GTY((skip (""))) *def_ops;
335 struct use_optype_d GTY((skip (""))) *use_ops;
339 /* Statements that take register operands. */
341 struct gimple_statement_with_ops GTY(())
344 struct gimple_statement_with_ops_base opbase;
347 Operand vector. NOTE! This must always be the last field
348 of this structure. In particular, this means that this
349 structure cannot be embedded inside another one. */
350 tree GTY((length ("%h.opbase.gsbase.num_ops"))) op[1];
354 /* Base for statements that take both memory and register operands. */
356 struct gimple_statement_with_memory_ops_base GTY(())
359 struct gimple_statement_with_ops_base opbase;
362 Vectors for virtual operands. */
363 struct voptype_d GTY((skip (""))) *vdef_ops;
364 struct voptype_d GTY((skip (""))) *vuse_ops;
367 Symbols stored/loaded by this statement. */
368 bitmap GTY((skip (""))) stores;
369 bitmap GTY((skip (""))) loads;
373 /* Statements that take both memory and register operands. */
375 struct gimple_statement_with_memory_ops GTY(())
378 struct gimple_statement_with_memory_ops_base membase;
381 Operand vector. NOTE! This must always be the last field
382 of this structure. In particular, this means that this
383 structure cannot be embedded inside another one. */
384 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
388 /* OpenMP statements (#pragma omp). */
390 struct gimple_statement_omp GTY(())
393 struct gimple_statement_base gsbase;
402 struct gimple_statement_bind GTY(())
405 struct gimple_statement_base gsbase;
408 Variables declared in this scope. */
412 This is different than the BLOCK field in gimple_statement_base,
413 which is analogous to TREE_BLOCK (i.e., the lexical block holding
414 this statement). This field is the equivalent of BIND_EXPR_BLOCK
415 in tree land (i.e., the lexical scope defined by this bind). See
426 struct gimple_statement_catch GTY(())
429 struct gimple_statement_base gsbase;
439 /* GIMPLE_EH_FILTER */
441 struct gimple_statement_eh_filter GTY(())
444 struct gimple_statement_base gsbase;
446 /* Subcode: EH_FILTER_MUST_NOT_THROW. A boolean flag analogous to
447 the tree counterpart. */
461 struct gimple_statement_phi GTY(())
464 struct gimple_statement_base gsbase;
474 struct phi_arg_d GTY ((length ("%h.nargs"))) args[1];
480 struct gimple_statement_resx GTY(())
483 struct gimple_statement_base gsbase;
486 Exception region number. */
493 struct gimple_statement_try GTY(())
496 struct gimple_statement_base gsbase;
499 Expression to evaluate. */
503 Cleanup expression. */
507 /* Kind of GIMPLE_TRY statements. */
508 enum gimple_try_flags
511 GIMPLE_TRY_CATCH = 1 << 0,
514 GIMPLE_TRY_FINALLY = 1 << 1,
515 GIMPLE_TRY_KIND = GIMPLE_TRY_CATCH | GIMPLE_TRY_FINALLY,
517 /* Analogous to TRY_CATCH_IS_CLEANUP. */
518 GIMPLE_TRY_CATCH_IS_CLEANUP = 1 << 2
521 /* GIMPLE_WITH_CLEANUP_EXPR */
523 struct gimple_statement_wce GTY(())
526 struct gimple_statement_base gsbase;
528 /* Subcode: CLEANUP_EH_ONLY. True if the cleanup should only be
529 executed if an exception is thrown, not on normal exit of its
530 scope. This flag is analogous to the CLEANUP_EH_ONLY flag
534 Cleanup expression. */
541 struct gimple_statement_asm GTY(())
544 struct gimple_statement_with_memory_ops_base membase;
547 __asm__ statement. */
551 Number of inputs, outputs and clobbers. */
557 Operand vector. NOTE! This must always be the last field
558 of this structure. In particular, this means that this
559 structure cannot be embedded inside another one. */
560 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
563 /* GIMPLE_OMP_CRITICAL */
565 struct gimple_statement_omp_critical GTY(())
568 struct gimple_statement_omp omp;
571 Critical section name. */
576 struct gimple_omp_for_iter GTY(())
578 /* Condition code. */
581 /* Index variable. */
596 struct gimple_statement_omp_for GTY(())
599 struct gimple_statement_omp omp;
605 Number of elements in iter array. */
609 struct gimple_omp_for_iter * GTY((length ("%h.collapse"))) iter;
612 Pre-body evaluated before the loop body begins. */
617 /* GIMPLE_OMP_PARALLEL */
619 struct gimple_statement_omp_parallel GTY(())
622 struct gimple_statement_omp omp;
629 Child function holding the body of the parallel region. */
633 Shared data argument. */
638 /* GIMPLE_OMP_TASK */
640 struct gimple_statement_omp_task GTY(())
643 struct gimple_statement_omp_parallel par;
646 Child function holding firstprivate initialization if needed. */
650 Size and alignment in bytes of the argument data block. */
656 /* GIMPLE_OMP_SECTION */
657 /* Uses struct gimple_statement_omp. */
660 /* GIMPLE_OMP_SECTIONS */
662 struct gimple_statement_omp_sections GTY(())
665 struct gimple_statement_omp omp;
671 The control variable used for deciding which of the sections to
676 /* GIMPLE_OMP_CONTINUE.
678 Note: This does not inherit from gimple_statement_omp, because we
679 do not need the body field. */
681 struct gimple_statement_omp_continue GTY(())
684 struct gimple_statement_base gsbase;
693 /* GIMPLE_OMP_SINGLE */
695 struct gimple_statement_omp_single GTY(())
698 struct gimple_statement_omp omp;
705 /* GIMPLE_OMP_ATOMIC_LOAD.
706 Note: This is based on gimple_statement_base, not g_s_omp, because g_s_omp
707 contains a sequence, which we don't need here. */
709 struct gimple_statement_omp_atomic_load GTY(())
712 struct gimple_statement_base gsbase;
718 /* GIMPLE_OMP_ATOMIC_STORE.
719 See note on GIMPLE_OMP_ATOMIC_LOAD. */
721 struct gimple_statement_omp_atomic_store GTY(())
724 struct gimple_statement_base gsbase;
730 enum gimple_statement_structure_enum {
731 #define DEFGSSTRUCT(SYM, STRING) SYM,
732 #include "gsstruct.def"
738 /* Define the overall contents of a gimple tuple. It may be any of the
739 structures declared above for various types of tuples. */
741 union gimple_statement_d GTY ((desc ("gimple_statement_structure (&%h)")))
743 struct gimple_statement_base GTY ((tag ("GSS_BASE"))) gsbase;
744 struct gimple_statement_with_ops GTY ((tag ("GSS_WITH_OPS"))) gsops;
745 struct gimple_statement_with_memory_ops GTY ((tag ("GSS_WITH_MEM_OPS"))) gsmem;
746 struct gimple_statement_omp GTY ((tag ("GSS_OMP"))) omp;
747 struct gimple_statement_bind GTY ((tag ("GSS_BIND"))) gimple_bind;
748 struct gimple_statement_catch GTY ((tag ("GSS_CATCH"))) gimple_catch;
749 struct gimple_statement_eh_filter GTY ((tag ("GSS_EH_FILTER"))) gimple_eh_filter;
750 struct gimple_statement_phi GTY ((tag ("GSS_PHI"))) gimple_phi;
751 struct gimple_statement_resx GTY ((tag ("GSS_RESX"))) gimple_resx;
752 struct gimple_statement_try GTY ((tag ("GSS_TRY"))) gimple_try;
753 struct gimple_statement_wce GTY ((tag ("GSS_WCE"))) gimple_wce;
754 struct gimple_statement_asm GTY ((tag ("GSS_ASM"))) gimple_asm;
755 struct gimple_statement_omp_critical GTY ((tag ("GSS_OMP_CRITICAL"))) gimple_omp_critical;
756 struct gimple_statement_omp_for GTY ((tag ("GSS_OMP_FOR"))) gimple_omp_for;
757 struct gimple_statement_omp_parallel GTY ((tag ("GSS_OMP_PARALLEL"))) gimple_omp_parallel;
758 struct gimple_statement_omp_task GTY ((tag ("GSS_OMP_TASK"))) gimple_omp_task;
759 struct gimple_statement_omp_sections GTY ((tag ("GSS_OMP_SECTIONS"))) gimple_omp_sections;
760 struct gimple_statement_omp_single GTY ((tag ("GSS_OMP_SINGLE"))) gimple_omp_single;
761 struct gimple_statement_omp_continue GTY ((tag ("GSS_OMP_CONTINUE"))) gimple_omp_continue;
762 struct gimple_statement_omp_atomic_load GTY ((tag ("GSS_OMP_ATOMIC_LOAD"))) gimple_omp_atomic_load;
763 struct gimple_statement_omp_atomic_store GTY ((tag ("GSS_OMP_ATOMIC_STORE"))) gimple_omp_atomic_store;
767 gimple gimple_build_return (tree);
769 gimple gimple_build_assign_stat (tree, tree MEM_STAT_DECL);
770 #define gimple_build_assign(l,r) gimple_build_assign_stat (l, r MEM_STAT_INFO)
772 void extract_ops_from_tree (tree, enum tree_code *, tree *, tree *);
774 gimple gimple_build_assign_with_ops_stat (enum tree_code, tree, tree,
776 #define gimple_build_assign_with_ops(c,o1,o2,o3) \
777 gimple_build_assign_with_ops_stat (c, o1, o2, o3 MEM_STAT_INFO)
779 gimple gimple_build_call_vec (tree, VEC(tree, heap) *);
780 gimple gimple_build_call (tree, unsigned, ...);
781 gimple gimple_build_call_from_tree (tree);
782 gimple gimplify_assign (tree, tree, gimple_seq *);
783 gimple gimple_build_cond (enum tree_code, tree, tree, tree, tree);
784 gimple gimple_build_label (tree label);
785 gimple gimple_build_goto (tree dest);
786 gimple gimple_build_nop (void);
787 gimple gimple_build_bind (tree, gimple_seq, tree);
788 gimple gimple_build_asm (const char *, unsigned, unsigned, unsigned, ...);
789 gimple gimple_build_asm_vec (const char *, VEC(tree,gc) *, VEC(tree,gc) *,
791 gimple gimple_build_catch (tree, gimple_seq);
792 gimple gimple_build_eh_filter (tree, gimple_seq);
793 gimple gimple_build_try (gimple_seq, gimple_seq, unsigned int);
794 gimple gimple_build_wce (gimple_seq);
795 gimple gimple_build_resx (int);
796 gimple gimple_build_switch (unsigned, tree, tree, ...);
797 gimple gimple_build_switch_vec (tree, tree, VEC(tree,heap) *);
798 gimple gimple_build_omp_parallel (gimple_seq, tree, tree, tree);
799 gimple gimple_build_omp_task (gimple_seq, tree, tree, tree, tree, tree, tree);
800 gimple gimple_build_omp_for (gimple_seq, tree, size_t, gimple_seq);
801 gimple gimple_build_omp_critical (gimple_seq, tree);
802 gimple gimple_build_omp_section (gimple_seq);
803 gimple gimple_build_omp_continue (tree, tree);
804 gimple gimple_build_omp_master (gimple_seq);
805 gimple gimple_build_omp_return (bool);
806 gimple gimple_build_omp_ordered (gimple_seq);
807 gimple gimple_build_omp_sections (gimple_seq, tree);
808 gimple gimple_build_omp_sections_switch (void);
809 gimple gimple_build_omp_single (gimple_seq, tree);
810 gimple gimple_build_cdt (tree, tree);
811 gimple gimple_build_omp_atomic_load (tree, tree);
812 gimple gimple_build_omp_atomic_store (tree);
813 gimple gimple_build_predict (enum br_predictor, enum prediction);
814 enum gimple_statement_structure_enum gimple_statement_structure (gimple);
815 enum gimple_statement_structure_enum gss_for_assign (enum tree_code);
816 void sort_case_labels (VEC(tree,heap) *);
817 void gimple_set_body (tree, gimple_seq);
818 gimple_seq gimple_body (tree);
819 gimple_seq gimple_seq_alloc (void);
820 void gimple_seq_free (gimple_seq);
821 void gimple_seq_add_seq (gimple_seq *, gimple_seq);
822 gimple_seq gimple_seq_copy (gimple_seq);
823 int gimple_call_flags (const_gimple);
824 bool gimple_assign_copy_p (gimple);
825 bool gimple_assign_ssa_name_copy_p (gimple);
826 bool gimple_assign_single_p (gimple);
827 bool gimple_assign_unary_nop_p (gimple);
828 void gimple_set_bb (gimple, struct basic_block_def *);
829 tree gimple_fold (const_gimple);
830 void gimple_assign_set_rhs_from_tree (gimple_stmt_iterator *, tree);
831 void gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *, enum tree_code,
833 tree gimple_get_lhs (const_gimple);
834 void gimple_set_lhs (gimple, tree);
835 gimple gimple_copy (gimple);
836 bool is_gimple_operand (const_tree);
837 void gimple_set_modified (gimple, bool);
838 void gimple_cond_get_ops_from_tree (tree, enum tree_code *, tree *, tree *);
839 gimple gimple_build_cond_from_tree (tree, tree, tree);
840 void gimple_cond_set_condition_from_tree (gimple, tree);
841 bool gimple_has_side_effects (const_gimple);
842 bool gimple_rhs_has_side_effects (const_gimple);
843 bool gimple_could_trap_p (gimple);
844 bool gimple_assign_rhs_could_trap_p (gimple);
845 void gimple_regimplify_operands (gimple, gimple_stmt_iterator *);
846 bool empty_body_p (gimple_seq);
847 unsigned get_gimple_rhs_num_ops (enum tree_code);
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 if T is a GIMPLE temporary variable, false otherwise. */
857 extern bool is_gimple_formal_tmp_var (tree);
858 /* Returns true if T is a GIMPLE temporary register variable. */
859 extern bool is_gimple_formal_tmp_reg (tree);
860 /* Returns true iff T is any sort of variable. */
861 extern bool is_gimple_variable (tree);
862 /* Returns true iff T is any sort of symbol. */
863 extern bool is_gimple_id (tree);
864 /* Returns true iff T is a variable or an INDIRECT_REF (of a variable). */
865 extern bool is_gimple_min_lval (tree);
866 /* Returns true iff T is something whose address can be taken. */
867 extern bool is_gimple_addressable (tree);
868 /* Returns true iff T is any valid GIMPLE lvalue. */
869 extern bool is_gimple_lvalue (tree);
871 /* Returns true iff T is a GIMPLE address. */
872 bool is_gimple_address (const_tree);
873 /* Returns true iff T is a GIMPLE invariant address. */
874 bool is_gimple_invariant_address (const_tree);
875 /* Returns true iff T is a valid GIMPLE constant. */
876 bool is_gimple_constant (const_tree);
877 /* Returns true iff T is a GIMPLE restricted function invariant. */
878 extern bool is_gimple_min_invariant (const_tree);
879 /* Returns true iff T is a GIMPLE rvalue. */
880 extern bool is_gimple_val (tree);
881 /* Returns true iff T is a GIMPLE asm statement input. */
882 extern bool is_gimple_asm_val (tree);
883 /* Returns true iff T is a valid rhs for a MODIFY_EXPR where the LHS is a
884 GIMPLE temporary, a renamed user variable, or something else,
886 extern bool is_gimple_formal_tmp_rhs (tree);
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);
906 extern tree create_tmp_var_raw (tree, const char *);
907 extern tree create_tmp_var_name (const char *);
908 extern tree create_tmp_var (tree, const char *);
909 extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq *);
910 extern tree get_formal_tmp_var (tree, gimple_seq *);
911 extern void declare_vars (tree, gimple, bool);
912 extern void tree_annotate_all_with_location (tree *, location_t);
913 extern void annotate_all_with_location (gimple_seq, location_t);
915 /* Validation of GIMPLE expressions. Note that these predicates only check
916 the basic form of the expression, they don't recurse to make sure that
917 underlying nodes are also of the right form. */
918 typedef bool (*gimple_predicate)(tree);
921 /* FIXME we should deduce this from the predicate. */
922 typedef enum fallback_t {
923 fb_none = 0, /* Do not generate a temporary. */
925 fb_rvalue = 1, /* Generate an rvalue to hold the result of a
926 gimplified expression. */
928 fb_lvalue = 2, /* Generate an lvalue to hold the result of a
929 gimplified expression. */
931 fb_mayfail = 4, /* Gimplification may fail. Error issued
933 fb_either= fb_rvalue | fb_lvalue
936 enum gimplify_status {
937 GS_ERROR = -2, /* Something Bad Seen. */
938 GS_UNHANDLED = -1, /* A langhook result for "I dunno". */
939 GS_OK = 0, /* We did something, maybe more to do. */
940 GS_ALL_DONE = 1 /* The expression is fully gimplified. */
945 struct gimplify_ctx *prev_context;
947 VEC(gimple,heap) *bind_expr_stack;
949 gimple_seq conditional_cleanups;
953 VEC(tree,heap) *case_labels;
954 /* The formal temporary table. Should this be persistent? */
960 bool allow_rhs_cond_expr;
963 extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *,
964 bool (*) (tree), fallback_t);
965 extern void gimplify_type_sizes (tree, gimple_seq *);
966 extern void gimplify_one_sizepos (tree *, gimple_seq *);
967 extern bool gimplify_stmt (tree *, gimple_seq *);
968 extern gimple gimplify_body (tree *, tree, bool);
969 extern void push_gimplify_context (struct gimplify_ctx *);
970 extern void pop_gimplify_context (gimple);
971 extern void gimplify_and_add (tree, gimple_seq *);
973 /* Miscellaneous helpers. */
974 extern void gimple_add_tmp_var (tree);
975 extern gimple gimple_current_bind_expr (void);
976 extern VEC(gimple, heap) *gimple_bind_expr_stack (void);
977 extern tree voidify_wrapper_expr (tree, tree);
978 extern tree build_and_jump (tree *);
979 extern tree alloc_stmt_list (void);
980 extern void free_stmt_list (tree);
981 extern tree force_labels_r (tree *, int *, void *);
982 extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *,
984 struct gimplify_omp_ctx;
985 extern void omp_firstprivatize_variable (struct gimplify_omp_ctx *, tree);
986 extern tree gimple_boolify (tree);
987 extern gimple_predicate rhs_predicate_for (tree);
988 extern tree canonicalize_cond_expr_cond (tree);
991 extern void diagnose_omp_structured_block_errors (tree);
992 extern tree omp_reduction_init (tree, tree);
994 /* In tree-nested.c. */
995 extern void lower_nested_functions (tree);
996 extern void insert_field_into_struct (tree, tree);
999 extern void gimplify_function_tree (tree);
1001 /* In cfgexpand.c. */
1002 extern tree gimple_assign_rhs_to_tree (gimple);
1005 extern bool validate_gimple_arglist (const_gimple, ...);
1007 /* In tree-ssa-operands.c */
1008 extern void gimple_add_to_addresses_taken (gimple, tree);
1011 extern bool tree_ssa_useless_type_conversion (tree);
1012 extern bool useless_type_conversion_p (tree, tree);
1013 extern bool types_compatible_p (tree, tree);
1015 /* Return the code for GIMPLE statement G. */
1017 static inline enum gimple_code
1018 gimple_code (const_gimple g)
1020 return g->gsbase.code;
1024 /* Return true if statement G has sub-statements. This is only true for
1025 High GIMPLE statements. */
1028 gimple_has_substatements (gimple g)
1030 switch (gimple_code (g))
1034 case GIMPLE_EH_FILTER:
1036 case GIMPLE_OMP_FOR:
1037 case GIMPLE_OMP_MASTER:
1038 case GIMPLE_OMP_ORDERED:
1039 case GIMPLE_OMP_SECTION:
1040 case GIMPLE_OMP_PARALLEL:
1041 case GIMPLE_OMP_TASK:
1042 case GIMPLE_OMP_SECTIONS:
1043 case GIMPLE_OMP_SINGLE:
1044 case GIMPLE_WITH_CLEANUP_EXPR:
1053 /* Return the basic block holding statement G. */
1055 static inline struct basic_block_def *
1056 gimple_bb (const_gimple g)
1058 return g->gsbase.bb;
1062 /* Return the lexical scope block holding statement G. */
1065 gimple_block (const_gimple g)
1067 return g->gsbase.block;
1071 /* Set BLOCK to be the lexical scope block holding statement G. */
1074 gimple_set_block (gimple g, tree block)
1076 g->gsbase.block = block;
1080 /* Return location information for statement G. */
1082 static inline location_t
1083 gimple_location (const_gimple g)
1085 return g->gsbase.location;
1088 /* Return pointer to location information for statement G. */
1090 static inline const location_t *
1091 gimple_location_ptr (const_gimple g)
1093 return &g->gsbase.location;
1097 /* Set location information for statement G. */
1100 gimple_set_location (gimple g, location_t location)
1102 g->gsbase.location = location;
1106 /* Return true if G contains location information. */
1109 gimple_has_location (const_gimple g)
1111 return gimple_location (g) != UNKNOWN_LOCATION;
1115 /* Return the file name of the location of STMT. */
1117 static inline const char *
1118 gimple_filename (const_gimple stmt)
1120 return LOCATION_FILE (gimple_location (stmt));
1124 /* Return the line number of the location of STMT. */
1127 gimple_lineno (const_gimple stmt)
1129 return LOCATION_LINE (gimple_location (stmt));
1133 /* Determine whether SEQ is a singleton. */
1136 gimple_seq_singleton_p (gimple_seq seq)
1138 return ((gimple_seq_first (seq) != NULL)
1139 && (gimple_seq_first (seq) == gimple_seq_last (seq)));
1142 /* Return true if no warnings should be emitted for statement STMT. */
1145 gimple_no_warning_p (const_gimple stmt)
1147 return stmt->gsbase.no_warning;
1150 /* Set the no_warning flag of STMT to NO_WARNING. */
1153 gimple_set_no_warning (gimple stmt, bool no_warning)
1155 stmt->gsbase.no_warning = (unsigned) no_warning;
1158 /* Set the visited status on statement STMT to VISITED_P. */
1161 gimple_set_visited (gimple stmt, bool visited_p)
1163 stmt->gsbase.visited = (unsigned) visited_p;
1167 /* Return the visited status for statement STMT. */
1170 gimple_visited_p (gimple stmt)
1172 return stmt->gsbase.visited;
1176 /* Set pass local flag PLF on statement STMT to VAL_P. */
1179 gimple_set_plf (gimple stmt, enum plf_mask plf, bool val_p)
1182 stmt->gsbase.plf |= (unsigned int) plf;
1184 stmt->gsbase.plf &= ~((unsigned int) plf);
1188 /* Return the value of pass local flag PLF on statement STMT. */
1190 static inline unsigned int
1191 gimple_plf (gimple stmt, enum plf_mask plf)
1193 return stmt->gsbase.plf & ((unsigned int) plf);
1197 /* Set the uid of statement */
1200 gimple_set_uid (gimple g, unsigned uid)
1202 g->gsbase.uid = uid;
1206 /* Return the uid of statement */
1208 static inline unsigned
1209 gimple_uid (const_gimple g)
1211 return g->gsbase.uid;
1215 /* Return true if GIMPLE statement G has register or memory operands. */
1218 gimple_has_ops (const_gimple g)
1220 return gimple_code (g) >= GIMPLE_COND && gimple_code (g) <= GIMPLE_RETURN;
1224 /* Return true if GIMPLE statement G has memory operands. */
1227 gimple_has_mem_ops (const_gimple g)
1229 return gimple_code (g) >= GIMPLE_ASSIGN && gimple_code (g) <= GIMPLE_RETURN;
1232 /* Return the set of addresses taken by statement G. */
1234 static inline bitmap
1235 gimple_addresses_taken (const_gimple g)
1237 if (gimple_has_ops (g))
1238 return g->gsops.opbase.addresses_taken;
1244 /* Return a pointer to the set of addresses taken by statement G. */
1246 static inline bitmap *
1247 gimple_addresses_taken_ptr (gimple g)
1249 if (gimple_has_ops (g))
1250 return &g->gsops.opbase.addresses_taken;
1256 /* Set B to be the set of addresses taken by statement G. The
1257 previous set is freed. */
1260 gimple_set_addresses_taken (gimple g, bitmap b)
1262 gcc_assert (gimple_has_ops (g));
1263 BITMAP_FREE (g->gsops.opbase.addresses_taken);
1264 g->gsops.opbase.addresses_taken = b;
1268 /* Return the set of DEF operands for statement G. */
1270 static inline struct def_optype_d *
1271 gimple_def_ops (const_gimple g)
1273 if (!gimple_has_ops (g))
1275 return g->gsops.opbase.def_ops;
1279 /* Set DEF to be the set of DEF operands for statement G. */
1282 gimple_set_def_ops (gimple g, struct def_optype_d *def)
1284 gcc_assert (gimple_has_ops (g));
1285 g->gsops.opbase.def_ops = def;
1289 /* Return the set of USE operands for statement G. */
1291 static inline struct use_optype_d *
1292 gimple_use_ops (const_gimple g)
1294 if (!gimple_has_ops (g))
1296 return g->gsops.opbase.use_ops;
1300 /* Set USE to be the set of USE operands for statement G. */
1303 gimple_set_use_ops (gimple g, struct use_optype_d *use)
1305 gcc_assert (gimple_has_ops (g));
1306 g->gsops.opbase.use_ops = use;
1310 /* Return the set of VUSE operands for statement G. */
1312 static inline struct voptype_d *
1313 gimple_vuse_ops (const_gimple g)
1315 if (!gimple_has_mem_ops (g))
1317 return g->gsmem.membase.vuse_ops;
1321 /* Set OPS to be the set of VUSE operands for statement G. */
1324 gimple_set_vuse_ops (gimple g, struct voptype_d *ops)
1326 gcc_assert (gimple_has_mem_ops (g));
1327 g->gsmem.membase.vuse_ops = ops;
1331 /* Return the set of VDEF operands for statement G. */
1333 static inline struct voptype_d *
1334 gimple_vdef_ops (const_gimple g)
1336 if (!gimple_has_mem_ops (g))
1338 return g->gsmem.membase.vdef_ops;
1342 /* Set OPS to be the set of VDEF operands for statement G. */
1345 gimple_set_vdef_ops (gimple g, struct voptype_d *ops)
1347 gcc_assert (gimple_has_mem_ops (g));
1348 g->gsmem.membase.vdef_ops = ops;
1352 /* Return the set of symbols loaded by statement G. Each element of the
1353 set is the DECL_UID of the corresponding symbol. */
1355 static inline bitmap
1356 gimple_loaded_syms (const_gimple g)
1358 if (!gimple_has_mem_ops (g))
1360 return g->gsmem.membase.loads;
1364 /* Return the set of symbols stored by statement G. Each element of
1365 the set is the DECL_UID of the corresponding symbol. */
1367 static inline bitmap
1368 gimple_stored_syms (const_gimple g)
1370 if (!gimple_has_mem_ops (g))
1372 return g->gsmem.membase.stores;
1376 /* Return true if statement G has operands and the modified field has
1380 gimple_modified_p (const_gimple g)
1382 return (gimple_has_ops (g)) ? (bool) g->gsbase.modified : false;
1385 /* Return the type of the main expression computed by STMT. Return
1386 void_type_node if the statement computes nothing. */
1389 gimple_expr_type (const_gimple stmt)
1391 enum gimple_code code = gimple_code (stmt);
1393 if (code == GIMPLE_ASSIGN || code == GIMPLE_CALL)
1395 tree type = TREE_TYPE (gimple_get_lhs (stmt));
1396 /* Integral sub-types are never the type of the expression,
1397 but they still can be the type of the result as the base
1398 type (in which expressions are computed) is trivially
1399 convertible to one of its sub-types. So always return
1400 the base type here. */
1401 if (INTEGRAL_TYPE_P (type)
1403 /* But only if they are trivially convertible. */
1404 && useless_type_conversion_p (type, TREE_TYPE (type)))
1405 type = TREE_TYPE (type);
1408 else if (code == GIMPLE_COND)
1409 return boolean_type_node;
1411 return void_type_node;
1415 /* Return the tree code for the expression computed by STMT. This is
1416 only valid for GIMPLE_COND, GIMPLE_CALL and GIMPLE_ASSIGN. For
1417 GIMPLE_CALL, return CALL_EXPR as the expression code for
1418 consistency. This is useful when the caller needs to deal with the
1419 three kinds of computation that GIMPLE supports. */
1421 static inline enum tree_code
1422 gimple_expr_code (const_gimple stmt)
1424 enum gimple_code code = gimple_code (stmt);
1425 if (code == GIMPLE_ASSIGN || code == GIMPLE_COND)
1426 return (enum tree_code) stmt->gsbase.subcode;
1427 else if (code == GIMPLE_CALL)
1434 /* Mark statement S as modified, and update it. */
1437 update_stmt (gimple s)
1439 if (gimple_has_ops (s))
1441 gimple_set_modified (s, true);
1442 update_stmt_operands (s);
1446 /* Update statement S if it has been optimized. */
1449 update_stmt_if_modified (gimple s)
1451 if (gimple_modified_p (s))
1452 update_stmt_operands (s);
1455 /* Return true if statement STMT contains volatile operands. */
1458 gimple_has_volatile_ops (const_gimple stmt)
1460 if (gimple_has_mem_ops (stmt))
1461 return stmt->gsbase.has_volatile_ops;
1467 /* Set the HAS_VOLATILE_OPS flag to VOLATILEP. */
1470 gimple_set_has_volatile_ops (gimple stmt, bool volatilep)
1472 if (gimple_has_mem_ops (stmt))
1473 stmt->gsbase.has_volatile_ops = (unsigned) volatilep;
1477 /* Return true if statement STMT may access memory. */
1480 gimple_references_memory_p (gimple stmt)
1482 return gimple_has_mem_ops (stmt) && stmt->gsbase.references_memory_p;
1486 /* Set the REFERENCES_MEMORY_P flag for STMT to MEM_P. */
1489 gimple_set_references_memory (gimple stmt, bool mem_p)
1491 if (gimple_has_mem_ops (stmt))
1492 stmt->gsbase.references_memory_p = (unsigned) mem_p;
1495 /* Return the subcode for OMP statement S. */
1497 static inline unsigned
1498 gimple_omp_subcode (const_gimple s)
1500 gcc_assert (gimple_code (s) >= GIMPLE_OMP_ATOMIC_LOAD
1501 && gimple_code (s) <= GIMPLE_OMP_SINGLE);
1502 return s->gsbase.subcode;
1505 /* Set the subcode for OMP statement S to SUBCODE. */
1508 gimple_omp_set_subcode (gimple s, unsigned int subcode)
1510 /* We only have 16 bits for the subcode. Assert that we are not
1512 gcc_assert (subcode < (1 << 16));
1513 s->gsbase.subcode = subcode;
1516 /* Set the nowait flag on OMP_RETURN statement S. */
1519 gimple_omp_return_set_nowait (gimple s)
1521 GIMPLE_CHECK (s, GIMPLE_OMP_RETURN);
1522 s->gsbase.subcode |= GF_OMP_RETURN_NOWAIT;
1526 /* Return true if OMP return statement G has the GF_OMP_RETURN_NOWAIT
1530 gimple_omp_return_nowait_p (const_gimple g)
1532 GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
1533 return (gimple_omp_subcode (g) & GF_OMP_RETURN_NOWAIT) != 0;
1537 /* Return true if OMP section statement G has the GF_OMP_SECTION_LAST
1541 gimple_omp_section_last_p (const_gimple g)
1543 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1544 return (gimple_omp_subcode (g) & GF_OMP_SECTION_LAST) != 0;
1548 /* Set the GF_OMP_SECTION_LAST flag on G. */
1551 gimple_omp_section_set_last (gimple g)
1553 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1554 g->gsbase.subcode |= GF_OMP_SECTION_LAST;
1558 /* Return true if OMP parallel statement G has the
1559 GF_OMP_PARALLEL_COMBINED flag set. */
1562 gimple_omp_parallel_combined_p (const_gimple g)
1564 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1565 return (gimple_omp_subcode (g) & GF_OMP_PARALLEL_COMBINED) != 0;
1569 /* Set the GF_OMP_PARALLEL_COMBINED field in G depending on the boolean
1570 value of COMBINED_P. */
1573 gimple_omp_parallel_set_combined_p (gimple g, bool combined_p)
1575 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1577 g->gsbase.subcode |= GF_OMP_PARALLEL_COMBINED;
1579 g->gsbase.subcode &= ~GF_OMP_PARALLEL_COMBINED;
1583 /* Return the number of operands for statement GS. */
1585 static inline unsigned
1586 gimple_num_ops (const_gimple gs)
1588 return gs->gsbase.num_ops;
1592 /* Set the number of operands for statement GS. */
1595 gimple_set_num_ops (gimple gs, unsigned num_ops)
1597 gs->gsbase.num_ops = num_ops;
1601 /* Return the array of operands for statement GS. */
1603 static inline tree *
1604 gimple_ops (gimple gs)
1606 /* Offset in bytes to the location of the operand vector in every
1607 tuple structure. Defined in gimple.c */
1608 extern size_t const gimple_ops_offset_[];
1610 if (!gimple_has_ops (gs))
1613 /* All the tuples have their operand vector at the very bottom
1614 of the structure. */
1615 return ((tree *) ((char *) gs + gimple_ops_offset_[gimple_code (gs)]));
1619 /* Return operand I for statement GS. */
1622 gimple_op (const_gimple gs, unsigned i)
1624 if (gimple_has_ops (gs))
1626 gcc_assert (i < gimple_num_ops (gs));
1627 return gimple_ops (CONST_CAST_GIMPLE (gs))[i];
1633 /* Return a pointer to operand I for statement GS. */
1635 static inline tree *
1636 gimple_op_ptr (const_gimple gs, unsigned i)
1638 if (gimple_has_ops (gs))
1640 gcc_assert (i < gimple_num_ops (gs));
1641 return gimple_ops (CONST_CAST_GIMPLE (gs)) + i;
1647 /* Set operand I of statement GS to OP. */
1650 gimple_set_op (gimple gs, unsigned i, tree op)
1652 gcc_assert (gimple_has_ops (gs) && i < gimple_num_ops (gs));
1654 /* Note. It may be tempting to assert that OP matches
1655 is_gimple_operand, but that would be wrong. Different tuples
1656 accept slightly different sets of tree operands. Each caller
1657 should perform its own validation. */
1658 gimple_ops (gs)[i] = op;
1661 /* Return true if GS is a GIMPLE_ASSIGN. */
1664 is_gimple_assign (const_gimple gs)
1666 return gimple_code (gs) == GIMPLE_ASSIGN;
1669 /* Determine if expression CODE is one of the valid expressions that can
1670 be used on the RHS of GIMPLE assignments. */
1672 static inline enum gimple_rhs_class
1673 get_gimple_rhs_class (enum tree_code code)
1675 return (enum gimple_rhs_class) gimple_rhs_class_table[(int) code];
1678 /* Return the LHS of assignment statement GS. */
1681 gimple_assign_lhs (const_gimple gs)
1683 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1684 return gimple_op (gs, 0);
1688 /* Return a pointer to the LHS of assignment statement GS. */
1690 static inline tree *
1691 gimple_assign_lhs_ptr (const_gimple gs)
1693 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1694 return gimple_op_ptr (gs, 0);
1698 /* Set LHS to be the LHS operand of assignment statement GS. */
1701 gimple_assign_set_lhs (gimple gs, tree lhs)
1703 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1704 gcc_assert (is_gimple_operand (lhs));
1705 gimple_set_op (gs, 0, lhs);
1707 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1708 SSA_NAME_DEF_STMT (lhs) = gs;
1712 /* Return the first operand on the RHS of assignment statement GS. */
1715 gimple_assign_rhs1 (const_gimple gs)
1717 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1718 return gimple_op (gs, 1);
1722 /* Return a pointer to the first operand on the RHS of assignment
1725 static inline tree *
1726 gimple_assign_rhs1_ptr (const_gimple gs)
1728 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1729 return gimple_op_ptr (gs, 1);
1732 /* Set RHS to be the first operand on the RHS of assignment statement GS. */
1735 gimple_assign_set_rhs1 (gimple gs, tree rhs)
1737 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1739 /* If there are 3 or more operands, the 2 operands on the RHS must be
1741 if (gimple_num_ops (gs) >= 3)
1742 gcc_assert (is_gimple_val (rhs));
1744 gcc_assert (is_gimple_operand (rhs));
1746 gimple_set_op (gs, 1, rhs);
1750 /* Return the second operand on the RHS of assignment statement GS.
1751 If GS does not have two operands, NULL is returned instead. */
1754 gimple_assign_rhs2 (const_gimple gs)
1756 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1758 if (gimple_num_ops (gs) >= 3)
1759 return gimple_op (gs, 2);
1765 /* Return a pointer to the second operand on the RHS of assignment
1768 static inline tree *
1769 gimple_assign_rhs2_ptr (const_gimple gs)
1771 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1772 return gimple_op_ptr (gs, 2);
1776 /* Set RHS to be the second operand on the RHS of assignment statement GS. */
1779 gimple_assign_set_rhs2 (gimple gs, tree rhs)
1781 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1783 /* The 2 operands on the RHS must be GIMPLE values. */
1784 gcc_assert (is_gimple_val (rhs));
1786 gimple_set_op (gs, 2, rhs);
1789 /* Returns true if GS is a nontemporal move. */
1792 gimple_assign_nontemporal_move_p (const_gimple gs)
1794 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1795 return gs->gsbase.nontemporal_move;
1798 /* Sets nontemporal move flag of GS to NONTEMPORAL. */
1801 gimple_assign_set_nontemporal_move (gimple gs, bool nontemporal)
1803 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1804 gs->gsbase.nontemporal_move = nontemporal;
1808 /* Return the code of the expression computed on the rhs of assignment
1809 statement GS. In case that the RHS is a single object, returns the
1810 tree code of the object. */
1812 static inline enum tree_code
1813 gimple_assign_rhs_code (const_gimple gs)
1815 enum tree_code code;
1816 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1818 code = gimple_expr_code (gs);
1819 if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS)
1820 code = TREE_CODE (gimple_assign_rhs1 (gs));
1826 /* Set CODE to be the code for the expression computed on the RHS of
1830 gimple_assign_set_rhs_code (gimple s, enum tree_code code)
1832 GIMPLE_CHECK (s, GIMPLE_ASSIGN);
1833 s->gsbase.subcode = code;
1837 /* Return true if S is a type-cast assignment. */
1840 gimple_assign_cast_p (gimple s)
1842 if (is_gimple_assign (s))
1844 enum tree_code sc = gimple_assign_rhs_code (s);
1845 return sc == NOP_EXPR
1846 || sc == CONVERT_EXPR
1847 || sc == VIEW_CONVERT_EXPR
1848 || sc == FIX_TRUNC_EXPR;
1855 /* Return true if GS is a GIMPLE_CALL. */
1858 is_gimple_call (const_gimple gs)
1860 return gimple_code (gs) == GIMPLE_CALL;
1863 /* Return the LHS of call statement GS. */
1866 gimple_call_lhs (const_gimple gs)
1868 GIMPLE_CHECK (gs, GIMPLE_CALL);
1869 return gimple_op (gs, 0);
1873 /* Return a pointer to the LHS of call statement GS. */
1875 static inline tree *
1876 gimple_call_lhs_ptr (const_gimple gs)
1878 GIMPLE_CHECK (gs, GIMPLE_CALL);
1879 return gimple_op_ptr (gs, 0);
1883 /* Set LHS to be the LHS operand of call statement GS. */
1886 gimple_call_set_lhs (gimple gs, tree lhs)
1888 GIMPLE_CHECK (gs, GIMPLE_CALL);
1889 gcc_assert (!lhs || is_gimple_operand (lhs));
1890 gimple_set_op (gs, 0, lhs);
1891 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1892 SSA_NAME_DEF_STMT (lhs) = gs;
1896 /* Return the tree node representing the function called by call
1897 statement GS. This may or may not be a FUNCTION_DECL node. */
1900 gimple_call_fn (const_gimple gs)
1902 GIMPLE_CHECK (gs, GIMPLE_CALL);
1903 return gimple_op (gs, 1);
1907 /* Return a pointer to the tree node representing the function called by call
1910 static inline tree *
1911 gimple_call_fn_ptr (const_gimple gs)
1913 GIMPLE_CHECK (gs, GIMPLE_CALL);
1914 return gimple_op_ptr (gs, 1);
1918 /* Set FN to be the function called by call statement GS. */
1921 gimple_call_set_fn (gimple gs, tree fn)
1923 GIMPLE_CHECK (gs, GIMPLE_CALL);
1924 gcc_assert (is_gimple_operand (fn));
1925 gimple_set_op (gs, 1, fn);
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 decl = gimple_call_fn (gs);
1937 return (TREE_CODE (decl) == FUNCTION_DECL) ? decl : NULL_TREE;
1941 /* Return the type returned by call statement GS. */
1944 gimple_call_return_type (const_gimple gs)
1946 tree fn = gimple_call_fn (gs);
1947 tree type = TREE_TYPE (fn);
1949 /* See through pointers. */
1950 if (POINTER_TYPE_P (type))
1951 type = TREE_TYPE (type);
1953 gcc_assert (TREE_CODE (type) == FUNCTION_TYPE
1954 || TREE_CODE (type) == METHOD_TYPE);
1956 /* The type returned by a FUNCTION_DECL is the type of its
1958 return TREE_TYPE (type);
1962 /* Return the static chain for call statement GS. */
1965 gimple_call_chain (const_gimple gs)
1967 GIMPLE_CHECK (gs, GIMPLE_CALL);
1968 return gimple_op (gs, 2);
1972 /* Return a pointer to the static chain for call statement GS. */
1974 static inline tree *
1975 gimple_call_chain_ptr (const_gimple gs)
1977 GIMPLE_CHECK (gs, GIMPLE_CALL);
1978 return gimple_op_ptr (gs, 2);
1981 /* Set CHAIN to be the static chain for call statement GS. */
1984 gimple_call_set_chain (gimple gs, tree chain)
1986 GIMPLE_CHECK (gs, GIMPLE_CALL);
1987 gcc_assert (chain == NULL
1988 || TREE_CODE (chain) == ADDR_EXPR
1990 gimple_set_op (gs, 2, chain);
1994 /* Return the number of arguments used by call statement GS. */
1996 static inline unsigned
1997 gimple_call_num_args (const_gimple gs)
2000 GIMPLE_CHECK (gs, GIMPLE_CALL);
2001 num_ops = gimple_num_ops (gs);
2002 gcc_assert (num_ops >= 3);
2007 /* Return the argument at position INDEX for call statement GS. */
2010 gimple_call_arg (const_gimple gs, unsigned index)
2012 GIMPLE_CHECK (gs, GIMPLE_CALL);
2013 return gimple_op (gs, index + 3);
2017 /* Return a pointer to the argument at position INDEX for call
2020 static inline tree *
2021 gimple_call_arg_ptr (const_gimple gs, unsigned index)
2023 GIMPLE_CHECK (gs, GIMPLE_CALL);
2024 return gimple_op_ptr (gs, index + 3);
2028 /* Set ARG to be the argument at position INDEX for call statement GS. */
2031 gimple_call_set_arg (gimple gs, unsigned index, tree arg)
2033 GIMPLE_CHECK (gs, GIMPLE_CALL);
2034 gcc_assert (is_gimple_operand (arg));
2035 gimple_set_op (gs, index + 3, arg);
2039 /* If TAIL_P is true, mark call statement S as being a tail call
2040 (i.e., a call just before the exit of a function). These calls are
2041 candidate for tail call optimization. */
2044 gimple_call_set_tail (gimple s, bool tail_p)
2046 GIMPLE_CHECK (s, GIMPLE_CALL);
2048 s->gsbase.subcode |= GF_CALL_TAILCALL;
2050 s->gsbase.subcode &= ~GF_CALL_TAILCALL;
2054 /* Return true if GIMPLE_CALL S is marked as a tail call. */
2057 gimple_call_tail_p (gimple s)
2059 GIMPLE_CHECK (s, GIMPLE_CALL);
2060 return (s->gsbase.subcode & GF_CALL_TAILCALL) != 0;
2064 /* Set the inlinable status of GIMPLE_CALL S to INLINABLE_P. */
2067 gimple_call_set_cannot_inline (gimple s, bool inlinable_p)
2069 GIMPLE_CHECK (s, GIMPLE_CALL);
2071 s->gsbase.subcode |= GF_CALL_CANNOT_INLINE;
2073 s->gsbase.subcode &= ~GF_CALL_CANNOT_INLINE;
2077 /* Return true if GIMPLE_CALL S cannot be inlined. */
2080 gimple_call_cannot_inline_p (gimple s)
2082 GIMPLE_CHECK (s, GIMPLE_CALL);
2083 return (s->gsbase.subcode & GF_CALL_CANNOT_INLINE) != 0;
2087 /* If RETURN_SLOT_OPT_P is true mark GIMPLE_CALL S as valid for return
2088 slot optimization. This transformation uses the target of the call
2089 expansion as the return slot for calls that return in memory. */
2092 gimple_call_set_return_slot_opt (gimple s, bool return_slot_opt_p)
2094 GIMPLE_CHECK (s, GIMPLE_CALL);
2095 if (return_slot_opt_p)
2096 s->gsbase.subcode |= GF_CALL_RETURN_SLOT_OPT;
2098 s->gsbase.subcode &= ~GF_CALL_RETURN_SLOT_OPT;
2102 /* Return true if S is marked for return slot optimization. */
2105 gimple_call_return_slot_opt_p (gimple s)
2107 GIMPLE_CHECK (s, GIMPLE_CALL);
2108 return (s->gsbase.subcode & GF_CALL_RETURN_SLOT_OPT) != 0;
2112 /* If FROM_THUNK_P is true, mark GIMPLE_CALL S as being the jump from a
2113 thunk to the thunked-to function. */
2116 gimple_call_set_from_thunk (gimple s, bool from_thunk_p)
2118 GIMPLE_CHECK (s, GIMPLE_CALL);
2120 s->gsbase.subcode |= GF_CALL_FROM_THUNK;
2122 s->gsbase.subcode &= ~GF_CALL_FROM_THUNK;
2126 /* Return true if GIMPLE_CALL S is a jump from a thunk. */
2129 gimple_call_from_thunk_p (gimple s)
2131 GIMPLE_CHECK (s, GIMPLE_CALL);
2132 return (s->gsbase.subcode & GF_CALL_FROM_THUNK) != 0;
2136 /* If PASS_ARG_PACK_P is true, GIMPLE_CALL S is a stdarg call that needs the
2137 argument pack in its argument list. */
2140 gimple_call_set_va_arg_pack (gimple s, bool pass_arg_pack_p)
2142 GIMPLE_CHECK (s, GIMPLE_CALL);
2143 if (pass_arg_pack_p)
2144 s->gsbase.subcode |= GF_CALL_VA_ARG_PACK;
2146 s->gsbase.subcode &= ~GF_CALL_VA_ARG_PACK;
2150 /* Return true if GIMPLE_CALL S is a stdarg call that needs the
2151 argument pack in its argument list. */
2154 gimple_call_va_arg_pack_p (gimple s)
2156 GIMPLE_CHECK (s, GIMPLE_CALL);
2157 return (s->gsbase.subcode & GF_CALL_VA_ARG_PACK) != 0;
2161 /* Return true if S is a noreturn call. */
2164 gimple_call_noreturn_p (gimple s)
2166 GIMPLE_CHECK (s, GIMPLE_CALL);
2167 return (gimple_call_flags (s) & ECF_NORETURN) != 0;
2171 /* Return true if S is a nothrow call. */
2174 gimple_call_nothrow_p (gimple s)
2176 GIMPLE_CHECK (s, GIMPLE_CALL);
2177 return (gimple_call_flags (s) & ECF_NOTHROW) != 0;
2181 /* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL. */
2184 gimple_call_copy_flags (gimple dest_call, gimple orig_call)
2186 GIMPLE_CHECK (dest_call, GIMPLE_CALL);
2187 GIMPLE_CHECK (orig_call, GIMPLE_CALL);
2188 dest_call->gsbase.subcode = orig_call->gsbase.subcode;
2192 /* Returns true if this is a GIMPLE_ASSIGN or a GIMPLE_CALL with a
2196 gimple_has_lhs (gimple stmt)
2198 return (is_gimple_assign (stmt)
2199 || (is_gimple_call (stmt)
2200 && gimple_call_lhs (stmt) != NULL_TREE));
2204 /* Return the code of the predicate computed by conditional statement GS. */
2206 static inline enum tree_code
2207 gimple_cond_code (const_gimple gs)
2209 GIMPLE_CHECK (gs, GIMPLE_COND);
2210 return gs->gsbase.subcode;
2214 /* Set CODE to be the predicate code for the conditional statement GS. */
2217 gimple_cond_set_code (gimple gs, enum tree_code code)
2219 GIMPLE_CHECK (gs, GIMPLE_COND);
2220 gcc_assert (TREE_CODE_CLASS (code) == tcc_comparison);
2221 gs->gsbase.subcode = code;
2225 /* Return the LHS of the predicate computed by conditional statement GS. */
2228 gimple_cond_lhs (const_gimple gs)
2230 GIMPLE_CHECK (gs, GIMPLE_COND);
2231 return gimple_op (gs, 0);
2234 /* Return the pointer to the LHS of the predicate computed by conditional
2237 static inline tree *
2238 gimple_cond_lhs_ptr (const_gimple gs)
2240 GIMPLE_CHECK (gs, GIMPLE_COND);
2241 return gimple_op_ptr (gs, 0);
2244 /* Set LHS to be the LHS operand of the predicate computed by
2245 conditional statement GS. */
2248 gimple_cond_set_lhs (gimple gs, tree lhs)
2250 GIMPLE_CHECK (gs, GIMPLE_COND);
2251 gcc_assert (is_gimple_operand (lhs));
2252 gimple_set_op (gs, 0, lhs);
2256 /* Return the RHS operand of the predicate computed by conditional GS. */
2259 gimple_cond_rhs (const_gimple gs)
2261 GIMPLE_CHECK (gs, GIMPLE_COND);
2262 return gimple_op (gs, 1);
2265 /* Return the pointer to the RHS operand of the predicate computed by
2268 static inline tree *
2269 gimple_cond_rhs_ptr (const_gimple gs)
2271 GIMPLE_CHECK (gs, GIMPLE_COND);
2272 return gimple_op_ptr (gs, 1);
2276 /* Set RHS to be the RHS operand of the predicate computed by
2277 conditional statement GS. */
2280 gimple_cond_set_rhs (gimple gs, tree rhs)
2282 GIMPLE_CHECK (gs, GIMPLE_COND);
2283 gcc_assert (is_gimple_operand (rhs));
2284 gimple_set_op (gs, 1, rhs);
2288 /* Return the label used by conditional statement GS when its
2289 predicate evaluates to true. */
2292 gimple_cond_true_label (const_gimple gs)
2294 GIMPLE_CHECK (gs, GIMPLE_COND);
2295 return gimple_op (gs, 2);
2299 /* Set LABEL to be the label used by conditional statement GS when its
2300 predicate evaluates to true. */
2303 gimple_cond_set_true_label (gimple gs, tree label)
2305 GIMPLE_CHECK (gs, GIMPLE_COND);
2306 gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
2307 gimple_set_op (gs, 2, label);
2311 /* Set LABEL to be the label used by conditional statement GS when its
2312 predicate evaluates to false. */
2315 gimple_cond_set_false_label (gimple gs, tree label)
2317 GIMPLE_CHECK (gs, GIMPLE_COND);
2318 gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
2319 gimple_set_op (gs, 3, label);
2323 /* Return the label used by conditional statement GS when its
2324 predicate evaluates to false. */
2327 gimple_cond_false_label (const_gimple gs)
2329 GIMPLE_CHECK (gs, GIMPLE_COND);
2330 return gimple_op (gs, 3);
2334 /* Set the conditional COND_STMT to be of the form 'if (1 == 0)'. */
2337 gimple_cond_make_false (gimple gs)
2339 gimple_cond_set_lhs (gs, boolean_true_node);
2340 gimple_cond_set_rhs (gs, boolean_false_node);
2341 gs->gsbase.subcode = EQ_EXPR;
2345 /* Set the conditional COND_STMT to be of the form 'if (1 == 1)'. */
2348 gimple_cond_make_true (gimple gs)
2350 gimple_cond_set_lhs (gs, boolean_true_node);
2351 gimple_cond_set_rhs (gs, boolean_true_node);
2352 gs->gsbase.subcode = EQ_EXPR;
2355 /* Check if conditional statemente GS is of the form 'if (1 == 1)',
2356 'if (0 == 0)', 'if (1 != 0)' or 'if (0 != 1)' */
2359 gimple_cond_true_p (const_gimple gs)
2361 tree lhs = gimple_cond_lhs (gs);
2362 tree rhs = gimple_cond_rhs (gs);
2363 enum tree_code code = gimple_cond_code (gs);
2365 if (lhs != boolean_true_node && lhs != boolean_false_node)
2368 if (rhs != boolean_true_node && rhs != boolean_false_node)
2371 if (code == NE_EXPR && lhs != rhs)
2374 if (code == EQ_EXPR && lhs == rhs)
2380 /* Check if conditional statement GS is of the form 'if (1 != 1)',
2381 'if (0 != 0)', 'if (1 == 0)' or 'if (0 == 1)' */
2384 gimple_cond_false_p (const_gimple gs)
2386 tree lhs = gimple_cond_lhs (gs);
2387 tree rhs = gimple_cond_rhs (gs);
2388 enum tree_code code = gimple_cond_code (gs);
2390 if (lhs != boolean_true_node && lhs != boolean_false_node)
2393 if (rhs != boolean_true_node && rhs != boolean_false_node)
2396 if (code == NE_EXPR && lhs == rhs)
2399 if (code == EQ_EXPR && lhs != rhs)
2405 /* Check if conditional statement GS is of the form 'if (var != 0)' or
2409 gimple_cond_single_var_p (gimple gs)
2411 if (gimple_cond_code (gs) == NE_EXPR
2412 && gimple_cond_rhs (gs) == boolean_false_node)
2415 if (gimple_cond_code (gs) == EQ_EXPR
2416 && gimple_cond_rhs (gs) == boolean_true_node)
2422 /* Set the code, LHS and RHS of GIMPLE_COND STMT from CODE, LHS and RHS. */
2425 gimple_cond_set_condition (gimple stmt, enum tree_code code, tree lhs, tree rhs)
2427 gimple_cond_set_code (stmt, code);
2428 gimple_cond_set_lhs (stmt, lhs);
2429 gimple_cond_set_rhs (stmt, rhs);
2432 /* Return the LABEL_DECL node used by GIMPLE_LABEL statement GS. */
2435 gimple_label_label (const_gimple gs)
2437 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2438 return gimple_op (gs, 0);
2442 /* Set LABEL to be the LABEL_DECL node used by GIMPLE_LABEL statement
2446 gimple_label_set_label (gimple gs, tree label)
2448 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2449 gcc_assert (TREE_CODE (label) == LABEL_DECL);
2450 gimple_set_op (gs, 0, label);
2454 /* Return the destination of the unconditional jump GS. */
2457 gimple_goto_dest (const_gimple gs)
2459 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2460 return gimple_op (gs, 0);
2464 /* Set DEST to be the destination of the unconditonal jump GS. */
2467 gimple_goto_set_dest (gimple gs, tree dest)
2469 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2470 gcc_assert (is_gimple_operand (dest));
2471 gimple_set_op (gs, 0, dest);
2475 /* Return the variables declared in the GIMPLE_BIND statement GS. */
2478 gimple_bind_vars (const_gimple gs)
2480 GIMPLE_CHECK (gs, GIMPLE_BIND);
2481 return gs->gimple_bind.vars;
2485 /* Set VARS to be the set of variables declared in the GIMPLE_BIND
2489 gimple_bind_set_vars (gimple gs, tree vars)
2491 GIMPLE_CHECK (gs, GIMPLE_BIND);
2492 gs->gimple_bind.vars = vars;
2496 /* Append VARS to the set of variables declared in the GIMPLE_BIND
2500 gimple_bind_append_vars (gimple gs, tree vars)
2502 GIMPLE_CHECK (gs, GIMPLE_BIND);
2503 gs->gimple_bind.vars = chainon (gs->gimple_bind.vars, vars);
2507 /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS. */
2509 static inline gimple_seq
2510 gimple_bind_body (gimple gs)
2512 GIMPLE_CHECK (gs, GIMPLE_BIND);
2513 return gs->gimple_bind.body;
2517 /* Set SEQ to be the GIMPLE sequence contained in the GIMPLE_BIND
2521 gimple_bind_set_body (gimple gs, gimple_seq seq)
2523 GIMPLE_CHECK (gs, GIMPLE_BIND);
2524 gs->gimple_bind.body = seq;
2528 /* Append a statement to the end of a GIMPLE_BIND's body. */
2531 gimple_bind_add_stmt (gimple gs, gimple stmt)
2533 GIMPLE_CHECK (gs, GIMPLE_BIND);
2534 gimple_seq_add_stmt (&gs->gimple_bind.body, stmt);
2538 /* Append a sequence of statements to the end of a GIMPLE_BIND's body. */
2541 gimple_bind_add_seq (gimple gs, gimple_seq seq)
2543 GIMPLE_CHECK (gs, GIMPLE_BIND);
2544 gimple_seq_add_seq (&gs->gimple_bind.body, seq);
2548 /* Return the TREE_BLOCK node associated with GIMPLE_BIND statement
2549 GS. This is analogous to the BIND_EXPR_BLOCK field in trees. */
2552 gimple_bind_block (const_gimple gs)
2554 GIMPLE_CHECK (gs, GIMPLE_BIND);
2555 return gs->gimple_bind.block;
2559 /* Set BLOCK to be the TREE_BLOCK node associated with GIMPLE_BIND
2563 gimple_bind_set_block (gimple gs, tree block)
2565 GIMPLE_CHECK (gs, GIMPLE_BIND);
2566 gcc_assert (TREE_CODE (block) == BLOCK);
2567 gs->gimple_bind.block = block;
2571 /* Return the number of input operands for GIMPLE_ASM GS. */
2573 static inline unsigned
2574 gimple_asm_ninputs (const_gimple gs)
2576 GIMPLE_CHECK (gs, GIMPLE_ASM);
2577 return gs->gimple_asm.ni;
2581 /* Return the number of output operands for GIMPLE_ASM GS. */
2583 static inline unsigned
2584 gimple_asm_noutputs (const_gimple gs)
2586 GIMPLE_CHECK (gs, GIMPLE_ASM);
2587 return gs->gimple_asm.no;
2591 /* Return the number of clobber operands for GIMPLE_ASM GS. */
2593 static inline unsigned
2594 gimple_asm_nclobbers (const_gimple gs)
2596 GIMPLE_CHECK (gs, GIMPLE_ASM);
2597 return gs->gimple_asm.nc;
2601 /* Return input operand INDEX of GIMPLE_ASM GS. */
2604 gimple_asm_input_op (const_gimple gs, unsigned index)
2606 GIMPLE_CHECK (gs, GIMPLE_ASM);
2607 gcc_assert (index <= gs->gimple_asm.ni);
2608 return gimple_op (gs, index);
2611 /* Return a pointer to input operand INDEX of GIMPLE_ASM GS. */
2613 static inline tree *
2614 gimple_asm_input_op_ptr (const_gimple gs, unsigned index)
2616 GIMPLE_CHECK (gs, GIMPLE_ASM);
2617 gcc_assert (index <= gs->gimple_asm.ni);
2618 return gimple_op_ptr (gs, index);
2622 /* Set IN_OP to be input operand INDEX in GIMPLE_ASM GS. */
2625 gimple_asm_set_input_op (gimple gs, unsigned index, tree in_op)
2627 GIMPLE_CHECK (gs, GIMPLE_ASM);
2628 gcc_assert (index <= gs->gimple_asm.ni);
2629 gcc_assert (TREE_CODE (in_op) == TREE_LIST);
2630 gimple_set_op (gs, index, in_op);
2634 /* Return output operand INDEX of GIMPLE_ASM GS. */
2637 gimple_asm_output_op (const_gimple gs, unsigned index)
2639 GIMPLE_CHECK (gs, GIMPLE_ASM);
2640 gcc_assert (index <= gs->gimple_asm.no);
2641 return gimple_op (gs, index + gs->gimple_asm.ni);
2644 /* Return a pointer to output operand INDEX of GIMPLE_ASM GS. */
2646 static inline tree *
2647 gimple_asm_output_op_ptr (const_gimple gs, unsigned index)
2649 GIMPLE_CHECK (gs, GIMPLE_ASM);
2650 gcc_assert (index <= gs->gimple_asm.no);
2651 return gimple_op_ptr (gs, index + gs->gimple_asm.ni);
2655 /* Set OUT_OP to be output operand INDEX in GIMPLE_ASM GS. */
2658 gimple_asm_set_output_op (gimple gs, unsigned index, tree out_op)
2660 GIMPLE_CHECK (gs, GIMPLE_ASM);
2661 gcc_assert (index <= gs->gimple_asm.no);
2662 gcc_assert (TREE_CODE (out_op) == TREE_LIST);
2663 gimple_set_op (gs, index + gs->gimple_asm.ni, out_op);
2667 /* Return clobber operand INDEX of GIMPLE_ASM GS. */
2670 gimple_asm_clobber_op (const_gimple gs, unsigned index)
2672 GIMPLE_CHECK (gs, GIMPLE_ASM);
2673 gcc_assert (index <= gs->gimple_asm.nc);
2674 return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no);
2678 /* Set CLOBBER_OP to be clobber operand INDEX in GIMPLE_ASM GS. */
2681 gimple_asm_set_clobber_op (gimple gs, unsigned index, tree clobber_op)
2683 GIMPLE_CHECK (gs, GIMPLE_ASM);
2684 gcc_assert (index <= gs->gimple_asm.nc);
2685 gcc_assert (TREE_CODE (clobber_op) == TREE_LIST);
2686 gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no, clobber_op);
2690 /* Return the string representing the assembly instruction in
2693 static inline const char *
2694 gimple_asm_string (const_gimple gs)
2696 GIMPLE_CHECK (gs, GIMPLE_ASM);
2697 return gs->gimple_asm.string;
2701 /* Return true if GS is an asm statement marked volatile. */
2704 gimple_asm_volatile_p (const_gimple gs)
2706 GIMPLE_CHECK (gs, GIMPLE_ASM);
2707 return (gs->gsbase.subcode & GF_ASM_VOLATILE) != 0;
2711 /* If VOLATLE_P is true, mark asm statement GS as volatile. */
2714 gimple_asm_set_volatile (gimple gs, bool volatile_p)
2716 GIMPLE_CHECK (gs, GIMPLE_ASM);
2718 gs->gsbase.subcode |= GF_ASM_VOLATILE;
2720 gs->gsbase.subcode &= ~GF_ASM_VOLATILE;
2724 /* If INPUT_P is true, mark asm GS as an ASM_INPUT. */
2727 gimple_asm_set_input (gimple gs, bool input_p)
2729 GIMPLE_CHECK (gs, GIMPLE_ASM);
2731 gs->gsbase.subcode |= GF_ASM_INPUT;
2733 gs->gsbase.subcode &= ~GF_ASM_INPUT;
2737 /* Return true if asm GS is an ASM_INPUT. */
2740 gimple_asm_input_p (const_gimple gs)
2742 GIMPLE_CHECK (gs, GIMPLE_ASM);
2743 return (gs->gsbase.subcode & GF_ASM_INPUT) != 0;
2747 /* Return the types handled by GIMPLE_CATCH statement GS. */
2750 gimple_catch_types (const_gimple gs)
2752 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2753 return gs->gimple_catch.types;
2757 /* Return a pointer to the types handled by GIMPLE_CATCH statement GS. */
2759 static inline tree *
2760 gimple_catch_types_ptr (gimple gs)
2762 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2763 return &gs->gimple_catch.types;
2767 /* Return the GIMPLE sequence representing the body of the handler of
2768 GIMPLE_CATCH statement GS. */
2770 static inline gimple_seq
2771 gimple_catch_handler (gimple gs)
2773 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2774 return gs->gimple_catch.handler;
2778 /* Return a pointer to the GIMPLE sequence representing the body of
2779 the handler of GIMPLE_CATCH statement GS. */
2781 static inline gimple_seq *
2782 gimple_catch_handler_ptr (gimple gs)
2784 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2785 return &gs->gimple_catch.handler;
2789 /* Set T to be the set of types handled by GIMPLE_CATCH GS. */
2792 gimple_catch_set_types (gimple gs, tree t)
2794 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2795 gs->gimple_catch.types = t;
2799 /* Set HANDLER to be the body of GIMPLE_CATCH GS. */
2802 gimple_catch_set_handler (gimple gs, gimple_seq handler)
2804 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2805 gs->gimple_catch.handler = handler;
2809 /* Return the types handled by GIMPLE_EH_FILTER statement GS. */
2812 gimple_eh_filter_types (const_gimple gs)
2814 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2815 return gs->gimple_eh_filter.types;
2819 /* Return a pointer to the types handled by GIMPLE_EH_FILTER statement
2822 static inline tree *
2823 gimple_eh_filter_types_ptr (gimple gs)
2825 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2826 return &gs->gimple_eh_filter.types;
2830 /* Return the sequence of statement to execute when GIMPLE_EH_FILTER
2833 static inline gimple_seq
2834 gimple_eh_filter_failure (gimple gs)
2836 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2837 return gs->gimple_eh_filter.failure;
2841 /* Set TYPES to be the set of types handled by GIMPLE_EH_FILTER GS. */
2844 gimple_eh_filter_set_types (gimple gs, tree types)
2846 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2847 gs->gimple_eh_filter.types = types;
2851 /* Set FAILURE to be the sequence of statements to execute on failure
2852 for GIMPLE_EH_FILTER GS. */
2855 gimple_eh_filter_set_failure (gimple gs, gimple_seq failure)
2857 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2858 gs->gimple_eh_filter.failure = failure;
2861 /* Return the EH_FILTER_MUST_NOT_THROW flag. */
2865 gimple_eh_filter_must_not_throw (gimple gs)
2867 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2868 return gs->gsbase.subcode != 0;
2871 /* Set the EH_FILTER_MUST_NOT_THROW flag to the value MNTP. */
2874 gimple_eh_filter_set_must_not_throw (gimple gs, bool mntp)
2876 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2877 gs->gsbase.subcode = (unsigned int) mntp;
2881 /* GIMPLE_TRY accessors. */
2883 /* Return the kind of try block represented by GIMPLE_TRY GS. This is
2884 either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY. */
2886 static inline enum gimple_try_flags
2887 gimple_try_kind (const_gimple gs)
2889 GIMPLE_CHECK (gs, GIMPLE_TRY);
2890 return (enum gimple_try_flags) (gs->gsbase.subcode & GIMPLE_TRY_KIND);
2894 /* Set the kind of try block represented by GIMPLE_TRY GS. */
2897 gimple_try_set_kind (gimple gs, enum gimple_try_flags kind)
2899 GIMPLE_CHECK (gs, GIMPLE_TRY);
2900 gcc_assert (kind == GIMPLE_TRY_CATCH || kind == GIMPLE_TRY_FINALLY);
2901 if (gimple_try_kind (gs) != kind)
2902 gs->gsbase.subcode = (unsigned int) kind;
2906 /* Return the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2909 gimple_try_catch_is_cleanup (const_gimple gs)
2911 gcc_assert (gimple_try_kind (gs) == GIMPLE_TRY_CATCH);
2912 return (gs->gsbase.subcode & GIMPLE_TRY_CATCH_IS_CLEANUP) != 0;
2916 /* Return the sequence of statements used as the body for GIMPLE_TRY GS. */
2918 static inline gimple_seq
2919 gimple_try_eval (gimple gs)
2921 GIMPLE_CHECK (gs, GIMPLE_TRY);
2922 return gs->gimple_try.eval;
2926 /* Return the sequence of statements used as the cleanup body for
2929 static inline gimple_seq
2930 gimple_try_cleanup (gimple gs)
2932 GIMPLE_CHECK (gs, GIMPLE_TRY);
2933 return gs->gimple_try.cleanup;
2937 /* Set the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2940 gimple_try_set_catch_is_cleanup (gimple g, bool catch_is_cleanup)
2942 gcc_assert (gimple_try_kind (g) == GIMPLE_TRY_CATCH);
2943 if (catch_is_cleanup)
2944 g->gsbase.subcode |= GIMPLE_TRY_CATCH_IS_CLEANUP;
2946 g->gsbase.subcode &= ~GIMPLE_TRY_CATCH_IS_CLEANUP;
2950 /* Set EVAL to be the sequence of statements to use as the body for
2954 gimple_try_set_eval (gimple gs, gimple_seq eval)
2956 GIMPLE_CHECK (gs, GIMPLE_TRY);
2957 gs->gimple_try.eval = eval;
2961 /* Set CLEANUP to be the sequence of statements to use as the cleanup
2962 body for GIMPLE_TRY GS. */
2965 gimple_try_set_cleanup (gimple gs, gimple_seq cleanup)
2967 GIMPLE_CHECK (gs, GIMPLE_TRY);
2968 gs->gimple_try.cleanup = cleanup;
2972 /* Return the cleanup sequence for cleanup statement GS. */
2974 static inline gimple_seq
2975 gimple_wce_cleanup (gimple gs)
2977 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
2978 return gs->gimple_wce.cleanup;
2982 /* Set CLEANUP to be the cleanup sequence for GS. */
2985 gimple_wce_set_cleanup (gimple gs, gimple_seq cleanup)
2987 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
2988 gs->gimple_wce.cleanup = cleanup;
2992 /* Return the CLEANUP_EH_ONLY flag for a WCE tuple. */
2995 gimple_wce_cleanup_eh_only (const_gimple gs)
2997 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
2998 return gs->gsbase.subcode != 0;
3002 /* Set the CLEANUP_EH_ONLY flag for a WCE tuple. */
3005 gimple_wce_set_cleanup_eh_only (gimple gs, bool eh_only_p)
3007 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3008 gs->gsbase.subcode = (unsigned int) eh_only_p;
3012 /* Return the maximum number of arguments supported by GIMPLE_PHI GS. */
3014 static inline unsigned
3015 gimple_phi_capacity (const_gimple gs)
3017 GIMPLE_CHECK (gs, GIMPLE_PHI);
3018 return gs->gimple_phi.capacity;
3022 /* Return the number of arguments in GIMPLE_PHI GS. This must always
3023 be exactly the number of incoming edges for the basic block holding
3026 static inline unsigned
3027 gimple_phi_num_args (const_gimple gs)
3029 GIMPLE_CHECK (gs, GIMPLE_PHI);
3030 return gs->gimple_phi.nargs;
3034 /* Return the SSA name created by GIMPLE_PHI GS. */
3037 gimple_phi_result (const_gimple gs)
3039 GIMPLE_CHECK (gs, GIMPLE_PHI);
3040 return gs->gimple_phi.result;
3043 /* Return a pointer to the SSA name created by GIMPLE_PHI GS. */
3045 static inline tree *
3046 gimple_phi_result_ptr (gimple gs)
3048 GIMPLE_CHECK (gs, GIMPLE_PHI);
3049 return &gs->gimple_phi.result;
3052 /* Set RESULT to be the SSA name created by GIMPLE_PHI GS. */
3055 gimple_phi_set_result (gimple gs, tree result)
3057 GIMPLE_CHECK (gs, GIMPLE_PHI);
3058 gs->gimple_phi.result = result;
3062 /* Return the PHI argument corresponding to incoming edge INDEX for
3065 static inline struct phi_arg_d *
3066 gimple_phi_arg (gimple gs, unsigned index)
3068 GIMPLE_CHECK (gs, GIMPLE_PHI);
3069 gcc_assert (index <= gs->gimple_phi.capacity);
3070 return &(gs->gimple_phi.args[index]);
3073 /* Set PHIARG to be the argument corresponding to incoming edge INDEX
3074 for GIMPLE_PHI GS. */
3077 gimple_phi_set_arg (gimple gs, unsigned index, struct phi_arg_d * phiarg)
3079 GIMPLE_CHECK (gs, GIMPLE_PHI);
3080 gcc_assert (index <= gs->gimple_phi.nargs);
3081 memcpy (gs->gimple_phi.args + index, phiarg, sizeof (struct phi_arg_d));
3084 /* Return the region number for GIMPLE_RESX GS. */
3087 gimple_resx_region (const_gimple gs)
3089 GIMPLE_CHECK (gs, GIMPLE_RESX);
3090 return gs->gimple_resx.region;
3093 /* Set REGION to be the region number for GIMPLE_RESX GS. */
3096 gimple_resx_set_region (gimple gs, int region)
3098 GIMPLE_CHECK (gs, GIMPLE_RESX);
3099 gs->gimple_resx.region = region;
3103 /* Return the number of labels associated with the switch statement GS. */
3105 static inline unsigned
3106 gimple_switch_num_labels (const_gimple gs)
3109 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3110 num_ops = gimple_num_ops (gs);
3111 gcc_assert (num_ops > 1);
3116 /* Set NLABELS to be the number of labels for the switch statement GS. */
3119 gimple_switch_set_num_labels (gimple g, unsigned nlabels)
3121 GIMPLE_CHECK (g, GIMPLE_SWITCH);
3122 gimple_set_num_ops (g, nlabels + 1);
3126 /* Return the index variable used by the switch statement GS. */
3129 gimple_switch_index (const_gimple gs)
3131 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3132 return gimple_op (gs, 0);
3136 /* Return a pointer to the index variable for the switch statement GS. */
3138 static inline tree *
3139 gimple_switch_index_ptr (const_gimple gs)
3141 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3142 return gimple_op_ptr (gs, 0);
3146 /* Set INDEX to be the index variable for switch statement GS. */
3149 gimple_switch_set_index (gimple gs, tree index)
3151 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3152 gcc_assert (SSA_VAR_P (index) || CONSTANT_CLASS_P (index));
3153 gimple_set_op (gs, 0, index);
3157 /* Return the label numbered INDEX. The default label is 0, followed by any
3158 labels in a switch statement. */
3161 gimple_switch_label (const_gimple gs, unsigned index)
3163 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3164 gcc_assert (gimple_num_ops (gs) > index + 1);
3165 return gimple_op (gs, index + 1);
3168 /* Set the label number INDEX to LABEL. 0 is always the default label. */
3171 gimple_switch_set_label (gimple gs, unsigned index, tree label)
3173 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3174 gcc_assert (gimple_num_ops (gs) > index + 1);
3175 gcc_assert (label == NULL_TREE || TREE_CODE (label) == CASE_LABEL_EXPR);
3176 gimple_set_op (gs, index + 1, label);
3179 /* Return the default label for a switch statement. */
3182 gimple_switch_default_label (const_gimple gs)
3184 return gimple_switch_label (gs, 0);
3187 /* Set the default label for a switch statement. */
3190 gimple_switch_set_default_label (gimple gs, tree label)
3192 gimple_switch_set_label (gs, 0, label);
3196 /* Return the body for the OMP statement GS. */
3198 static inline gimple_seq
3199 gimple_omp_body (gimple gs)
3201 return gs->omp.body;
3204 /* Set BODY to be the body for the OMP statement GS. */
3207 gimple_omp_set_body (gimple gs, gimple_seq body)
3209 gs->omp.body = body;
3213 /* Return the name associated with OMP_CRITICAL statement GS. */
3216 gimple_omp_critical_name (const_gimple gs)
3218 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3219 return gs->gimple_omp_critical.name;
3223 /* Return a pointer to the name associated with OMP critical statement GS. */
3225 static inline tree *
3226 gimple_omp_critical_name_ptr (gimple gs)
3228 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3229 return &gs->gimple_omp_critical.name;
3233 /* Set NAME to be the name associated with OMP critical statement GS. */
3236 gimple_omp_critical_set_name (gimple gs, tree name)
3238 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3239 gs->gimple_omp_critical.name = name;
3243 /* Return the clauses associated with OMP_FOR GS. */
3246 gimple_omp_for_clauses (const_gimple gs)
3248 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3249 return gs->gimple_omp_for.clauses;
3253 /* Return a pointer to the OMP_FOR GS. */
3255 static inline tree *
3256 gimple_omp_for_clauses_ptr (gimple gs)
3258 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3259 return &gs->gimple_omp_for.clauses;
3263 /* Set CLAUSES to be the list of clauses associated with OMP_FOR GS. */
3266 gimple_omp_for_set_clauses (gimple gs, tree clauses)
3268 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3269 gs->gimple_omp_for.clauses = clauses;
3273 /* Get the collapse count of OMP_FOR GS. */
3275 static inline size_t
3276 gimple_omp_for_collapse (gimple gs)
3278 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3279 return gs->gimple_omp_for.collapse;
3283 /* Return the index variable for OMP_FOR GS. */
3286 gimple_omp_for_index (const_gimple gs, size_t i)
3288 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3289 gcc_assert (i < gs->gimple_omp_for.collapse);
3290 return gs->gimple_omp_for.iter[i].index;
3294 /* Return a pointer to the index variable for OMP_FOR GS. */
3296 static inline tree *
3297 gimple_omp_for_index_ptr (gimple gs, size_t i)
3299 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3300 gcc_assert (i < gs->gimple_omp_for.collapse);
3301 return &gs->gimple_omp_for.iter[i].index;
3305 /* Set INDEX to be the index variable for OMP_FOR GS. */
3308 gimple_omp_for_set_index (gimple gs, size_t i, tree index)
3310 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3311 gcc_assert (i < gs->gimple_omp_for.collapse);
3312 gs->gimple_omp_for.iter[i].index = index;
3316 /* Return the initial value for OMP_FOR GS. */
3319 gimple_omp_for_initial (const_gimple gs, size_t i)
3321 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3322 gcc_assert (i < gs->gimple_omp_for.collapse);
3323 return gs->gimple_omp_for.iter[i].initial;
3327 /* Return a pointer to the initial value for OMP_FOR GS. */
3329 static inline tree *
3330 gimple_omp_for_initial_ptr (gimple gs, size_t i)
3332 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3333 gcc_assert (i < gs->gimple_omp_for.collapse);
3334 return &gs->gimple_omp_for.iter[i].initial;
3338 /* Set INITIAL to be the initial value for OMP_FOR GS. */
3341 gimple_omp_for_set_initial (gimple gs, size_t i, tree initial)
3343 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3344 gcc_assert (i < gs->gimple_omp_for.collapse);
3345 gs->gimple_omp_for.iter[i].initial = initial;
3349 /* Return the final value for OMP_FOR GS. */
3352 gimple_omp_for_final (const_gimple gs, size_t i)
3354 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3355 gcc_assert (i < gs->gimple_omp_for.collapse);
3356 return gs->gimple_omp_for.iter[i].final;
3360 /* Return a pointer to the final value for OMP_FOR GS. */
3362 static inline tree *
3363 gimple_omp_for_final_ptr (gimple gs, size_t i)
3365 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3366 gcc_assert (i < gs->gimple_omp_for.collapse);
3367 return &gs->gimple_omp_for.iter[i].final;
3371 /* Set FINAL to be the final value for OMP_FOR GS. */
3374 gimple_omp_for_set_final (gimple gs, size_t i, tree final)
3376 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3377 gcc_assert (i < gs->gimple_omp_for.collapse);
3378 gs->gimple_omp_for.iter[i].final = final;
3382 /* Return the increment value for OMP_FOR GS. */
3385 gimple_omp_for_incr (const_gimple gs, size_t i)
3387 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3388 gcc_assert (i < gs->gimple_omp_for.collapse);
3389 return gs->gimple_omp_for.iter[i].incr;
3393 /* Return a pointer to the increment value for OMP_FOR GS. */
3395 static inline tree *
3396 gimple_omp_for_incr_ptr (gimple gs, size_t i)
3398 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3399 gcc_assert (i < gs->gimple_omp_for.collapse);
3400 return &gs->gimple_omp_for.iter[i].incr;
3404 /* Set INCR to be the increment value for OMP_FOR GS. */
3407 gimple_omp_for_set_incr (gimple gs, size_t i, tree incr)
3409 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3410 gcc_assert (i < gs->gimple_omp_for.collapse);
3411 gs->gimple_omp_for.iter[i].incr = incr;
3415 /* Return the sequence of statements to execute before the OMP_FOR
3416 statement GS starts. */
3418 static inline gimple_seq
3419 gimple_omp_for_pre_body (gimple gs)
3421 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3422 return gs->gimple_omp_for.pre_body;
3426 /* Set PRE_BODY to be the sequence of statements to execute before the
3427 OMP_FOR statement GS starts. */
3430 gimple_omp_for_set_pre_body (gimple gs, gimple_seq pre_body)
3432 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3433 gs->gimple_omp_for.pre_body = pre_body;
3437 /* Return the clauses associated with OMP_PARALLEL GS. */
3440 gimple_omp_parallel_clauses (const_gimple gs)
3442 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3443 return gs->gimple_omp_parallel.clauses;
3447 /* Return a pointer to the clauses associated with OMP_PARALLEL GS. */
3449 static inline tree *
3450 gimple_omp_parallel_clauses_ptr (gimple gs)
3452 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3453 return &gs->gimple_omp_parallel.clauses;
3457 /* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL
3461 gimple_omp_parallel_set_clauses (gimple gs, tree clauses)
3463 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3464 gs->gimple_omp_parallel.clauses = clauses;
3468 /* Return the child function used to hold the body of OMP_PARALLEL GS. */
3471 gimple_omp_parallel_child_fn (const_gimple gs)
3473 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3474 return gs->gimple_omp_parallel.child_fn;
3477 /* Return a pointer to the child function used to hold the body of
3480 static inline tree *
3481 gimple_omp_parallel_child_fn_ptr (gimple gs)
3483 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3484 return &gs->gimple_omp_parallel.child_fn;
3488 /* Set CHILD_FN to be the child function for OMP_PARALLEL GS. */
3491 gimple_omp_parallel_set_child_fn (gimple gs, tree child_fn)
3493 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3494 gs->gimple_omp_parallel.child_fn = child_fn;
3498 /* Return the artificial argument used to send variables and values
3499 from the parent to the children threads in OMP_PARALLEL GS. */
3502 gimple_omp_parallel_data_arg (const_gimple gs)
3504 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3505 return gs->gimple_omp_parallel.data_arg;
3509 /* Return a pointer to the data argument for OMP_PARALLEL GS. */
3511 static inline tree *
3512 gimple_omp_parallel_data_arg_ptr (gimple gs)
3514 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3515 return &gs->gimple_omp_parallel.data_arg;
3519 /* Set DATA_ARG to be the data argument for OMP_PARALLEL GS. */
3522 gimple_omp_parallel_set_data_arg (gimple gs, tree data_arg)
3524 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3525 gs->gimple_omp_parallel.data_arg = data_arg;
3529 /* Return the clauses associated with OMP_TASK GS. */
3532 gimple_omp_task_clauses (const_gimple gs)
3534 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3535 return gs->gimple_omp_parallel.clauses;
3539 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3541 static inline tree *
3542 gimple_omp_task_clauses_ptr (gimple gs)
3544 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3545 return &gs->gimple_omp_parallel.clauses;
3549 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3553 gimple_omp_task_set_clauses (gimple gs, tree clauses)
3555 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3556 gs->gimple_omp_parallel.clauses = clauses;
3560 /* Return the child function used to hold the body of OMP_TASK GS. */
3563 gimple_omp_task_child_fn (const_gimple gs)
3565 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3566 return gs->gimple_omp_parallel.child_fn;
3569 /* Return a pointer to the child function used to hold the body of
3572 static inline tree *
3573 gimple_omp_task_child_fn_ptr (gimple gs)
3575 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3576 return &gs->gimple_omp_parallel.child_fn;
3580 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3583 gimple_omp_task_set_child_fn (gimple gs, tree child_fn)
3585 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3586 gs->gimple_omp_parallel.child_fn = child_fn;
3590 /* Return the artificial argument used to send variables and values
3591 from the parent to the children threads in OMP_TASK GS. */
3594 gimple_omp_task_data_arg (const_gimple gs)
3596 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3597 return gs->gimple_omp_parallel.data_arg;
3601 /* Return a pointer to the data argument for OMP_TASK GS. */
3603 static inline tree *
3604 gimple_omp_task_data_arg_ptr (gimple gs)
3606 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3607 return &gs->gimple_omp_parallel.data_arg;
3611 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3614 gimple_omp_task_set_data_arg (gimple gs, tree data_arg)
3616 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3617 gs->gimple_omp_parallel.data_arg = data_arg;
3621 /* Return the clauses associated with OMP_TASK GS. */
3624 gimple_omp_taskreg_clauses (const_gimple gs)
3626 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3627 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3628 return gs->gimple_omp_parallel.clauses;
3632 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3634 static inline tree *
3635 gimple_omp_taskreg_clauses_ptr (gimple gs)
3637 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3638 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3639 return &gs->gimple_omp_parallel.clauses;
3643 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3647 gimple_omp_taskreg_set_clauses (gimple gs, tree clauses)
3649 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3650 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3651 gs->gimple_omp_parallel.clauses = clauses;
3655 /* Return the child function used to hold the body of OMP_TASK GS. */
3658 gimple_omp_taskreg_child_fn (const_gimple gs)
3660 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3661 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3662 return gs->gimple_omp_parallel.child_fn;
3665 /* Return a pointer to the child function used to hold the body of
3668 static inline tree *
3669 gimple_omp_taskreg_child_fn_ptr (gimple gs)
3671 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3672 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3673 return &gs->gimple_omp_parallel.child_fn;
3677 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3680 gimple_omp_taskreg_set_child_fn (gimple gs, tree child_fn)
3682 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3683 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3684 gs->gimple_omp_parallel.child_fn = child_fn;
3688 /* Return the artificial argument used to send variables and values
3689 from the parent to the children threads in OMP_TASK GS. */
3692 gimple_omp_taskreg_data_arg (const_gimple gs)
3694 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3695 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3696 return gs->gimple_omp_parallel.data_arg;
3700 /* Return a pointer to the data argument for OMP_TASK GS. */
3702 static inline tree *
3703 gimple_omp_taskreg_data_arg_ptr (gimple gs)
3705 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3706 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3707 return &gs->gimple_omp_parallel.data_arg;
3711 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3714 gimple_omp_taskreg_set_data_arg (gimple gs, tree data_arg)
3716 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3717 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3718 gs->gimple_omp_parallel.data_arg = data_arg;
3722 /* Return the copy function used to hold the body of OMP_TASK GS. */
3725 gimple_omp_task_copy_fn (const_gimple gs)
3727 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3728 return gs->gimple_omp_task.copy_fn;
3731 /* Return a pointer to the copy function used to hold the body of
3734 static inline tree *
3735 gimple_omp_task_copy_fn_ptr (gimple gs)
3737 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3738 return &gs->gimple_omp_task.copy_fn;
3742 /* Set CHILD_FN to be the copy function for OMP_TASK GS. */
3745 gimple_omp_task_set_copy_fn (gimple gs, tree copy_fn)
3747 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3748 gs->gimple_omp_task.copy_fn = copy_fn;
3752 /* Return size of the data block in bytes in OMP_TASK GS. */
3755 gimple_omp_task_arg_size (const_gimple gs)
3757 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3758 return gs->gimple_omp_task.arg_size;
3762 /* Return a pointer to the data block size for OMP_TASK GS. */
3764 static inline tree *
3765 gimple_omp_task_arg_size_ptr (gimple gs)
3767 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3768 return &gs->gimple_omp_task.arg_size;
3772 /* Set ARG_SIZE to be the data block size for OMP_TASK GS. */
3775 gimple_omp_task_set_arg_size (gimple gs, tree arg_size)
3777 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3778 gs->gimple_omp_task.arg_size = arg_size;
3782 /* Return align of the data block in bytes in OMP_TASK GS. */
3785 gimple_omp_task_arg_align (const_gimple gs)
3787 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3788 return gs->gimple_omp_task.arg_align;
3792 /* Return a pointer to the data block align for OMP_TASK GS. */
3794 static inline tree *
3795 gimple_omp_task_arg_align_ptr (gimple gs)
3797 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3798 return &gs->gimple_omp_task.arg_align;
3802 /* Set ARG_SIZE to be the data block align for OMP_TASK GS. */
3805 gimple_omp_task_set_arg_align (gimple gs, tree arg_align)
3807 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3808 gs->gimple_omp_task.arg_align = arg_align;
3812 /* Return the clauses associated with OMP_SINGLE GS. */
3815 gimple_omp_single_clauses (const_gimple gs)
3817 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3818 return gs->gimple_omp_single.clauses;
3822 /* Return a pointer to the clauses associated with OMP_SINGLE GS. */
3824 static inline tree *
3825 gimple_omp_single_clauses_ptr (gimple gs)
3827 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3828 return &gs->gimple_omp_single.clauses;
3832 /* Set CLAUSES to be the clauses associated with OMP_SINGLE GS. */
3835 gimple_omp_single_set_clauses (gimple gs, tree clauses)
3837 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3838 gs->gimple_omp_single.clauses = clauses;
3842 /* Return the clauses associated with OMP_SECTIONS GS. */
3845 gimple_omp_sections_clauses (const_gimple gs)
3847 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3848 return gs->gimple_omp_sections.clauses;
3852 /* Return a pointer to the clauses associated with OMP_SECTIONS GS. */
3854 static inline tree *
3855 gimple_omp_sections_clauses_ptr (gimple gs)
3857 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3858 return &gs->gimple_omp_sections.clauses;
3862 /* Set CLAUSES to be the set of clauses associated with OMP_SECTIONS
3866 gimple_omp_sections_set_clauses (gimple gs, tree clauses)
3868 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3869 gs->gimple_omp_sections.clauses = clauses;
3873 /* Return the control variable associated with the GIMPLE_OMP_SECTIONS
3877 gimple_omp_sections_control (const_gimple gs)
3879 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3880 return gs->gimple_omp_sections.control;
3884 /* Return a pointer to the clauses associated with the GIMPLE_OMP_SECTIONS
3887 static inline tree *
3888 gimple_omp_sections_control_ptr (gimple gs)
3890 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3891 return &gs->gimple_omp_sections.control;
3895 /* Set CONTROL to be the set of clauses associated with the
3896 GIMPLE_OMP_SECTIONS in GS. */
3899 gimple_omp_sections_set_control (gimple gs, tree control)
3901 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3902 gs->gimple_omp_sections.control = control;
3906 /* Set COND to be the condition code for OMP_FOR GS. */
3909 gimple_omp_for_set_cond (gimple gs, size_t i, enum tree_code cond)
3911 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3912 gcc_assert (TREE_CODE_CLASS (cond) == tcc_comparison);
3913 gcc_assert (i < gs->gimple_omp_for.collapse);
3914 gs->gimple_omp_for.iter[i].cond = cond;
3918 /* Return the condition code associated with OMP_FOR GS. */
3920 static inline enum tree_code
3921 gimple_omp_for_cond (const_gimple gs, size_t i)
3923 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3924 gcc_assert (i < gs->gimple_omp_for.collapse);
3925 return gs->gimple_omp_for.iter[i].cond;
3929 /* Set the value being stored in an atomic store. */
3932 gimple_omp_atomic_store_set_val (gimple g, tree val)
3934 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3935 g->gimple_omp_atomic_store.val = val;
3939 /* Return the value being stored in an atomic store. */
3942 gimple_omp_atomic_store_val (const_gimple g)
3944 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3945 return g->gimple_omp_atomic_store.val;
3949 /* Return a pointer to the value being stored in an atomic store. */
3951 static inline tree *
3952 gimple_omp_atomic_store_val_ptr (gimple g)
3954 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3955 return &g->gimple_omp_atomic_store.val;
3959 /* Set the LHS of an atomic load. */
3962 gimple_omp_atomic_load_set_lhs (gimple g, tree lhs)
3964 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
3965 g->gimple_omp_atomic_load.lhs = lhs;
3969 /* Get the LHS of an atomic load. */
3972 gimple_omp_atomic_load_lhs (const_gimple g)
3974 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
3975 return g->gimple_omp_atomic_load.lhs;
3979 /* Return a pointer to the LHS of an atomic load. */
3981 static inline tree *
3982 gimple_omp_atomic_load_lhs_ptr (gimple g)
3984 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
3985 return &g->gimple_omp_atomic_load.lhs;
3989 /* Set the RHS of an atomic load. */
3992 gimple_omp_atomic_load_set_rhs (gimple g, tree rhs)
3994 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
3995 g->gimple_omp_atomic_load.rhs = rhs;
3999 /* Get the RHS of an atomic load. */
4002 gimple_omp_atomic_load_rhs (const_gimple g)
4004 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4005 return g->gimple_omp_atomic_load.rhs;
4009 /* Return a pointer to the RHS of an atomic load. */
4011 static inline tree *
4012 gimple_omp_atomic_load_rhs_ptr (gimple g)
4014 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4015 return &g->gimple_omp_atomic_load.rhs;
4019 /* Get the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4022 gimple_omp_continue_control_def (const_gimple g)
4024 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4025 return g->gimple_omp_continue.control_def;
4028 /* The same as above, but return the address. */
4030 static inline tree *
4031 gimple_omp_continue_control_def_ptr (gimple g)
4033 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4034 return &g->gimple_omp_continue.control_def;
4037 /* Set the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4040 gimple_omp_continue_set_control_def (gimple g, tree def)
4042 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4043 g->gimple_omp_continue.control_def = def;
4047 /* Get the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4050 gimple_omp_continue_control_use (const_gimple g)
4052 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4053 return g->gimple_omp_continue.control_use;
4057 /* The same as above, but return the address. */
4059 static inline tree *
4060 gimple_omp_continue_control_use_ptr (gimple g)
4062 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4063 return &g->gimple_omp_continue.control_use;
4067 /* Set the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4070 gimple_omp_continue_set_control_use (gimple g, tree use)
4072 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4073 g->gimple_omp_continue.control_use = use;
4077 /* Return a pointer to the return value for GIMPLE_RETURN GS. */
4079 static inline tree *
4080 gimple_return_retval_ptr (const_gimple gs)
4082 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4083 gcc_assert (gimple_num_ops (gs) == 1);
4084 return gimple_op_ptr (gs, 0);
4087 /* Return the return value for GIMPLE_RETURN GS. */
4090 gimple_return_retval (const_gimple gs)
4092 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4093 gcc_assert (gimple_num_ops (gs) == 1);
4094 return gimple_op (gs, 0);
4098 /* Set RETVAL to be the return value for GIMPLE_RETURN GS. */
4101 gimple_return_set_retval (gimple gs, tree retval)
4103 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4104 gcc_assert (gimple_num_ops (gs) == 1);
4105 gcc_assert (retval == NULL_TREE
4106 || TREE_CODE (retval) == RESULT_DECL
4107 || is_gimple_val (retval));
4108 gimple_set_op (gs, 0, retval);
4112 /* Returns true when the gimple statment STMT is any of the OpenMP types. */
4115 is_gimple_omp (const_gimple stmt)
4117 return (gimple_code (stmt) == GIMPLE_OMP_PARALLEL
4118 || gimple_code (stmt) == GIMPLE_OMP_TASK
4119 || gimple_code (stmt) == GIMPLE_OMP_FOR
4120 || gimple_code (stmt) == GIMPLE_OMP_SECTIONS
4121 || gimple_code (stmt) == GIMPLE_OMP_SECTIONS_SWITCH
4122 || gimple_code (stmt) == GIMPLE_OMP_SINGLE
4123 || gimple_code (stmt) == GIMPLE_OMP_SECTION
4124 || gimple_code (stmt) == GIMPLE_OMP_MASTER
4125 || gimple_code (stmt) == GIMPLE_OMP_ORDERED
4126 || gimple_code (stmt) == GIMPLE_OMP_CRITICAL
4127 || gimple_code (stmt) == GIMPLE_OMP_RETURN
4128 || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_LOAD
4129 || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_STORE
4130 || gimple_code (stmt) == GIMPLE_OMP_CONTINUE);
4134 /* Returns TRUE if statement G is a GIMPLE_NOP. */
4137 gimple_nop_p (const_gimple g)
4139 return gimple_code (g) == GIMPLE_NOP;
4143 /* Return the new type set by GIMPLE_CHANGE_DYNAMIC_TYPE statement GS. */
4146 gimple_cdt_new_type (gimple gs)
4148 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4149 return gimple_op (gs, 1);
4152 /* Return a pointer to the new type set by GIMPLE_CHANGE_DYNAMIC_TYPE
4155 static inline tree *
4156 gimple_cdt_new_type_ptr (gimple gs)
4158 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4159 return gimple_op_ptr (gs, 1);
4162 /* Set NEW_TYPE to be the type returned by GIMPLE_CHANGE_DYNAMIC_TYPE
4166 gimple_cdt_set_new_type (gimple gs, tree new_type)
4168 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4169 gcc_assert (TREE_CODE_CLASS (TREE_CODE (new_type)) == tcc_type);
4170 gimple_set_op (gs, 1, new_type);
4174 /* Return the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE statement GS. */
4177 gimple_cdt_location (gimple gs)
4179 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4180 return gimple_op (gs, 0);
4184 /* Return a pointer to the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE
4187 static inline tree *
4188 gimple_cdt_location_ptr (gimple gs)
4190 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4191 return gimple_op_ptr (gs, 0);
4195 /* Set PTR to be the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE
4199 gimple_cdt_set_location (gimple gs, tree ptr)
4201 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4202 gimple_set_op (gs, 0, ptr);
4206 /* Return the predictor of GIMPLE_PREDICT statement GS. */
4208 static inline enum br_predictor
4209 gimple_predict_predictor (gimple gs)
4211 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4212 return (enum br_predictor) (gs->gsbase.subcode & ~GF_PREDICT_TAKEN);
4216 /* Set the predictor of GIMPLE_PREDICT statement GS to PREDICT. */
4219 gimple_predict_set_predictor (gimple gs, enum br_predictor predictor)
4221 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4222 gs->gsbase.subcode = (gs->gsbase.subcode & GF_PREDICT_TAKEN)
4223 | (unsigned) predictor;
4227 /* Return the outcome of GIMPLE_PREDICT statement GS. */
4229 static inline enum prediction
4230 gimple_predict_outcome (gimple gs)
4232 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4233 return (gs->gsbase.subcode & GF_PREDICT_TAKEN) ? TAKEN : NOT_TAKEN;
4237 /* Set the outcome of GIMPLE_PREDICT statement GS to OUTCOME. */
4240 gimple_predict_set_outcome (gimple gs, enum prediction outcome)
4242 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4243 if (outcome == TAKEN)
4244 gs->gsbase.subcode |= GF_PREDICT_TAKEN;
4246 gs->gsbase.subcode &= ~GF_PREDICT_TAKEN;
4250 /* Return a new iterator pointing to GIMPLE_SEQ's first statement. */
4252 static inline gimple_stmt_iterator
4253 gsi_start (gimple_seq seq)
4255 gimple_stmt_iterator i;
4257 i.ptr = gimple_seq_first (seq);
4259 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4265 /* Return a new iterator pointing to the first statement in basic block BB. */
4267 static inline gimple_stmt_iterator
4268 gsi_start_bb (basic_block bb)
4270 gimple_stmt_iterator i;
4274 i.ptr = gimple_seq_first (seq);
4282 /* Return a new iterator initially pointing to GIMPLE_SEQ's last statement. */
4284 static inline gimple_stmt_iterator
4285 gsi_last (gimple_seq seq)
4287 gimple_stmt_iterator i;
4289 i.ptr = gimple_seq_last (seq);
4291 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4297 /* Return a new iterator pointing to the last statement in basic block BB. */
4299 static inline gimple_stmt_iterator
4300 gsi_last_bb (basic_block bb)
4302 gimple_stmt_iterator i;
4306 i.ptr = gimple_seq_last (seq);
4314 /* Return true if I is at the end of its sequence. */
4317 gsi_end_p (gimple_stmt_iterator i)
4319 return i.ptr == NULL;
4323 /* Return true if I is one statement before the end of its sequence. */
4326 gsi_one_before_end_p (gimple_stmt_iterator i)
4328 return i.ptr != NULL && i.ptr->next == NULL;
4332 /* Advance the iterator to the next gimple statement. */
4335 gsi_next (gimple_stmt_iterator *i)
4337 i->ptr = i->ptr->next;
4340 /* Advance the iterator to the previous gimple statement. */
4343 gsi_prev (gimple_stmt_iterator *i)
4345 i->ptr = i->ptr->prev;
4348 /* Return the current stmt. */
4350 static inline gimple
4351 gsi_stmt (gimple_stmt_iterator i)
4356 /* Return a block statement iterator that points to the first non-label
4357 statement in block BB. */
4359 static inline gimple_stmt_iterator
4360 gsi_after_labels (basic_block bb)
4362 gimple_stmt_iterator gsi = gsi_start_bb (bb);
4364 while (!gsi_end_p (gsi) && gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL)
4370 /* Return a pointer to the current stmt.
4372 NOTE: You may want to use gsi_replace on the iterator itself,
4373 as this performs additional bookkeeping that will not be done
4374 if you simply assign through a pointer returned by gsi_stmt_ptr. */
4376 static inline gimple *
4377 gsi_stmt_ptr (gimple_stmt_iterator *i)
4379 return &i->ptr->stmt;
4383 /* Return the basic block associated with this iterator. */
4385 static inline basic_block
4386 gsi_bb (gimple_stmt_iterator i)
4392 /* Return the sequence associated with this iterator. */
4394 static inline gimple_seq
4395 gsi_seq (gimple_stmt_iterator i)
4401 enum gsi_iterator_update
4403 GSI_NEW_STMT, /* Only valid when single statement is added, move
4405 GSI_SAME_STMT, /* Leave the iterator at the same statement. */
4406 GSI_CONTINUE_LINKING /* Move iterator to whatever position is suitable
4407 for linking other statements in the same
4411 /* In gimple-iterator.c */
4412 gimple_stmt_iterator gsi_start_phis (basic_block);
4413 gimple_seq gsi_split_seq_after (gimple_stmt_iterator);
4414 gimple_seq gsi_split_seq_before (gimple_stmt_iterator *);
4415 void gsi_replace (gimple_stmt_iterator *, gimple, bool);
4416 void gsi_insert_before (gimple_stmt_iterator *, gimple,
4417 enum gsi_iterator_update);
4418 void gsi_insert_before_without_update (gimple_stmt_iterator *, gimple,
4419 enum gsi_iterator_update);
4420 void gsi_insert_seq_before (gimple_stmt_iterator *, gimple_seq,
4421 enum gsi_iterator_update);
4422 void gsi_insert_seq_before_without_update (gimple_stmt_iterator *, gimple_seq,
4423 enum gsi_iterator_update);
4424 void gsi_insert_after (gimple_stmt_iterator *, gimple,
4425 enum gsi_iterator_update);
4426 void gsi_insert_after_without_update (gimple_stmt_iterator *, gimple,
4427 enum gsi_iterator_update);
4428 void gsi_insert_seq_after (gimple_stmt_iterator *, gimple_seq,
4429 enum gsi_iterator_update);
4430 void gsi_insert_seq_after_without_update (gimple_stmt_iterator *, gimple_seq,
4431 enum gsi_iterator_update);
4432 void gsi_remove (gimple_stmt_iterator *, bool);
4433 gimple_stmt_iterator gsi_for_stmt (gimple);
4434 void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *);
4435 void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *);
4436 void gsi_move_to_bb_end (gimple_stmt_iterator *, struct basic_block_def *);
4437 void gsi_insert_on_edge (edge, gimple);
4438 void gsi_insert_seq_on_edge (edge, gimple_seq);
4439 basic_block gsi_insert_on_edge_immediate (edge, gimple);
4440 basic_block gsi_insert_seq_on_edge_immediate (edge, gimple_seq);
4441 void gsi_commit_one_edge_insert (edge, basic_block *);
4442 void gsi_commit_edge_inserts (void);
4445 /* Convenience routines to walk all statements of a gimple function.
4446 Note that this is useful exclusively before the code is converted
4447 into SSA form. Once the program is in SSA form, the standard
4448 operand interface should be used to analyze/modify statements. */
4449 struct walk_stmt_info
4451 /* Points to the current statement being walked. */
4452 gimple_stmt_iterator gsi;
4454 /* Additional data that the callback functions may want to carry
4455 through the recursion. */
4458 /* Pointer map used to mark visited tree nodes when calling
4459 walk_tree on each operand. If set to NULL, duplicate tree nodes
4460 will be visited more than once. */
4461 struct pointer_set_t *pset;
4463 /* Indicates whether the operand being examined may be replaced
4464 with something that matches is_gimple_val (if true) or something
4465 slightly more complicated (if false). "Something" technically
4466 means the common subset of is_gimple_lvalue and is_gimple_rhs,
4467 but we never try to form anything more complicated than that, so
4468 we don't bother checking.
4470 Also note that CALLBACK should update this flag while walking the
4471 sub-expressions of a statement. For instance, when walking the
4472 statement 'foo (&var)', the flag VAL_ONLY will initially be set
4473 to true, however, when walking &var, the operand of that
4474 ADDR_EXPR does not need to be a GIMPLE value. */
4477 /* True if we are currently walking the LHS of an assignment. */
4480 /* Optional. Set to true by the callback functions if they made any
4484 /* True if we're interested in location information. */
4485 bool want_locations;
4487 /* Operand returned by the callbacks. This is set when calling
4488 walk_gimple_seq. If the walk_stmt_fn or walk_tree_fn callback
4489 returns non-NULL, this field will contain the tree returned by
4490 the last callback. */
4491 tree callback_result;
4494 /* Callback for walk_gimple_stmt. Called for every statement found
4495 during traversal. The first argument points to the statement to
4496 walk. The second argument is a flag that the callback sets to
4497 'true' if it the callback handled all the operands and
4498 sub-statements of the statement (the default value of this flag is
4499 'false'). The third argument is an anonymous pointer to data
4500 to be used by the callback. */
4501 typedef tree (*walk_stmt_fn) (gimple_stmt_iterator *, bool *,
4502 struct walk_stmt_info *);
4504 gimple walk_gimple_seq (gimple_seq, walk_stmt_fn, walk_tree_fn,
4505 struct walk_stmt_info *);
4506 tree walk_gimple_stmt (gimple_stmt_iterator *, walk_stmt_fn, walk_tree_fn,
4507 struct walk_stmt_info *);
4508 tree walk_gimple_op (gimple, walk_tree_fn, struct walk_stmt_info *);
4510 #ifdef GATHER_STATISTICS
4511 /* Enum and arrays used for allocation stats. Keep in sync with
4512 gimple.c:gimple_alloc_kind_names. */
4513 enum gimple_alloc_kind
4515 gimple_alloc_kind_assign, /* Assignments. */
4516 gimple_alloc_kind_phi, /* PHI nodes. */
4517 gimple_alloc_kind_cond, /* Conditionals. */
4518 gimple_alloc_kind_seq, /* Sequences. */
4519 gimple_alloc_kind_rest, /* Everything else. */
4520 gimple_alloc_kind_all
4523 extern int gimple_alloc_counts[];
4524 extern int gimple_alloc_sizes[];
4526 /* Return the allocation kind for a given stmt CODE. */
4527 static inline enum gimple_alloc_kind
4528 gimple_alloc_kind (enum gimple_code code)
4533 return gimple_alloc_kind_assign;
4535 return gimple_alloc_kind_phi;
4537 return gimple_alloc_kind_cond;
4539 return gimple_alloc_kind_rest;
4542 #endif /* GATHER_STATISTICS */
4544 extern void dump_gimple_statistics (void);
4546 #endif /* GCC_GIMPLE_H */