1 /* Gimple IR definitions.
3 Copyright 2007, 2008, 2009 Free Software Foundation, Inc.
4 Contributed by Aldy Hernandez <aldyh@redhat.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
25 #include "pointer-set.h"
29 #include "hard-reg-set.h"
30 #include "basic-block.h"
31 #include "tree-ssa-operands.h"
34 DEF_VEC_ALLOC_P(gimple,heap);
35 DEF_VEC_ALLOC_P(gimple,gc);
37 typedef gimple *gimple_p;
39 DEF_VEC_ALLOC_P(gimple_p,heap);
41 DEF_VEC_P(gimple_seq);
42 DEF_VEC_ALLOC_P(gimple_seq,gc);
43 DEF_VEC_ALLOC_P(gimple_seq,heap);
45 /* For each block, the PHI nodes that need to be rewritten are stored into
47 typedef VEC(gimple, heap) *gimple_vec;
48 DEF_VEC_P (gimple_vec);
49 DEF_VEC_ALLOC_P (gimple_vec, heap);
52 #define DEFGSCODE(SYM, STRING, STRUCT) SYM,
55 LAST_AND_UNUSED_GIMPLE_CODE
58 extern const char *const gimple_code_name[];
59 extern const unsigned char gimple_rhs_class_table[];
61 /* Error out if a gimple tuple is addressed incorrectly. */
62 #if defined ENABLE_GIMPLE_CHECKING
63 extern void gimple_check_failed (const_gimple, const char *, int, \
64 const char *, enum gimple_code, \
65 enum tree_code) ATTRIBUTE_NORETURN;
67 #define GIMPLE_CHECK(GS, CODE) \
69 const_gimple __gs = (GS); \
70 if (gimple_code (__gs) != (CODE)) \
71 gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__, \
72 (CODE), ERROR_MARK); \
74 #else /* not ENABLE_GIMPLE_CHECKING */
75 #define GIMPLE_CHECK(GS, CODE) (void)0
78 /* Class of GIMPLE expressions suitable for the RHS of assignments. See
79 get_gimple_rhs_class. */
82 GIMPLE_INVALID_RHS, /* The expression cannot be used on the RHS. */
83 GIMPLE_BINARY_RHS, /* The expression is a binary operation. */
84 GIMPLE_UNARY_RHS, /* The expression is a unary operation. */
85 GIMPLE_SINGLE_RHS /* The expression is a single object (an SSA
86 name, a _DECL, a _REF, etc. */
89 /* Specific flags for individual GIMPLE statements. These flags are
90 always stored in gimple_statement_base.subcode and they may only be
91 defined for statement codes that do not use sub-codes.
93 Values for the masks can overlap as long as the overlapping values
94 are never used in the same statement class.
96 The maximum mask value that can be defined is 1 << 15 (i.e., each
97 statement code can hold up to 16 bitflags).
99 Keep this list sorted. */
101 GF_ASM_INPUT = 1 << 0,
102 GF_ASM_VOLATILE = 1 << 1,
103 GF_CALL_CANNOT_INLINE = 1 << 0,
104 GF_CALL_FROM_THUNK = 1 << 1,
105 GF_CALL_RETURN_SLOT_OPT = 1 << 2,
106 GF_CALL_TAILCALL = 1 << 3,
107 GF_CALL_VA_ARG_PACK = 1 << 4,
108 GF_OMP_PARALLEL_COMBINED = 1 << 0,
110 /* True on an GIMPLE_OMP_RETURN statement if the return does not require
111 a thread synchronization via some sort of barrier. The exact barrier
112 that would otherwise be emitted is dependent on the OMP statement with
113 which this return is associated. */
114 GF_OMP_RETURN_NOWAIT = 1 << 0,
116 GF_OMP_SECTION_LAST = 1 << 0,
117 GF_PREDICT_TAKEN = 1 << 15
120 /* Currently, there's only one type of gimple debug stmt. Others are
121 envisioned, for example, to enable the generation of is_stmt notes
122 in line number information, to mark sequence points, etc. This
123 subcode is to be used to tell them apart. */
124 enum gimple_debug_subcode {
125 GIMPLE_DEBUG_BIND = 0
128 /* Masks for selecting a pass local flag (PLF) to work on. These
129 masks are used by gimple_set_plf and gimple_plf. */
135 /* A node in a gimple_seq_d. */
136 struct GTY((chain_next ("%h.next"), chain_prev ("%h.prev"))) gimple_seq_node_d {
138 struct gimple_seq_node_d *prev;
139 struct gimple_seq_node_d *next;
142 /* A double-linked sequence of gimple statements. */
143 struct GTY ((chain_next ("%h.next_free"))) gimple_seq_d {
144 /* First and last statements in the sequence. */
145 gimple_seq_node first;
146 gimple_seq_node last;
148 /* Sequences are created/destroyed frequently. To minimize
149 allocation activity, deallocated sequences are kept in a pool of
150 available sequences. This is the pointer to the next free
151 sequence in the pool. */
152 gimple_seq next_free;
156 /* Return the first node in GIMPLE sequence S. */
158 static inline gimple_seq_node
159 gimple_seq_first (const_gimple_seq s)
161 return s ? s->first : NULL;
165 /* Return the first statement in GIMPLE sequence S. */
168 gimple_seq_first_stmt (const_gimple_seq s)
170 gimple_seq_node n = gimple_seq_first (s);
171 return (n) ? n->stmt : NULL;
175 /* Return the last node in GIMPLE sequence S. */
177 static inline gimple_seq_node
178 gimple_seq_last (const_gimple_seq s)
180 return s ? s->last : NULL;
184 /* Return the last statement in GIMPLE sequence S. */
187 gimple_seq_last_stmt (const_gimple_seq s)
189 gimple_seq_node n = gimple_seq_last (s);
190 return (n) ? n->stmt : NULL;
194 /* Set the last node in GIMPLE sequence S to LAST. */
197 gimple_seq_set_last (gimple_seq s, gimple_seq_node last)
203 /* Set the first node in GIMPLE sequence S to FIRST. */
206 gimple_seq_set_first (gimple_seq s, gimple_seq_node first)
212 /* Return true if GIMPLE sequence S is empty. */
215 gimple_seq_empty_p (const_gimple_seq s)
217 return s == NULL || s->first == NULL;
221 void gimple_seq_add_stmt (gimple_seq *, gimple);
223 /* Allocate a new sequence and initialize its first element with STMT. */
225 static inline gimple_seq
226 gimple_seq_alloc_with_stmt (gimple stmt)
228 gimple_seq seq = NULL;
229 gimple_seq_add_stmt (&seq, stmt);
234 /* Returns the sequence of statements in BB. */
236 static inline gimple_seq
237 bb_seq (const_basic_block bb)
239 return (!(bb->flags & BB_RTL) && bb->il.gimple) ? bb->il.gimple->seq : NULL;
243 /* Sets the sequence of statements in BB to SEQ. */
246 set_bb_seq (basic_block bb, gimple_seq seq)
248 gcc_assert (!(bb->flags & BB_RTL));
249 bb->il.gimple->seq = seq;
252 /* Iterator object for GIMPLE statement sequences. */
256 /* Sequence node holding the current statement. */
259 /* Sequence and basic block holding the statement. These fields
260 are necessary to handle edge cases such as when statement is
261 added to an empty basic block or when the last statement of a
262 block/sequence is removed. */
265 } gimple_stmt_iterator;
268 /* Data structure definitions for GIMPLE tuples. NOTE: word markers
269 are for 64 bit hosts. */
271 struct GTY(()) gimple_statement_base {
273 Main identifying code for a tuple. */
274 ENUM_BITFIELD(gimple_code) code : 8;
276 /* Nonzero if a warning should not be emitted on this tuple. */
277 unsigned int no_warning : 1;
279 /* Nonzero if this tuple has been visited. Passes are responsible
280 for clearing this bit before using it. */
281 unsigned int visited : 1;
283 /* Nonzero if this tuple represents a non-temporal move. */
284 unsigned int nontemporal_move : 1;
286 /* Pass local flags. These flags are free for any pass to use as
287 they see fit. Passes should not assume that these flags contain
288 any useful value when the pass starts. Any initial state that
289 the pass requires should be set on entry to the pass. See
290 gimple_set_plf and gimple_plf for usage. */
291 unsigned int plf : 2;
293 /* Nonzero if this statement has been modified and needs to have its
294 operands rescanned. */
295 unsigned modified : 1;
297 /* Nonzero if this statement contains volatile operands. */
298 unsigned has_volatile_ops : 1;
300 /* Padding to get subcode to 16 bit alignment. */
303 /* The SUBCODE field can be used for tuple-specific flags for tuples
304 that do not require subcodes. Note that SUBCODE should be at
305 least as wide as tree codes, as several tuples store tree codes
307 unsigned int subcode : 16;
309 /* UID of this statement. This is used by passes that want to
310 assign IDs to statements. It must be assigned and used by each
311 pass. By default it should be assumed to contain garbage. */
315 Locus information for debug info. */
318 /* Number of operands in this tuple. */
322 Basic block holding this statement. */
323 struct basic_block_def *bb;
326 Lexical block holding this statement. */
331 /* Base structure for tuples with operands. */
333 struct GTY(()) gimple_statement_with_ops_base
336 struct gimple_statement_base gsbase;
339 SSA operand vectors. NOTE: It should be possible to
340 amalgamate these vectors with the operand vector OP. However,
341 the SSA operand vectors are organized differently and contain
342 more information (like immediate use chaining). */
343 struct def_optype_d GTY((skip (""))) *def_ops;
344 struct use_optype_d GTY((skip (""))) *use_ops;
348 /* Statements that take register operands. */
350 struct GTY(()) gimple_statement_with_ops
353 struct gimple_statement_with_ops_base opbase;
356 Operand vector. NOTE! This must always be the last field
357 of this structure. In particular, this means that this
358 structure cannot be embedded inside another one. */
359 tree GTY((length ("%h.opbase.gsbase.num_ops"))) op[1];
363 /* Base for statements that take both memory and register operands. */
365 struct GTY(()) gimple_statement_with_memory_ops_base
368 struct gimple_statement_with_ops_base opbase;
371 Virtual operands for this statement. The GC will pick them
372 up via the ssa_names array. */
373 tree GTY((skip (""))) vdef;
374 tree GTY((skip (""))) vuse;
378 /* Statements that take both memory and register operands. */
380 struct GTY(()) gimple_statement_with_memory_ops
383 struct gimple_statement_with_memory_ops_base membase;
386 Operand vector. NOTE! This must always be the last field
387 of this structure. In particular, this means that this
388 structure cannot be embedded inside another one. */
389 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
393 /* OpenMP statements (#pragma omp). */
395 struct GTY(()) gimple_statement_omp {
397 struct gimple_statement_base gsbase;
406 struct GTY(()) gimple_statement_bind {
408 struct gimple_statement_base gsbase;
411 Variables declared in this scope. */
415 This is different than the BLOCK field in gimple_statement_base,
416 which is analogous to TREE_BLOCK (i.e., the lexical block holding
417 this statement). This field is the equivalent of BIND_EXPR_BLOCK
418 in tree land (i.e., the lexical scope defined by this bind). See
429 struct GTY(()) gimple_statement_catch {
431 struct gimple_statement_base gsbase;
441 /* GIMPLE_EH_FILTER */
443 struct GTY(()) gimple_statement_eh_filter {
445 struct gimple_statement_base gsbase;
447 /* Subcode: EH_FILTER_MUST_NOT_THROW. A boolean flag analogous to
448 the tree counterpart. */
462 struct GTY(()) gimple_statement_phi {
464 struct gimple_statement_base gsbase;
474 struct phi_arg_d GTY ((length ("%h.nargs"))) args[1];
480 struct GTY(()) gimple_statement_resx {
482 struct gimple_statement_base gsbase;
485 Exception region number. */
492 struct GTY(()) gimple_statement_try {
494 struct gimple_statement_base gsbase;
497 Expression to evaluate. */
501 Cleanup expression. */
505 /* Kind of GIMPLE_TRY statements. */
506 enum gimple_try_flags
509 GIMPLE_TRY_CATCH = 1 << 0,
512 GIMPLE_TRY_FINALLY = 1 << 1,
513 GIMPLE_TRY_KIND = GIMPLE_TRY_CATCH | GIMPLE_TRY_FINALLY,
515 /* Analogous to TRY_CATCH_IS_CLEANUP. */
516 GIMPLE_TRY_CATCH_IS_CLEANUP = 1 << 2
519 /* GIMPLE_WITH_CLEANUP_EXPR */
521 struct GTY(()) gimple_statement_wce {
523 struct gimple_statement_base gsbase;
525 /* Subcode: CLEANUP_EH_ONLY. True if the cleanup should only be
526 executed if an exception is thrown, not on normal exit of its
527 scope. This flag is analogous to the CLEANUP_EH_ONLY flag
531 Cleanup expression. */
538 struct GTY(()) gimple_statement_asm
541 struct gimple_statement_with_memory_ops_base membase;
544 __asm__ statement. */
548 Number of inputs, outputs and clobbers. */
554 Operand vector. NOTE! This must always be the last field
555 of this structure. In particular, this means that this
556 structure cannot be embedded inside another one. */
557 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
560 /* GIMPLE_OMP_CRITICAL */
562 struct GTY(()) gimple_statement_omp_critical {
564 struct gimple_statement_omp omp;
567 Critical section name. */
572 struct GTY(()) gimple_omp_for_iter {
573 /* Condition code. */
576 /* Index variable. */
591 struct GTY(()) gimple_statement_omp_for {
593 struct gimple_statement_omp omp;
599 Number of elements in iter array. */
603 struct gimple_omp_for_iter * GTY((length ("%h.collapse"))) iter;
606 Pre-body evaluated before the loop body begins. */
611 /* GIMPLE_OMP_PARALLEL */
613 struct GTY(()) gimple_statement_omp_parallel {
615 struct gimple_statement_omp omp;
622 Child function holding the body of the parallel region. */
626 Shared data argument. */
631 /* GIMPLE_OMP_TASK */
633 struct GTY(()) gimple_statement_omp_task {
635 struct gimple_statement_omp_parallel par;
638 Child function holding firstprivate initialization if needed. */
642 Size and alignment in bytes of the argument data block. */
648 /* GIMPLE_OMP_SECTION */
649 /* Uses struct gimple_statement_omp. */
652 /* GIMPLE_OMP_SECTIONS */
654 struct GTY(()) gimple_statement_omp_sections {
656 struct gimple_statement_omp omp;
662 The control variable used for deciding which of the sections to
667 /* GIMPLE_OMP_CONTINUE.
669 Note: This does not inherit from gimple_statement_omp, because we
670 do not need the body field. */
672 struct GTY(()) gimple_statement_omp_continue {
674 struct gimple_statement_base gsbase;
683 /* GIMPLE_OMP_SINGLE */
685 struct GTY(()) gimple_statement_omp_single {
687 struct gimple_statement_omp omp;
694 /* GIMPLE_OMP_ATOMIC_LOAD.
695 Note: This is based on gimple_statement_base, not g_s_omp, because g_s_omp
696 contains a sequence, which we don't need here. */
698 struct GTY(()) gimple_statement_omp_atomic_load {
700 struct gimple_statement_base gsbase;
706 /* GIMPLE_OMP_ATOMIC_STORE.
707 See note on GIMPLE_OMP_ATOMIC_LOAD. */
709 struct GTY(()) gimple_statement_omp_atomic_store {
711 struct gimple_statement_base gsbase;
717 enum gimple_statement_structure_enum {
718 #define DEFGSSTRUCT(SYM, STRING) SYM,
719 #include "gsstruct.def"
725 /* Define the overall contents of a gimple tuple. It may be any of the
726 structures declared above for various types of tuples. */
728 union GTY ((desc ("gimple_statement_structure (&%h)"))) gimple_statement_d {
729 struct gimple_statement_base GTY ((tag ("GSS_BASE"))) gsbase;
730 struct gimple_statement_with_ops GTY ((tag ("GSS_WITH_OPS"))) gsops;
731 struct gimple_statement_with_memory_ops GTY ((tag ("GSS_WITH_MEM_OPS"))) gsmem;
732 struct gimple_statement_omp GTY ((tag ("GSS_OMP"))) omp;
733 struct gimple_statement_bind GTY ((tag ("GSS_BIND"))) gimple_bind;
734 struct gimple_statement_catch GTY ((tag ("GSS_CATCH"))) gimple_catch;
735 struct gimple_statement_eh_filter GTY ((tag ("GSS_EH_FILTER"))) gimple_eh_filter;
736 struct gimple_statement_phi GTY ((tag ("GSS_PHI"))) gimple_phi;
737 struct gimple_statement_resx GTY ((tag ("GSS_RESX"))) gimple_resx;
738 struct gimple_statement_try GTY ((tag ("GSS_TRY"))) gimple_try;
739 struct gimple_statement_wce GTY ((tag ("GSS_WCE"))) gimple_wce;
740 struct gimple_statement_asm GTY ((tag ("GSS_ASM"))) gimple_asm;
741 struct gimple_statement_omp_critical GTY ((tag ("GSS_OMP_CRITICAL"))) gimple_omp_critical;
742 struct gimple_statement_omp_for GTY ((tag ("GSS_OMP_FOR"))) gimple_omp_for;
743 struct gimple_statement_omp_parallel GTY ((tag ("GSS_OMP_PARALLEL"))) gimple_omp_parallel;
744 struct gimple_statement_omp_task GTY ((tag ("GSS_OMP_TASK"))) gimple_omp_task;
745 struct gimple_statement_omp_sections GTY ((tag ("GSS_OMP_SECTIONS"))) gimple_omp_sections;
746 struct gimple_statement_omp_single GTY ((tag ("GSS_OMP_SINGLE"))) gimple_omp_single;
747 struct gimple_statement_omp_continue GTY ((tag ("GSS_OMP_CONTINUE"))) gimple_omp_continue;
748 struct gimple_statement_omp_atomic_load GTY ((tag ("GSS_OMP_ATOMIC_LOAD"))) gimple_omp_atomic_load;
749 struct gimple_statement_omp_atomic_store GTY ((tag ("GSS_OMP_ATOMIC_STORE"))) gimple_omp_atomic_store;
753 gimple gimple_build_return (tree);
755 gimple gimple_build_assign_stat (tree, tree MEM_STAT_DECL);
756 #define gimple_build_assign(l,r) gimple_build_assign_stat (l, r MEM_STAT_INFO)
758 void extract_ops_from_tree (tree, enum tree_code *, tree *, tree *);
760 gimple gimple_build_assign_with_ops_stat (enum tree_code, tree, tree,
762 #define gimple_build_assign_with_ops(c,o1,o2,o3) \
763 gimple_build_assign_with_ops_stat (c, o1, o2, o3 MEM_STAT_INFO)
765 gimple gimple_build_debug_bind_stat (tree, tree, gimple MEM_STAT_DECL);
766 #define gimple_build_debug_bind(var,val,stmt) \
767 gimple_build_debug_bind_stat ((var), (val), (stmt) MEM_STAT_INFO)
769 gimple gimple_build_call_vec (tree, VEC(tree, heap) *);
770 gimple gimple_build_call (tree, unsigned, ...);
771 gimple gimple_build_call_from_tree (tree);
772 gimple gimplify_assign (tree, tree, gimple_seq *);
773 gimple gimple_build_cond (enum tree_code, tree, tree, tree, tree);
774 gimple gimple_build_label (tree label);
775 gimple gimple_build_goto (tree dest);
776 gimple gimple_build_nop (void);
777 gimple gimple_build_bind (tree, gimple_seq, tree);
778 gimple gimple_build_asm (const char *, unsigned, unsigned, unsigned, ...);
779 gimple gimple_build_asm_vec (const char *, VEC(tree,gc) *, VEC(tree,gc) *,
781 gimple gimple_build_catch (tree, gimple_seq);
782 gimple gimple_build_eh_filter (tree, gimple_seq);
783 gimple gimple_build_try (gimple_seq, gimple_seq, enum gimple_try_flags);
784 gimple gimple_build_wce (gimple_seq);
785 gimple gimple_build_resx (int);
786 gimple gimple_build_switch (unsigned, tree, tree, ...);
787 gimple gimple_build_switch_vec (tree, tree, VEC(tree,heap) *);
788 gimple gimple_build_omp_parallel (gimple_seq, tree, tree, tree);
789 gimple gimple_build_omp_task (gimple_seq, tree, tree, tree, tree, tree, tree);
790 gimple gimple_build_omp_for (gimple_seq, tree, size_t, gimple_seq);
791 gimple gimple_build_omp_critical (gimple_seq, tree);
792 gimple gimple_build_omp_section (gimple_seq);
793 gimple gimple_build_omp_continue (tree, tree);
794 gimple gimple_build_omp_master (gimple_seq);
795 gimple gimple_build_omp_return (bool);
796 gimple gimple_build_omp_ordered (gimple_seq);
797 gimple gimple_build_omp_sections (gimple_seq, tree);
798 gimple gimple_build_omp_sections_switch (void);
799 gimple gimple_build_omp_single (gimple_seq, tree);
800 gimple gimple_build_cdt (tree, tree);
801 gimple gimple_build_omp_atomic_load (tree, tree);
802 gimple gimple_build_omp_atomic_store (tree);
803 gimple gimple_build_predict (enum br_predictor, enum prediction);
804 enum gimple_statement_structure_enum gimple_statement_structure (gimple);
805 enum gimple_statement_structure_enum gss_for_assign (enum tree_code);
806 void sort_case_labels (VEC(tree,heap) *);
807 void gimple_set_body (tree, gimple_seq);
808 gimple_seq gimple_body (tree);
809 bool gimple_has_body_p (tree);
810 gimple_seq gimple_seq_alloc (void);
811 void gimple_seq_free (gimple_seq);
812 void gimple_seq_add_seq (gimple_seq *, gimple_seq);
813 gimple_seq gimple_seq_copy (gimple_seq);
814 int gimple_call_flags (const_gimple);
815 bool gimple_assign_copy_p (gimple);
816 bool gimple_assign_ssa_name_copy_p (gimple);
817 bool gimple_assign_single_p (gimple);
818 bool gimple_assign_unary_nop_p (gimple);
819 void gimple_set_bb (gimple, struct basic_block_def *);
820 tree gimple_fold (const_gimple);
821 void gimple_assign_set_rhs_from_tree (gimple_stmt_iterator *, tree);
822 void gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *, enum tree_code,
824 tree gimple_get_lhs (const_gimple);
825 void gimple_set_lhs (gimple, tree);
826 gimple gimple_copy (gimple);
827 bool is_gimple_operand (const_tree);
828 void gimple_set_modified (gimple, bool);
829 void gimple_cond_get_ops_from_tree (tree, enum tree_code *, tree *, tree *);
830 gimple gimple_build_cond_from_tree (tree, tree, tree);
831 void gimple_cond_set_condition_from_tree (gimple, tree);
832 bool gimple_has_side_effects (const_gimple);
833 bool gimple_rhs_has_side_effects (const_gimple);
834 bool gimple_could_trap_p (gimple);
835 bool gimple_assign_rhs_could_trap_p (gimple);
836 void gimple_regimplify_operands (gimple, gimple_stmt_iterator *);
837 bool empty_body_p (gimple_seq);
838 unsigned get_gimple_rhs_num_ops (enum tree_code);
840 /* Returns true iff T is a valid GIMPLE statement. */
841 extern bool is_gimple_stmt (tree);
843 /* Returns true iff TYPE is a valid type for a scalar register variable. */
844 extern bool is_gimple_reg_type (tree);
845 /* Returns true iff T is a scalar register variable. */
846 extern bool is_gimple_reg (tree);
847 /* Returns true iff T is any sort of variable. */
848 extern bool is_gimple_variable (tree);
849 /* Returns true iff T is any sort of symbol. */
850 extern bool is_gimple_id (tree);
851 /* Returns true iff T is a variable or an INDIRECT_REF (of a variable). */
852 extern bool is_gimple_min_lval (tree);
853 /* Returns true iff T is something whose address can be taken. */
854 extern bool is_gimple_addressable (tree);
855 /* Returns true iff T is any valid GIMPLE lvalue. */
856 extern bool is_gimple_lvalue (tree);
858 /* Returns true iff T is a GIMPLE address. */
859 bool is_gimple_address (const_tree);
860 /* Returns true iff T is a GIMPLE invariant address. */
861 bool is_gimple_invariant_address (const_tree);
862 /* Returns true iff T is a GIMPLE invariant address at interprocedural
864 bool is_gimple_ip_invariant_address (const_tree);
865 /* Returns true iff T is a valid GIMPLE constant. */
866 bool is_gimple_constant (const_tree);
867 /* Returns true iff T is a GIMPLE restricted function invariant. */
868 extern bool is_gimple_min_invariant (const_tree);
869 /* Returns true iff T is a GIMPLE restricted interprecodural invariant. */
870 extern bool is_gimple_ip_invariant (const_tree);
871 /* Returns true iff T is a GIMPLE rvalue. */
872 extern bool is_gimple_val (tree);
873 /* Returns true iff T is a GIMPLE asm statement input. */
874 extern bool is_gimple_asm_val (tree);
875 /* Returns true iff T is a valid rhs for a MODIFY_EXPR where the LHS is a
876 GIMPLE temporary, a renamed user variable, or something else,
878 extern bool is_gimple_reg_rhs (tree);
879 extern bool is_gimple_mem_rhs (tree);
881 /* Returns true iff T is a valid if-statement condition. */
882 extern bool is_gimple_condexpr (tree);
884 /* Returns true iff T is a type conversion. */
885 extern bool is_gimple_cast (tree);
886 /* Returns true iff T is a variable that does not need to live in memory. */
887 extern bool is_gimple_non_addressable (tree t);
889 /* Returns true iff T is a valid call address expression. */
890 extern bool is_gimple_call_addr (tree);
891 /* If T makes a function call, returns the CALL_EXPR operand. */
892 extern tree get_call_expr_in (tree t);
894 extern void recalculate_side_effects (tree);
895 extern void count_uses_and_derefs (tree, gimple, unsigned *, unsigned *,
897 extern bool walk_stmt_load_store_addr_ops (gimple, void *,
898 bool (*)(gimple, tree, void *),
899 bool (*)(gimple, tree, void *),
900 bool (*)(gimple, tree, void *));
901 extern bool walk_stmt_load_store_ops (gimple, void *,
902 bool (*)(gimple, tree, void *),
903 bool (*)(gimple, tree, void *));
904 extern bool gimple_ior_addresses_taken (bitmap, gimple);
907 extern tree create_tmp_var_raw (tree, const char *);
908 extern tree create_tmp_var_name (const char *);
909 extern tree create_tmp_var (tree, const char *);
910 extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq *);
911 extern tree get_formal_tmp_var (tree, gimple_seq *);
912 extern void declare_vars (tree, gimple, bool);
913 extern void tree_annotate_all_with_location (tree *, location_t);
914 extern void annotate_all_with_location (gimple_seq, location_t);
916 /* Validation of GIMPLE expressions. Note that these predicates only check
917 the basic form of the expression, they don't recurse to make sure that
918 underlying nodes are also of the right form. */
919 typedef bool (*gimple_predicate)(tree);
922 /* FIXME we should deduce this from the predicate. */
924 fb_none = 0, /* Do not generate a temporary. */
926 fb_rvalue = 1, /* Generate an rvalue to hold the result of a
927 gimplified expression. */
929 fb_lvalue = 2, /* Generate an lvalue to hold the result of a
930 gimplified expression. */
932 fb_mayfail = 4, /* Gimplification may fail. Error issued
934 fb_either= fb_rvalue | fb_lvalue
937 typedef int fallback_t;
939 enum gimplify_status {
940 GS_ERROR = -2, /* Something Bad Seen. */
941 GS_UNHANDLED = -1, /* A langhook result for "I dunno". */
942 GS_OK = 0, /* We did something, maybe more to do. */
943 GS_ALL_DONE = 1 /* The expression is fully gimplified. */
948 struct gimplify_ctx *prev_context;
950 VEC(gimple,heap) *bind_expr_stack;
952 gimple_seq conditional_cleanups;
956 VEC(tree,heap) *case_labels;
957 /* The formal temporary table. Should this be persistent? */
963 bool allow_rhs_cond_expr;
966 extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *,
967 bool (*) (tree), fallback_t);
968 extern void gimplify_type_sizes (tree, gimple_seq *);
969 extern void gimplify_one_sizepos (tree *, gimple_seq *);
970 extern bool gimplify_stmt (tree *, gimple_seq *);
971 extern gimple gimplify_body (tree *, tree, bool);
972 extern void push_gimplify_context (struct gimplify_ctx *);
973 extern void pop_gimplify_context (gimple);
974 extern void gimplify_and_add (tree, gimple_seq *);
976 /* Miscellaneous helpers. */
977 extern void gimple_add_tmp_var (tree);
978 extern gimple gimple_current_bind_expr (void);
979 extern VEC(gimple, heap) *gimple_bind_expr_stack (void);
980 extern tree voidify_wrapper_expr (tree, tree);
981 extern tree build_and_jump (tree *);
982 extern tree alloc_stmt_list (void);
983 extern void free_stmt_list (tree);
984 extern tree force_labels_r (tree *, int *, void *);
985 extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *,
987 struct gimplify_omp_ctx;
988 extern void omp_firstprivatize_variable (struct gimplify_omp_ctx *, tree);
989 extern tree gimple_boolify (tree);
990 extern gimple_predicate rhs_predicate_for (tree);
991 extern tree canonicalize_cond_expr_cond (tree);
994 extern tree omp_reduction_init (tree, tree);
996 /* In tree-nested.c. */
997 extern void lower_nested_functions (tree);
998 extern void insert_field_into_struct (tree, tree);
1000 /* In gimplify.c. */
1001 extern void gimplify_function_tree (tree);
1003 /* In cfgexpand.c. */
1004 extern tree gimple_assign_rhs_to_tree (gimple);
1007 extern bool validate_gimple_arglist (const_gimple, ...);
1010 extern bool tree_ssa_useless_type_conversion (tree);
1011 extern tree tree_ssa_strip_useless_type_conversions (tree);
1012 extern bool useless_type_conversion_p (tree, tree);
1013 extern bool types_compatible_p (tree, tree);
1015 /* Return the code for GIMPLE statement G. */
1017 static inline enum gimple_code
1018 gimple_code (const_gimple g)
1020 return g->gsbase.code;
1024 /* Return true if statement G has sub-statements. This is only true for
1025 High GIMPLE statements. */
1028 gimple_has_substatements (gimple g)
1030 switch (gimple_code (g))
1034 case GIMPLE_EH_FILTER:
1036 case GIMPLE_OMP_FOR:
1037 case GIMPLE_OMP_MASTER:
1038 case GIMPLE_OMP_ORDERED:
1039 case GIMPLE_OMP_SECTION:
1040 case GIMPLE_OMP_PARALLEL:
1041 case GIMPLE_OMP_TASK:
1042 case GIMPLE_OMP_SECTIONS:
1043 case GIMPLE_OMP_SINGLE:
1044 case GIMPLE_OMP_CRITICAL:
1045 case GIMPLE_WITH_CLEANUP_EXPR:
1054 /* Return the basic block holding statement G. */
1056 static inline struct basic_block_def *
1057 gimple_bb (const_gimple g)
1059 return g->gsbase.bb;
1063 /* Return the lexical scope block holding statement G. */
1066 gimple_block (const_gimple g)
1068 return g->gsbase.block;
1072 /* Set BLOCK to be the lexical scope block holding statement G. */
1075 gimple_set_block (gimple g, tree block)
1077 g->gsbase.block = block;
1081 /* Return location information for statement G. */
1083 static inline location_t
1084 gimple_location (const_gimple g)
1086 return g->gsbase.location;
1089 /* Return pointer to location information for statement G. */
1091 static inline const location_t *
1092 gimple_location_ptr (const_gimple g)
1094 return &g->gsbase.location;
1098 /* Set location information for statement G. */
1101 gimple_set_location (gimple g, location_t location)
1103 g->gsbase.location = location;
1107 /* Return true if G contains location information. */
1110 gimple_has_location (const_gimple g)
1112 return gimple_location (g) != UNKNOWN_LOCATION;
1116 /* Return the file name of the location of STMT. */
1118 static inline const char *
1119 gimple_filename (const_gimple stmt)
1121 return LOCATION_FILE (gimple_location (stmt));
1125 /* Return the line number of the location of STMT. */
1128 gimple_lineno (const_gimple stmt)
1130 return LOCATION_LINE (gimple_location (stmt));
1134 /* Determine whether SEQ is a singleton. */
1137 gimple_seq_singleton_p (gimple_seq seq)
1139 return ((gimple_seq_first (seq) != NULL)
1140 && (gimple_seq_first (seq) == gimple_seq_last (seq)));
1143 /* Return true if no warnings should be emitted for statement STMT. */
1146 gimple_no_warning_p (const_gimple stmt)
1148 return stmt->gsbase.no_warning;
1151 /* Set the no_warning flag of STMT to NO_WARNING. */
1154 gimple_set_no_warning (gimple stmt, bool no_warning)
1156 stmt->gsbase.no_warning = (unsigned) no_warning;
1159 /* Set the visited status on statement STMT to VISITED_P. */
1162 gimple_set_visited (gimple stmt, bool visited_p)
1164 stmt->gsbase.visited = (unsigned) visited_p;
1168 /* Return the visited status for statement STMT. */
1171 gimple_visited_p (gimple stmt)
1173 return stmt->gsbase.visited;
1177 /* Set pass local flag PLF on statement STMT to VAL_P. */
1180 gimple_set_plf (gimple stmt, enum plf_mask plf, bool val_p)
1183 stmt->gsbase.plf |= (unsigned int) plf;
1185 stmt->gsbase.plf &= ~((unsigned int) plf);
1189 /* Return the value of pass local flag PLF on statement STMT. */
1191 static inline unsigned int
1192 gimple_plf (gimple stmt, enum plf_mask plf)
1194 return stmt->gsbase.plf & ((unsigned int) plf);
1198 /* Set the UID of statement. */
1201 gimple_set_uid (gimple g, unsigned uid)
1203 g->gsbase.uid = uid;
1207 /* Return the UID of statement. */
1209 static inline unsigned
1210 gimple_uid (const_gimple g)
1212 return g->gsbase.uid;
1216 /* Return true if GIMPLE statement G has register or memory operands. */
1219 gimple_has_ops (const_gimple g)
1221 return gimple_code (g) >= GIMPLE_COND && gimple_code (g) <= GIMPLE_RETURN;
1225 /* Return true if GIMPLE statement G has memory operands. */
1228 gimple_has_mem_ops (const_gimple g)
1230 return gimple_code (g) >= GIMPLE_ASSIGN && gimple_code (g) <= GIMPLE_RETURN;
1234 /* Return the set of DEF operands for statement G. */
1236 static inline struct def_optype_d *
1237 gimple_def_ops (const_gimple g)
1239 if (!gimple_has_ops (g))
1241 return g->gsops.opbase.def_ops;
1245 /* Set DEF to be the set of DEF operands for statement G. */
1248 gimple_set_def_ops (gimple g, struct def_optype_d *def)
1250 gcc_assert (gimple_has_ops (g));
1251 g->gsops.opbase.def_ops = def;
1255 /* Return the set of USE operands for statement G. */
1257 static inline struct use_optype_d *
1258 gimple_use_ops (const_gimple g)
1260 if (!gimple_has_ops (g))
1262 return g->gsops.opbase.use_ops;
1266 /* Set USE to be the set of USE operands for statement G. */
1269 gimple_set_use_ops (gimple g, struct use_optype_d *use)
1271 gcc_assert (gimple_has_ops (g));
1272 g->gsops.opbase.use_ops = use;
1276 /* Return the set of VUSE operand for statement G. */
1278 static inline use_operand_p
1279 gimple_vuse_op (const_gimple g)
1281 struct use_optype_d *ops;
1282 if (!gimple_has_mem_ops (g))
1283 return NULL_USE_OPERAND_P;
1284 ops = g->gsops.opbase.use_ops;
1286 && USE_OP_PTR (ops)->use == &g->gsmem.membase.vuse)
1287 return USE_OP_PTR (ops);
1288 return NULL_USE_OPERAND_P;
1291 /* Return the set of VDEF operand for statement G. */
1293 static inline def_operand_p
1294 gimple_vdef_op (const_gimple g)
1296 struct def_optype_d *ops;
1297 if (!gimple_has_mem_ops (g))
1298 return NULL_DEF_OPERAND_P;
1299 ops = g->gsops.opbase.def_ops;
1301 && DEF_OP_PTR (ops) == &g->gsmem.membase.vdef)
1302 return DEF_OP_PTR (ops);
1303 return NULL_DEF_OPERAND_P;
1307 /* Return the single VUSE operand of the statement G. */
1310 gimple_vuse (const_gimple g)
1312 if (!gimple_has_mem_ops (g))
1314 return g->gsmem.membase.vuse;
1317 /* Return the single VDEF operand of the statement G. */
1320 gimple_vdef (const_gimple g)
1322 if (!gimple_has_mem_ops (g))
1324 return g->gsmem.membase.vdef;
1327 /* Return the single VUSE operand of the statement G. */
1329 static inline tree *
1330 gimple_vuse_ptr (gimple g)
1332 if (!gimple_has_mem_ops (g))
1334 return &g->gsmem.membase.vuse;
1337 /* Return the single VDEF operand of the statement G. */
1339 static inline tree *
1340 gimple_vdef_ptr (gimple g)
1342 if (!gimple_has_mem_ops (g))
1344 return &g->gsmem.membase.vdef;
1347 /* Set the single VUSE operand of the statement G. */
1350 gimple_set_vuse (gimple g, tree vuse)
1352 gcc_assert (gimple_has_mem_ops (g));
1353 g->gsmem.membase.vuse = vuse;
1356 /* Set the single VDEF operand of the statement G. */
1359 gimple_set_vdef (gimple g, tree vdef)
1361 gcc_assert (gimple_has_mem_ops (g));
1362 g->gsmem.membase.vdef = vdef;
1366 /* Return true if statement G has operands and the modified field has
1370 gimple_modified_p (const_gimple g)
1372 return (gimple_has_ops (g)) ? (bool) g->gsbase.modified : false;
1376 /* Return the tree code for the expression computed by STMT. This is
1377 only valid for GIMPLE_COND, GIMPLE_CALL and GIMPLE_ASSIGN. For
1378 GIMPLE_CALL, return CALL_EXPR as the expression code for
1379 consistency. This is useful when the caller needs to deal with the
1380 three kinds of computation that GIMPLE supports. */
1382 static inline enum tree_code
1383 gimple_expr_code (const_gimple stmt)
1385 enum gimple_code code = gimple_code (stmt);
1386 if (code == GIMPLE_ASSIGN || code == GIMPLE_COND)
1387 return (enum tree_code) stmt->gsbase.subcode;
1388 else if (code == GIMPLE_CALL)
1395 /* Mark statement S as modified, and update it. */
1398 update_stmt (gimple s)
1400 if (gimple_has_ops (s))
1402 gimple_set_modified (s, true);
1403 update_stmt_operands (s);
1407 /* Update statement S if it has been optimized. */
1410 update_stmt_if_modified (gimple s)
1412 if (gimple_modified_p (s))
1413 update_stmt_operands (s);
1416 /* Return true if statement STMT contains volatile operands. */
1419 gimple_has_volatile_ops (const_gimple stmt)
1421 if (gimple_has_mem_ops (stmt))
1422 return stmt->gsbase.has_volatile_ops;
1428 /* Set the HAS_VOLATILE_OPS flag to VOLATILEP. */
1431 gimple_set_has_volatile_ops (gimple stmt, bool volatilep)
1433 if (gimple_has_mem_ops (stmt))
1434 stmt->gsbase.has_volatile_ops = (unsigned) volatilep;
1438 /* Return true if statement STMT may access memory. */
1441 gimple_references_memory_p (gimple stmt)
1443 return gimple_has_mem_ops (stmt) && gimple_vuse (stmt);
1447 /* Return the subcode for OMP statement S. */
1449 static inline unsigned
1450 gimple_omp_subcode (const_gimple s)
1452 gcc_assert (gimple_code (s) >= GIMPLE_OMP_ATOMIC_LOAD
1453 && gimple_code (s) <= GIMPLE_OMP_SINGLE);
1454 return s->gsbase.subcode;
1457 /* Set the subcode for OMP statement S to SUBCODE. */
1460 gimple_omp_set_subcode (gimple s, unsigned int subcode)
1462 /* We only have 16 bits for the subcode. Assert that we are not
1464 gcc_assert (subcode < (1 << 16));
1465 s->gsbase.subcode = subcode;
1468 /* Set the nowait flag on OMP_RETURN statement S. */
1471 gimple_omp_return_set_nowait (gimple s)
1473 GIMPLE_CHECK (s, GIMPLE_OMP_RETURN);
1474 s->gsbase.subcode |= GF_OMP_RETURN_NOWAIT;
1478 /* Return true if OMP return statement G has the GF_OMP_RETURN_NOWAIT
1482 gimple_omp_return_nowait_p (const_gimple g)
1484 GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
1485 return (gimple_omp_subcode (g) & GF_OMP_RETURN_NOWAIT) != 0;
1489 /* Return true if OMP section statement G has the GF_OMP_SECTION_LAST
1493 gimple_omp_section_last_p (const_gimple g)
1495 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1496 return (gimple_omp_subcode (g) & GF_OMP_SECTION_LAST) != 0;
1500 /* Set the GF_OMP_SECTION_LAST flag on G. */
1503 gimple_omp_section_set_last (gimple g)
1505 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1506 g->gsbase.subcode |= GF_OMP_SECTION_LAST;
1510 /* Return true if OMP parallel statement G has the
1511 GF_OMP_PARALLEL_COMBINED flag set. */
1514 gimple_omp_parallel_combined_p (const_gimple g)
1516 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1517 return (gimple_omp_subcode (g) & GF_OMP_PARALLEL_COMBINED) != 0;
1521 /* Set the GF_OMP_PARALLEL_COMBINED field in G depending on the boolean
1522 value of COMBINED_P. */
1525 gimple_omp_parallel_set_combined_p (gimple g, bool combined_p)
1527 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1529 g->gsbase.subcode |= GF_OMP_PARALLEL_COMBINED;
1531 g->gsbase.subcode &= ~GF_OMP_PARALLEL_COMBINED;
1535 /* Return the number of operands for statement GS. */
1537 static inline unsigned
1538 gimple_num_ops (const_gimple gs)
1540 return gs->gsbase.num_ops;
1544 /* Set the number of operands for statement GS. */
1547 gimple_set_num_ops (gimple gs, unsigned num_ops)
1549 gs->gsbase.num_ops = num_ops;
1553 /* Return the array of operands for statement GS. */
1555 static inline tree *
1556 gimple_ops (gimple gs)
1558 /* Offset in bytes to the location of the operand vector in every
1559 tuple structure. Defined in gimple.c */
1560 extern size_t const gimple_ops_offset_[];
1562 if (!gimple_has_ops (gs))
1565 /* All the tuples have their operand vector at the very bottom
1566 of the structure. */
1567 return ((tree *) ((char *) gs + gimple_ops_offset_[gimple_code (gs)]));
1571 /* Return operand I for statement GS. */
1574 gimple_op (const_gimple gs, unsigned i)
1576 if (gimple_has_ops (gs))
1578 gcc_assert (i < gimple_num_ops (gs));
1579 return gimple_ops (CONST_CAST_GIMPLE (gs))[i];
1585 /* Return a pointer to operand I for statement GS. */
1587 static inline tree *
1588 gimple_op_ptr (const_gimple gs, unsigned i)
1590 if (gimple_has_ops (gs))
1592 gcc_assert (i < gimple_num_ops (gs));
1593 return gimple_ops (CONST_CAST_GIMPLE (gs)) + i;
1599 /* Set operand I of statement GS to OP. */
1602 gimple_set_op (gimple gs, unsigned i, tree op)
1604 gcc_assert (gimple_has_ops (gs) && i < gimple_num_ops (gs));
1606 /* Note. It may be tempting to assert that OP matches
1607 is_gimple_operand, but that would be wrong. Different tuples
1608 accept slightly different sets of tree operands. Each caller
1609 should perform its own validation. */
1610 gimple_ops (gs)[i] = op;
1613 /* Return true if GS is a GIMPLE_ASSIGN. */
1616 is_gimple_assign (const_gimple gs)
1618 return gimple_code (gs) == GIMPLE_ASSIGN;
1621 /* Determine if expression CODE is one of the valid expressions that can
1622 be used on the RHS of GIMPLE assignments. */
1624 static inline enum gimple_rhs_class
1625 get_gimple_rhs_class (enum tree_code code)
1627 return (enum gimple_rhs_class) gimple_rhs_class_table[(int) code];
1630 /* Return the LHS of assignment statement GS. */
1633 gimple_assign_lhs (const_gimple gs)
1635 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1636 return gimple_op (gs, 0);
1640 /* Return a pointer to the LHS of assignment statement GS. */
1642 static inline tree *
1643 gimple_assign_lhs_ptr (const_gimple gs)
1645 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1646 return gimple_op_ptr (gs, 0);
1650 /* Set LHS to be the LHS operand of assignment statement GS. */
1653 gimple_assign_set_lhs (gimple gs, tree lhs)
1655 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1656 gcc_assert (is_gimple_operand (lhs));
1657 gimple_set_op (gs, 0, lhs);
1659 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1660 SSA_NAME_DEF_STMT (lhs) = gs;
1664 /* Return the first operand on the RHS of assignment statement GS. */
1667 gimple_assign_rhs1 (const_gimple gs)
1669 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1670 return gimple_op (gs, 1);
1674 /* Return a pointer to the first operand on the RHS of assignment
1677 static inline tree *
1678 gimple_assign_rhs1_ptr (const_gimple gs)
1680 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1681 return gimple_op_ptr (gs, 1);
1684 /* Set RHS to be the first operand on the RHS of assignment statement GS. */
1687 gimple_assign_set_rhs1 (gimple gs, tree rhs)
1689 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1691 /* If there are 3 or more operands, the 2 operands on the RHS must be
1693 if (gimple_num_ops (gs) >= 3)
1694 gcc_assert (is_gimple_val (rhs));
1696 gcc_assert (is_gimple_operand (rhs));
1698 gimple_set_op (gs, 1, rhs);
1702 /* Return the second operand on the RHS of assignment statement GS.
1703 If GS does not have two operands, NULL is returned instead. */
1706 gimple_assign_rhs2 (const_gimple gs)
1708 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1710 if (gimple_num_ops (gs) >= 3)
1711 return gimple_op (gs, 2);
1717 /* Return a pointer to the second operand on the RHS of assignment
1720 static inline tree *
1721 gimple_assign_rhs2_ptr (const_gimple gs)
1723 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1724 return gimple_op_ptr (gs, 2);
1728 /* Set RHS to be the second operand on the RHS of assignment statement GS. */
1731 gimple_assign_set_rhs2 (gimple gs, tree rhs)
1733 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1735 /* The 2 operands on the RHS must be GIMPLE values. */
1736 gcc_assert (is_gimple_val (rhs));
1738 gimple_set_op (gs, 2, rhs);
1741 /* Returns true if GS is a nontemporal move. */
1744 gimple_assign_nontemporal_move_p (const_gimple gs)
1746 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1747 return gs->gsbase.nontemporal_move;
1750 /* Sets nontemporal move flag of GS to NONTEMPORAL. */
1753 gimple_assign_set_nontemporal_move (gimple gs, bool nontemporal)
1755 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1756 gs->gsbase.nontemporal_move = nontemporal;
1760 /* Return the code of the expression computed on the rhs of assignment
1761 statement GS. In case that the RHS is a single object, returns the
1762 tree code of the object. */
1764 static inline enum tree_code
1765 gimple_assign_rhs_code (const_gimple gs)
1767 enum tree_code code;
1768 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1770 code = gimple_expr_code (gs);
1771 if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS)
1772 code = TREE_CODE (gimple_assign_rhs1 (gs));
1778 /* Set CODE to be the code for the expression computed on the RHS of
1782 gimple_assign_set_rhs_code (gimple s, enum tree_code code)
1784 GIMPLE_CHECK (s, GIMPLE_ASSIGN);
1785 s->gsbase.subcode = code;
1789 /* Return the gimple rhs class of the code of the expression computed on
1790 the rhs of assignment statement GS.
1791 This will never return GIMPLE_INVALID_RHS. */
1793 static inline enum gimple_rhs_class
1794 gimple_assign_rhs_class (const_gimple gs)
1796 return get_gimple_rhs_class (gimple_assign_rhs_code (gs));
1800 /* Return true if S is a type-cast assignment. */
1803 gimple_assign_cast_p (gimple s)
1805 if (is_gimple_assign (s))
1807 enum tree_code sc = gimple_assign_rhs_code (s);
1808 return CONVERT_EXPR_CODE_P (sc)
1809 || sc == VIEW_CONVERT_EXPR
1810 || sc == FIX_TRUNC_EXPR;
1817 /* Return true if GS is a GIMPLE_CALL. */
1820 is_gimple_call (const_gimple gs)
1822 return gimple_code (gs) == GIMPLE_CALL;
1825 /* Return the LHS of call statement GS. */
1828 gimple_call_lhs (const_gimple gs)
1830 GIMPLE_CHECK (gs, GIMPLE_CALL);
1831 return gimple_op (gs, 0);
1835 /* Return a pointer to the LHS of call statement GS. */
1837 static inline tree *
1838 gimple_call_lhs_ptr (const_gimple gs)
1840 GIMPLE_CHECK (gs, GIMPLE_CALL);
1841 return gimple_op_ptr (gs, 0);
1845 /* Set LHS to be the LHS operand of call statement GS. */
1848 gimple_call_set_lhs (gimple gs, tree lhs)
1850 GIMPLE_CHECK (gs, GIMPLE_CALL);
1851 gcc_assert (!lhs || is_gimple_operand (lhs));
1852 gimple_set_op (gs, 0, lhs);
1853 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1854 SSA_NAME_DEF_STMT (lhs) = gs;
1858 /* Return the tree node representing the function called by call
1862 gimple_call_fn (const_gimple gs)
1864 GIMPLE_CHECK (gs, GIMPLE_CALL);
1865 return gimple_op (gs, 1);
1869 /* Return a pointer to the tree node representing the function called by call
1872 static inline tree *
1873 gimple_call_fn_ptr (const_gimple gs)
1875 GIMPLE_CHECK (gs, GIMPLE_CALL);
1876 return gimple_op_ptr (gs, 1);
1880 /* Set FN to be the function called by call statement GS. */
1883 gimple_call_set_fn (gimple gs, tree fn)
1885 GIMPLE_CHECK (gs, GIMPLE_CALL);
1886 gcc_assert (is_gimple_operand (fn));
1887 gimple_set_op (gs, 1, fn);
1891 /* Set FNDECL to be the function called by call statement GS. */
1894 gimple_call_set_fndecl (gimple gs, tree decl)
1896 GIMPLE_CHECK (gs, GIMPLE_CALL);
1897 gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
1898 gimple_set_op (gs, 1, build_fold_addr_expr_loc (gimple_location (gs), decl));
1902 /* If a given GIMPLE_CALL's callee is a FUNCTION_DECL, return it.
1903 Otherwise return NULL. This function is analogous to
1904 get_callee_fndecl in tree land. */
1907 gimple_call_fndecl (const_gimple gs)
1909 tree addr = gimple_call_fn (gs);
1910 if (TREE_CODE (addr) == ADDR_EXPR)
1912 gcc_assert (TREE_CODE (TREE_OPERAND (addr, 0)) == FUNCTION_DECL);
1913 return TREE_OPERAND (addr, 0);
1919 /* Return the type returned by call statement GS. */
1922 gimple_call_return_type (const_gimple gs)
1924 tree fn = gimple_call_fn (gs);
1925 tree type = TREE_TYPE (fn);
1927 /* See through the pointer. */
1928 gcc_assert (POINTER_TYPE_P (type));
1929 type = TREE_TYPE (type);
1931 gcc_assert (TREE_CODE (type) == FUNCTION_TYPE
1932 || TREE_CODE (type) == METHOD_TYPE);
1934 /* The type returned by a FUNCTION_DECL is the type of its
1936 return TREE_TYPE (type);
1940 /* Return the static chain for call statement GS. */
1943 gimple_call_chain (const_gimple gs)
1945 GIMPLE_CHECK (gs, GIMPLE_CALL);
1946 return gimple_op (gs, 2);
1950 /* Return a pointer to the static chain for call statement GS. */
1952 static inline tree *
1953 gimple_call_chain_ptr (const_gimple gs)
1955 GIMPLE_CHECK (gs, GIMPLE_CALL);
1956 return gimple_op_ptr (gs, 2);
1959 /* Set CHAIN to be the static chain for call statement GS. */
1962 gimple_call_set_chain (gimple gs, tree chain)
1964 GIMPLE_CHECK (gs, GIMPLE_CALL);
1965 gcc_assert (chain == NULL
1966 || TREE_CODE (chain) == ADDR_EXPR
1967 || SSA_VAR_P (chain));
1968 gimple_set_op (gs, 2, chain);
1972 /* Return the number of arguments used by call statement GS. */
1974 static inline unsigned
1975 gimple_call_num_args (const_gimple gs)
1978 GIMPLE_CHECK (gs, GIMPLE_CALL);
1979 num_ops = gimple_num_ops (gs);
1980 gcc_assert (num_ops >= 3);
1985 /* Return the argument at position INDEX for call statement GS. */
1988 gimple_call_arg (const_gimple gs, unsigned index)
1990 GIMPLE_CHECK (gs, GIMPLE_CALL);
1991 return gimple_op (gs, index + 3);
1995 /* Return a pointer to the argument at position INDEX for call
1998 static inline tree *
1999 gimple_call_arg_ptr (const_gimple gs, unsigned index)
2001 GIMPLE_CHECK (gs, GIMPLE_CALL);
2002 return gimple_op_ptr (gs, index + 3);
2006 /* Set ARG to be the argument at position INDEX for call statement GS. */
2009 gimple_call_set_arg (gimple gs, unsigned index, tree arg)
2011 GIMPLE_CHECK (gs, GIMPLE_CALL);
2012 gcc_assert (is_gimple_operand (arg));
2013 gimple_set_op (gs, index + 3, arg);
2017 /* If TAIL_P is true, mark call statement S as being a tail call
2018 (i.e., a call just before the exit of a function). These calls are
2019 candidate for tail call optimization. */
2022 gimple_call_set_tail (gimple s, bool tail_p)
2024 GIMPLE_CHECK (s, GIMPLE_CALL);
2026 s->gsbase.subcode |= GF_CALL_TAILCALL;
2028 s->gsbase.subcode &= ~GF_CALL_TAILCALL;
2032 /* Return true if GIMPLE_CALL S is marked as a tail call. */
2035 gimple_call_tail_p (gimple s)
2037 GIMPLE_CHECK (s, GIMPLE_CALL);
2038 return (s->gsbase.subcode & GF_CALL_TAILCALL) != 0;
2042 /* Set the inlinable status of GIMPLE_CALL S to INLINABLE_P. */
2045 gimple_call_set_cannot_inline (gimple s, bool inlinable_p)
2047 GIMPLE_CHECK (s, GIMPLE_CALL);
2049 s->gsbase.subcode |= GF_CALL_CANNOT_INLINE;
2051 s->gsbase.subcode &= ~GF_CALL_CANNOT_INLINE;
2055 /* Return true if GIMPLE_CALL S cannot be inlined. */
2058 gimple_call_cannot_inline_p (gimple s)
2060 GIMPLE_CHECK (s, GIMPLE_CALL);
2061 return (s->gsbase.subcode & GF_CALL_CANNOT_INLINE) != 0;
2065 /* If RETURN_SLOT_OPT_P is true mark GIMPLE_CALL S as valid for return
2066 slot optimization. This transformation uses the target of the call
2067 expansion as the return slot for calls that return in memory. */
2070 gimple_call_set_return_slot_opt (gimple s, bool return_slot_opt_p)
2072 GIMPLE_CHECK (s, GIMPLE_CALL);
2073 if (return_slot_opt_p)
2074 s->gsbase.subcode |= GF_CALL_RETURN_SLOT_OPT;
2076 s->gsbase.subcode &= ~GF_CALL_RETURN_SLOT_OPT;
2080 /* Return true if S is marked for return slot optimization. */
2083 gimple_call_return_slot_opt_p (gimple s)
2085 GIMPLE_CHECK (s, GIMPLE_CALL);
2086 return (s->gsbase.subcode & GF_CALL_RETURN_SLOT_OPT) != 0;
2090 /* If FROM_THUNK_P is true, mark GIMPLE_CALL S as being the jump from a
2091 thunk to the thunked-to function. */
2094 gimple_call_set_from_thunk (gimple s, bool from_thunk_p)
2096 GIMPLE_CHECK (s, GIMPLE_CALL);
2098 s->gsbase.subcode |= GF_CALL_FROM_THUNK;
2100 s->gsbase.subcode &= ~GF_CALL_FROM_THUNK;
2104 /* Return true if GIMPLE_CALL S is a jump from a thunk. */
2107 gimple_call_from_thunk_p (gimple s)
2109 GIMPLE_CHECK (s, GIMPLE_CALL);
2110 return (s->gsbase.subcode & GF_CALL_FROM_THUNK) != 0;
2114 /* If PASS_ARG_PACK_P is true, GIMPLE_CALL S is a stdarg call that needs the
2115 argument pack in its argument list. */
2118 gimple_call_set_va_arg_pack (gimple s, bool pass_arg_pack_p)
2120 GIMPLE_CHECK (s, GIMPLE_CALL);
2121 if (pass_arg_pack_p)
2122 s->gsbase.subcode |= GF_CALL_VA_ARG_PACK;
2124 s->gsbase.subcode &= ~GF_CALL_VA_ARG_PACK;
2128 /* Return true if GIMPLE_CALL S is a stdarg call that needs the
2129 argument pack in its argument list. */
2132 gimple_call_va_arg_pack_p (gimple s)
2134 GIMPLE_CHECK (s, GIMPLE_CALL);
2135 return (s->gsbase.subcode & GF_CALL_VA_ARG_PACK) != 0;
2139 /* Return true if S is a noreturn call. */
2142 gimple_call_noreturn_p (gimple s)
2144 GIMPLE_CHECK (s, GIMPLE_CALL);
2145 return (gimple_call_flags (s) & ECF_NORETURN) != 0;
2149 /* Return true if S is a nothrow call. */
2152 gimple_call_nothrow_p (gimple s)
2154 GIMPLE_CHECK (s, GIMPLE_CALL);
2155 return (gimple_call_flags (s) & ECF_NOTHROW) != 0;
2159 /* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL. */
2162 gimple_call_copy_flags (gimple dest_call, gimple orig_call)
2164 GIMPLE_CHECK (dest_call, GIMPLE_CALL);
2165 GIMPLE_CHECK (orig_call, GIMPLE_CALL);
2166 dest_call->gsbase.subcode = orig_call->gsbase.subcode;
2170 /* Returns true if this is a GIMPLE_ASSIGN or a GIMPLE_CALL with a
2174 gimple_has_lhs (gimple stmt)
2176 return (is_gimple_assign (stmt)
2177 || (is_gimple_call (stmt)
2178 && gimple_call_lhs (stmt) != NULL_TREE));
2182 /* Return the code of the predicate computed by conditional statement GS. */
2184 static inline enum tree_code
2185 gimple_cond_code (const_gimple gs)
2187 GIMPLE_CHECK (gs, GIMPLE_COND);
2188 return (enum tree_code) gs->gsbase.subcode;
2192 /* Set CODE to be the predicate code for the conditional statement GS. */
2195 gimple_cond_set_code (gimple gs, enum tree_code code)
2197 GIMPLE_CHECK (gs, GIMPLE_COND);
2198 gcc_assert (TREE_CODE_CLASS (code) == tcc_comparison);
2199 gs->gsbase.subcode = code;
2203 /* Return the LHS of the predicate computed by conditional statement GS. */
2206 gimple_cond_lhs (const_gimple gs)
2208 GIMPLE_CHECK (gs, GIMPLE_COND);
2209 return gimple_op (gs, 0);
2212 /* Return the pointer to the LHS of the predicate computed by conditional
2215 static inline tree *
2216 gimple_cond_lhs_ptr (const_gimple gs)
2218 GIMPLE_CHECK (gs, GIMPLE_COND);
2219 return gimple_op_ptr (gs, 0);
2222 /* Set LHS to be the LHS operand of the predicate computed by
2223 conditional statement GS. */
2226 gimple_cond_set_lhs (gimple gs, tree lhs)
2228 GIMPLE_CHECK (gs, GIMPLE_COND);
2229 gcc_assert (is_gimple_operand (lhs));
2230 gimple_set_op (gs, 0, lhs);
2234 /* Return the RHS operand of the predicate computed by conditional GS. */
2237 gimple_cond_rhs (const_gimple gs)
2239 GIMPLE_CHECK (gs, GIMPLE_COND);
2240 return gimple_op (gs, 1);
2243 /* Return the pointer to the RHS operand of the predicate computed by
2246 static inline tree *
2247 gimple_cond_rhs_ptr (const_gimple gs)
2249 GIMPLE_CHECK (gs, GIMPLE_COND);
2250 return gimple_op_ptr (gs, 1);
2254 /* Set RHS to be the RHS operand of the predicate computed by
2255 conditional statement GS. */
2258 gimple_cond_set_rhs (gimple gs, tree rhs)
2260 GIMPLE_CHECK (gs, GIMPLE_COND);
2261 gcc_assert (is_gimple_operand (rhs));
2262 gimple_set_op (gs, 1, rhs);
2266 /* Return the label used by conditional statement GS when its
2267 predicate evaluates to true. */
2270 gimple_cond_true_label (const_gimple gs)
2272 GIMPLE_CHECK (gs, GIMPLE_COND);
2273 return gimple_op (gs, 2);
2277 /* Set LABEL to be the label used by conditional statement GS when its
2278 predicate evaluates to true. */
2281 gimple_cond_set_true_label (gimple gs, tree label)
2283 GIMPLE_CHECK (gs, GIMPLE_COND);
2284 gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
2285 gimple_set_op (gs, 2, label);
2289 /* Set LABEL to be the label used by conditional statement GS when its
2290 predicate evaluates to false. */
2293 gimple_cond_set_false_label (gimple gs, tree label)
2295 GIMPLE_CHECK (gs, GIMPLE_COND);
2296 gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
2297 gimple_set_op (gs, 3, label);
2301 /* Return the label used by conditional statement GS when its
2302 predicate evaluates to false. */
2305 gimple_cond_false_label (const_gimple gs)
2307 GIMPLE_CHECK (gs, GIMPLE_COND);
2308 return gimple_op (gs, 3);
2312 /* Set the conditional COND_STMT to be of the form 'if (1 == 0)'. */
2315 gimple_cond_make_false (gimple gs)
2317 gimple_cond_set_lhs (gs, boolean_true_node);
2318 gimple_cond_set_rhs (gs, boolean_false_node);
2319 gs->gsbase.subcode = EQ_EXPR;
2323 /* Set the conditional COND_STMT to be of the form 'if (1 == 1)'. */
2326 gimple_cond_make_true (gimple gs)
2328 gimple_cond_set_lhs (gs, boolean_true_node);
2329 gimple_cond_set_rhs (gs, boolean_true_node);
2330 gs->gsbase.subcode = EQ_EXPR;
2333 /* Check if conditional statemente GS is of the form 'if (1 == 1)',
2334 'if (0 == 0)', 'if (1 != 0)' or 'if (0 != 1)' */
2337 gimple_cond_true_p (const_gimple gs)
2339 tree lhs = gimple_cond_lhs (gs);
2340 tree rhs = gimple_cond_rhs (gs);
2341 enum tree_code code = gimple_cond_code (gs);
2343 if (lhs != boolean_true_node && lhs != boolean_false_node)
2346 if (rhs != boolean_true_node && rhs != boolean_false_node)
2349 if (code == NE_EXPR && lhs != rhs)
2352 if (code == EQ_EXPR && lhs == rhs)
2358 /* Check if conditional statement GS is of the form 'if (1 != 1)',
2359 'if (0 != 0)', 'if (1 == 0)' or 'if (0 == 1)' */
2362 gimple_cond_false_p (const_gimple gs)
2364 tree lhs = gimple_cond_lhs (gs);
2365 tree rhs = gimple_cond_rhs (gs);
2366 enum tree_code code = gimple_cond_code (gs);
2368 if (lhs != boolean_true_node && lhs != boolean_false_node)
2371 if (rhs != boolean_true_node && rhs != boolean_false_node)
2374 if (code == NE_EXPR && lhs == rhs)
2377 if (code == EQ_EXPR && lhs != rhs)
2383 /* Check if conditional statement GS is of the form 'if (var != 0)' or
2387 gimple_cond_single_var_p (gimple gs)
2389 if (gimple_cond_code (gs) == NE_EXPR
2390 && gimple_cond_rhs (gs) == boolean_false_node)
2393 if (gimple_cond_code (gs) == EQ_EXPR
2394 && gimple_cond_rhs (gs) == boolean_true_node)
2400 /* Set the code, LHS and RHS of GIMPLE_COND STMT from CODE, LHS and RHS. */
2403 gimple_cond_set_condition (gimple stmt, enum tree_code code, tree lhs, tree rhs)
2405 gimple_cond_set_code (stmt, code);
2406 gimple_cond_set_lhs (stmt, lhs);
2407 gimple_cond_set_rhs (stmt, rhs);
2410 /* Return the LABEL_DECL node used by GIMPLE_LABEL statement GS. */
2413 gimple_label_label (const_gimple gs)
2415 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2416 return gimple_op (gs, 0);
2420 /* Set LABEL to be the LABEL_DECL node used by GIMPLE_LABEL statement
2424 gimple_label_set_label (gimple gs, tree label)
2426 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2427 gcc_assert (TREE_CODE (label) == LABEL_DECL);
2428 gimple_set_op (gs, 0, label);
2432 /* Return the destination of the unconditional jump GS. */
2435 gimple_goto_dest (const_gimple gs)
2437 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2438 return gimple_op (gs, 0);
2442 /* Set DEST to be the destination of the unconditonal jump GS. */
2445 gimple_goto_set_dest (gimple gs, tree dest)
2447 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2448 gcc_assert (is_gimple_operand (dest));
2449 gimple_set_op (gs, 0, dest);
2453 /* Return the variables declared in the GIMPLE_BIND statement GS. */
2456 gimple_bind_vars (const_gimple gs)
2458 GIMPLE_CHECK (gs, GIMPLE_BIND);
2459 return gs->gimple_bind.vars;
2463 /* Set VARS to be the set of variables declared in the GIMPLE_BIND
2467 gimple_bind_set_vars (gimple gs, tree vars)
2469 GIMPLE_CHECK (gs, GIMPLE_BIND);
2470 gs->gimple_bind.vars = vars;
2474 /* Append VARS to the set of variables declared in the GIMPLE_BIND
2478 gimple_bind_append_vars (gimple gs, tree vars)
2480 GIMPLE_CHECK (gs, GIMPLE_BIND);
2481 gs->gimple_bind.vars = chainon (gs->gimple_bind.vars, vars);
2485 /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS. */
2487 static inline gimple_seq
2488 gimple_bind_body (gimple gs)
2490 GIMPLE_CHECK (gs, GIMPLE_BIND);
2491 return gs->gimple_bind.body;
2495 /* Set SEQ to be the GIMPLE sequence contained in the GIMPLE_BIND
2499 gimple_bind_set_body (gimple gs, gimple_seq seq)
2501 GIMPLE_CHECK (gs, GIMPLE_BIND);
2502 gs->gimple_bind.body = seq;
2506 /* Append a statement to the end of a GIMPLE_BIND's body. */
2509 gimple_bind_add_stmt (gimple gs, gimple stmt)
2511 GIMPLE_CHECK (gs, GIMPLE_BIND);
2512 gimple_seq_add_stmt (&gs->gimple_bind.body, stmt);
2516 /* Append a sequence of statements to the end of a GIMPLE_BIND's body. */
2519 gimple_bind_add_seq (gimple gs, gimple_seq seq)
2521 GIMPLE_CHECK (gs, GIMPLE_BIND);
2522 gimple_seq_add_seq (&gs->gimple_bind.body, seq);
2526 /* Return the TREE_BLOCK node associated with GIMPLE_BIND statement
2527 GS. This is analogous to the BIND_EXPR_BLOCK field in trees. */
2530 gimple_bind_block (const_gimple gs)
2532 GIMPLE_CHECK (gs, GIMPLE_BIND);
2533 return gs->gimple_bind.block;
2537 /* Set BLOCK to be the TREE_BLOCK node associated with GIMPLE_BIND
2541 gimple_bind_set_block (gimple gs, tree block)
2543 GIMPLE_CHECK (gs, GIMPLE_BIND);
2544 gcc_assert (block == NULL_TREE || TREE_CODE (block) == BLOCK);
2545 gs->gimple_bind.block = block;
2549 /* Return the number of input operands for GIMPLE_ASM GS. */
2551 static inline unsigned
2552 gimple_asm_ninputs (const_gimple gs)
2554 GIMPLE_CHECK (gs, GIMPLE_ASM);
2555 return gs->gimple_asm.ni;
2559 /* Return the number of output operands for GIMPLE_ASM GS. */
2561 static inline unsigned
2562 gimple_asm_noutputs (const_gimple gs)
2564 GIMPLE_CHECK (gs, GIMPLE_ASM);
2565 return gs->gimple_asm.no;
2569 /* Return the number of clobber operands for GIMPLE_ASM GS. */
2571 static inline unsigned
2572 gimple_asm_nclobbers (const_gimple gs)
2574 GIMPLE_CHECK (gs, GIMPLE_ASM);
2575 return gs->gimple_asm.nc;
2579 /* Return input operand INDEX of GIMPLE_ASM GS. */
2582 gimple_asm_input_op (const_gimple gs, unsigned index)
2584 GIMPLE_CHECK (gs, GIMPLE_ASM);
2585 gcc_assert (index <= gs->gimple_asm.ni);
2586 return gimple_op (gs, index);
2589 /* Return a pointer to input operand INDEX of GIMPLE_ASM GS. */
2591 static inline tree *
2592 gimple_asm_input_op_ptr (const_gimple gs, unsigned index)
2594 GIMPLE_CHECK (gs, GIMPLE_ASM);
2595 gcc_assert (index <= gs->gimple_asm.ni);
2596 return gimple_op_ptr (gs, index);
2600 /* Set IN_OP to be input operand INDEX in GIMPLE_ASM GS. */
2603 gimple_asm_set_input_op (gimple gs, unsigned index, tree in_op)
2605 GIMPLE_CHECK (gs, GIMPLE_ASM);
2606 gcc_assert (index <= gs->gimple_asm.ni);
2607 gcc_assert (TREE_CODE (in_op) == TREE_LIST);
2608 gimple_set_op (gs, index, in_op);
2612 /* Return output operand INDEX of GIMPLE_ASM GS. */
2615 gimple_asm_output_op (const_gimple gs, unsigned index)
2617 GIMPLE_CHECK (gs, GIMPLE_ASM);
2618 gcc_assert (index <= gs->gimple_asm.no);
2619 return gimple_op (gs, index + gs->gimple_asm.ni);
2622 /* Return a pointer to output operand INDEX of GIMPLE_ASM GS. */
2624 static inline tree *
2625 gimple_asm_output_op_ptr (const_gimple gs, unsigned index)
2627 GIMPLE_CHECK (gs, GIMPLE_ASM);
2628 gcc_assert (index <= gs->gimple_asm.no);
2629 return gimple_op_ptr (gs, index + gs->gimple_asm.ni);
2633 /* Set OUT_OP to be output operand INDEX in GIMPLE_ASM GS. */
2636 gimple_asm_set_output_op (gimple gs, unsigned index, tree out_op)
2638 GIMPLE_CHECK (gs, GIMPLE_ASM);
2639 gcc_assert (index <= gs->gimple_asm.no);
2640 gcc_assert (TREE_CODE (out_op) == TREE_LIST);
2641 gimple_set_op (gs, index + gs->gimple_asm.ni, out_op);
2645 /* Return clobber operand INDEX of GIMPLE_ASM GS. */
2648 gimple_asm_clobber_op (const_gimple gs, unsigned index)
2650 GIMPLE_CHECK (gs, GIMPLE_ASM);
2651 gcc_assert (index <= gs->gimple_asm.nc);
2652 return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no);
2656 /* Set CLOBBER_OP to be clobber operand INDEX in GIMPLE_ASM GS. */
2659 gimple_asm_set_clobber_op (gimple gs, unsigned index, tree clobber_op)
2661 GIMPLE_CHECK (gs, GIMPLE_ASM);
2662 gcc_assert (index <= gs->gimple_asm.nc);
2663 gcc_assert (TREE_CODE (clobber_op) == TREE_LIST);
2664 gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no, clobber_op);
2668 /* Return the string representing the assembly instruction in
2671 static inline const char *
2672 gimple_asm_string (const_gimple gs)
2674 GIMPLE_CHECK (gs, GIMPLE_ASM);
2675 return gs->gimple_asm.string;
2679 /* Return true if GS is an asm statement marked volatile. */
2682 gimple_asm_volatile_p (const_gimple gs)
2684 GIMPLE_CHECK (gs, GIMPLE_ASM);
2685 return (gs->gsbase.subcode & GF_ASM_VOLATILE) != 0;
2689 /* If VOLATLE_P is true, mark asm statement GS as volatile. */
2692 gimple_asm_set_volatile (gimple gs, bool volatile_p)
2694 GIMPLE_CHECK (gs, GIMPLE_ASM);
2696 gs->gsbase.subcode |= GF_ASM_VOLATILE;
2698 gs->gsbase.subcode &= ~GF_ASM_VOLATILE;
2702 /* If INPUT_P is true, mark asm GS as an ASM_INPUT. */
2705 gimple_asm_set_input (gimple gs, bool input_p)
2707 GIMPLE_CHECK (gs, GIMPLE_ASM);
2709 gs->gsbase.subcode |= GF_ASM_INPUT;
2711 gs->gsbase.subcode &= ~GF_ASM_INPUT;
2715 /* Return true if asm GS is an ASM_INPUT. */
2718 gimple_asm_input_p (const_gimple gs)
2720 GIMPLE_CHECK (gs, GIMPLE_ASM);
2721 return (gs->gsbase.subcode & GF_ASM_INPUT) != 0;
2725 /* Return the types handled by GIMPLE_CATCH statement GS. */
2728 gimple_catch_types (const_gimple gs)
2730 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2731 return gs->gimple_catch.types;
2735 /* Return a pointer to the types handled by GIMPLE_CATCH statement GS. */
2737 static inline tree *
2738 gimple_catch_types_ptr (gimple gs)
2740 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2741 return &gs->gimple_catch.types;
2745 /* Return the GIMPLE sequence representing the body of the handler of
2746 GIMPLE_CATCH statement GS. */
2748 static inline gimple_seq
2749 gimple_catch_handler (gimple gs)
2751 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2752 return gs->gimple_catch.handler;
2756 /* Return a pointer to the GIMPLE sequence representing the body of
2757 the handler of GIMPLE_CATCH statement GS. */
2759 static inline gimple_seq *
2760 gimple_catch_handler_ptr (gimple gs)
2762 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2763 return &gs->gimple_catch.handler;
2767 /* Set T to be the set of types handled by GIMPLE_CATCH GS. */
2770 gimple_catch_set_types (gimple gs, tree t)
2772 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2773 gs->gimple_catch.types = t;
2777 /* Set HANDLER to be the body of GIMPLE_CATCH GS. */
2780 gimple_catch_set_handler (gimple gs, gimple_seq handler)
2782 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2783 gs->gimple_catch.handler = handler;
2787 /* Return the types handled by GIMPLE_EH_FILTER statement GS. */
2790 gimple_eh_filter_types (const_gimple gs)
2792 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2793 return gs->gimple_eh_filter.types;
2797 /* Return a pointer to the types handled by GIMPLE_EH_FILTER statement
2800 static inline tree *
2801 gimple_eh_filter_types_ptr (gimple gs)
2803 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2804 return &gs->gimple_eh_filter.types;
2808 /* Return the sequence of statement to execute when GIMPLE_EH_FILTER
2811 static inline gimple_seq
2812 gimple_eh_filter_failure (gimple gs)
2814 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2815 return gs->gimple_eh_filter.failure;
2819 /* Set TYPES to be the set of types handled by GIMPLE_EH_FILTER GS. */
2822 gimple_eh_filter_set_types (gimple gs, tree types)
2824 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2825 gs->gimple_eh_filter.types = types;
2829 /* Set FAILURE to be the sequence of statements to execute on failure
2830 for GIMPLE_EH_FILTER GS. */
2833 gimple_eh_filter_set_failure (gimple gs, gimple_seq failure)
2835 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2836 gs->gimple_eh_filter.failure = failure;
2839 /* Return the EH_FILTER_MUST_NOT_THROW flag. */
2843 gimple_eh_filter_must_not_throw (gimple gs)
2845 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2846 return gs->gsbase.subcode != 0;
2849 /* Set the EH_FILTER_MUST_NOT_THROW flag to the value MNTP. */
2852 gimple_eh_filter_set_must_not_throw (gimple gs, bool mntp)
2854 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2855 gs->gsbase.subcode = (unsigned int) mntp;
2859 /* GIMPLE_TRY accessors. */
2861 /* Return the kind of try block represented by GIMPLE_TRY GS. This is
2862 either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY. */
2864 static inline enum gimple_try_flags
2865 gimple_try_kind (const_gimple gs)
2867 GIMPLE_CHECK (gs, GIMPLE_TRY);
2868 return (enum gimple_try_flags) (gs->gsbase.subcode & GIMPLE_TRY_KIND);
2872 /* Set the kind of try block represented by GIMPLE_TRY GS. */
2875 gimple_try_set_kind (gimple gs, enum gimple_try_flags kind)
2877 GIMPLE_CHECK (gs, GIMPLE_TRY);
2878 gcc_assert (kind == GIMPLE_TRY_CATCH || kind == GIMPLE_TRY_FINALLY);
2879 if (gimple_try_kind (gs) != kind)
2880 gs->gsbase.subcode = (unsigned int) kind;
2884 /* Return the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2887 gimple_try_catch_is_cleanup (const_gimple gs)
2889 gcc_assert (gimple_try_kind (gs) == GIMPLE_TRY_CATCH);
2890 return (gs->gsbase.subcode & GIMPLE_TRY_CATCH_IS_CLEANUP) != 0;
2894 /* Return the sequence of statements used as the body for GIMPLE_TRY GS. */
2896 static inline gimple_seq
2897 gimple_try_eval (gimple gs)
2899 GIMPLE_CHECK (gs, GIMPLE_TRY);
2900 return gs->gimple_try.eval;
2904 /* Return the sequence of statements used as the cleanup body for
2907 static inline gimple_seq
2908 gimple_try_cleanup (gimple gs)
2910 GIMPLE_CHECK (gs, GIMPLE_TRY);
2911 return gs->gimple_try.cleanup;
2915 /* Set the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2918 gimple_try_set_catch_is_cleanup (gimple g, bool catch_is_cleanup)
2920 gcc_assert (gimple_try_kind (g) == GIMPLE_TRY_CATCH);
2921 if (catch_is_cleanup)
2922 g->gsbase.subcode |= GIMPLE_TRY_CATCH_IS_CLEANUP;
2924 g->gsbase.subcode &= ~GIMPLE_TRY_CATCH_IS_CLEANUP;
2928 /* Set EVAL to be the sequence of statements to use as the body for
2932 gimple_try_set_eval (gimple gs, gimple_seq eval)
2934 GIMPLE_CHECK (gs, GIMPLE_TRY);
2935 gs->gimple_try.eval = eval;
2939 /* Set CLEANUP to be the sequence of statements to use as the cleanup
2940 body for GIMPLE_TRY GS. */
2943 gimple_try_set_cleanup (gimple gs, gimple_seq cleanup)
2945 GIMPLE_CHECK (gs, GIMPLE_TRY);
2946 gs->gimple_try.cleanup = cleanup;
2950 /* Return the cleanup sequence for cleanup statement GS. */
2952 static inline gimple_seq
2953 gimple_wce_cleanup (gimple gs)
2955 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
2956 return gs->gimple_wce.cleanup;
2960 /* Set CLEANUP to be the cleanup sequence for GS. */
2963 gimple_wce_set_cleanup (gimple gs, gimple_seq cleanup)
2965 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
2966 gs->gimple_wce.cleanup = cleanup;
2970 /* Return the CLEANUP_EH_ONLY flag for a WCE tuple. */
2973 gimple_wce_cleanup_eh_only (const_gimple gs)
2975 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
2976 return gs->gsbase.subcode != 0;
2980 /* Set the CLEANUP_EH_ONLY flag for a WCE tuple. */
2983 gimple_wce_set_cleanup_eh_only (gimple gs, bool eh_only_p)
2985 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
2986 gs->gsbase.subcode = (unsigned int) eh_only_p;
2990 /* Return the maximum number of arguments supported by GIMPLE_PHI GS. */
2992 static inline unsigned
2993 gimple_phi_capacity (const_gimple gs)
2995 GIMPLE_CHECK (gs, GIMPLE_PHI);
2996 return gs->gimple_phi.capacity;
3000 /* Return the number of arguments in GIMPLE_PHI GS. This must always
3001 be exactly the number of incoming edges for the basic block holding
3004 static inline unsigned
3005 gimple_phi_num_args (const_gimple gs)
3007 GIMPLE_CHECK (gs, GIMPLE_PHI);
3008 return gs->gimple_phi.nargs;
3012 /* Return the SSA name created by GIMPLE_PHI GS. */
3015 gimple_phi_result (const_gimple gs)
3017 GIMPLE_CHECK (gs, GIMPLE_PHI);
3018 return gs->gimple_phi.result;
3021 /* Return a pointer to the SSA name created by GIMPLE_PHI GS. */
3023 static inline tree *
3024 gimple_phi_result_ptr (gimple gs)
3026 GIMPLE_CHECK (gs, GIMPLE_PHI);
3027 return &gs->gimple_phi.result;
3030 /* Set RESULT to be the SSA name created by GIMPLE_PHI GS. */
3033 gimple_phi_set_result (gimple gs, tree result)
3035 GIMPLE_CHECK (gs, GIMPLE_PHI);
3036 gs->gimple_phi.result = result;
3040 /* Return the PHI argument corresponding to incoming edge INDEX for
3043 static inline struct phi_arg_d *
3044 gimple_phi_arg (gimple gs, unsigned index)
3046 GIMPLE_CHECK (gs, GIMPLE_PHI);
3047 gcc_assert (index <= gs->gimple_phi.capacity);
3048 return &(gs->gimple_phi.args[index]);
3051 /* Set PHIARG to be the argument corresponding to incoming edge INDEX
3052 for GIMPLE_PHI GS. */
3055 gimple_phi_set_arg (gimple gs, unsigned index, struct phi_arg_d * phiarg)
3057 GIMPLE_CHECK (gs, GIMPLE_PHI);
3058 gcc_assert (index <= gs->gimple_phi.nargs);
3059 memcpy (gs->gimple_phi.args + index, phiarg, sizeof (struct phi_arg_d));
3062 /* Return the region number for GIMPLE_RESX GS. */
3065 gimple_resx_region (const_gimple gs)
3067 GIMPLE_CHECK (gs, GIMPLE_RESX);
3068 return gs->gimple_resx.region;
3071 /* Set REGION to be the region number for GIMPLE_RESX GS. */
3074 gimple_resx_set_region (gimple gs, int region)
3076 GIMPLE_CHECK (gs, GIMPLE_RESX);
3077 gs->gimple_resx.region = region;
3081 /* Return the number of labels associated with the switch statement GS. */
3083 static inline unsigned
3084 gimple_switch_num_labels (const_gimple gs)
3087 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3088 num_ops = gimple_num_ops (gs);
3089 gcc_assert (num_ops > 1);
3094 /* Set NLABELS to be the number of labels for the switch statement GS. */
3097 gimple_switch_set_num_labels (gimple g, unsigned nlabels)
3099 GIMPLE_CHECK (g, GIMPLE_SWITCH);
3100 gimple_set_num_ops (g, nlabels + 1);
3104 /* Return the index variable used by the switch statement GS. */
3107 gimple_switch_index (const_gimple gs)
3109 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3110 return gimple_op (gs, 0);
3114 /* Return a pointer to the index variable for the switch statement GS. */
3116 static inline tree *
3117 gimple_switch_index_ptr (const_gimple gs)
3119 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3120 return gimple_op_ptr (gs, 0);
3124 /* Set INDEX to be the index variable for switch statement GS. */
3127 gimple_switch_set_index (gimple gs, tree index)
3129 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3130 gcc_assert (SSA_VAR_P (index) || CONSTANT_CLASS_P (index));
3131 gimple_set_op (gs, 0, index);
3135 /* Return the label numbered INDEX. The default label is 0, followed by any
3136 labels in a switch statement. */
3139 gimple_switch_label (const_gimple gs, unsigned index)
3141 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3142 gcc_assert (gimple_num_ops (gs) > index + 1);
3143 return gimple_op (gs, index + 1);
3146 /* Set the label number INDEX to LABEL. 0 is always the default label. */
3149 gimple_switch_set_label (gimple gs, unsigned index, tree label)
3151 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3152 gcc_assert (gimple_num_ops (gs) > index + 1);
3153 gcc_assert (label == NULL_TREE || TREE_CODE (label) == CASE_LABEL_EXPR);
3154 gimple_set_op (gs, index + 1, label);
3157 /* Return the default label for a switch statement. */
3160 gimple_switch_default_label (const_gimple gs)
3162 return gimple_switch_label (gs, 0);
3165 /* Set the default label for a switch statement. */
3168 gimple_switch_set_default_label (gimple gs, tree label)
3170 gimple_switch_set_label (gs, 0, label);
3173 /* Return true if GS is a GIMPLE_DEBUG statement. */
3176 is_gimple_debug (const_gimple gs)
3178 return gimple_code (gs) == GIMPLE_DEBUG;
3181 /* Return true if S is a GIMPLE_DEBUG BIND statement. */
3184 gimple_debug_bind_p (const_gimple s)
3186 if (is_gimple_debug (s))
3187 return s->gsbase.subcode == GIMPLE_DEBUG_BIND;
3192 /* Return the variable bound in a GIMPLE_DEBUG bind statement. */
3195 gimple_debug_bind_get_var (gimple dbg)
3197 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3198 gcc_assert (gimple_debug_bind_p (dbg));
3199 return gimple_op (dbg, 0);
3202 /* Return the value bound to the variable in a GIMPLE_DEBUG bind
3206 gimple_debug_bind_get_value (gimple dbg)
3208 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3209 gcc_assert (gimple_debug_bind_p (dbg));
3210 return gimple_op (dbg, 1);
3213 /* Return a pointer to the value bound to the variable in a
3214 GIMPLE_DEBUG bind statement. */
3216 static inline tree *
3217 gimple_debug_bind_get_value_ptr (gimple dbg)
3219 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3220 gcc_assert (gimple_debug_bind_p (dbg));
3221 return gimple_op_ptr (dbg, 1);
3224 /* Set the variable bound in a GIMPLE_DEBUG bind statement. */
3227 gimple_debug_bind_set_var (gimple dbg, tree var)
3229 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3230 gcc_assert (gimple_debug_bind_p (dbg));
3231 gimple_set_op (dbg, 0, var);
3234 /* Set the value bound to the variable in a GIMPLE_DEBUG bind
3238 gimple_debug_bind_set_value (gimple dbg, tree value)
3240 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3241 gcc_assert (gimple_debug_bind_p (dbg));
3242 gimple_set_op (dbg, 1, value);
3245 /* The second operand of a GIMPLE_DEBUG_BIND, when the value was
3247 #define GIMPLE_DEBUG_BIND_NOVALUE NULL_TREE /* error_mark_node */
3249 /* Remove the value bound to the variable in a GIMPLE_DEBUG bind
3253 gimple_debug_bind_reset_value (gimple dbg)
3255 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3256 gcc_assert (gimple_debug_bind_p (dbg));
3257 gimple_set_op (dbg, 1, GIMPLE_DEBUG_BIND_NOVALUE);
3260 /* Return true if the GIMPLE_DEBUG bind statement is bound to a
3264 gimple_debug_bind_has_value_p (gimple dbg)
3266 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3267 gcc_assert (gimple_debug_bind_p (dbg));
3268 return gimple_op (dbg, 1) != GIMPLE_DEBUG_BIND_NOVALUE;
3271 #undef GIMPLE_DEBUG_BIND_NOVALUE
3273 /* Return the body for the OMP statement GS. */
3275 static inline gimple_seq
3276 gimple_omp_body (gimple gs)
3278 return gs->omp.body;
3281 /* Set BODY to be the body for the OMP statement GS. */
3284 gimple_omp_set_body (gimple gs, gimple_seq body)
3286 gs->omp.body = body;
3290 /* Return the name associated with OMP_CRITICAL statement GS. */
3293 gimple_omp_critical_name (const_gimple gs)
3295 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3296 return gs->gimple_omp_critical.name;
3300 /* Return a pointer to the name associated with OMP critical statement GS. */
3302 static inline tree *
3303 gimple_omp_critical_name_ptr (gimple gs)
3305 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3306 return &gs->gimple_omp_critical.name;
3310 /* Set NAME to be the name associated with OMP critical statement GS. */
3313 gimple_omp_critical_set_name (gimple gs, tree name)
3315 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3316 gs->gimple_omp_critical.name = name;
3320 /* Return the clauses associated with OMP_FOR GS. */
3323 gimple_omp_for_clauses (const_gimple gs)
3325 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3326 return gs->gimple_omp_for.clauses;
3330 /* Return a pointer to the OMP_FOR GS. */
3332 static inline tree *
3333 gimple_omp_for_clauses_ptr (gimple gs)
3335 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3336 return &gs->gimple_omp_for.clauses;
3340 /* Set CLAUSES to be the list of clauses associated with OMP_FOR GS. */
3343 gimple_omp_for_set_clauses (gimple gs, tree clauses)
3345 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3346 gs->gimple_omp_for.clauses = clauses;
3350 /* Get the collapse count of OMP_FOR GS. */
3352 static inline size_t
3353 gimple_omp_for_collapse (gimple gs)
3355 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3356 return gs->gimple_omp_for.collapse;
3360 /* Return the index variable for OMP_FOR GS. */
3363 gimple_omp_for_index (const_gimple gs, size_t i)
3365 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3366 gcc_assert (i < gs->gimple_omp_for.collapse);
3367 return gs->gimple_omp_for.iter[i].index;
3371 /* Return a pointer to the index variable for OMP_FOR GS. */
3373 static inline tree *
3374 gimple_omp_for_index_ptr (gimple gs, size_t i)
3376 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3377 gcc_assert (i < gs->gimple_omp_for.collapse);
3378 return &gs->gimple_omp_for.iter[i].index;
3382 /* Set INDEX to be the index variable for OMP_FOR GS. */
3385 gimple_omp_for_set_index (gimple gs, size_t i, tree index)
3387 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3388 gcc_assert (i < gs->gimple_omp_for.collapse);
3389 gs->gimple_omp_for.iter[i].index = index;
3393 /* Return the initial value for OMP_FOR GS. */
3396 gimple_omp_for_initial (const_gimple gs, size_t i)
3398 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3399 gcc_assert (i < gs->gimple_omp_for.collapse);
3400 return gs->gimple_omp_for.iter[i].initial;
3404 /* Return a pointer to the initial value for OMP_FOR GS. */
3406 static inline tree *
3407 gimple_omp_for_initial_ptr (gimple gs, size_t i)
3409 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3410 gcc_assert (i < gs->gimple_omp_for.collapse);
3411 return &gs->gimple_omp_for.iter[i].initial;
3415 /* Set INITIAL to be the initial value for OMP_FOR GS. */
3418 gimple_omp_for_set_initial (gimple gs, size_t i, tree initial)
3420 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3421 gcc_assert (i < gs->gimple_omp_for.collapse);
3422 gs->gimple_omp_for.iter[i].initial = initial;
3426 /* Return the final value for OMP_FOR GS. */
3429 gimple_omp_for_final (const_gimple gs, size_t i)
3431 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3432 gcc_assert (i < gs->gimple_omp_for.collapse);
3433 return gs->gimple_omp_for.iter[i].final;
3437 /* Return a pointer to the final value for OMP_FOR GS. */
3439 static inline tree *
3440 gimple_omp_for_final_ptr (gimple gs, size_t i)
3442 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3443 gcc_assert (i < gs->gimple_omp_for.collapse);
3444 return &gs->gimple_omp_for.iter[i].final;
3448 /* Set FINAL to be the final value for OMP_FOR GS. */
3451 gimple_omp_for_set_final (gimple gs, size_t i, tree final)
3453 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3454 gcc_assert (i < gs->gimple_omp_for.collapse);
3455 gs->gimple_omp_for.iter[i].final = final;
3459 /* Return the increment value for OMP_FOR GS. */
3462 gimple_omp_for_incr (const_gimple gs, size_t i)
3464 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3465 gcc_assert (i < gs->gimple_omp_for.collapse);
3466 return gs->gimple_omp_for.iter[i].incr;
3470 /* Return a pointer to the increment value for OMP_FOR GS. */
3472 static inline tree *
3473 gimple_omp_for_incr_ptr (gimple gs, size_t i)
3475 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3476 gcc_assert (i < gs->gimple_omp_for.collapse);
3477 return &gs->gimple_omp_for.iter[i].incr;
3481 /* Set INCR to be the increment value for OMP_FOR GS. */
3484 gimple_omp_for_set_incr (gimple gs, size_t i, tree incr)
3486 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3487 gcc_assert (i < gs->gimple_omp_for.collapse);
3488 gs->gimple_omp_for.iter[i].incr = incr;
3492 /* Return the sequence of statements to execute before the OMP_FOR
3493 statement GS starts. */
3495 static inline gimple_seq
3496 gimple_omp_for_pre_body (gimple gs)
3498 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3499 return gs->gimple_omp_for.pre_body;
3503 /* Set PRE_BODY to be the sequence of statements to execute before the
3504 OMP_FOR statement GS starts. */
3507 gimple_omp_for_set_pre_body (gimple gs, gimple_seq pre_body)
3509 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3510 gs->gimple_omp_for.pre_body = pre_body;
3514 /* Return the clauses associated with OMP_PARALLEL GS. */
3517 gimple_omp_parallel_clauses (const_gimple gs)
3519 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3520 return gs->gimple_omp_parallel.clauses;
3524 /* Return a pointer to the clauses associated with OMP_PARALLEL GS. */
3526 static inline tree *
3527 gimple_omp_parallel_clauses_ptr (gimple gs)
3529 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3530 return &gs->gimple_omp_parallel.clauses;
3534 /* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL
3538 gimple_omp_parallel_set_clauses (gimple gs, tree clauses)
3540 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3541 gs->gimple_omp_parallel.clauses = clauses;
3545 /* Return the child function used to hold the body of OMP_PARALLEL GS. */
3548 gimple_omp_parallel_child_fn (const_gimple gs)
3550 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3551 return gs->gimple_omp_parallel.child_fn;
3554 /* Return a pointer to the child function used to hold the body of
3557 static inline tree *
3558 gimple_omp_parallel_child_fn_ptr (gimple gs)
3560 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3561 return &gs->gimple_omp_parallel.child_fn;
3565 /* Set CHILD_FN to be the child function for OMP_PARALLEL GS. */
3568 gimple_omp_parallel_set_child_fn (gimple gs, tree child_fn)
3570 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3571 gs->gimple_omp_parallel.child_fn = child_fn;
3575 /* Return the artificial argument used to send variables and values
3576 from the parent to the children threads in OMP_PARALLEL GS. */
3579 gimple_omp_parallel_data_arg (const_gimple gs)
3581 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3582 return gs->gimple_omp_parallel.data_arg;
3586 /* Return a pointer to the data argument for OMP_PARALLEL GS. */
3588 static inline tree *
3589 gimple_omp_parallel_data_arg_ptr (gimple gs)
3591 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3592 return &gs->gimple_omp_parallel.data_arg;
3596 /* Set DATA_ARG to be the data argument for OMP_PARALLEL GS. */
3599 gimple_omp_parallel_set_data_arg (gimple gs, tree data_arg)
3601 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3602 gs->gimple_omp_parallel.data_arg = data_arg;
3606 /* Return the clauses associated with OMP_TASK GS. */
3609 gimple_omp_task_clauses (const_gimple gs)
3611 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3612 return gs->gimple_omp_parallel.clauses;
3616 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3618 static inline tree *
3619 gimple_omp_task_clauses_ptr (gimple gs)
3621 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3622 return &gs->gimple_omp_parallel.clauses;
3626 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3630 gimple_omp_task_set_clauses (gimple gs, tree clauses)
3632 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3633 gs->gimple_omp_parallel.clauses = clauses;
3637 /* Return the child function used to hold the body of OMP_TASK GS. */
3640 gimple_omp_task_child_fn (const_gimple gs)
3642 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3643 return gs->gimple_omp_parallel.child_fn;
3646 /* Return a pointer to the child function used to hold the body of
3649 static inline tree *
3650 gimple_omp_task_child_fn_ptr (gimple gs)
3652 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3653 return &gs->gimple_omp_parallel.child_fn;
3657 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3660 gimple_omp_task_set_child_fn (gimple gs, tree child_fn)
3662 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3663 gs->gimple_omp_parallel.child_fn = child_fn;
3667 /* Return the artificial argument used to send variables and values
3668 from the parent to the children threads in OMP_TASK GS. */
3671 gimple_omp_task_data_arg (const_gimple gs)
3673 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3674 return gs->gimple_omp_parallel.data_arg;
3678 /* Return a pointer to the data argument for OMP_TASK GS. */
3680 static inline tree *
3681 gimple_omp_task_data_arg_ptr (gimple gs)
3683 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3684 return &gs->gimple_omp_parallel.data_arg;
3688 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3691 gimple_omp_task_set_data_arg (gimple gs, tree data_arg)
3693 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3694 gs->gimple_omp_parallel.data_arg = data_arg;
3698 /* Return the clauses associated with OMP_TASK GS. */
3701 gimple_omp_taskreg_clauses (const_gimple gs)
3703 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3704 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3705 return gs->gimple_omp_parallel.clauses;
3709 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3711 static inline tree *
3712 gimple_omp_taskreg_clauses_ptr (gimple gs)
3714 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3715 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3716 return &gs->gimple_omp_parallel.clauses;
3720 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3724 gimple_omp_taskreg_set_clauses (gimple gs, tree clauses)
3726 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3727 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3728 gs->gimple_omp_parallel.clauses = clauses;
3732 /* Return the child function used to hold the body of OMP_TASK GS. */
3735 gimple_omp_taskreg_child_fn (const_gimple gs)
3737 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3738 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3739 return gs->gimple_omp_parallel.child_fn;
3742 /* Return a pointer to the child function used to hold the body of
3745 static inline tree *
3746 gimple_omp_taskreg_child_fn_ptr (gimple gs)
3748 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3749 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3750 return &gs->gimple_omp_parallel.child_fn;
3754 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3757 gimple_omp_taskreg_set_child_fn (gimple gs, tree child_fn)
3759 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3760 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3761 gs->gimple_omp_parallel.child_fn = child_fn;
3765 /* Return the artificial argument used to send variables and values
3766 from the parent to the children threads in OMP_TASK GS. */
3769 gimple_omp_taskreg_data_arg (const_gimple gs)
3771 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3772 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3773 return gs->gimple_omp_parallel.data_arg;
3777 /* Return a pointer to the data argument for OMP_TASK GS. */
3779 static inline tree *
3780 gimple_omp_taskreg_data_arg_ptr (gimple gs)
3782 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3783 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3784 return &gs->gimple_omp_parallel.data_arg;
3788 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3791 gimple_omp_taskreg_set_data_arg (gimple gs, tree data_arg)
3793 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3794 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3795 gs->gimple_omp_parallel.data_arg = data_arg;
3799 /* Return the copy function used to hold the body of OMP_TASK GS. */
3802 gimple_omp_task_copy_fn (const_gimple gs)
3804 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3805 return gs->gimple_omp_task.copy_fn;
3808 /* Return a pointer to the copy function used to hold the body of
3811 static inline tree *
3812 gimple_omp_task_copy_fn_ptr (gimple gs)
3814 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3815 return &gs->gimple_omp_task.copy_fn;
3819 /* Set CHILD_FN to be the copy function for OMP_TASK GS. */
3822 gimple_omp_task_set_copy_fn (gimple gs, tree copy_fn)
3824 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3825 gs->gimple_omp_task.copy_fn = copy_fn;
3829 /* Return size of the data block in bytes in OMP_TASK GS. */
3832 gimple_omp_task_arg_size (const_gimple gs)
3834 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3835 return gs->gimple_omp_task.arg_size;
3839 /* Return a pointer to the data block size for OMP_TASK GS. */
3841 static inline tree *
3842 gimple_omp_task_arg_size_ptr (gimple gs)
3844 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3845 return &gs->gimple_omp_task.arg_size;
3849 /* Set ARG_SIZE to be the data block size for OMP_TASK GS. */
3852 gimple_omp_task_set_arg_size (gimple gs, tree arg_size)
3854 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3855 gs->gimple_omp_task.arg_size = arg_size;
3859 /* Return align of the data block in bytes in OMP_TASK GS. */
3862 gimple_omp_task_arg_align (const_gimple gs)
3864 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3865 return gs->gimple_omp_task.arg_align;
3869 /* Return a pointer to the data block align for OMP_TASK GS. */
3871 static inline tree *
3872 gimple_omp_task_arg_align_ptr (gimple gs)
3874 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3875 return &gs->gimple_omp_task.arg_align;
3879 /* Set ARG_SIZE to be the data block align for OMP_TASK GS. */
3882 gimple_omp_task_set_arg_align (gimple gs, tree arg_align)
3884 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3885 gs->gimple_omp_task.arg_align = arg_align;
3889 /* Return the clauses associated with OMP_SINGLE GS. */
3892 gimple_omp_single_clauses (const_gimple gs)
3894 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3895 return gs->gimple_omp_single.clauses;
3899 /* Return a pointer to the clauses associated with OMP_SINGLE GS. */
3901 static inline tree *
3902 gimple_omp_single_clauses_ptr (gimple gs)
3904 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3905 return &gs->gimple_omp_single.clauses;
3909 /* Set CLAUSES to be the clauses associated with OMP_SINGLE GS. */
3912 gimple_omp_single_set_clauses (gimple gs, tree clauses)
3914 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3915 gs->gimple_omp_single.clauses = clauses;
3919 /* Return the clauses associated with OMP_SECTIONS GS. */
3922 gimple_omp_sections_clauses (const_gimple gs)
3924 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3925 return gs->gimple_omp_sections.clauses;
3929 /* Return a pointer to the clauses associated with OMP_SECTIONS GS. */
3931 static inline tree *
3932 gimple_omp_sections_clauses_ptr (gimple gs)
3934 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3935 return &gs->gimple_omp_sections.clauses;
3939 /* Set CLAUSES to be the set of clauses associated with OMP_SECTIONS
3943 gimple_omp_sections_set_clauses (gimple gs, tree clauses)
3945 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3946 gs->gimple_omp_sections.clauses = clauses;
3950 /* Return the control variable associated with the GIMPLE_OMP_SECTIONS
3954 gimple_omp_sections_control (const_gimple gs)
3956 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3957 return gs->gimple_omp_sections.control;
3961 /* Return a pointer to the clauses associated with the GIMPLE_OMP_SECTIONS
3964 static inline tree *
3965 gimple_omp_sections_control_ptr (gimple gs)
3967 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3968 return &gs->gimple_omp_sections.control;
3972 /* Set CONTROL to be the set of clauses associated with the
3973 GIMPLE_OMP_SECTIONS in GS. */
3976 gimple_omp_sections_set_control (gimple gs, tree control)
3978 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3979 gs->gimple_omp_sections.control = control;
3983 /* Set COND to be the condition code for OMP_FOR GS. */
3986 gimple_omp_for_set_cond (gimple gs, size_t i, enum tree_code cond)
3988 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3989 gcc_assert (TREE_CODE_CLASS (cond) == tcc_comparison);
3990 gcc_assert (i < gs->gimple_omp_for.collapse);
3991 gs->gimple_omp_for.iter[i].cond = cond;
3995 /* Return the condition code associated with OMP_FOR GS. */
3997 static inline enum tree_code
3998 gimple_omp_for_cond (const_gimple gs, size_t i)
4000 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4001 gcc_assert (i < gs->gimple_omp_for.collapse);
4002 return gs->gimple_omp_for.iter[i].cond;
4006 /* Set the value being stored in an atomic store. */
4009 gimple_omp_atomic_store_set_val (gimple g, tree val)
4011 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4012 g->gimple_omp_atomic_store.val = val;
4016 /* Return the value being stored in an atomic store. */
4019 gimple_omp_atomic_store_val (const_gimple g)
4021 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4022 return g->gimple_omp_atomic_store.val;
4026 /* Return a pointer to the value being stored in an atomic store. */
4028 static inline tree *
4029 gimple_omp_atomic_store_val_ptr (gimple g)
4031 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4032 return &g->gimple_omp_atomic_store.val;
4036 /* Set the LHS of an atomic load. */
4039 gimple_omp_atomic_load_set_lhs (gimple g, tree lhs)
4041 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4042 g->gimple_omp_atomic_load.lhs = lhs;
4046 /* Get the LHS of an atomic load. */
4049 gimple_omp_atomic_load_lhs (const_gimple g)
4051 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4052 return g->gimple_omp_atomic_load.lhs;
4056 /* Return a pointer to the LHS of an atomic load. */
4058 static inline tree *
4059 gimple_omp_atomic_load_lhs_ptr (gimple g)
4061 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4062 return &g->gimple_omp_atomic_load.lhs;
4066 /* Set the RHS of an atomic load. */
4069 gimple_omp_atomic_load_set_rhs (gimple g, tree rhs)
4071 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4072 g->gimple_omp_atomic_load.rhs = rhs;
4076 /* Get the RHS of an atomic load. */
4079 gimple_omp_atomic_load_rhs (const_gimple g)
4081 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4082 return g->gimple_omp_atomic_load.rhs;
4086 /* Return a pointer to the RHS of an atomic load. */
4088 static inline tree *
4089 gimple_omp_atomic_load_rhs_ptr (gimple g)
4091 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4092 return &g->gimple_omp_atomic_load.rhs;
4096 /* Get the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4099 gimple_omp_continue_control_def (const_gimple g)
4101 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4102 return g->gimple_omp_continue.control_def;
4105 /* The same as above, but return the address. */
4107 static inline tree *
4108 gimple_omp_continue_control_def_ptr (gimple g)
4110 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4111 return &g->gimple_omp_continue.control_def;
4114 /* Set the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4117 gimple_omp_continue_set_control_def (gimple g, tree def)
4119 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4120 g->gimple_omp_continue.control_def = def;
4124 /* Get the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4127 gimple_omp_continue_control_use (const_gimple g)
4129 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4130 return g->gimple_omp_continue.control_use;
4134 /* The same as above, but return the address. */
4136 static inline tree *
4137 gimple_omp_continue_control_use_ptr (gimple g)
4139 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4140 return &g->gimple_omp_continue.control_use;
4144 /* Set the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4147 gimple_omp_continue_set_control_use (gimple g, tree use)
4149 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4150 g->gimple_omp_continue.control_use = use;
4154 /* Return a pointer to the return value for GIMPLE_RETURN GS. */
4156 static inline tree *
4157 gimple_return_retval_ptr (const_gimple gs)
4159 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4160 gcc_assert (gimple_num_ops (gs) == 1);
4161 return gimple_op_ptr (gs, 0);
4164 /* Return the return value for GIMPLE_RETURN GS. */
4167 gimple_return_retval (const_gimple gs)
4169 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4170 gcc_assert (gimple_num_ops (gs) == 1);
4171 return gimple_op (gs, 0);
4175 /* Set RETVAL to be the return value for GIMPLE_RETURN GS. */
4178 gimple_return_set_retval (gimple gs, tree retval)
4180 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4181 gcc_assert (gimple_num_ops (gs) == 1);
4182 gcc_assert (retval == NULL_TREE
4183 || TREE_CODE (retval) == RESULT_DECL
4184 || is_gimple_val (retval));
4185 gimple_set_op (gs, 0, retval);
4189 /* Returns true when the gimple statment STMT is any of the OpenMP types. */
4192 is_gimple_omp (const_gimple stmt)
4194 return (gimple_code (stmt) == GIMPLE_OMP_PARALLEL
4195 || gimple_code (stmt) == GIMPLE_OMP_TASK
4196 || gimple_code (stmt) == GIMPLE_OMP_FOR
4197 || gimple_code (stmt) == GIMPLE_OMP_SECTIONS
4198 || gimple_code (stmt) == GIMPLE_OMP_SECTIONS_SWITCH
4199 || gimple_code (stmt) == GIMPLE_OMP_SINGLE
4200 || gimple_code (stmt) == GIMPLE_OMP_SECTION
4201 || gimple_code (stmt) == GIMPLE_OMP_MASTER
4202 || gimple_code (stmt) == GIMPLE_OMP_ORDERED
4203 || gimple_code (stmt) == GIMPLE_OMP_CRITICAL
4204 || gimple_code (stmt) == GIMPLE_OMP_RETURN
4205 || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_LOAD
4206 || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_STORE
4207 || gimple_code (stmt) == GIMPLE_OMP_CONTINUE);
4211 /* Returns TRUE if statement G is a GIMPLE_NOP. */
4214 gimple_nop_p (const_gimple g)
4216 return gimple_code (g) == GIMPLE_NOP;
4220 /* Return the predictor of GIMPLE_PREDICT statement GS. */
4222 static inline enum br_predictor
4223 gimple_predict_predictor (gimple gs)
4225 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4226 return (enum br_predictor) (gs->gsbase.subcode & ~GF_PREDICT_TAKEN);
4230 /* Set the predictor of GIMPLE_PREDICT statement GS to PREDICT. */
4233 gimple_predict_set_predictor (gimple gs, enum br_predictor predictor)
4235 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4236 gs->gsbase.subcode = (gs->gsbase.subcode & GF_PREDICT_TAKEN)
4237 | (unsigned) predictor;
4241 /* Return the outcome of GIMPLE_PREDICT statement GS. */
4243 static inline enum prediction
4244 gimple_predict_outcome (gimple gs)
4246 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4247 return (gs->gsbase.subcode & GF_PREDICT_TAKEN) ? TAKEN : NOT_TAKEN;
4251 /* Set the outcome of GIMPLE_PREDICT statement GS to OUTCOME. */
4254 gimple_predict_set_outcome (gimple gs, enum prediction outcome)
4256 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4257 if (outcome == TAKEN)
4258 gs->gsbase.subcode |= GF_PREDICT_TAKEN;
4260 gs->gsbase.subcode &= ~GF_PREDICT_TAKEN;
4264 /* Return the type of the main expression computed by STMT. Return
4265 void_type_node if the statement computes nothing. */
4268 gimple_expr_type (const_gimple stmt)
4270 enum gimple_code code = gimple_code (stmt);
4272 if (code == GIMPLE_ASSIGN || code == GIMPLE_CALL)
4275 /* In general we want to pass out a type that can be substituted
4276 for both the RHS and the LHS types if there is a possibly
4277 useless conversion involved. That means returning the
4278 original RHS type as far as we can reconstruct it. */
4279 if (code == GIMPLE_CALL)
4280 type = gimple_call_return_type (stmt);
4282 switch (gimple_assign_rhs_code (stmt))
4284 case POINTER_PLUS_EXPR:
4285 type = TREE_TYPE (gimple_assign_rhs1 (stmt));
4289 /* As fallback use the type of the LHS. */
4290 type = TREE_TYPE (gimple_get_lhs (stmt));
4295 else if (code == GIMPLE_COND)
4296 return boolean_type_node;
4298 return void_type_node;
4302 /* Return a new iterator pointing to GIMPLE_SEQ's first statement. */
4304 static inline gimple_stmt_iterator
4305 gsi_start (gimple_seq seq)
4307 gimple_stmt_iterator i;
4309 i.ptr = gimple_seq_first (seq);
4311 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4317 /* Return a new iterator pointing to the first statement in basic block BB. */
4319 static inline gimple_stmt_iterator
4320 gsi_start_bb (basic_block bb)
4322 gimple_stmt_iterator i;
4326 i.ptr = gimple_seq_first (seq);
4334 /* Return a new iterator initially pointing to GIMPLE_SEQ's last statement. */
4336 static inline gimple_stmt_iterator
4337 gsi_last (gimple_seq seq)
4339 gimple_stmt_iterator i;
4341 i.ptr = gimple_seq_last (seq);
4343 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4349 /* Return a new iterator pointing to the last statement in basic block BB. */
4351 static inline gimple_stmt_iterator
4352 gsi_last_bb (basic_block bb)
4354 gimple_stmt_iterator i;
4358 i.ptr = gimple_seq_last (seq);
4366 /* Return true if I is at the end of its sequence. */
4369 gsi_end_p (gimple_stmt_iterator i)
4371 return i.ptr == NULL;
4375 /* Return true if I is one statement before the end of its sequence. */
4378 gsi_one_before_end_p (gimple_stmt_iterator i)
4380 return i.ptr != NULL && i.ptr->next == NULL;
4384 /* Advance the iterator to the next gimple statement. */
4387 gsi_next (gimple_stmt_iterator *i)
4389 i->ptr = i->ptr->next;
4392 /* Advance the iterator to the previous gimple statement. */
4395 gsi_prev (gimple_stmt_iterator *i)
4397 i->ptr = i->ptr->prev;
4400 /* Return the current stmt. */
4402 static inline gimple
4403 gsi_stmt (gimple_stmt_iterator i)
4408 /* Return a block statement iterator that points to the first non-label
4409 statement in block BB. */
4411 static inline gimple_stmt_iterator
4412 gsi_after_labels (basic_block bb)
4414 gimple_stmt_iterator gsi = gsi_start_bb (bb);
4416 while (!gsi_end_p (gsi) && gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL)
4422 /* Advance the iterator to the next non-debug gimple statement. */
4425 gsi_next_nondebug (gimple_stmt_iterator *i)
4431 while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
4434 /* Advance the iterator to the next non-debug gimple statement. */
4437 gsi_prev_nondebug (gimple_stmt_iterator *i)
4443 while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
4446 /* Return a new iterator pointing to the first non-debug statement in
4449 static inline gimple_stmt_iterator
4450 gsi_start_nondebug_bb (basic_block bb)
4452 gimple_stmt_iterator i = gsi_start_bb (bb);
4454 if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
4455 gsi_next_nondebug (&i);
4460 /* Return a new iterator pointing to the last non-debug statement in
4463 static inline gimple_stmt_iterator
4464 gsi_last_nondebug_bb (basic_block bb)
4466 gimple_stmt_iterator i = gsi_last_bb (bb);
4468 if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
4469 gsi_prev_nondebug (&i);
4474 /* Return a pointer to the current stmt.
4476 NOTE: You may want to use gsi_replace on the iterator itself,
4477 as this performs additional bookkeeping that will not be done
4478 if you simply assign through a pointer returned by gsi_stmt_ptr. */
4480 static inline gimple *
4481 gsi_stmt_ptr (gimple_stmt_iterator *i)
4483 return &i->ptr->stmt;
4487 /* Return the basic block associated with this iterator. */
4489 static inline basic_block
4490 gsi_bb (gimple_stmt_iterator i)
4496 /* Return the sequence associated with this iterator. */
4498 static inline gimple_seq
4499 gsi_seq (gimple_stmt_iterator i)
4505 enum gsi_iterator_update
4507 GSI_NEW_STMT, /* Only valid when single statement is added, move
4509 GSI_SAME_STMT, /* Leave the iterator at the same statement. */
4510 GSI_CONTINUE_LINKING /* Move iterator to whatever position is suitable
4511 for linking other statements in the same
4515 /* In gimple-iterator.c */
4516 gimple_stmt_iterator gsi_start_phis (basic_block);
4517 gimple_seq gsi_split_seq_after (gimple_stmt_iterator);
4518 gimple_seq gsi_split_seq_before (gimple_stmt_iterator *);
4519 void gsi_replace (gimple_stmt_iterator *, gimple, bool);
4520 void gsi_insert_before (gimple_stmt_iterator *, gimple,
4521 enum gsi_iterator_update);
4522 void gsi_insert_before_without_update (gimple_stmt_iterator *, gimple,
4523 enum gsi_iterator_update);
4524 void gsi_insert_seq_before (gimple_stmt_iterator *, gimple_seq,
4525 enum gsi_iterator_update);
4526 void gsi_insert_seq_before_without_update (gimple_stmt_iterator *, gimple_seq,
4527 enum gsi_iterator_update);
4528 void gsi_insert_after (gimple_stmt_iterator *, gimple,
4529 enum gsi_iterator_update);
4530 void gsi_insert_after_without_update (gimple_stmt_iterator *, gimple,
4531 enum gsi_iterator_update);
4532 void gsi_insert_seq_after (gimple_stmt_iterator *, gimple_seq,
4533 enum gsi_iterator_update);
4534 void gsi_insert_seq_after_without_update (gimple_stmt_iterator *, gimple_seq,
4535 enum gsi_iterator_update);
4536 void gsi_remove (gimple_stmt_iterator *, bool);
4537 gimple_stmt_iterator gsi_for_stmt (gimple);
4538 void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *);
4539 void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *);
4540 void gsi_move_to_bb_end (gimple_stmt_iterator *, struct basic_block_def *);
4541 void gsi_insert_on_edge (edge, gimple);
4542 void gsi_insert_seq_on_edge (edge, gimple_seq);
4543 basic_block gsi_insert_on_edge_immediate (edge, gimple);
4544 basic_block gsi_insert_seq_on_edge_immediate (edge, gimple_seq);
4545 void gsi_commit_one_edge_insert (edge, basic_block *);
4546 void gsi_commit_edge_inserts (void);
4547 gimple gimple_call_copy_skip_args (gimple, bitmap);
4550 /* Convenience routines to walk all statements of a gimple function.
4551 Note that this is useful exclusively before the code is converted
4552 into SSA form. Once the program is in SSA form, the standard
4553 operand interface should be used to analyze/modify statements. */
4554 struct walk_stmt_info
4556 /* Points to the current statement being walked. */
4557 gimple_stmt_iterator gsi;
4559 /* Additional data that the callback functions may want to carry
4560 through the recursion. */
4563 /* Pointer map used to mark visited tree nodes when calling
4564 walk_tree on each operand. If set to NULL, duplicate tree nodes
4565 will be visited more than once. */
4566 struct pointer_set_t *pset;
4568 /* Indicates whether the operand being examined may be replaced
4569 with something that matches is_gimple_val (if true) or something
4570 slightly more complicated (if false). "Something" technically
4571 means the common subset of is_gimple_lvalue and is_gimple_rhs,
4572 but we never try to form anything more complicated than that, so
4573 we don't bother checking.
4575 Also note that CALLBACK should update this flag while walking the
4576 sub-expressions of a statement. For instance, when walking the
4577 statement 'foo (&var)', the flag VAL_ONLY will initially be set
4578 to true, however, when walking &var, the operand of that
4579 ADDR_EXPR does not need to be a GIMPLE value. */
4582 /* True if we are currently walking the LHS of an assignment. */
4585 /* Optional. Set to true by the callback functions if they made any
4589 /* True if we're interested in location information. */
4590 bool want_locations;
4592 /* Operand returned by the callbacks. This is set when calling
4593 walk_gimple_seq. If the walk_stmt_fn or walk_tree_fn callback
4594 returns non-NULL, this field will contain the tree returned by
4595 the last callback. */
4596 tree callback_result;
4599 /* Callback for walk_gimple_stmt. Called for every statement found
4600 during traversal. The first argument points to the statement to
4601 walk. The second argument is a flag that the callback sets to
4602 'true' if it the callback handled all the operands and
4603 sub-statements of the statement (the default value of this flag is
4604 'false'). The third argument is an anonymous pointer to data
4605 to be used by the callback. */
4606 typedef tree (*walk_stmt_fn) (gimple_stmt_iterator *, bool *,
4607 struct walk_stmt_info *);
4609 gimple walk_gimple_seq (gimple_seq, walk_stmt_fn, walk_tree_fn,
4610 struct walk_stmt_info *);
4611 tree walk_gimple_stmt (gimple_stmt_iterator *, walk_stmt_fn, walk_tree_fn,
4612 struct walk_stmt_info *);
4613 tree walk_gimple_op (gimple, walk_tree_fn, struct walk_stmt_info *);
4615 #ifdef GATHER_STATISTICS
4616 /* Enum and arrays used for allocation stats. Keep in sync with
4617 gimple.c:gimple_alloc_kind_names. */
4618 enum gimple_alloc_kind
4620 gimple_alloc_kind_assign, /* Assignments. */
4621 gimple_alloc_kind_phi, /* PHI nodes. */
4622 gimple_alloc_kind_cond, /* Conditionals. */
4623 gimple_alloc_kind_seq, /* Sequences. */
4624 gimple_alloc_kind_rest, /* Everything else. */
4625 gimple_alloc_kind_all
4628 extern int gimple_alloc_counts[];
4629 extern int gimple_alloc_sizes[];
4631 /* Return the allocation kind for a given stmt CODE. */
4632 static inline enum gimple_alloc_kind
4633 gimple_alloc_kind (enum gimple_code code)
4638 return gimple_alloc_kind_assign;
4640 return gimple_alloc_kind_phi;
4642 return gimple_alloc_kind_cond;
4644 return gimple_alloc_kind_rest;
4647 #endif /* GATHER_STATISTICS */
4649 extern void dump_gimple_statistics (void);
4651 #endif /* GCC_GIMPLE_H */