1 /* Gimple IR definitions.
3 Copyright 2007, 2008, 2009 Free Software Foundation, Inc.
4 Contributed by Aldy Hernandez <aldyh@redhat.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
25 #include "pointer-set.h"
29 #include "hard-reg-set.h"
30 #include "basic-block.h"
31 #include "tree-ssa-operands.h"
34 DEF_VEC_ALLOC_P(gimple,heap);
35 DEF_VEC_ALLOC_P(gimple,gc);
37 typedef gimple *gimple_p;
39 DEF_VEC_ALLOC_P(gimple_p,heap);
41 DEF_VEC_P(gimple_seq);
42 DEF_VEC_ALLOC_P(gimple_seq,gc);
43 DEF_VEC_ALLOC_P(gimple_seq,heap);
45 /* For each block, the PHI nodes that need to be rewritten are stored into
47 typedef VEC(gimple, heap) *gimple_vec;
48 DEF_VEC_P (gimple_vec);
49 DEF_VEC_ALLOC_P (gimple_vec, heap);
52 #define DEFGSCODE(SYM, STRING, STRUCT) SYM,
55 LAST_AND_UNUSED_GIMPLE_CODE
58 extern const char *const gimple_code_name[];
59 extern const unsigned char gimple_rhs_class_table[];
61 /* Error out if a gimple tuple is addressed incorrectly. */
62 #if defined ENABLE_GIMPLE_CHECKING
63 extern void gimple_check_failed (const_gimple, const char *, int, \
64 const char *, enum gimple_code, \
65 enum tree_code) ATTRIBUTE_NORETURN;
67 #define GIMPLE_CHECK(GS, CODE) \
69 const_gimple __gs = (GS); \
70 if (gimple_code (__gs) != (CODE)) \
71 gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__, \
72 (CODE), ERROR_MARK); \
74 #else /* not ENABLE_GIMPLE_CHECKING */
75 #define GIMPLE_CHECK(GS, CODE) (void)0
78 /* Class of GIMPLE expressions suitable for the RHS of assignments. See
79 get_gimple_rhs_class. */
82 GIMPLE_INVALID_RHS, /* The expression cannot be used on the RHS. */
83 GIMPLE_BINARY_RHS, /* The expression is a binary operation. */
84 GIMPLE_UNARY_RHS, /* The expression is a unary operation. */
85 GIMPLE_SINGLE_RHS /* The expression is a single object (an SSA
86 name, a _DECL, a _REF, etc. */
89 /* Specific flags for individual GIMPLE statements. These flags are
90 always stored in gimple_statement_base.subcode and they may only be
91 defined for statement codes that do not use sub-codes.
93 Values for the masks can overlap as long as the overlapping values
94 are never used in the same statement class.
96 The maximum mask value that can be defined is 1 << 15 (i.e., each
97 statement code can hold up to 16 bitflags).
99 Keep this list sorted. */
101 GF_ASM_INPUT = 1 << 0,
102 GF_ASM_VOLATILE = 1 << 1,
103 GF_CALL_CANNOT_INLINE = 1 << 0,
104 GF_CALL_FROM_THUNK = 1 << 1,
105 GF_CALL_RETURN_SLOT_OPT = 1 << 2,
106 GF_CALL_TAILCALL = 1 << 3,
107 GF_CALL_VA_ARG_PACK = 1 << 4,
108 GF_OMP_PARALLEL_COMBINED = 1 << 0,
110 /* True on an GIMPLE_OMP_RETURN statement if the return does not require
111 a thread synchronization via some sort of barrier. The exact barrier
112 that would otherwise be emitted is dependent on the OMP statement with
113 which this return is associated. */
114 GF_OMP_RETURN_NOWAIT = 1 << 0,
116 GF_OMP_SECTION_LAST = 1 << 0,
117 GF_PREDICT_TAKEN = 1 << 15
120 /* Currently, there's only one type of gimple debug stmt. Others are
121 envisioned, for example, to enable the generation of is_stmt notes
122 in line number information, to mark sequence points, etc. This
123 subcode is to be used to tell them apart. */
124 enum gimple_debug_subcode {
125 GIMPLE_DEBUG_BIND = 0
128 /* Masks for selecting a pass local flag (PLF) to work on. These
129 masks are used by gimple_set_plf and gimple_plf. */
135 /* A node in a gimple_seq_d. */
136 struct GTY((chain_next ("%h.next"), chain_prev ("%h.prev"))) gimple_seq_node_d {
138 struct gimple_seq_node_d *prev;
139 struct gimple_seq_node_d *next;
142 /* A double-linked sequence of gimple statements. */
143 struct GTY ((chain_next ("%h.next_free"))) gimple_seq_d {
144 /* First and last statements in the sequence. */
145 gimple_seq_node first;
146 gimple_seq_node last;
148 /* Sequences are created/destroyed frequently. To minimize
149 allocation activity, deallocated sequences are kept in a pool of
150 available sequences. This is the pointer to the next free
151 sequence in the pool. */
152 gimple_seq next_free;
156 /* Return the first node in GIMPLE sequence S. */
158 static inline gimple_seq_node
159 gimple_seq_first (const_gimple_seq s)
161 return s ? s->first : NULL;
165 /* Return the first statement in GIMPLE sequence S. */
168 gimple_seq_first_stmt (const_gimple_seq s)
170 gimple_seq_node n = gimple_seq_first (s);
171 return (n) ? n->stmt : NULL;
175 /* Return the last node in GIMPLE sequence S. */
177 static inline gimple_seq_node
178 gimple_seq_last (const_gimple_seq s)
180 return s ? s->last : NULL;
184 /* Return the last statement in GIMPLE sequence S. */
187 gimple_seq_last_stmt (const_gimple_seq s)
189 gimple_seq_node n = gimple_seq_last (s);
190 return (n) ? n->stmt : NULL;
194 /* Set the last node in GIMPLE sequence S to LAST. */
197 gimple_seq_set_last (gimple_seq s, gimple_seq_node last)
203 /* Set the first node in GIMPLE sequence S to FIRST. */
206 gimple_seq_set_first (gimple_seq s, gimple_seq_node first)
212 /* Return true if GIMPLE sequence S is empty. */
215 gimple_seq_empty_p (const_gimple_seq s)
217 return s == NULL || s->first == NULL;
221 void gimple_seq_add_stmt (gimple_seq *, gimple);
223 /* Allocate a new sequence and initialize its first element with STMT. */
225 static inline gimple_seq
226 gimple_seq_alloc_with_stmt (gimple stmt)
228 gimple_seq seq = NULL;
229 gimple_seq_add_stmt (&seq, stmt);
234 /* Returns the sequence of statements in BB. */
236 static inline gimple_seq
237 bb_seq (const_basic_block bb)
239 return (!(bb->flags & BB_RTL) && bb->il.gimple) ? bb->il.gimple->seq : NULL;
243 /* Sets the sequence of statements in BB to SEQ. */
246 set_bb_seq (basic_block bb, gimple_seq seq)
248 gcc_assert (!(bb->flags & BB_RTL));
249 bb->il.gimple->seq = seq;
252 /* Iterator object for GIMPLE statement sequences. */
256 /* Sequence node holding the current statement. */
259 /* Sequence and basic block holding the statement. These fields
260 are necessary to handle edge cases such as when statement is
261 added to an empty basic block or when the last statement of a
262 block/sequence is removed. */
265 } gimple_stmt_iterator;
268 /* Data structure definitions for GIMPLE tuples. NOTE: word markers
269 are for 64 bit hosts. */
271 struct GTY(()) gimple_statement_base {
273 Main identifying code for a tuple. */
274 ENUM_BITFIELD(gimple_code) code : 8;
276 /* Nonzero if a warning should not be emitted on this tuple. */
277 unsigned int no_warning : 1;
279 /* Nonzero if this tuple has been visited. Passes are responsible
280 for clearing this bit before using it. */
281 unsigned int visited : 1;
283 /* Nonzero if this tuple represents a non-temporal move. */
284 unsigned int nontemporal_move : 1;
286 /* Pass local flags. These flags are free for any pass to use as
287 they see fit. Passes should not assume that these flags contain
288 any useful value when the pass starts. Any initial state that
289 the pass requires should be set on entry to the pass. See
290 gimple_set_plf and gimple_plf for usage. */
291 unsigned int plf : 2;
293 /* Nonzero if this statement has been modified and needs to have its
294 operands rescanned. */
295 unsigned modified : 1;
297 /* Nonzero if this statement contains volatile operands. */
298 unsigned has_volatile_ops : 1;
300 /* Padding to get subcode to 16 bit alignment. */
303 /* The SUBCODE field can be used for tuple-specific flags for tuples
304 that do not require subcodes. Note that SUBCODE should be at
305 least as wide as tree codes, as several tuples store tree codes
307 unsigned int subcode : 16;
309 /* UID of this statement. This is used by passes that want to
310 assign IDs to statements. It must be assigned and used by each
311 pass. By default it should be assumed to contain garbage. */
315 Locus information for debug info. */
318 /* Number of operands in this tuple. */
322 Basic block holding this statement. */
323 struct basic_block_def *bb;
326 Lexical block holding this statement. */
331 /* Base structure for tuples with operands. */
333 struct GTY(()) gimple_statement_with_ops_base
336 struct gimple_statement_base gsbase;
339 SSA operand vectors. NOTE: It should be possible to
340 amalgamate these vectors with the operand vector OP. However,
341 the SSA operand vectors are organized differently and contain
342 more information (like immediate use chaining). */
343 struct def_optype_d GTY((skip (""))) *def_ops;
344 struct use_optype_d GTY((skip (""))) *use_ops;
348 /* Statements that take register operands. */
350 struct GTY(()) gimple_statement_with_ops
353 struct gimple_statement_with_ops_base opbase;
356 Operand vector. NOTE! This must always be the last field
357 of this structure. In particular, this means that this
358 structure cannot be embedded inside another one. */
359 tree GTY((length ("%h.opbase.gsbase.num_ops"))) op[1];
363 /* Base for statements that take both memory and register operands. */
365 struct GTY(()) gimple_statement_with_memory_ops_base
368 struct gimple_statement_with_ops_base opbase;
371 Virtual operands for this statement. The GC will pick them
372 up via the ssa_names array. */
373 tree GTY((skip (""))) vdef;
374 tree GTY((skip (""))) vuse;
378 /* Statements that take both memory and register operands. */
380 struct GTY(()) gimple_statement_with_memory_ops
383 struct gimple_statement_with_memory_ops_base membase;
386 Operand vector. NOTE! This must always be the last field
387 of this structure. In particular, this means that this
388 structure cannot be embedded inside another one. */
389 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
393 /* OpenMP statements (#pragma omp). */
395 struct GTY(()) gimple_statement_omp {
397 struct gimple_statement_base gsbase;
406 struct GTY(()) gimple_statement_bind {
408 struct gimple_statement_base gsbase;
411 Variables declared in this scope. */
415 This is different than the BLOCK field in gimple_statement_base,
416 which is analogous to TREE_BLOCK (i.e., the lexical block holding
417 this statement). This field is the equivalent of BIND_EXPR_BLOCK
418 in tree land (i.e., the lexical scope defined by this bind). See
429 struct GTY(()) gimple_statement_catch {
431 struct gimple_statement_base gsbase;
441 /* GIMPLE_EH_FILTER */
443 struct GTY(()) gimple_statement_eh_filter {
445 struct gimple_statement_base gsbase;
457 /* GIMPLE_EH_MUST_NOT_THROW */
459 struct GTY(()) gimple_statement_eh_mnt {
461 struct gimple_statement_base gsbase;
463 /* [ WORD 5 ] Abort function decl. */
469 struct GTY(()) gimple_statement_phi {
471 struct gimple_statement_base gsbase;
481 struct phi_arg_d GTY ((length ("%h.nargs"))) args[1];
485 /* GIMPLE_RESX, GIMPLE_EH_DISPATCH */
487 struct GTY(()) gimple_statement_eh_ctrl
490 struct gimple_statement_base gsbase;
493 Exception region number. */
500 struct GTY(()) gimple_statement_try {
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 GTY(()) gimple_statement_wce {
531 struct gimple_statement_base gsbase;
533 /* Subcode: CLEANUP_EH_ONLY. True if the cleanup should only be
534 executed if an exception is thrown, not on normal exit of its
535 scope. This flag is analogous to the CLEANUP_EH_ONLY flag
539 Cleanup expression. */
546 struct GTY(()) gimple_statement_asm
549 struct gimple_statement_with_memory_ops_base membase;
552 __asm__ statement. */
556 Number of inputs, outputs and clobbers. */
562 Operand vector. NOTE! This must always be the last field
563 of this structure. In particular, this means that this
564 structure cannot be embedded inside another one. */
565 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
568 /* GIMPLE_OMP_CRITICAL */
570 struct GTY(()) gimple_statement_omp_critical {
572 struct gimple_statement_omp omp;
575 Critical section name. */
580 struct GTY(()) gimple_omp_for_iter {
581 /* Condition code. */
584 /* Index variable. */
599 struct GTY(()) gimple_statement_omp_for {
601 struct gimple_statement_omp omp;
607 Number of elements in iter array. */
611 struct gimple_omp_for_iter * GTY((length ("%h.collapse"))) iter;
614 Pre-body evaluated before the loop body begins. */
619 /* GIMPLE_OMP_PARALLEL */
621 struct GTY(()) gimple_statement_omp_parallel {
623 struct gimple_statement_omp omp;
630 Child function holding the body of the parallel region. */
634 Shared data argument. */
639 /* GIMPLE_OMP_TASK */
641 struct GTY(()) gimple_statement_omp_task {
643 struct gimple_statement_omp_parallel par;
646 Child function holding firstprivate initialization if needed. */
650 Size and alignment in bytes of the argument data block. */
656 /* GIMPLE_OMP_SECTION */
657 /* Uses struct gimple_statement_omp. */
660 /* GIMPLE_OMP_SECTIONS */
662 struct GTY(()) gimple_statement_omp_sections {
664 struct gimple_statement_omp omp;
670 The control variable used for deciding which of the sections to
675 /* GIMPLE_OMP_CONTINUE.
677 Note: This does not inherit from gimple_statement_omp, because we
678 do not need the body field. */
680 struct GTY(()) gimple_statement_omp_continue {
682 struct gimple_statement_base gsbase;
691 /* GIMPLE_OMP_SINGLE */
693 struct GTY(()) gimple_statement_omp_single {
695 struct gimple_statement_omp omp;
702 /* GIMPLE_OMP_ATOMIC_LOAD.
703 Note: This is based on gimple_statement_base, not g_s_omp, because g_s_omp
704 contains a sequence, which we don't need here. */
706 struct GTY(()) gimple_statement_omp_atomic_load {
708 struct gimple_statement_base gsbase;
714 /* GIMPLE_OMP_ATOMIC_STORE.
715 See note on GIMPLE_OMP_ATOMIC_LOAD. */
717 struct GTY(()) gimple_statement_omp_atomic_store {
719 struct gimple_statement_base gsbase;
725 #define DEFGSSTRUCT(SYM, STRUCT, HAS_TREE_OP) SYM,
726 enum gimple_statement_structure_enum {
727 #include "gsstruct.def"
733 /* Define the overall contents of a gimple tuple. It may be any of the
734 structures declared above for various types of tuples. */
736 union GTY ((desc ("gimple_statement_structure (&%h)"))) gimple_statement_d {
737 struct gimple_statement_base GTY ((tag ("GSS_BASE"))) gsbase;
738 struct gimple_statement_with_ops GTY ((tag ("GSS_WITH_OPS"))) gsops;
739 struct gimple_statement_with_memory_ops GTY ((tag ("GSS_WITH_MEM_OPS"))) gsmem;
740 struct gimple_statement_omp GTY ((tag ("GSS_OMP"))) omp;
741 struct gimple_statement_bind GTY ((tag ("GSS_BIND"))) gimple_bind;
742 struct gimple_statement_catch GTY ((tag ("GSS_CATCH"))) gimple_catch;
743 struct gimple_statement_eh_filter GTY ((tag ("GSS_EH_FILTER"))) gimple_eh_filter;
744 struct gimple_statement_eh_mnt GTY ((tag ("GSS_EH_MNT"))) gimple_eh_mnt;
745 struct gimple_statement_phi GTY ((tag ("GSS_PHI"))) gimple_phi;
746 struct gimple_statement_eh_ctrl GTY ((tag ("GSS_EH_CTRL"))) gimple_eh_ctrl;
747 struct gimple_statement_try GTY ((tag ("GSS_TRY"))) gimple_try;
748 struct gimple_statement_wce GTY ((tag ("GSS_WCE"))) gimple_wce;
749 struct gimple_statement_asm GTY ((tag ("GSS_ASM"))) gimple_asm;
750 struct gimple_statement_omp_critical GTY ((tag ("GSS_OMP_CRITICAL"))) gimple_omp_critical;
751 struct gimple_statement_omp_for GTY ((tag ("GSS_OMP_FOR"))) gimple_omp_for;
752 struct gimple_statement_omp_parallel GTY ((tag ("GSS_OMP_PARALLEL"))) gimple_omp_parallel;
753 struct gimple_statement_omp_task GTY ((tag ("GSS_OMP_TASK"))) gimple_omp_task;
754 struct gimple_statement_omp_sections GTY ((tag ("GSS_OMP_SECTIONS"))) gimple_omp_sections;
755 struct gimple_statement_omp_single GTY ((tag ("GSS_OMP_SINGLE"))) gimple_omp_single;
756 struct gimple_statement_omp_continue GTY ((tag ("GSS_OMP_CONTINUE"))) gimple_omp_continue;
757 struct gimple_statement_omp_atomic_load GTY ((tag ("GSS_OMP_ATOMIC_LOAD"))) gimple_omp_atomic_load;
758 struct gimple_statement_omp_atomic_store GTY ((tag ("GSS_OMP_ATOMIC_STORE"))) gimple_omp_atomic_store;
763 /* Offset in bytes to the location of the operand vector.
764 Zero if there is no operand vector for this tuple structure. */
765 extern size_t const gimple_ops_offset_[];
767 /* Map GIMPLE codes to GSS codes. */
768 extern enum gimple_statement_structure_enum const gss_for_code_[];
770 gimple gimple_build_return (tree);
772 gimple gimple_build_assign_stat (tree, tree MEM_STAT_DECL);
773 #define gimple_build_assign(l,r) gimple_build_assign_stat (l, r MEM_STAT_INFO)
775 void extract_ops_from_tree (tree, enum tree_code *, tree *, tree *);
777 gimple gimple_build_assign_with_ops_stat (enum tree_code, tree, tree,
779 #define gimple_build_assign_with_ops(c,o1,o2,o3) \
780 gimple_build_assign_with_ops_stat (c, o1, o2, o3 MEM_STAT_INFO)
782 gimple gimple_build_debug_bind_stat (tree, tree, gimple MEM_STAT_DECL);
783 #define gimple_build_debug_bind(var,val,stmt) \
784 gimple_build_debug_bind_stat ((var), (val), (stmt) MEM_STAT_INFO)
786 gimple gimple_build_call_vec (tree, VEC(tree, heap) *);
787 gimple gimple_build_call (tree, unsigned, ...);
788 gimple gimple_build_call_from_tree (tree);
789 gimple gimplify_assign (tree, tree, gimple_seq *);
790 gimple gimple_build_cond (enum tree_code, tree, tree, tree, tree);
791 gimple gimple_build_label (tree label);
792 gimple gimple_build_goto (tree dest);
793 gimple gimple_build_nop (void);
794 gimple gimple_build_bind (tree, gimple_seq, tree);
795 gimple gimple_build_asm (const char *, unsigned, unsigned, unsigned, ...);
796 gimple gimple_build_asm_vec (const char *, VEC(tree,gc) *, VEC(tree,gc) *,
798 gimple gimple_build_catch (tree, gimple_seq);
799 gimple gimple_build_eh_filter (tree, gimple_seq);
800 gimple gimple_build_eh_must_not_throw (tree);
801 gimple gimple_build_try (gimple_seq, gimple_seq, enum gimple_try_flags);
802 gimple gimple_build_wce (gimple_seq);
803 gimple gimple_build_resx (int);
804 gimple gimple_build_eh_dispatch (int);
805 gimple gimple_build_switch_nlabels (unsigned, tree, tree);
806 gimple gimple_build_switch (unsigned, tree, tree, ...);
807 gimple gimple_build_switch_vec (tree, tree, VEC(tree,heap) *);
808 gimple gimple_build_omp_parallel (gimple_seq, tree, tree, tree);
809 gimple gimple_build_omp_task (gimple_seq, tree, tree, tree, tree, tree, tree);
810 gimple gimple_build_omp_for (gimple_seq, tree, size_t, gimple_seq);
811 gimple gimple_build_omp_critical (gimple_seq, tree);
812 gimple gimple_build_omp_section (gimple_seq);
813 gimple gimple_build_omp_continue (tree, tree);
814 gimple gimple_build_omp_master (gimple_seq);
815 gimple gimple_build_omp_return (bool);
816 gimple gimple_build_omp_ordered (gimple_seq);
817 gimple gimple_build_omp_sections (gimple_seq, tree);
818 gimple gimple_build_omp_sections_switch (void);
819 gimple gimple_build_omp_single (gimple_seq, tree);
820 gimple gimple_build_cdt (tree, tree);
821 gimple gimple_build_omp_atomic_load (tree, tree);
822 gimple gimple_build_omp_atomic_store (tree);
823 gimple gimple_build_predict (enum br_predictor, enum prediction);
824 enum gimple_statement_structure_enum gss_for_assign (enum tree_code);
825 void sort_case_labels (VEC(tree,heap) *);
826 void gimple_set_body (tree, gimple_seq);
827 gimple_seq gimple_body (tree);
828 bool gimple_has_body_p (tree);
829 gimple_seq gimple_seq_alloc (void);
830 void gimple_seq_free (gimple_seq);
831 void gimple_seq_add_seq (gimple_seq *, gimple_seq);
832 gimple_seq gimple_seq_copy (gimple_seq);
833 int gimple_call_flags (const_gimple);
834 bool gimple_assign_copy_p (gimple);
835 bool gimple_assign_ssa_name_copy_p (gimple);
836 bool gimple_assign_single_p (gimple);
837 bool gimple_assign_unary_nop_p (gimple);
838 void gimple_set_bb (gimple, struct basic_block_def *);
839 tree gimple_fold (const_gimple);
840 void gimple_assign_set_rhs_from_tree (gimple_stmt_iterator *, tree);
841 void gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *, enum tree_code,
843 tree gimple_get_lhs (const_gimple);
844 void gimple_set_lhs (gimple, tree);
845 gimple gimple_copy (gimple);
846 bool is_gimple_operand (const_tree);
847 void gimple_set_modified (gimple, bool);
848 void gimple_cond_get_ops_from_tree (tree, enum tree_code *, tree *, tree *);
849 gimple gimple_build_cond_from_tree (tree, tree, tree);
850 void gimple_cond_set_condition_from_tree (gimple, tree);
851 bool gimple_has_side_effects (const_gimple);
852 bool gimple_rhs_has_side_effects (const_gimple);
853 bool gimple_could_trap_p (gimple);
854 bool gimple_assign_rhs_could_trap_p (gimple);
855 void gimple_regimplify_operands (gimple, gimple_stmt_iterator *);
856 bool empty_body_p (gimple_seq);
857 unsigned get_gimple_rhs_num_ops (enum tree_code);
858 const char *gimple_decl_printable_name (tree, int);
859 tree gimple_fold_obj_type_ref (tree, tree);
861 /* Returns true iff T is a valid GIMPLE statement. */
862 extern bool is_gimple_stmt (tree);
864 /* Returns true iff TYPE is a valid type for a scalar register variable. */
865 extern bool is_gimple_reg_type (tree);
866 /* Returns true iff T is a scalar register variable. */
867 extern bool is_gimple_reg (tree);
868 /* Returns true iff T is any sort of variable. */
869 extern bool is_gimple_variable (tree);
870 /* Returns true iff T is any sort of symbol. */
871 extern bool is_gimple_id (tree);
872 /* Returns true iff T is a variable or an INDIRECT_REF (of a variable). */
873 extern bool is_gimple_min_lval (tree);
874 /* Returns true iff T is something whose address can be taken. */
875 extern bool is_gimple_addressable (tree);
876 /* Returns true iff T is any valid GIMPLE lvalue. */
877 extern bool is_gimple_lvalue (tree);
879 /* Returns true iff T is a GIMPLE address. */
880 bool is_gimple_address (const_tree);
881 /* Returns true iff T is a GIMPLE invariant address. */
882 bool is_gimple_invariant_address (const_tree);
883 /* Returns true iff T is a GIMPLE invariant address at interprocedural
885 bool is_gimple_ip_invariant_address (const_tree);
886 /* Returns true iff T is a valid GIMPLE constant. */
887 bool is_gimple_constant (const_tree);
888 /* Returns true iff T is a GIMPLE restricted function invariant. */
889 extern bool is_gimple_min_invariant (const_tree);
890 /* Returns true iff T is a GIMPLE restricted interprecodural invariant. */
891 extern bool is_gimple_ip_invariant (const_tree);
892 /* Returns true iff T is a GIMPLE rvalue. */
893 extern bool is_gimple_val (tree);
894 /* Returns true iff T is a GIMPLE asm statement input. */
895 extern bool is_gimple_asm_val (tree);
896 /* Returns true iff T is a valid rhs for a MODIFY_EXPR where the LHS is a
897 GIMPLE temporary, a renamed user variable, or something else,
899 extern bool is_gimple_reg_rhs (tree);
900 extern bool is_gimple_mem_rhs (tree);
902 /* Returns true iff T is a valid if-statement condition. */
903 extern bool is_gimple_condexpr (tree);
905 /* Returns true iff T is a type conversion. */
906 extern bool is_gimple_cast (tree);
907 /* Returns true iff T is a variable that does not need to live in memory. */
908 extern bool is_gimple_non_addressable (tree t);
910 /* Returns true iff T is a valid call address expression. */
911 extern bool is_gimple_call_addr (tree);
912 /* If T makes a function call, returns the CALL_EXPR operand. */
913 extern tree get_call_expr_in (tree t);
915 extern void recalculate_side_effects (tree);
916 extern void count_uses_and_derefs (tree, gimple, unsigned *, unsigned *,
918 extern bool walk_stmt_load_store_addr_ops (gimple, void *,
919 bool (*)(gimple, tree, void *),
920 bool (*)(gimple, tree, void *),
921 bool (*)(gimple, tree, void *));
922 extern bool walk_stmt_load_store_ops (gimple, void *,
923 bool (*)(gimple, tree, void *),
924 bool (*)(gimple, tree, void *));
925 extern bool gimple_ior_addresses_taken (bitmap, gimple);
928 extern tree create_tmp_var_raw (tree, const char *);
929 extern tree create_tmp_var_name (const char *);
930 extern tree create_tmp_var (tree, const char *);
931 extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq *);
932 extern tree get_formal_tmp_var (tree, gimple_seq *);
933 extern void declare_vars (tree, gimple, bool);
934 extern void tree_annotate_all_with_location (tree *, location_t);
935 extern void annotate_all_with_location (gimple_seq, location_t);
937 /* Validation of GIMPLE expressions. Note that these predicates only check
938 the basic form of the expression, they don't recurse to make sure that
939 underlying nodes are also of the right form. */
940 typedef bool (*gimple_predicate)(tree);
943 /* FIXME we should deduce this from the predicate. */
945 fb_none = 0, /* Do not generate a temporary. */
947 fb_rvalue = 1, /* Generate an rvalue to hold the result of a
948 gimplified expression. */
950 fb_lvalue = 2, /* Generate an lvalue to hold the result of a
951 gimplified expression. */
953 fb_mayfail = 4, /* Gimplification may fail. Error issued
955 fb_either= fb_rvalue | fb_lvalue
958 typedef int fallback_t;
960 enum gimplify_status {
961 GS_ERROR = -2, /* Something Bad Seen. */
962 GS_UNHANDLED = -1, /* A langhook result for "I dunno". */
963 GS_OK = 0, /* We did something, maybe more to do. */
964 GS_ALL_DONE = 1 /* The expression is fully gimplified. */
969 struct gimplify_ctx *prev_context;
971 VEC(gimple,heap) *bind_expr_stack;
973 gimple_seq conditional_cleanups;
977 VEC(tree,heap) *case_labels;
978 /* The formal temporary table. Should this be persistent? */
984 bool allow_rhs_cond_expr;
987 extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *,
988 bool (*) (tree), fallback_t);
989 extern void gimplify_type_sizes (tree, gimple_seq *);
990 extern void gimplify_one_sizepos (tree *, gimple_seq *);
991 extern bool gimplify_stmt (tree *, gimple_seq *);
992 extern gimple gimplify_body (tree *, tree, bool);
993 extern void push_gimplify_context (struct gimplify_ctx *);
994 extern void pop_gimplify_context (gimple);
995 extern void gimplify_and_add (tree, gimple_seq *);
997 /* Miscellaneous helpers. */
998 extern void gimple_add_tmp_var (tree);
999 extern gimple gimple_current_bind_expr (void);
1000 extern VEC(gimple, heap) *gimple_bind_expr_stack (void);
1001 extern tree voidify_wrapper_expr (tree, tree);
1002 extern tree build_and_jump (tree *);
1003 extern tree alloc_stmt_list (void);
1004 extern void free_stmt_list (tree);
1005 extern tree force_labels_r (tree *, int *, void *);
1006 extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *,
1008 struct gimplify_omp_ctx;
1009 extern void omp_firstprivatize_variable (struct gimplify_omp_ctx *, tree);
1010 extern tree gimple_boolify (tree);
1011 extern gimple_predicate rhs_predicate_for (tree);
1012 extern tree canonicalize_cond_expr_cond (tree);
1015 extern tree omp_reduction_init (tree, tree);
1017 /* In tree-nested.c. */
1018 extern void lower_nested_functions (tree);
1019 extern void insert_field_into_struct (tree, tree);
1021 /* In gimplify.c. */
1022 extern void gimplify_function_tree (tree);
1024 /* In cfgexpand.c. */
1025 extern tree gimple_assign_rhs_to_tree (gimple);
1028 extern bool validate_gimple_arglist (const_gimple, ...);
1031 extern bool tree_ssa_useless_type_conversion (tree);
1032 extern tree tree_ssa_strip_useless_type_conversions (tree);
1033 extern bool useless_type_conversion_p (tree, tree);
1034 extern bool types_compatible_p (tree, tree);
1036 /* Return the code for GIMPLE statement G. */
1038 static inline enum gimple_code
1039 gimple_code (const_gimple g)
1041 return g->gsbase.code;
1045 /* Return the GSS code used by a GIMPLE code. */
1047 static inline enum gimple_statement_structure_enum
1048 gss_for_code (enum gimple_code code)
1050 gcc_assert ((unsigned int)code < LAST_AND_UNUSED_GIMPLE_CODE);
1051 return gss_for_code_[code];
1055 /* Return which GSS code is used by GS. */
1057 static inline enum gimple_statement_structure_enum
1058 gimple_statement_structure (gimple gs)
1060 return gss_for_code (gimple_code (gs));
1064 /* Return true if statement G has sub-statements. This is only true for
1065 High GIMPLE statements. */
1068 gimple_has_substatements (gimple g)
1070 switch (gimple_code (g))
1074 case GIMPLE_EH_FILTER:
1076 case GIMPLE_OMP_FOR:
1077 case GIMPLE_OMP_MASTER:
1078 case GIMPLE_OMP_ORDERED:
1079 case GIMPLE_OMP_SECTION:
1080 case GIMPLE_OMP_PARALLEL:
1081 case GIMPLE_OMP_TASK:
1082 case GIMPLE_OMP_SECTIONS:
1083 case GIMPLE_OMP_SINGLE:
1084 case GIMPLE_OMP_CRITICAL:
1085 case GIMPLE_WITH_CLEANUP_EXPR:
1094 /* Return the basic block holding statement G. */
1096 static inline struct basic_block_def *
1097 gimple_bb (const_gimple g)
1099 return g->gsbase.bb;
1103 /* Return the lexical scope block holding statement G. */
1106 gimple_block (const_gimple g)
1108 return g->gsbase.block;
1112 /* Set BLOCK to be the lexical scope block holding statement G. */
1115 gimple_set_block (gimple g, tree block)
1117 g->gsbase.block = block;
1121 /* Return location information for statement G. */
1123 static inline location_t
1124 gimple_location (const_gimple g)
1126 return g->gsbase.location;
1129 /* Return pointer to location information for statement G. */
1131 static inline const location_t *
1132 gimple_location_ptr (const_gimple g)
1134 return &g->gsbase.location;
1138 /* Set location information for statement G. */
1141 gimple_set_location (gimple g, location_t location)
1143 g->gsbase.location = location;
1147 /* Return true if G contains location information. */
1150 gimple_has_location (const_gimple g)
1152 return gimple_location (g) != UNKNOWN_LOCATION;
1156 /* Return the file name of the location of STMT. */
1158 static inline const char *
1159 gimple_filename (const_gimple stmt)
1161 return LOCATION_FILE (gimple_location (stmt));
1165 /* Return the line number of the location of STMT. */
1168 gimple_lineno (const_gimple stmt)
1170 return LOCATION_LINE (gimple_location (stmt));
1174 /* Determine whether SEQ is a singleton. */
1177 gimple_seq_singleton_p (gimple_seq seq)
1179 return ((gimple_seq_first (seq) != NULL)
1180 && (gimple_seq_first (seq) == gimple_seq_last (seq)));
1183 /* Return true if no warnings should be emitted for statement STMT. */
1186 gimple_no_warning_p (const_gimple stmt)
1188 return stmt->gsbase.no_warning;
1191 /* Set the no_warning flag of STMT to NO_WARNING. */
1194 gimple_set_no_warning (gimple stmt, bool no_warning)
1196 stmt->gsbase.no_warning = (unsigned) no_warning;
1199 /* Set the visited status on statement STMT to VISITED_P. */
1202 gimple_set_visited (gimple stmt, bool visited_p)
1204 stmt->gsbase.visited = (unsigned) visited_p;
1208 /* Return the visited status for statement STMT. */
1211 gimple_visited_p (gimple stmt)
1213 return stmt->gsbase.visited;
1217 /* Set pass local flag PLF on statement STMT to VAL_P. */
1220 gimple_set_plf (gimple stmt, enum plf_mask plf, bool val_p)
1223 stmt->gsbase.plf |= (unsigned int) plf;
1225 stmt->gsbase.plf &= ~((unsigned int) plf);
1229 /* Return the value of pass local flag PLF on statement STMT. */
1231 static inline unsigned int
1232 gimple_plf (gimple stmt, enum plf_mask plf)
1234 return stmt->gsbase.plf & ((unsigned int) plf);
1238 /* Set the UID of statement. */
1241 gimple_set_uid (gimple g, unsigned uid)
1243 g->gsbase.uid = uid;
1247 /* Return the UID of statement. */
1249 static inline unsigned
1250 gimple_uid (const_gimple g)
1252 return g->gsbase.uid;
1256 /* Return true if GIMPLE statement G has register or memory operands. */
1259 gimple_has_ops (const_gimple g)
1261 return gimple_code (g) >= GIMPLE_COND && gimple_code (g) <= GIMPLE_RETURN;
1265 /* Return true if GIMPLE statement G has memory operands. */
1268 gimple_has_mem_ops (const_gimple g)
1270 return gimple_code (g) >= GIMPLE_ASSIGN && gimple_code (g) <= GIMPLE_RETURN;
1274 /* Return the set of DEF operands for statement G. */
1276 static inline struct def_optype_d *
1277 gimple_def_ops (const_gimple g)
1279 if (!gimple_has_ops (g))
1281 return g->gsops.opbase.def_ops;
1285 /* Set DEF to be the set of DEF operands for statement G. */
1288 gimple_set_def_ops (gimple g, struct def_optype_d *def)
1290 gcc_assert (gimple_has_ops (g));
1291 g->gsops.opbase.def_ops = def;
1295 /* Return the set of USE operands for statement G. */
1297 static inline struct use_optype_d *
1298 gimple_use_ops (const_gimple g)
1300 if (!gimple_has_ops (g))
1302 return g->gsops.opbase.use_ops;
1306 /* Set USE to be the set of USE operands for statement G. */
1309 gimple_set_use_ops (gimple g, struct use_optype_d *use)
1311 gcc_assert (gimple_has_ops (g));
1312 g->gsops.opbase.use_ops = use;
1316 /* Return the set of VUSE operand for statement G. */
1318 static inline use_operand_p
1319 gimple_vuse_op (const_gimple g)
1321 struct use_optype_d *ops;
1322 if (!gimple_has_mem_ops (g))
1323 return NULL_USE_OPERAND_P;
1324 ops = g->gsops.opbase.use_ops;
1326 && USE_OP_PTR (ops)->use == &g->gsmem.membase.vuse)
1327 return USE_OP_PTR (ops);
1328 return NULL_USE_OPERAND_P;
1331 /* Return the set of VDEF operand for statement G. */
1333 static inline def_operand_p
1334 gimple_vdef_op (const_gimple g)
1336 struct def_optype_d *ops;
1337 if (!gimple_has_mem_ops (g))
1338 return NULL_DEF_OPERAND_P;
1339 ops = g->gsops.opbase.def_ops;
1341 && DEF_OP_PTR (ops) == &g->gsmem.membase.vdef)
1342 return DEF_OP_PTR (ops);
1343 return NULL_DEF_OPERAND_P;
1347 /* Return the single VUSE operand of the statement G. */
1350 gimple_vuse (const_gimple g)
1352 if (!gimple_has_mem_ops (g))
1354 return g->gsmem.membase.vuse;
1357 /* Return the single VDEF operand of the statement G. */
1360 gimple_vdef (const_gimple g)
1362 if (!gimple_has_mem_ops (g))
1364 return g->gsmem.membase.vdef;
1367 /* Return the single VUSE operand of the statement G. */
1369 static inline tree *
1370 gimple_vuse_ptr (gimple g)
1372 if (!gimple_has_mem_ops (g))
1374 return &g->gsmem.membase.vuse;
1377 /* Return the single VDEF operand of the statement G. */
1379 static inline tree *
1380 gimple_vdef_ptr (gimple g)
1382 if (!gimple_has_mem_ops (g))
1384 return &g->gsmem.membase.vdef;
1387 /* Set the single VUSE operand of the statement G. */
1390 gimple_set_vuse (gimple g, tree vuse)
1392 gcc_assert (gimple_has_mem_ops (g));
1393 g->gsmem.membase.vuse = vuse;
1396 /* Set the single VDEF operand of the statement G. */
1399 gimple_set_vdef (gimple g, tree vdef)
1401 gcc_assert (gimple_has_mem_ops (g));
1402 g->gsmem.membase.vdef = vdef;
1406 /* Return true if statement G has operands and the modified field has
1410 gimple_modified_p (const_gimple g)
1412 return (gimple_has_ops (g)) ? (bool) g->gsbase.modified : false;
1416 /* Return the tree code for the expression computed by STMT. This is
1417 only valid for GIMPLE_COND, GIMPLE_CALL and GIMPLE_ASSIGN. For
1418 GIMPLE_CALL, return CALL_EXPR as the expression code for
1419 consistency. This is useful when the caller needs to deal with the
1420 three kinds of computation that GIMPLE supports. */
1422 static inline enum tree_code
1423 gimple_expr_code (const_gimple stmt)
1425 enum gimple_code code = gimple_code (stmt);
1426 if (code == GIMPLE_ASSIGN || code == GIMPLE_COND)
1427 return (enum tree_code) stmt->gsbase.subcode;
1428 else if (code == GIMPLE_CALL)
1435 /* Mark statement S as modified, and update it. */
1438 update_stmt (gimple s)
1440 if (gimple_has_ops (s))
1442 gimple_set_modified (s, true);
1443 update_stmt_operands (s);
1447 /* Update statement S if it has been optimized. */
1450 update_stmt_if_modified (gimple s)
1452 if (gimple_modified_p (s))
1453 update_stmt_operands (s);
1456 /* Return true if statement STMT contains volatile operands. */
1459 gimple_has_volatile_ops (const_gimple stmt)
1461 if (gimple_has_mem_ops (stmt))
1462 return stmt->gsbase.has_volatile_ops;
1468 /* Set the HAS_VOLATILE_OPS flag to VOLATILEP. */
1471 gimple_set_has_volatile_ops (gimple stmt, bool volatilep)
1473 if (gimple_has_mem_ops (stmt))
1474 stmt->gsbase.has_volatile_ops = (unsigned) volatilep;
1478 /* Return true if statement STMT may access memory. */
1481 gimple_references_memory_p (gimple stmt)
1483 return gimple_has_mem_ops (stmt) && gimple_vuse (stmt);
1487 /* Return the subcode for OMP statement S. */
1489 static inline unsigned
1490 gimple_omp_subcode (const_gimple s)
1492 gcc_assert (gimple_code (s) >= GIMPLE_OMP_ATOMIC_LOAD
1493 && gimple_code (s) <= GIMPLE_OMP_SINGLE);
1494 return s->gsbase.subcode;
1497 /* Set the subcode for OMP statement S to SUBCODE. */
1500 gimple_omp_set_subcode (gimple s, unsigned int subcode)
1502 /* We only have 16 bits for the subcode. Assert that we are not
1504 gcc_assert (subcode < (1 << 16));
1505 s->gsbase.subcode = subcode;
1508 /* Set the nowait flag on OMP_RETURN statement S. */
1511 gimple_omp_return_set_nowait (gimple s)
1513 GIMPLE_CHECK (s, GIMPLE_OMP_RETURN);
1514 s->gsbase.subcode |= GF_OMP_RETURN_NOWAIT;
1518 /* Return true if OMP return statement G has the GF_OMP_RETURN_NOWAIT
1522 gimple_omp_return_nowait_p (const_gimple g)
1524 GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
1525 return (gimple_omp_subcode (g) & GF_OMP_RETURN_NOWAIT) != 0;
1529 /* Return true if OMP section statement G has the GF_OMP_SECTION_LAST
1533 gimple_omp_section_last_p (const_gimple g)
1535 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1536 return (gimple_omp_subcode (g) & GF_OMP_SECTION_LAST) != 0;
1540 /* Set the GF_OMP_SECTION_LAST flag on G. */
1543 gimple_omp_section_set_last (gimple g)
1545 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1546 g->gsbase.subcode |= GF_OMP_SECTION_LAST;
1550 /* Return true if OMP parallel statement G has the
1551 GF_OMP_PARALLEL_COMBINED flag set. */
1554 gimple_omp_parallel_combined_p (const_gimple g)
1556 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1557 return (gimple_omp_subcode (g) & GF_OMP_PARALLEL_COMBINED) != 0;
1561 /* Set the GF_OMP_PARALLEL_COMBINED field in G depending on the boolean
1562 value of COMBINED_P. */
1565 gimple_omp_parallel_set_combined_p (gimple g, bool combined_p)
1567 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1569 g->gsbase.subcode |= GF_OMP_PARALLEL_COMBINED;
1571 g->gsbase.subcode &= ~GF_OMP_PARALLEL_COMBINED;
1575 /* Return the number of operands for statement GS. */
1577 static inline unsigned
1578 gimple_num_ops (const_gimple gs)
1580 return gs->gsbase.num_ops;
1584 /* Set the number of operands for statement GS. */
1587 gimple_set_num_ops (gimple gs, unsigned num_ops)
1589 gs->gsbase.num_ops = num_ops;
1593 /* Return the array of operands for statement GS. */
1595 static inline tree *
1596 gimple_ops (gimple gs)
1600 /* All the tuples have their operand vector at the very bottom
1601 of the structure. Note that those structures that do not
1602 have an operand vector have a zero offset. */
1603 off = gimple_ops_offset_[gimple_statement_structure (gs)];
1604 gcc_assert (off != 0);
1606 return (tree *) ((char *) gs + off);
1610 /* Return operand I for statement GS. */
1613 gimple_op (const_gimple gs, unsigned i)
1615 if (gimple_has_ops (gs))
1617 gcc_assert (i < gimple_num_ops (gs));
1618 return gimple_ops (CONST_CAST_GIMPLE (gs))[i];
1624 /* Return a pointer to operand I for statement GS. */
1626 static inline tree *
1627 gimple_op_ptr (const_gimple gs, unsigned i)
1629 if (gimple_has_ops (gs))
1631 gcc_assert (i < gimple_num_ops (gs));
1632 return gimple_ops (CONST_CAST_GIMPLE (gs)) + i;
1638 /* Set operand I of statement GS to OP. */
1641 gimple_set_op (gimple gs, unsigned i, tree op)
1643 gcc_assert (gimple_has_ops (gs) && i < gimple_num_ops (gs));
1645 /* Note. It may be tempting to assert that OP matches
1646 is_gimple_operand, but that would be wrong. Different tuples
1647 accept slightly different sets of tree operands. Each caller
1648 should perform its own validation. */
1649 gimple_ops (gs)[i] = op;
1652 /* Return true if GS is a GIMPLE_ASSIGN. */
1655 is_gimple_assign (const_gimple gs)
1657 return gimple_code (gs) == GIMPLE_ASSIGN;
1660 /* Determine if expression CODE is one of the valid expressions that can
1661 be used on the RHS of GIMPLE assignments. */
1663 static inline enum gimple_rhs_class
1664 get_gimple_rhs_class (enum tree_code code)
1666 return (enum gimple_rhs_class) gimple_rhs_class_table[(int) code];
1669 /* Return the LHS of assignment statement GS. */
1672 gimple_assign_lhs (const_gimple gs)
1674 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1675 return gimple_op (gs, 0);
1679 /* Return a pointer to the LHS of assignment statement GS. */
1681 static inline tree *
1682 gimple_assign_lhs_ptr (const_gimple gs)
1684 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1685 return gimple_op_ptr (gs, 0);
1689 /* Set LHS to be the LHS operand of assignment statement GS. */
1692 gimple_assign_set_lhs (gimple gs, tree lhs)
1694 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1695 gcc_assert (is_gimple_operand (lhs));
1696 gimple_set_op (gs, 0, lhs);
1698 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1699 SSA_NAME_DEF_STMT (lhs) = gs;
1703 /* Return the first operand on the RHS of assignment statement GS. */
1706 gimple_assign_rhs1 (const_gimple gs)
1708 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1709 return gimple_op (gs, 1);
1713 /* Return a pointer to the first operand on the RHS of assignment
1716 static inline tree *
1717 gimple_assign_rhs1_ptr (const_gimple gs)
1719 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1720 return gimple_op_ptr (gs, 1);
1723 /* Set RHS to be the first operand on the RHS of assignment statement GS. */
1726 gimple_assign_set_rhs1 (gimple gs, tree rhs)
1728 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1730 /* If there are 3 or more operands, the 2 operands on the RHS must be
1732 if (gimple_num_ops (gs) >= 3)
1733 gcc_assert (is_gimple_val (rhs));
1735 gcc_assert (is_gimple_operand (rhs));
1737 gimple_set_op (gs, 1, rhs);
1741 /* Return the second operand on the RHS of assignment statement GS.
1742 If GS does not have two operands, NULL is returned instead. */
1745 gimple_assign_rhs2 (const_gimple gs)
1747 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1749 if (gimple_num_ops (gs) >= 3)
1750 return gimple_op (gs, 2);
1756 /* Return a pointer to the second operand on the RHS of assignment
1759 static inline tree *
1760 gimple_assign_rhs2_ptr (const_gimple gs)
1762 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1763 return gimple_op_ptr (gs, 2);
1767 /* Set RHS to be the second operand on the RHS of assignment statement GS. */
1770 gimple_assign_set_rhs2 (gimple gs, tree rhs)
1772 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1774 /* The 2 operands on the RHS must be GIMPLE values. */
1775 gcc_assert (is_gimple_val (rhs));
1777 gimple_set_op (gs, 2, rhs);
1780 /* Returns true if GS is a nontemporal move. */
1783 gimple_assign_nontemporal_move_p (const_gimple gs)
1785 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1786 return gs->gsbase.nontemporal_move;
1789 /* Sets nontemporal move flag of GS to NONTEMPORAL. */
1792 gimple_assign_set_nontemporal_move (gimple gs, bool nontemporal)
1794 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1795 gs->gsbase.nontemporal_move = nontemporal;
1799 /* Return the code of the expression computed on the rhs of assignment
1800 statement GS. In case that the RHS is a single object, returns the
1801 tree code of the object. */
1803 static inline enum tree_code
1804 gimple_assign_rhs_code (const_gimple gs)
1806 enum tree_code code;
1807 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1809 code = gimple_expr_code (gs);
1810 if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS)
1811 code = TREE_CODE (gimple_assign_rhs1 (gs));
1817 /* Set CODE to be the code for the expression computed on the RHS of
1821 gimple_assign_set_rhs_code (gimple s, enum tree_code code)
1823 GIMPLE_CHECK (s, GIMPLE_ASSIGN);
1824 s->gsbase.subcode = code;
1828 /* Return the gimple rhs class of the code of the expression computed on
1829 the rhs of assignment statement GS.
1830 This will never return GIMPLE_INVALID_RHS. */
1832 static inline enum gimple_rhs_class
1833 gimple_assign_rhs_class (const_gimple gs)
1835 return get_gimple_rhs_class (gimple_assign_rhs_code (gs));
1839 /* Return true if S is a type-cast assignment. */
1842 gimple_assign_cast_p (gimple s)
1844 if (is_gimple_assign (s))
1846 enum tree_code sc = gimple_assign_rhs_code (s);
1847 return CONVERT_EXPR_CODE_P (sc)
1848 || sc == VIEW_CONVERT_EXPR
1849 || sc == FIX_TRUNC_EXPR;
1856 /* Return true if GS is a GIMPLE_CALL. */
1859 is_gimple_call (const_gimple gs)
1861 return gimple_code (gs) == GIMPLE_CALL;
1864 /* Return the LHS of call statement GS. */
1867 gimple_call_lhs (const_gimple gs)
1869 GIMPLE_CHECK (gs, GIMPLE_CALL);
1870 return gimple_op (gs, 0);
1874 /* Return a pointer to the LHS of call statement GS. */
1876 static inline tree *
1877 gimple_call_lhs_ptr (const_gimple gs)
1879 GIMPLE_CHECK (gs, GIMPLE_CALL);
1880 return gimple_op_ptr (gs, 0);
1884 /* Set LHS to be the LHS operand of call statement GS. */
1887 gimple_call_set_lhs (gimple gs, tree lhs)
1889 GIMPLE_CHECK (gs, GIMPLE_CALL);
1890 gcc_assert (!lhs || is_gimple_operand (lhs));
1891 gimple_set_op (gs, 0, lhs);
1892 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1893 SSA_NAME_DEF_STMT (lhs) = gs;
1897 /* Return the tree node representing the function called by call
1901 gimple_call_fn (const_gimple gs)
1903 GIMPLE_CHECK (gs, GIMPLE_CALL);
1904 return gimple_op (gs, 1);
1908 /* Return a pointer to the tree node representing the function called by call
1911 static inline tree *
1912 gimple_call_fn_ptr (const_gimple gs)
1914 GIMPLE_CHECK (gs, GIMPLE_CALL);
1915 return gimple_op_ptr (gs, 1);
1919 /* Set FN to be the function called by call statement GS. */
1922 gimple_call_set_fn (gimple gs, tree fn)
1924 GIMPLE_CHECK (gs, GIMPLE_CALL);
1925 gcc_assert (is_gimple_operand (fn));
1926 gimple_set_op (gs, 1, fn);
1930 /* Set FNDECL to be the function called by call statement GS. */
1933 gimple_call_set_fndecl (gimple gs, tree decl)
1935 GIMPLE_CHECK (gs, GIMPLE_CALL);
1936 gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
1937 gimple_set_op (gs, 1, build_fold_addr_expr_loc (gimple_location (gs), decl));
1941 /* If a given GIMPLE_CALL's callee is a FUNCTION_DECL, return it.
1942 Otherwise return NULL. This function is analogous to
1943 get_callee_fndecl in tree land. */
1946 gimple_call_fndecl (const_gimple gs)
1948 tree addr = gimple_call_fn (gs);
1949 if (TREE_CODE (addr) == ADDR_EXPR)
1951 gcc_assert (TREE_CODE (TREE_OPERAND (addr, 0)) == FUNCTION_DECL);
1952 return TREE_OPERAND (addr, 0);
1958 /* Return the type returned by call statement GS. */
1961 gimple_call_return_type (const_gimple gs)
1963 tree fn = gimple_call_fn (gs);
1964 tree type = TREE_TYPE (fn);
1966 /* See through the pointer. */
1967 gcc_assert (POINTER_TYPE_P (type));
1968 type = TREE_TYPE (type);
1970 gcc_assert (TREE_CODE (type) == FUNCTION_TYPE
1971 || TREE_CODE (type) == METHOD_TYPE);
1973 /* The type returned by a FUNCTION_DECL is the type of its
1975 return TREE_TYPE (type);
1979 /* Return the static chain for call statement GS. */
1982 gimple_call_chain (const_gimple gs)
1984 GIMPLE_CHECK (gs, GIMPLE_CALL);
1985 return gimple_op (gs, 2);
1989 /* Return a pointer to the static chain for call statement GS. */
1991 static inline tree *
1992 gimple_call_chain_ptr (const_gimple gs)
1994 GIMPLE_CHECK (gs, GIMPLE_CALL);
1995 return gimple_op_ptr (gs, 2);
1998 /* Set CHAIN to be the static chain for call statement GS. */
2001 gimple_call_set_chain (gimple gs, tree chain)
2003 GIMPLE_CHECK (gs, GIMPLE_CALL);
2004 gcc_assert (chain == NULL
2005 || TREE_CODE (chain) == ADDR_EXPR
2006 || SSA_VAR_P (chain));
2007 gimple_set_op (gs, 2, chain);
2011 /* Return the number of arguments used by call statement GS. */
2013 static inline unsigned
2014 gimple_call_num_args (const_gimple gs)
2017 GIMPLE_CHECK (gs, GIMPLE_CALL);
2018 num_ops = gimple_num_ops (gs);
2019 gcc_assert (num_ops >= 3);
2024 /* Return the argument at position INDEX for call statement GS. */
2027 gimple_call_arg (const_gimple gs, unsigned index)
2029 GIMPLE_CHECK (gs, GIMPLE_CALL);
2030 return gimple_op (gs, index + 3);
2034 /* Return a pointer to the argument at position INDEX for call
2037 static inline tree *
2038 gimple_call_arg_ptr (const_gimple gs, unsigned index)
2040 GIMPLE_CHECK (gs, GIMPLE_CALL);
2041 return gimple_op_ptr (gs, index + 3);
2045 /* Set ARG to be the argument at position INDEX for call statement GS. */
2048 gimple_call_set_arg (gimple gs, unsigned index, tree arg)
2050 GIMPLE_CHECK (gs, GIMPLE_CALL);
2051 gcc_assert (is_gimple_operand (arg));
2052 gimple_set_op (gs, index + 3, arg);
2056 /* If TAIL_P is true, mark call statement S as being a tail call
2057 (i.e., a call just before the exit of a function). These calls are
2058 candidate for tail call optimization. */
2061 gimple_call_set_tail (gimple s, bool tail_p)
2063 GIMPLE_CHECK (s, GIMPLE_CALL);
2065 s->gsbase.subcode |= GF_CALL_TAILCALL;
2067 s->gsbase.subcode &= ~GF_CALL_TAILCALL;
2071 /* Return true if GIMPLE_CALL S is marked as a tail call. */
2074 gimple_call_tail_p (gimple s)
2076 GIMPLE_CHECK (s, GIMPLE_CALL);
2077 return (s->gsbase.subcode & GF_CALL_TAILCALL) != 0;
2081 /* Set the inlinable status of GIMPLE_CALL S to INLINABLE_P. */
2084 gimple_call_set_cannot_inline (gimple s, bool inlinable_p)
2086 GIMPLE_CHECK (s, GIMPLE_CALL);
2088 s->gsbase.subcode |= GF_CALL_CANNOT_INLINE;
2090 s->gsbase.subcode &= ~GF_CALL_CANNOT_INLINE;
2094 /* Return true if GIMPLE_CALL S cannot be inlined. */
2097 gimple_call_cannot_inline_p (gimple s)
2099 GIMPLE_CHECK (s, GIMPLE_CALL);
2100 return (s->gsbase.subcode & GF_CALL_CANNOT_INLINE) != 0;
2104 /* If RETURN_SLOT_OPT_P is true mark GIMPLE_CALL S as valid for return
2105 slot optimization. This transformation uses the target of the call
2106 expansion as the return slot for calls that return in memory. */
2109 gimple_call_set_return_slot_opt (gimple s, bool return_slot_opt_p)
2111 GIMPLE_CHECK (s, GIMPLE_CALL);
2112 if (return_slot_opt_p)
2113 s->gsbase.subcode |= GF_CALL_RETURN_SLOT_OPT;
2115 s->gsbase.subcode &= ~GF_CALL_RETURN_SLOT_OPT;
2119 /* Return true if S is marked for return slot optimization. */
2122 gimple_call_return_slot_opt_p (gimple s)
2124 GIMPLE_CHECK (s, GIMPLE_CALL);
2125 return (s->gsbase.subcode & GF_CALL_RETURN_SLOT_OPT) != 0;
2129 /* If FROM_THUNK_P is true, mark GIMPLE_CALL S as being the jump from a
2130 thunk to the thunked-to function. */
2133 gimple_call_set_from_thunk (gimple s, bool from_thunk_p)
2135 GIMPLE_CHECK (s, GIMPLE_CALL);
2137 s->gsbase.subcode |= GF_CALL_FROM_THUNK;
2139 s->gsbase.subcode &= ~GF_CALL_FROM_THUNK;
2143 /* Return true if GIMPLE_CALL S is a jump from a thunk. */
2146 gimple_call_from_thunk_p (gimple s)
2148 GIMPLE_CHECK (s, GIMPLE_CALL);
2149 return (s->gsbase.subcode & GF_CALL_FROM_THUNK) != 0;
2153 /* If PASS_ARG_PACK_P is true, GIMPLE_CALL S is a stdarg call that needs the
2154 argument pack in its argument list. */
2157 gimple_call_set_va_arg_pack (gimple s, bool pass_arg_pack_p)
2159 GIMPLE_CHECK (s, GIMPLE_CALL);
2160 if (pass_arg_pack_p)
2161 s->gsbase.subcode |= GF_CALL_VA_ARG_PACK;
2163 s->gsbase.subcode &= ~GF_CALL_VA_ARG_PACK;
2167 /* Return true if GIMPLE_CALL S is a stdarg call that needs the
2168 argument pack in its argument list. */
2171 gimple_call_va_arg_pack_p (gimple s)
2173 GIMPLE_CHECK (s, GIMPLE_CALL);
2174 return (s->gsbase.subcode & GF_CALL_VA_ARG_PACK) != 0;
2178 /* Return true if S is a noreturn call. */
2181 gimple_call_noreturn_p (gimple s)
2183 GIMPLE_CHECK (s, GIMPLE_CALL);
2184 return (gimple_call_flags (s) & ECF_NORETURN) != 0;
2188 /* Return true if S is a nothrow call. */
2191 gimple_call_nothrow_p (gimple s)
2193 GIMPLE_CHECK (s, GIMPLE_CALL);
2194 return (gimple_call_flags (s) & ECF_NOTHROW) != 0;
2198 /* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL. */
2201 gimple_call_copy_flags (gimple dest_call, gimple orig_call)
2203 GIMPLE_CHECK (dest_call, GIMPLE_CALL);
2204 GIMPLE_CHECK (orig_call, GIMPLE_CALL);
2205 dest_call->gsbase.subcode = orig_call->gsbase.subcode;
2209 /* Returns true if this is a GIMPLE_ASSIGN or a GIMPLE_CALL with a
2213 gimple_has_lhs (gimple stmt)
2215 return (is_gimple_assign (stmt)
2216 || (is_gimple_call (stmt)
2217 && gimple_call_lhs (stmt) != NULL_TREE));
2221 /* Return the code of the predicate computed by conditional statement GS. */
2223 static inline enum tree_code
2224 gimple_cond_code (const_gimple gs)
2226 GIMPLE_CHECK (gs, GIMPLE_COND);
2227 return (enum tree_code) gs->gsbase.subcode;
2231 /* Set CODE to be the predicate code for the conditional statement GS. */
2234 gimple_cond_set_code (gimple gs, enum tree_code code)
2236 GIMPLE_CHECK (gs, GIMPLE_COND);
2237 gcc_assert (TREE_CODE_CLASS (code) == tcc_comparison);
2238 gs->gsbase.subcode = code;
2242 /* Return the LHS of the predicate computed by conditional statement GS. */
2245 gimple_cond_lhs (const_gimple gs)
2247 GIMPLE_CHECK (gs, GIMPLE_COND);
2248 return gimple_op (gs, 0);
2251 /* Return the pointer to the LHS of the predicate computed by conditional
2254 static inline tree *
2255 gimple_cond_lhs_ptr (const_gimple gs)
2257 GIMPLE_CHECK (gs, GIMPLE_COND);
2258 return gimple_op_ptr (gs, 0);
2261 /* Set LHS to be the LHS operand of the predicate computed by
2262 conditional statement GS. */
2265 gimple_cond_set_lhs (gimple gs, tree lhs)
2267 GIMPLE_CHECK (gs, GIMPLE_COND);
2268 gcc_assert (is_gimple_operand (lhs));
2269 gimple_set_op (gs, 0, lhs);
2273 /* Return the RHS operand of the predicate computed by conditional GS. */
2276 gimple_cond_rhs (const_gimple gs)
2278 GIMPLE_CHECK (gs, GIMPLE_COND);
2279 return gimple_op (gs, 1);
2282 /* Return the pointer to the RHS operand of the predicate computed by
2285 static inline tree *
2286 gimple_cond_rhs_ptr (const_gimple gs)
2288 GIMPLE_CHECK (gs, GIMPLE_COND);
2289 return gimple_op_ptr (gs, 1);
2293 /* Set RHS to be the RHS operand of the predicate computed by
2294 conditional statement GS. */
2297 gimple_cond_set_rhs (gimple gs, tree rhs)
2299 GIMPLE_CHECK (gs, GIMPLE_COND);
2300 gcc_assert (is_gimple_operand (rhs));
2301 gimple_set_op (gs, 1, rhs);
2305 /* Return the label used by conditional statement GS when its
2306 predicate evaluates to true. */
2309 gimple_cond_true_label (const_gimple gs)
2311 GIMPLE_CHECK (gs, GIMPLE_COND);
2312 return gimple_op (gs, 2);
2316 /* Set LABEL to be the label used by conditional statement GS when its
2317 predicate evaluates to true. */
2320 gimple_cond_set_true_label (gimple gs, tree label)
2322 GIMPLE_CHECK (gs, GIMPLE_COND);
2323 gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
2324 gimple_set_op (gs, 2, label);
2328 /* Set LABEL to be the label used by conditional statement GS when its
2329 predicate evaluates to false. */
2332 gimple_cond_set_false_label (gimple gs, tree label)
2334 GIMPLE_CHECK (gs, GIMPLE_COND);
2335 gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
2336 gimple_set_op (gs, 3, label);
2340 /* Return the label used by conditional statement GS when its
2341 predicate evaluates to false. */
2344 gimple_cond_false_label (const_gimple gs)
2346 GIMPLE_CHECK (gs, GIMPLE_COND);
2347 return gimple_op (gs, 3);
2351 /* Set the conditional COND_STMT to be of the form 'if (1 == 0)'. */
2354 gimple_cond_make_false (gimple gs)
2356 gimple_cond_set_lhs (gs, boolean_true_node);
2357 gimple_cond_set_rhs (gs, boolean_false_node);
2358 gs->gsbase.subcode = EQ_EXPR;
2362 /* Set the conditional COND_STMT to be of the form 'if (1 == 1)'. */
2365 gimple_cond_make_true (gimple gs)
2367 gimple_cond_set_lhs (gs, boolean_true_node);
2368 gimple_cond_set_rhs (gs, boolean_true_node);
2369 gs->gsbase.subcode = EQ_EXPR;
2372 /* Check if conditional statemente GS is of the form 'if (1 == 1)',
2373 'if (0 == 0)', 'if (1 != 0)' or 'if (0 != 1)' */
2376 gimple_cond_true_p (const_gimple gs)
2378 tree lhs = gimple_cond_lhs (gs);
2379 tree rhs = gimple_cond_rhs (gs);
2380 enum tree_code code = gimple_cond_code (gs);
2382 if (lhs != boolean_true_node && lhs != boolean_false_node)
2385 if (rhs != boolean_true_node && rhs != boolean_false_node)
2388 if (code == NE_EXPR && lhs != rhs)
2391 if (code == EQ_EXPR && lhs == rhs)
2397 /* Check if conditional statement GS is of the form 'if (1 != 1)',
2398 'if (0 != 0)', 'if (1 == 0)' or 'if (0 == 1)' */
2401 gimple_cond_false_p (const_gimple gs)
2403 tree lhs = gimple_cond_lhs (gs);
2404 tree rhs = gimple_cond_rhs (gs);
2405 enum tree_code code = gimple_cond_code (gs);
2407 if (lhs != boolean_true_node && lhs != boolean_false_node)
2410 if (rhs != boolean_true_node && rhs != boolean_false_node)
2413 if (code == NE_EXPR && lhs == rhs)
2416 if (code == EQ_EXPR && lhs != rhs)
2422 /* Check if conditional statement GS is of the form 'if (var != 0)' or
2426 gimple_cond_single_var_p (gimple gs)
2428 if (gimple_cond_code (gs) == NE_EXPR
2429 && gimple_cond_rhs (gs) == boolean_false_node)
2432 if (gimple_cond_code (gs) == EQ_EXPR
2433 && gimple_cond_rhs (gs) == boolean_true_node)
2439 /* Set the code, LHS and RHS of GIMPLE_COND STMT from CODE, LHS and RHS. */
2442 gimple_cond_set_condition (gimple stmt, enum tree_code code, tree lhs, tree rhs)
2444 gimple_cond_set_code (stmt, code);
2445 gimple_cond_set_lhs (stmt, lhs);
2446 gimple_cond_set_rhs (stmt, rhs);
2449 /* Return the LABEL_DECL node used by GIMPLE_LABEL statement GS. */
2452 gimple_label_label (const_gimple gs)
2454 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2455 return gimple_op (gs, 0);
2459 /* Set LABEL to be the LABEL_DECL node used by GIMPLE_LABEL statement
2463 gimple_label_set_label (gimple gs, tree label)
2465 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2466 gcc_assert (TREE_CODE (label) == LABEL_DECL);
2467 gimple_set_op (gs, 0, label);
2471 /* Return the destination of the unconditional jump GS. */
2474 gimple_goto_dest (const_gimple gs)
2476 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2477 return gimple_op (gs, 0);
2481 /* Set DEST to be the destination of the unconditonal jump GS. */
2484 gimple_goto_set_dest (gimple gs, tree dest)
2486 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2487 gcc_assert (is_gimple_operand (dest));
2488 gimple_set_op (gs, 0, dest);
2492 /* Return the variables declared in the GIMPLE_BIND statement GS. */
2495 gimple_bind_vars (const_gimple gs)
2497 GIMPLE_CHECK (gs, GIMPLE_BIND);
2498 return gs->gimple_bind.vars;
2502 /* Set VARS to be the set of variables declared in the GIMPLE_BIND
2506 gimple_bind_set_vars (gimple gs, tree vars)
2508 GIMPLE_CHECK (gs, GIMPLE_BIND);
2509 gs->gimple_bind.vars = vars;
2513 /* Append VARS to the set of variables declared in the GIMPLE_BIND
2517 gimple_bind_append_vars (gimple gs, tree vars)
2519 GIMPLE_CHECK (gs, GIMPLE_BIND);
2520 gs->gimple_bind.vars = chainon (gs->gimple_bind.vars, vars);
2524 /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS. */
2526 static inline gimple_seq
2527 gimple_bind_body (gimple gs)
2529 GIMPLE_CHECK (gs, GIMPLE_BIND);
2530 return gs->gimple_bind.body;
2534 /* Set SEQ to be the GIMPLE sequence contained in the GIMPLE_BIND
2538 gimple_bind_set_body (gimple gs, gimple_seq seq)
2540 GIMPLE_CHECK (gs, GIMPLE_BIND);
2541 gs->gimple_bind.body = seq;
2545 /* Append a statement to the end of a GIMPLE_BIND's body. */
2548 gimple_bind_add_stmt (gimple gs, gimple stmt)
2550 GIMPLE_CHECK (gs, GIMPLE_BIND);
2551 gimple_seq_add_stmt (&gs->gimple_bind.body, stmt);
2555 /* Append a sequence of statements to the end of a GIMPLE_BIND's body. */
2558 gimple_bind_add_seq (gimple gs, gimple_seq seq)
2560 GIMPLE_CHECK (gs, GIMPLE_BIND);
2561 gimple_seq_add_seq (&gs->gimple_bind.body, seq);
2565 /* Return the TREE_BLOCK node associated with GIMPLE_BIND statement
2566 GS. This is analogous to the BIND_EXPR_BLOCK field in trees. */
2569 gimple_bind_block (const_gimple gs)
2571 GIMPLE_CHECK (gs, GIMPLE_BIND);
2572 return gs->gimple_bind.block;
2576 /* Set BLOCK to be the TREE_BLOCK node associated with GIMPLE_BIND
2580 gimple_bind_set_block (gimple gs, tree block)
2582 GIMPLE_CHECK (gs, GIMPLE_BIND);
2583 gcc_assert (block == NULL_TREE || TREE_CODE (block) == BLOCK);
2584 gs->gimple_bind.block = block;
2588 /* Return the number of input operands for GIMPLE_ASM GS. */
2590 static inline unsigned
2591 gimple_asm_ninputs (const_gimple gs)
2593 GIMPLE_CHECK (gs, GIMPLE_ASM);
2594 return gs->gimple_asm.ni;
2598 /* Return the number of output operands for GIMPLE_ASM GS. */
2600 static inline unsigned
2601 gimple_asm_noutputs (const_gimple gs)
2603 GIMPLE_CHECK (gs, GIMPLE_ASM);
2604 return gs->gimple_asm.no;
2608 /* Return the number of clobber operands for GIMPLE_ASM GS. */
2610 static inline unsigned
2611 gimple_asm_nclobbers (const_gimple gs)
2613 GIMPLE_CHECK (gs, GIMPLE_ASM);
2614 return gs->gimple_asm.nc;
2618 /* Return input operand INDEX of GIMPLE_ASM GS. */
2621 gimple_asm_input_op (const_gimple gs, unsigned index)
2623 GIMPLE_CHECK (gs, GIMPLE_ASM);
2624 gcc_assert (index <= gs->gimple_asm.ni);
2625 return gimple_op (gs, index);
2628 /* Return a pointer to input operand INDEX of GIMPLE_ASM GS. */
2630 static inline tree *
2631 gimple_asm_input_op_ptr (const_gimple gs, unsigned index)
2633 GIMPLE_CHECK (gs, GIMPLE_ASM);
2634 gcc_assert (index <= gs->gimple_asm.ni);
2635 return gimple_op_ptr (gs, index);
2639 /* Set IN_OP to be input operand INDEX in GIMPLE_ASM GS. */
2642 gimple_asm_set_input_op (gimple gs, unsigned index, tree in_op)
2644 GIMPLE_CHECK (gs, GIMPLE_ASM);
2645 gcc_assert (index <= gs->gimple_asm.ni);
2646 gcc_assert (TREE_CODE (in_op) == TREE_LIST);
2647 gimple_set_op (gs, index, in_op);
2651 /* Return output operand INDEX of GIMPLE_ASM GS. */
2654 gimple_asm_output_op (const_gimple gs, unsigned index)
2656 GIMPLE_CHECK (gs, GIMPLE_ASM);
2657 gcc_assert (index <= gs->gimple_asm.no);
2658 return gimple_op (gs, index + gs->gimple_asm.ni);
2661 /* Return a pointer to output operand INDEX of GIMPLE_ASM GS. */
2663 static inline tree *
2664 gimple_asm_output_op_ptr (const_gimple gs, unsigned index)
2666 GIMPLE_CHECK (gs, GIMPLE_ASM);
2667 gcc_assert (index <= gs->gimple_asm.no);
2668 return gimple_op_ptr (gs, index + gs->gimple_asm.ni);
2672 /* Set OUT_OP to be output operand INDEX in GIMPLE_ASM GS. */
2675 gimple_asm_set_output_op (gimple gs, unsigned index, tree out_op)
2677 GIMPLE_CHECK (gs, GIMPLE_ASM);
2678 gcc_assert (index <= gs->gimple_asm.no);
2679 gcc_assert (TREE_CODE (out_op) == TREE_LIST);
2680 gimple_set_op (gs, index + gs->gimple_asm.ni, out_op);
2684 /* Return clobber operand INDEX of GIMPLE_ASM GS. */
2687 gimple_asm_clobber_op (const_gimple gs, unsigned index)
2689 GIMPLE_CHECK (gs, GIMPLE_ASM);
2690 gcc_assert (index <= gs->gimple_asm.nc);
2691 return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no);
2695 /* Set CLOBBER_OP to be clobber operand INDEX in GIMPLE_ASM GS. */
2698 gimple_asm_set_clobber_op (gimple gs, unsigned index, tree clobber_op)
2700 GIMPLE_CHECK (gs, GIMPLE_ASM);
2701 gcc_assert (index <= gs->gimple_asm.nc);
2702 gcc_assert (TREE_CODE (clobber_op) == TREE_LIST);
2703 gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no, clobber_op);
2707 /* Return the string representing the assembly instruction in
2710 static inline const char *
2711 gimple_asm_string (const_gimple gs)
2713 GIMPLE_CHECK (gs, GIMPLE_ASM);
2714 return gs->gimple_asm.string;
2718 /* Return true if GS is an asm statement marked volatile. */
2721 gimple_asm_volatile_p (const_gimple gs)
2723 GIMPLE_CHECK (gs, GIMPLE_ASM);
2724 return (gs->gsbase.subcode & GF_ASM_VOLATILE) != 0;
2728 /* If VOLATLE_P is true, mark asm statement GS as volatile. */
2731 gimple_asm_set_volatile (gimple gs, bool volatile_p)
2733 GIMPLE_CHECK (gs, GIMPLE_ASM);
2735 gs->gsbase.subcode |= GF_ASM_VOLATILE;
2737 gs->gsbase.subcode &= ~GF_ASM_VOLATILE;
2741 /* If INPUT_P is true, mark asm GS as an ASM_INPUT. */
2744 gimple_asm_set_input (gimple gs, bool input_p)
2746 GIMPLE_CHECK (gs, GIMPLE_ASM);
2748 gs->gsbase.subcode |= GF_ASM_INPUT;
2750 gs->gsbase.subcode &= ~GF_ASM_INPUT;
2754 /* Return true if asm GS is an ASM_INPUT. */
2757 gimple_asm_input_p (const_gimple gs)
2759 GIMPLE_CHECK (gs, GIMPLE_ASM);
2760 return (gs->gsbase.subcode & GF_ASM_INPUT) != 0;
2764 /* Return the types handled by GIMPLE_CATCH statement GS. */
2767 gimple_catch_types (const_gimple gs)
2769 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2770 return gs->gimple_catch.types;
2774 /* Return a pointer to the types handled by GIMPLE_CATCH statement GS. */
2776 static inline tree *
2777 gimple_catch_types_ptr (gimple gs)
2779 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2780 return &gs->gimple_catch.types;
2784 /* Return the GIMPLE sequence representing the body of the handler of
2785 GIMPLE_CATCH statement GS. */
2787 static inline gimple_seq
2788 gimple_catch_handler (gimple gs)
2790 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2791 return gs->gimple_catch.handler;
2795 /* Return a pointer to the GIMPLE sequence representing the body of
2796 the handler of GIMPLE_CATCH statement GS. */
2798 static inline gimple_seq *
2799 gimple_catch_handler_ptr (gimple gs)
2801 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2802 return &gs->gimple_catch.handler;
2806 /* Set T to be the set of types handled by GIMPLE_CATCH GS. */
2809 gimple_catch_set_types (gimple gs, tree t)
2811 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2812 gs->gimple_catch.types = t;
2816 /* Set HANDLER to be the body of GIMPLE_CATCH GS. */
2819 gimple_catch_set_handler (gimple gs, gimple_seq handler)
2821 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2822 gs->gimple_catch.handler = handler;
2826 /* Return the types handled by GIMPLE_EH_FILTER statement GS. */
2829 gimple_eh_filter_types (const_gimple gs)
2831 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2832 return gs->gimple_eh_filter.types;
2836 /* Return a pointer to the types handled by GIMPLE_EH_FILTER statement
2839 static inline tree *
2840 gimple_eh_filter_types_ptr (gimple gs)
2842 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2843 return &gs->gimple_eh_filter.types;
2847 /* Return the sequence of statement to execute when GIMPLE_EH_FILTER
2850 static inline gimple_seq
2851 gimple_eh_filter_failure (gimple gs)
2853 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2854 return gs->gimple_eh_filter.failure;
2858 /* Set TYPES to be the set of types handled by GIMPLE_EH_FILTER GS. */
2861 gimple_eh_filter_set_types (gimple gs, tree types)
2863 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2864 gs->gimple_eh_filter.types = types;
2868 /* Set FAILURE to be the sequence of statements to execute on failure
2869 for GIMPLE_EH_FILTER GS. */
2872 gimple_eh_filter_set_failure (gimple gs, gimple_seq failure)
2874 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2875 gs->gimple_eh_filter.failure = failure;
2878 /* Get the function decl to be called by the MUST_NOT_THROW region. */
2881 gimple_eh_must_not_throw_fndecl (gimple gs)
2883 GIMPLE_CHECK (gs, GIMPLE_EH_MUST_NOT_THROW);
2884 return gs->gimple_eh_mnt.fndecl;
2887 /* GIMPLE_TRY accessors. */
2889 /* Return the kind of try block represented by GIMPLE_TRY GS. This is
2890 either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY. */
2892 static inline enum gimple_try_flags
2893 gimple_try_kind (const_gimple gs)
2895 GIMPLE_CHECK (gs, GIMPLE_TRY);
2896 return (enum gimple_try_flags) (gs->gsbase.subcode & GIMPLE_TRY_KIND);
2900 /* Set the kind of try block represented by GIMPLE_TRY GS. */
2903 gimple_try_set_kind (gimple gs, enum gimple_try_flags kind)
2905 GIMPLE_CHECK (gs, GIMPLE_TRY);
2906 gcc_assert (kind == GIMPLE_TRY_CATCH || kind == GIMPLE_TRY_FINALLY);
2907 if (gimple_try_kind (gs) != kind)
2908 gs->gsbase.subcode = (unsigned int) kind;
2912 /* Return the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2915 gimple_try_catch_is_cleanup (const_gimple gs)
2917 gcc_assert (gimple_try_kind (gs) == GIMPLE_TRY_CATCH);
2918 return (gs->gsbase.subcode & GIMPLE_TRY_CATCH_IS_CLEANUP) != 0;
2922 /* Return the sequence of statements used as the body for GIMPLE_TRY GS. */
2924 static inline gimple_seq
2925 gimple_try_eval (gimple gs)
2927 GIMPLE_CHECK (gs, GIMPLE_TRY);
2928 return gs->gimple_try.eval;
2932 /* Return the sequence of statements used as the cleanup body for
2935 static inline gimple_seq
2936 gimple_try_cleanup (gimple gs)
2938 GIMPLE_CHECK (gs, GIMPLE_TRY);
2939 return gs->gimple_try.cleanup;
2943 /* Set the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2946 gimple_try_set_catch_is_cleanup (gimple g, bool catch_is_cleanup)
2948 gcc_assert (gimple_try_kind (g) == GIMPLE_TRY_CATCH);
2949 if (catch_is_cleanup)
2950 g->gsbase.subcode |= GIMPLE_TRY_CATCH_IS_CLEANUP;
2952 g->gsbase.subcode &= ~GIMPLE_TRY_CATCH_IS_CLEANUP;
2956 /* Set EVAL to be the sequence of statements to use as the body for
2960 gimple_try_set_eval (gimple gs, gimple_seq eval)
2962 GIMPLE_CHECK (gs, GIMPLE_TRY);
2963 gs->gimple_try.eval = eval;
2967 /* Set CLEANUP to be the sequence of statements to use as the cleanup
2968 body for GIMPLE_TRY GS. */
2971 gimple_try_set_cleanup (gimple gs, gimple_seq cleanup)
2973 GIMPLE_CHECK (gs, GIMPLE_TRY);
2974 gs->gimple_try.cleanup = cleanup;
2978 /* Return the cleanup sequence for cleanup statement GS. */
2980 static inline gimple_seq
2981 gimple_wce_cleanup (gimple gs)
2983 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
2984 return gs->gimple_wce.cleanup;
2988 /* Set CLEANUP to be the cleanup sequence for GS. */
2991 gimple_wce_set_cleanup (gimple gs, gimple_seq cleanup)
2993 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
2994 gs->gimple_wce.cleanup = cleanup;
2998 /* Return the CLEANUP_EH_ONLY flag for a WCE tuple. */
3001 gimple_wce_cleanup_eh_only (const_gimple gs)
3003 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3004 return gs->gsbase.subcode != 0;
3008 /* Set the CLEANUP_EH_ONLY flag for a WCE tuple. */
3011 gimple_wce_set_cleanup_eh_only (gimple gs, bool eh_only_p)
3013 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3014 gs->gsbase.subcode = (unsigned int) eh_only_p;
3018 /* Return the maximum number of arguments supported by GIMPLE_PHI GS. */
3020 static inline unsigned
3021 gimple_phi_capacity (const_gimple gs)
3023 GIMPLE_CHECK (gs, GIMPLE_PHI);
3024 return gs->gimple_phi.capacity;
3028 /* Return the number of arguments in GIMPLE_PHI GS. This must always
3029 be exactly the number of incoming edges for the basic block holding
3032 static inline unsigned
3033 gimple_phi_num_args (const_gimple gs)
3035 GIMPLE_CHECK (gs, GIMPLE_PHI);
3036 return gs->gimple_phi.nargs;
3040 /* Return the SSA name created by GIMPLE_PHI GS. */
3043 gimple_phi_result (const_gimple gs)
3045 GIMPLE_CHECK (gs, GIMPLE_PHI);
3046 return gs->gimple_phi.result;
3049 /* Return a pointer to the SSA name created by GIMPLE_PHI GS. */
3051 static inline tree *
3052 gimple_phi_result_ptr (gimple gs)
3054 GIMPLE_CHECK (gs, GIMPLE_PHI);
3055 return &gs->gimple_phi.result;
3058 /* Set RESULT to be the SSA name created by GIMPLE_PHI GS. */
3061 gimple_phi_set_result (gimple gs, tree result)
3063 GIMPLE_CHECK (gs, GIMPLE_PHI);
3064 gs->gimple_phi.result = result;
3068 /* Return the PHI argument corresponding to incoming edge INDEX for
3071 static inline struct phi_arg_d *
3072 gimple_phi_arg (gimple gs, unsigned index)
3074 GIMPLE_CHECK (gs, GIMPLE_PHI);
3075 gcc_assert (index <= gs->gimple_phi.capacity);
3076 return &(gs->gimple_phi.args[index]);
3079 /* Set PHIARG to be the argument corresponding to incoming edge INDEX
3080 for GIMPLE_PHI GS. */
3083 gimple_phi_set_arg (gimple gs, unsigned index, struct phi_arg_d * phiarg)
3085 GIMPLE_CHECK (gs, GIMPLE_PHI);
3086 gcc_assert (index <= gs->gimple_phi.nargs);
3087 memcpy (gs->gimple_phi.args + index, phiarg, sizeof (struct phi_arg_d));
3090 /* Return the region number for GIMPLE_RESX GS. */
3093 gimple_resx_region (const_gimple gs)
3095 GIMPLE_CHECK (gs, GIMPLE_RESX);
3096 return gs->gimple_eh_ctrl.region;
3099 /* Set REGION to be the region number for GIMPLE_RESX GS. */
3102 gimple_resx_set_region (gimple gs, int region)
3104 GIMPLE_CHECK (gs, GIMPLE_RESX);
3105 gs->gimple_eh_ctrl.region = region;
3108 /* Return the region number for GIMPLE_EH_DISPATCH GS. */
3111 gimple_eh_dispatch_region (const_gimple gs)
3113 GIMPLE_CHECK (gs, GIMPLE_EH_DISPATCH);
3114 return gs->gimple_eh_ctrl.region;
3117 /* Set REGION to be the region number for GIMPLE_EH_DISPATCH GS. */
3120 gimple_eh_dispatch_set_region (gimple gs, int region)
3122 GIMPLE_CHECK (gs, GIMPLE_EH_DISPATCH);
3123 gs->gimple_eh_ctrl.region = region;
3126 /* Return the number of labels associated with the switch statement GS. */
3128 static inline unsigned
3129 gimple_switch_num_labels (const_gimple gs)
3132 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3133 num_ops = gimple_num_ops (gs);
3134 gcc_assert (num_ops > 1);
3139 /* Set NLABELS to be the number of labels for the switch statement GS. */
3142 gimple_switch_set_num_labels (gimple g, unsigned nlabels)
3144 GIMPLE_CHECK (g, GIMPLE_SWITCH);
3145 gimple_set_num_ops (g, nlabels + 1);
3149 /* Return the index variable used by the switch statement GS. */
3152 gimple_switch_index (const_gimple gs)
3154 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3155 return gimple_op (gs, 0);
3159 /* Return a pointer to the index variable for the switch statement GS. */
3161 static inline tree *
3162 gimple_switch_index_ptr (const_gimple gs)
3164 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3165 return gimple_op_ptr (gs, 0);
3169 /* Set INDEX to be the index variable for switch statement GS. */
3172 gimple_switch_set_index (gimple gs, tree index)
3174 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3175 gcc_assert (SSA_VAR_P (index) || CONSTANT_CLASS_P (index));
3176 gimple_set_op (gs, 0, index);
3180 /* Return the label numbered INDEX. The default label is 0, followed by any
3181 labels in a switch statement. */
3184 gimple_switch_label (const_gimple gs, unsigned index)
3186 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3187 gcc_assert (gimple_num_ops (gs) > index + 1);
3188 return gimple_op (gs, index + 1);
3191 /* Set the label number INDEX to LABEL. 0 is always the default label. */
3194 gimple_switch_set_label (gimple gs, unsigned index, tree label)
3196 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3197 gcc_assert (gimple_num_ops (gs) > index + 1);
3198 gcc_assert (label == NULL_TREE || TREE_CODE (label) == CASE_LABEL_EXPR);
3199 gimple_set_op (gs, index + 1, label);
3202 /* Return the default label for a switch statement. */
3205 gimple_switch_default_label (const_gimple gs)
3207 return gimple_switch_label (gs, 0);
3210 /* Set the default label for a switch statement. */
3213 gimple_switch_set_default_label (gimple gs, tree label)
3215 gimple_switch_set_label (gs, 0, label);
3218 /* Return true if GS is a GIMPLE_DEBUG statement. */
3221 is_gimple_debug (const_gimple gs)
3223 return gimple_code (gs) == GIMPLE_DEBUG;
3226 /* Return true if S is a GIMPLE_DEBUG BIND statement. */
3229 gimple_debug_bind_p (const_gimple s)
3231 if (is_gimple_debug (s))
3232 return s->gsbase.subcode == GIMPLE_DEBUG_BIND;
3237 /* Return the variable bound in a GIMPLE_DEBUG bind statement. */
3240 gimple_debug_bind_get_var (gimple dbg)
3242 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3243 gcc_assert (gimple_debug_bind_p (dbg));
3244 return gimple_op (dbg, 0);
3247 /* Return the value bound to the variable in a GIMPLE_DEBUG bind
3251 gimple_debug_bind_get_value (gimple dbg)
3253 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3254 gcc_assert (gimple_debug_bind_p (dbg));
3255 return gimple_op (dbg, 1);
3258 /* Return a pointer to the value bound to the variable in a
3259 GIMPLE_DEBUG bind statement. */
3261 static inline tree *
3262 gimple_debug_bind_get_value_ptr (gimple dbg)
3264 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3265 gcc_assert (gimple_debug_bind_p (dbg));
3266 return gimple_op_ptr (dbg, 1);
3269 /* Set the variable bound in a GIMPLE_DEBUG bind statement. */
3272 gimple_debug_bind_set_var (gimple dbg, tree var)
3274 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3275 gcc_assert (gimple_debug_bind_p (dbg));
3276 gimple_set_op (dbg, 0, var);
3279 /* Set the value bound to the variable in a GIMPLE_DEBUG bind
3283 gimple_debug_bind_set_value (gimple dbg, tree value)
3285 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3286 gcc_assert (gimple_debug_bind_p (dbg));
3287 gimple_set_op (dbg, 1, value);
3290 /* The second operand of a GIMPLE_DEBUG_BIND, when the value was
3292 #define GIMPLE_DEBUG_BIND_NOVALUE NULL_TREE /* error_mark_node */
3294 /* Remove the value bound to the variable in a GIMPLE_DEBUG bind
3298 gimple_debug_bind_reset_value (gimple dbg)
3300 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3301 gcc_assert (gimple_debug_bind_p (dbg));
3302 gimple_set_op (dbg, 1, GIMPLE_DEBUG_BIND_NOVALUE);
3305 /* Return true if the GIMPLE_DEBUG bind statement is bound to a
3309 gimple_debug_bind_has_value_p (gimple dbg)
3311 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3312 gcc_assert (gimple_debug_bind_p (dbg));
3313 return gimple_op (dbg, 1) != GIMPLE_DEBUG_BIND_NOVALUE;
3316 #undef GIMPLE_DEBUG_BIND_NOVALUE
3318 /* Return the body for the OMP statement GS. */
3320 static inline gimple_seq
3321 gimple_omp_body (gimple gs)
3323 return gs->omp.body;
3326 /* Set BODY to be the body for the OMP statement GS. */
3329 gimple_omp_set_body (gimple gs, gimple_seq body)
3331 gs->omp.body = body;
3335 /* Return the name associated with OMP_CRITICAL statement GS. */
3338 gimple_omp_critical_name (const_gimple gs)
3340 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3341 return gs->gimple_omp_critical.name;
3345 /* Return a pointer to the name associated with OMP critical statement GS. */
3347 static inline tree *
3348 gimple_omp_critical_name_ptr (gimple gs)
3350 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3351 return &gs->gimple_omp_critical.name;
3355 /* Set NAME to be the name associated with OMP critical statement GS. */
3358 gimple_omp_critical_set_name (gimple gs, tree name)
3360 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3361 gs->gimple_omp_critical.name = name;
3365 /* Return the clauses associated with OMP_FOR GS. */
3368 gimple_omp_for_clauses (const_gimple gs)
3370 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3371 return gs->gimple_omp_for.clauses;
3375 /* Return a pointer to the OMP_FOR GS. */
3377 static inline tree *
3378 gimple_omp_for_clauses_ptr (gimple gs)
3380 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3381 return &gs->gimple_omp_for.clauses;
3385 /* Set CLAUSES to be the list of clauses associated with OMP_FOR GS. */
3388 gimple_omp_for_set_clauses (gimple gs, tree clauses)
3390 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3391 gs->gimple_omp_for.clauses = clauses;
3395 /* Get the collapse count of OMP_FOR GS. */
3397 static inline size_t
3398 gimple_omp_for_collapse (gimple gs)
3400 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3401 return gs->gimple_omp_for.collapse;
3405 /* Return the index variable for OMP_FOR GS. */
3408 gimple_omp_for_index (const_gimple gs, size_t i)
3410 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3411 gcc_assert (i < gs->gimple_omp_for.collapse);
3412 return gs->gimple_omp_for.iter[i].index;
3416 /* Return a pointer to the index variable for OMP_FOR GS. */
3418 static inline tree *
3419 gimple_omp_for_index_ptr (gimple gs, size_t i)
3421 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3422 gcc_assert (i < gs->gimple_omp_for.collapse);
3423 return &gs->gimple_omp_for.iter[i].index;
3427 /* Set INDEX to be the index variable for OMP_FOR GS. */
3430 gimple_omp_for_set_index (gimple gs, size_t i, tree index)
3432 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3433 gcc_assert (i < gs->gimple_omp_for.collapse);
3434 gs->gimple_omp_for.iter[i].index = index;
3438 /* Return the initial value for OMP_FOR GS. */
3441 gimple_omp_for_initial (const_gimple gs, size_t i)
3443 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3444 gcc_assert (i < gs->gimple_omp_for.collapse);
3445 return gs->gimple_omp_for.iter[i].initial;
3449 /* Return a pointer to the initial value for OMP_FOR GS. */
3451 static inline tree *
3452 gimple_omp_for_initial_ptr (gimple gs, size_t i)
3454 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3455 gcc_assert (i < gs->gimple_omp_for.collapse);
3456 return &gs->gimple_omp_for.iter[i].initial;
3460 /* Set INITIAL to be the initial value for OMP_FOR GS. */
3463 gimple_omp_for_set_initial (gimple gs, size_t i, tree initial)
3465 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3466 gcc_assert (i < gs->gimple_omp_for.collapse);
3467 gs->gimple_omp_for.iter[i].initial = initial;
3471 /* Return the final value for OMP_FOR GS. */
3474 gimple_omp_for_final (const_gimple gs, size_t i)
3476 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3477 gcc_assert (i < gs->gimple_omp_for.collapse);
3478 return gs->gimple_omp_for.iter[i].final;
3482 /* Return a pointer to the final value for OMP_FOR GS. */
3484 static inline tree *
3485 gimple_omp_for_final_ptr (gimple gs, size_t i)
3487 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3488 gcc_assert (i < gs->gimple_omp_for.collapse);
3489 return &gs->gimple_omp_for.iter[i].final;
3493 /* Set FINAL to be the final value for OMP_FOR GS. */
3496 gimple_omp_for_set_final (gimple gs, size_t i, tree final)
3498 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3499 gcc_assert (i < gs->gimple_omp_for.collapse);
3500 gs->gimple_omp_for.iter[i].final = final;
3504 /* Return the increment value for OMP_FOR GS. */
3507 gimple_omp_for_incr (const_gimple gs, size_t i)
3509 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3510 gcc_assert (i < gs->gimple_omp_for.collapse);
3511 return gs->gimple_omp_for.iter[i].incr;
3515 /* Return a pointer to the increment value for OMP_FOR GS. */
3517 static inline tree *
3518 gimple_omp_for_incr_ptr (gimple gs, size_t i)
3520 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3521 gcc_assert (i < gs->gimple_omp_for.collapse);
3522 return &gs->gimple_omp_for.iter[i].incr;
3526 /* Set INCR to be the increment value for OMP_FOR GS. */
3529 gimple_omp_for_set_incr (gimple gs, size_t i, tree incr)
3531 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3532 gcc_assert (i < gs->gimple_omp_for.collapse);
3533 gs->gimple_omp_for.iter[i].incr = incr;
3537 /* Return the sequence of statements to execute before the OMP_FOR
3538 statement GS starts. */
3540 static inline gimple_seq
3541 gimple_omp_for_pre_body (gimple gs)
3543 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3544 return gs->gimple_omp_for.pre_body;
3548 /* Set PRE_BODY to be the sequence of statements to execute before the
3549 OMP_FOR statement GS starts. */
3552 gimple_omp_for_set_pre_body (gimple gs, gimple_seq pre_body)
3554 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3555 gs->gimple_omp_for.pre_body = pre_body;
3559 /* Return the clauses associated with OMP_PARALLEL GS. */
3562 gimple_omp_parallel_clauses (const_gimple gs)
3564 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3565 return gs->gimple_omp_parallel.clauses;
3569 /* Return a pointer to the clauses associated with OMP_PARALLEL GS. */
3571 static inline tree *
3572 gimple_omp_parallel_clauses_ptr (gimple gs)
3574 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3575 return &gs->gimple_omp_parallel.clauses;
3579 /* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL
3583 gimple_omp_parallel_set_clauses (gimple gs, tree clauses)
3585 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3586 gs->gimple_omp_parallel.clauses = clauses;
3590 /* Return the child function used to hold the body of OMP_PARALLEL GS. */
3593 gimple_omp_parallel_child_fn (const_gimple gs)
3595 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3596 return gs->gimple_omp_parallel.child_fn;
3599 /* Return a pointer to the child function used to hold the body of
3602 static inline tree *
3603 gimple_omp_parallel_child_fn_ptr (gimple gs)
3605 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3606 return &gs->gimple_omp_parallel.child_fn;
3610 /* Set CHILD_FN to be the child function for OMP_PARALLEL GS. */
3613 gimple_omp_parallel_set_child_fn (gimple gs, tree child_fn)
3615 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3616 gs->gimple_omp_parallel.child_fn = child_fn;
3620 /* Return the artificial argument used to send variables and values
3621 from the parent to the children threads in OMP_PARALLEL GS. */
3624 gimple_omp_parallel_data_arg (const_gimple gs)
3626 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3627 return gs->gimple_omp_parallel.data_arg;
3631 /* Return a pointer to the data argument for OMP_PARALLEL GS. */
3633 static inline tree *
3634 gimple_omp_parallel_data_arg_ptr (gimple gs)
3636 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3637 return &gs->gimple_omp_parallel.data_arg;
3641 /* Set DATA_ARG to be the data argument for OMP_PARALLEL GS. */
3644 gimple_omp_parallel_set_data_arg (gimple gs, tree data_arg)
3646 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3647 gs->gimple_omp_parallel.data_arg = data_arg;
3651 /* Return the clauses associated with OMP_TASK GS. */
3654 gimple_omp_task_clauses (const_gimple gs)
3656 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3657 return gs->gimple_omp_parallel.clauses;
3661 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3663 static inline tree *
3664 gimple_omp_task_clauses_ptr (gimple gs)
3666 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3667 return &gs->gimple_omp_parallel.clauses;
3671 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3675 gimple_omp_task_set_clauses (gimple gs, tree clauses)
3677 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3678 gs->gimple_omp_parallel.clauses = clauses;
3682 /* Return the child function used to hold the body of OMP_TASK GS. */
3685 gimple_omp_task_child_fn (const_gimple gs)
3687 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3688 return gs->gimple_omp_parallel.child_fn;
3691 /* Return a pointer to the child function used to hold the body of
3694 static inline tree *
3695 gimple_omp_task_child_fn_ptr (gimple gs)
3697 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3698 return &gs->gimple_omp_parallel.child_fn;
3702 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3705 gimple_omp_task_set_child_fn (gimple gs, tree child_fn)
3707 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3708 gs->gimple_omp_parallel.child_fn = child_fn;
3712 /* Return the artificial argument used to send variables and values
3713 from the parent to the children threads in OMP_TASK GS. */
3716 gimple_omp_task_data_arg (const_gimple gs)
3718 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3719 return gs->gimple_omp_parallel.data_arg;
3723 /* Return a pointer to the data argument for OMP_TASK GS. */
3725 static inline tree *
3726 gimple_omp_task_data_arg_ptr (gimple gs)
3728 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3729 return &gs->gimple_omp_parallel.data_arg;
3733 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3736 gimple_omp_task_set_data_arg (gimple gs, tree data_arg)
3738 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3739 gs->gimple_omp_parallel.data_arg = data_arg;
3743 /* Return the clauses associated with OMP_TASK GS. */
3746 gimple_omp_taskreg_clauses (const_gimple gs)
3748 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3749 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3750 return gs->gimple_omp_parallel.clauses;
3754 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3756 static inline tree *
3757 gimple_omp_taskreg_clauses_ptr (gimple gs)
3759 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3760 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3761 return &gs->gimple_omp_parallel.clauses;
3765 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3769 gimple_omp_taskreg_set_clauses (gimple gs, tree clauses)
3771 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3772 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3773 gs->gimple_omp_parallel.clauses = clauses;
3777 /* Return the child function used to hold the body of OMP_TASK GS. */
3780 gimple_omp_taskreg_child_fn (const_gimple gs)
3782 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3783 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3784 return gs->gimple_omp_parallel.child_fn;
3787 /* Return a pointer to the child function used to hold the body of
3790 static inline tree *
3791 gimple_omp_taskreg_child_fn_ptr (gimple gs)
3793 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3794 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3795 return &gs->gimple_omp_parallel.child_fn;
3799 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3802 gimple_omp_taskreg_set_child_fn (gimple gs, tree child_fn)
3804 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3805 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3806 gs->gimple_omp_parallel.child_fn = child_fn;
3810 /* Return the artificial argument used to send variables and values
3811 from the parent to the children threads in OMP_TASK GS. */
3814 gimple_omp_taskreg_data_arg (const_gimple gs)
3816 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3817 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3818 return gs->gimple_omp_parallel.data_arg;
3822 /* Return a pointer to the data argument for OMP_TASK GS. */
3824 static inline tree *
3825 gimple_omp_taskreg_data_arg_ptr (gimple gs)
3827 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3828 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3829 return &gs->gimple_omp_parallel.data_arg;
3833 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3836 gimple_omp_taskreg_set_data_arg (gimple gs, tree data_arg)
3838 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3839 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3840 gs->gimple_omp_parallel.data_arg = data_arg;
3844 /* Return the copy function used to hold the body of OMP_TASK GS. */
3847 gimple_omp_task_copy_fn (const_gimple gs)
3849 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3850 return gs->gimple_omp_task.copy_fn;
3853 /* Return a pointer to the copy function used to hold the body of
3856 static inline tree *
3857 gimple_omp_task_copy_fn_ptr (gimple gs)
3859 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3860 return &gs->gimple_omp_task.copy_fn;
3864 /* Set CHILD_FN to be the copy function for OMP_TASK GS. */
3867 gimple_omp_task_set_copy_fn (gimple gs, tree copy_fn)
3869 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3870 gs->gimple_omp_task.copy_fn = copy_fn;
3874 /* Return size of the data block in bytes in OMP_TASK GS. */
3877 gimple_omp_task_arg_size (const_gimple gs)
3879 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3880 return gs->gimple_omp_task.arg_size;
3884 /* Return a pointer to the data block size for OMP_TASK GS. */
3886 static inline tree *
3887 gimple_omp_task_arg_size_ptr (gimple gs)
3889 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3890 return &gs->gimple_omp_task.arg_size;
3894 /* Set ARG_SIZE to be the data block size for OMP_TASK GS. */
3897 gimple_omp_task_set_arg_size (gimple gs, tree arg_size)
3899 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3900 gs->gimple_omp_task.arg_size = arg_size;
3904 /* Return align of the data block in bytes in OMP_TASK GS. */
3907 gimple_omp_task_arg_align (const_gimple gs)
3909 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3910 return gs->gimple_omp_task.arg_align;
3914 /* Return a pointer to the data block align for OMP_TASK GS. */
3916 static inline tree *
3917 gimple_omp_task_arg_align_ptr (gimple gs)
3919 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3920 return &gs->gimple_omp_task.arg_align;
3924 /* Set ARG_SIZE to be the data block align for OMP_TASK GS. */
3927 gimple_omp_task_set_arg_align (gimple gs, tree arg_align)
3929 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3930 gs->gimple_omp_task.arg_align = arg_align;
3934 /* Return the clauses associated with OMP_SINGLE GS. */
3937 gimple_omp_single_clauses (const_gimple gs)
3939 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3940 return gs->gimple_omp_single.clauses;
3944 /* Return a pointer to the clauses associated with OMP_SINGLE GS. */
3946 static inline tree *
3947 gimple_omp_single_clauses_ptr (gimple gs)
3949 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3950 return &gs->gimple_omp_single.clauses;
3954 /* Set CLAUSES to be the clauses associated with OMP_SINGLE GS. */
3957 gimple_omp_single_set_clauses (gimple gs, tree clauses)
3959 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3960 gs->gimple_omp_single.clauses = clauses;
3964 /* Return the clauses associated with OMP_SECTIONS GS. */
3967 gimple_omp_sections_clauses (const_gimple gs)
3969 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3970 return gs->gimple_omp_sections.clauses;
3974 /* Return a pointer to the clauses associated with OMP_SECTIONS GS. */
3976 static inline tree *
3977 gimple_omp_sections_clauses_ptr (gimple gs)
3979 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3980 return &gs->gimple_omp_sections.clauses;
3984 /* Set CLAUSES to be the set of clauses associated with OMP_SECTIONS
3988 gimple_omp_sections_set_clauses (gimple gs, tree clauses)
3990 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3991 gs->gimple_omp_sections.clauses = clauses;
3995 /* Return the control variable associated with the GIMPLE_OMP_SECTIONS
3999 gimple_omp_sections_control (const_gimple gs)
4001 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4002 return gs->gimple_omp_sections.control;
4006 /* Return a pointer to the clauses associated with the GIMPLE_OMP_SECTIONS
4009 static inline tree *
4010 gimple_omp_sections_control_ptr (gimple gs)
4012 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4013 return &gs->gimple_omp_sections.control;
4017 /* Set CONTROL to be the set of clauses associated with the
4018 GIMPLE_OMP_SECTIONS in GS. */
4021 gimple_omp_sections_set_control (gimple gs, tree control)
4023 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4024 gs->gimple_omp_sections.control = control;
4028 /* Set COND to be the condition code for OMP_FOR GS. */
4031 gimple_omp_for_set_cond (gimple gs, size_t i, enum tree_code cond)
4033 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4034 gcc_assert (TREE_CODE_CLASS (cond) == tcc_comparison);
4035 gcc_assert (i < gs->gimple_omp_for.collapse);
4036 gs->gimple_omp_for.iter[i].cond = cond;
4040 /* Return the condition code associated with OMP_FOR GS. */
4042 static inline enum tree_code
4043 gimple_omp_for_cond (const_gimple gs, size_t i)
4045 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4046 gcc_assert (i < gs->gimple_omp_for.collapse);
4047 return gs->gimple_omp_for.iter[i].cond;
4051 /* Set the value being stored in an atomic store. */
4054 gimple_omp_atomic_store_set_val (gimple g, tree val)
4056 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4057 g->gimple_omp_atomic_store.val = val;
4061 /* Return the value being stored in an atomic store. */
4064 gimple_omp_atomic_store_val (const_gimple g)
4066 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4067 return g->gimple_omp_atomic_store.val;
4071 /* Return a pointer to the value being stored in an atomic store. */
4073 static inline tree *
4074 gimple_omp_atomic_store_val_ptr (gimple g)
4076 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4077 return &g->gimple_omp_atomic_store.val;
4081 /* Set the LHS of an atomic load. */
4084 gimple_omp_atomic_load_set_lhs (gimple g, tree lhs)
4086 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4087 g->gimple_omp_atomic_load.lhs = lhs;
4091 /* Get the LHS of an atomic load. */
4094 gimple_omp_atomic_load_lhs (const_gimple g)
4096 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4097 return g->gimple_omp_atomic_load.lhs;
4101 /* Return a pointer to the LHS of an atomic load. */
4103 static inline tree *
4104 gimple_omp_atomic_load_lhs_ptr (gimple g)
4106 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4107 return &g->gimple_omp_atomic_load.lhs;
4111 /* Set the RHS of an atomic load. */
4114 gimple_omp_atomic_load_set_rhs (gimple g, tree rhs)
4116 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4117 g->gimple_omp_atomic_load.rhs = rhs;
4121 /* Get the RHS of an atomic load. */
4124 gimple_omp_atomic_load_rhs (const_gimple g)
4126 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4127 return g->gimple_omp_atomic_load.rhs;
4131 /* Return a pointer to the RHS of an atomic load. */
4133 static inline tree *
4134 gimple_omp_atomic_load_rhs_ptr (gimple g)
4136 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4137 return &g->gimple_omp_atomic_load.rhs;
4141 /* Get the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4144 gimple_omp_continue_control_def (const_gimple g)
4146 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4147 return g->gimple_omp_continue.control_def;
4150 /* The same as above, but return the address. */
4152 static inline tree *
4153 gimple_omp_continue_control_def_ptr (gimple g)
4155 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4156 return &g->gimple_omp_continue.control_def;
4159 /* Set the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4162 gimple_omp_continue_set_control_def (gimple g, tree def)
4164 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4165 g->gimple_omp_continue.control_def = def;
4169 /* Get the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4172 gimple_omp_continue_control_use (const_gimple g)
4174 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4175 return g->gimple_omp_continue.control_use;
4179 /* The same as above, but return the address. */
4181 static inline tree *
4182 gimple_omp_continue_control_use_ptr (gimple g)
4184 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4185 return &g->gimple_omp_continue.control_use;
4189 /* Set the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4192 gimple_omp_continue_set_control_use (gimple g, tree use)
4194 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4195 g->gimple_omp_continue.control_use = use;
4199 /* Return a pointer to the return value for GIMPLE_RETURN GS. */
4201 static inline tree *
4202 gimple_return_retval_ptr (const_gimple gs)
4204 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4205 gcc_assert (gimple_num_ops (gs) == 1);
4206 return gimple_op_ptr (gs, 0);
4209 /* Return the return value for GIMPLE_RETURN GS. */
4212 gimple_return_retval (const_gimple gs)
4214 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4215 gcc_assert (gimple_num_ops (gs) == 1);
4216 return gimple_op (gs, 0);
4220 /* Set RETVAL to be the return value for GIMPLE_RETURN GS. */
4223 gimple_return_set_retval (gimple gs, tree retval)
4225 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4226 gcc_assert (gimple_num_ops (gs) == 1);
4227 gcc_assert (retval == NULL_TREE
4228 || TREE_CODE (retval) == RESULT_DECL
4229 || is_gimple_val (retval));
4230 gimple_set_op (gs, 0, retval);
4234 /* Returns true when the gimple statment STMT is any of the OpenMP types. */
4236 #define CASE_GIMPLE_OMP \
4237 case GIMPLE_OMP_PARALLEL: \
4238 case GIMPLE_OMP_TASK: \
4239 case GIMPLE_OMP_FOR: \
4240 case GIMPLE_OMP_SECTIONS: \
4241 case GIMPLE_OMP_SECTIONS_SWITCH: \
4242 case GIMPLE_OMP_SINGLE: \
4243 case GIMPLE_OMP_SECTION: \
4244 case GIMPLE_OMP_MASTER: \
4245 case GIMPLE_OMP_ORDERED: \
4246 case GIMPLE_OMP_CRITICAL: \
4247 case GIMPLE_OMP_RETURN: \
4248 case GIMPLE_OMP_ATOMIC_LOAD: \
4249 case GIMPLE_OMP_ATOMIC_STORE: \
4250 case GIMPLE_OMP_CONTINUE
4253 is_gimple_omp (const_gimple stmt)
4255 switch (gimple_code (stmt))
4265 /* Returns TRUE if statement G is a GIMPLE_NOP. */
4268 gimple_nop_p (const_gimple g)
4270 return gimple_code (g) == GIMPLE_NOP;
4274 /* Return true if GS is a GIMPLE_RESX. */
4277 is_gimple_resx (const_gimple gs)
4279 return gimple_code (gs) == GIMPLE_RESX;
4282 /* Return the predictor of GIMPLE_PREDICT statement GS. */
4284 static inline enum br_predictor
4285 gimple_predict_predictor (gimple gs)
4287 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4288 return (enum br_predictor) (gs->gsbase.subcode & ~GF_PREDICT_TAKEN);
4292 /* Set the predictor of GIMPLE_PREDICT statement GS to PREDICT. */
4295 gimple_predict_set_predictor (gimple gs, enum br_predictor predictor)
4297 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4298 gs->gsbase.subcode = (gs->gsbase.subcode & GF_PREDICT_TAKEN)
4299 | (unsigned) predictor;
4303 /* Return the outcome of GIMPLE_PREDICT statement GS. */
4305 static inline enum prediction
4306 gimple_predict_outcome (gimple gs)
4308 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4309 return (gs->gsbase.subcode & GF_PREDICT_TAKEN) ? TAKEN : NOT_TAKEN;
4313 /* Set the outcome of GIMPLE_PREDICT statement GS to OUTCOME. */
4316 gimple_predict_set_outcome (gimple gs, enum prediction outcome)
4318 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4319 if (outcome == TAKEN)
4320 gs->gsbase.subcode |= GF_PREDICT_TAKEN;
4322 gs->gsbase.subcode &= ~GF_PREDICT_TAKEN;
4326 /* Return the type of the main expression computed by STMT. Return
4327 void_type_node if the statement computes nothing. */
4330 gimple_expr_type (const_gimple stmt)
4332 enum gimple_code code = gimple_code (stmt);
4334 if (code == GIMPLE_ASSIGN || code == GIMPLE_CALL)
4337 /* In general we want to pass out a type that can be substituted
4338 for both the RHS and the LHS types if there is a possibly
4339 useless conversion involved. That means returning the
4340 original RHS type as far as we can reconstruct it. */
4341 if (code == GIMPLE_CALL)
4342 type = gimple_call_return_type (stmt);
4344 switch (gimple_assign_rhs_code (stmt))
4346 case POINTER_PLUS_EXPR:
4347 type = TREE_TYPE (gimple_assign_rhs1 (stmt));
4351 /* As fallback use the type of the LHS. */
4352 type = TREE_TYPE (gimple_get_lhs (stmt));
4357 else if (code == GIMPLE_COND)
4358 return boolean_type_node;
4360 return void_type_node;
4364 /* Return a new iterator pointing to GIMPLE_SEQ's first statement. */
4366 static inline gimple_stmt_iterator
4367 gsi_start (gimple_seq seq)
4369 gimple_stmt_iterator i;
4371 i.ptr = gimple_seq_first (seq);
4373 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4379 /* Return a new iterator pointing to the first statement in basic block BB. */
4381 static inline gimple_stmt_iterator
4382 gsi_start_bb (basic_block bb)
4384 gimple_stmt_iterator i;
4388 i.ptr = gimple_seq_first (seq);
4396 /* Return a new iterator initially pointing to GIMPLE_SEQ's last statement. */
4398 static inline gimple_stmt_iterator
4399 gsi_last (gimple_seq seq)
4401 gimple_stmt_iterator i;
4403 i.ptr = gimple_seq_last (seq);
4405 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4411 /* Return a new iterator pointing to the last statement in basic block BB. */
4413 static inline gimple_stmt_iterator
4414 gsi_last_bb (basic_block bb)
4416 gimple_stmt_iterator i;
4420 i.ptr = gimple_seq_last (seq);
4428 /* Return true if I is at the end of its sequence. */
4431 gsi_end_p (gimple_stmt_iterator i)
4433 return i.ptr == NULL;
4437 /* Return true if I is one statement before the end of its sequence. */
4440 gsi_one_before_end_p (gimple_stmt_iterator i)
4442 return i.ptr != NULL && i.ptr->next == NULL;
4446 /* Advance the iterator to the next gimple statement. */
4449 gsi_next (gimple_stmt_iterator *i)
4451 i->ptr = i->ptr->next;
4454 /* Advance the iterator to the previous gimple statement. */
4457 gsi_prev (gimple_stmt_iterator *i)
4459 i->ptr = i->ptr->prev;
4462 /* Return the current stmt. */
4464 static inline gimple
4465 gsi_stmt (gimple_stmt_iterator i)
4470 /* Return a block statement iterator that points to the first non-label
4471 statement in block BB. */
4473 static inline gimple_stmt_iterator
4474 gsi_after_labels (basic_block bb)
4476 gimple_stmt_iterator gsi = gsi_start_bb (bb);
4478 while (!gsi_end_p (gsi) && gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL)
4484 /* Advance the iterator to the next non-debug gimple statement. */
4487 gsi_next_nondebug (gimple_stmt_iterator *i)
4493 while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
4496 /* Advance the iterator to the next non-debug gimple statement. */
4499 gsi_prev_nondebug (gimple_stmt_iterator *i)
4505 while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
4508 /* Return a new iterator pointing to the first non-debug statement in
4511 static inline gimple_stmt_iterator
4512 gsi_start_nondebug_bb (basic_block bb)
4514 gimple_stmt_iterator i = gsi_start_bb (bb);
4516 if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
4517 gsi_next_nondebug (&i);
4522 /* Return a new iterator pointing to the last non-debug statement in
4525 static inline gimple_stmt_iterator
4526 gsi_last_nondebug_bb (basic_block bb)
4528 gimple_stmt_iterator i = gsi_last_bb (bb);
4530 if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
4531 gsi_prev_nondebug (&i);
4536 /* Return a pointer to the current stmt.
4538 NOTE: You may want to use gsi_replace on the iterator itself,
4539 as this performs additional bookkeeping that will not be done
4540 if you simply assign through a pointer returned by gsi_stmt_ptr. */
4542 static inline gimple *
4543 gsi_stmt_ptr (gimple_stmt_iterator *i)
4545 return &i->ptr->stmt;
4549 /* Return the basic block associated with this iterator. */
4551 static inline basic_block
4552 gsi_bb (gimple_stmt_iterator i)
4558 /* Return the sequence associated with this iterator. */
4560 static inline gimple_seq
4561 gsi_seq (gimple_stmt_iterator i)
4567 enum gsi_iterator_update
4569 GSI_NEW_STMT, /* Only valid when single statement is added, move
4571 GSI_SAME_STMT, /* Leave the iterator at the same statement. */
4572 GSI_CONTINUE_LINKING /* Move iterator to whatever position is suitable
4573 for linking other statements in the same
4577 /* In gimple-iterator.c */
4578 gimple_stmt_iterator gsi_start_phis (basic_block);
4579 gimple_seq gsi_split_seq_after (gimple_stmt_iterator);
4580 gimple_seq gsi_split_seq_before (gimple_stmt_iterator *);
4581 void gsi_replace (gimple_stmt_iterator *, gimple, bool);
4582 void gsi_insert_before (gimple_stmt_iterator *, gimple,
4583 enum gsi_iterator_update);
4584 void gsi_insert_before_without_update (gimple_stmt_iterator *, gimple,
4585 enum gsi_iterator_update);
4586 void gsi_insert_seq_before (gimple_stmt_iterator *, gimple_seq,
4587 enum gsi_iterator_update);
4588 void gsi_insert_seq_before_without_update (gimple_stmt_iterator *, gimple_seq,
4589 enum gsi_iterator_update);
4590 void gsi_insert_after (gimple_stmt_iterator *, gimple,
4591 enum gsi_iterator_update);
4592 void gsi_insert_after_without_update (gimple_stmt_iterator *, gimple,
4593 enum gsi_iterator_update);
4594 void gsi_insert_seq_after (gimple_stmt_iterator *, gimple_seq,
4595 enum gsi_iterator_update);
4596 void gsi_insert_seq_after_without_update (gimple_stmt_iterator *, gimple_seq,
4597 enum gsi_iterator_update);
4598 void gsi_remove (gimple_stmt_iterator *, bool);
4599 gimple_stmt_iterator gsi_for_stmt (gimple);
4600 void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *);
4601 void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *);
4602 void gsi_move_to_bb_end (gimple_stmt_iterator *, struct basic_block_def *);
4603 void gsi_insert_on_edge (edge, gimple);
4604 void gsi_insert_seq_on_edge (edge, gimple_seq);
4605 basic_block gsi_insert_on_edge_immediate (edge, gimple);
4606 basic_block gsi_insert_seq_on_edge_immediate (edge, gimple_seq);
4607 void gsi_commit_one_edge_insert (edge, basic_block *);
4608 void gsi_commit_edge_inserts (void);
4609 gimple gimple_call_copy_skip_args (gimple, bitmap);
4612 /* Convenience routines to walk all statements of a gimple function.
4613 Note that this is useful exclusively before the code is converted
4614 into SSA form. Once the program is in SSA form, the standard
4615 operand interface should be used to analyze/modify statements. */
4616 struct walk_stmt_info
4618 /* Points to the current statement being walked. */
4619 gimple_stmt_iterator gsi;
4621 /* Additional data that the callback functions may want to carry
4622 through the recursion. */
4625 /* Pointer map used to mark visited tree nodes when calling
4626 walk_tree on each operand. If set to NULL, duplicate tree nodes
4627 will be visited more than once. */
4628 struct pointer_set_t *pset;
4630 /* Indicates whether the operand being examined may be replaced
4631 with something that matches is_gimple_val (if true) or something
4632 slightly more complicated (if false). "Something" technically
4633 means the common subset of is_gimple_lvalue and is_gimple_rhs,
4634 but we never try to form anything more complicated than that, so
4635 we don't bother checking.
4637 Also note that CALLBACK should update this flag while walking the
4638 sub-expressions of a statement. For instance, when walking the
4639 statement 'foo (&var)', the flag VAL_ONLY will initially be set
4640 to true, however, when walking &var, the operand of that
4641 ADDR_EXPR does not need to be a GIMPLE value. */
4644 /* True if we are currently walking the LHS of an assignment. */
4647 /* Optional. Set to true by the callback functions if they made any
4651 /* True if we're interested in location information. */
4652 bool want_locations;
4654 /* Operand returned by the callbacks. This is set when calling
4655 walk_gimple_seq. If the walk_stmt_fn or walk_tree_fn callback
4656 returns non-NULL, this field will contain the tree returned by
4657 the last callback. */
4658 tree callback_result;
4661 /* Callback for walk_gimple_stmt. Called for every statement found
4662 during traversal. The first argument points to the statement to
4663 walk. The second argument is a flag that the callback sets to
4664 'true' if it the callback handled all the operands and
4665 sub-statements of the statement (the default value of this flag is
4666 'false'). The third argument is an anonymous pointer to data
4667 to be used by the callback. */
4668 typedef tree (*walk_stmt_fn) (gimple_stmt_iterator *, bool *,
4669 struct walk_stmt_info *);
4671 gimple walk_gimple_seq (gimple_seq, walk_stmt_fn, walk_tree_fn,
4672 struct walk_stmt_info *);
4673 tree walk_gimple_stmt (gimple_stmt_iterator *, walk_stmt_fn, walk_tree_fn,
4674 struct walk_stmt_info *);
4675 tree walk_gimple_op (gimple, walk_tree_fn, struct walk_stmt_info *);
4677 #ifdef GATHER_STATISTICS
4678 /* Enum and arrays used for allocation stats. Keep in sync with
4679 gimple.c:gimple_alloc_kind_names. */
4680 enum gimple_alloc_kind
4682 gimple_alloc_kind_assign, /* Assignments. */
4683 gimple_alloc_kind_phi, /* PHI nodes. */
4684 gimple_alloc_kind_cond, /* Conditionals. */
4685 gimple_alloc_kind_seq, /* Sequences. */
4686 gimple_alloc_kind_rest, /* Everything else. */
4687 gimple_alloc_kind_all
4690 extern int gimple_alloc_counts[];
4691 extern int gimple_alloc_sizes[];
4693 /* Return the allocation kind for a given stmt CODE. */
4694 static inline enum gimple_alloc_kind
4695 gimple_alloc_kind (enum gimple_code code)
4700 return gimple_alloc_kind_assign;
4702 return gimple_alloc_kind_phi;
4704 return gimple_alloc_kind_cond;
4706 return gimple_alloc_kind_rest;
4709 #endif /* GATHER_STATISTICS */
4711 extern void dump_gimple_statistics (void);
4713 #endif /* GCC_GIMPLE_H */