1 /* Gimple IR definitions.
3 Copyright 2007, 2008 Free Software Foundation, Inc.
4 Contributed by Aldy Hernandez <aldyh@redhat.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
25 #include "pointer-set.h"
29 #include "hard-reg-set.h"
30 #include "basic-block.h"
31 #include "tree-ssa-operands.h"
34 DEF_VEC_ALLOC_P(gimple,heap);
35 DEF_VEC_ALLOC_P(gimple,gc);
37 DEF_VEC_P(gimple_seq);
38 DEF_VEC_ALLOC_P(gimple_seq,gc);
39 DEF_VEC_ALLOC_P(gimple_seq,heap);
41 /* For each block, the PHI nodes that need to be rewritten are stored into
43 typedef VEC(gimple, heap) *gimple_vec;
44 DEF_VEC_P (gimple_vec);
45 DEF_VEC_ALLOC_P (gimple_vec, heap);
48 #define DEFGSCODE(SYM, STRING, STRUCT) SYM,
51 LAST_AND_UNUSED_GIMPLE_CODE
54 extern const char *const gimple_code_name[];
55 extern const unsigned char gimple_rhs_class_table[];
57 /* Error out if a gimple tuple is addressed incorrectly. */
58 #if defined ENABLE_GIMPLE_CHECKING
59 extern void gimple_check_failed (const_gimple, const char *, int, \
60 const char *, enum gimple_code, \
61 enum tree_code) ATTRIBUTE_NORETURN;
62 extern void gimple_range_check_failed (const_gimple, const char *, int, \
63 const char *, enum gimple_code, \
64 enum gimple_code) ATTRIBUTE_NORETURN;
66 #define GIMPLE_CHECK(GS, CODE) \
68 const_gimple __gs = (GS); \
69 if (gimple_code (__gs) != (CODE)) \
70 gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__, \
73 #else /* not ENABLE_GIMPLE_CHECKING */
74 #define GIMPLE_CHECK(GS, CODE) (void)0
77 /* Class of GIMPLE expressions suitable for the RHS of assignments. See
78 get_gimple_rhs_class. */
81 GIMPLE_INVALID_RHS, /* The expression cannot be used on the RHS. */
82 GIMPLE_BINARY_RHS, /* The expression is a binary operation. */
83 GIMPLE_UNARY_RHS, /* The expression is a unary operation. */
84 GIMPLE_SINGLE_RHS /* The expression is a single object (an SSA
85 name, a _DECL, a _REF, etc. */
88 /* Specific flags for individual GIMPLE statements. These flags are
89 always stored in gimple_statement_base.subcode and they may only be
90 defined for statement codes that do not use sub-codes.
92 Values for the masks can overlap as long as the overlapping values
93 are never used in the same statement class.
95 The maximum mask value that can be defined is 1 << 15 (i.e., each
96 statement code can hold up to 16 bitflags).
98 Keep this list sorted. */
100 GF_ASM_INPUT = 1 << 0,
101 GF_ASM_VOLATILE = 1 << 1,
102 GF_CALL_CANNOT_INLINE = 1 << 0,
103 GF_CALL_FROM_THUNK = 1 << 1,
104 GF_CALL_RETURN_SLOT_OPT = 1 << 2,
105 GF_CALL_TAILCALL = 1 << 3,
106 GF_CALL_VA_ARG_PACK = 1 << 4,
107 GF_OMP_PARALLEL_COMBINED = 1 << 0,
109 /* True on an GIMPLE_OMP_RETURN statement if the return does not require
110 a thread synchronization via some sort of barrier. The exact barrier
111 that would otherwise be emitted is dependent on the OMP statement with
112 which this return is associated. */
113 GF_OMP_RETURN_NOWAIT = 1 << 0,
115 GF_OMP_SECTION_LAST = 1 << 0,
116 GF_PREDICT_TAKEN = 1 << 15
119 /* Masks for selecting a pass local flag (PLF) to work on. These
120 masks are used by gimple_set_plf and gimple_plf. */
126 /* A node in a gimple_seq_d. */
127 struct gimple_seq_node_d GTY((chain_next ("%h.next"), chain_prev ("%h.prev")))
130 struct gimple_seq_node_d *prev;
131 struct gimple_seq_node_d *next;
134 /* A double-linked sequence of gimple statements. */
135 struct gimple_seq_d GTY ((chain_next ("%h.next_free")))
137 /* First and last statements in the sequence. */
138 gimple_seq_node first;
139 gimple_seq_node last;
141 /* Sequences are created/destroyed frequently. To minimize
142 allocation activity, deallocated sequences are kept in a pool of
143 available sequences. This is the pointer to the next free
144 sequence in the pool. */
145 gimple_seq next_free;
149 /* Return the first node in GIMPLE sequence S. */
151 static inline gimple_seq_node
152 gimple_seq_first (const_gimple_seq s)
154 return s ? s->first : NULL;
158 /* Return the first statement in GIMPLE sequence S. */
161 gimple_seq_first_stmt (const_gimple_seq s)
163 gimple_seq_node n = gimple_seq_first (s);
164 return (n) ? n->stmt : NULL;
168 /* Return the last node in GIMPLE sequence S. */
170 static inline gimple_seq_node
171 gimple_seq_last (const_gimple_seq s)
173 return s ? s->last : NULL;
177 /* Return the last statement in GIMPLE sequence S. */
180 gimple_seq_last_stmt (const_gimple_seq s)
182 gimple_seq_node n = gimple_seq_last (s);
183 return (n) ? n->stmt : NULL;
187 /* Set the last node in GIMPLE sequence S to LAST. */
190 gimple_seq_set_last (gimple_seq s, gimple_seq_node last)
196 /* Set the first node in GIMPLE sequence S to FIRST. */
199 gimple_seq_set_first (gimple_seq s, gimple_seq_node first)
205 /* Return true if GIMPLE sequence S is empty. */
208 gimple_seq_empty_p (const_gimple_seq s)
210 return s == NULL || s->first == NULL;
214 void gimple_seq_add_stmt (gimple_seq *, gimple);
216 /* Allocate a new sequence and initialize its first element with STMT. */
218 static inline gimple_seq
219 gimple_seq_alloc_with_stmt (gimple stmt)
221 gimple_seq seq = NULL;
222 gimple_seq_add_stmt (&seq, stmt);
227 /* Returns the sequence of statements in BB. */
229 static inline gimple_seq
230 bb_seq (const_basic_block bb)
232 return (!(bb->flags & BB_RTL) && bb->il.gimple) ? bb->il.gimple->seq : NULL;
236 /* Sets the sequence of statements in BB to SEQ. */
239 set_bb_seq (basic_block bb, gimple_seq seq)
241 gcc_assert (!(bb->flags & BB_RTL));
242 bb->il.gimple->seq = seq;
245 /* Iterator object for GIMPLE statement sequences. */
249 /* Sequence node holding the current statement. */
252 /* Sequence and basic block holding the statement. These fields
253 are necessary to handle edge cases such as when statement is
254 added to an empty basic block or when the last statement of a
255 block/sequence is removed. */
258 } gimple_stmt_iterator;
261 /* Data structure definitions for GIMPLE tuples. NOTE: word markers
262 are for 64 bit hosts. */
264 struct gimple_statement_base GTY(())
267 Main identifying code for a tuple. */
268 ENUM_BITFIELD(gimple_code) code : 8;
270 /* Nonzero if a warning should not be emitted on this tuple. */
271 unsigned int no_warning : 1;
273 /* Nonzero if this tuple has been visited. Passes are responsible
274 for clearing this bit before using it. */
275 unsigned int visited : 1;
277 /* Nonzero if this tuple represents a non-temporal move. */
278 unsigned int nontemporal_move : 1;
280 /* Pass local flags. These flags are free for any pass to use as
281 they see fit. Passes should not assume that these flags contain
282 any useful value when the pass starts. Any initial state that
283 the pass requires should be set on entry to the pass. See
284 gimple_set_plf and gimple_plf for usage. */
285 unsigned int plf : 2;
287 /* Nonzero if this statement has been modified and needs to have its
288 operands rescanned. */
289 unsigned modified : 1;
291 /* Nonzero if this statement contains volatile operands. */
292 unsigned has_volatile_ops : 1;
294 /* Nonzero if this statement contains memory refernces. */
295 unsigned references_memory_p : 1;
297 /* The SUBCODE field can be used for tuple-specific flags for tuples
298 that do not require subcodes. Note that SUBCODE should be at
299 least as wide as tree codes, as several tuples store tree codes
301 unsigned int subcode : 16;
303 /* UID of this statement. */
307 Locus information for debug info. */
310 /* Number of operands in this tuple. */
314 Basic block holding this statement. */
315 struct basic_block_def *bb;
318 Lexical block holding this statement. */
323 /* Base structure for tuples with operands. */
325 struct gimple_statement_with_ops_base GTY(())
328 struct gimple_statement_base gsbase;
331 Symbols whose addresses are taken by this statement (i.e., they
332 appear inside ADDR_EXPR nodes). */
333 bitmap GTY((skip (""))) addresses_taken;
336 SSA operand vectors. NOTE: It should be possible to
337 amalgamate these vectors with the operand vector OP. However,
338 the SSA operand vectors are organized differently and contain
339 more information (like immediate use chaining). */
340 struct def_optype_d GTY((skip (""))) *def_ops;
341 struct use_optype_d GTY((skip (""))) *use_ops;
345 /* Statements that take register operands. */
347 struct gimple_statement_with_ops GTY(())
350 struct gimple_statement_with_ops_base opbase;
353 Operand vector. NOTE! This must always be the last field
354 of this structure. In particular, this means that this
355 structure cannot be embedded inside another one. */
356 tree GTY((length ("%h.opbase.gsbase.num_ops"))) op[1];
360 /* Base for statements that take both memory and register operands. */
362 struct gimple_statement_with_memory_ops_base GTY(())
365 struct gimple_statement_with_ops_base opbase;
368 Vectors for virtual operands. */
369 struct voptype_d GTY((skip (""))) *vdef_ops;
370 struct voptype_d GTY((skip (""))) *vuse_ops;
373 Symbols stored/loaded by this statement. */
374 bitmap GTY((skip (""))) stores;
375 bitmap GTY((skip (""))) loads;
379 /* Statements that take both memory and register operands. */
381 struct gimple_statement_with_memory_ops GTY(())
384 struct gimple_statement_with_memory_ops_base membase;
387 Operand vector. NOTE! This must always be the last field
388 of this structure. In particular, this means that this
389 structure cannot be embedded inside another one. */
390 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
394 /* OpenMP statements (#pragma omp). */
396 struct gimple_statement_omp GTY(())
399 struct gimple_statement_base gsbase;
408 struct gimple_statement_bind GTY(())
411 struct gimple_statement_base gsbase;
414 Variables declared in this scope. */
418 This is different than the BLOCK field in gimple_statement_base,
419 which is analogous to TREE_BLOCK (i.e., the lexical block holding
420 this statement). This field is the equivalent of BIND_EXPR_BLOCK
421 in tree land (i.e., the lexical scope defined by this bind). See
432 struct gimple_statement_catch GTY(())
435 struct gimple_statement_base gsbase;
445 /* GIMPLE_EH_FILTER */
447 struct gimple_statement_eh_filter GTY(())
450 struct gimple_statement_base gsbase;
452 /* Subcode: EH_FILTER_MUST_NOT_THROW. A boolean flag analogous to
453 the tree counterpart. */
467 struct gimple_statement_phi GTY(())
470 struct gimple_statement_base gsbase;
480 struct phi_arg_d GTY ((length ("%h.nargs"))) args[1];
486 struct gimple_statement_resx GTY(())
489 struct gimple_statement_base gsbase;
492 Exception region number. */
499 struct gimple_statement_try GTY(())
502 struct gimple_statement_base gsbase;
505 Expression to evaluate. */
509 Cleanup expression. */
513 /* Kind of GIMPLE_TRY statements. */
514 enum gimple_try_flags
517 GIMPLE_TRY_CATCH = 1 << 0,
520 GIMPLE_TRY_FINALLY = 1 << 1,
521 GIMPLE_TRY_KIND = GIMPLE_TRY_CATCH | GIMPLE_TRY_FINALLY,
523 /* Analogous to TRY_CATCH_IS_CLEANUP. */
524 GIMPLE_TRY_CATCH_IS_CLEANUP = 1 << 2
527 /* GIMPLE_WITH_CLEANUP_EXPR */
529 struct gimple_statement_wce GTY(())
532 struct gimple_statement_base gsbase;
534 /* Subcode: CLEANUP_EH_ONLY. True if the cleanup should only be
535 executed if an exception is thrown, not on normal exit of its
536 scope. This flag is analogous to the CLEANUP_EH_ONLY flag
540 Cleanup expression. */
547 struct gimple_statement_asm GTY(())
550 struct gimple_statement_with_memory_ops_base membase;
553 __asm__ statement. */
557 Number of inputs, outputs and clobbers. */
563 Operand vector. NOTE! This must always be the last field
564 of this structure. In particular, this means that this
565 structure cannot be embedded inside another one. */
566 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
569 /* GIMPLE_OMP_CRITICAL */
571 struct gimple_statement_omp_critical GTY(())
574 struct gimple_statement_omp omp;
577 Critical section name. */
582 struct gimple_omp_for_iter GTY(())
584 /* Condition code. */
587 /* Index variable. */
602 struct gimple_statement_omp_for GTY(())
605 struct gimple_statement_omp omp;
611 Number of elements in iter array. */
615 struct gimple_omp_for_iter * GTY((length ("%h.collapse"))) iter;
618 Pre-body evaluated before the loop body begins. */
623 /* GIMPLE_OMP_PARALLEL */
625 struct gimple_statement_omp_parallel GTY(())
628 struct gimple_statement_omp omp;
635 Child function holding the body of the parallel region. */
639 Shared data argument. */
644 /* GIMPLE_OMP_TASK */
646 struct gimple_statement_omp_task GTY(())
649 struct gimple_statement_omp_parallel par;
652 Child function holding firstprivate initialization if needed. */
656 Size and alignment in bytes of the argument data block. */
662 /* GIMPLE_OMP_SECTION */
663 /* Uses struct gimple_statement_omp. */
666 /* GIMPLE_OMP_SECTIONS */
668 struct gimple_statement_omp_sections GTY(())
671 struct gimple_statement_omp omp;
677 The control variable used for deciding which of the sections to
682 /* GIMPLE_OMP_CONTINUE.
684 Note: This does not inherit from gimple_statement_omp, because we
685 do not need the body field. */
687 struct gimple_statement_omp_continue GTY(())
690 struct gimple_statement_base gsbase;
699 /* GIMPLE_OMP_SINGLE */
701 struct gimple_statement_omp_single GTY(())
704 struct gimple_statement_omp omp;
711 /* GIMPLE_OMP_ATOMIC_LOAD.
712 Note: This is based on gimple_statement_base, not g_s_omp, because g_s_omp
713 contains a sequence, which we don't need here. */
715 struct gimple_statement_omp_atomic_load GTY(())
718 struct gimple_statement_base gsbase;
724 /* GIMPLE_OMP_ATOMIC_STORE.
725 See note on GIMPLE_OMP_ATOMIC_LOAD. */
727 struct gimple_statement_omp_atomic_store GTY(())
730 struct gimple_statement_base gsbase;
736 enum gimple_statement_structure_enum {
737 #define DEFGSSTRUCT(SYM, STRING) SYM,
738 #include "gsstruct.def"
744 /* Define the overall contents of a gimple tuple. It may be any of the
745 structures declared above for various types of tuples. */
747 union gimple_statement_d GTY ((desc ("gimple_statement_structure (&%h)")))
749 struct gimple_statement_base GTY ((tag ("GSS_BASE"))) gsbase;
750 struct gimple_statement_with_ops GTY ((tag ("GSS_WITH_OPS"))) gsops;
751 struct gimple_statement_with_memory_ops GTY ((tag ("GSS_WITH_MEM_OPS"))) gsmem;
752 struct gimple_statement_omp GTY ((tag ("GSS_OMP"))) omp;
753 struct gimple_statement_bind GTY ((tag ("GSS_BIND"))) gimple_bind;
754 struct gimple_statement_catch GTY ((tag ("GSS_CATCH"))) gimple_catch;
755 struct gimple_statement_eh_filter GTY ((tag ("GSS_EH_FILTER"))) gimple_eh_filter;
756 struct gimple_statement_phi GTY ((tag ("GSS_PHI"))) gimple_phi;
757 struct gimple_statement_resx GTY ((tag ("GSS_RESX"))) gimple_resx;
758 struct gimple_statement_try GTY ((tag ("GSS_TRY"))) gimple_try;
759 struct gimple_statement_wce GTY ((tag ("GSS_WCE"))) gimple_wce;
760 struct gimple_statement_asm GTY ((tag ("GSS_ASM"))) gimple_asm;
761 struct gimple_statement_omp_critical GTY ((tag ("GSS_OMP_CRITICAL"))) gimple_omp_critical;
762 struct gimple_statement_omp_for GTY ((tag ("GSS_OMP_FOR"))) gimple_omp_for;
763 struct gimple_statement_omp_parallel GTY ((tag ("GSS_OMP_PARALLEL"))) gimple_omp_parallel;
764 struct gimple_statement_omp_task GTY ((tag ("GSS_OMP_TASK"))) gimple_omp_task;
765 struct gimple_statement_omp_sections GTY ((tag ("GSS_OMP_SECTIONS"))) gimple_omp_sections;
766 struct gimple_statement_omp_single GTY ((tag ("GSS_OMP_SINGLE"))) gimple_omp_single;
767 struct gimple_statement_omp_continue GTY ((tag ("GSS_OMP_CONTINUE"))) gimple_omp_continue;
768 struct gimple_statement_omp_atomic_load GTY ((tag ("GSS_OMP_ATOMIC_LOAD"))) gimple_omp_atomic_load;
769 struct gimple_statement_omp_atomic_store GTY ((tag ("GSS_OMP_ATOMIC_STORE"))) gimple_omp_atomic_store;
773 gimple gimple_build_return (tree);
775 gimple gimple_build_assign_stat (tree, tree MEM_STAT_DECL);
776 #define gimple_build_assign(l,r) gimple_build_assign_stat (l, r MEM_STAT_INFO)
778 void extract_ops_from_tree (tree, enum tree_code *, tree *, tree *);
780 gimple gimple_build_assign_with_ops_stat (enum tree_code, tree, tree,
782 #define gimple_build_assign_with_ops(c,o1,o2,o3) \
783 gimple_build_assign_with_ops_stat (c, o1, o2, o3 MEM_STAT_INFO)
785 gimple gimple_build_call_vec (tree, VEC(tree, heap) *);
786 gimple gimple_build_call (tree, unsigned, ...);
787 gimple gimple_build_call_from_tree (tree);
788 gimple gimplify_assign (tree, tree, gimple_seq *);
789 gimple gimple_build_cond (enum tree_code, tree, tree, tree, tree);
790 gimple gimple_build_label (tree label);
791 gimple gimple_build_goto (tree dest);
792 gimple gimple_build_nop (void);
793 gimple gimple_build_bind (tree, gimple_seq, tree);
794 gimple gimple_build_asm (const char *, unsigned, unsigned, unsigned, ...);
795 gimple gimple_build_asm_vec (const char *, VEC(tree,gc) *, VEC(tree,gc) *,
797 gimple gimple_build_catch (tree, gimple_seq);
798 gimple gimple_build_eh_filter (tree, gimple_seq);
799 gimple gimple_build_try (gimple_seq, gimple_seq, unsigned int);
800 gimple gimple_build_wce (gimple_seq);
801 gimple gimple_build_resx (int);
802 gimple gimple_build_switch (unsigned, tree, tree, ...);
803 gimple gimple_build_switch_vec (tree, tree, VEC(tree,heap) *);
804 gimple gimple_build_omp_parallel (gimple_seq, tree, tree, tree);
805 gimple gimple_build_omp_task (gimple_seq, tree, tree, tree, tree, tree, tree);
806 gimple gimple_build_omp_for (gimple_seq, tree, size_t, gimple_seq);
807 gimple gimple_build_omp_critical (gimple_seq, tree);
808 gimple gimple_build_omp_section (gimple_seq);
809 gimple gimple_build_omp_continue (tree, tree);
810 gimple gimple_build_omp_master (gimple_seq);
811 gimple gimple_build_omp_return (bool);
812 gimple gimple_build_omp_ordered (gimple_seq);
813 gimple gimple_build_omp_sections (gimple_seq, tree);
814 gimple gimple_build_omp_sections_switch (void);
815 gimple gimple_build_omp_single (gimple_seq, tree);
816 gimple gimple_build_cdt (tree, tree);
817 gimple gimple_build_omp_atomic_load (tree, tree);
818 gimple gimple_build_omp_atomic_store (tree);
819 gimple gimple_build_predict (enum br_predictor, enum prediction);
820 enum gimple_statement_structure_enum gimple_statement_structure (gimple);
821 enum gimple_statement_structure_enum gss_for_assign (enum tree_code);
822 void sort_case_labels (VEC(tree,heap) *);
823 void gimple_set_body (tree, gimple_seq);
824 gimple_seq gimple_body (tree);
825 gimple_seq gimple_seq_alloc (void);
826 void gimple_seq_free (gimple_seq);
827 void gimple_seq_add_seq (gimple_seq *, gimple_seq);
828 gimple_seq gimple_seq_copy (gimple_seq);
829 int gimple_call_flags (const_gimple);
830 bool gimple_assign_copy_p (gimple);
831 bool gimple_assign_ssa_name_copy_p (gimple);
832 bool gimple_assign_single_p (gimple);
833 bool gimple_assign_unary_nop_p (gimple);
834 void gimple_set_bb (gimple, struct basic_block_def *);
835 tree gimple_fold (const_gimple);
836 void gimple_assign_set_rhs_from_tree (gimple_stmt_iterator *, tree);
837 void gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *, enum tree_code,
839 tree gimple_get_lhs (const_gimple);
840 void gimple_set_lhs (gimple, tree);
841 gimple gimple_copy (gimple);
842 bool is_gimple_operand (const_tree);
843 void gimple_set_modified (gimple, bool);
844 void gimple_cond_get_ops_from_tree (tree, enum tree_code *, tree *, tree *);
845 gimple gimple_build_cond_from_tree (tree, tree, tree);
846 void gimple_cond_set_condition_from_tree (gimple, tree);
847 bool gimple_has_side_effects (const_gimple);
848 bool gimple_rhs_has_side_effects (const_gimple);
849 bool gimple_could_trap_p (gimple);
850 bool gimple_assign_rhs_could_trap_p (gimple);
851 void gimple_regimplify_operands (gimple, gimple_stmt_iterator *);
852 bool empty_body_p (gimple_seq);
853 unsigned get_gimple_rhs_num_ops (enum tree_code);
855 /* Returns true iff T is a valid GIMPLE statement. */
856 extern bool is_gimple_stmt (tree);
858 /* Returns true iff TYPE is a valid type for a scalar register variable. */
859 extern bool is_gimple_reg_type (tree);
860 /* Returns true iff T is a scalar register variable. */
861 extern bool is_gimple_reg (tree);
862 /* Returns true if T is a GIMPLE temporary variable, false otherwise. */
863 extern bool is_gimple_formal_tmp_var (tree);
864 /* Returns true if T is a GIMPLE temporary register variable. */
865 extern bool is_gimple_formal_tmp_reg (tree);
866 /* Returns true iff T is any sort of variable. */
867 extern bool is_gimple_variable (tree);
868 /* Returns true iff T is any sort of symbol. */
869 extern bool is_gimple_id (tree);
870 /* Returns true iff T is a variable or an INDIRECT_REF (of a variable). */
871 extern bool is_gimple_min_lval (tree);
872 /* Returns true iff T is something whose address can be taken. */
873 extern bool is_gimple_addressable (tree);
874 /* Returns true iff T is any valid GIMPLE lvalue. */
875 extern bool is_gimple_lvalue (tree);
877 /* Returns true iff T is a GIMPLE address. */
878 bool is_gimple_address (const_tree);
879 /* Returns true iff T is a GIMPLE invariant address. */
880 bool is_gimple_invariant_address (const_tree);
881 /* Returns true iff T is a GIMPLE invariant address at interprocedural
883 bool is_gimple_ip_invariant_address (const_tree);
884 /* Returns true iff T is a valid GIMPLE constant. */
885 bool is_gimple_constant (const_tree);
886 /* Returns true iff T is a GIMPLE restricted function invariant. */
887 extern bool is_gimple_min_invariant (const_tree);
888 /* Returns true iff T is a GIMPLE restricted interprecodural invariant. */
889 extern bool is_gimple_ip_invariant (const_tree);
890 /* Returns true iff T is a GIMPLE rvalue. */
891 extern bool is_gimple_val (tree);
892 /* Returns true iff T is a GIMPLE asm statement input. */
893 extern bool is_gimple_asm_val (tree);
894 /* Returns true iff T is a valid rhs for a MODIFY_EXPR where the LHS is a
895 GIMPLE temporary, a renamed user variable, or something else,
897 extern bool is_gimple_formal_tmp_rhs (tree);
898 extern bool is_gimple_reg_rhs (tree);
899 extern bool is_gimple_mem_rhs (tree);
901 /* Returns true iff T is a valid if-statement condition. */
902 extern bool is_gimple_condexpr (tree);
904 /* Returns true iff T is a type conversion. */
905 extern bool is_gimple_cast (tree);
906 /* Returns true iff T is a variable that does not need to live in memory. */
907 extern bool is_gimple_non_addressable (tree t);
909 /* Returns true iff T is a valid call address expression. */
910 extern bool is_gimple_call_addr (tree);
911 /* If T makes a function call, returns the CALL_EXPR operand. */
912 extern tree get_call_expr_in (tree t);
914 extern void recalculate_side_effects (tree);
917 extern tree create_tmp_var_raw (tree, const char *);
918 extern tree create_tmp_var_name (const char *);
919 extern tree create_tmp_var (tree, const char *);
920 extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq *);
921 extern tree get_formal_tmp_var (tree, gimple_seq *);
922 extern void declare_vars (tree, gimple, bool);
923 extern void tree_annotate_all_with_location (tree *, location_t);
924 extern void annotate_all_with_location (gimple_seq, location_t);
926 /* Validation of GIMPLE expressions. Note that these predicates only check
927 the basic form of the expression, they don't recurse to make sure that
928 underlying nodes are also of the right form. */
929 typedef bool (*gimple_predicate)(tree);
932 /* FIXME we should deduce this from the predicate. */
933 typedef enum fallback_t {
934 fb_none = 0, /* Do not generate a temporary. */
936 fb_rvalue = 1, /* Generate an rvalue to hold the result of a
937 gimplified expression. */
939 fb_lvalue = 2, /* Generate an lvalue to hold the result of a
940 gimplified expression. */
942 fb_mayfail = 4, /* Gimplification may fail. Error issued
944 fb_either= fb_rvalue | fb_lvalue
947 enum gimplify_status {
948 GS_ERROR = -2, /* Something Bad Seen. */
949 GS_UNHANDLED = -1, /* A langhook result for "I dunno". */
950 GS_OK = 0, /* We did something, maybe more to do. */
951 GS_ALL_DONE = 1 /* The expression is fully gimplified. */
956 struct gimplify_ctx *prev_context;
958 VEC(gimple,heap) *bind_expr_stack;
960 gimple_seq conditional_cleanups;
964 VEC(tree,heap) *case_labels;
965 /* The formal temporary table. Should this be persistent? */
971 bool allow_rhs_cond_expr;
974 extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *,
975 bool (*) (tree), fallback_t);
976 extern void gimplify_type_sizes (tree, gimple_seq *);
977 extern void gimplify_one_sizepos (tree *, gimple_seq *);
978 extern bool gimplify_stmt (tree *, gimple_seq *);
979 extern gimple gimplify_body (tree *, tree, bool);
980 extern void push_gimplify_context (struct gimplify_ctx *);
981 extern void pop_gimplify_context (gimple);
982 extern void gimplify_and_add (tree, gimple_seq *);
984 /* Miscellaneous helpers. */
985 extern void gimple_add_tmp_var (tree);
986 extern gimple gimple_current_bind_expr (void);
987 extern VEC(gimple, heap) *gimple_bind_expr_stack (void);
988 extern tree voidify_wrapper_expr (tree, tree);
989 extern tree build_and_jump (tree *);
990 extern tree alloc_stmt_list (void);
991 extern void free_stmt_list (tree);
992 extern tree force_labels_r (tree *, int *, void *);
993 extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *,
995 struct gimplify_omp_ctx;
996 extern void omp_firstprivatize_variable (struct gimplify_omp_ctx *, tree);
997 extern tree gimple_boolify (tree);
998 extern gimple_predicate rhs_predicate_for (tree);
999 extern tree canonicalize_cond_expr_cond (tree);
1002 extern void diagnose_omp_structured_block_errors (tree);
1003 extern tree omp_reduction_init (tree, tree);
1005 /* In tree-nested.c. */
1006 extern void lower_nested_functions (tree);
1007 extern void insert_field_into_struct (tree, tree);
1009 /* In gimplify.c. */
1010 extern void gimplify_function_tree (tree);
1012 /* In cfgexpand.c. */
1013 extern tree gimple_assign_rhs_to_tree (gimple);
1016 extern bool validate_gimple_arglist (const_gimple, ...);
1018 /* In tree-ssa-operands.c */
1019 extern void gimple_add_to_addresses_taken (gimple, tree);
1022 extern bool tree_ssa_useless_type_conversion (tree);
1023 extern bool useless_type_conversion_p (tree, tree);
1024 extern bool types_compatible_p (tree, tree);
1026 /* Return the code for GIMPLE statement G. */
1028 static inline enum gimple_code
1029 gimple_code (const_gimple g)
1031 return g->gsbase.code;
1035 /* Return true if statement G has sub-statements. This is only true for
1036 High GIMPLE statements. */
1039 gimple_has_substatements (gimple g)
1041 switch (gimple_code (g))
1045 case GIMPLE_EH_FILTER:
1047 case GIMPLE_OMP_FOR:
1048 case GIMPLE_OMP_MASTER:
1049 case GIMPLE_OMP_ORDERED:
1050 case GIMPLE_OMP_SECTION:
1051 case GIMPLE_OMP_PARALLEL:
1052 case GIMPLE_OMP_TASK:
1053 case GIMPLE_OMP_SECTIONS:
1054 case GIMPLE_OMP_SINGLE:
1055 case GIMPLE_WITH_CLEANUP_EXPR:
1064 /* Return the basic block holding statement G. */
1066 static inline struct basic_block_def *
1067 gimple_bb (const_gimple g)
1069 return g->gsbase.bb;
1073 /* Return the lexical scope block holding statement G. */
1076 gimple_block (const_gimple g)
1078 return g->gsbase.block;
1082 /* Set BLOCK to be the lexical scope block holding statement G. */
1085 gimple_set_block (gimple g, tree block)
1087 g->gsbase.block = block;
1091 /* Return location information for statement G. */
1093 static inline location_t
1094 gimple_location (const_gimple g)
1096 return g->gsbase.location;
1099 /* Return pointer to location information for statement G. */
1101 static inline const location_t *
1102 gimple_location_ptr (const_gimple g)
1104 return &g->gsbase.location;
1108 /* Set location information for statement G. */
1111 gimple_set_location (gimple g, location_t location)
1113 g->gsbase.location = location;
1117 /* Return true if G contains location information. */
1120 gimple_has_location (const_gimple g)
1122 return gimple_location (g) != UNKNOWN_LOCATION;
1126 /* Return the file name of the location of STMT. */
1128 static inline const char *
1129 gimple_filename (const_gimple stmt)
1131 return LOCATION_FILE (gimple_location (stmt));
1135 /* Return the line number of the location of STMT. */
1138 gimple_lineno (const_gimple stmt)
1140 return LOCATION_LINE (gimple_location (stmt));
1144 /* Determine whether SEQ is a singleton. */
1147 gimple_seq_singleton_p (gimple_seq seq)
1149 return ((gimple_seq_first (seq) != NULL)
1150 && (gimple_seq_first (seq) == gimple_seq_last (seq)));
1153 /* Return true if no warnings should be emitted for statement STMT. */
1156 gimple_no_warning_p (const_gimple stmt)
1158 return stmt->gsbase.no_warning;
1161 /* Set the no_warning flag of STMT to NO_WARNING. */
1164 gimple_set_no_warning (gimple stmt, bool no_warning)
1166 stmt->gsbase.no_warning = (unsigned) no_warning;
1169 /* Set the visited status on statement STMT to VISITED_P. */
1172 gimple_set_visited (gimple stmt, bool visited_p)
1174 stmt->gsbase.visited = (unsigned) visited_p;
1178 /* Return the visited status for statement STMT. */
1181 gimple_visited_p (gimple stmt)
1183 return stmt->gsbase.visited;
1187 /* Set pass local flag PLF on statement STMT to VAL_P. */
1190 gimple_set_plf (gimple stmt, enum plf_mask plf, bool val_p)
1193 stmt->gsbase.plf |= (unsigned int) plf;
1195 stmt->gsbase.plf &= ~((unsigned int) plf);
1199 /* Return the value of pass local flag PLF on statement STMT. */
1201 static inline unsigned int
1202 gimple_plf (gimple stmt, enum plf_mask plf)
1204 return stmt->gsbase.plf & ((unsigned int) plf);
1208 /* Set the uid of statement */
1211 gimple_set_uid (gimple g, unsigned uid)
1213 g->gsbase.uid = uid;
1217 /* Return the uid of statement */
1219 static inline unsigned
1220 gimple_uid (const_gimple g)
1222 return g->gsbase.uid;
1226 /* Return true if GIMPLE statement G has register or memory operands. */
1229 gimple_has_ops (const_gimple g)
1231 return gimple_code (g) >= GIMPLE_COND && gimple_code (g) <= GIMPLE_RETURN;
1235 /* Return true if GIMPLE statement G has memory operands. */
1238 gimple_has_mem_ops (const_gimple g)
1240 return gimple_code (g) >= GIMPLE_ASSIGN && gimple_code (g) <= GIMPLE_RETURN;
1243 /* Return the set of addresses taken by statement G. */
1245 static inline bitmap
1246 gimple_addresses_taken (const_gimple g)
1248 if (gimple_has_ops (g))
1249 return g->gsops.opbase.addresses_taken;
1255 /* Return a pointer to the set of addresses taken by statement G. */
1257 static inline bitmap *
1258 gimple_addresses_taken_ptr (gimple g)
1260 if (gimple_has_ops (g))
1261 return &g->gsops.opbase.addresses_taken;
1267 /* Set B to be the set of addresses taken by statement G. The
1268 previous set is freed. */
1271 gimple_set_addresses_taken (gimple g, bitmap b)
1273 gcc_assert (gimple_has_ops (g));
1274 BITMAP_FREE (g->gsops.opbase.addresses_taken);
1275 g->gsops.opbase.addresses_taken = b;
1279 /* Return the set of DEF operands for statement G. */
1281 static inline struct def_optype_d *
1282 gimple_def_ops (const_gimple g)
1284 if (!gimple_has_ops (g))
1286 return g->gsops.opbase.def_ops;
1290 /* Set DEF to be the set of DEF operands for statement G. */
1293 gimple_set_def_ops (gimple g, struct def_optype_d *def)
1295 gcc_assert (gimple_has_ops (g));
1296 g->gsops.opbase.def_ops = def;
1300 /* Return the set of USE operands for statement G. */
1302 static inline struct use_optype_d *
1303 gimple_use_ops (const_gimple g)
1305 if (!gimple_has_ops (g))
1307 return g->gsops.opbase.use_ops;
1311 /* Set USE to be the set of USE operands for statement G. */
1314 gimple_set_use_ops (gimple g, struct use_optype_d *use)
1316 gcc_assert (gimple_has_ops (g));
1317 g->gsops.opbase.use_ops = use;
1321 /* Return the set of VUSE operands for statement G. */
1323 static inline struct voptype_d *
1324 gimple_vuse_ops (const_gimple g)
1326 if (!gimple_has_mem_ops (g))
1328 return g->gsmem.membase.vuse_ops;
1332 /* Set OPS to be the set of VUSE operands for statement G. */
1335 gimple_set_vuse_ops (gimple g, struct voptype_d *ops)
1337 gcc_assert (gimple_has_mem_ops (g));
1338 g->gsmem.membase.vuse_ops = ops;
1342 /* Return the set of VDEF operands for statement G. */
1344 static inline struct voptype_d *
1345 gimple_vdef_ops (const_gimple g)
1347 if (!gimple_has_mem_ops (g))
1349 return g->gsmem.membase.vdef_ops;
1353 /* Set OPS to be the set of VDEF operands for statement G. */
1356 gimple_set_vdef_ops (gimple g, struct voptype_d *ops)
1358 gcc_assert (gimple_has_mem_ops (g));
1359 g->gsmem.membase.vdef_ops = ops;
1363 /* Return the set of symbols loaded by statement G. Each element of the
1364 set is the DECL_UID of the corresponding symbol. */
1366 static inline bitmap
1367 gimple_loaded_syms (const_gimple g)
1369 if (!gimple_has_mem_ops (g))
1371 return g->gsmem.membase.loads;
1375 /* Return the set of symbols stored by statement G. Each element of
1376 the set is the DECL_UID of the corresponding symbol. */
1378 static inline bitmap
1379 gimple_stored_syms (const_gimple g)
1381 if (!gimple_has_mem_ops (g))
1383 return g->gsmem.membase.stores;
1387 /* Return true if statement G has operands and the modified field has
1391 gimple_modified_p (const_gimple g)
1393 return (gimple_has_ops (g)) ? (bool) g->gsbase.modified : false;
1396 /* Return the type of the main expression computed by STMT. Return
1397 void_type_node if the statement computes nothing. */
1400 gimple_expr_type (const_gimple stmt)
1402 enum gimple_code code = gimple_code (stmt);
1404 if (code == GIMPLE_ASSIGN || code == GIMPLE_CALL)
1406 tree type = TREE_TYPE (gimple_get_lhs (stmt));
1407 /* Integral sub-types are never the type of the expression,
1408 but they still can be the type of the result as the base
1409 type (in which expressions are computed) is trivially
1410 convertible to one of its sub-types. So always return
1411 the base type here. */
1412 if (INTEGRAL_TYPE_P (type)
1414 /* But only if they are trivially convertible. */
1415 && useless_type_conversion_p (type, TREE_TYPE (type)))
1416 type = TREE_TYPE (type);
1419 else if (code == GIMPLE_COND)
1420 return boolean_type_node;
1422 return void_type_node;
1426 /* Return the tree code for the expression computed by STMT. This is
1427 only valid for GIMPLE_COND, GIMPLE_CALL and GIMPLE_ASSIGN. For
1428 GIMPLE_CALL, return CALL_EXPR as the expression code for
1429 consistency. This is useful when the caller needs to deal with the
1430 three kinds of computation that GIMPLE supports. */
1432 static inline enum tree_code
1433 gimple_expr_code (const_gimple stmt)
1435 enum gimple_code code = gimple_code (stmt);
1436 if (code == GIMPLE_ASSIGN || code == GIMPLE_COND)
1437 return (enum tree_code) stmt->gsbase.subcode;
1438 else if (code == GIMPLE_CALL)
1445 /* Mark statement S as modified, and update it. */
1448 update_stmt (gimple s)
1450 if (gimple_has_ops (s))
1452 gimple_set_modified (s, true);
1453 update_stmt_operands (s);
1457 /* Update statement S if it has been optimized. */
1460 update_stmt_if_modified (gimple s)
1462 if (gimple_modified_p (s))
1463 update_stmt_operands (s);
1466 /* Return true if statement STMT contains volatile operands. */
1469 gimple_has_volatile_ops (const_gimple stmt)
1471 if (gimple_has_mem_ops (stmt))
1472 return stmt->gsbase.has_volatile_ops;
1478 /* Set the HAS_VOLATILE_OPS flag to VOLATILEP. */
1481 gimple_set_has_volatile_ops (gimple stmt, bool volatilep)
1483 if (gimple_has_mem_ops (stmt))
1484 stmt->gsbase.has_volatile_ops = (unsigned) volatilep;
1488 /* Return true if statement STMT may access memory. */
1491 gimple_references_memory_p (gimple stmt)
1493 return gimple_has_mem_ops (stmt) && stmt->gsbase.references_memory_p;
1497 /* Set the REFERENCES_MEMORY_P flag for STMT to MEM_P. */
1500 gimple_set_references_memory (gimple stmt, bool mem_p)
1502 if (gimple_has_mem_ops (stmt))
1503 stmt->gsbase.references_memory_p = (unsigned) mem_p;
1506 /* Return the subcode for OMP statement S. */
1508 static inline unsigned
1509 gimple_omp_subcode (const_gimple s)
1511 gcc_assert (gimple_code (s) >= GIMPLE_OMP_ATOMIC_LOAD
1512 && gimple_code (s) <= GIMPLE_OMP_SINGLE);
1513 return s->gsbase.subcode;
1516 /* Set the subcode for OMP statement S to SUBCODE. */
1519 gimple_omp_set_subcode (gimple s, unsigned int subcode)
1521 /* We only have 16 bits for the subcode. Assert that we are not
1523 gcc_assert (subcode < (1 << 16));
1524 s->gsbase.subcode = subcode;
1527 /* Set the nowait flag on OMP_RETURN statement S. */
1530 gimple_omp_return_set_nowait (gimple s)
1532 GIMPLE_CHECK (s, GIMPLE_OMP_RETURN);
1533 s->gsbase.subcode |= GF_OMP_RETURN_NOWAIT;
1537 /* Return true if OMP return statement G has the GF_OMP_RETURN_NOWAIT
1541 gimple_omp_return_nowait_p (const_gimple g)
1543 GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
1544 return (gimple_omp_subcode (g) & GF_OMP_RETURN_NOWAIT) != 0;
1548 /* Return true if OMP section statement G has the GF_OMP_SECTION_LAST
1552 gimple_omp_section_last_p (const_gimple g)
1554 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1555 return (gimple_omp_subcode (g) & GF_OMP_SECTION_LAST) != 0;
1559 /* Set the GF_OMP_SECTION_LAST flag on G. */
1562 gimple_omp_section_set_last (gimple g)
1564 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1565 g->gsbase.subcode |= GF_OMP_SECTION_LAST;
1569 /* Return true if OMP parallel statement G has the
1570 GF_OMP_PARALLEL_COMBINED flag set. */
1573 gimple_omp_parallel_combined_p (const_gimple g)
1575 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1576 return (gimple_omp_subcode (g) & GF_OMP_PARALLEL_COMBINED) != 0;
1580 /* Set the GF_OMP_PARALLEL_COMBINED field in G depending on the boolean
1581 value of COMBINED_P. */
1584 gimple_omp_parallel_set_combined_p (gimple g, bool combined_p)
1586 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1588 g->gsbase.subcode |= GF_OMP_PARALLEL_COMBINED;
1590 g->gsbase.subcode &= ~GF_OMP_PARALLEL_COMBINED;
1594 /* Return the number of operands for statement GS. */
1596 static inline unsigned
1597 gimple_num_ops (const_gimple gs)
1599 return gs->gsbase.num_ops;
1603 /* Set the number of operands for statement GS. */
1606 gimple_set_num_ops (gimple gs, unsigned num_ops)
1608 gs->gsbase.num_ops = num_ops;
1612 /* Return the array of operands for statement GS. */
1614 static inline tree *
1615 gimple_ops (gimple gs)
1617 /* Offset in bytes to the location of the operand vector in every
1618 tuple structure. Defined in gimple.c */
1619 extern size_t const gimple_ops_offset_[];
1621 if (!gimple_has_ops (gs))
1624 /* All the tuples have their operand vector at the very bottom
1625 of the structure. */
1626 return ((tree *) ((char *) gs + gimple_ops_offset_[gimple_code (gs)]));
1630 /* Return operand I for statement GS. */
1633 gimple_op (const_gimple gs, unsigned i)
1635 if (gimple_has_ops (gs))
1637 gcc_assert (i < gimple_num_ops (gs));
1638 return gimple_ops (CONST_CAST_GIMPLE (gs))[i];
1644 /* Return a pointer to operand I for statement GS. */
1646 static inline tree *
1647 gimple_op_ptr (const_gimple gs, unsigned i)
1649 if (gimple_has_ops (gs))
1651 gcc_assert (i < gimple_num_ops (gs));
1652 return gimple_ops (CONST_CAST_GIMPLE (gs)) + i;
1658 /* Set operand I of statement GS to OP. */
1661 gimple_set_op (gimple gs, unsigned i, tree op)
1663 gcc_assert (gimple_has_ops (gs) && i < gimple_num_ops (gs));
1665 /* Note. It may be tempting to assert that OP matches
1666 is_gimple_operand, but that would be wrong. Different tuples
1667 accept slightly different sets of tree operands. Each caller
1668 should perform its own validation. */
1669 gimple_ops (gs)[i] = op;
1672 /* Return true if GS is a GIMPLE_ASSIGN. */
1675 is_gimple_assign (const_gimple gs)
1677 return gimple_code (gs) == GIMPLE_ASSIGN;
1680 /* Determine if expression CODE is one of the valid expressions that can
1681 be used on the RHS of GIMPLE assignments. */
1683 static inline enum gimple_rhs_class
1684 get_gimple_rhs_class (enum tree_code code)
1686 return (enum gimple_rhs_class) gimple_rhs_class_table[(int) code];
1689 /* Return the LHS of assignment statement GS. */
1692 gimple_assign_lhs (const_gimple gs)
1694 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1695 return gimple_op (gs, 0);
1699 /* Return a pointer to the LHS of assignment statement GS. */
1701 static inline tree *
1702 gimple_assign_lhs_ptr (const_gimple gs)
1704 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1705 return gimple_op_ptr (gs, 0);
1709 /* Set LHS to be the LHS operand of assignment statement GS. */
1712 gimple_assign_set_lhs (gimple gs, tree lhs)
1714 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1715 gcc_assert (is_gimple_operand (lhs));
1716 gimple_set_op (gs, 0, lhs);
1718 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1719 SSA_NAME_DEF_STMT (lhs) = gs;
1723 /* Return the first operand on the RHS of assignment statement GS. */
1726 gimple_assign_rhs1 (const_gimple gs)
1728 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1729 return gimple_op (gs, 1);
1733 /* Return a pointer to the first operand on the RHS of assignment
1736 static inline tree *
1737 gimple_assign_rhs1_ptr (const_gimple gs)
1739 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1740 return gimple_op_ptr (gs, 1);
1743 /* Set RHS to be the first operand on the RHS of assignment statement GS. */
1746 gimple_assign_set_rhs1 (gimple gs, tree rhs)
1748 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1750 /* If there are 3 or more operands, the 2 operands on the RHS must be
1752 if (gimple_num_ops (gs) >= 3)
1753 gcc_assert (is_gimple_val (rhs));
1755 gcc_assert (is_gimple_operand (rhs));
1757 gimple_set_op (gs, 1, rhs);
1761 /* Return the second operand on the RHS of assignment statement GS.
1762 If GS does not have two operands, NULL is returned instead. */
1765 gimple_assign_rhs2 (const_gimple gs)
1767 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1769 if (gimple_num_ops (gs) >= 3)
1770 return gimple_op (gs, 2);
1776 /* Return a pointer to the second operand on the RHS of assignment
1779 static inline tree *
1780 gimple_assign_rhs2_ptr (const_gimple gs)
1782 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1783 return gimple_op_ptr (gs, 2);
1787 /* Set RHS to be the second operand on the RHS of assignment statement GS. */
1790 gimple_assign_set_rhs2 (gimple gs, tree rhs)
1792 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1794 /* The 2 operands on the RHS must be GIMPLE values. */
1795 gcc_assert (is_gimple_val (rhs));
1797 gimple_set_op (gs, 2, rhs);
1800 /* Returns true if GS is a nontemporal move. */
1803 gimple_assign_nontemporal_move_p (const_gimple gs)
1805 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1806 return gs->gsbase.nontemporal_move;
1809 /* Sets nontemporal move flag of GS to NONTEMPORAL. */
1812 gimple_assign_set_nontemporal_move (gimple gs, bool nontemporal)
1814 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1815 gs->gsbase.nontemporal_move = nontemporal;
1819 /* Return the code of the expression computed on the rhs of assignment
1820 statement GS. In case that the RHS is a single object, returns the
1821 tree code of the object. */
1823 static inline enum tree_code
1824 gimple_assign_rhs_code (const_gimple gs)
1826 enum tree_code code;
1827 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1829 code = gimple_expr_code (gs);
1830 if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS)
1831 code = TREE_CODE (gimple_assign_rhs1 (gs));
1837 /* Set CODE to be the code for the expression computed on the RHS of
1841 gimple_assign_set_rhs_code (gimple s, enum tree_code code)
1843 GIMPLE_CHECK (s, GIMPLE_ASSIGN);
1844 s->gsbase.subcode = code;
1848 /* Return the gimple rhs class of the code of the expression computed on
1849 the rhs of assignment statement GS.
1850 This will never return GIMPLE_INVALID_RHS. */
1852 static inline enum gimple_rhs_class
1853 gimple_assign_rhs_class (const_gimple gs)
1855 return get_gimple_rhs_class (gimple_assign_rhs_code (gs));
1859 /* Return true if S is a type-cast assignment. */
1862 gimple_assign_cast_p (gimple s)
1864 if (is_gimple_assign (s))
1866 enum tree_code sc = gimple_assign_rhs_code (s);
1867 return CONVERT_EXPR_CODE_P (sc)
1868 || sc == VIEW_CONVERT_EXPR
1869 || sc == FIX_TRUNC_EXPR;
1876 /* Return true if GS is a GIMPLE_CALL. */
1879 is_gimple_call (const_gimple gs)
1881 return gimple_code (gs) == GIMPLE_CALL;
1884 /* Return the LHS of call statement GS. */
1887 gimple_call_lhs (const_gimple gs)
1889 GIMPLE_CHECK (gs, GIMPLE_CALL);
1890 return gimple_op (gs, 0);
1894 /* Return a pointer to the LHS of call statement GS. */
1896 static inline tree *
1897 gimple_call_lhs_ptr (const_gimple gs)
1899 GIMPLE_CHECK (gs, GIMPLE_CALL);
1900 return gimple_op_ptr (gs, 0);
1904 /* Set LHS to be the LHS operand of call statement GS. */
1907 gimple_call_set_lhs (gimple gs, tree lhs)
1909 GIMPLE_CHECK (gs, GIMPLE_CALL);
1910 gcc_assert (!lhs || is_gimple_operand (lhs));
1911 gimple_set_op (gs, 0, lhs);
1912 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1913 SSA_NAME_DEF_STMT (lhs) = gs;
1917 /* Return the tree node representing the function called by call
1921 gimple_call_fn (const_gimple gs)
1923 GIMPLE_CHECK (gs, GIMPLE_CALL);
1924 return gimple_op (gs, 1);
1928 /* Return a pointer to the tree node representing the function called by call
1931 static inline tree *
1932 gimple_call_fn_ptr (const_gimple gs)
1934 GIMPLE_CHECK (gs, GIMPLE_CALL);
1935 return gimple_op_ptr (gs, 1);
1939 /* Set FN to be the function called by call statement GS. */
1942 gimple_call_set_fn (gimple gs, tree fn)
1944 GIMPLE_CHECK (gs, GIMPLE_CALL);
1945 gcc_assert (is_gimple_operand (fn));
1946 gimple_set_op (gs, 1, fn);
1950 /* Set FNDECL to be the function called by call statement GS. */
1953 gimple_call_set_fndecl (gimple gs, tree decl)
1955 GIMPLE_CHECK (gs, GIMPLE_CALL);
1956 gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
1957 gimple_set_op (gs, 1, build_fold_addr_expr (decl));
1961 /* If a given GIMPLE_CALL's callee is a FUNCTION_DECL, return it.
1962 Otherwise return NULL. This function is analogous to
1963 get_callee_fndecl in tree land. */
1966 gimple_call_fndecl (const_gimple gs)
1968 tree addr = gimple_call_fn (gs);
1969 if (TREE_CODE (addr) == ADDR_EXPR)
1971 gcc_assert (TREE_CODE (TREE_OPERAND (addr, 0)) == FUNCTION_DECL);
1972 return TREE_OPERAND (addr, 0);
1978 /* Return the type returned by call statement GS. */
1981 gimple_call_return_type (const_gimple gs)
1983 tree fn = gimple_call_fn (gs);
1984 tree type = TREE_TYPE (fn);
1986 /* See through the pointer. */
1987 gcc_assert (POINTER_TYPE_P (type));
1988 type = TREE_TYPE (type);
1990 gcc_assert (TREE_CODE (type) == FUNCTION_TYPE
1991 || TREE_CODE (type) == METHOD_TYPE);
1993 /* The type returned by a FUNCTION_DECL is the type of its
1995 return TREE_TYPE (type);
1999 /* Return the static chain for call statement GS. */
2002 gimple_call_chain (const_gimple gs)
2004 GIMPLE_CHECK (gs, GIMPLE_CALL);
2005 return gimple_op (gs, 2);
2009 /* Return a pointer to the static chain for call statement GS. */
2011 static inline tree *
2012 gimple_call_chain_ptr (const_gimple gs)
2014 GIMPLE_CHECK (gs, GIMPLE_CALL);
2015 return gimple_op_ptr (gs, 2);
2018 /* Set CHAIN to be the static chain for call statement GS. */
2021 gimple_call_set_chain (gimple gs, tree chain)
2023 GIMPLE_CHECK (gs, GIMPLE_CALL);
2024 gcc_assert (chain == NULL
2025 || TREE_CODE (chain) == ADDR_EXPR
2026 || SSA_VAR_P (chain));
2027 gimple_set_op (gs, 2, chain);
2031 /* Return the number of arguments used by call statement GS. */
2033 static inline unsigned
2034 gimple_call_num_args (const_gimple gs)
2037 GIMPLE_CHECK (gs, GIMPLE_CALL);
2038 num_ops = gimple_num_ops (gs);
2039 gcc_assert (num_ops >= 3);
2044 /* Return the argument at position INDEX for call statement GS. */
2047 gimple_call_arg (const_gimple gs, unsigned index)
2049 GIMPLE_CHECK (gs, GIMPLE_CALL);
2050 return gimple_op (gs, index + 3);
2054 /* Return a pointer to the argument at position INDEX for call
2057 static inline tree *
2058 gimple_call_arg_ptr (const_gimple gs, unsigned index)
2060 GIMPLE_CHECK (gs, GIMPLE_CALL);
2061 return gimple_op_ptr (gs, index + 3);
2065 /* Set ARG to be the argument at position INDEX for call statement GS. */
2068 gimple_call_set_arg (gimple gs, unsigned index, tree arg)
2070 GIMPLE_CHECK (gs, GIMPLE_CALL);
2071 gcc_assert (is_gimple_operand (arg));
2072 gimple_set_op (gs, index + 3, arg);
2076 /* If TAIL_P is true, mark call statement S as being a tail call
2077 (i.e., a call just before the exit of a function). These calls are
2078 candidate for tail call optimization. */
2081 gimple_call_set_tail (gimple s, bool tail_p)
2083 GIMPLE_CHECK (s, GIMPLE_CALL);
2085 s->gsbase.subcode |= GF_CALL_TAILCALL;
2087 s->gsbase.subcode &= ~GF_CALL_TAILCALL;
2091 /* Return true if GIMPLE_CALL S is marked as a tail call. */
2094 gimple_call_tail_p (gimple s)
2096 GIMPLE_CHECK (s, GIMPLE_CALL);
2097 return (s->gsbase.subcode & GF_CALL_TAILCALL) != 0;
2101 /* Set the inlinable status of GIMPLE_CALL S to INLINABLE_P. */
2104 gimple_call_set_cannot_inline (gimple s, bool inlinable_p)
2106 GIMPLE_CHECK (s, GIMPLE_CALL);
2108 s->gsbase.subcode |= GF_CALL_CANNOT_INLINE;
2110 s->gsbase.subcode &= ~GF_CALL_CANNOT_INLINE;
2114 /* Return true if GIMPLE_CALL S cannot be inlined. */
2117 gimple_call_cannot_inline_p (gimple s)
2119 GIMPLE_CHECK (s, GIMPLE_CALL);
2120 return (s->gsbase.subcode & GF_CALL_CANNOT_INLINE) != 0;
2124 /* If RETURN_SLOT_OPT_P is true mark GIMPLE_CALL S as valid for return
2125 slot optimization. This transformation uses the target of the call
2126 expansion as the return slot for calls that return in memory. */
2129 gimple_call_set_return_slot_opt (gimple s, bool return_slot_opt_p)
2131 GIMPLE_CHECK (s, GIMPLE_CALL);
2132 if (return_slot_opt_p)
2133 s->gsbase.subcode |= GF_CALL_RETURN_SLOT_OPT;
2135 s->gsbase.subcode &= ~GF_CALL_RETURN_SLOT_OPT;
2139 /* Return true if S is marked for return slot optimization. */
2142 gimple_call_return_slot_opt_p (gimple s)
2144 GIMPLE_CHECK (s, GIMPLE_CALL);
2145 return (s->gsbase.subcode & GF_CALL_RETURN_SLOT_OPT) != 0;
2149 /* If FROM_THUNK_P is true, mark GIMPLE_CALL S as being the jump from a
2150 thunk to the thunked-to function. */
2153 gimple_call_set_from_thunk (gimple s, bool from_thunk_p)
2155 GIMPLE_CHECK (s, GIMPLE_CALL);
2157 s->gsbase.subcode |= GF_CALL_FROM_THUNK;
2159 s->gsbase.subcode &= ~GF_CALL_FROM_THUNK;
2163 /* Return true if GIMPLE_CALL S is a jump from a thunk. */
2166 gimple_call_from_thunk_p (gimple s)
2168 GIMPLE_CHECK (s, GIMPLE_CALL);
2169 return (s->gsbase.subcode & GF_CALL_FROM_THUNK) != 0;
2173 /* If PASS_ARG_PACK_P is true, GIMPLE_CALL S is a stdarg call that needs the
2174 argument pack in its argument list. */
2177 gimple_call_set_va_arg_pack (gimple s, bool pass_arg_pack_p)
2179 GIMPLE_CHECK (s, GIMPLE_CALL);
2180 if (pass_arg_pack_p)
2181 s->gsbase.subcode |= GF_CALL_VA_ARG_PACK;
2183 s->gsbase.subcode &= ~GF_CALL_VA_ARG_PACK;
2187 /* Return true if GIMPLE_CALL S is a stdarg call that needs the
2188 argument pack in its argument list. */
2191 gimple_call_va_arg_pack_p (gimple s)
2193 GIMPLE_CHECK (s, GIMPLE_CALL);
2194 return (s->gsbase.subcode & GF_CALL_VA_ARG_PACK) != 0;
2198 /* Return true if S is a noreturn call. */
2201 gimple_call_noreturn_p (gimple s)
2203 GIMPLE_CHECK (s, GIMPLE_CALL);
2204 return (gimple_call_flags (s) & ECF_NORETURN) != 0;
2208 /* Return true if S is a nothrow call. */
2211 gimple_call_nothrow_p (gimple s)
2213 GIMPLE_CHECK (s, GIMPLE_CALL);
2214 return (gimple_call_flags (s) & ECF_NOTHROW) != 0;
2218 /* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL. */
2221 gimple_call_copy_flags (gimple dest_call, gimple orig_call)
2223 GIMPLE_CHECK (dest_call, GIMPLE_CALL);
2224 GIMPLE_CHECK (orig_call, GIMPLE_CALL);
2225 dest_call->gsbase.subcode = orig_call->gsbase.subcode;
2229 /* Returns true if this is a GIMPLE_ASSIGN or a GIMPLE_CALL with a
2233 gimple_has_lhs (gimple stmt)
2235 return (is_gimple_assign (stmt)
2236 || (is_gimple_call (stmt)
2237 && gimple_call_lhs (stmt) != NULL_TREE));
2241 /* Return the code of the predicate computed by conditional statement GS. */
2243 static inline enum tree_code
2244 gimple_cond_code (const_gimple gs)
2246 GIMPLE_CHECK (gs, GIMPLE_COND);
2247 return gs->gsbase.subcode;
2251 /* Set CODE to be the predicate code for the conditional statement GS. */
2254 gimple_cond_set_code (gimple gs, enum tree_code code)
2256 GIMPLE_CHECK (gs, GIMPLE_COND);
2257 gcc_assert (TREE_CODE_CLASS (code) == tcc_comparison);
2258 gs->gsbase.subcode = code;
2262 /* Return the LHS of the predicate computed by conditional statement GS. */
2265 gimple_cond_lhs (const_gimple gs)
2267 GIMPLE_CHECK (gs, GIMPLE_COND);
2268 return gimple_op (gs, 0);
2271 /* Return the pointer to the LHS of the predicate computed by conditional
2274 static inline tree *
2275 gimple_cond_lhs_ptr (const_gimple gs)
2277 GIMPLE_CHECK (gs, GIMPLE_COND);
2278 return gimple_op_ptr (gs, 0);
2281 /* Set LHS to be the LHS operand of the predicate computed by
2282 conditional statement GS. */
2285 gimple_cond_set_lhs (gimple gs, tree lhs)
2287 GIMPLE_CHECK (gs, GIMPLE_COND);
2288 gcc_assert (is_gimple_operand (lhs));
2289 gimple_set_op (gs, 0, lhs);
2293 /* Return the RHS operand of the predicate computed by conditional GS. */
2296 gimple_cond_rhs (const_gimple gs)
2298 GIMPLE_CHECK (gs, GIMPLE_COND);
2299 return gimple_op (gs, 1);
2302 /* Return the pointer to the RHS operand of the predicate computed by
2305 static inline tree *
2306 gimple_cond_rhs_ptr (const_gimple gs)
2308 GIMPLE_CHECK (gs, GIMPLE_COND);
2309 return gimple_op_ptr (gs, 1);
2313 /* Set RHS to be the RHS operand of the predicate computed by
2314 conditional statement GS. */
2317 gimple_cond_set_rhs (gimple gs, tree rhs)
2319 GIMPLE_CHECK (gs, GIMPLE_COND);
2320 gcc_assert (is_gimple_operand (rhs));
2321 gimple_set_op (gs, 1, rhs);
2325 /* Return the label used by conditional statement GS when its
2326 predicate evaluates to true. */
2329 gimple_cond_true_label (const_gimple gs)
2331 GIMPLE_CHECK (gs, GIMPLE_COND);
2332 return gimple_op (gs, 2);
2336 /* Set LABEL to be the label used by conditional statement GS when its
2337 predicate evaluates to true. */
2340 gimple_cond_set_true_label (gimple gs, tree label)
2342 GIMPLE_CHECK (gs, GIMPLE_COND);
2343 gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
2344 gimple_set_op (gs, 2, label);
2348 /* Set LABEL to be the label used by conditional statement GS when its
2349 predicate evaluates to false. */
2352 gimple_cond_set_false_label (gimple gs, tree label)
2354 GIMPLE_CHECK (gs, GIMPLE_COND);
2355 gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
2356 gimple_set_op (gs, 3, label);
2360 /* Return the label used by conditional statement GS when its
2361 predicate evaluates to false. */
2364 gimple_cond_false_label (const_gimple gs)
2366 GIMPLE_CHECK (gs, GIMPLE_COND);
2367 return gimple_op (gs, 3);
2371 /* Set the conditional COND_STMT to be of the form 'if (1 == 0)'. */
2374 gimple_cond_make_false (gimple gs)
2376 gimple_cond_set_lhs (gs, boolean_true_node);
2377 gimple_cond_set_rhs (gs, boolean_false_node);
2378 gs->gsbase.subcode = EQ_EXPR;
2382 /* Set the conditional COND_STMT to be of the form 'if (1 == 1)'. */
2385 gimple_cond_make_true (gimple gs)
2387 gimple_cond_set_lhs (gs, boolean_true_node);
2388 gimple_cond_set_rhs (gs, boolean_true_node);
2389 gs->gsbase.subcode = EQ_EXPR;
2392 /* Check if conditional statemente GS is of the form 'if (1 == 1)',
2393 'if (0 == 0)', 'if (1 != 0)' or 'if (0 != 1)' */
2396 gimple_cond_true_p (const_gimple gs)
2398 tree lhs = gimple_cond_lhs (gs);
2399 tree rhs = gimple_cond_rhs (gs);
2400 enum tree_code code = gimple_cond_code (gs);
2402 if (lhs != boolean_true_node && lhs != boolean_false_node)
2405 if (rhs != boolean_true_node && rhs != boolean_false_node)
2408 if (code == NE_EXPR && lhs != rhs)
2411 if (code == EQ_EXPR && lhs == rhs)
2417 /* Check if conditional statement GS is of the form 'if (1 != 1)',
2418 'if (0 != 0)', 'if (1 == 0)' or 'if (0 == 1)' */
2421 gimple_cond_false_p (const_gimple gs)
2423 tree lhs = gimple_cond_lhs (gs);
2424 tree rhs = gimple_cond_rhs (gs);
2425 enum tree_code code = gimple_cond_code (gs);
2427 if (lhs != boolean_true_node && lhs != boolean_false_node)
2430 if (rhs != boolean_true_node && rhs != boolean_false_node)
2433 if (code == NE_EXPR && lhs == rhs)
2436 if (code == EQ_EXPR && lhs != rhs)
2442 /* Check if conditional statement GS is of the form 'if (var != 0)' or
2446 gimple_cond_single_var_p (gimple gs)
2448 if (gimple_cond_code (gs) == NE_EXPR
2449 && gimple_cond_rhs (gs) == boolean_false_node)
2452 if (gimple_cond_code (gs) == EQ_EXPR
2453 && gimple_cond_rhs (gs) == boolean_true_node)
2459 /* Set the code, LHS and RHS of GIMPLE_COND STMT from CODE, LHS and RHS. */
2462 gimple_cond_set_condition (gimple stmt, enum tree_code code, tree lhs, tree rhs)
2464 gimple_cond_set_code (stmt, code);
2465 gimple_cond_set_lhs (stmt, lhs);
2466 gimple_cond_set_rhs (stmt, rhs);
2469 /* Return the LABEL_DECL node used by GIMPLE_LABEL statement GS. */
2472 gimple_label_label (const_gimple gs)
2474 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2475 return gimple_op (gs, 0);
2479 /* Set LABEL to be the LABEL_DECL node used by GIMPLE_LABEL statement
2483 gimple_label_set_label (gimple gs, tree label)
2485 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2486 gcc_assert (TREE_CODE (label) == LABEL_DECL);
2487 gimple_set_op (gs, 0, label);
2491 /* Return the destination of the unconditional jump GS. */
2494 gimple_goto_dest (const_gimple gs)
2496 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2497 return gimple_op (gs, 0);
2501 /* Set DEST to be the destination of the unconditonal jump GS. */
2504 gimple_goto_set_dest (gimple gs, tree dest)
2506 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2507 gcc_assert (is_gimple_operand (dest));
2508 gimple_set_op (gs, 0, dest);
2512 /* Return the variables declared in the GIMPLE_BIND statement GS. */
2515 gimple_bind_vars (const_gimple gs)
2517 GIMPLE_CHECK (gs, GIMPLE_BIND);
2518 return gs->gimple_bind.vars;
2522 /* Set VARS to be the set of variables declared in the GIMPLE_BIND
2526 gimple_bind_set_vars (gimple gs, tree vars)
2528 GIMPLE_CHECK (gs, GIMPLE_BIND);
2529 gs->gimple_bind.vars = vars;
2533 /* Append VARS to the set of variables declared in the GIMPLE_BIND
2537 gimple_bind_append_vars (gimple gs, tree vars)
2539 GIMPLE_CHECK (gs, GIMPLE_BIND);
2540 gs->gimple_bind.vars = chainon (gs->gimple_bind.vars, vars);
2544 /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS. */
2546 static inline gimple_seq
2547 gimple_bind_body (gimple gs)
2549 GIMPLE_CHECK (gs, GIMPLE_BIND);
2550 return gs->gimple_bind.body;
2554 /* Set SEQ to be the GIMPLE sequence contained in the GIMPLE_BIND
2558 gimple_bind_set_body (gimple gs, gimple_seq seq)
2560 GIMPLE_CHECK (gs, GIMPLE_BIND);
2561 gs->gimple_bind.body = seq;
2565 /* Append a statement to the end of a GIMPLE_BIND's body. */
2568 gimple_bind_add_stmt (gimple gs, gimple stmt)
2570 GIMPLE_CHECK (gs, GIMPLE_BIND);
2571 gimple_seq_add_stmt (&gs->gimple_bind.body, stmt);
2575 /* Append a sequence of statements to the end of a GIMPLE_BIND's body. */
2578 gimple_bind_add_seq (gimple gs, gimple_seq seq)
2580 GIMPLE_CHECK (gs, GIMPLE_BIND);
2581 gimple_seq_add_seq (&gs->gimple_bind.body, seq);
2585 /* Return the TREE_BLOCK node associated with GIMPLE_BIND statement
2586 GS. This is analogous to the BIND_EXPR_BLOCK field in trees. */
2589 gimple_bind_block (const_gimple gs)
2591 GIMPLE_CHECK (gs, GIMPLE_BIND);
2592 return gs->gimple_bind.block;
2596 /* Set BLOCK to be the TREE_BLOCK node associated with GIMPLE_BIND
2600 gimple_bind_set_block (gimple gs, tree block)
2602 GIMPLE_CHECK (gs, GIMPLE_BIND);
2603 gcc_assert (TREE_CODE (block) == BLOCK);
2604 gs->gimple_bind.block = block;
2608 /* Return the number of input operands for GIMPLE_ASM GS. */
2610 static inline unsigned
2611 gimple_asm_ninputs (const_gimple gs)
2613 GIMPLE_CHECK (gs, GIMPLE_ASM);
2614 return gs->gimple_asm.ni;
2618 /* Return the number of output operands for GIMPLE_ASM GS. */
2620 static inline unsigned
2621 gimple_asm_noutputs (const_gimple gs)
2623 GIMPLE_CHECK (gs, GIMPLE_ASM);
2624 return gs->gimple_asm.no;
2628 /* Return the number of clobber operands for GIMPLE_ASM GS. */
2630 static inline unsigned
2631 gimple_asm_nclobbers (const_gimple gs)
2633 GIMPLE_CHECK (gs, GIMPLE_ASM);
2634 return gs->gimple_asm.nc;
2638 /* Return input operand INDEX of GIMPLE_ASM GS. */
2641 gimple_asm_input_op (const_gimple gs, unsigned index)
2643 GIMPLE_CHECK (gs, GIMPLE_ASM);
2644 gcc_assert (index <= gs->gimple_asm.ni);
2645 return gimple_op (gs, index);
2648 /* Return a pointer to input operand INDEX of GIMPLE_ASM GS. */
2650 static inline tree *
2651 gimple_asm_input_op_ptr (const_gimple gs, unsigned index)
2653 GIMPLE_CHECK (gs, GIMPLE_ASM);
2654 gcc_assert (index <= gs->gimple_asm.ni);
2655 return gimple_op_ptr (gs, index);
2659 /* Set IN_OP to be input operand INDEX in GIMPLE_ASM GS. */
2662 gimple_asm_set_input_op (gimple gs, unsigned index, tree in_op)
2664 GIMPLE_CHECK (gs, GIMPLE_ASM);
2665 gcc_assert (index <= gs->gimple_asm.ni);
2666 gcc_assert (TREE_CODE (in_op) == TREE_LIST);
2667 gimple_set_op (gs, index, in_op);
2671 /* Return output operand INDEX of GIMPLE_ASM GS. */
2674 gimple_asm_output_op (const_gimple gs, unsigned index)
2676 GIMPLE_CHECK (gs, GIMPLE_ASM);
2677 gcc_assert (index <= gs->gimple_asm.no);
2678 return gimple_op (gs, index + gs->gimple_asm.ni);
2681 /* Return a pointer to output operand INDEX of GIMPLE_ASM GS. */
2683 static inline tree *
2684 gimple_asm_output_op_ptr (const_gimple gs, unsigned index)
2686 GIMPLE_CHECK (gs, GIMPLE_ASM);
2687 gcc_assert (index <= gs->gimple_asm.no);
2688 return gimple_op_ptr (gs, index + gs->gimple_asm.ni);
2692 /* Set OUT_OP to be output operand INDEX in GIMPLE_ASM GS. */
2695 gimple_asm_set_output_op (gimple gs, unsigned index, tree out_op)
2697 GIMPLE_CHECK (gs, GIMPLE_ASM);
2698 gcc_assert (index <= gs->gimple_asm.no);
2699 gcc_assert (TREE_CODE (out_op) == TREE_LIST);
2700 gimple_set_op (gs, index + gs->gimple_asm.ni, out_op);
2704 /* Return clobber operand INDEX of GIMPLE_ASM GS. */
2707 gimple_asm_clobber_op (const_gimple gs, unsigned index)
2709 GIMPLE_CHECK (gs, GIMPLE_ASM);
2710 gcc_assert (index <= gs->gimple_asm.nc);
2711 return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no);
2715 /* Set CLOBBER_OP to be clobber operand INDEX in GIMPLE_ASM GS. */
2718 gimple_asm_set_clobber_op (gimple gs, unsigned index, tree clobber_op)
2720 GIMPLE_CHECK (gs, GIMPLE_ASM);
2721 gcc_assert (index <= gs->gimple_asm.nc);
2722 gcc_assert (TREE_CODE (clobber_op) == TREE_LIST);
2723 gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no, clobber_op);
2727 /* Return the string representing the assembly instruction in
2730 static inline const char *
2731 gimple_asm_string (const_gimple gs)
2733 GIMPLE_CHECK (gs, GIMPLE_ASM);
2734 return gs->gimple_asm.string;
2738 /* Return true if GS is an asm statement marked volatile. */
2741 gimple_asm_volatile_p (const_gimple gs)
2743 GIMPLE_CHECK (gs, GIMPLE_ASM);
2744 return (gs->gsbase.subcode & GF_ASM_VOLATILE) != 0;
2748 /* If VOLATLE_P is true, mark asm statement GS as volatile. */
2751 gimple_asm_set_volatile (gimple gs, bool volatile_p)
2753 GIMPLE_CHECK (gs, GIMPLE_ASM);
2755 gs->gsbase.subcode |= GF_ASM_VOLATILE;
2757 gs->gsbase.subcode &= ~GF_ASM_VOLATILE;
2761 /* If INPUT_P is true, mark asm GS as an ASM_INPUT. */
2764 gimple_asm_set_input (gimple gs, bool input_p)
2766 GIMPLE_CHECK (gs, GIMPLE_ASM);
2768 gs->gsbase.subcode |= GF_ASM_INPUT;
2770 gs->gsbase.subcode &= ~GF_ASM_INPUT;
2774 /* Return true if asm GS is an ASM_INPUT. */
2777 gimple_asm_input_p (const_gimple gs)
2779 GIMPLE_CHECK (gs, GIMPLE_ASM);
2780 return (gs->gsbase.subcode & GF_ASM_INPUT) != 0;
2784 /* Return the types handled by GIMPLE_CATCH statement GS. */
2787 gimple_catch_types (const_gimple gs)
2789 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2790 return gs->gimple_catch.types;
2794 /* Return a pointer to the types handled by GIMPLE_CATCH statement GS. */
2796 static inline tree *
2797 gimple_catch_types_ptr (gimple gs)
2799 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2800 return &gs->gimple_catch.types;
2804 /* Return the GIMPLE sequence representing the body of the handler of
2805 GIMPLE_CATCH statement GS. */
2807 static inline gimple_seq
2808 gimple_catch_handler (gimple gs)
2810 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2811 return gs->gimple_catch.handler;
2815 /* Return a pointer to the GIMPLE sequence representing the body of
2816 the handler of GIMPLE_CATCH statement GS. */
2818 static inline gimple_seq *
2819 gimple_catch_handler_ptr (gimple gs)
2821 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2822 return &gs->gimple_catch.handler;
2826 /* Set T to be the set of types handled by GIMPLE_CATCH GS. */
2829 gimple_catch_set_types (gimple gs, tree t)
2831 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2832 gs->gimple_catch.types = t;
2836 /* Set HANDLER to be the body of GIMPLE_CATCH GS. */
2839 gimple_catch_set_handler (gimple gs, gimple_seq handler)
2841 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2842 gs->gimple_catch.handler = handler;
2846 /* Return the types handled by GIMPLE_EH_FILTER statement GS. */
2849 gimple_eh_filter_types (const_gimple gs)
2851 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2852 return gs->gimple_eh_filter.types;
2856 /* Return a pointer to the types handled by GIMPLE_EH_FILTER statement
2859 static inline tree *
2860 gimple_eh_filter_types_ptr (gimple gs)
2862 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2863 return &gs->gimple_eh_filter.types;
2867 /* Return the sequence of statement to execute when GIMPLE_EH_FILTER
2870 static inline gimple_seq
2871 gimple_eh_filter_failure (gimple gs)
2873 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2874 return gs->gimple_eh_filter.failure;
2878 /* Set TYPES to be the set of types handled by GIMPLE_EH_FILTER GS. */
2881 gimple_eh_filter_set_types (gimple gs, tree types)
2883 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2884 gs->gimple_eh_filter.types = types;
2888 /* Set FAILURE to be the sequence of statements to execute on failure
2889 for GIMPLE_EH_FILTER GS. */
2892 gimple_eh_filter_set_failure (gimple gs, gimple_seq failure)
2894 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2895 gs->gimple_eh_filter.failure = failure;
2898 /* Return the EH_FILTER_MUST_NOT_THROW flag. */
2902 gimple_eh_filter_must_not_throw (gimple gs)
2904 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2905 return gs->gsbase.subcode != 0;
2908 /* Set the EH_FILTER_MUST_NOT_THROW flag to the value MNTP. */
2911 gimple_eh_filter_set_must_not_throw (gimple gs, bool mntp)
2913 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2914 gs->gsbase.subcode = (unsigned int) mntp;
2918 /* GIMPLE_TRY accessors. */
2920 /* Return the kind of try block represented by GIMPLE_TRY GS. This is
2921 either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY. */
2923 static inline enum gimple_try_flags
2924 gimple_try_kind (const_gimple gs)
2926 GIMPLE_CHECK (gs, GIMPLE_TRY);
2927 return (enum gimple_try_flags) (gs->gsbase.subcode & GIMPLE_TRY_KIND);
2931 /* Set the kind of try block represented by GIMPLE_TRY GS. */
2934 gimple_try_set_kind (gimple gs, enum gimple_try_flags kind)
2936 GIMPLE_CHECK (gs, GIMPLE_TRY);
2937 gcc_assert (kind == GIMPLE_TRY_CATCH || kind == GIMPLE_TRY_FINALLY);
2938 if (gimple_try_kind (gs) != kind)
2939 gs->gsbase.subcode = (unsigned int) kind;
2943 /* Return the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2946 gimple_try_catch_is_cleanup (const_gimple gs)
2948 gcc_assert (gimple_try_kind (gs) == GIMPLE_TRY_CATCH);
2949 return (gs->gsbase.subcode & GIMPLE_TRY_CATCH_IS_CLEANUP) != 0;
2953 /* Return the sequence of statements used as the body for GIMPLE_TRY GS. */
2955 static inline gimple_seq
2956 gimple_try_eval (gimple gs)
2958 GIMPLE_CHECK (gs, GIMPLE_TRY);
2959 return gs->gimple_try.eval;
2963 /* Return the sequence of statements used as the cleanup body for
2966 static inline gimple_seq
2967 gimple_try_cleanup (gimple gs)
2969 GIMPLE_CHECK (gs, GIMPLE_TRY);
2970 return gs->gimple_try.cleanup;
2974 /* Set the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2977 gimple_try_set_catch_is_cleanup (gimple g, bool catch_is_cleanup)
2979 gcc_assert (gimple_try_kind (g) == GIMPLE_TRY_CATCH);
2980 if (catch_is_cleanup)
2981 g->gsbase.subcode |= GIMPLE_TRY_CATCH_IS_CLEANUP;
2983 g->gsbase.subcode &= ~GIMPLE_TRY_CATCH_IS_CLEANUP;
2987 /* Set EVAL to be the sequence of statements to use as the body for
2991 gimple_try_set_eval (gimple gs, gimple_seq eval)
2993 GIMPLE_CHECK (gs, GIMPLE_TRY);
2994 gs->gimple_try.eval = eval;
2998 /* Set CLEANUP to be the sequence of statements to use as the cleanup
2999 body for GIMPLE_TRY GS. */
3002 gimple_try_set_cleanup (gimple gs, gimple_seq cleanup)
3004 GIMPLE_CHECK (gs, GIMPLE_TRY);
3005 gs->gimple_try.cleanup = cleanup;
3009 /* Return the cleanup sequence for cleanup statement GS. */
3011 static inline gimple_seq
3012 gimple_wce_cleanup (gimple gs)
3014 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3015 return gs->gimple_wce.cleanup;
3019 /* Set CLEANUP to be the cleanup sequence for GS. */
3022 gimple_wce_set_cleanup (gimple gs, gimple_seq cleanup)
3024 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3025 gs->gimple_wce.cleanup = cleanup;
3029 /* Return the CLEANUP_EH_ONLY flag for a WCE tuple. */
3032 gimple_wce_cleanup_eh_only (const_gimple gs)
3034 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3035 return gs->gsbase.subcode != 0;
3039 /* Set the CLEANUP_EH_ONLY flag for a WCE tuple. */
3042 gimple_wce_set_cleanup_eh_only (gimple gs, bool eh_only_p)
3044 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3045 gs->gsbase.subcode = (unsigned int) eh_only_p;
3049 /* Return the maximum number of arguments supported by GIMPLE_PHI GS. */
3051 static inline unsigned
3052 gimple_phi_capacity (const_gimple gs)
3054 GIMPLE_CHECK (gs, GIMPLE_PHI);
3055 return gs->gimple_phi.capacity;
3059 /* Return the number of arguments in GIMPLE_PHI GS. This must always
3060 be exactly the number of incoming edges for the basic block holding
3063 static inline unsigned
3064 gimple_phi_num_args (const_gimple gs)
3066 GIMPLE_CHECK (gs, GIMPLE_PHI);
3067 return gs->gimple_phi.nargs;
3071 /* Return the SSA name created by GIMPLE_PHI GS. */
3074 gimple_phi_result (const_gimple gs)
3076 GIMPLE_CHECK (gs, GIMPLE_PHI);
3077 return gs->gimple_phi.result;
3080 /* Return a pointer to the SSA name created by GIMPLE_PHI GS. */
3082 static inline tree *
3083 gimple_phi_result_ptr (gimple gs)
3085 GIMPLE_CHECK (gs, GIMPLE_PHI);
3086 return &gs->gimple_phi.result;
3089 /* Set RESULT to be the SSA name created by GIMPLE_PHI GS. */
3092 gimple_phi_set_result (gimple gs, tree result)
3094 GIMPLE_CHECK (gs, GIMPLE_PHI);
3095 gs->gimple_phi.result = result;
3099 /* Return the PHI argument corresponding to incoming edge INDEX for
3102 static inline struct phi_arg_d *
3103 gimple_phi_arg (gimple gs, unsigned index)
3105 GIMPLE_CHECK (gs, GIMPLE_PHI);
3106 gcc_assert (index <= gs->gimple_phi.capacity);
3107 return &(gs->gimple_phi.args[index]);
3110 /* Set PHIARG to be the argument corresponding to incoming edge INDEX
3111 for GIMPLE_PHI GS. */
3114 gimple_phi_set_arg (gimple gs, unsigned index, struct phi_arg_d * phiarg)
3116 GIMPLE_CHECK (gs, GIMPLE_PHI);
3117 gcc_assert (index <= gs->gimple_phi.nargs);
3118 memcpy (gs->gimple_phi.args + index, phiarg, sizeof (struct phi_arg_d));
3121 /* Return the region number for GIMPLE_RESX GS. */
3124 gimple_resx_region (const_gimple gs)
3126 GIMPLE_CHECK (gs, GIMPLE_RESX);
3127 return gs->gimple_resx.region;
3130 /* Set REGION to be the region number for GIMPLE_RESX GS. */
3133 gimple_resx_set_region (gimple gs, int region)
3135 GIMPLE_CHECK (gs, GIMPLE_RESX);
3136 gs->gimple_resx.region = region;
3140 /* Return the number of labels associated with the switch statement GS. */
3142 static inline unsigned
3143 gimple_switch_num_labels (const_gimple gs)
3146 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3147 num_ops = gimple_num_ops (gs);
3148 gcc_assert (num_ops > 1);
3153 /* Set NLABELS to be the number of labels for the switch statement GS. */
3156 gimple_switch_set_num_labels (gimple g, unsigned nlabels)
3158 GIMPLE_CHECK (g, GIMPLE_SWITCH);
3159 gimple_set_num_ops (g, nlabels + 1);
3163 /* Return the index variable used by the switch statement GS. */
3166 gimple_switch_index (const_gimple gs)
3168 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3169 return gimple_op (gs, 0);
3173 /* Return a pointer to the index variable for the switch statement GS. */
3175 static inline tree *
3176 gimple_switch_index_ptr (const_gimple gs)
3178 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3179 return gimple_op_ptr (gs, 0);
3183 /* Set INDEX to be the index variable for switch statement GS. */
3186 gimple_switch_set_index (gimple gs, tree index)
3188 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3189 gcc_assert (SSA_VAR_P (index) || CONSTANT_CLASS_P (index));
3190 gimple_set_op (gs, 0, index);
3194 /* Return the label numbered INDEX. The default label is 0, followed by any
3195 labels in a switch statement. */
3198 gimple_switch_label (const_gimple gs, unsigned index)
3200 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3201 gcc_assert (gimple_num_ops (gs) > index + 1);
3202 return gimple_op (gs, index + 1);
3205 /* Set the label number INDEX to LABEL. 0 is always the default label. */
3208 gimple_switch_set_label (gimple gs, unsigned index, tree label)
3210 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3211 gcc_assert (gimple_num_ops (gs) > index + 1);
3212 gcc_assert (label == NULL_TREE || TREE_CODE (label) == CASE_LABEL_EXPR);
3213 gimple_set_op (gs, index + 1, label);
3216 /* Return the default label for a switch statement. */
3219 gimple_switch_default_label (const_gimple gs)
3221 return gimple_switch_label (gs, 0);
3224 /* Set the default label for a switch statement. */
3227 gimple_switch_set_default_label (gimple gs, tree label)
3229 gimple_switch_set_label (gs, 0, label);
3233 /* Return the body for the OMP statement GS. */
3235 static inline gimple_seq
3236 gimple_omp_body (gimple gs)
3238 return gs->omp.body;
3241 /* Set BODY to be the body for the OMP statement GS. */
3244 gimple_omp_set_body (gimple gs, gimple_seq body)
3246 gs->omp.body = body;
3250 /* Return the name associated with OMP_CRITICAL statement GS. */
3253 gimple_omp_critical_name (const_gimple gs)
3255 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3256 return gs->gimple_omp_critical.name;
3260 /* Return a pointer to the name associated with OMP critical statement GS. */
3262 static inline tree *
3263 gimple_omp_critical_name_ptr (gimple gs)
3265 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3266 return &gs->gimple_omp_critical.name;
3270 /* Set NAME to be the name associated with OMP critical statement GS. */
3273 gimple_omp_critical_set_name (gimple gs, tree name)
3275 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3276 gs->gimple_omp_critical.name = name;
3280 /* Return the clauses associated with OMP_FOR GS. */
3283 gimple_omp_for_clauses (const_gimple gs)
3285 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3286 return gs->gimple_omp_for.clauses;
3290 /* Return a pointer to the OMP_FOR GS. */
3292 static inline tree *
3293 gimple_omp_for_clauses_ptr (gimple gs)
3295 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3296 return &gs->gimple_omp_for.clauses;
3300 /* Set CLAUSES to be the list of clauses associated with OMP_FOR GS. */
3303 gimple_omp_for_set_clauses (gimple gs, tree clauses)
3305 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3306 gs->gimple_omp_for.clauses = clauses;
3310 /* Get the collapse count of OMP_FOR GS. */
3312 static inline size_t
3313 gimple_omp_for_collapse (gimple gs)
3315 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3316 return gs->gimple_omp_for.collapse;
3320 /* Return the index variable for OMP_FOR GS. */
3323 gimple_omp_for_index (const_gimple gs, size_t i)
3325 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3326 gcc_assert (i < gs->gimple_omp_for.collapse);
3327 return gs->gimple_omp_for.iter[i].index;
3331 /* Return a pointer to the index variable for OMP_FOR GS. */
3333 static inline tree *
3334 gimple_omp_for_index_ptr (gimple gs, size_t i)
3336 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3337 gcc_assert (i < gs->gimple_omp_for.collapse);
3338 return &gs->gimple_omp_for.iter[i].index;
3342 /* Set INDEX to be the index variable for OMP_FOR GS. */
3345 gimple_omp_for_set_index (gimple gs, size_t i, tree index)
3347 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3348 gcc_assert (i < gs->gimple_omp_for.collapse);
3349 gs->gimple_omp_for.iter[i].index = index;
3353 /* Return the initial value for OMP_FOR GS. */
3356 gimple_omp_for_initial (const_gimple gs, size_t i)
3358 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3359 gcc_assert (i < gs->gimple_omp_for.collapse);
3360 return gs->gimple_omp_for.iter[i].initial;
3364 /* Return a pointer to the initial value for OMP_FOR GS. */
3366 static inline tree *
3367 gimple_omp_for_initial_ptr (gimple gs, size_t i)
3369 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3370 gcc_assert (i < gs->gimple_omp_for.collapse);
3371 return &gs->gimple_omp_for.iter[i].initial;
3375 /* Set INITIAL to be the initial value for OMP_FOR GS. */
3378 gimple_omp_for_set_initial (gimple gs, size_t i, tree initial)
3380 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3381 gcc_assert (i < gs->gimple_omp_for.collapse);
3382 gs->gimple_omp_for.iter[i].initial = initial;
3386 /* Return the final value for OMP_FOR GS. */
3389 gimple_omp_for_final (const_gimple gs, size_t i)
3391 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3392 gcc_assert (i < gs->gimple_omp_for.collapse);
3393 return gs->gimple_omp_for.iter[i].final;
3397 /* Return a pointer to the final value for OMP_FOR GS. */
3399 static inline tree *
3400 gimple_omp_for_final_ptr (gimple gs, size_t i)
3402 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3403 gcc_assert (i < gs->gimple_omp_for.collapse);
3404 return &gs->gimple_omp_for.iter[i].final;
3408 /* Set FINAL to be the final value for OMP_FOR GS. */
3411 gimple_omp_for_set_final (gimple gs, size_t i, tree final)
3413 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3414 gcc_assert (i < gs->gimple_omp_for.collapse);
3415 gs->gimple_omp_for.iter[i].final = final;
3419 /* Return the increment value for OMP_FOR GS. */
3422 gimple_omp_for_incr (const_gimple gs, size_t i)
3424 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3425 gcc_assert (i < gs->gimple_omp_for.collapse);
3426 return gs->gimple_omp_for.iter[i].incr;
3430 /* Return a pointer to the increment value for OMP_FOR GS. */
3432 static inline tree *
3433 gimple_omp_for_incr_ptr (gimple gs, size_t i)
3435 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3436 gcc_assert (i < gs->gimple_omp_for.collapse);
3437 return &gs->gimple_omp_for.iter[i].incr;
3441 /* Set INCR to be the increment value for OMP_FOR GS. */
3444 gimple_omp_for_set_incr (gimple gs, size_t i, tree incr)
3446 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3447 gcc_assert (i < gs->gimple_omp_for.collapse);
3448 gs->gimple_omp_for.iter[i].incr = incr;
3452 /* Return the sequence of statements to execute before the OMP_FOR
3453 statement GS starts. */
3455 static inline gimple_seq
3456 gimple_omp_for_pre_body (gimple gs)
3458 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3459 return gs->gimple_omp_for.pre_body;
3463 /* Set PRE_BODY to be the sequence of statements to execute before the
3464 OMP_FOR statement GS starts. */
3467 gimple_omp_for_set_pre_body (gimple gs, gimple_seq pre_body)
3469 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3470 gs->gimple_omp_for.pre_body = pre_body;
3474 /* Return the clauses associated with OMP_PARALLEL GS. */
3477 gimple_omp_parallel_clauses (const_gimple gs)
3479 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3480 return gs->gimple_omp_parallel.clauses;
3484 /* Return a pointer to the clauses associated with OMP_PARALLEL GS. */
3486 static inline tree *
3487 gimple_omp_parallel_clauses_ptr (gimple gs)
3489 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3490 return &gs->gimple_omp_parallel.clauses;
3494 /* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL
3498 gimple_omp_parallel_set_clauses (gimple gs, tree clauses)
3500 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3501 gs->gimple_omp_parallel.clauses = clauses;
3505 /* Return the child function used to hold the body of OMP_PARALLEL GS. */
3508 gimple_omp_parallel_child_fn (const_gimple gs)
3510 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3511 return gs->gimple_omp_parallel.child_fn;
3514 /* Return a pointer to the child function used to hold the body of
3517 static inline tree *
3518 gimple_omp_parallel_child_fn_ptr (gimple gs)
3520 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3521 return &gs->gimple_omp_parallel.child_fn;
3525 /* Set CHILD_FN to be the child function for OMP_PARALLEL GS. */
3528 gimple_omp_parallel_set_child_fn (gimple gs, tree child_fn)
3530 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3531 gs->gimple_omp_parallel.child_fn = child_fn;
3535 /* Return the artificial argument used to send variables and values
3536 from the parent to the children threads in OMP_PARALLEL GS. */
3539 gimple_omp_parallel_data_arg (const_gimple gs)
3541 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3542 return gs->gimple_omp_parallel.data_arg;
3546 /* Return a pointer to the data argument for OMP_PARALLEL GS. */
3548 static inline tree *
3549 gimple_omp_parallel_data_arg_ptr (gimple gs)
3551 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3552 return &gs->gimple_omp_parallel.data_arg;
3556 /* Set DATA_ARG to be the data argument for OMP_PARALLEL GS. */
3559 gimple_omp_parallel_set_data_arg (gimple gs, tree data_arg)
3561 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3562 gs->gimple_omp_parallel.data_arg = data_arg;
3566 /* Return the clauses associated with OMP_TASK GS. */
3569 gimple_omp_task_clauses (const_gimple gs)
3571 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3572 return gs->gimple_omp_parallel.clauses;
3576 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3578 static inline tree *
3579 gimple_omp_task_clauses_ptr (gimple gs)
3581 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3582 return &gs->gimple_omp_parallel.clauses;
3586 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3590 gimple_omp_task_set_clauses (gimple gs, tree clauses)
3592 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3593 gs->gimple_omp_parallel.clauses = clauses;
3597 /* Return the child function used to hold the body of OMP_TASK GS. */
3600 gimple_omp_task_child_fn (const_gimple gs)
3602 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3603 return gs->gimple_omp_parallel.child_fn;
3606 /* Return a pointer to the child function used to hold the body of
3609 static inline tree *
3610 gimple_omp_task_child_fn_ptr (gimple gs)
3612 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3613 return &gs->gimple_omp_parallel.child_fn;
3617 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3620 gimple_omp_task_set_child_fn (gimple gs, tree child_fn)
3622 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3623 gs->gimple_omp_parallel.child_fn = child_fn;
3627 /* Return the artificial argument used to send variables and values
3628 from the parent to the children threads in OMP_TASK GS. */
3631 gimple_omp_task_data_arg (const_gimple gs)
3633 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3634 return gs->gimple_omp_parallel.data_arg;
3638 /* Return a pointer to the data argument for OMP_TASK GS. */
3640 static inline tree *
3641 gimple_omp_task_data_arg_ptr (gimple gs)
3643 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3644 return &gs->gimple_omp_parallel.data_arg;
3648 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3651 gimple_omp_task_set_data_arg (gimple gs, tree data_arg)
3653 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3654 gs->gimple_omp_parallel.data_arg = data_arg;
3658 /* Return the clauses associated with OMP_TASK GS. */
3661 gimple_omp_taskreg_clauses (const_gimple gs)
3663 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3664 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3665 return gs->gimple_omp_parallel.clauses;
3669 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3671 static inline tree *
3672 gimple_omp_taskreg_clauses_ptr (gimple gs)
3674 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3675 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3676 return &gs->gimple_omp_parallel.clauses;
3680 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3684 gimple_omp_taskreg_set_clauses (gimple gs, tree clauses)
3686 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3687 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3688 gs->gimple_omp_parallel.clauses = clauses;
3692 /* Return the child function used to hold the body of OMP_TASK GS. */
3695 gimple_omp_taskreg_child_fn (const_gimple gs)
3697 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3698 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3699 return gs->gimple_omp_parallel.child_fn;
3702 /* Return a pointer to the child function used to hold the body of
3705 static inline tree *
3706 gimple_omp_taskreg_child_fn_ptr (gimple gs)
3708 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3709 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3710 return &gs->gimple_omp_parallel.child_fn;
3714 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3717 gimple_omp_taskreg_set_child_fn (gimple gs, tree child_fn)
3719 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3720 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3721 gs->gimple_omp_parallel.child_fn = child_fn;
3725 /* Return the artificial argument used to send variables and values
3726 from the parent to the children threads in OMP_TASK GS. */
3729 gimple_omp_taskreg_data_arg (const_gimple gs)
3731 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3732 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3733 return gs->gimple_omp_parallel.data_arg;
3737 /* Return a pointer to the data argument for OMP_TASK GS. */
3739 static inline tree *
3740 gimple_omp_taskreg_data_arg_ptr (gimple gs)
3742 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3743 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3744 return &gs->gimple_omp_parallel.data_arg;
3748 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3751 gimple_omp_taskreg_set_data_arg (gimple gs, tree data_arg)
3753 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3754 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3755 gs->gimple_omp_parallel.data_arg = data_arg;
3759 /* Return the copy function used to hold the body of OMP_TASK GS. */
3762 gimple_omp_task_copy_fn (const_gimple gs)
3764 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3765 return gs->gimple_omp_task.copy_fn;
3768 /* Return a pointer to the copy function used to hold the body of
3771 static inline tree *
3772 gimple_omp_task_copy_fn_ptr (gimple gs)
3774 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3775 return &gs->gimple_omp_task.copy_fn;
3779 /* Set CHILD_FN to be the copy function for OMP_TASK GS. */
3782 gimple_omp_task_set_copy_fn (gimple gs, tree copy_fn)
3784 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3785 gs->gimple_omp_task.copy_fn = copy_fn;
3789 /* Return size of the data block in bytes in OMP_TASK GS. */
3792 gimple_omp_task_arg_size (const_gimple gs)
3794 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3795 return gs->gimple_omp_task.arg_size;
3799 /* Return a pointer to the data block size for OMP_TASK GS. */
3801 static inline tree *
3802 gimple_omp_task_arg_size_ptr (gimple gs)
3804 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3805 return &gs->gimple_omp_task.arg_size;
3809 /* Set ARG_SIZE to be the data block size for OMP_TASK GS. */
3812 gimple_omp_task_set_arg_size (gimple gs, tree arg_size)
3814 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3815 gs->gimple_omp_task.arg_size = arg_size;
3819 /* Return align of the data block in bytes in OMP_TASK GS. */
3822 gimple_omp_task_arg_align (const_gimple gs)
3824 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3825 return gs->gimple_omp_task.arg_align;
3829 /* Return a pointer to the data block align for OMP_TASK GS. */
3831 static inline tree *
3832 gimple_omp_task_arg_align_ptr (gimple gs)
3834 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3835 return &gs->gimple_omp_task.arg_align;
3839 /* Set ARG_SIZE to be the data block align for OMP_TASK GS. */
3842 gimple_omp_task_set_arg_align (gimple gs, tree arg_align)
3844 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3845 gs->gimple_omp_task.arg_align = arg_align;
3849 /* Return the clauses associated with OMP_SINGLE GS. */
3852 gimple_omp_single_clauses (const_gimple gs)
3854 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3855 return gs->gimple_omp_single.clauses;
3859 /* Return a pointer to the clauses associated with OMP_SINGLE GS. */
3861 static inline tree *
3862 gimple_omp_single_clauses_ptr (gimple gs)
3864 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3865 return &gs->gimple_omp_single.clauses;
3869 /* Set CLAUSES to be the clauses associated with OMP_SINGLE GS. */
3872 gimple_omp_single_set_clauses (gimple gs, tree clauses)
3874 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3875 gs->gimple_omp_single.clauses = clauses;
3879 /* Return the clauses associated with OMP_SECTIONS GS. */
3882 gimple_omp_sections_clauses (const_gimple gs)
3884 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3885 return gs->gimple_omp_sections.clauses;
3889 /* Return a pointer to the clauses associated with OMP_SECTIONS GS. */
3891 static inline tree *
3892 gimple_omp_sections_clauses_ptr (gimple gs)
3894 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3895 return &gs->gimple_omp_sections.clauses;
3899 /* Set CLAUSES to be the set of clauses associated with OMP_SECTIONS
3903 gimple_omp_sections_set_clauses (gimple gs, tree clauses)
3905 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3906 gs->gimple_omp_sections.clauses = clauses;
3910 /* Return the control variable associated with the GIMPLE_OMP_SECTIONS
3914 gimple_omp_sections_control (const_gimple gs)
3916 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3917 return gs->gimple_omp_sections.control;
3921 /* Return a pointer to the clauses associated with the GIMPLE_OMP_SECTIONS
3924 static inline tree *
3925 gimple_omp_sections_control_ptr (gimple gs)
3927 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3928 return &gs->gimple_omp_sections.control;
3932 /* Set CONTROL to be the set of clauses associated with the
3933 GIMPLE_OMP_SECTIONS in GS. */
3936 gimple_omp_sections_set_control (gimple gs, tree control)
3938 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3939 gs->gimple_omp_sections.control = control;
3943 /* Set COND to be the condition code for OMP_FOR GS. */
3946 gimple_omp_for_set_cond (gimple gs, size_t i, enum tree_code cond)
3948 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3949 gcc_assert (TREE_CODE_CLASS (cond) == tcc_comparison);
3950 gcc_assert (i < gs->gimple_omp_for.collapse);
3951 gs->gimple_omp_for.iter[i].cond = cond;
3955 /* Return the condition code associated with OMP_FOR GS. */
3957 static inline enum tree_code
3958 gimple_omp_for_cond (const_gimple gs, size_t i)
3960 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3961 gcc_assert (i < gs->gimple_omp_for.collapse);
3962 return gs->gimple_omp_for.iter[i].cond;
3966 /* Set the value being stored in an atomic store. */
3969 gimple_omp_atomic_store_set_val (gimple g, tree val)
3971 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3972 g->gimple_omp_atomic_store.val = val;
3976 /* Return the value being stored in an atomic store. */
3979 gimple_omp_atomic_store_val (const_gimple g)
3981 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3982 return g->gimple_omp_atomic_store.val;
3986 /* Return a pointer to the value being stored in an atomic store. */
3988 static inline tree *
3989 gimple_omp_atomic_store_val_ptr (gimple g)
3991 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3992 return &g->gimple_omp_atomic_store.val;
3996 /* Set the LHS of an atomic load. */
3999 gimple_omp_atomic_load_set_lhs (gimple g, tree lhs)
4001 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4002 g->gimple_omp_atomic_load.lhs = lhs;
4006 /* Get the LHS of an atomic load. */
4009 gimple_omp_atomic_load_lhs (const_gimple g)
4011 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4012 return g->gimple_omp_atomic_load.lhs;
4016 /* Return a pointer to the LHS of an atomic load. */
4018 static inline tree *
4019 gimple_omp_atomic_load_lhs_ptr (gimple g)
4021 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4022 return &g->gimple_omp_atomic_load.lhs;
4026 /* Set the RHS of an atomic load. */
4029 gimple_omp_atomic_load_set_rhs (gimple g, tree rhs)
4031 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4032 g->gimple_omp_atomic_load.rhs = rhs;
4036 /* Get the RHS of an atomic load. */
4039 gimple_omp_atomic_load_rhs (const_gimple g)
4041 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4042 return g->gimple_omp_atomic_load.rhs;
4046 /* Return a pointer to the RHS of an atomic load. */
4048 static inline tree *
4049 gimple_omp_atomic_load_rhs_ptr (gimple g)
4051 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4052 return &g->gimple_omp_atomic_load.rhs;
4056 /* Get the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4059 gimple_omp_continue_control_def (const_gimple g)
4061 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4062 return g->gimple_omp_continue.control_def;
4065 /* The same as above, but return the address. */
4067 static inline tree *
4068 gimple_omp_continue_control_def_ptr (gimple g)
4070 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4071 return &g->gimple_omp_continue.control_def;
4074 /* Set the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4077 gimple_omp_continue_set_control_def (gimple g, tree def)
4079 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4080 g->gimple_omp_continue.control_def = def;
4084 /* Get the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4087 gimple_omp_continue_control_use (const_gimple g)
4089 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4090 return g->gimple_omp_continue.control_use;
4094 /* The same as above, but return the address. */
4096 static inline tree *
4097 gimple_omp_continue_control_use_ptr (gimple g)
4099 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4100 return &g->gimple_omp_continue.control_use;
4104 /* Set the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4107 gimple_omp_continue_set_control_use (gimple g, tree use)
4109 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4110 g->gimple_omp_continue.control_use = use;
4114 /* Return a pointer to the return value for GIMPLE_RETURN GS. */
4116 static inline tree *
4117 gimple_return_retval_ptr (const_gimple gs)
4119 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4120 gcc_assert (gimple_num_ops (gs) == 1);
4121 return gimple_op_ptr (gs, 0);
4124 /* Return the return value for GIMPLE_RETURN GS. */
4127 gimple_return_retval (const_gimple gs)
4129 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4130 gcc_assert (gimple_num_ops (gs) == 1);
4131 return gimple_op (gs, 0);
4135 /* Set RETVAL to be the return value for GIMPLE_RETURN GS. */
4138 gimple_return_set_retval (gimple gs, tree retval)
4140 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4141 gcc_assert (gimple_num_ops (gs) == 1);
4142 gcc_assert (retval == NULL_TREE
4143 || TREE_CODE (retval) == RESULT_DECL
4144 || is_gimple_val (retval));
4145 gimple_set_op (gs, 0, retval);
4149 /* Returns true when the gimple statment STMT is any of the OpenMP types. */
4152 is_gimple_omp (const_gimple stmt)
4154 return (gimple_code (stmt) == GIMPLE_OMP_PARALLEL
4155 || gimple_code (stmt) == GIMPLE_OMP_TASK
4156 || gimple_code (stmt) == GIMPLE_OMP_FOR
4157 || gimple_code (stmt) == GIMPLE_OMP_SECTIONS
4158 || gimple_code (stmt) == GIMPLE_OMP_SECTIONS_SWITCH
4159 || gimple_code (stmt) == GIMPLE_OMP_SINGLE
4160 || gimple_code (stmt) == GIMPLE_OMP_SECTION
4161 || gimple_code (stmt) == GIMPLE_OMP_MASTER
4162 || gimple_code (stmt) == GIMPLE_OMP_ORDERED
4163 || gimple_code (stmt) == GIMPLE_OMP_CRITICAL
4164 || gimple_code (stmt) == GIMPLE_OMP_RETURN
4165 || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_LOAD
4166 || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_STORE
4167 || gimple_code (stmt) == GIMPLE_OMP_CONTINUE);
4171 /* Returns TRUE if statement G is a GIMPLE_NOP. */
4174 gimple_nop_p (const_gimple g)
4176 return gimple_code (g) == GIMPLE_NOP;
4180 /* Return the new type set by GIMPLE_CHANGE_DYNAMIC_TYPE statement GS. */
4183 gimple_cdt_new_type (gimple gs)
4185 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4186 return gimple_op (gs, 1);
4189 /* Return a pointer to the new type set by GIMPLE_CHANGE_DYNAMIC_TYPE
4192 static inline tree *
4193 gimple_cdt_new_type_ptr (gimple gs)
4195 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4196 return gimple_op_ptr (gs, 1);
4199 /* Set NEW_TYPE to be the type returned by GIMPLE_CHANGE_DYNAMIC_TYPE
4203 gimple_cdt_set_new_type (gimple gs, tree new_type)
4205 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4206 gcc_assert (TREE_CODE_CLASS (TREE_CODE (new_type)) == tcc_type);
4207 gimple_set_op (gs, 1, new_type);
4211 /* Return the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE statement GS. */
4214 gimple_cdt_location (gimple gs)
4216 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4217 return gimple_op (gs, 0);
4221 /* Return a pointer to the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE
4224 static inline tree *
4225 gimple_cdt_location_ptr (gimple gs)
4227 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4228 return gimple_op_ptr (gs, 0);
4232 /* Set PTR to be the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE
4236 gimple_cdt_set_location (gimple gs, tree ptr)
4238 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4239 gimple_set_op (gs, 0, ptr);
4243 /* Return the predictor of GIMPLE_PREDICT statement GS. */
4245 static inline enum br_predictor
4246 gimple_predict_predictor (gimple gs)
4248 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4249 return (enum br_predictor) (gs->gsbase.subcode & ~GF_PREDICT_TAKEN);
4253 /* Set the predictor of GIMPLE_PREDICT statement GS to PREDICT. */
4256 gimple_predict_set_predictor (gimple gs, enum br_predictor predictor)
4258 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4259 gs->gsbase.subcode = (gs->gsbase.subcode & GF_PREDICT_TAKEN)
4260 | (unsigned) predictor;
4264 /* Return the outcome of GIMPLE_PREDICT statement GS. */
4266 static inline enum prediction
4267 gimple_predict_outcome (gimple gs)
4269 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4270 return (gs->gsbase.subcode & GF_PREDICT_TAKEN) ? TAKEN : NOT_TAKEN;
4274 /* Set the outcome of GIMPLE_PREDICT statement GS to OUTCOME. */
4277 gimple_predict_set_outcome (gimple gs, enum prediction outcome)
4279 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4280 if (outcome == TAKEN)
4281 gs->gsbase.subcode |= GF_PREDICT_TAKEN;
4283 gs->gsbase.subcode &= ~GF_PREDICT_TAKEN;
4287 /* Return a new iterator pointing to GIMPLE_SEQ's first statement. */
4289 static inline gimple_stmt_iterator
4290 gsi_start (gimple_seq seq)
4292 gimple_stmt_iterator i;
4294 i.ptr = gimple_seq_first (seq);
4296 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4302 /* Return a new iterator pointing to the first statement in basic block BB. */
4304 static inline gimple_stmt_iterator
4305 gsi_start_bb (basic_block bb)
4307 gimple_stmt_iterator i;
4311 i.ptr = gimple_seq_first (seq);
4319 /* Return a new iterator initially pointing to GIMPLE_SEQ's last statement. */
4321 static inline gimple_stmt_iterator
4322 gsi_last (gimple_seq seq)
4324 gimple_stmt_iterator i;
4326 i.ptr = gimple_seq_last (seq);
4328 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4334 /* Return a new iterator pointing to the last statement in basic block BB. */
4336 static inline gimple_stmt_iterator
4337 gsi_last_bb (basic_block bb)
4339 gimple_stmt_iterator i;
4343 i.ptr = gimple_seq_last (seq);
4351 /* Return true if I is at the end of its sequence. */
4354 gsi_end_p (gimple_stmt_iterator i)
4356 return i.ptr == NULL;
4360 /* Return true if I is one statement before the end of its sequence. */
4363 gsi_one_before_end_p (gimple_stmt_iterator i)
4365 return i.ptr != NULL && i.ptr->next == NULL;
4369 /* Advance the iterator to the next gimple statement. */
4372 gsi_next (gimple_stmt_iterator *i)
4374 i->ptr = i->ptr->next;
4377 /* Advance the iterator to the previous gimple statement. */
4380 gsi_prev (gimple_stmt_iterator *i)
4382 i->ptr = i->ptr->prev;
4385 /* Return the current stmt. */
4387 static inline gimple
4388 gsi_stmt (gimple_stmt_iterator i)
4393 /* Return a block statement iterator that points to the first non-label
4394 statement in block BB. */
4396 static inline gimple_stmt_iterator
4397 gsi_after_labels (basic_block bb)
4399 gimple_stmt_iterator gsi = gsi_start_bb (bb);
4401 while (!gsi_end_p (gsi) && gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL)
4407 /* Return a pointer to the current stmt.
4409 NOTE: You may want to use gsi_replace on the iterator itself,
4410 as this performs additional bookkeeping that will not be done
4411 if you simply assign through a pointer returned by gsi_stmt_ptr. */
4413 static inline gimple *
4414 gsi_stmt_ptr (gimple_stmt_iterator *i)
4416 return &i->ptr->stmt;
4420 /* Return the basic block associated with this iterator. */
4422 static inline basic_block
4423 gsi_bb (gimple_stmt_iterator i)
4429 /* Return the sequence associated with this iterator. */
4431 static inline gimple_seq
4432 gsi_seq (gimple_stmt_iterator i)
4438 enum gsi_iterator_update
4440 GSI_NEW_STMT, /* Only valid when single statement is added, move
4442 GSI_SAME_STMT, /* Leave the iterator at the same statement. */
4443 GSI_CONTINUE_LINKING /* Move iterator to whatever position is suitable
4444 for linking other statements in the same
4448 /* In gimple-iterator.c */
4449 gimple_stmt_iterator gsi_start_phis (basic_block);
4450 gimple_seq gsi_split_seq_after (gimple_stmt_iterator);
4451 gimple_seq gsi_split_seq_before (gimple_stmt_iterator *);
4452 void gsi_replace (gimple_stmt_iterator *, gimple, bool);
4453 void gsi_insert_before (gimple_stmt_iterator *, gimple,
4454 enum gsi_iterator_update);
4455 void gsi_insert_before_without_update (gimple_stmt_iterator *, gimple,
4456 enum gsi_iterator_update);
4457 void gsi_insert_seq_before (gimple_stmt_iterator *, gimple_seq,
4458 enum gsi_iterator_update);
4459 void gsi_insert_seq_before_without_update (gimple_stmt_iterator *, gimple_seq,
4460 enum gsi_iterator_update);
4461 void gsi_insert_after (gimple_stmt_iterator *, gimple,
4462 enum gsi_iterator_update);
4463 void gsi_insert_after_without_update (gimple_stmt_iterator *, gimple,
4464 enum gsi_iterator_update);
4465 void gsi_insert_seq_after (gimple_stmt_iterator *, gimple_seq,
4466 enum gsi_iterator_update);
4467 void gsi_insert_seq_after_without_update (gimple_stmt_iterator *, gimple_seq,
4468 enum gsi_iterator_update);
4469 void gsi_remove (gimple_stmt_iterator *, bool);
4470 gimple_stmt_iterator gsi_for_stmt (gimple);
4471 void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *);
4472 void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *);
4473 void gsi_move_to_bb_end (gimple_stmt_iterator *, struct basic_block_def *);
4474 void gsi_insert_on_edge (edge, gimple);
4475 void gsi_insert_seq_on_edge (edge, gimple_seq);
4476 basic_block gsi_insert_on_edge_immediate (edge, gimple);
4477 basic_block gsi_insert_seq_on_edge_immediate (edge, gimple_seq);
4478 void gsi_commit_one_edge_insert (edge, basic_block *);
4479 void gsi_commit_edge_inserts (void);
4480 gimple giple_copy_call_skip_args (gimple, bitmap);
4483 /* Convenience routines to walk all statements of a gimple function.
4484 Note that this is useful exclusively before the code is converted
4485 into SSA form. Once the program is in SSA form, the standard
4486 operand interface should be used to analyze/modify statements. */
4487 struct walk_stmt_info
4489 /* Points to the current statement being walked. */
4490 gimple_stmt_iterator gsi;
4492 /* Additional data that the callback functions may want to carry
4493 through the recursion. */
4496 /* Pointer map used to mark visited tree nodes when calling
4497 walk_tree on each operand. If set to NULL, duplicate tree nodes
4498 will be visited more than once. */
4499 struct pointer_set_t *pset;
4501 /* Indicates whether the operand being examined may be replaced
4502 with something that matches is_gimple_val (if true) or something
4503 slightly more complicated (if false). "Something" technically
4504 means the common subset of is_gimple_lvalue and is_gimple_rhs,
4505 but we never try to form anything more complicated than that, so
4506 we don't bother checking.
4508 Also note that CALLBACK should update this flag while walking the
4509 sub-expressions of a statement. For instance, when walking the
4510 statement 'foo (&var)', the flag VAL_ONLY will initially be set
4511 to true, however, when walking &var, the operand of that
4512 ADDR_EXPR does not need to be a GIMPLE value. */
4515 /* True if we are currently walking the LHS of an assignment. */
4518 /* Optional. Set to true by the callback functions if they made any
4522 /* True if we're interested in location information. */
4523 bool want_locations;
4525 /* Operand returned by the callbacks. This is set when calling
4526 walk_gimple_seq. If the walk_stmt_fn or walk_tree_fn callback
4527 returns non-NULL, this field will contain the tree returned by
4528 the last callback. */
4529 tree callback_result;
4532 /* Callback for walk_gimple_stmt. Called for every statement found
4533 during traversal. The first argument points to the statement to
4534 walk. The second argument is a flag that the callback sets to
4535 'true' if it the callback handled all the operands and
4536 sub-statements of the statement (the default value of this flag is
4537 'false'). The third argument is an anonymous pointer to data
4538 to be used by the callback. */
4539 typedef tree (*walk_stmt_fn) (gimple_stmt_iterator *, bool *,
4540 struct walk_stmt_info *);
4542 gimple walk_gimple_seq (gimple_seq, walk_stmt_fn, walk_tree_fn,
4543 struct walk_stmt_info *);
4544 tree walk_gimple_stmt (gimple_stmt_iterator *, walk_stmt_fn, walk_tree_fn,
4545 struct walk_stmt_info *);
4546 tree walk_gimple_op (gimple, walk_tree_fn, struct walk_stmt_info *);
4548 #ifdef GATHER_STATISTICS
4549 /* Enum and arrays used for allocation stats. Keep in sync with
4550 gimple.c:gimple_alloc_kind_names. */
4551 enum gimple_alloc_kind
4553 gimple_alloc_kind_assign, /* Assignments. */
4554 gimple_alloc_kind_phi, /* PHI nodes. */
4555 gimple_alloc_kind_cond, /* Conditionals. */
4556 gimple_alloc_kind_seq, /* Sequences. */
4557 gimple_alloc_kind_rest, /* Everything else. */
4558 gimple_alloc_kind_all
4561 extern int gimple_alloc_counts[];
4562 extern int gimple_alloc_sizes[];
4564 /* Return the allocation kind for a given stmt CODE. */
4565 static inline enum gimple_alloc_kind
4566 gimple_alloc_kind (enum gimple_code code)
4571 return gimple_alloc_kind_assign;
4573 return gimple_alloc_kind_phi;
4575 return gimple_alloc_kind_cond;
4577 return gimple_alloc_kind_rest;
4580 #endif /* GATHER_STATISTICS */
4582 extern void dump_gimple_statistics (void);
4584 #endif /* GCC_GIMPLE_H */