1 /* Gimple IR definitions.
3 Copyright 2007, 2008, 2009 Free Software Foundation, Inc.
4 Contributed by Aldy Hernandez <aldyh@redhat.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
25 #include "pointer-set.h"
29 #include "hard-reg-set.h"
30 #include "basic-block.h"
31 #include "tree-ssa-operands.h"
34 DEF_VEC_ALLOC_P(gimple,heap);
35 DEF_VEC_ALLOC_P(gimple,gc);
37 typedef gimple *gimple_p;
39 DEF_VEC_ALLOC_P(gimple_p,heap);
41 DEF_VEC_P(gimple_seq);
42 DEF_VEC_ALLOC_P(gimple_seq,gc);
43 DEF_VEC_ALLOC_P(gimple_seq,heap);
45 /* For each block, the PHI nodes that need to be rewritten are stored into
47 typedef VEC(gimple, heap) *gimple_vec;
48 DEF_VEC_P (gimple_vec);
49 DEF_VEC_ALLOC_P (gimple_vec, heap);
52 #define DEFGSCODE(SYM, STRING, STRUCT) SYM,
55 LAST_AND_UNUSED_GIMPLE_CODE
58 extern const char *const gimple_code_name[];
59 extern const unsigned char gimple_rhs_class_table[];
61 /* Error out if a gimple tuple is addressed incorrectly. */
62 #if defined ENABLE_GIMPLE_CHECKING
63 extern void gimple_check_failed (const_gimple, const char *, int, \
64 const char *, enum gimple_code, \
65 enum tree_code) ATTRIBUTE_NORETURN;
67 #define GIMPLE_CHECK(GS, CODE) \
69 const_gimple __gs = (GS); \
70 if (gimple_code (__gs) != (CODE)) \
71 gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__, \
72 (CODE), ERROR_MARK); \
74 #else /* not ENABLE_GIMPLE_CHECKING */
75 #define GIMPLE_CHECK(GS, CODE) (void)0
78 /* Class of GIMPLE expressions suitable for the RHS of assignments. See
79 get_gimple_rhs_class. */
82 GIMPLE_INVALID_RHS, /* The expression cannot be used on the RHS. */
83 GIMPLE_BINARY_RHS, /* The expression is a binary operation. */
84 GIMPLE_UNARY_RHS, /* The expression is a unary operation. */
85 GIMPLE_SINGLE_RHS /* The expression is a single object (an SSA
86 name, a _DECL, a _REF, etc. */
89 /* Specific flags for individual GIMPLE statements. These flags are
90 always stored in gimple_statement_base.subcode and they may only be
91 defined for statement codes that do not use sub-codes.
93 Values for the masks can overlap as long as the overlapping values
94 are never used in the same statement class.
96 The maximum mask value that can be defined is 1 << 15 (i.e., each
97 statement code can hold up to 16 bitflags).
99 Keep this list sorted. */
101 GF_ASM_INPUT = 1 << 0,
102 GF_ASM_VOLATILE = 1 << 1,
103 GF_CALL_CANNOT_INLINE = 1 << 0,
104 GF_CALL_FROM_THUNK = 1 << 1,
105 GF_CALL_RETURN_SLOT_OPT = 1 << 2,
106 GF_CALL_TAILCALL = 1 << 3,
107 GF_CALL_VA_ARG_PACK = 1 << 4,
108 GF_OMP_PARALLEL_COMBINED = 1 << 0,
110 /* True on an GIMPLE_OMP_RETURN statement if the return does not require
111 a thread synchronization via some sort of barrier. The exact barrier
112 that would otherwise be emitted is dependent on the OMP statement with
113 which this return is associated. */
114 GF_OMP_RETURN_NOWAIT = 1 << 0,
116 GF_OMP_SECTION_LAST = 1 << 0,
117 GF_PREDICT_TAKEN = 1 << 15
120 /* Masks for selecting a pass local flag (PLF) to work on. These
121 masks are used by gimple_set_plf and gimple_plf. */
127 /* A node in a gimple_seq_d. */
128 struct gimple_seq_node_d GTY((chain_next ("%h.next"), chain_prev ("%h.prev")))
131 struct gimple_seq_node_d *prev;
132 struct gimple_seq_node_d *next;
135 /* A double-linked sequence of gimple statements. */
136 struct gimple_seq_d GTY ((chain_next ("%h.next_free")))
138 /* First and last statements in the sequence. */
139 gimple_seq_node first;
140 gimple_seq_node last;
142 /* Sequences are created/destroyed frequently. To minimize
143 allocation activity, deallocated sequences are kept in a pool of
144 available sequences. This is the pointer to the next free
145 sequence in the pool. */
146 gimple_seq next_free;
150 /* Return the first node in GIMPLE sequence S. */
152 static inline gimple_seq_node
153 gimple_seq_first (const_gimple_seq s)
155 return s ? s->first : NULL;
159 /* Return the first statement in GIMPLE sequence S. */
162 gimple_seq_first_stmt (const_gimple_seq s)
164 gimple_seq_node n = gimple_seq_first (s);
165 return (n) ? n->stmt : NULL;
169 /* Return the last node in GIMPLE sequence S. */
171 static inline gimple_seq_node
172 gimple_seq_last (const_gimple_seq s)
174 return s ? s->last : NULL;
178 /* Return the last statement in GIMPLE sequence S. */
181 gimple_seq_last_stmt (const_gimple_seq s)
183 gimple_seq_node n = gimple_seq_last (s);
184 return (n) ? n->stmt : NULL;
188 /* Set the last node in GIMPLE sequence S to LAST. */
191 gimple_seq_set_last (gimple_seq s, gimple_seq_node last)
197 /* Set the first node in GIMPLE sequence S to FIRST. */
200 gimple_seq_set_first (gimple_seq s, gimple_seq_node first)
206 /* Return true if GIMPLE sequence S is empty. */
209 gimple_seq_empty_p (const_gimple_seq s)
211 return s == NULL || s->first == NULL;
215 void gimple_seq_add_stmt (gimple_seq *, gimple);
217 /* Allocate a new sequence and initialize its first element with STMT. */
219 static inline gimple_seq
220 gimple_seq_alloc_with_stmt (gimple stmt)
222 gimple_seq seq = NULL;
223 gimple_seq_add_stmt (&seq, stmt);
228 /* Returns the sequence of statements in BB. */
230 static inline gimple_seq
231 bb_seq (const_basic_block bb)
233 return (!(bb->flags & BB_RTL) && bb->il.gimple) ? bb->il.gimple->seq : NULL;
237 /* Sets the sequence of statements in BB to SEQ. */
240 set_bb_seq (basic_block bb, gimple_seq seq)
242 gcc_assert (!(bb->flags & BB_RTL));
243 bb->il.gimple->seq = seq;
246 /* Iterator object for GIMPLE statement sequences. */
250 /* Sequence node holding the current statement. */
253 /* Sequence and basic block holding the statement. These fields
254 are necessary to handle edge cases such as when statement is
255 added to an empty basic block or when the last statement of a
256 block/sequence is removed. */
259 } gimple_stmt_iterator;
262 /* Data structure definitions for GIMPLE tuples. NOTE: word markers
263 are for 64 bit hosts. */
265 struct gimple_statement_base GTY(())
268 Main identifying code for a tuple. */
269 ENUM_BITFIELD(gimple_code) code : 8;
271 /* Nonzero if a warning should not be emitted on this tuple. */
272 unsigned int no_warning : 1;
274 /* Nonzero if this tuple has been visited. Passes are responsible
275 for clearing this bit before using it. */
276 unsigned int visited : 1;
278 /* Nonzero if this tuple represents a non-temporal move. */
279 unsigned int nontemporal_move : 1;
281 /* Pass local flags. These flags are free for any pass to use as
282 they see fit. Passes should not assume that these flags contain
283 any useful value when the pass starts. Any initial state that
284 the pass requires should be set on entry to the pass. See
285 gimple_set_plf and gimple_plf for usage. */
286 unsigned int plf : 2;
288 /* Nonzero if this statement has been modified and needs to have its
289 operands rescanned. */
290 unsigned modified : 1;
292 /* Nonzero if this statement contains volatile operands. */
293 unsigned has_volatile_ops : 1;
295 /* Padding to get subcode to 16 bit alignment. */
298 /* The SUBCODE field can be used for tuple-specific flags for tuples
299 that do not require subcodes. Note that SUBCODE should be at
300 least as wide as tree codes, as several tuples store tree codes
302 unsigned int subcode : 16;
304 /* UID of this statement. This is used by passes that want to
305 assign IDs to statements. It must be assigned and used by each
306 pass. By default it should be assumed to contain garbage. */
310 Locus information for debug info. */
313 /* Number of operands in this tuple. */
317 Basic block holding this statement. */
318 struct basic_block_def *bb;
321 Lexical block holding this statement. */
326 /* Base structure for tuples with operands. */
328 struct gimple_statement_with_ops_base GTY(())
331 struct gimple_statement_base gsbase;
334 SSA operand vectors. NOTE: It should be possible to
335 amalgamate these vectors with the operand vector OP. However,
336 the SSA operand vectors are organized differently and contain
337 more information (like immediate use chaining). */
338 struct def_optype_d GTY((skip (""))) *def_ops;
339 struct use_optype_d GTY((skip (""))) *use_ops;
343 /* Statements that take register operands. */
345 struct gimple_statement_with_ops GTY(())
348 struct gimple_statement_with_ops_base opbase;
351 Operand vector. NOTE! This must always be the last field
352 of this structure. In particular, this means that this
353 structure cannot be embedded inside another one. */
354 tree GTY((length ("%h.opbase.gsbase.num_ops"))) op[1];
358 /* Base for statements that take both memory and register operands. */
360 struct gimple_statement_with_memory_ops_base GTY(())
363 struct gimple_statement_with_ops_base opbase;
366 Virtual operands for this statement. The GC will pick them
367 up via the ssa_names array. */
368 tree GTY((skip (""))) vdef;
369 tree GTY((skip (""))) vuse;
373 /* Statements that take both memory and register operands. */
375 struct gimple_statement_with_memory_ops GTY(())
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, enum gimple_try_flags);
794 gimple gimple_build_wce (gimple_seq);
795 gimple gimple_build_resx (int);
796 gimple gimple_build_switch (unsigned, tree, tree, ...);
797 gimple gimple_build_switch_vec (tree, tree, VEC(tree,heap) *);
798 gimple gimple_build_omp_parallel (gimple_seq, tree, tree, tree);
799 gimple gimple_build_omp_task (gimple_seq, tree, tree, tree, tree, tree, tree);
800 gimple gimple_build_omp_for (gimple_seq, tree, size_t, gimple_seq);
801 gimple gimple_build_omp_critical (gimple_seq, tree);
802 gimple gimple_build_omp_section (gimple_seq);
803 gimple gimple_build_omp_continue (tree, tree);
804 gimple gimple_build_omp_master (gimple_seq);
805 gimple gimple_build_omp_return (bool);
806 gimple gimple_build_omp_ordered (gimple_seq);
807 gimple gimple_build_omp_sections (gimple_seq, tree);
808 gimple gimple_build_omp_sections_switch (void);
809 gimple gimple_build_omp_single (gimple_seq, tree);
810 gimple gimple_build_cdt (tree, tree);
811 gimple gimple_build_omp_atomic_load (tree, tree);
812 gimple gimple_build_omp_atomic_store (tree);
813 gimple gimple_build_predict (enum br_predictor, enum prediction);
814 enum gimple_statement_structure_enum gimple_statement_structure (gimple);
815 enum gimple_statement_structure_enum gss_for_assign (enum tree_code);
816 void sort_case_labels (VEC(tree,heap) *);
817 void gimple_set_body (tree, gimple_seq);
818 gimple_seq gimple_body (tree);
819 bool gimple_has_body_p (tree);
820 gimple_seq gimple_seq_alloc (void);
821 void gimple_seq_free (gimple_seq);
822 void gimple_seq_add_seq (gimple_seq *, gimple_seq);
823 gimple_seq gimple_seq_copy (gimple_seq);
824 int gimple_call_flags (const_gimple);
825 bool gimple_assign_copy_p (gimple);
826 bool gimple_assign_ssa_name_copy_p (gimple);
827 bool gimple_assign_single_p (gimple);
828 bool gimple_assign_unary_nop_p (gimple);
829 void gimple_set_bb (gimple, struct basic_block_def *);
830 tree gimple_fold (const_gimple);
831 void gimple_assign_set_rhs_from_tree (gimple_stmt_iterator *, tree);
832 void gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *, enum tree_code,
834 tree gimple_get_lhs (const_gimple);
835 void gimple_set_lhs (gimple, tree);
836 gimple gimple_copy (gimple);
837 bool is_gimple_operand (const_tree);
838 void gimple_set_modified (gimple, bool);
839 void gimple_cond_get_ops_from_tree (tree, enum tree_code *, tree *, tree *);
840 gimple gimple_build_cond_from_tree (tree, tree, tree);
841 void gimple_cond_set_condition_from_tree (gimple, tree);
842 bool gimple_has_side_effects (const_gimple);
843 bool gimple_rhs_has_side_effects (const_gimple);
844 bool gimple_could_trap_p (gimple);
845 bool gimple_assign_rhs_could_trap_p (gimple);
846 void gimple_regimplify_operands (gimple, gimple_stmt_iterator *);
847 bool empty_body_p (gimple_seq);
848 unsigned get_gimple_rhs_num_ops (enum tree_code);
850 /* Returns true iff T is a valid GIMPLE statement. */
851 extern bool is_gimple_stmt (tree);
853 /* Returns true iff TYPE is a valid type for a scalar register variable. */
854 extern bool is_gimple_reg_type (tree);
855 /* Returns true iff T is a scalar register variable. */
856 extern bool is_gimple_reg (tree);
857 /* Returns true iff T is any sort of variable. */
858 extern bool is_gimple_variable (tree);
859 /* Returns true iff T is any sort of symbol. */
860 extern bool is_gimple_id (tree);
861 /* Returns true iff T is a variable or an INDIRECT_REF (of a variable). */
862 extern bool is_gimple_min_lval (tree);
863 /* Returns true iff T is something whose address can be taken. */
864 extern bool is_gimple_addressable (tree);
865 /* Returns true iff T is any valid GIMPLE lvalue. */
866 extern bool is_gimple_lvalue (tree);
868 /* Returns true iff T is a GIMPLE address. */
869 bool is_gimple_address (const_tree);
870 /* Returns true iff T is a GIMPLE invariant address. */
871 bool is_gimple_invariant_address (const_tree);
872 /* Returns true iff T is a GIMPLE invariant address at interprocedural
874 bool is_gimple_ip_invariant_address (const_tree);
875 /* Returns true iff T is a valid GIMPLE constant. */
876 bool is_gimple_constant (const_tree);
877 /* Returns true iff T is a GIMPLE restricted function invariant. */
878 extern bool is_gimple_min_invariant (const_tree);
879 /* Returns true iff T is a GIMPLE restricted interprecodural invariant. */
880 extern bool is_gimple_ip_invariant (const_tree);
881 /* Returns true iff T is a GIMPLE rvalue. */
882 extern bool is_gimple_val (tree);
883 /* Returns true iff T is a GIMPLE asm statement input. */
884 extern bool is_gimple_asm_val (tree);
885 /* Returns true iff T is a valid rhs for a MODIFY_EXPR where the LHS is a
886 GIMPLE temporary, a renamed user variable, or something else,
888 extern bool is_gimple_reg_rhs (tree);
889 extern bool is_gimple_mem_rhs (tree);
891 /* Returns true iff T is a valid if-statement condition. */
892 extern bool is_gimple_condexpr (tree);
894 /* Returns true iff T is a type conversion. */
895 extern bool is_gimple_cast (tree);
896 /* Returns true iff T is a variable that does not need to live in memory. */
897 extern bool is_gimple_non_addressable (tree t);
899 /* Returns true iff T is a valid call address expression. */
900 extern bool is_gimple_call_addr (tree);
901 /* If T makes a function call, returns the CALL_EXPR operand. */
902 extern tree get_call_expr_in (tree t);
904 extern void recalculate_side_effects (tree);
905 extern void count_uses_and_derefs (tree, gimple, unsigned *, unsigned *,
907 extern bool walk_stmt_load_store_addr_ops (gimple, void *,
908 bool (*)(gimple, tree, void *),
909 bool (*)(gimple, tree, void *),
910 bool (*)(gimple, tree, void *));
911 extern bool walk_stmt_load_store_ops (gimple, void *,
912 bool (*)(gimple, tree, void *),
913 bool (*)(gimple, tree, void *));
914 extern bool gimple_ior_addresses_taken (bitmap, gimple);
917 extern tree create_tmp_var_raw (tree, const char *);
918 extern tree create_tmp_var_name (const char *);
919 extern tree create_tmp_var (tree, const char *);
920 extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq *);
921 extern tree get_formal_tmp_var (tree, gimple_seq *);
922 extern void declare_vars (tree, gimple, bool);
923 extern void tree_annotate_all_with_location (tree *, location_t);
924 extern void annotate_all_with_location (gimple_seq, location_t);
926 /* Validation of GIMPLE expressions. Note that these predicates only check
927 the basic form of the expression, they don't recurse to make sure that
928 underlying nodes are also of the right form. */
929 typedef bool (*gimple_predicate)(tree);
932 /* FIXME we should deduce this from the predicate. */
934 fb_none = 0, /* Do not generate a temporary. */
936 fb_rvalue = 1, /* Generate an rvalue to hold the result of a
937 gimplified expression. */
939 fb_lvalue = 2, /* Generate an lvalue to hold the result of a
940 gimplified expression. */
942 fb_mayfail = 4, /* Gimplification may fail. Error issued
944 fb_either= fb_rvalue | fb_lvalue
947 typedef int fallback_t;
949 enum gimplify_status {
950 GS_ERROR = -2, /* Something Bad Seen. */
951 GS_UNHANDLED = -1, /* A langhook result for "I dunno". */
952 GS_OK = 0, /* We did something, maybe more to do. */
953 GS_ALL_DONE = 1 /* The expression is fully gimplified. */
958 struct gimplify_ctx *prev_context;
960 VEC(gimple,heap) *bind_expr_stack;
962 gimple_seq conditional_cleanups;
966 VEC(tree,heap) *case_labels;
967 /* The formal temporary table. Should this be persistent? */
973 bool allow_rhs_cond_expr;
976 extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *,
977 bool (*) (tree), fallback_t);
978 extern void gimplify_type_sizes (tree, gimple_seq *);
979 extern void gimplify_one_sizepos (tree *, gimple_seq *);
980 extern bool gimplify_stmt (tree *, gimple_seq *);
981 extern gimple gimplify_body (tree *, tree, bool);
982 extern void push_gimplify_context (struct gimplify_ctx *);
983 extern void pop_gimplify_context (gimple);
984 extern void gimplify_and_add (tree, gimple_seq *);
986 /* Miscellaneous helpers. */
987 extern void gimple_add_tmp_var (tree);
988 extern gimple gimple_current_bind_expr (void);
989 extern VEC(gimple, heap) *gimple_bind_expr_stack (void);
990 extern tree voidify_wrapper_expr (tree, tree);
991 extern tree build_and_jump (tree *);
992 extern tree alloc_stmt_list (void);
993 extern void free_stmt_list (tree);
994 extern tree force_labels_r (tree *, int *, void *);
995 extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *,
997 struct gimplify_omp_ctx;
998 extern void omp_firstprivatize_variable (struct gimplify_omp_ctx *, tree);
999 extern tree gimple_boolify (tree);
1000 extern gimple_predicate rhs_predicate_for (tree);
1001 extern tree canonicalize_cond_expr_cond (tree);
1004 extern void diagnose_omp_structured_block_errors (tree);
1005 extern tree omp_reduction_init (tree, tree);
1007 /* In tree-nested.c. */
1008 extern void lower_nested_functions (tree);
1009 extern void insert_field_into_struct (tree, tree);
1011 /* In gimplify.c. */
1012 extern void gimplify_function_tree (tree);
1014 /* In cfgexpand.c. */
1015 extern tree gimple_assign_rhs_to_tree (gimple);
1018 extern bool validate_gimple_arglist (const_gimple, ...);
1021 extern bool tree_ssa_useless_type_conversion (tree);
1022 extern bool useless_type_conversion_p (tree, tree);
1023 extern bool types_compatible_p (tree, tree);
1025 /* Return the code for GIMPLE statement G. */
1027 static inline enum gimple_code
1028 gimple_code (const_gimple g)
1030 return g->gsbase.code;
1034 /* Return true if statement G has sub-statements. This is only true for
1035 High GIMPLE statements. */
1038 gimple_has_substatements (gimple g)
1040 switch (gimple_code (g))
1044 case GIMPLE_EH_FILTER:
1046 case GIMPLE_OMP_FOR:
1047 case GIMPLE_OMP_MASTER:
1048 case GIMPLE_OMP_ORDERED:
1049 case GIMPLE_OMP_SECTION:
1050 case GIMPLE_OMP_PARALLEL:
1051 case GIMPLE_OMP_TASK:
1052 case GIMPLE_OMP_SECTIONS:
1053 case GIMPLE_OMP_SINGLE:
1054 case GIMPLE_OMP_CRITICAL:
1055 case GIMPLE_WITH_CLEANUP_EXPR:
1064 /* Return the basic block holding statement G. */
1066 static inline struct basic_block_def *
1067 gimple_bb (const_gimple g)
1069 return g->gsbase.bb;
1073 /* Return the lexical scope block holding statement G. */
1076 gimple_block (const_gimple g)
1078 return g->gsbase.block;
1082 /* Set BLOCK to be the lexical scope block holding statement G. */
1085 gimple_set_block (gimple g, tree block)
1087 g->gsbase.block = block;
1091 /* Return location information for statement G. */
1093 static inline location_t
1094 gimple_location (const_gimple g)
1096 return g->gsbase.location;
1099 /* Return pointer to location information for statement G. */
1101 static inline const location_t *
1102 gimple_location_ptr (const_gimple g)
1104 return &g->gsbase.location;
1108 /* Set location information for statement G. */
1111 gimple_set_location (gimple g, location_t location)
1113 g->gsbase.location = location;
1117 /* Return true if G contains location information. */
1120 gimple_has_location (const_gimple g)
1122 return gimple_location (g) != UNKNOWN_LOCATION;
1126 /* Return the file name of the location of STMT. */
1128 static inline const char *
1129 gimple_filename (const_gimple stmt)
1131 return LOCATION_FILE (gimple_location (stmt));
1135 /* Return the line number of the location of STMT. */
1138 gimple_lineno (const_gimple stmt)
1140 return LOCATION_LINE (gimple_location (stmt));
1144 /* Determine whether SEQ is a singleton. */
1147 gimple_seq_singleton_p (gimple_seq seq)
1149 return ((gimple_seq_first (seq) != NULL)
1150 && (gimple_seq_first (seq) == gimple_seq_last (seq)));
1153 /* Return true if no warnings should be emitted for statement STMT. */
1156 gimple_no_warning_p (const_gimple stmt)
1158 return stmt->gsbase.no_warning;
1161 /* Set the no_warning flag of STMT to NO_WARNING. */
1164 gimple_set_no_warning (gimple stmt, bool no_warning)
1166 stmt->gsbase.no_warning = (unsigned) no_warning;
1169 /* Set the visited status on statement STMT to VISITED_P. */
1172 gimple_set_visited (gimple stmt, bool visited_p)
1174 stmt->gsbase.visited = (unsigned) visited_p;
1178 /* Return the visited status for statement STMT. */
1181 gimple_visited_p (gimple stmt)
1183 return stmt->gsbase.visited;
1187 /* Set pass local flag PLF on statement STMT to VAL_P. */
1190 gimple_set_plf (gimple stmt, enum plf_mask plf, bool val_p)
1193 stmt->gsbase.plf |= (unsigned int) plf;
1195 stmt->gsbase.plf &= ~((unsigned int) plf);
1199 /* Return the value of pass local flag PLF on statement STMT. */
1201 static inline unsigned int
1202 gimple_plf (gimple stmt, enum plf_mask plf)
1204 return stmt->gsbase.plf & ((unsigned int) plf);
1208 /* Set the UID of statement. */
1211 gimple_set_uid (gimple g, unsigned uid)
1213 g->gsbase.uid = uid;
1217 /* Return the UID of statement. */
1219 static inline unsigned
1220 gimple_uid (const_gimple g)
1222 return g->gsbase.uid;
1226 /* Return true if GIMPLE statement G has register or memory operands. */
1229 gimple_has_ops (const_gimple g)
1231 return gimple_code (g) >= GIMPLE_COND && gimple_code (g) <= GIMPLE_RETURN;
1235 /* Return true if GIMPLE statement G has memory operands. */
1238 gimple_has_mem_ops (const_gimple g)
1240 return gimple_code (g) >= GIMPLE_ASSIGN && gimple_code (g) <= GIMPLE_RETURN;
1244 /* Return the set of DEF operands for statement G. */
1246 static inline struct def_optype_d *
1247 gimple_def_ops (const_gimple g)
1249 if (!gimple_has_ops (g))
1251 return g->gsops.opbase.def_ops;
1255 /* Set DEF to be the set of DEF operands for statement G. */
1258 gimple_set_def_ops (gimple g, struct def_optype_d *def)
1260 gcc_assert (gimple_has_ops (g));
1261 g->gsops.opbase.def_ops = def;
1265 /* Return the set of USE operands for statement G. */
1267 static inline struct use_optype_d *
1268 gimple_use_ops (const_gimple g)
1270 if (!gimple_has_ops (g))
1272 return g->gsops.opbase.use_ops;
1276 /* Set USE to be the set of USE operands for statement G. */
1279 gimple_set_use_ops (gimple g, struct use_optype_d *use)
1281 gcc_assert (gimple_has_ops (g));
1282 g->gsops.opbase.use_ops = use;
1286 /* Return the set of VUSE operand for statement G. */
1288 static inline use_operand_p
1289 gimple_vuse_op (const_gimple g)
1291 struct use_optype_d *ops;
1292 if (!gimple_has_mem_ops (g))
1293 return NULL_USE_OPERAND_P;
1294 ops = g->gsops.opbase.use_ops;
1296 && USE_OP_PTR (ops)->use == &g->gsmem.membase.vuse)
1297 return USE_OP_PTR (ops);
1298 return NULL_USE_OPERAND_P;
1301 /* Return the set of VDEF operand for statement G. */
1303 static inline def_operand_p
1304 gimple_vdef_op (const_gimple g)
1306 struct def_optype_d *ops;
1307 if (!gimple_has_mem_ops (g))
1308 return NULL_DEF_OPERAND_P;
1309 ops = g->gsops.opbase.def_ops;
1311 && DEF_OP_PTR (ops) == &g->gsmem.membase.vdef)
1312 return DEF_OP_PTR (ops);
1313 return NULL_DEF_OPERAND_P;
1317 /* Return the single VUSE operand of the statement G. */
1320 gimple_vuse (const_gimple g)
1322 if (!gimple_has_mem_ops (g))
1324 return g->gsmem.membase.vuse;
1327 /* Return the single VDEF operand of the statement G. */
1330 gimple_vdef (const_gimple g)
1332 if (!gimple_has_mem_ops (g))
1334 return g->gsmem.membase.vdef;
1337 /* Return the single VUSE operand of the statement G. */
1339 static inline tree *
1340 gimple_vuse_ptr (gimple g)
1342 if (!gimple_has_mem_ops (g))
1344 return &g->gsmem.membase.vuse;
1347 /* Return the single VDEF operand of the statement G. */
1349 static inline tree *
1350 gimple_vdef_ptr (gimple g)
1352 if (!gimple_has_mem_ops (g))
1354 return &g->gsmem.membase.vdef;
1357 /* Set the single VUSE operand of the statement G. */
1360 gimple_set_vuse (gimple g, tree vuse)
1362 gcc_assert (gimple_has_mem_ops (g));
1363 g->gsmem.membase.vuse = vuse;
1366 /* Set the single VDEF operand of the statement G. */
1369 gimple_set_vdef (gimple g, tree vdef)
1371 gcc_assert (gimple_has_mem_ops (g));
1372 g->gsmem.membase.vdef = vdef;
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) && gimple_vuse (stmt);
1486 /* Return the subcode for OMP statement S. */
1488 static inline unsigned
1489 gimple_omp_subcode (const_gimple s)
1491 gcc_assert (gimple_code (s) >= GIMPLE_OMP_ATOMIC_LOAD
1492 && gimple_code (s) <= GIMPLE_OMP_SINGLE);
1493 return s->gsbase.subcode;
1496 /* Set the subcode for OMP statement S to SUBCODE. */
1499 gimple_omp_set_subcode (gimple s, unsigned int subcode)
1501 /* We only have 16 bits for the subcode. Assert that we are not
1503 gcc_assert (subcode < (1 << 16));
1504 s->gsbase.subcode = subcode;
1507 /* Set the nowait flag on OMP_RETURN statement S. */
1510 gimple_omp_return_set_nowait (gimple s)
1512 GIMPLE_CHECK (s, GIMPLE_OMP_RETURN);
1513 s->gsbase.subcode |= GF_OMP_RETURN_NOWAIT;
1517 /* Return true if OMP return statement G has the GF_OMP_RETURN_NOWAIT
1521 gimple_omp_return_nowait_p (const_gimple g)
1523 GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
1524 return (gimple_omp_subcode (g) & GF_OMP_RETURN_NOWAIT) != 0;
1528 /* Return true if OMP section statement G has the GF_OMP_SECTION_LAST
1532 gimple_omp_section_last_p (const_gimple g)
1534 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1535 return (gimple_omp_subcode (g) & GF_OMP_SECTION_LAST) != 0;
1539 /* Set the GF_OMP_SECTION_LAST flag on G. */
1542 gimple_omp_section_set_last (gimple g)
1544 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1545 g->gsbase.subcode |= GF_OMP_SECTION_LAST;
1549 /* Return true if OMP parallel statement G has the
1550 GF_OMP_PARALLEL_COMBINED flag set. */
1553 gimple_omp_parallel_combined_p (const_gimple g)
1555 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1556 return (gimple_omp_subcode (g) & GF_OMP_PARALLEL_COMBINED) != 0;
1560 /* Set the GF_OMP_PARALLEL_COMBINED field in G depending on the boolean
1561 value of COMBINED_P. */
1564 gimple_omp_parallel_set_combined_p (gimple g, bool combined_p)
1566 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1568 g->gsbase.subcode |= GF_OMP_PARALLEL_COMBINED;
1570 g->gsbase.subcode &= ~GF_OMP_PARALLEL_COMBINED;
1574 /* Return the number of operands for statement GS. */
1576 static inline unsigned
1577 gimple_num_ops (const_gimple gs)
1579 return gs->gsbase.num_ops;
1583 /* Set the number of operands for statement GS. */
1586 gimple_set_num_ops (gimple gs, unsigned num_ops)
1588 gs->gsbase.num_ops = num_ops;
1592 /* Return the array of operands for statement GS. */
1594 static inline tree *
1595 gimple_ops (gimple gs)
1597 /* Offset in bytes to the location of the operand vector in every
1598 tuple structure. Defined in gimple.c */
1599 extern size_t const gimple_ops_offset_[];
1601 if (!gimple_has_ops (gs))
1604 /* All the tuples have their operand vector at the very bottom
1605 of the structure. */
1606 return ((tree *) ((char *) gs + gimple_ops_offset_[gimple_code (gs)]));
1610 /* Return operand I for statement GS. */
1613 gimple_op (const_gimple gs, unsigned i)
1615 if (gimple_has_ops (gs))
1617 gcc_assert (i < gimple_num_ops (gs));
1618 return gimple_ops (CONST_CAST_GIMPLE (gs))[i];
1624 /* Return a pointer to operand I for statement GS. */
1626 static inline tree *
1627 gimple_op_ptr (const_gimple gs, unsigned i)
1629 if (gimple_has_ops (gs))
1631 gcc_assert (i < gimple_num_ops (gs));
1632 return gimple_ops (CONST_CAST_GIMPLE (gs)) + i;
1638 /* Set operand I of statement GS to OP. */
1641 gimple_set_op (gimple gs, unsigned i, tree op)
1643 gcc_assert (gimple_has_ops (gs) && i < gimple_num_ops (gs));
1645 /* Note. It may be tempting to assert that OP matches
1646 is_gimple_operand, but that would be wrong. Different tuples
1647 accept slightly different sets of tree operands. Each caller
1648 should perform its own validation. */
1649 gimple_ops (gs)[i] = op;
1652 /* Return true if GS is a GIMPLE_ASSIGN. */
1655 is_gimple_assign (const_gimple gs)
1657 return gimple_code (gs) == GIMPLE_ASSIGN;
1660 /* Determine if expression CODE is one of the valid expressions that can
1661 be used on the RHS of GIMPLE assignments. */
1663 static inline enum gimple_rhs_class
1664 get_gimple_rhs_class (enum tree_code code)
1666 return (enum gimple_rhs_class) gimple_rhs_class_table[(int) code];
1669 /* Return the LHS of assignment statement GS. */
1672 gimple_assign_lhs (const_gimple gs)
1674 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1675 return gimple_op (gs, 0);
1679 /* Return a pointer to the LHS of assignment statement GS. */
1681 static inline tree *
1682 gimple_assign_lhs_ptr (const_gimple gs)
1684 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1685 return gimple_op_ptr (gs, 0);
1689 /* Set LHS to be the LHS operand of assignment statement GS. */
1692 gimple_assign_set_lhs (gimple gs, tree lhs)
1694 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1695 gcc_assert (is_gimple_operand (lhs));
1696 gimple_set_op (gs, 0, lhs);
1698 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1699 SSA_NAME_DEF_STMT (lhs) = gs;
1703 /* Return the first operand on the RHS of assignment statement GS. */
1706 gimple_assign_rhs1 (const_gimple gs)
1708 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1709 return gimple_op (gs, 1);
1713 /* Return a pointer to the first operand on the RHS of assignment
1716 static inline tree *
1717 gimple_assign_rhs1_ptr (const_gimple gs)
1719 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1720 return gimple_op_ptr (gs, 1);
1723 /* Set RHS to be the first operand on the RHS of assignment statement GS. */
1726 gimple_assign_set_rhs1 (gimple gs, tree rhs)
1728 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1730 /* If there are 3 or more operands, the 2 operands on the RHS must be
1732 if (gimple_num_ops (gs) >= 3)
1733 gcc_assert (is_gimple_val (rhs));
1735 gcc_assert (is_gimple_operand (rhs));
1737 gimple_set_op (gs, 1, rhs);
1741 /* Return the second operand on the RHS of assignment statement GS.
1742 If GS does not have two operands, NULL is returned instead. */
1745 gimple_assign_rhs2 (const_gimple gs)
1747 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1749 if (gimple_num_ops (gs) >= 3)
1750 return gimple_op (gs, 2);
1756 /* Return a pointer to the second operand on the RHS of assignment
1759 static inline tree *
1760 gimple_assign_rhs2_ptr (const_gimple gs)
1762 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1763 return gimple_op_ptr (gs, 2);
1767 /* Set RHS to be the second operand on the RHS of assignment statement GS. */
1770 gimple_assign_set_rhs2 (gimple gs, tree rhs)
1772 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1774 /* The 2 operands on the RHS must be GIMPLE values. */
1775 gcc_assert (is_gimple_val (rhs));
1777 gimple_set_op (gs, 2, rhs);
1780 /* Returns true if GS is a nontemporal move. */
1783 gimple_assign_nontemporal_move_p (const_gimple gs)
1785 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1786 return gs->gsbase.nontemporal_move;
1789 /* Sets nontemporal move flag of GS to NONTEMPORAL. */
1792 gimple_assign_set_nontemporal_move (gimple gs, bool nontemporal)
1794 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1795 gs->gsbase.nontemporal_move = nontemporal;
1799 /* Return the code of the expression computed on the rhs of assignment
1800 statement GS. In case that the RHS is a single object, returns the
1801 tree code of the object. */
1803 static inline enum tree_code
1804 gimple_assign_rhs_code (const_gimple gs)
1806 enum tree_code code;
1807 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1809 code = gimple_expr_code (gs);
1810 if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS)
1811 code = TREE_CODE (gimple_assign_rhs1 (gs));
1817 /* Set CODE to be the code for the expression computed on the RHS of
1821 gimple_assign_set_rhs_code (gimple s, enum tree_code code)
1823 GIMPLE_CHECK (s, GIMPLE_ASSIGN);
1824 s->gsbase.subcode = code;
1828 /* Return the gimple rhs class of the code of the expression computed on
1829 the rhs of assignment statement GS.
1830 This will never return GIMPLE_INVALID_RHS. */
1832 static inline enum gimple_rhs_class
1833 gimple_assign_rhs_class (const_gimple gs)
1835 return get_gimple_rhs_class (gimple_assign_rhs_code (gs));
1839 /* Return true if S is a type-cast assignment. */
1842 gimple_assign_cast_p (gimple s)
1844 if (is_gimple_assign (s))
1846 enum tree_code sc = gimple_assign_rhs_code (s);
1847 return CONVERT_EXPR_CODE_P (sc)
1848 || sc == VIEW_CONVERT_EXPR
1849 || sc == FIX_TRUNC_EXPR;
1856 /* Return true if GS is a GIMPLE_CALL. */
1859 is_gimple_call (const_gimple gs)
1861 return gimple_code (gs) == GIMPLE_CALL;
1864 /* Return the LHS of call statement GS. */
1867 gimple_call_lhs (const_gimple gs)
1869 GIMPLE_CHECK (gs, GIMPLE_CALL);
1870 return gimple_op (gs, 0);
1874 /* Return a pointer to the LHS of call statement GS. */
1876 static inline tree *
1877 gimple_call_lhs_ptr (const_gimple gs)
1879 GIMPLE_CHECK (gs, GIMPLE_CALL);
1880 return gimple_op_ptr (gs, 0);
1884 /* Set LHS to be the LHS operand of call statement GS. */
1887 gimple_call_set_lhs (gimple gs, tree lhs)
1889 GIMPLE_CHECK (gs, GIMPLE_CALL);
1890 gcc_assert (!lhs || is_gimple_operand (lhs));
1891 gimple_set_op (gs, 0, lhs);
1892 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1893 SSA_NAME_DEF_STMT (lhs) = gs;
1897 /* Return the tree node representing the function called by call
1901 gimple_call_fn (const_gimple gs)
1903 GIMPLE_CHECK (gs, GIMPLE_CALL);
1904 return gimple_op (gs, 1);
1908 /* Return a pointer to the tree node representing the function called by call
1911 static inline tree *
1912 gimple_call_fn_ptr (const_gimple gs)
1914 GIMPLE_CHECK (gs, GIMPLE_CALL);
1915 return gimple_op_ptr (gs, 1);
1919 /* Set FN to be the function called by call statement GS. */
1922 gimple_call_set_fn (gimple gs, tree fn)
1924 GIMPLE_CHECK (gs, GIMPLE_CALL);
1925 gcc_assert (is_gimple_operand (fn));
1926 gimple_set_op (gs, 1, fn);
1930 /* Set FNDECL to be the function called by call statement GS. */
1933 gimple_call_set_fndecl (gimple gs, tree decl)
1935 GIMPLE_CHECK (gs, GIMPLE_CALL);
1936 gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
1937 gimple_set_op (gs, 1, build_fold_addr_expr (decl));
1941 /* If a given GIMPLE_CALL's callee is a FUNCTION_DECL, return it.
1942 Otherwise return NULL. This function is analogous to
1943 get_callee_fndecl in tree land. */
1946 gimple_call_fndecl (const_gimple gs)
1948 tree addr = gimple_call_fn (gs);
1949 if (TREE_CODE (addr) == ADDR_EXPR)
1951 gcc_assert (TREE_CODE (TREE_OPERAND (addr, 0)) == FUNCTION_DECL);
1952 return TREE_OPERAND (addr, 0);
1958 /* Return the type returned by call statement GS. */
1961 gimple_call_return_type (const_gimple gs)
1963 tree fn = gimple_call_fn (gs);
1964 tree type = TREE_TYPE (fn);
1966 /* See through the pointer. */
1967 gcc_assert (POINTER_TYPE_P (type));
1968 type = TREE_TYPE (type);
1970 gcc_assert (TREE_CODE (type) == FUNCTION_TYPE
1971 || TREE_CODE (type) == METHOD_TYPE);
1973 /* The type returned by a FUNCTION_DECL is the type of its
1975 return TREE_TYPE (type);
1979 /* Return the static chain for call statement GS. */
1982 gimple_call_chain (const_gimple gs)
1984 GIMPLE_CHECK (gs, GIMPLE_CALL);
1985 return gimple_op (gs, 2);
1989 /* Return a pointer to the static chain for call statement GS. */
1991 static inline tree *
1992 gimple_call_chain_ptr (const_gimple gs)
1994 GIMPLE_CHECK (gs, GIMPLE_CALL);
1995 return gimple_op_ptr (gs, 2);
1998 /* Set CHAIN to be the static chain for call statement GS. */
2001 gimple_call_set_chain (gimple gs, tree chain)
2003 GIMPLE_CHECK (gs, GIMPLE_CALL);
2004 gcc_assert (chain == NULL
2005 || TREE_CODE (chain) == ADDR_EXPR
2006 || SSA_VAR_P (chain));
2007 gimple_set_op (gs, 2, chain);
2011 /* Return the number of arguments used by call statement GS. */
2013 static inline unsigned
2014 gimple_call_num_args (const_gimple gs)
2017 GIMPLE_CHECK (gs, GIMPLE_CALL);
2018 num_ops = gimple_num_ops (gs);
2019 gcc_assert (num_ops >= 3);
2024 /* Return the argument at position INDEX for call statement GS. */
2027 gimple_call_arg (const_gimple gs, unsigned index)
2029 GIMPLE_CHECK (gs, GIMPLE_CALL);
2030 return gimple_op (gs, index + 3);
2034 /* Return a pointer to the argument at position INDEX for call
2037 static inline tree *
2038 gimple_call_arg_ptr (const_gimple gs, unsigned index)
2040 GIMPLE_CHECK (gs, GIMPLE_CALL);
2041 return gimple_op_ptr (gs, index + 3);
2045 /* Set ARG to be the argument at position INDEX for call statement GS. */
2048 gimple_call_set_arg (gimple gs, unsigned index, tree arg)
2050 GIMPLE_CHECK (gs, GIMPLE_CALL);
2051 gcc_assert (is_gimple_operand (arg));
2052 gimple_set_op (gs, index + 3, arg);
2056 /* If TAIL_P is true, mark call statement S as being a tail call
2057 (i.e., a call just before the exit of a function). These calls are
2058 candidate for tail call optimization. */
2061 gimple_call_set_tail (gimple s, bool tail_p)
2063 GIMPLE_CHECK (s, GIMPLE_CALL);
2065 s->gsbase.subcode |= GF_CALL_TAILCALL;
2067 s->gsbase.subcode &= ~GF_CALL_TAILCALL;
2071 /* Return true if GIMPLE_CALL S is marked as a tail call. */
2074 gimple_call_tail_p (gimple s)
2076 GIMPLE_CHECK (s, GIMPLE_CALL);
2077 return (s->gsbase.subcode & GF_CALL_TAILCALL) != 0;
2081 /* Set the inlinable status of GIMPLE_CALL S to INLINABLE_P. */
2084 gimple_call_set_cannot_inline (gimple s, bool inlinable_p)
2086 GIMPLE_CHECK (s, GIMPLE_CALL);
2088 s->gsbase.subcode |= GF_CALL_CANNOT_INLINE;
2090 s->gsbase.subcode &= ~GF_CALL_CANNOT_INLINE;
2094 /* Return true if GIMPLE_CALL S cannot be inlined. */
2097 gimple_call_cannot_inline_p (gimple s)
2099 GIMPLE_CHECK (s, GIMPLE_CALL);
2100 return (s->gsbase.subcode & GF_CALL_CANNOT_INLINE) != 0;
2104 /* If RETURN_SLOT_OPT_P is true mark GIMPLE_CALL S as valid for return
2105 slot optimization. This transformation uses the target of the call
2106 expansion as the return slot for calls that return in memory. */
2109 gimple_call_set_return_slot_opt (gimple s, bool return_slot_opt_p)
2111 GIMPLE_CHECK (s, GIMPLE_CALL);
2112 if (return_slot_opt_p)
2113 s->gsbase.subcode |= GF_CALL_RETURN_SLOT_OPT;
2115 s->gsbase.subcode &= ~GF_CALL_RETURN_SLOT_OPT;
2119 /* Return true if S is marked for return slot optimization. */
2122 gimple_call_return_slot_opt_p (gimple s)
2124 GIMPLE_CHECK (s, GIMPLE_CALL);
2125 return (s->gsbase.subcode & GF_CALL_RETURN_SLOT_OPT) != 0;
2129 /* If FROM_THUNK_P is true, mark GIMPLE_CALL S as being the jump from a
2130 thunk to the thunked-to function. */
2133 gimple_call_set_from_thunk (gimple s, bool from_thunk_p)
2135 GIMPLE_CHECK (s, GIMPLE_CALL);
2137 s->gsbase.subcode |= GF_CALL_FROM_THUNK;
2139 s->gsbase.subcode &= ~GF_CALL_FROM_THUNK;
2143 /* Return true if GIMPLE_CALL S is a jump from a thunk. */
2146 gimple_call_from_thunk_p (gimple s)
2148 GIMPLE_CHECK (s, GIMPLE_CALL);
2149 return (s->gsbase.subcode & GF_CALL_FROM_THUNK) != 0;
2153 /* If PASS_ARG_PACK_P is true, GIMPLE_CALL S is a stdarg call that needs the
2154 argument pack in its argument list. */
2157 gimple_call_set_va_arg_pack (gimple s, bool pass_arg_pack_p)
2159 GIMPLE_CHECK (s, GIMPLE_CALL);
2160 if (pass_arg_pack_p)
2161 s->gsbase.subcode |= GF_CALL_VA_ARG_PACK;
2163 s->gsbase.subcode &= ~GF_CALL_VA_ARG_PACK;
2167 /* Return true if GIMPLE_CALL S is a stdarg call that needs the
2168 argument pack in its argument list. */
2171 gimple_call_va_arg_pack_p (gimple s)
2173 GIMPLE_CHECK (s, GIMPLE_CALL);
2174 return (s->gsbase.subcode & GF_CALL_VA_ARG_PACK) != 0;
2178 /* Return true if S is a noreturn call. */
2181 gimple_call_noreturn_p (gimple s)
2183 GIMPLE_CHECK (s, GIMPLE_CALL);
2184 return (gimple_call_flags (s) & ECF_NORETURN) != 0;
2188 /* Return true if S is a nothrow call. */
2191 gimple_call_nothrow_p (gimple s)
2193 GIMPLE_CHECK (s, GIMPLE_CALL);
2194 return (gimple_call_flags (s) & ECF_NOTHROW) != 0;
2198 /* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL. */
2201 gimple_call_copy_flags (gimple dest_call, gimple orig_call)
2203 GIMPLE_CHECK (dest_call, GIMPLE_CALL);
2204 GIMPLE_CHECK (orig_call, GIMPLE_CALL);
2205 dest_call->gsbase.subcode = orig_call->gsbase.subcode;
2209 /* Returns true if this is a GIMPLE_ASSIGN or a GIMPLE_CALL with a
2213 gimple_has_lhs (gimple stmt)
2215 return (is_gimple_assign (stmt)
2216 || (is_gimple_call (stmt)
2217 && gimple_call_lhs (stmt) != NULL_TREE));
2221 /* Return the code of the predicate computed by conditional statement GS. */
2223 static inline enum tree_code
2224 gimple_cond_code (const_gimple gs)
2226 GIMPLE_CHECK (gs, GIMPLE_COND);
2227 return gs->gsbase.subcode;
2231 /* Set CODE to be the predicate code for the conditional statement GS. */
2234 gimple_cond_set_code (gimple gs, enum tree_code code)
2236 GIMPLE_CHECK (gs, GIMPLE_COND);
2237 gcc_assert (TREE_CODE_CLASS (code) == tcc_comparison);
2238 gs->gsbase.subcode = code;
2242 /* Return the LHS of the predicate computed by conditional statement GS. */
2245 gimple_cond_lhs (const_gimple gs)
2247 GIMPLE_CHECK (gs, GIMPLE_COND);
2248 return gimple_op (gs, 0);
2251 /* Return the pointer to the LHS of the predicate computed by conditional
2254 static inline tree *
2255 gimple_cond_lhs_ptr (const_gimple gs)
2257 GIMPLE_CHECK (gs, GIMPLE_COND);
2258 return gimple_op_ptr (gs, 0);
2261 /* Set LHS to be the LHS operand of the predicate computed by
2262 conditional statement GS. */
2265 gimple_cond_set_lhs (gimple gs, tree lhs)
2267 GIMPLE_CHECK (gs, GIMPLE_COND);
2268 gcc_assert (is_gimple_operand (lhs));
2269 gimple_set_op (gs, 0, lhs);
2273 /* Return the RHS operand of the predicate computed by conditional GS. */
2276 gimple_cond_rhs (const_gimple gs)
2278 GIMPLE_CHECK (gs, GIMPLE_COND);
2279 return gimple_op (gs, 1);
2282 /* Return the pointer to the RHS operand of the predicate computed by
2285 static inline tree *
2286 gimple_cond_rhs_ptr (const_gimple gs)
2288 GIMPLE_CHECK (gs, GIMPLE_COND);
2289 return gimple_op_ptr (gs, 1);
2293 /* Set RHS to be the RHS operand of the predicate computed by
2294 conditional statement GS. */
2297 gimple_cond_set_rhs (gimple gs, tree rhs)
2299 GIMPLE_CHECK (gs, GIMPLE_COND);
2300 gcc_assert (is_gimple_operand (rhs));
2301 gimple_set_op (gs, 1, rhs);
2305 /* Return the label used by conditional statement GS when its
2306 predicate evaluates to true. */
2309 gimple_cond_true_label (const_gimple gs)
2311 GIMPLE_CHECK (gs, GIMPLE_COND);
2312 return gimple_op (gs, 2);
2316 /* Set LABEL to be the label used by conditional statement GS when its
2317 predicate evaluates to true. */
2320 gimple_cond_set_true_label (gimple gs, tree label)
2322 GIMPLE_CHECK (gs, GIMPLE_COND);
2323 gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
2324 gimple_set_op (gs, 2, label);
2328 /* Set LABEL to be the label used by conditional statement GS when its
2329 predicate evaluates to false. */
2332 gimple_cond_set_false_label (gimple gs, tree label)
2334 GIMPLE_CHECK (gs, GIMPLE_COND);
2335 gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
2336 gimple_set_op (gs, 3, label);
2340 /* Return the label used by conditional statement GS when its
2341 predicate evaluates to false. */
2344 gimple_cond_false_label (const_gimple gs)
2346 GIMPLE_CHECK (gs, GIMPLE_COND);
2347 return gimple_op (gs, 3);
2351 /* Set the conditional COND_STMT to be of the form 'if (1 == 0)'. */
2354 gimple_cond_make_false (gimple gs)
2356 gimple_cond_set_lhs (gs, boolean_true_node);
2357 gimple_cond_set_rhs (gs, boolean_false_node);
2358 gs->gsbase.subcode = EQ_EXPR;
2362 /* Set the conditional COND_STMT to be of the form 'if (1 == 1)'. */
2365 gimple_cond_make_true (gimple gs)
2367 gimple_cond_set_lhs (gs, boolean_true_node);
2368 gimple_cond_set_rhs (gs, boolean_true_node);
2369 gs->gsbase.subcode = EQ_EXPR;
2372 /* Check if conditional statemente GS is of the form 'if (1 == 1)',
2373 'if (0 == 0)', 'if (1 != 0)' or 'if (0 != 1)' */
2376 gimple_cond_true_p (const_gimple gs)
2378 tree lhs = gimple_cond_lhs (gs);
2379 tree rhs = gimple_cond_rhs (gs);
2380 enum tree_code code = gimple_cond_code (gs);
2382 if (lhs != boolean_true_node && lhs != boolean_false_node)
2385 if (rhs != boolean_true_node && rhs != boolean_false_node)
2388 if (code == NE_EXPR && lhs != rhs)
2391 if (code == EQ_EXPR && lhs == rhs)
2397 /* Check if conditional statement GS is of the form 'if (1 != 1)',
2398 'if (0 != 0)', 'if (1 == 0)' or 'if (0 == 1)' */
2401 gimple_cond_false_p (const_gimple gs)
2403 tree lhs = gimple_cond_lhs (gs);
2404 tree rhs = gimple_cond_rhs (gs);
2405 enum tree_code code = gimple_cond_code (gs);
2407 if (lhs != boolean_true_node && lhs != boolean_false_node)
2410 if (rhs != boolean_true_node && rhs != boolean_false_node)
2413 if (code == NE_EXPR && lhs == rhs)
2416 if (code == EQ_EXPR && lhs != rhs)
2422 /* Check if conditional statement GS is of the form 'if (var != 0)' or
2426 gimple_cond_single_var_p (gimple gs)
2428 if (gimple_cond_code (gs) == NE_EXPR
2429 && gimple_cond_rhs (gs) == boolean_false_node)
2432 if (gimple_cond_code (gs) == EQ_EXPR
2433 && gimple_cond_rhs (gs) == boolean_true_node)
2439 /* Set the code, LHS and RHS of GIMPLE_COND STMT from CODE, LHS and RHS. */
2442 gimple_cond_set_condition (gimple stmt, enum tree_code code, tree lhs, tree rhs)
2444 gimple_cond_set_code (stmt, code);
2445 gimple_cond_set_lhs (stmt, lhs);
2446 gimple_cond_set_rhs (stmt, rhs);
2449 /* Return the LABEL_DECL node used by GIMPLE_LABEL statement GS. */
2452 gimple_label_label (const_gimple gs)
2454 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2455 return gimple_op (gs, 0);
2459 /* Set LABEL to be the LABEL_DECL node used by GIMPLE_LABEL statement
2463 gimple_label_set_label (gimple gs, tree label)
2465 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2466 gcc_assert (TREE_CODE (label) == LABEL_DECL);
2467 gimple_set_op (gs, 0, label);
2471 /* Return the destination of the unconditional jump GS. */
2474 gimple_goto_dest (const_gimple gs)
2476 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2477 return gimple_op (gs, 0);
2481 /* Set DEST to be the destination of the unconditonal jump GS. */
2484 gimple_goto_set_dest (gimple gs, tree dest)
2486 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2487 gcc_assert (is_gimple_operand (dest));
2488 gimple_set_op (gs, 0, dest);
2492 /* Return the variables declared in the GIMPLE_BIND statement GS. */
2495 gimple_bind_vars (const_gimple gs)
2497 GIMPLE_CHECK (gs, GIMPLE_BIND);
2498 return gs->gimple_bind.vars;
2502 /* Set VARS to be the set of variables declared in the GIMPLE_BIND
2506 gimple_bind_set_vars (gimple gs, tree vars)
2508 GIMPLE_CHECK (gs, GIMPLE_BIND);
2509 gs->gimple_bind.vars = vars;
2513 /* Append VARS to the set of variables declared in the GIMPLE_BIND
2517 gimple_bind_append_vars (gimple gs, tree vars)
2519 GIMPLE_CHECK (gs, GIMPLE_BIND);
2520 gs->gimple_bind.vars = chainon (gs->gimple_bind.vars, vars);
2524 /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS. */
2526 static inline gimple_seq
2527 gimple_bind_body (gimple gs)
2529 GIMPLE_CHECK (gs, GIMPLE_BIND);
2530 return gs->gimple_bind.body;
2534 /* Set SEQ to be the GIMPLE sequence contained in the GIMPLE_BIND
2538 gimple_bind_set_body (gimple gs, gimple_seq seq)
2540 GIMPLE_CHECK (gs, GIMPLE_BIND);
2541 gs->gimple_bind.body = seq;
2545 /* Append a statement to the end of a GIMPLE_BIND's body. */
2548 gimple_bind_add_stmt (gimple gs, gimple stmt)
2550 GIMPLE_CHECK (gs, GIMPLE_BIND);
2551 gimple_seq_add_stmt (&gs->gimple_bind.body, stmt);
2555 /* Append a sequence of statements to the end of a GIMPLE_BIND's body. */
2558 gimple_bind_add_seq (gimple gs, gimple_seq seq)
2560 GIMPLE_CHECK (gs, GIMPLE_BIND);
2561 gimple_seq_add_seq (&gs->gimple_bind.body, seq);
2565 /* Return the TREE_BLOCK node associated with GIMPLE_BIND statement
2566 GS. This is analogous to the BIND_EXPR_BLOCK field in trees. */
2569 gimple_bind_block (const_gimple gs)
2571 GIMPLE_CHECK (gs, GIMPLE_BIND);
2572 return gs->gimple_bind.block;
2576 /* Set BLOCK to be the TREE_BLOCK node associated with GIMPLE_BIND
2580 gimple_bind_set_block (gimple gs, tree block)
2582 GIMPLE_CHECK (gs, GIMPLE_BIND);
2583 gcc_assert (block == NULL_TREE || TREE_CODE (block) == BLOCK);
2584 gs->gimple_bind.block = block;
2588 /* Return the number of input operands for GIMPLE_ASM GS. */
2590 static inline unsigned
2591 gimple_asm_ninputs (const_gimple gs)
2593 GIMPLE_CHECK (gs, GIMPLE_ASM);
2594 return gs->gimple_asm.ni;
2598 /* Return the number of output operands for GIMPLE_ASM GS. */
2600 static inline unsigned
2601 gimple_asm_noutputs (const_gimple gs)
2603 GIMPLE_CHECK (gs, GIMPLE_ASM);
2604 return gs->gimple_asm.no;
2608 /* Return the number of clobber operands for GIMPLE_ASM GS. */
2610 static inline unsigned
2611 gimple_asm_nclobbers (const_gimple gs)
2613 GIMPLE_CHECK (gs, GIMPLE_ASM);
2614 return gs->gimple_asm.nc;
2618 /* Return input operand INDEX of GIMPLE_ASM GS. */
2621 gimple_asm_input_op (const_gimple gs, unsigned index)
2623 GIMPLE_CHECK (gs, GIMPLE_ASM);
2624 gcc_assert (index <= gs->gimple_asm.ni);
2625 return gimple_op (gs, index);
2628 /* Return a pointer to input operand INDEX of GIMPLE_ASM GS. */
2630 static inline tree *
2631 gimple_asm_input_op_ptr (const_gimple gs, unsigned index)
2633 GIMPLE_CHECK (gs, GIMPLE_ASM);
2634 gcc_assert (index <= gs->gimple_asm.ni);
2635 return gimple_op_ptr (gs, index);
2639 /* Set IN_OP to be input operand INDEX in GIMPLE_ASM GS. */
2642 gimple_asm_set_input_op (gimple gs, unsigned index, tree in_op)
2644 GIMPLE_CHECK (gs, GIMPLE_ASM);
2645 gcc_assert (index <= gs->gimple_asm.ni);
2646 gcc_assert (TREE_CODE (in_op) == TREE_LIST);
2647 gimple_set_op (gs, index, in_op);
2651 /* Return output operand INDEX of GIMPLE_ASM GS. */
2654 gimple_asm_output_op (const_gimple gs, unsigned index)
2656 GIMPLE_CHECK (gs, GIMPLE_ASM);
2657 gcc_assert (index <= gs->gimple_asm.no);
2658 return gimple_op (gs, index + gs->gimple_asm.ni);
2661 /* Return a pointer to output operand INDEX of GIMPLE_ASM GS. */
2663 static inline tree *
2664 gimple_asm_output_op_ptr (const_gimple gs, unsigned index)
2666 GIMPLE_CHECK (gs, GIMPLE_ASM);
2667 gcc_assert (index <= gs->gimple_asm.no);
2668 return gimple_op_ptr (gs, index + gs->gimple_asm.ni);
2672 /* Set OUT_OP to be output operand INDEX in GIMPLE_ASM GS. */
2675 gimple_asm_set_output_op (gimple gs, unsigned index, tree out_op)
2677 GIMPLE_CHECK (gs, GIMPLE_ASM);
2678 gcc_assert (index <= gs->gimple_asm.no);
2679 gcc_assert (TREE_CODE (out_op) == TREE_LIST);
2680 gimple_set_op (gs, index + gs->gimple_asm.ni, out_op);
2684 /* Return clobber operand INDEX of GIMPLE_ASM GS. */
2687 gimple_asm_clobber_op (const_gimple gs, unsigned index)
2689 GIMPLE_CHECK (gs, GIMPLE_ASM);
2690 gcc_assert (index <= gs->gimple_asm.nc);
2691 return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no);
2695 /* Set CLOBBER_OP to be clobber operand INDEX in GIMPLE_ASM GS. */
2698 gimple_asm_set_clobber_op (gimple gs, unsigned index, tree clobber_op)
2700 GIMPLE_CHECK (gs, GIMPLE_ASM);
2701 gcc_assert (index <= gs->gimple_asm.nc);
2702 gcc_assert (TREE_CODE (clobber_op) == TREE_LIST);
2703 gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no, clobber_op);
2707 /* Return the string representing the assembly instruction in
2710 static inline const char *
2711 gimple_asm_string (const_gimple gs)
2713 GIMPLE_CHECK (gs, GIMPLE_ASM);
2714 return gs->gimple_asm.string;
2718 /* Return true if GS is an asm statement marked volatile. */
2721 gimple_asm_volatile_p (const_gimple gs)
2723 GIMPLE_CHECK (gs, GIMPLE_ASM);
2724 return (gs->gsbase.subcode & GF_ASM_VOLATILE) != 0;
2728 /* If VOLATLE_P is true, mark asm statement GS as volatile. */
2731 gimple_asm_set_volatile (gimple gs, bool volatile_p)
2733 GIMPLE_CHECK (gs, GIMPLE_ASM);
2735 gs->gsbase.subcode |= GF_ASM_VOLATILE;
2737 gs->gsbase.subcode &= ~GF_ASM_VOLATILE;
2741 /* If INPUT_P is true, mark asm GS as an ASM_INPUT. */
2744 gimple_asm_set_input (gimple gs, bool input_p)
2746 GIMPLE_CHECK (gs, GIMPLE_ASM);
2748 gs->gsbase.subcode |= GF_ASM_INPUT;
2750 gs->gsbase.subcode &= ~GF_ASM_INPUT;
2754 /* Return true if asm GS is an ASM_INPUT. */
2757 gimple_asm_input_p (const_gimple gs)
2759 GIMPLE_CHECK (gs, GIMPLE_ASM);
2760 return (gs->gsbase.subcode & GF_ASM_INPUT) != 0;
2764 /* Return the types handled by GIMPLE_CATCH statement GS. */
2767 gimple_catch_types (const_gimple gs)
2769 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2770 return gs->gimple_catch.types;
2774 /* Return a pointer to the types handled by GIMPLE_CATCH statement GS. */
2776 static inline tree *
2777 gimple_catch_types_ptr (gimple gs)
2779 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2780 return &gs->gimple_catch.types;
2784 /* Return the GIMPLE sequence representing the body of the handler of
2785 GIMPLE_CATCH statement GS. */
2787 static inline gimple_seq
2788 gimple_catch_handler (gimple gs)
2790 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2791 return gs->gimple_catch.handler;
2795 /* Return a pointer to the GIMPLE sequence representing the body of
2796 the handler of GIMPLE_CATCH statement GS. */
2798 static inline gimple_seq *
2799 gimple_catch_handler_ptr (gimple gs)
2801 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2802 return &gs->gimple_catch.handler;
2806 /* Set T to be the set of types handled by GIMPLE_CATCH GS. */
2809 gimple_catch_set_types (gimple gs, tree t)
2811 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2812 gs->gimple_catch.types = t;
2816 /* Set HANDLER to be the body of GIMPLE_CATCH GS. */
2819 gimple_catch_set_handler (gimple gs, gimple_seq handler)
2821 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2822 gs->gimple_catch.handler = handler;
2826 /* Return the types handled by GIMPLE_EH_FILTER statement GS. */
2829 gimple_eh_filter_types (const_gimple gs)
2831 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2832 return gs->gimple_eh_filter.types;
2836 /* Return a pointer to the types handled by GIMPLE_EH_FILTER statement
2839 static inline tree *
2840 gimple_eh_filter_types_ptr (gimple gs)
2842 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2843 return &gs->gimple_eh_filter.types;
2847 /* Return the sequence of statement to execute when GIMPLE_EH_FILTER
2850 static inline gimple_seq
2851 gimple_eh_filter_failure (gimple gs)
2853 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2854 return gs->gimple_eh_filter.failure;
2858 /* Set TYPES to be the set of types handled by GIMPLE_EH_FILTER GS. */
2861 gimple_eh_filter_set_types (gimple gs, tree types)
2863 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2864 gs->gimple_eh_filter.types = types;
2868 /* Set FAILURE to be the sequence of statements to execute on failure
2869 for GIMPLE_EH_FILTER GS. */
2872 gimple_eh_filter_set_failure (gimple gs, gimple_seq failure)
2874 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2875 gs->gimple_eh_filter.failure = failure;
2878 /* Return the EH_FILTER_MUST_NOT_THROW flag. */
2882 gimple_eh_filter_must_not_throw (gimple gs)
2884 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2885 return gs->gsbase.subcode != 0;
2888 /* Set the EH_FILTER_MUST_NOT_THROW flag to the value MNTP. */
2891 gimple_eh_filter_set_must_not_throw (gimple gs, bool mntp)
2893 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2894 gs->gsbase.subcode = (unsigned int) mntp;
2898 /* GIMPLE_TRY accessors. */
2900 /* Return the kind of try block represented by GIMPLE_TRY GS. This is
2901 either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY. */
2903 static inline enum gimple_try_flags
2904 gimple_try_kind (const_gimple gs)
2906 GIMPLE_CHECK (gs, GIMPLE_TRY);
2907 return (enum gimple_try_flags) (gs->gsbase.subcode & GIMPLE_TRY_KIND);
2911 /* Set the kind of try block represented by GIMPLE_TRY GS. */
2914 gimple_try_set_kind (gimple gs, enum gimple_try_flags kind)
2916 GIMPLE_CHECK (gs, GIMPLE_TRY);
2917 gcc_assert (kind == GIMPLE_TRY_CATCH || kind == GIMPLE_TRY_FINALLY);
2918 if (gimple_try_kind (gs) != kind)
2919 gs->gsbase.subcode = (unsigned int) kind;
2923 /* Return the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2926 gimple_try_catch_is_cleanup (const_gimple gs)
2928 gcc_assert (gimple_try_kind (gs) == GIMPLE_TRY_CATCH);
2929 return (gs->gsbase.subcode & GIMPLE_TRY_CATCH_IS_CLEANUP) != 0;
2933 /* Return the sequence of statements used as the body for GIMPLE_TRY GS. */
2935 static inline gimple_seq
2936 gimple_try_eval (gimple gs)
2938 GIMPLE_CHECK (gs, GIMPLE_TRY);
2939 return gs->gimple_try.eval;
2943 /* Return the sequence of statements used as the cleanup body for
2946 static inline gimple_seq
2947 gimple_try_cleanup (gimple gs)
2949 GIMPLE_CHECK (gs, GIMPLE_TRY);
2950 return gs->gimple_try.cleanup;
2954 /* Set the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2957 gimple_try_set_catch_is_cleanup (gimple g, bool catch_is_cleanup)
2959 gcc_assert (gimple_try_kind (g) == GIMPLE_TRY_CATCH);
2960 if (catch_is_cleanup)
2961 g->gsbase.subcode |= GIMPLE_TRY_CATCH_IS_CLEANUP;
2963 g->gsbase.subcode &= ~GIMPLE_TRY_CATCH_IS_CLEANUP;
2967 /* Set EVAL to be the sequence of statements to use as the body for
2971 gimple_try_set_eval (gimple gs, gimple_seq eval)
2973 GIMPLE_CHECK (gs, GIMPLE_TRY);
2974 gs->gimple_try.eval = eval;
2978 /* Set CLEANUP to be the sequence of statements to use as the cleanup
2979 body for GIMPLE_TRY GS. */
2982 gimple_try_set_cleanup (gimple gs, gimple_seq cleanup)
2984 GIMPLE_CHECK (gs, GIMPLE_TRY);
2985 gs->gimple_try.cleanup = cleanup;
2989 /* Return the cleanup sequence for cleanup statement GS. */
2991 static inline gimple_seq
2992 gimple_wce_cleanup (gimple gs)
2994 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
2995 return gs->gimple_wce.cleanup;
2999 /* Set CLEANUP to be the cleanup sequence for GS. */
3002 gimple_wce_set_cleanup (gimple gs, gimple_seq cleanup)
3004 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3005 gs->gimple_wce.cleanup = cleanup;
3009 /* Return the CLEANUP_EH_ONLY flag for a WCE tuple. */
3012 gimple_wce_cleanup_eh_only (const_gimple gs)
3014 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3015 return gs->gsbase.subcode != 0;
3019 /* Set the CLEANUP_EH_ONLY flag for a WCE tuple. */
3022 gimple_wce_set_cleanup_eh_only (gimple gs, bool eh_only_p)
3024 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3025 gs->gsbase.subcode = (unsigned int) eh_only_p;
3029 /* Return the maximum number of arguments supported by GIMPLE_PHI GS. */
3031 static inline unsigned
3032 gimple_phi_capacity (const_gimple gs)
3034 GIMPLE_CHECK (gs, GIMPLE_PHI);
3035 return gs->gimple_phi.capacity;
3039 /* Return the number of arguments in GIMPLE_PHI GS. This must always
3040 be exactly the number of incoming edges for the basic block holding
3043 static inline unsigned
3044 gimple_phi_num_args (const_gimple gs)
3046 GIMPLE_CHECK (gs, GIMPLE_PHI);
3047 return gs->gimple_phi.nargs;
3051 /* Return the SSA name created by GIMPLE_PHI GS. */
3054 gimple_phi_result (const_gimple gs)
3056 GIMPLE_CHECK (gs, GIMPLE_PHI);
3057 return gs->gimple_phi.result;
3060 /* Return a pointer to the SSA name created by GIMPLE_PHI GS. */
3062 static inline tree *
3063 gimple_phi_result_ptr (gimple gs)
3065 GIMPLE_CHECK (gs, GIMPLE_PHI);
3066 return &gs->gimple_phi.result;
3069 /* Set RESULT to be the SSA name created by GIMPLE_PHI GS. */
3072 gimple_phi_set_result (gimple gs, tree result)
3074 GIMPLE_CHECK (gs, GIMPLE_PHI);
3075 gs->gimple_phi.result = result;
3079 /* Return the PHI argument corresponding to incoming edge INDEX for
3082 static inline struct phi_arg_d *
3083 gimple_phi_arg (gimple gs, unsigned index)
3085 GIMPLE_CHECK (gs, GIMPLE_PHI);
3086 gcc_assert (index <= gs->gimple_phi.capacity);
3087 return &(gs->gimple_phi.args[index]);
3090 /* Set PHIARG to be the argument corresponding to incoming edge INDEX
3091 for GIMPLE_PHI GS. */
3094 gimple_phi_set_arg (gimple gs, unsigned index, struct phi_arg_d * phiarg)
3096 GIMPLE_CHECK (gs, GIMPLE_PHI);
3097 gcc_assert (index <= gs->gimple_phi.nargs);
3098 memcpy (gs->gimple_phi.args + index, phiarg, sizeof (struct phi_arg_d));
3101 /* Return the region number for GIMPLE_RESX GS. */
3104 gimple_resx_region (const_gimple gs)
3106 GIMPLE_CHECK (gs, GIMPLE_RESX);
3107 return gs->gimple_resx.region;
3110 /* Set REGION to be the region number for GIMPLE_RESX GS. */
3113 gimple_resx_set_region (gimple gs, int region)
3115 GIMPLE_CHECK (gs, GIMPLE_RESX);
3116 gs->gimple_resx.region = region;
3120 /* Return the number of labels associated with the switch statement GS. */
3122 static inline unsigned
3123 gimple_switch_num_labels (const_gimple gs)
3126 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3127 num_ops = gimple_num_ops (gs);
3128 gcc_assert (num_ops > 1);
3133 /* Set NLABELS to be the number of labels for the switch statement GS. */
3136 gimple_switch_set_num_labels (gimple g, unsigned nlabels)
3138 GIMPLE_CHECK (g, GIMPLE_SWITCH);
3139 gimple_set_num_ops (g, nlabels + 1);
3143 /* Return the index variable used by the switch statement GS. */
3146 gimple_switch_index (const_gimple gs)
3148 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3149 return gimple_op (gs, 0);
3153 /* Return a pointer to the index variable for the switch statement GS. */
3155 static inline tree *
3156 gimple_switch_index_ptr (const_gimple gs)
3158 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3159 return gimple_op_ptr (gs, 0);
3163 /* Set INDEX to be the index variable for switch statement GS. */
3166 gimple_switch_set_index (gimple gs, tree index)
3168 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3169 gcc_assert (SSA_VAR_P (index) || CONSTANT_CLASS_P (index));
3170 gimple_set_op (gs, 0, index);
3174 /* Return the label numbered INDEX. The default label is 0, followed by any
3175 labels in a switch statement. */
3178 gimple_switch_label (const_gimple gs, unsigned index)
3180 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3181 gcc_assert (gimple_num_ops (gs) > index + 1);
3182 return gimple_op (gs, index + 1);
3185 /* Set the label number INDEX to LABEL. 0 is always the default label. */
3188 gimple_switch_set_label (gimple gs, unsigned index, tree label)
3190 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3191 gcc_assert (gimple_num_ops (gs) > index + 1);
3192 gcc_assert (label == NULL_TREE || TREE_CODE (label) == CASE_LABEL_EXPR);
3193 gimple_set_op (gs, index + 1, label);
3196 /* Return the default label for a switch statement. */
3199 gimple_switch_default_label (const_gimple gs)
3201 return gimple_switch_label (gs, 0);
3204 /* Set the default label for a switch statement. */
3207 gimple_switch_set_default_label (gimple gs, tree label)
3209 gimple_switch_set_label (gs, 0, label);
3213 /* Return the body for the OMP statement GS. */
3215 static inline gimple_seq
3216 gimple_omp_body (gimple gs)
3218 return gs->omp.body;
3221 /* Set BODY to be the body for the OMP statement GS. */
3224 gimple_omp_set_body (gimple gs, gimple_seq body)
3226 gs->omp.body = body;
3230 /* Return the name associated with OMP_CRITICAL statement GS. */
3233 gimple_omp_critical_name (const_gimple gs)
3235 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3236 return gs->gimple_omp_critical.name;
3240 /* Return a pointer to the name associated with OMP critical statement GS. */
3242 static inline tree *
3243 gimple_omp_critical_name_ptr (gimple gs)
3245 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3246 return &gs->gimple_omp_critical.name;
3250 /* Set NAME to be the name associated with OMP critical statement GS. */
3253 gimple_omp_critical_set_name (gimple gs, tree name)
3255 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3256 gs->gimple_omp_critical.name = name;
3260 /* Return the clauses associated with OMP_FOR GS. */
3263 gimple_omp_for_clauses (const_gimple gs)
3265 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3266 return gs->gimple_omp_for.clauses;
3270 /* Return a pointer to the OMP_FOR GS. */
3272 static inline tree *
3273 gimple_omp_for_clauses_ptr (gimple gs)
3275 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3276 return &gs->gimple_omp_for.clauses;
3280 /* Set CLAUSES to be the list of clauses associated with OMP_FOR GS. */
3283 gimple_omp_for_set_clauses (gimple gs, tree clauses)
3285 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3286 gs->gimple_omp_for.clauses = clauses;
3290 /* Get the collapse count of OMP_FOR GS. */
3292 static inline size_t
3293 gimple_omp_for_collapse (gimple gs)
3295 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3296 return gs->gimple_omp_for.collapse;
3300 /* Return the index variable for OMP_FOR GS. */
3303 gimple_omp_for_index (const_gimple gs, size_t i)
3305 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3306 gcc_assert (i < gs->gimple_omp_for.collapse);
3307 return gs->gimple_omp_for.iter[i].index;
3311 /* Return a pointer to the index variable for OMP_FOR GS. */
3313 static inline tree *
3314 gimple_omp_for_index_ptr (gimple gs, size_t i)
3316 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3317 gcc_assert (i < gs->gimple_omp_for.collapse);
3318 return &gs->gimple_omp_for.iter[i].index;
3322 /* Set INDEX to be the index variable for OMP_FOR GS. */
3325 gimple_omp_for_set_index (gimple gs, size_t i, tree index)
3327 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3328 gcc_assert (i < gs->gimple_omp_for.collapse);
3329 gs->gimple_omp_for.iter[i].index = index;
3333 /* Return the initial value for OMP_FOR GS. */
3336 gimple_omp_for_initial (const_gimple gs, size_t i)
3338 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3339 gcc_assert (i < gs->gimple_omp_for.collapse);
3340 return gs->gimple_omp_for.iter[i].initial;
3344 /* Return a pointer to the initial value for OMP_FOR GS. */
3346 static inline tree *
3347 gimple_omp_for_initial_ptr (gimple gs, size_t i)
3349 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3350 gcc_assert (i < gs->gimple_omp_for.collapse);
3351 return &gs->gimple_omp_for.iter[i].initial;
3355 /* Set INITIAL to be the initial value for OMP_FOR GS. */
3358 gimple_omp_for_set_initial (gimple gs, size_t i, tree initial)
3360 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3361 gcc_assert (i < gs->gimple_omp_for.collapse);
3362 gs->gimple_omp_for.iter[i].initial = initial;
3366 /* Return the final value for OMP_FOR GS. */
3369 gimple_omp_for_final (const_gimple gs, size_t i)
3371 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3372 gcc_assert (i < gs->gimple_omp_for.collapse);
3373 return gs->gimple_omp_for.iter[i].final;
3377 /* Return a pointer to the final value for OMP_FOR GS. */
3379 static inline tree *
3380 gimple_omp_for_final_ptr (gimple gs, size_t i)
3382 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3383 gcc_assert (i < gs->gimple_omp_for.collapse);
3384 return &gs->gimple_omp_for.iter[i].final;
3388 /* Set FINAL to be the final value for OMP_FOR GS. */
3391 gimple_omp_for_set_final (gimple gs, size_t i, tree final)
3393 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3394 gcc_assert (i < gs->gimple_omp_for.collapse);
3395 gs->gimple_omp_for.iter[i].final = final;
3399 /* Return the increment value for OMP_FOR GS. */
3402 gimple_omp_for_incr (const_gimple gs, size_t i)
3404 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3405 gcc_assert (i < gs->gimple_omp_for.collapse);
3406 return gs->gimple_omp_for.iter[i].incr;
3410 /* Return a pointer to the increment value for OMP_FOR GS. */
3412 static inline tree *
3413 gimple_omp_for_incr_ptr (gimple gs, size_t i)
3415 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3416 gcc_assert (i < gs->gimple_omp_for.collapse);
3417 return &gs->gimple_omp_for.iter[i].incr;
3421 /* Set INCR to be the increment value for OMP_FOR GS. */
3424 gimple_omp_for_set_incr (gimple gs, size_t i, tree incr)
3426 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3427 gcc_assert (i < gs->gimple_omp_for.collapse);
3428 gs->gimple_omp_for.iter[i].incr = incr;
3432 /* Return the sequence of statements to execute before the OMP_FOR
3433 statement GS starts. */
3435 static inline gimple_seq
3436 gimple_omp_for_pre_body (gimple gs)
3438 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3439 return gs->gimple_omp_for.pre_body;
3443 /* Set PRE_BODY to be the sequence of statements to execute before the
3444 OMP_FOR statement GS starts. */
3447 gimple_omp_for_set_pre_body (gimple gs, gimple_seq pre_body)
3449 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3450 gs->gimple_omp_for.pre_body = pre_body;
3454 /* Return the clauses associated with OMP_PARALLEL GS. */
3457 gimple_omp_parallel_clauses (const_gimple gs)
3459 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3460 return gs->gimple_omp_parallel.clauses;
3464 /* Return a pointer to the clauses associated with OMP_PARALLEL GS. */
3466 static inline tree *
3467 gimple_omp_parallel_clauses_ptr (gimple gs)
3469 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3470 return &gs->gimple_omp_parallel.clauses;
3474 /* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL
3478 gimple_omp_parallel_set_clauses (gimple gs, tree clauses)
3480 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3481 gs->gimple_omp_parallel.clauses = clauses;
3485 /* Return the child function used to hold the body of OMP_PARALLEL GS. */
3488 gimple_omp_parallel_child_fn (const_gimple gs)
3490 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3491 return gs->gimple_omp_parallel.child_fn;
3494 /* Return a pointer to the child function used to hold the body of
3497 static inline tree *
3498 gimple_omp_parallel_child_fn_ptr (gimple gs)
3500 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3501 return &gs->gimple_omp_parallel.child_fn;
3505 /* Set CHILD_FN to be the child function for OMP_PARALLEL GS. */
3508 gimple_omp_parallel_set_child_fn (gimple gs, tree child_fn)
3510 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3511 gs->gimple_omp_parallel.child_fn = child_fn;
3515 /* Return the artificial argument used to send variables and values
3516 from the parent to the children threads in OMP_PARALLEL GS. */
3519 gimple_omp_parallel_data_arg (const_gimple gs)
3521 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3522 return gs->gimple_omp_parallel.data_arg;
3526 /* Return a pointer to the data argument for OMP_PARALLEL GS. */
3528 static inline tree *
3529 gimple_omp_parallel_data_arg_ptr (gimple gs)
3531 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3532 return &gs->gimple_omp_parallel.data_arg;
3536 /* Set DATA_ARG to be the data argument for OMP_PARALLEL GS. */
3539 gimple_omp_parallel_set_data_arg (gimple gs, tree data_arg)
3541 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3542 gs->gimple_omp_parallel.data_arg = data_arg;
3546 /* Return the clauses associated with OMP_TASK GS. */
3549 gimple_omp_task_clauses (const_gimple gs)
3551 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3552 return gs->gimple_omp_parallel.clauses;
3556 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3558 static inline tree *
3559 gimple_omp_task_clauses_ptr (gimple gs)
3561 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3562 return &gs->gimple_omp_parallel.clauses;
3566 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3570 gimple_omp_task_set_clauses (gimple gs, tree clauses)
3572 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3573 gs->gimple_omp_parallel.clauses = clauses;
3577 /* Return the child function used to hold the body of OMP_TASK GS. */
3580 gimple_omp_task_child_fn (const_gimple gs)
3582 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3583 return gs->gimple_omp_parallel.child_fn;
3586 /* Return a pointer to the child function used to hold the body of
3589 static inline tree *
3590 gimple_omp_task_child_fn_ptr (gimple gs)
3592 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3593 return &gs->gimple_omp_parallel.child_fn;
3597 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3600 gimple_omp_task_set_child_fn (gimple gs, tree child_fn)
3602 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3603 gs->gimple_omp_parallel.child_fn = child_fn;
3607 /* Return the artificial argument used to send variables and values
3608 from the parent to the children threads in OMP_TASK GS. */
3611 gimple_omp_task_data_arg (const_gimple gs)
3613 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3614 return gs->gimple_omp_parallel.data_arg;
3618 /* Return a pointer to the data argument for OMP_TASK GS. */
3620 static inline tree *
3621 gimple_omp_task_data_arg_ptr (gimple gs)
3623 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3624 return &gs->gimple_omp_parallel.data_arg;
3628 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3631 gimple_omp_task_set_data_arg (gimple gs, tree data_arg)
3633 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3634 gs->gimple_omp_parallel.data_arg = data_arg;
3638 /* Return the clauses associated with OMP_TASK GS. */
3641 gimple_omp_taskreg_clauses (const_gimple gs)
3643 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3644 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3645 return gs->gimple_omp_parallel.clauses;
3649 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3651 static inline tree *
3652 gimple_omp_taskreg_clauses_ptr (gimple gs)
3654 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3655 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3656 return &gs->gimple_omp_parallel.clauses;
3660 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3664 gimple_omp_taskreg_set_clauses (gimple gs, tree clauses)
3666 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3667 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3668 gs->gimple_omp_parallel.clauses = clauses;
3672 /* Return the child function used to hold the body of OMP_TASK GS. */
3675 gimple_omp_taskreg_child_fn (const_gimple gs)
3677 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3678 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3679 return gs->gimple_omp_parallel.child_fn;
3682 /* Return a pointer to the child function used to hold the body of
3685 static inline tree *
3686 gimple_omp_taskreg_child_fn_ptr (gimple gs)
3688 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3689 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3690 return &gs->gimple_omp_parallel.child_fn;
3694 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3697 gimple_omp_taskreg_set_child_fn (gimple gs, tree child_fn)
3699 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3700 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3701 gs->gimple_omp_parallel.child_fn = child_fn;
3705 /* Return the artificial argument used to send variables and values
3706 from the parent to the children threads in OMP_TASK GS. */
3709 gimple_omp_taskreg_data_arg (const_gimple gs)
3711 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3712 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3713 return gs->gimple_omp_parallel.data_arg;
3717 /* Return a pointer to the data argument for OMP_TASK GS. */
3719 static inline tree *
3720 gimple_omp_taskreg_data_arg_ptr (gimple gs)
3722 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3723 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3724 return &gs->gimple_omp_parallel.data_arg;
3728 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3731 gimple_omp_taskreg_set_data_arg (gimple gs, tree data_arg)
3733 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3734 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3735 gs->gimple_omp_parallel.data_arg = data_arg;
3739 /* Return the copy function used to hold the body of OMP_TASK GS. */
3742 gimple_omp_task_copy_fn (const_gimple gs)
3744 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3745 return gs->gimple_omp_task.copy_fn;
3748 /* Return a pointer to the copy function used to hold the body of
3751 static inline tree *
3752 gimple_omp_task_copy_fn_ptr (gimple gs)
3754 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3755 return &gs->gimple_omp_task.copy_fn;
3759 /* Set CHILD_FN to be the copy function for OMP_TASK GS. */
3762 gimple_omp_task_set_copy_fn (gimple gs, tree copy_fn)
3764 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3765 gs->gimple_omp_task.copy_fn = copy_fn;
3769 /* Return size of the data block in bytes in OMP_TASK GS. */
3772 gimple_omp_task_arg_size (const_gimple gs)
3774 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3775 return gs->gimple_omp_task.arg_size;
3779 /* Return a pointer to the data block size for OMP_TASK GS. */
3781 static inline tree *
3782 gimple_omp_task_arg_size_ptr (gimple gs)
3784 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3785 return &gs->gimple_omp_task.arg_size;
3789 /* Set ARG_SIZE to be the data block size for OMP_TASK GS. */
3792 gimple_omp_task_set_arg_size (gimple gs, tree arg_size)
3794 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3795 gs->gimple_omp_task.arg_size = arg_size;
3799 /* Return align of the data block in bytes in OMP_TASK GS. */
3802 gimple_omp_task_arg_align (const_gimple gs)
3804 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3805 return gs->gimple_omp_task.arg_align;
3809 /* Return a pointer to the data block align for OMP_TASK GS. */
3811 static inline tree *
3812 gimple_omp_task_arg_align_ptr (gimple gs)
3814 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3815 return &gs->gimple_omp_task.arg_align;
3819 /* Set ARG_SIZE to be the data block align for OMP_TASK GS. */
3822 gimple_omp_task_set_arg_align (gimple gs, tree arg_align)
3824 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3825 gs->gimple_omp_task.arg_align = arg_align;
3829 /* Return the clauses associated with OMP_SINGLE GS. */
3832 gimple_omp_single_clauses (const_gimple gs)
3834 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3835 return gs->gimple_omp_single.clauses;
3839 /* Return a pointer to the clauses associated with OMP_SINGLE GS. */
3841 static inline tree *
3842 gimple_omp_single_clauses_ptr (gimple gs)
3844 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3845 return &gs->gimple_omp_single.clauses;
3849 /* Set CLAUSES to be the clauses associated with OMP_SINGLE GS. */
3852 gimple_omp_single_set_clauses (gimple gs, tree clauses)
3854 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3855 gs->gimple_omp_single.clauses = clauses;
3859 /* Return the clauses associated with OMP_SECTIONS GS. */
3862 gimple_omp_sections_clauses (const_gimple gs)
3864 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3865 return gs->gimple_omp_sections.clauses;
3869 /* Return a pointer to the clauses associated with OMP_SECTIONS GS. */
3871 static inline tree *
3872 gimple_omp_sections_clauses_ptr (gimple gs)
3874 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3875 return &gs->gimple_omp_sections.clauses;
3879 /* Set CLAUSES to be the set of clauses associated with OMP_SECTIONS
3883 gimple_omp_sections_set_clauses (gimple gs, tree clauses)
3885 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3886 gs->gimple_omp_sections.clauses = clauses;
3890 /* Return the control variable associated with the GIMPLE_OMP_SECTIONS
3894 gimple_omp_sections_control (const_gimple gs)
3896 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3897 return gs->gimple_omp_sections.control;
3901 /* Return a pointer to the clauses associated with the GIMPLE_OMP_SECTIONS
3904 static inline tree *
3905 gimple_omp_sections_control_ptr (gimple gs)
3907 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3908 return &gs->gimple_omp_sections.control;
3912 /* Set CONTROL to be the set of clauses associated with the
3913 GIMPLE_OMP_SECTIONS in GS. */
3916 gimple_omp_sections_set_control (gimple gs, tree control)
3918 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3919 gs->gimple_omp_sections.control = control;
3923 /* Set COND to be the condition code for OMP_FOR GS. */
3926 gimple_omp_for_set_cond (gimple gs, size_t i, enum tree_code cond)
3928 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3929 gcc_assert (TREE_CODE_CLASS (cond) == tcc_comparison);
3930 gcc_assert (i < gs->gimple_omp_for.collapse);
3931 gs->gimple_omp_for.iter[i].cond = cond;
3935 /* Return the condition code associated with OMP_FOR GS. */
3937 static inline enum tree_code
3938 gimple_omp_for_cond (const_gimple gs, size_t i)
3940 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3941 gcc_assert (i < gs->gimple_omp_for.collapse);
3942 return gs->gimple_omp_for.iter[i].cond;
3946 /* Set the value being stored in an atomic store. */
3949 gimple_omp_atomic_store_set_val (gimple g, tree val)
3951 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3952 g->gimple_omp_atomic_store.val = val;
3956 /* Return the value being stored in an atomic store. */
3959 gimple_omp_atomic_store_val (const_gimple g)
3961 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3962 return g->gimple_omp_atomic_store.val;
3966 /* Return a pointer to the value being stored in an atomic store. */
3968 static inline tree *
3969 gimple_omp_atomic_store_val_ptr (gimple g)
3971 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3972 return &g->gimple_omp_atomic_store.val;
3976 /* Set the LHS of an atomic load. */
3979 gimple_omp_atomic_load_set_lhs (gimple g, tree lhs)
3981 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
3982 g->gimple_omp_atomic_load.lhs = lhs;
3986 /* Get the LHS of an atomic load. */
3989 gimple_omp_atomic_load_lhs (const_gimple g)
3991 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
3992 return g->gimple_omp_atomic_load.lhs;
3996 /* Return a pointer to the LHS of an atomic load. */
3998 static inline tree *
3999 gimple_omp_atomic_load_lhs_ptr (gimple g)
4001 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4002 return &g->gimple_omp_atomic_load.lhs;
4006 /* Set the RHS of an atomic load. */
4009 gimple_omp_atomic_load_set_rhs (gimple g, tree rhs)
4011 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4012 g->gimple_omp_atomic_load.rhs = rhs;
4016 /* Get the RHS of an atomic load. */
4019 gimple_omp_atomic_load_rhs (const_gimple g)
4021 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4022 return g->gimple_omp_atomic_load.rhs;
4026 /* Return a pointer to the RHS of an atomic load. */
4028 static inline tree *
4029 gimple_omp_atomic_load_rhs_ptr (gimple g)
4031 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4032 return &g->gimple_omp_atomic_load.rhs;
4036 /* Get the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4039 gimple_omp_continue_control_def (const_gimple g)
4041 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4042 return g->gimple_omp_continue.control_def;
4045 /* The same as above, but return the address. */
4047 static inline tree *
4048 gimple_omp_continue_control_def_ptr (gimple g)
4050 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4051 return &g->gimple_omp_continue.control_def;
4054 /* Set the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4057 gimple_omp_continue_set_control_def (gimple g, tree def)
4059 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4060 g->gimple_omp_continue.control_def = def;
4064 /* Get the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4067 gimple_omp_continue_control_use (const_gimple g)
4069 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4070 return g->gimple_omp_continue.control_use;
4074 /* The same as above, but return the address. */
4076 static inline tree *
4077 gimple_omp_continue_control_use_ptr (gimple g)
4079 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4080 return &g->gimple_omp_continue.control_use;
4084 /* Set the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4087 gimple_omp_continue_set_control_use (gimple g, tree use)
4089 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4090 g->gimple_omp_continue.control_use = use;
4094 /* Return a pointer to the return value for GIMPLE_RETURN GS. */
4096 static inline tree *
4097 gimple_return_retval_ptr (const_gimple gs)
4099 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4100 gcc_assert (gimple_num_ops (gs) == 1);
4101 return gimple_op_ptr (gs, 0);
4104 /* Return the return value for GIMPLE_RETURN GS. */
4107 gimple_return_retval (const_gimple gs)
4109 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4110 gcc_assert (gimple_num_ops (gs) == 1);
4111 return gimple_op (gs, 0);
4115 /* Set RETVAL to be the return value for GIMPLE_RETURN GS. */
4118 gimple_return_set_retval (gimple gs, tree retval)
4120 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4121 gcc_assert (gimple_num_ops (gs) == 1);
4122 gcc_assert (retval == NULL_TREE
4123 || TREE_CODE (retval) == RESULT_DECL
4124 || is_gimple_val (retval));
4125 gimple_set_op (gs, 0, retval);
4129 /* Returns true when the gimple statment STMT is any of the OpenMP types. */
4132 is_gimple_omp (const_gimple stmt)
4134 return (gimple_code (stmt) == GIMPLE_OMP_PARALLEL
4135 || gimple_code (stmt) == GIMPLE_OMP_TASK
4136 || gimple_code (stmt) == GIMPLE_OMP_FOR
4137 || gimple_code (stmt) == GIMPLE_OMP_SECTIONS
4138 || gimple_code (stmt) == GIMPLE_OMP_SECTIONS_SWITCH
4139 || gimple_code (stmt) == GIMPLE_OMP_SINGLE
4140 || gimple_code (stmt) == GIMPLE_OMP_SECTION
4141 || gimple_code (stmt) == GIMPLE_OMP_MASTER
4142 || gimple_code (stmt) == GIMPLE_OMP_ORDERED
4143 || gimple_code (stmt) == GIMPLE_OMP_CRITICAL
4144 || gimple_code (stmt) == GIMPLE_OMP_RETURN
4145 || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_LOAD
4146 || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_STORE
4147 || gimple_code (stmt) == GIMPLE_OMP_CONTINUE);
4151 /* Returns TRUE if statement G is a GIMPLE_NOP. */
4154 gimple_nop_p (const_gimple g)
4156 return gimple_code (g) == GIMPLE_NOP;
4160 /* Return the new type set by GIMPLE_CHANGE_DYNAMIC_TYPE statement GS. */
4163 gimple_cdt_new_type (gimple gs)
4165 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4166 return gimple_op (gs, 1);
4169 /* Return a pointer to the new type set by GIMPLE_CHANGE_DYNAMIC_TYPE
4172 static inline tree *
4173 gimple_cdt_new_type_ptr (gimple gs)
4175 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4176 return gimple_op_ptr (gs, 1);
4179 /* Set NEW_TYPE to be the type returned by GIMPLE_CHANGE_DYNAMIC_TYPE
4183 gimple_cdt_set_new_type (gimple gs, tree new_type)
4185 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4186 gcc_assert (TREE_CODE_CLASS (TREE_CODE (new_type)) == tcc_type);
4187 gimple_set_op (gs, 1, new_type);
4191 /* Return the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE statement GS. */
4194 gimple_cdt_location (gimple gs)
4196 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4197 return gimple_op (gs, 0);
4201 /* Return a pointer to the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE
4204 static inline tree *
4205 gimple_cdt_location_ptr (gimple gs)
4207 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4208 return gimple_op_ptr (gs, 0);
4212 /* Set PTR to be the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE
4216 gimple_cdt_set_location (gimple gs, tree ptr)
4218 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4219 gimple_set_op (gs, 0, ptr);
4223 /* Return the predictor of GIMPLE_PREDICT statement GS. */
4225 static inline enum br_predictor
4226 gimple_predict_predictor (gimple gs)
4228 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4229 return (enum br_predictor) (gs->gsbase.subcode & ~GF_PREDICT_TAKEN);
4233 /* Set the predictor of GIMPLE_PREDICT statement GS to PREDICT. */
4236 gimple_predict_set_predictor (gimple gs, enum br_predictor predictor)
4238 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4239 gs->gsbase.subcode = (gs->gsbase.subcode & GF_PREDICT_TAKEN)
4240 | (unsigned) predictor;
4244 /* Return the outcome of GIMPLE_PREDICT statement GS. */
4246 static inline enum prediction
4247 gimple_predict_outcome (gimple gs)
4249 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4250 return (gs->gsbase.subcode & GF_PREDICT_TAKEN) ? TAKEN : NOT_TAKEN;
4254 /* Set the outcome of GIMPLE_PREDICT statement GS to OUTCOME. */
4257 gimple_predict_set_outcome (gimple gs, enum prediction outcome)
4259 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4260 if (outcome == TAKEN)
4261 gs->gsbase.subcode |= GF_PREDICT_TAKEN;
4263 gs->gsbase.subcode &= ~GF_PREDICT_TAKEN;
4267 /* Return a new iterator pointing to GIMPLE_SEQ's first statement. */
4269 static inline gimple_stmt_iterator
4270 gsi_start (gimple_seq seq)
4272 gimple_stmt_iterator i;
4274 i.ptr = gimple_seq_first (seq);
4276 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4282 /* Return a new iterator pointing to the first statement in basic block BB. */
4284 static inline gimple_stmt_iterator
4285 gsi_start_bb (basic_block bb)
4287 gimple_stmt_iterator i;
4291 i.ptr = gimple_seq_first (seq);
4299 /* Return a new iterator initially pointing to GIMPLE_SEQ's last statement. */
4301 static inline gimple_stmt_iterator
4302 gsi_last (gimple_seq seq)
4304 gimple_stmt_iterator i;
4306 i.ptr = gimple_seq_last (seq);
4308 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4314 /* Return a new iterator pointing to the last statement in basic block BB. */
4316 static inline gimple_stmt_iterator
4317 gsi_last_bb (basic_block bb)
4319 gimple_stmt_iterator i;
4323 i.ptr = gimple_seq_last (seq);
4331 /* Return true if I is at the end of its sequence. */
4334 gsi_end_p (gimple_stmt_iterator i)
4336 return i.ptr == NULL;
4340 /* Return true if I is one statement before the end of its sequence. */
4343 gsi_one_before_end_p (gimple_stmt_iterator i)
4345 return i.ptr != NULL && i.ptr->next == NULL;
4349 /* Advance the iterator to the next gimple statement. */
4352 gsi_next (gimple_stmt_iterator *i)
4354 i->ptr = i->ptr->next;
4357 /* Advance the iterator to the previous gimple statement. */
4360 gsi_prev (gimple_stmt_iterator *i)
4362 i->ptr = i->ptr->prev;
4365 /* Return the current stmt. */
4367 static inline gimple
4368 gsi_stmt (gimple_stmt_iterator i)
4373 /* Return a block statement iterator that points to the first non-label
4374 statement in block BB. */
4376 static inline gimple_stmt_iterator
4377 gsi_after_labels (basic_block bb)
4379 gimple_stmt_iterator gsi = gsi_start_bb (bb);
4381 while (!gsi_end_p (gsi) && gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL)
4387 /* Return a pointer to the current stmt.
4389 NOTE: You may want to use gsi_replace on the iterator itself,
4390 as this performs additional bookkeeping that will not be done
4391 if you simply assign through a pointer returned by gsi_stmt_ptr. */
4393 static inline gimple *
4394 gsi_stmt_ptr (gimple_stmt_iterator *i)
4396 return &i->ptr->stmt;
4400 /* Return the basic block associated with this iterator. */
4402 static inline basic_block
4403 gsi_bb (gimple_stmt_iterator i)
4409 /* Return the sequence associated with this iterator. */
4411 static inline gimple_seq
4412 gsi_seq (gimple_stmt_iterator i)
4418 enum gsi_iterator_update
4420 GSI_NEW_STMT, /* Only valid when single statement is added, move
4422 GSI_SAME_STMT, /* Leave the iterator at the same statement. */
4423 GSI_CONTINUE_LINKING /* Move iterator to whatever position is suitable
4424 for linking other statements in the same
4428 /* In gimple-iterator.c */
4429 gimple_stmt_iterator gsi_start_phis (basic_block);
4430 gimple_seq gsi_split_seq_after (gimple_stmt_iterator);
4431 gimple_seq gsi_split_seq_before (gimple_stmt_iterator *);
4432 void gsi_replace (gimple_stmt_iterator *, gimple, bool);
4433 void gsi_insert_before (gimple_stmt_iterator *, gimple,
4434 enum gsi_iterator_update);
4435 void gsi_insert_before_without_update (gimple_stmt_iterator *, gimple,
4436 enum gsi_iterator_update);
4437 void gsi_insert_seq_before (gimple_stmt_iterator *, gimple_seq,
4438 enum gsi_iterator_update);
4439 void gsi_insert_seq_before_without_update (gimple_stmt_iterator *, gimple_seq,
4440 enum gsi_iterator_update);
4441 void gsi_insert_after (gimple_stmt_iterator *, gimple,
4442 enum gsi_iterator_update);
4443 void gsi_insert_after_without_update (gimple_stmt_iterator *, gimple,
4444 enum gsi_iterator_update);
4445 void gsi_insert_seq_after (gimple_stmt_iterator *, gimple_seq,
4446 enum gsi_iterator_update);
4447 void gsi_insert_seq_after_without_update (gimple_stmt_iterator *, gimple_seq,
4448 enum gsi_iterator_update);
4449 void gsi_remove (gimple_stmt_iterator *, bool);
4450 gimple_stmt_iterator gsi_for_stmt (gimple);
4451 void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *);
4452 void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *);
4453 void gsi_move_to_bb_end (gimple_stmt_iterator *, struct basic_block_def *);
4454 void gsi_insert_on_edge (edge, gimple);
4455 void gsi_insert_seq_on_edge (edge, gimple_seq);
4456 basic_block gsi_insert_on_edge_immediate (edge, gimple);
4457 basic_block gsi_insert_seq_on_edge_immediate (edge, gimple_seq);
4458 void gsi_commit_one_edge_insert (edge, basic_block *);
4459 void gsi_commit_edge_inserts (void);
4460 gimple gimple_call_copy_skip_args (gimple, bitmap);
4463 /* Convenience routines to walk all statements of a gimple function.
4464 Note that this is useful exclusively before the code is converted
4465 into SSA form. Once the program is in SSA form, the standard
4466 operand interface should be used to analyze/modify statements. */
4467 struct walk_stmt_info
4469 /* Points to the current statement being walked. */
4470 gimple_stmt_iterator gsi;
4472 /* Additional data that the callback functions may want to carry
4473 through the recursion. */
4476 /* Pointer map used to mark visited tree nodes when calling
4477 walk_tree on each operand. If set to NULL, duplicate tree nodes
4478 will be visited more than once. */
4479 struct pointer_set_t *pset;
4481 /* Indicates whether the operand being examined may be replaced
4482 with something that matches is_gimple_val (if true) or something
4483 slightly more complicated (if false). "Something" technically
4484 means the common subset of is_gimple_lvalue and is_gimple_rhs,
4485 but we never try to form anything more complicated than that, so
4486 we don't bother checking.
4488 Also note that CALLBACK should update this flag while walking the
4489 sub-expressions of a statement. For instance, when walking the
4490 statement 'foo (&var)', the flag VAL_ONLY will initially be set
4491 to true, however, when walking &var, the operand of that
4492 ADDR_EXPR does not need to be a GIMPLE value. */
4495 /* True if we are currently walking the LHS of an assignment. */
4498 /* Optional. Set to true by the callback functions if they made any
4502 /* True if we're interested in location information. */
4503 bool want_locations;
4505 /* Operand returned by the callbacks. This is set when calling
4506 walk_gimple_seq. If the walk_stmt_fn or walk_tree_fn callback
4507 returns non-NULL, this field will contain the tree returned by
4508 the last callback. */
4509 tree callback_result;
4512 /* Callback for walk_gimple_stmt. Called for every statement found
4513 during traversal. The first argument points to the statement to
4514 walk. The second argument is a flag that the callback sets to
4515 'true' if it the callback handled all the operands and
4516 sub-statements of the statement (the default value of this flag is
4517 'false'). The third argument is an anonymous pointer to data
4518 to be used by the callback. */
4519 typedef tree (*walk_stmt_fn) (gimple_stmt_iterator *, bool *,
4520 struct walk_stmt_info *);
4522 gimple walk_gimple_seq (gimple_seq, walk_stmt_fn, walk_tree_fn,
4523 struct walk_stmt_info *);
4524 tree walk_gimple_stmt (gimple_stmt_iterator *, walk_stmt_fn, walk_tree_fn,
4525 struct walk_stmt_info *);
4526 tree walk_gimple_op (gimple, walk_tree_fn, struct walk_stmt_info *);
4528 #ifdef GATHER_STATISTICS
4529 /* Enum and arrays used for allocation stats. Keep in sync with
4530 gimple.c:gimple_alloc_kind_names. */
4531 enum gimple_alloc_kind
4533 gimple_alloc_kind_assign, /* Assignments. */
4534 gimple_alloc_kind_phi, /* PHI nodes. */
4535 gimple_alloc_kind_cond, /* Conditionals. */
4536 gimple_alloc_kind_seq, /* Sequences. */
4537 gimple_alloc_kind_rest, /* Everything else. */
4538 gimple_alloc_kind_all
4541 extern int gimple_alloc_counts[];
4542 extern int gimple_alloc_sizes[];
4544 /* Return the allocation kind for a given stmt CODE. */
4545 static inline enum gimple_alloc_kind
4546 gimple_alloc_kind (enum gimple_code code)
4551 return gimple_alloc_kind_assign;
4553 return gimple_alloc_kind_phi;
4555 return gimple_alloc_kind_cond;
4557 return gimple_alloc_kind_rest;
4560 #endif /* GATHER_STATISTICS */
4562 extern void dump_gimple_statistics (void);
4564 #endif /* GCC_GIMPLE_H */