1 /* Gimple IR definitions.
3 Copyright 2007, 2008, 2009, 2010 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"
30 #include "basic-block.h"
31 #include "tree-ssa-operands.h"
32 #include "tree-ssa-alias.h"
34 struct gimple_seq_node_d;
35 typedef struct gimple_seq_node_d *gimple_seq_node;
36 typedef const struct gimple_seq_node_d *const_gimple_seq_node;
38 /* For each block, the PHI nodes that need to be rewritten are stored into
40 typedef VEC(gimple, heap) *gimple_vec;
41 DEF_VEC_P (gimple_vec);
42 DEF_VEC_ALLOC_P (gimple_vec, heap);
45 #define DEFGSCODE(SYM, STRING, STRUCT) SYM,
48 LAST_AND_UNUSED_GIMPLE_CODE
51 extern const char *const gimple_code_name[];
52 extern const unsigned char gimple_rhs_class_table[];
54 /* Error out if a gimple tuple is addressed incorrectly. */
55 #if defined ENABLE_GIMPLE_CHECKING
56 #define gcc_gimple_checking_assert(EXPR) gcc_assert (EXPR)
57 extern void gimple_check_failed (const_gimple, const char *, int, \
58 const char *, enum gimple_code, \
59 enum tree_code) ATTRIBUTE_NORETURN;
61 #define GIMPLE_CHECK(GS, CODE) \
63 const_gimple __gs = (GS); \
64 if (gimple_code (__gs) != (CODE)) \
65 gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__, \
66 (CODE), ERROR_MARK); \
68 #else /* not ENABLE_GIMPLE_CHECKING */
69 #define gcc_gimple_checking_assert(EXPR) ((void)(0 && (EXPR)))
70 #define GIMPLE_CHECK(GS, CODE) (void)0
73 /* Class of GIMPLE expressions suitable for the RHS of assignments. See
74 get_gimple_rhs_class. */
77 GIMPLE_INVALID_RHS, /* The expression cannot be used on the RHS. */
78 GIMPLE_TERNARY_RHS, /* The expression is a ternary operation. */
79 GIMPLE_BINARY_RHS, /* The expression is a binary operation. */
80 GIMPLE_UNARY_RHS, /* The expression is a unary operation. */
81 GIMPLE_SINGLE_RHS /* The expression is a single object (an SSA
82 name, a _DECL, a _REF, etc. */
85 /* Specific flags for individual GIMPLE statements. These flags are
86 always stored in gimple_statement_base.subcode and they may only be
87 defined for statement codes that do not use sub-codes.
89 Values for the masks can overlap as long as the overlapping values
90 are never used in the same statement class.
92 The maximum mask value that can be defined is 1 << 15 (i.e., each
93 statement code can hold up to 16 bitflags).
95 Keep this list sorted. */
97 GF_ASM_INPUT = 1 << 0,
98 GF_ASM_VOLATILE = 1 << 1,
99 GF_CALL_CANNOT_INLINE = 1 << 0,
100 GF_CALL_FROM_THUNK = 1 << 1,
101 GF_CALL_RETURN_SLOT_OPT = 1 << 2,
102 GF_CALL_TAILCALL = 1 << 3,
103 GF_CALL_VA_ARG_PACK = 1 << 4,
104 GF_CALL_NOTHROW = 1 << 5,
105 GF_CALL_ALLOCA_FOR_VAR = 1 << 6,
106 GF_OMP_PARALLEL_COMBINED = 1 << 0,
108 /* True on an GIMPLE_OMP_RETURN statement if the return does not require
109 a thread synchronization via some sort of barrier. The exact barrier
110 that would otherwise be emitted is dependent on the OMP statement with
111 which this return is associated. */
112 GF_OMP_RETURN_NOWAIT = 1 << 0,
114 GF_OMP_SECTION_LAST = 1 << 0,
115 GF_PREDICT_TAKEN = 1 << 15
118 /* Currently, there's only one type of gimple debug stmt. Others are
119 envisioned, for example, to enable the generation of is_stmt notes
120 in line number information, to mark sequence points, etc. This
121 subcode is to be used to tell them apart. */
122 enum gimple_debug_subcode {
123 GIMPLE_DEBUG_BIND = 0
126 /* Masks for selecting a pass local flag (PLF) to work on. These
127 masks are used by gimple_set_plf and gimple_plf. */
133 /* A node in a gimple_seq_d. */
134 struct GTY((chain_next ("%h.next"), chain_prev ("%h.prev"))) gimple_seq_node_d {
136 struct gimple_seq_node_d *prev;
137 struct gimple_seq_node_d *next;
140 /* A double-linked sequence of gimple statements. */
141 struct GTY ((chain_next ("%h.next_free"))) gimple_seq_d {
142 /* First and last statements in the sequence. */
143 gimple_seq_node first;
144 gimple_seq_node last;
146 /* Sequences are created/destroyed frequently. To minimize
147 allocation activity, deallocated sequences are kept in a pool of
148 available sequences. This is the pointer to the next free
149 sequence in the pool. */
150 gimple_seq next_free;
154 /* Return the first node in GIMPLE sequence S. */
156 static inline gimple_seq_node
157 gimple_seq_first (const_gimple_seq s)
159 return s ? s->first : NULL;
163 /* Return the first statement in GIMPLE sequence S. */
166 gimple_seq_first_stmt (const_gimple_seq s)
168 gimple_seq_node n = gimple_seq_first (s);
169 return (n) ? n->stmt : NULL;
173 /* Return the last node in GIMPLE sequence S. */
175 static inline gimple_seq_node
176 gimple_seq_last (const_gimple_seq s)
178 return s ? s->last : NULL;
182 /* Return the last statement in GIMPLE sequence S. */
185 gimple_seq_last_stmt (const_gimple_seq s)
187 gimple_seq_node n = gimple_seq_last (s);
188 return (n) ? n->stmt : NULL;
192 /* Set the last node in GIMPLE sequence S to LAST. */
195 gimple_seq_set_last (gimple_seq s, gimple_seq_node last)
201 /* Set the first node in GIMPLE sequence S to FIRST. */
204 gimple_seq_set_first (gimple_seq s, gimple_seq_node first)
210 /* Return true if GIMPLE sequence S is empty. */
213 gimple_seq_empty_p (const_gimple_seq s)
215 return s == NULL || s->first == NULL;
219 void gimple_seq_add_stmt (gimple_seq *, gimple);
221 /* Link gimple statement GS to the end of the sequence *SEQ_P. If
222 *SEQ_P is NULL, a new sequence is allocated. This function is
223 similar to gimple_seq_add_stmt, but does not scan the operands.
224 During gimplification, we need to manipulate statement sequences
225 before the def/use vectors have been constructed. */
226 void gimplify_seq_add_stmt (gimple_seq *, gimple);
228 /* Allocate a new sequence and initialize its first element with STMT. */
230 static inline gimple_seq
231 gimple_seq_alloc_with_stmt (gimple stmt)
233 gimple_seq seq = NULL;
234 gimple_seq_add_stmt (&seq, stmt);
239 /* Returns the sequence of statements in BB. */
241 static inline gimple_seq
242 bb_seq (const_basic_block bb)
244 return (!(bb->flags & BB_RTL) && bb->il.gimple) ? bb->il.gimple->seq : NULL;
248 /* Sets the sequence of statements in BB to SEQ. */
251 set_bb_seq (basic_block bb, gimple_seq seq)
253 gcc_checking_assert (!(bb->flags & BB_RTL));
254 bb->il.gimple->seq = seq;
257 /* Iterator object for GIMPLE statement sequences. */
261 /* Sequence node holding the current statement. */
264 /* Sequence and basic block holding the statement. These fields
265 are necessary to handle edge cases such as when statement is
266 added to an empty basic block or when the last statement of a
267 block/sequence is removed. */
270 } gimple_stmt_iterator;
273 /* Data structure definitions for GIMPLE tuples. NOTE: word markers
274 are for 64 bit hosts. */
276 struct GTY(()) gimple_statement_base {
278 Main identifying code for a tuple. */
279 ENUM_BITFIELD(gimple_code) code : 8;
281 /* Nonzero if a warning should not be emitted on this tuple. */
282 unsigned int no_warning : 1;
284 /* Nonzero if this tuple has been visited. Passes are responsible
285 for clearing this bit before using it. */
286 unsigned int visited : 1;
288 /* Nonzero if this tuple represents a non-temporal move. */
289 unsigned int nontemporal_move : 1;
291 /* Pass local flags. These flags are free for any pass to use as
292 they see fit. Passes should not assume that these flags contain
293 any useful value when the pass starts. Any initial state that
294 the pass requires should be set on entry to the pass. See
295 gimple_set_plf and gimple_plf for usage. */
296 unsigned int plf : 2;
298 /* Nonzero if this statement has been modified and needs to have its
299 operands rescanned. */
300 unsigned modified : 1;
302 /* Nonzero if this statement contains volatile operands. */
303 unsigned has_volatile_ops : 1;
305 /* Padding to get subcode to 16 bit alignment. */
308 /* The SUBCODE field can be used for tuple-specific flags for tuples
309 that do not require subcodes. Note that SUBCODE should be at
310 least as wide as tree codes, as several tuples store tree codes
312 unsigned int subcode : 16;
314 /* UID of this statement. This is used by passes that want to
315 assign IDs to statements. It must be assigned and used by each
316 pass. By default it should be assumed to contain garbage. */
320 Locus information for debug info. */
323 /* Number of operands in this tuple. */
327 Basic block holding this statement. */
328 struct basic_block_def *bb;
331 Lexical block holding this statement. */
336 /* Base structure for tuples with operands. */
338 struct GTY(()) gimple_statement_with_ops_base
341 struct gimple_statement_base gsbase;
344 SSA operand vectors. NOTE: It should be possible to
345 amalgamate these vectors with the operand vector OP. However,
346 the SSA operand vectors are organized differently and contain
347 more information (like immediate use chaining). */
348 struct def_optype_d GTY((skip (""))) *def_ops;
349 struct use_optype_d GTY((skip (""))) *use_ops;
353 /* Statements that take register operands. */
355 struct GTY(()) gimple_statement_with_ops
358 struct gimple_statement_with_ops_base opbase;
361 Operand vector. NOTE! This must always be the last field
362 of this structure. In particular, this means that this
363 structure cannot be embedded inside another one. */
364 tree GTY((length ("%h.opbase.gsbase.num_ops"))) op[1];
368 /* Base for statements that take both memory and register operands. */
370 struct GTY(()) gimple_statement_with_memory_ops_base
373 struct gimple_statement_with_ops_base opbase;
376 Virtual operands for this statement. The GC will pick them
377 up via the ssa_names array. */
378 tree GTY((skip (""))) vdef;
379 tree GTY((skip (""))) vuse;
383 /* Statements that take both memory and register operands. */
385 struct GTY(()) gimple_statement_with_memory_ops
388 struct gimple_statement_with_memory_ops_base membase;
391 Operand vector. NOTE! This must always be the last field
392 of this structure. In particular, this means that this
393 structure cannot be embedded inside another one. */
394 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
398 /* Call statements that take both memory and register operands. */
400 struct GTY(()) gimple_statement_call
403 struct gimple_statement_with_memory_ops_base membase;
406 struct pt_solution call_used;
407 struct pt_solution call_clobbered;
413 Operand vector. NOTE! This must always be the last field
414 of this structure. In particular, this means that this
415 structure cannot be embedded inside another one. */
416 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
420 /* OpenMP statements (#pragma omp). */
422 struct GTY(()) gimple_statement_omp {
424 struct gimple_statement_base gsbase;
433 struct GTY(()) gimple_statement_bind {
435 struct gimple_statement_base gsbase;
438 Variables declared in this scope. */
442 This is different than the BLOCK field in gimple_statement_base,
443 which is analogous to TREE_BLOCK (i.e., the lexical block holding
444 this statement). This field is the equivalent of BIND_EXPR_BLOCK
445 in tree land (i.e., the lexical scope defined by this bind). See
456 struct GTY(()) gimple_statement_catch {
458 struct gimple_statement_base gsbase;
468 /* GIMPLE_EH_FILTER */
470 struct GTY(()) gimple_statement_eh_filter {
472 struct gimple_statement_base gsbase;
484 /* GIMPLE_EH_MUST_NOT_THROW */
486 struct GTY(()) gimple_statement_eh_mnt {
488 struct gimple_statement_base gsbase;
490 /* [ WORD 5 ] Abort function decl. */
496 struct GTY(()) gimple_statement_phi {
498 struct gimple_statement_base gsbase;
508 struct phi_arg_d GTY ((length ("%h.nargs"))) args[1];
512 /* GIMPLE_RESX, GIMPLE_EH_DISPATCH */
514 struct GTY(()) gimple_statement_eh_ctrl
517 struct gimple_statement_base gsbase;
520 Exception region number. */
527 struct GTY(()) gimple_statement_try {
529 struct gimple_statement_base gsbase;
532 Expression to evaluate. */
536 Cleanup expression. */
540 /* Kind of GIMPLE_TRY statements. */
541 enum gimple_try_flags
544 GIMPLE_TRY_CATCH = 1 << 0,
547 GIMPLE_TRY_FINALLY = 1 << 1,
548 GIMPLE_TRY_KIND = GIMPLE_TRY_CATCH | GIMPLE_TRY_FINALLY,
550 /* Analogous to TRY_CATCH_IS_CLEANUP. */
551 GIMPLE_TRY_CATCH_IS_CLEANUP = 1 << 2
554 /* GIMPLE_WITH_CLEANUP_EXPR */
556 struct GTY(()) gimple_statement_wce {
558 struct gimple_statement_base gsbase;
560 /* Subcode: CLEANUP_EH_ONLY. True if the cleanup should only be
561 executed if an exception is thrown, not on normal exit of its
562 scope. This flag is analogous to the CLEANUP_EH_ONLY flag
566 Cleanup expression. */
573 struct GTY(()) gimple_statement_asm
576 struct gimple_statement_with_memory_ops_base membase;
579 __asm__ statement. */
583 Number of inputs, outputs, clobbers, labels. */
590 Operand vector. NOTE! This must always be the last field
591 of this structure. In particular, this means that this
592 structure cannot be embedded inside another one. */
593 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
596 /* GIMPLE_OMP_CRITICAL */
598 struct GTY(()) gimple_statement_omp_critical {
600 struct gimple_statement_omp omp;
603 Critical section name. */
608 struct GTY(()) gimple_omp_for_iter {
609 /* Condition code. */
612 /* Index variable. */
627 struct GTY(()) gimple_statement_omp_for {
629 struct gimple_statement_omp omp;
635 Number of elements in iter array. */
639 struct gimple_omp_for_iter * GTY((length ("%h.collapse"))) iter;
642 Pre-body evaluated before the loop body begins. */
647 /* GIMPLE_OMP_PARALLEL */
649 struct GTY(()) gimple_statement_omp_parallel {
651 struct gimple_statement_omp omp;
658 Child function holding the body of the parallel region. */
662 Shared data argument. */
667 /* GIMPLE_OMP_TASK */
669 struct GTY(()) gimple_statement_omp_task {
671 struct gimple_statement_omp_parallel par;
674 Child function holding firstprivate initialization if needed. */
678 Size and alignment in bytes of the argument data block. */
684 /* GIMPLE_OMP_SECTION */
685 /* Uses struct gimple_statement_omp. */
688 /* GIMPLE_OMP_SECTIONS */
690 struct GTY(()) gimple_statement_omp_sections {
692 struct gimple_statement_omp omp;
698 The control variable used for deciding which of the sections to
703 /* GIMPLE_OMP_CONTINUE.
705 Note: This does not inherit from gimple_statement_omp, because we
706 do not need the body field. */
708 struct GTY(()) gimple_statement_omp_continue {
710 struct gimple_statement_base gsbase;
719 /* GIMPLE_OMP_SINGLE */
721 struct GTY(()) gimple_statement_omp_single {
723 struct gimple_statement_omp omp;
730 /* GIMPLE_OMP_ATOMIC_LOAD.
731 Note: This is based on gimple_statement_base, not g_s_omp, because g_s_omp
732 contains a sequence, which we don't need here. */
734 struct GTY(()) gimple_statement_omp_atomic_load {
736 struct gimple_statement_base gsbase;
742 /* GIMPLE_OMP_ATOMIC_STORE.
743 See note on GIMPLE_OMP_ATOMIC_LOAD. */
745 struct GTY(()) gimple_statement_omp_atomic_store {
747 struct gimple_statement_base gsbase;
753 #define DEFGSSTRUCT(SYM, STRUCT, HAS_TREE_OP) SYM,
754 enum gimple_statement_structure_enum {
755 #include "gsstruct.def"
761 /* Define the overall contents of a gimple tuple. It may be any of the
762 structures declared above for various types of tuples. */
764 union GTY ((desc ("gimple_statement_structure (&%h)"), variable_size)) gimple_statement_d {
765 struct gimple_statement_base GTY ((tag ("GSS_BASE"))) gsbase;
766 struct gimple_statement_with_ops GTY ((tag ("GSS_WITH_OPS"))) gsops;
767 struct gimple_statement_with_memory_ops_base GTY ((tag ("GSS_WITH_MEM_OPS_BASE"))) gsmembase;
768 struct gimple_statement_with_memory_ops GTY ((tag ("GSS_WITH_MEM_OPS"))) gsmem;
769 struct gimple_statement_call GTY ((tag ("GSS_CALL"))) gimple_call;
770 struct gimple_statement_omp GTY ((tag ("GSS_OMP"))) omp;
771 struct gimple_statement_bind GTY ((tag ("GSS_BIND"))) gimple_bind;
772 struct gimple_statement_catch GTY ((tag ("GSS_CATCH"))) gimple_catch;
773 struct gimple_statement_eh_filter GTY ((tag ("GSS_EH_FILTER"))) gimple_eh_filter;
774 struct gimple_statement_eh_mnt GTY ((tag ("GSS_EH_MNT"))) gimple_eh_mnt;
775 struct gimple_statement_phi GTY ((tag ("GSS_PHI"))) gimple_phi;
776 struct gimple_statement_eh_ctrl GTY ((tag ("GSS_EH_CTRL"))) gimple_eh_ctrl;
777 struct gimple_statement_try GTY ((tag ("GSS_TRY"))) gimple_try;
778 struct gimple_statement_wce GTY ((tag ("GSS_WCE"))) gimple_wce;
779 struct gimple_statement_asm GTY ((tag ("GSS_ASM"))) gimple_asm;
780 struct gimple_statement_omp_critical GTY ((tag ("GSS_OMP_CRITICAL"))) gimple_omp_critical;
781 struct gimple_statement_omp_for GTY ((tag ("GSS_OMP_FOR"))) gimple_omp_for;
782 struct gimple_statement_omp_parallel GTY ((tag ("GSS_OMP_PARALLEL"))) gimple_omp_parallel;
783 struct gimple_statement_omp_task GTY ((tag ("GSS_OMP_TASK"))) gimple_omp_task;
784 struct gimple_statement_omp_sections GTY ((tag ("GSS_OMP_SECTIONS"))) gimple_omp_sections;
785 struct gimple_statement_omp_single GTY ((tag ("GSS_OMP_SINGLE"))) gimple_omp_single;
786 struct gimple_statement_omp_continue GTY ((tag ("GSS_OMP_CONTINUE"))) gimple_omp_continue;
787 struct gimple_statement_omp_atomic_load GTY ((tag ("GSS_OMP_ATOMIC_LOAD"))) gimple_omp_atomic_load;
788 struct gimple_statement_omp_atomic_store GTY ((tag ("GSS_OMP_ATOMIC_STORE"))) gimple_omp_atomic_store;
793 /* Offset in bytes to the location of the operand vector.
794 Zero if there is no operand vector for this tuple structure. */
795 extern size_t const gimple_ops_offset_[];
797 /* Map GIMPLE codes to GSS codes. */
798 extern enum gimple_statement_structure_enum const gss_for_code_[];
800 /* This variable holds the currently expanded gimple statement for purposes
801 of comminucating the profile info to the builtin expanders. */
802 extern gimple currently_expanding_gimple_stmt;
804 gimple gimple_build_return (tree);
806 gimple gimple_build_assign_stat (tree, tree MEM_STAT_DECL);
807 #define gimple_build_assign(l,r) gimple_build_assign_stat (l, r MEM_STAT_INFO)
809 void extract_ops_from_tree_1 (tree, enum tree_code *, tree *, tree *, tree *);
811 gimple gimple_build_assign_with_ops_stat (enum tree_code, tree, tree,
812 tree, tree MEM_STAT_DECL);
813 #define gimple_build_assign_with_ops(c,o1,o2,o3) \
814 gimple_build_assign_with_ops_stat (c, o1, o2, o3, NULL_TREE MEM_STAT_INFO)
815 #define gimple_build_assign_with_ops3(c,o1,o2,o3,o4) \
816 gimple_build_assign_with_ops_stat (c, o1, o2, o3, o4 MEM_STAT_INFO)
818 gimple gimple_build_debug_bind_stat (tree, tree, gimple MEM_STAT_DECL);
819 #define gimple_build_debug_bind(var,val,stmt) \
820 gimple_build_debug_bind_stat ((var), (val), (stmt) MEM_STAT_INFO)
822 gimple gimple_build_call_vec (tree, VEC(tree, heap) *);
823 gimple gimple_build_call (tree, unsigned, ...);
824 gimple gimple_build_call_from_tree (tree);
825 gimple gimplify_assign (tree, tree, gimple_seq *);
826 gimple gimple_build_cond (enum tree_code, tree, tree, tree, tree);
827 gimple gimple_build_label (tree label);
828 gimple gimple_build_goto (tree dest);
829 gimple gimple_build_nop (void);
830 gimple gimple_build_bind (tree, gimple_seq, tree);
831 gimple gimple_build_asm_vec (const char *, VEC(tree,gc) *, VEC(tree,gc) *,
832 VEC(tree,gc) *, VEC(tree,gc) *);
833 gimple gimple_build_catch (tree, gimple_seq);
834 gimple gimple_build_eh_filter (tree, gimple_seq);
835 gimple gimple_build_eh_must_not_throw (tree);
836 gimple gimple_build_try (gimple_seq, gimple_seq, enum gimple_try_flags);
837 gimple gimple_build_wce (gimple_seq);
838 gimple gimple_build_resx (int);
839 gimple gimple_build_eh_dispatch (int);
840 gimple gimple_build_switch_nlabels (unsigned, tree, tree);
841 gimple gimple_build_switch (unsigned, tree, tree, ...);
842 gimple gimple_build_switch_vec (tree, tree, VEC(tree,heap) *);
843 gimple gimple_build_omp_parallel (gimple_seq, tree, tree, tree);
844 gimple gimple_build_omp_task (gimple_seq, tree, tree, tree, tree, tree, tree);
845 gimple gimple_build_omp_for (gimple_seq, tree, size_t, gimple_seq);
846 gimple gimple_build_omp_critical (gimple_seq, tree);
847 gimple gimple_build_omp_section (gimple_seq);
848 gimple gimple_build_omp_continue (tree, tree);
849 gimple gimple_build_omp_master (gimple_seq);
850 gimple gimple_build_omp_return (bool);
851 gimple gimple_build_omp_ordered (gimple_seq);
852 gimple gimple_build_omp_sections (gimple_seq, tree);
853 gimple gimple_build_omp_sections_switch (void);
854 gimple gimple_build_omp_single (gimple_seq, tree);
855 gimple gimple_build_cdt (tree, tree);
856 gimple gimple_build_omp_atomic_load (tree, tree);
857 gimple gimple_build_omp_atomic_store (tree);
858 gimple gimple_build_predict (enum br_predictor, enum prediction);
859 enum gimple_statement_structure_enum gss_for_assign (enum tree_code);
860 void sort_case_labels (VEC(tree,heap) *);
861 void gimple_set_body (tree, gimple_seq);
862 gimple_seq gimple_body (tree);
863 bool gimple_has_body_p (tree);
864 gimple_seq gimple_seq_alloc (void);
865 void gimple_seq_free (gimple_seq);
866 void gimple_seq_add_seq (gimple_seq *, gimple_seq);
867 gimple_seq gimple_seq_copy (gimple_seq);
868 int gimple_call_flags (const_gimple);
869 int gimple_call_return_flags (const_gimple);
870 int gimple_call_arg_flags (const_gimple, unsigned);
871 void gimple_call_reset_alias_info (gimple);
872 bool gimple_assign_copy_p (gimple);
873 bool gimple_assign_ssa_name_copy_p (gimple);
874 bool gimple_assign_unary_nop_p (gimple);
875 void gimple_set_bb (gimple, struct basic_block_def *);
876 void gimple_assign_set_rhs_from_tree (gimple_stmt_iterator *, tree);
877 void gimple_assign_set_rhs_with_ops_1 (gimple_stmt_iterator *, enum tree_code,
879 tree gimple_get_lhs (const_gimple);
880 void gimple_set_lhs (gimple, tree);
881 void gimple_replace_lhs (gimple, tree);
882 gimple gimple_copy (gimple);
883 void gimple_set_modified (gimple, bool);
884 void gimple_cond_get_ops_from_tree (tree, enum tree_code *, tree *, tree *);
885 gimple gimple_build_cond_from_tree (tree, tree, tree);
886 void gimple_cond_set_condition_from_tree (gimple, tree);
887 bool gimple_has_side_effects (const_gimple);
888 bool gimple_rhs_has_side_effects (const_gimple);
889 bool gimple_could_trap_p (gimple);
890 bool gimple_could_trap_p_1 (gimple, bool, bool);
891 bool gimple_assign_rhs_could_trap_p (gimple);
892 void gimple_regimplify_operands (gimple, gimple_stmt_iterator *);
893 bool empty_body_p (gimple_seq);
894 unsigned get_gimple_rhs_num_ops (enum tree_code);
895 #define gimple_alloc(c, n) gimple_alloc_stat (c, n MEM_STAT_INFO)
896 gimple gimple_alloc_stat (enum gimple_code, unsigned MEM_STAT_DECL);
897 const char *gimple_decl_printable_name (tree, int);
898 bool gimple_fold_call (gimple_stmt_iterator *gsi, bool inplace);
899 tree gimple_get_virt_method_for_binfo (HOST_WIDE_INT, tree, tree *, bool);
900 void gimple_adjust_this_by_delta (gimple_stmt_iterator *, tree);
901 tree gimple_extract_devirt_binfo_from_cst (tree);
902 /* Returns true iff T is a valid GIMPLE statement. */
903 extern bool is_gimple_stmt (tree);
905 /* Returns true iff TYPE is a valid type for a scalar register variable. */
906 extern bool is_gimple_reg_type (tree);
907 /* Returns true iff T is a scalar register variable. */
908 extern bool is_gimple_reg (tree);
909 /* Returns true iff T is any sort of variable. */
910 extern bool is_gimple_variable (tree);
911 /* Returns true iff T is any sort of symbol. */
912 extern bool is_gimple_id (tree);
913 /* Returns true iff T is a variable or an INDIRECT_REF (of a variable). */
914 extern bool is_gimple_min_lval (tree);
915 /* Returns true iff T is something whose address can be taken. */
916 extern bool is_gimple_addressable (tree);
917 /* Returns true iff T is any valid GIMPLE lvalue. */
918 extern bool is_gimple_lvalue (tree);
920 /* Returns true iff T is a GIMPLE address. */
921 bool is_gimple_address (const_tree);
922 /* Returns true iff T is a GIMPLE invariant address. */
923 bool is_gimple_invariant_address (const_tree);
924 /* Returns true iff T is a GIMPLE invariant address at interprocedural
926 bool is_gimple_ip_invariant_address (const_tree);
927 /* Returns true iff T is a valid GIMPLE constant. */
928 bool is_gimple_constant (const_tree);
929 /* Returns true iff T is a GIMPLE restricted function invariant. */
930 extern bool is_gimple_min_invariant (const_tree);
931 /* Returns true iff T is a GIMPLE restricted interprecodural invariant. */
932 extern bool is_gimple_ip_invariant (const_tree);
933 /* Returns true iff T is a GIMPLE rvalue. */
934 extern bool is_gimple_val (tree);
935 /* Returns true iff T is a GIMPLE asm statement input. */
936 extern bool is_gimple_asm_val (tree);
937 /* Returns true iff T is a valid address operand of a MEM_REF. */
938 bool is_gimple_mem_ref_addr (tree);
939 /* Returns true iff T is a valid rhs for a MODIFY_EXPR where the LHS is a
940 GIMPLE temporary, a renamed user variable, or something else,
942 extern bool is_gimple_reg_rhs (tree);
943 extern bool is_gimple_mem_rhs (tree);
945 /* Returns true iff T is a valid if-statement condition. */
946 extern bool is_gimple_condexpr (tree);
948 /* Returns true iff T is a variable that does not need to live in memory. */
949 extern bool is_gimple_non_addressable (tree t);
951 /* Returns true iff T is a valid call address expression. */
952 extern bool is_gimple_call_addr (tree);
953 /* If T makes a function call, returns the CALL_EXPR operand. */
954 extern tree get_call_expr_in (tree t);
956 extern void recalculate_side_effects (tree);
957 extern bool gimple_compare_field_offset (tree, tree);
958 extern tree gimple_register_type (tree);
959 extern tree gimple_register_canonical_type (tree);
960 enum gtc_mode { GTC_MERGE = 0, GTC_DIAG = 1 };
961 extern bool gimple_types_compatible_p (tree, tree, enum gtc_mode);
962 extern void print_gimple_types_stats (void);
963 extern void free_gimple_type_tables (void);
964 extern tree gimple_unsigned_type (tree);
965 extern tree gimple_signed_type (tree);
966 extern alias_set_type gimple_get_alias_set (tree);
967 extern void count_uses_and_derefs (tree, gimple, unsigned *, unsigned *,
969 extern bool walk_stmt_load_store_addr_ops (gimple, void *,
970 bool (*)(gimple, tree, void *),
971 bool (*)(gimple, tree, void *),
972 bool (*)(gimple, tree, void *));
973 extern bool walk_stmt_load_store_ops (gimple, void *,
974 bool (*)(gimple, tree, void *),
975 bool (*)(gimple, tree, void *));
976 extern bool gimple_ior_addresses_taken (bitmap, gimple);
977 extern bool gimple_call_builtin_p (gimple, enum built_in_function);
978 extern bool gimple_asm_clobbers_memory_p (const_gimple);
981 extern tree create_tmp_var_raw (tree, const char *);
982 extern tree create_tmp_var_name (const char *);
983 extern tree create_tmp_var (tree, const char *);
984 extern tree create_tmp_reg (tree, const char *);
985 extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq *);
986 extern tree get_formal_tmp_var (tree, gimple_seq *);
987 extern void declare_vars (tree, gimple, bool);
988 extern void annotate_all_with_location (gimple_seq, location_t);
990 /* Validation of GIMPLE expressions. Note that these predicates only check
991 the basic form of the expression, they don't recurse to make sure that
992 underlying nodes are also of the right form. */
993 typedef bool (*gimple_predicate)(tree);
996 /* FIXME we should deduce this from the predicate. */
998 fb_none = 0, /* Do not generate a temporary. */
1000 fb_rvalue = 1, /* Generate an rvalue to hold the result of a
1001 gimplified expression. */
1003 fb_lvalue = 2, /* Generate an lvalue to hold the result of a
1004 gimplified expression. */
1006 fb_mayfail = 4, /* Gimplification may fail. Error issued
1008 fb_either= fb_rvalue | fb_lvalue
1011 typedef int fallback_t;
1013 enum gimplify_status {
1014 GS_ERROR = -2, /* Something Bad Seen. */
1015 GS_UNHANDLED = -1, /* A langhook result for "I dunno". */
1016 GS_OK = 0, /* We did something, maybe more to do. */
1017 GS_ALL_DONE = 1 /* The expression is fully gimplified. */
1022 struct gimplify_ctx *prev_context;
1024 VEC(gimple,heap) *bind_expr_stack;
1026 gimple_seq conditional_cleanups;
1030 VEC(tree,heap) *case_labels;
1031 /* The formal temporary table. Should this be persistent? */
1037 bool allow_rhs_cond_expr;
1040 extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *,
1041 bool (*) (tree), fallback_t);
1042 extern void gimplify_type_sizes (tree, gimple_seq *);
1043 extern void gimplify_one_sizepos (tree *, gimple_seq *);
1044 extern bool gimplify_stmt (tree *, gimple_seq *);
1045 extern gimple gimplify_body (tree *, tree, bool);
1046 extern void push_gimplify_context (struct gimplify_ctx *);
1047 extern void pop_gimplify_context (gimple);
1048 extern void gimplify_and_add (tree, gimple_seq *);
1050 /* Miscellaneous helpers. */
1051 extern void gimple_add_tmp_var (tree);
1052 extern gimple gimple_current_bind_expr (void);
1053 extern VEC(gimple, heap) *gimple_bind_expr_stack (void);
1054 extern tree voidify_wrapper_expr (tree, tree);
1055 extern tree build_and_jump (tree *);
1056 extern tree force_labels_r (tree *, int *, void *);
1057 extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *,
1059 struct gimplify_omp_ctx;
1060 extern void omp_firstprivatize_variable (struct gimplify_omp_ctx *, tree);
1061 extern tree gimple_boolify (tree);
1062 extern gimple_predicate rhs_predicate_for (tree);
1063 extern tree canonicalize_cond_expr_cond (tree);
1066 extern tree omp_reduction_init (tree, tree);
1068 /* In tree-nested.c. */
1069 extern void lower_nested_functions (tree);
1070 extern void insert_field_into_struct (tree, tree);
1072 /* In gimplify.c. */
1073 extern void gimplify_function_tree (tree);
1075 /* In cfgexpand.c. */
1076 extern tree gimple_assign_rhs_to_tree (gimple);
1079 extern bool validate_gimple_arglist (const_gimple, ...);
1082 extern bool tree_ssa_useless_type_conversion (tree);
1083 extern tree tree_ssa_strip_useless_type_conversions (tree);
1084 extern bool useless_type_conversion_p (tree, tree);
1085 extern bool types_compatible_p (tree, tree);
1087 /* Return the code for GIMPLE statement G. */
1089 static inline enum gimple_code
1090 gimple_code (const_gimple g)
1092 return g->gsbase.code;
1096 /* Return the GSS code used by a GIMPLE code. */
1098 static inline enum gimple_statement_structure_enum
1099 gss_for_code (enum gimple_code code)
1101 gcc_gimple_checking_assert ((unsigned int)code < LAST_AND_UNUSED_GIMPLE_CODE);
1102 return gss_for_code_[code];
1106 /* Return which GSS code is used by GS. */
1108 static inline enum gimple_statement_structure_enum
1109 gimple_statement_structure (gimple gs)
1111 return gss_for_code (gimple_code (gs));
1115 /* Return true if statement G has sub-statements. This is only true for
1116 High GIMPLE statements. */
1119 gimple_has_substatements (gimple g)
1121 switch (gimple_code (g))
1125 case GIMPLE_EH_FILTER:
1127 case GIMPLE_OMP_FOR:
1128 case GIMPLE_OMP_MASTER:
1129 case GIMPLE_OMP_ORDERED:
1130 case GIMPLE_OMP_SECTION:
1131 case GIMPLE_OMP_PARALLEL:
1132 case GIMPLE_OMP_TASK:
1133 case GIMPLE_OMP_SECTIONS:
1134 case GIMPLE_OMP_SINGLE:
1135 case GIMPLE_OMP_CRITICAL:
1136 case GIMPLE_WITH_CLEANUP_EXPR:
1145 /* Return the basic block holding statement G. */
1147 static inline struct basic_block_def *
1148 gimple_bb (const_gimple g)
1150 return g->gsbase.bb;
1154 /* Return the lexical scope block holding statement G. */
1157 gimple_block (const_gimple g)
1159 return g->gsbase.block;
1163 /* Set BLOCK to be the lexical scope block holding statement G. */
1166 gimple_set_block (gimple g, tree block)
1168 g->gsbase.block = block;
1172 /* Return location information for statement G. */
1174 static inline location_t
1175 gimple_location (const_gimple g)
1177 return g->gsbase.location;
1180 /* Return pointer to location information for statement G. */
1182 static inline const location_t *
1183 gimple_location_ptr (const_gimple g)
1185 return &g->gsbase.location;
1189 /* Set location information for statement G. */
1192 gimple_set_location (gimple g, location_t location)
1194 g->gsbase.location = location;
1198 /* Return true if G contains location information. */
1201 gimple_has_location (const_gimple g)
1203 return gimple_location (g) != UNKNOWN_LOCATION;
1207 /* Return the file name of the location of STMT. */
1209 static inline const char *
1210 gimple_filename (const_gimple stmt)
1212 return LOCATION_FILE (gimple_location (stmt));
1216 /* Return the line number of the location of STMT. */
1219 gimple_lineno (const_gimple stmt)
1221 return LOCATION_LINE (gimple_location (stmt));
1225 /* Determine whether SEQ is a singleton. */
1228 gimple_seq_singleton_p (gimple_seq seq)
1230 return ((gimple_seq_first (seq) != NULL)
1231 && (gimple_seq_first (seq) == gimple_seq_last (seq)));
1234 /* Return true if no warnings should be emitted for statement STMT. */
1237 gimple_no_warning_p (const_gimple stmt)
1239 return stmt->gsbase.no_warning;
1242 /* Set the no_warning flag of STMT to NO_WARNING. */
1245 gimple_set_no_warning (gimple stmt, bool no_warning)
1247 stmt->gsbase.no_warning = (unsigned) no_warning;
1250 /* Set the visited status on statement STMT to VISITED_P. */
1253 gimple_set_visited (gimple stmt, bool visited_p)
1255 stmt->gsbase.visited = (unsigned) visited_p;
1259 /* Return the visited status for statement STMT. */
1262 gimple_visited_p (gimple stmt)
1264 return stmt->gsbase.visited;
1268 /* Set pass local flag PLF on statement STMT to VAL_P. */
1271 gimple_set_plf (gimple stmt, enum plf_mask plf, bool val_p)
1274 stmt->gsbase.plf |= (unsigned int) plf;
1276 stmt->gsbase.plf &= ~((unsigned int) plf);
1280 /* Return the value of pass local flag PLF on statement STMT. */
1282 static inline unsigned int
1283 gimple_plf (gimple stmt, enum plf_mask plf)
1285 return stmt->gsbase.plf & ((unsigned int) plf);
1289 /* Set the UID of statement. */
1292 gimple_set_uid (gimple g, unsigned uid)
1294 g->gsbase.uid = uid;
1298 /* Return the UID of statement. */
1300 static inline unsigned
1301 gimple_uid (const_gimple g)
1303 return g->gsbase.uid;
1307 /* Return true if GIMPLE statement G has register or memory operands. */
1310 gimple_has_ops (const_gimple g)
1312 return gimple_code (g) >= GIMPLE_COND && gimple_code (g) <= GIMPLE_RETURN;
1316 /* Return true if GIMPLE statement G has memory operands. */
1319 gimple_has_mem_ops (const_gimple g)
1321 return gimple_code (g) >= GIMPLE_ASSIGN && gimple_code (g) <= GIMPLE_RETURN;
1325 /* Return the set of DEF operands for statement G. */
1327 static inline struct def_optype_d *
1328 gimple_def_ops (const_gimple g)
1330 if (!gimple_has_ops (g))
1332 return g->gsops.opbase.def_ops;
1336 /* Set DEF to be the set of DEF operands for statement G. */
1339 gimple_set_def_ops (gimple g, struct def_optype_d *def)
1341 gcc_gimple_checking_assert (gimple_has_ops (g));
1342 g->gsops.opbase.def_ops = def;
1346 /* Return the set of USE operands for statement G. */
1348 static inline struct use_optype_d *
1349 gimple_use_ops (const_gimple g)
1351 if (!gimple_has_ops (g))
1353 return g->gsops.opbase.use_ops;
1357 /* Set USE to be the set of USE operands for statement G. */
1360 gimple_set_use_ops (gimple g, struct use_optype_d *use)
1362 gcc_gimple_checking_assert (gimple_has_ops (g));
1363 g->gsops.opbase.use_ops = use;
1367 /* Return the set of VUSE operand for statement G. */
1369 static inline use_operand_p
1370 gimple_vuse_op (const_gimple g)
1372 struct use_optype_d *ops;
1373 if (!gimple_has_mem_ops (g))
1374 return NULL_USE_OPERAND_P;
1375 ops = g->gsops.opbase.use_ops;
1377 && USE_OP_PTR (ops)->use == &g->gsmembase.vuse)
1378 return USE_OP_PTR (ops);
1379 return NULL_USE_OPERAND_P;
1382 /* Return the set of VDEF operand for statement G. */
1384 static inline def_operand_p
1385 gimple_vdef_op (const_gimple g)
1387 struct def_optype_d *ops;
1388 if (!gimple_has_mem_ops (g))
1389 return NULL_DEF_OPERAND_P;
1390 ops = g->gsops.opbase.def_ops;
1392 && DEF_OP_PTR (ops) == &g->gsmembase.vdef)
1393 return DEF_OP_PTR (ops);
1394 return NULL_DEF_OPERAND_P;
1398 /* Return the single VUSE operand of the statement G. */
1401 gimple_vuse (const_gimple g)
1403 if (!gimple_has_mem_ops (g))
1405 return g->gsmembase.vuse;
1408 /* Return the single VDEF operand of the statement G. */
1411 gimple_vdef (const_gimple g)
1413 if (!gimple_has_mem_ops (g))
1415 return g->gsmembase.vdef;
1418 /* Return the single VUSE operand of the statement G. */
1420 static inline tree *
1421 gimple_vuse_ptr (gimple g)
1423 if (!gimple_has_mem_ops (g))
1425 return &g->gsmembase.vuse;
1428 /* Return the single VDEF operand of the statement G. */
1430 static inline tree *
1431 gimple_vdef_ptr (gimple g)
1433 if (!gimple_has_mem_ops (g))
1435 return &g->gsmembase.vdef;
1438 /* Set the single VUSE operand of the statement G. */
1441 gimple_set_vuse (gimple g, tree vuse)
1443 gcc_gimple_checking_assert (gimple_has_mem_ops (g));
1444 g->gsmembase.vuse = vuse;
1447 /* Set the single VDEF operand of the statement G. */
1450 gimple_set_vdef (gimple g, tree vdef)
1452 gcc_gimple_checking_assert (gimple_has_mem_ops (g));
1453 g->gsmembase.vdef = vdef;
1457 /* Return true if statement G has operands and the modified field has
1461 gimple_modified_p (const_gimple g)
1463 return (gimple_has_ops (g)) ? (bool) g->gsbase.modified : false;
1467 /* Return the tree code for the expression computed by STMT. This is
1468 only valid for GIMPLE_COND, GIMPLE_CALL and GIMPLE_ASSIGN. For
1469 GIMPLE_CALL, return CALL_EXPR as the expression code for
1470 consistency. This is useful when the caller needs to deal with the
1471 three kinds of computation that GIMPLE supports. */
1473 static inline enum tree_code
1474 gimple_expr_code (const_gimple stmt)
1476 enum gimple_code code = gimple_code (stmt);
1477 if (code == GIMPLE_ASSIGN || code == GIMPLE_COND)
1478 return (enum tree_code) stmt->gsbase.subcode;
1481 gcc_gimple_checking_assert (code == GIMPLE_CALL);
1487 /* Mark statement S as modified, and update it. */
1490 update_stmt (gimple s)
1492 if (gimple_has_ops (s))
1494 gimple_set_modified (s, true);
1495 update_stmt_operands (s);
1499 /* Update statement S if it has been optimized. */
1502 update_stmt_if_modified (gimple s)
1504 if (gimple_modified_p (s))
1505 update_stmt_operands (s);
1508 /* Return true if statement STMT contains volatile operands. */
1511 gimple_has_volatile_ops (const_gimple stmt)
1513 if (gimple_has_mem_ops (stmt))
1514 return stmt->gsbase.has_volatile_ops;
1520 /* Set the HAS_VOLATILE_OPS flag to VOLATILEP. */
1523 gimple_set_has_volatile_ops (gimple stmt, bool volatilep)
1525 if (gimple_has_mem_ops (stmt))
1526 stmt->gsbase.has_volatile_ops = (unsigned) volatilep;
1530 /* Return true if statement STMT may access memory. */
1533 gimple_references_memory_p (gimple stmt)
1535 return gimple_has_mem_ops (stmt) && gimple_vuse (stmt);
1539 /* Return the subcode for OMP statement S. */
1541 static inline unsigned
1542 gimple_omp_subcode (const_gimple s)
1544 gcc_gimple_checking_assert (gimple_code (s) >= GIMPLE_OMP_ATOMIC_LOAD
1545 && gimple_code (s) <= GIMPLE_OMP_SINGLE);
1546 return s->gsbase.subcode;
1549 /* Set the subcode for OMP statement S to SUBCODE. */
1552 gimple_omp_set_subcode (gimple s, unsigned int subcode)
1554 /* We only have 16 bits for the subcode. Assert that we are not
1556 gcc_gimple_checking_assert (subcode < (1 << 16));
1557 s->gsbase.subcode = subcode;
1560 /* Set the nowait flag on OMP_RETURN statement S. */
1563 gimple_omp_return_set_nowait (gimple s)
1565 GIMPLE_CHECK (s, GIMPLE_OMP_RETURN);
1566 s->gsbase.subcode |= GF_OMP_RETURN_NOWAIT;
1570 /* Return true if OMP return statement G has the GF_OMP_RETURN_NOWAIT
1574 gimple_omp_return_nowait_p (const_gimple g)
1576 GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
1577 return (gimple_omp_subcode (g) & GF_OMP_RETURN_NOWAIT) != 0;
1581 /* Return true if OMP section statement G has the GF_OMP_SECTION_LAST
1585 gimple_omp_section_last_p (const_gimple g)
1587 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1588 return (gimple_omp_subcode (g) & GF_OMP_SECTION_LAST) != 0;
1592 /* Set the GF_OMP_SECTION_LAST flag on G. */
1595 gimple_omp_section_set_last (gimple g)
1597 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1598 g->gsbase.subcode |= GF_OMP_SECTION_LAST;
1602 /* Return true if OMP parallel statement G has the
1603 GF_OMP_PARALLEL_COMBINED flag set. */
1606 gimple_omp_parallel_combined_p (const_gimple g)
1608 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1609 return (gimple_omp_subcode (g) & GF_OMP_PARALLEL_COMBINED) != 0;
1613 /* Set the GF_OMP_PARALLEL_COMBINED field in G depending on the boolean
1614 value of COMBINED_P. */
1617 gimple_omp_parallel_set_combined_p (gimple g, bool combined_p)
1619 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1621 g->gsbase.subcode |= GF_OMP_PARALLEL_COMBINED;
1623 g->gsbase.subcode &= ~GF_OMP_PARALLEL_COMBINED;
1627 /* Return the number of operands for statement GS. */
1629 static inline unsigned
1630 gimple_num_ops (const_gimple gs)
1632 return gs->gsbase.num_ops;
1636 /* Set the number of operands for statement GS. */
1639 gimple_set_num_ops (gimple gs, unsigned num_ops)
1641 gs->gsbase.num_ops = num_ops;
1645 /* Return the array of operands for statement GS. */
1647 static inline tree *
1648 gimple_ops (gimple gs)
1652 /* All the tuples have their operand vector at the very bottom
1653 of the structure. Note that those structures that do not
1654 have an operand vector have a zero offset. */
1655 off = gimple_ops_offset_[gimple_statement_structure (gs)];
1656 gcc_gimple_checking_assert (off != 0);
1658 return (tree *) ((char *) gs + off);
1662 /* Return operand I for statement GS. */
1665 gimple_op (const_gimple gs, unsigned i)
1667 if (gimple_has_ops (gs))
1669 gcc_gimple_checking_assert (i < gimple_num_ops (gs));
1670 return gimple_ops (CONST_CAST_GIMPLE (gs))[i];
1676 /* Return a pointer to operand I for statement GS. */
1678 static inline tree *
1679 gimple_op_ptr (const_gimple gs, unsigned i)
1681 if (gimple_has_ops (gs))
1683 gcc_gimple_checking_assert (i < gimple_num_ops (gs));
1684 return gimple_ops (CONST_CAST_GIMPLE (gs)) + i;
1690 /* Set operand I of statement GS to OP. */
1693 gimple_set_op (gimple gs, unsigned i, tree op)
1695 gcc_gimple_checking_assert (gimple_has_ops (gs) && i < gimple_num_ops (gs));
1697 /* Note. It may be tempting to assert that OP matches
1698 is_gimple_operand, but that would be wrong. Different tuples
1699 accept slightly different sets of tree operands. Each caller
1700 should perform its own validation. */
1701 gimple_ops (gs)[i] = op;
1704 /* Return true if GS is a GIMPLE_ASSIGN. */
1707 is_gimple_assign (const_gimple gs)
1709 return gimple_code (gs) == GIMPLE_ASSIGN;
1712 /* Determine if expression CODE is one of the valid expressions that can
1713 be used on the RHS of GIMPLE assignments. */
1715 static inline enum gimple_rhs_class
1716 get_gimple_rhs_class (enum tree_code code)
1718 return (enum gimple_rhs_class) gimple_rhs_class_table[(int) code];
1721 /* Return the LHS of assignment statement GS. */
1724 gimple_assign_lhs (const_gimple gs)
1726 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1727 return gimple_op (gs, 0);
1731 /* Return a pointer to the LHS of assignment statement GS. */
1733 static inline tree *
1734 gimple_assign_lhs_ptr (const_gimple gs)
1736 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1737 return gimple_op_ptr (gs, 0);
1741 /* Set LHS to be the LHS operand of assignment statement GS. */
1744 gimple_assign_set_lhs (gimple gs, tree lhs)
1746 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1747 gimple_set_op (gs, 0, lhs);
1749 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1750 SSA_NAME_DEF_STMT (lhs) = gs;
1754 /* Return the first operand on the RHS of assignment statement GS. */
1757 gimple_assign_rhs1 (const_gimple gs)
1759 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1760 return gimple_op (gs, 1);
1764 /* Return a pointer to the first operand on the RHS of assignment
1767 static inline tree *
1768 gimple_assign_rhs1_ptr (const_gimple gs)
1770 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1771 return gimple_op_ptr (gs, 1);
1774 /* Set RHS to be the first operand on the RHS of assignment statement GS. */
1777 gimple_assign_set_rhs1 (gimple gs, tree rhs)
1779 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1781 gimple_set_op (gs, 1, rhs);
1785 /* Return the second operand on the RHS of assignment statement GS.
1786 If GS does not have two operands, NULL is returned instead. */
1789 gimple_assign_rhs2 (const_gimple gs)
1791 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1793 if (gimple_num_ops (gs) >= 3)
1794 return gimple_op (gs, 2);
1800 /* Return a pointer to the second operand on the RHS of assignment
1803 static inline tree *
1804 gimple_assign_rhs2_ptr (const_gimple gs)
1806 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1807 return gimple_op_ptr (gs, 2);
1811 /* Set RHS to be the second operand on the RHS of assignment statement GS. */
1814 gimple_assign_set_rhs2 (gimple gs, tree rhs)
1816 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1818 gimple_set_op (gs, 2, rhs);
1821 /* Return the third operand on the RHS of assignment statement GS.
1822 If GS does not have two operands, NULL is returned instead. */
1825 gimple_assign_rhs3 (const_gimple gs)
1827 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1829 if (gimple_num_ops (gs) >= 4)
1830 return gimple_op (gs, 3);
1835 /* Return a pointer to the third operand on the RHS of assignment
1838 static inline tree *
1839 gimple_assign_rhs3_ptr (const_gimple gs)
1841 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1842 return gimple_op_ptr (gs, 3);
1846 /* Set RHS to be the third operand on the RHS of assignment statement GS. */
1849 gimple_assign_set_rhs3 (gimple gs, tree rhs)
1851 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1853 gimple_set_op (gs, 3, rhs);
1856 /* A wrapper around gimple_assign_set_rhs_with_ops_1, for callers which expect
1857 to see only a maximum of two operands. */
1860 gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *gsi, enum tree_code code,
1863 gimple_assign_set_rhs_with_ops_1 (gsi, code, op1, op2, NULL);
1866 /* A wrapper around extract_ops_from_tree_1, for callers which expect
1867 to see only a maximum of two operands. */
1870 extract_ops_from_tree (tree expr, enum tree_code *code, tree *op0,
1874 extract_ops_from_tree_1 (expr, code, op0, op1, &op2);
1875 gcc_assert (op2 == NULL_TREE);
1878 /* Returns true if GS is a nontemporal move. */
1881 gimple_assign_nontemporal_move_p (const_gimple gs)
1883 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1884 return gs->gsbase.nontemporal_move;
1887 /* Sets nontemporal move flag of GS to NONTEMPORAL. */
1890 gimple_assign_set_nontemporal_move (gimple gs, bool nontemporal)
1892 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1893 gs->gsbase.nontemporal_move = nontemporal;
1897 /* Return the code of the expression computed on the rhs of assignment
1898 statement GS. In case that the RHS is a single object, returns the
1899 tree code of the object. */
1901 static inline enum tree_code
1902 gimple_assign_rhs_code (const_gimple gs)
1904 enum tree_code code;
1905 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1907 code = (enum tree_code) gs->gsbase.subcode;
1908 /* While we initially set subcode to the TREE_CODE of the rhs for
1909 GIMPLE_SINGLE_RHS assigns we do not update that subcode to stay
1910 in sync when we rewrite stmts into SSA form or do SSA propagations. */
1911 if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS)
1912 code = TREE_CODE (gimple_assign_rhs1 (gs));
1918 /* Set CODE to be the code for the expression computed on the RHS of
1922 gimple_assign_set_rhs_code (gimple s, enum tree_code code)
1924 GIMPLE_CHECK (s, GIMPLE_ASSIGN);
1925 s->gsbase.subcode = code;
1929 /* Return the gimple rhs class of the code of the expression computed on
1930 the rhs of assignment statement GS.
1931 This will never return GIMPLE_INVALID_RHS. */
1933 static inline enum gimple_rhs_class
1934 gimple_assign_rhs_class (const_gimple gs)
1936 return get_gimple_rhs_class (gimple_assign_rhs_code (gs));
1939 /* Return true if GS is an assignment with a singleton RHS, i.e.,
1940 there is no operator associated with the assignment itself.
1941 Unlike gimple_assign_copy_p, this predicate returns true for
1942 any RHS operand, including those that perform an operation
1943 and do not have the semantics of a copy, such as COND_EXPR. */
1946 gimple_assign_single_p (gimple gs)
1948 return (is_gimple_assign (gs)
1949 && gimple_assign_rhs_class (gs) == GIMPLE_SINGLE_RHS);
1953 /* Return true if S is a type-cast assignment. */
1956 gimple_assign_cast_p (gimple s)
1958 if (is_gimple_assign (s))
1960 enum tree_code sc = gimple_assign_rhs_code (s);
1961 return CONVERT_EXPR_CODE_P (sc)
1962 || sc == VIEW_CONVERT_EXPR
1963 || sc == FIX_TRUNC_EXPR;
1970 /* Return true if GS is a GIMPLE_CALL. */
1973 is_gimple_call (const_gimple gs)
1975 return gimple_code (gs) == GIMPLE_CALL;
1978 /* Return the LHS of call statement GS. */
1981 gimple_call_lhs (const_gimple gs)
1983 GIMPLE_CHECK (gs, GIMPLE_CALL);
1984 return gimple_op (gs, 0);
1988 /* Return a pointer to the LHS of call statement GS. */
1990 static inline tree *
1991 gimple_call_lhs_ptr (const_gimple gs)
1993 GIMPLE_CHECK (gs, GIMPLE_CALL);
1994 return gimple_op_ptr (gs, 0);
1998 /* Set LHS to be the LHS operand of call statement GS. */
2001 gimple_call_set_lhs (gimple gs, tree lhs)
2003 GIMPLE_CHECK (gs, GIMPLE_CALL);
2004 gimple_set_op (gs, 0, lhs);
2005 if (lhs && TREE_CODE (lhs) == SSA_NAME)
2006 SSA_NAME_DEF_STMT (lhs) = gs;
2010 /* Return the function type of the function called by GS. */
2013 gimple_call_fntype (const_gimple gs)
2015 GIMPLE_CHECK (gs, GIMPLE_CALL);
2016 return gs->gimple_call.fntype;
2019 /* Set the type of the function called by GS to FNTYPE. */
2022 gimple_call_set_fntype (gimple gs, tree fntype)
2024 GIMPLE_CHECK (gs, GIMPLE_CALL);
2025 gs->gimple_call.fntype = fntype;
2029 /* Return the tree node representing the function called by call
2033 gimple_call_fn (const_gimple gs)
2035 GIMPLE_CHECK (gs, GIMPLE_CALL);
2036 return gimple_op (gs, 1);
2039 /* Return a pointer to the tree node representing the function called by call
2042 static inline tree *
2043 gimple_call_fn_ptr (const_gimple gs)
2045 GIMPLE_CHECK (gs, GIMPLE_CALL);
2046 return gimple_op_ptr (gs, 1);
2050 /* Set FN to be the function called by call statement GS. */
2053 gimple_call_set_fn (gimple gs, tree fn)
2055 GIMPLE_CHECK (gs, GIMPLE_CALL);
2056 gimple_set_op (gs, 1, fn);
2060 /* Set FNDECL to be the function called by call statement GS. */
2063 gimple_call_set_fndecl (gimple gs, tree decl)
2065 GIMPLE_CHECK (gs, GIMPLE_CALL);
2066 gimple_set_op (gs, 1, build_fold_addr_expr_loc (gimple_location (gs), decl));
2069 /* Given a valid GIMPLE_CALL function address return the FUNCTION_DECL
2070 associated with the callee if known. Otherwise return NULL_TREE. */
2073 gimple_call_addr_fndecl (const_tree fn)
2075 if (TREE_CODE (fn) == ADDR_EXPR)
2077 tree fndecl = TREE_OPERAND (fn, 0);
2078 if (TREE_CODE (fndecl) == MEM_REF
2079 && TREE_CODE (TREE_OPERAND (fndecl, 0)) == ADDR_EXPR
2080 && integer_zerop (TREE_OPERAND (fndecl, 1)))
2081 fndecl = TREE_OPERAND (TREE_OPERAND (fndecl, 0), 0);
2082 if (TREE_CODE (fndecl) == FUNCTION_DECL)
2088 /* If a given GIMPLE_CALL's callee is a FUNCTION_DECL, return it.
2089 Otherwise return NULL. This function is analogous to
2090 get_callee_fndecl in tree land. */
2093 gimple_call_fndecl (const_gimple gs)
2095 return gimple_call_addr_fndecl (gimple_call_fn (gs));
2099 /* Return the type returned by call statement GS. */
2102 gimple_call_return_type (const_gimple gs)
2104 tree type = gimple_call_fntype (gs);
2106 /* The type returned by a function is the type of its
2108 return TREE_TYPE (type);
2112 /* Return the static chain for call statement GS. */
2115 gimple_call_chain (const_gimple gs)
2117 GIMPLE_CHECK (gs, GIMPLE_CALL);
2118 return gimple_op (gs, 2);
2122 /* Return a pointer to the static chain for call statement GS. */
2124 static inline tree *
2125 gimple_call_chain_ptr (const_gimple gs)
2127 GIMPLE_CHECK (gs, GIMPLE_CALL);
2128 return gimple_op_ptr (gs, 2);
2131 /* Set CHAIN to be the static chain for call statement GS. */
2134 gimple_call_set_chain (gimple gs, tree chain)
2136 GIMPLE_CHECK (gs, GIMPLE_CALL);
2138 gimple_set_op (gs, 2, chain);
2142 /* Return the number of arguments used by call statement GS. */
2144 static inline unsigned
2145 gimple_call_num_args (const_gimple gs)
2148 GIMPLE_CHECK (gs, GIMPLE_CALL);
2149 num_ops = gimple_num_ops (gs);
2154 /* Return the argument at position INDEX for call statement GS. */
2157 gimple_call_arg (const_gimple gs, unsigned index)
2159 GIMPLE_CHECK (gs, GIMPLE_CALL);
2160 return gimple_op (gs, index + 3);
2164 /* Return a pointer to the argument at position INDEX for call
2167 static inline tree *
2168 gimple_call_arg_ptr (const_gimple gs, unsigned index)
2170 GIMPLE_CHECK (gs, GIMPLE_CALL);
2171 return gimple_op_ptr (gs, index + 3);
2175 /* Set ARG to be the argument at position INDEX for call statement GS. */
2178 gimple_call_set_arg (gimple gs, unsigned index, tree arg)
2180 GIMPLE_CHECK (gs, GIMPLE_CALL);
2181 gimple_set_op (gs, index + 3, arg);
2185 /* If TAIL_P is true, mark call statement S as being a tail call
2186 (i.e., a call just before the exit of a function). These calls are
2187 candidate for tail call optimization. */
2190 gimple_call_set_tail (gimple s, bool tail_p)
2192 GIMPLE_CHECK (s, GIMPLE_CALL);
2194 s->gsbase.subcode |= GF_CALL_TAILCALL;
2196 s->gsbase.subcode &= ~GF_CALL_TAILCALL;
2200 /* Return true if GIMPLE_CALL S is marked as a tail call. */
2203 gimple_call_tail_p (gimple s)
2205 GIMPLE_CHECK (s, GIMPLE_CALL);
2206 return (s->gsbase.subcode & GF_CALL_TAILCALL) != 0;
2210 /* Set the inlinable status of GIMPLE_CALL S to INLINABLE_P. */
2213 gimple_call_set_cannot_inline (gimple s, bool inlinable_p)
2215 GIMPLE_CHECK (s, GIMPLE_CALL);
2217 s->gsbase.subcode |= GF_CALL_CANNOT_INLINE;
2219 s->gsbase.subcode &= ~GF_CALL_CANNOT_INLINE;
2223 /* Return true if GIMPLE_CALL S cannot be inlined. */
2226 gimple_call_cannot_inline_p (gimple s)
2228 GIMPLE_CHECK (s, GIMPLE_CALL);
2229 return (s->gsbase.subcode & GF_CALL_CANNOT_INLINE) != 0;
2233 /* If RETURN_SLOT_OPT_P is true mark GIMPLE_CALL S as valid for return
2234 slot optimization. This transformation uses the target of the call
2235 expansion as the return slot for calls that return in memory. */
2238 gimple_call_set_return_slot_opt (gimple s, bool return_slot_opt_p)
2240 GIMPLE_CHECK (s, GIMPLE_CALL);
2241 if (return_slot_opt_p)
2242 s->gsbase.subcode |= GF_CALL_RETURN_SLOT_OPT;
2244 s->gsbase.subcode &= ~GF_CALL_RETURN_SLOT_OPT;
2248 /* Return true if S is marked for return slot optimization. */
2251 gimple_call_return_slot_opt_p (gimple s)
2253 GIMPLE_CHECK (s, GIMPLE_CALL);
2254 return (s->gsbase.subcode & GF_CALL_RETURN_SLOT_OPT) != 0;
2258 /* If FROM_THUNK_P is true, mark GIMPLE_CALL S as being the jump from a
2259 thunk to the thunked-to function. */
2262 gimple_call_set_from_thunk (gimple s, bool from_thunk_p)
2264 GIMPLE_CHECK (s, GIMPLE_CALL);
2266 s->gsbase.subcode |= GF_CALL_FROM_THUNK;
2268 s->gsbase.subcode &= ~GF_CALL_FROM_THUNK;
2272 /* Return true if GIMPLE_CALL S is a jump from a thunk. */
2275 gimple_call_from_thunk_p (gimple s)
2277 GIMPLE_CHECK (s, GIMPLE_CALL);
2278 return (s->gsbase.subcode & GF_CALL_FROM_THUNK) != 0;
2282 /* If PASS_ARG_PACK_P is true, GIMPLE_CALL S is a stdarg call that needs the
2283 argument pack in its argument list. */
2286 gimple_call_set_va_arg_pack (gimple s, bool pass_arg_pack_p)
2288 GIMPLE_CHECK (s, GIMPLE_CALL);
2289 if (pass_arg_pack_p)
2290 s->gsbase.subcode |= GF_CALL_VA_ARG_PACK;
2292 s->gsbase.subcode &= ~GF_CALL_VA_ARG_PACK;
2296 /* Return true if GIMPLE_CALL S is a stdarg call that needs the
2297 argument pack in its argument list. */
2300 gimple_call_va_arg_pack_p (gimple s)
2302 GIMPLE_CHECK (s, GIMPLE_CALL);
2303 return (s->gsbase.subcode & GF_CALL_VA_ARG_PACK) != 0;
2307 /* Return true if S is a noreturn call. */
2310 gimple_call_noreturn_p (gimple s)
2312 GIMPLE_CHECK (s, GIMPLE_CALL);
2313 return (gimple_call_flags (s) & ECF_NORETURN) != 0;
2317 /* If NOTHROW_P is true, GIMPLE_CALL S is a call that is known to not throw
2318 even if the called function can throw in other cases. */
2321 gimple_call_set_nothrow (gimple s, bool nothrow_p)
2323 GIMPLE_CHECK (s, GIMPLE_CALL);
2325 s->gsbase.subcode |= GF_CALL_NOTHROW;
2327 s->gsbase.subcode &= ~GF_CALL_NOTHROW;
2330 /* Return true if S is a nothrow call. */
2333 gimple_call_nothrow_p (gimple s)
2335 GIMPLE_CHECK (s, GIMPLE_CALL);
2336 return (gimple_call_flags (s) & ECF_NOTHROW) != 0;
2339 /* If FOR_VAR is true, GIMPLE_CALL S is a call to builtin_alloca that
2340 is known to be emitted for VLA objects. Those are wrapped by
2341 stack_save/stack_restore calls and hence can't lead to unbounded
2342 stack growth even when they occur in loops. */
2345 gimple_call_set_alloca_for_var (gimple s, bool for_var)
2347 GIMPLE_CHECK (s, GIMPLE_CALL);
2349 s->gsbase.subcode |= GF_CALL_ALLOCA_FOR_VAR;
2351 s->gsbase.subcode &= ~GF_CALL_ALLOCA_FOR_VAR;
2354 /* Return true of S is a call to builtin_alloca emitted for VLA objects. */
2357 gimple_call_alloca_for_var_p (gimple s)
2359 GIMPLE_CHECK (s, GIMPLE_CALL);
2360 return (s->gsbase.subcode & GF_CALL_ALLOCA_FOR_VAR) != 0;
2363 /* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL. */
2366 gimple_call_copy_flags (gimple dest_call, gimple orig_call)
2368 GIMPLE_CHECK (dest_call, GIMPLE_CALL);
2369 GIMPLE_CHECK (orig_call, GIMPLE_CALL);
2370 dest_call->gsbase.subcode = orig_call->gsbase.subcode;
2374 /* Return a pointer to the points-to solution for the set of call-used
2375 variables of the call CALL. */
2377 static inline struct pt_solution *
2378 gimple_call_use_set (gimple call)
2380 GIMPLE_CHECK (call, GIMPLE_CALL);
2381 return &call->gimple_call.call_used;
2385 /* Return a pointer to the points-to solution for the set of call-used
2386 variables of the call CALL. */
2388 static inline struct pt_solution *
2389 gimple_call_clobber_set (gimple call)
2391 GIMPLE_CHECK (call, GIMPLE_CALL);
2392 return &call->gimple_call.call_clobbered;
2396 /* Returns true if this is a GIMPLE_ASSIGN or a GIMPLE_CALL with a
2400 gimple_has_lhs (gimple stmt)
2402 return (is_gimple_assign (stmt)
2403 || (is_gimple_call (stmt)
2404 && gimple_call_lhs (stmt) != NULL_TREE));
2408 /* Return the code of the predicate computed by conditional statement GS. */
2410 static inline enum tree_code
2411 gimple_cond_code (const_gimple gs)
2413 GIMPLE_CHECK (gs, GIMPLE_COND);
2414 return (enum tree_code) gs->gsbase.subcode;
2418 /* Set CODE to be the predicate code for the conditional statement GS. */
2421 gimple_cond_set_code (gimple gs, enum tree_code code)
2423 GIMPLE_CHECK (gs, GIMPLE_COND);
2424 gs->gsbase.subcode = code;
2428 /* Return the LHS of the predicate computed by conditional statement GS. */
2431 gimple_cond_lhs (const_gimple gs)
2433 GIMPLE_CHECK (gs, GIMPLE_COND);
2434 return gimple_op (gs, 0);
2437 /* Return the pointer to the LHS of the predicate computed by conditional
2440 static inline tree *
2441 gimple_cond_lhs_ptr (const_gimple gs)
2443 GIMPLE_CHECK (gs, GIMPLE_COND);
2444 return gimple_op_ptr (gs, 0);
2447 /* Set LHS to be the LHS operand of the predicate computed by
2448 conditional statement GS. */
2451 gimple_cond_set_lhs (gimple gs, tree lhs)
2453 GIMPLE_CHECK (gs, GIMPLE_COND);
2454 gimple_set_op (gs, 0, lhs);
2458 /* Return the RHS operand of the predicate computed by conditional GS. */
2461 gimple_cond_rhs (const_gimple gs)
2463 GIMPLE_CHECK (gs, GIMPLE_COND);
2464 return gimple_op (gs, 1);
2467 /* Return the pointer to the RHS operand of the predicate computed by
2470 static inline tree *
2471 gimple_cond_rhs_ptr (const_gimple gs)
2473 GIMPLE_CHECK (gs, GIMPLE_COND);
2474 return gimple_op_ptr (gs, 1);
2478 /* Set RHS to be the RHS operand of the predicate computed by
2479 conditional statement GS. */
2482 gimple_cond_set_rhs (gimple gs, tree rhs)
2484 GIMPLE_CHECK (gs, GIMPLE_COND);
2485 gimple_set_op (gs, 1, rhs);
2489 /* Return the label used by conditional statement GS when its
2490 predicate evaluates to true. */
2493 gimple_cond_true_label (const_gimple gs)
2495 GIMPLE_CHECK (gs, GIMPLE_COND);
2496 return gimple_op (gs, 2);
2500 /* Set LABEL to be the label used by conditional statement GS when its
2501 predicate evaluates to true. */
2504 gimple_cond_set_true_label (gimple gs, tree label)
2506 GIMPLE_CHECK (gs, GIMPLE_COND);
2507 gimple_set_op (gs, 2, label);
2511 /* Set LABEL to be the label used by conditional statement GS when its
2512 predicate evaluates to false. */
2515 gimple_cond_set_false_label (gimple gs, tree label)
2517 GIMPLE_CHECK (gs, GIMPLE_COND);
2518 gimple_set_op (gs, 3, label);
2522 /* Return the label used by conditional statement GS when its
2523 predicate evaluates to false. */
2526 gimple_cond_false_label (const_gimple gs)
2528 GIMPLE_CHECK (gs, GIMPLE_COND);
2529 return gimple_op (gs, 3);
2533 /* Set the conditional COND_STMT to be of the form 'if (1 == 0)'. */
2536 gimple_cond_make_false (gimple gs)
2538 gimple_cond_set_lhs (gs, boolean_true_node);
2539 gimple_cond_set_rhs (gs, boolean_false_node);
2540 gs->gsbase.subcode = EQ_EXPR;
2544 /* Set the conditional COND_STMT to be of the form 'if (1 == 1)'. */
2547 gimple_cond_make_true (gimple gs)
2549 gimple_cond_set_lhs (gs, boolean_true_node);
2550 gimple_cond_set_rhs (gs, boolean_true_node);
2551 gs->gsbase.subcode = EQ_EXPR;
2554 /* Check if conditional statemente GS is of the form 'if (1 == 1)',
2555 'if (0 == 0)', 'if (1 != 0)' or 'if (0 != 1)' */
2558 gimple_cond_true_p (const_gimple gs)
2560 tree lhs = gimple_cond_lhs (gs);
2561 tree rhs = gimple_cond_rhs (gs);
2562 enum tree_code code = gimple_cond_code (gs);
2564 if (lhs != boolean_true_node && lhs != boolean_false_node)
2567 if (rhs != boolean_true_node && rhs != boolean_false_node)
2570 if (code == NE_EXPR && lhs != rhs)
2573 if (code == EQ_EXPR && lhs == rhs)
2579 /* Check if conditional statement GS is of the form 'if (1 != 1)',
2580 'if (0 != 0)', 'if (1 == 0)' or 'if (0 == 1)' */
2583 gimple_cond_false_p (const_gimple gs)
2585 tree lhs = gimple_cond_lhs (gs);
2586 tree rhs = gimple_cond_rhs (gs);
2587 enum tree_code code = gimple_cond_code (gs);
2589 if (lhs != boolean_true_node && lhs != boolean_false_node)
2592 if (rhs != boolean_true_node && rhs != boolean_false_node)
2595 if (code == NE_EXPR && lhs == rhs)
2598 if (code == EQ_EXPR && lhs != rhs)
2604 /* Check if conditional statement GS is of the form 'if (var != 0)' or
2608 gimple_cond_single_var_p (gimple gs)
2610 if (gimple_cond_code (gs) == NE_EXPR
2611 && gimple_cond_rhs (gs) == boolean_false_node)
2614 if (gimple_cond_code (gs) == EQ_EXPR
2615 && gimple_cond_rhs (gs) == boolean_true_node)
2621 /* Set the code, LHS and RHS of GIMPLE_COND STMT from CODE, LHS and RHS. */
2624 gimple_cond_set_condition (gimple stmt, enum tree_code code, tree lhs, tree rhs)
2626 gimple_cond_set_code (stmt, code);
2627 gimple_cond_set_lhs (stmt, lhs);
2628 gimple_cond_set_rhs (stmt, rhs);
2631 /* Return the LABEL_DECL node used by GIMPLE_LABEL statement GS. */
2634 gimple_label_label (const_gimple gs)
2636 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2637 return gimple_op (gs, 0);
2641 /* Set LABEL to be the LABEL_DECL node used by GIMPLE_LABEL statement
2645 gimple_label_set_label (gimple gs, tree label)
2647 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2648 gimple_set_op (gs, 0, label);
2652 /* Return the destination of the unconditional jump GS. */
2655 gimple_goto_dest (const_gimple gs)
2657 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2658 return gimple_op (gs, 0);
2662 /* Set DEST to be the destination of the unconditonal jump GS. */
2665 gimple_goto_set_dest (gimple gs, tree dest)
2667 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2668 gimple_set_op (gs, 0, dest);
2672 /* Return the variables declared in the GIMPLE_BIND statement GS. */
2675 gimple_bind_vars (const_gimple gs)
2677 GIMPLE_CHECK (gs, GIMPLE_BIND);
2678 return gs->gimple_bind.vars;
2682 /* Set VARS to be the set of variables declared in the GIMPLE_BIND
2686 gimple_bind_set_vars (gimple gs, tree vars)
2688 GIMPLE_CHECK (gs, GIMPLE_BIND);
2689 gs->gimple_bind.vars = vars;
2693 /* Append VARS to the set of variables declared in the GIMPLE_BIND
2697 gimple_bind_append_vars (gimple gs, tree vars)
2699 GIMPLE_CHECK (gs, GIMPLE_BIND);
2700 gs->gimple_bind.vars = chainon (gs->gimple_bind.vars, vars);
2704 /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS. */
2706 static inline gimple_seq
2707 gimple_bind_body (gimple gs)
2709 GIMPLE_CHECK (gs, GIMPLE_BIND);
2710 return gs->gimple_bind.body;
2714 /* Set SEQ to be the GIMPLE sequence contained in the GIMPLE_BIND
2718 gimple_bind_set_body (gimple gs, gimple_seq seq)
2720 GIMPLE_CHECK (gs, GIMPLE_BIND);
2721 gs->gimple_bind.body = seq;
2725 /* Append a statement to the end of a GIMPLE_BIND's body. */
2728 gimple_bind_add_stmt (gimple gs, gimple stmt)
2730 GIMPLE_CHECK (gs, GIMPLE_BIND);
2731 gimple_seq_add_stmt (&gs->gimple_bind.body, stmt);
2735 /* Append a sequence of statements to the end of a GIMPLE_BIND's body. */
2738 gimple_bind_add_seq (gimple gs, gimple_seq seq)
2740 GIMPLE_CHECK (gs, GIMPLE_BIND);
2741 gimple_seq_add_seq (&gs->gimple_bind.body, seq);
2745 /* Return the TREE_BLOCK node associated with GIMPLE_BIND statement
2746 GS. This is analogous to the BIND_EXPR_BLOCK field in trees. */
2749 gimple_bind_block (const_gimple gs)
2751 GIMPLE_CHECK (gs, GIMPLE_BIND);
2752 return gs->gimple_bind.block;
2756 /* Set BLOCK to be the TREE_BLOCK node associated with GIMPLE_BIND
2760 gimple_bind_set_block (gimple gs, tree block)
2762 GIMPLE_CHECK (gs, GIMPLE_BIND);
2763 gcc_gimple_checking_assert (block == NULL_TREE
2764 || TREE_CODE (block) == BLOCK);
2765 gs->gimple_bind.block = block;
2769 /* Return the number of input operands for GIMPLE_ASM GS. */
2771 static inline unsigned
2772 gimple_asm_ninputs (const_gimple gs)
2774 GIMPLE_CHECK (gs, GIMPLE_ASM);
2775 return gs->gimple_asm.ni;
2779 /* Return the number of output operands for GIMPLE_ASM GS. */
2781 static inline unsigned
2782 gimple_asm_noutputs (const_gimple gs)
2784 GIMPLE_CHECK (gs, GIMPLE_ASM);
2785 return gs->gimple_asm.no;
2789 /* Return the number of clobber operands for GIMPLE_ASM GS. */
2791 static inline unsigned
2792 gimple_asm_nclobbers (const_gimple gs)
2794 GIMPLE_CHECK (gs, GIMPLE_ASM);
2795 return gs->gimple_asm.nc;
2798 /* Return the number of label operands for GIMPLE_ASM GS. */
2800 static inline unsigned
2801 gimple_asm_nlabels (const_gimple gs)
2803 GIMPLE_CHECK (gs, GIMPLE_ASM);
2804 return gs->gimple_asm.nl;
2807 /* Return input operand INDEX of GIMPLE_ASM GS. */
2810 gimple_asm_input_op (const_gimple gs, unsigned index)
2812 GIMPLE_CHECK (gs, GIMPLE_ASM);
2813 gcc_gimple_checking_assert (index <= gs->gimple_asm.ni);
2814 return gimple_op (gs, index);
2817 /* Return a pointer to input operand INDEX of GIMPLE_ASM GS. */
2819 static inline tree *
2820 gimple_asm_input_op_ptr (const_gimple gs, unsigned index)
2822 GIMPLE_CHECK (gs, GIMPLE_ASM);
2823 gcc_gimple_checking_assert (index <= gs->gimple_asm.ni);
2824 return gimple_op_ptr (gs, index);
2828 /* Set IN_OP to be input operand INDEX in GIMPLE_ASM GS. */
2831 gimple_asm_set_input_op (gimple gs, unsigned index, tree in_op)
2833 GIMPLE_CHECK (gs, GIMPLE_ASM);
2834 gcc_gimple_checking_assert (index <= gs->gimple_asm.ni
2835 && TREE_CODE (in_op) == TREE_LIST);
2836 gimple_set_op (gs, index, in_op);
2840 /* Return output operand INDEX of GIMPLE_ASM GS. */
2843 gimple_asm_output_op (const_gimple gs, unsigned index)
2845 GIMPLE_CHECK (gs, GIMPLE_ASM);
2846 gcc_gimple_checking_assert (index <= gs->gimple_asm.no);
2847 return gimple_op (gs, index + gs->gimple_asm.ni);
2850 /* Return a pointer to output operand INDEX of GIMPLE_ASM GS. */
2852 static inline tree *
2853 gimple_asm_output_op_ptr (const_gimple gs, unsigned index)
2855 GIMPLE_CHECK (gs, GIMPLE_ASM);
2856 gcc_gimple_checking_assert (index <= gs->gimple_asm.no);
2857 return gimple_op_ptr (gs, index + gs->gimple_asm.ni);
2861 /* Set OUT_OP to be output operand INDEX in GIMPLE_ASM GS. */
2864 gimple_asm_set_output_op (gimple gs, unsigned index, tree out_op)
2866 GIMPLE_CHECK (gs, GIMPLE_ASM);
2867 gcc_gimple_checking_assert (index <= gs->gimple_asm.no
2868 && TREE_CODE (out_op) == TREE_LIST);
2869 gimple_set_op (gs, index + gs->gimple_asm.ni, out_op);
2873 /* Return clobber operand INDEX of GIMPLE_ASM GS. */
2876 gimple_asm_clobber_op (const_gimple gs, unsigned index)
2878 GIMPLE_CHECK (gs, GIMPLE_ASM);
2879 gcc_gimple_checking_assert (index <= gs->gimple_asm.nc);
2880 return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no);
2884 /* Set CLOBBER_OP to be clobber operand INDEX in GIMPLE_ASM GS. */
2887 gimple_asm_set_clobber_op (gimple gs, unsigned index, tree clobber_op)
2889 GIMPLE_CHECK (gs, GIMPLE_ASM);
2890 gcc_gimple_checking_assert (index <= gs->gimple_asm.nc
2891 && TREE_CODE (clobber_op) == TREE_LIST);
2892 gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no, clobber_op);
2895 /* Return label operand INDEX of GIMPLE_ASM GS. */
2898 gimple_asm_label_op (const_gimple gs, unsigned index)
2900 GIMPLE_CHECK (gs, GIMPLE_ASM);
2901 gcc_gimple_checking_assert (index <= gs->gimple_asm.nl);
2902 return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.nc);
2905 /* Set LABEL_OP to be label operand INDEX in GIMPLE_ASM GS. */
2908 gimple_asm_set_label_op (gimple gs, unsigned index, tree label_op)
2910 GIMPLE_CHECK (gs, GIMPLE_ASM);
2911 gcc_gimple_checking_assert (index <= gs->gimple_asm.nl
2912 && TREE_CODE (label_op) == TREE_LIST);
2913 gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.nc, label_op);
2916 /* Return the string representing the assembly instruction in
2919 static inline const char *
2920 gimple_asm_string (const_gimple gs)
2922 GIMPLE_CHECK (gs, GIMPLE_ASM);
2923 return gs->gimple_asm.string;
2927 /* Return true if GS is an asm statement marked volatile. */
2930 gimple_asm_volatile_p (const_gimple gs)
2932 GIMPLE_CHECK (gs, GIMPLE_ASM);
2933 return (gs->gsbase.subcode & GF_ASM_VOLATILE) != 0;
2937 /* If VOLATLE_P is true, mark asm statement GS as volatile. */
2940 gimple_asm_set_volatile (gimple gs, bool volatile_p)
2942 GIMPLE_CHECK (gs, GIMPLE_ASM);
2944 gs->gsbase.subcode |= GF_ASM_VOLATILE;
2946 gs->gsbase.subcode &= ~GF_ASM_VOLATILE;
2950 /* If INPUT_P is true, mark asm GS as an ASM_INPUT. */
2953 gimple_asm_set_input (gimple gs, bool input_p)
2955 GIMPLE_CHECK (gs, GIMPLE_ASM);
2957 gs->gsbase.subcode |= GF_ASM_INPUT;
2959 gs->gsbase.subcode &= ~GF_ASM_INPUT;
2963 /* Return true if asm GS is an ASM_INPUT. */
2966 gimple_asm_input_p (const_gimple gs)
2968 GIMPLE_CHECK (gs, GIMPLE_ASM);
2969 return (gs->gsbase.subcode & GF_ASM_INPUT) != 0;
2973 /* Return the types handled by GIMPLE_CATCH statement GS. */
2976 gimple_catch_types (const_gimple gs)
2978 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2979 return gs->gimple_catch.types;
2983 /* Return a pointer to the types handled by GIMPLE_CATCH statement GS. */
2985 static inline tree *
2986 gimple_catch_types_ptr (gimple gs)
2988 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2989 return &gs->gimple_catch.types;
2993 /* Return the GIMPLE sequence representing the body of the handler of
2994 GIMPLE_CATCH statement GS. */
2996 static inline gimple_seq
2997 gimple_catch_handler (gimple gs)
2999 GIMPLE_CHECK (gs, GIMPLE_CATCH);
3000 return gs->gimple_catch.handler;
3004 /* Return a pointer to the GIMPLE sequence representing the body of
3005 the handler of GIMPLE_CATCH statement GS. */
3007 static inline gimple_seq *
3008 gimple_catch_handler_ptr (gimple gs)
3010 GIMPLE_CHECK (gs, GIMPLE_CATCH);
3011 return &gs->gimple_catch.handler;
3015 /* Set T to be the set of types handled by GIMPLE_CATCH GS. */
3018 gimple_catch_set_types (gimple gs, tree t)
3020 GIMPLE_CHECK (gs, GIMPLE_CATCH);
3021 gs->gimple_catch.types = t;
3025 /* Set HANDLER to be the body of GIMPLE_CATCH GS. */
3028 gimple_catch_set_handler (gimple gs, gimple_seq handler)
3030 GIMPLE_CHECK (gs, GIMPLE_CATCH);
3031 gs->gimple_catch.handler = handler;
3035 /* Return the types handled by GIMPLE_EH_FILTER statement GS. */
3038 gimple_eh_filter_types (const_gimple gs)
3040 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
3041 return gs->gimple_eh_filter.types;
3045 /* Return a pointer to the types handled by GIMPLE_EH_FILTER statement
3048 static inline tree *
3049 gimple_eh_filter_types_ptr (gimple gs)
3051 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
3052 return &gs->gimple_eh_filter.types;
3056 /* Return the sequence of statement to execute when GIMPLE_EH_FILTER
3059 static inline gimple_seq
3060 gimple_eh_filter_failure (gimple gs)
3062 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
3063 return gs->gimple_eh_filter.failure;
3067 /* Set TYPES to be the set of types handled by GIMPLE_EH_FILTER GS. */
3070 gimple_eh_filter_set_types (gimple gs, tree types)
3072 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
3073 gs->gimple_eh_filter.types = types;
3077 /* Set FAILURE to be the sequence of statements to execute on failure
3078 for GIMPLE_EH_FILTER GS. */
3081 gimple_eh_filter_set_failure (gimple gs, gimple_seq failure)
3083 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
3084 gs->gimple_eh_filter.failure = failure;
3087 /* Get the function decl to be called by the MUST_NOT_THROW region. */
3090 gimple_eh_must_not_throw_fndecl (gimple gs)
3092 GIMPLE_CHECK (gs, GIMPLE_EH_MUST_NOT_THROW);
3093 return gs->gimple_eh_mnt.fndecl;
3096 /* Set the function decl to be called by GS to DECL. */
3099 gimple_eh_must_not_throw_set_fndecl (gimple gs, tree decl)
3101 GIMPLE_CHECK (gs, GIMPLE_EH_MUST_NOT_THROW);
3102 gs->gimple_eh_mnt.fndecl = decl;
3106 /* GIMPLE_TRY accessors. */
3108 /* Return the kind of try block represented by GIMPLE_TRY GS. This is
3109 either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY. */
3111 static inline enum gimple_try_flags
3112 gimple_try_kind (const_gimple gs)
3114 GIMPLE_CHECK (gs, GIMPLE_TRY);
3115 return (enum gimple_try_flags) (gs->gsbase.subcode & GIMPLE_TRY_KIND);
3119 /* Set the kind of try block represented by GIMPLE_TRY GS. */
3122 gimple_try_set_kind (gimple gs, enum gimple_try_flags kind)
3124 GIMPLE_CHECK (gs, GIMPLE_TRY);
3125 gcc_gimple_checking_assert (kind == GIMPLE_TRY_CATCH
3126 || kind == GIMPLE_TRY_FINALLY);
3127 if (gimple_try_kind (gs) != kind)
3128 gs->gsbase.subcode = (unsigned int) kind;
3132 /* Return the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
3135 gimple_try_catch_is_cleanup (const_gimple gs)
3137 gcc_gimple_checking_assert (gimple_try_kind (gs) == GIMPLE_TRY_CATCH);
3138 return (gs->gsbase.subcode & GIMPLE_TRY_CATCH_IS_CLEANUP) != 0;
3142 /* Return the sequence of statements used as the body for GIMPLE_TRY GS. */
3144 static inline gimple_seq
3145 gimple_try_eval (gimple gs)
3147 GIMPLE_CHECK (gs, GIMPLE_TRY);
3148 return gs->gimple_try.eval;
3152 /* Return the sequence of statements used as the cleanup body for
3155 static inline gimple_seq
3156 gimple_try_cleanup (gimple gs)
3158 GIMPLE_CHECK (gs, GIMPLE_TRY);
3159 return gs->gimple_try.cleanup;
3163 /* Set the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
3166 gimple_try_set_catch_is_cleanup (gimple g, bool catch_is_cleanup)
3168 gcc_gimple_checking_assert (gimple_try_kind (g) == GIMPLE_TRY_CATCH);
3169 if (catch_is_cleanup)
3170 g->gsbase.subcode |= GIMPLE_TRY_CATCH_IS_CLEANUP;
3172 g->gsbase.subcode &= ~GIMPLE_TRY_CATCH_IS_CLEANUP;
3176 /* Set EVAL to be the sequence of statements to use as the body for
3180 gimple_try_set_eval (gimple gs, gimple_seq eval)
3182 GIMPLE_CHECK (gs, GIMPLE_TRY);
3183 gs->gimple_try.eval = eval;
3187 /* Set CLEANUP to be the sequence of statements to use as the cleanup
3188 body for GIMPLE_TRY GS. */
3191 gimple_try_set_cleanup (gimple gs, gimple_seq cleanup)
3193 GIMPLE_CHECK (gs, GIMPLE_TRY);
3194 gs->gimple_try.cleanup = cleanup;
3198 /* Return the cleanup sequence for cleanup statement GS. */
3200 static inline gimple_seq
3201 gimple_wce_cleanup (gimple gs)
3203 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3204 return gs->gimple_wce.cleanup;
3208 /* Set CLEANUP to be the cleanup sequence for GS. */
3211 gimple_wce_set_cleanup (gimple gs, gimple_seq cleanup)
3213 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3214 gs->gimple_wce.cleanup = cleanup;
3218 /* Return the CLEANUP_EH_ONLY flag for a WCE tuple. */
3221 gimple_wce_cleanup_eh_only (const_gimple gs)
3223 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3224 return gs->gsbase.subcode != 0;
3228 /* Set the CLEANUP_EH_ONLY flag for a WCE tuple. */
3231 gimple_wce_set_cleanup_eh_only (gimple gs, bool eh_only_p)
3233 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3234 gs->gsbase.subcode = (unsigned int) eh_only_p;
3238 /* Return the maximum number of arguments supported by GIMPLE_PHI GS. */
3240 static inline unsigned
3241 gimple_phi_capacity (const_gimple gs)
3243 GIMPLE_CHECK (gs, GIMPLE_PHI);
3244 return gs->gimple_phi.capacity;
3248 /* Return the number of arguments in GIMPLE_PHI GS. This must always
3249 be exactly the number of incoming edges for the basic block holding
3252 static inline unsigned
3253 gimple_phi_num_args (const_gimple gs)
3255 GIMPLE_CHECK (gs, GIMPLE_PHI);
3256 return gs->gimple_phi.nargs;
3260 /* Return the SSA name created by GIMPLE_PHI GS. */
3263 gimple_phi_result (const_gimple gs)
3265 GIMPLE_CHECK (gs, GIMPLE_PHI);
3266 return gs->gimple_phi.result;
3269 /* Return a pointer to the SSA name created by GIMPLE_PHI GS. */
3271 static inline tree *
3272 gimple_phi_result_ptr (gimple gs)
3274 GIMPLE_CHECK (gs, GIMPLE_PHI);
3275 return &gs->gimple_phi.result;
3278 /* Set RESULT to be the SSA name created by GIMPLE_PHI GS. */
3281 gimple_phi_set_result (gimple gs, tree result)
3283 GIMPLE_CHECK (gs, GIMPLE_PHI);
3284 gs->gimple_phi.result = result;
3288 /* Return the PHI argument corresponding to incoming edge INDEX for
3291 static inline struct phi_arg_d *
3292 gimple_phi_arg (gimple gs, unsigned index)
3294 GIMPLE_CHECK (gs, GIMPLE_PHI);
3295 gcc_gimple_checking_assert (index <= gs->gimple_phi.capacity);
3296 return &(gs->gimple_phi.args[index]);
3299 /* Set PHIARG to be the argument corresponding to incoming edge INDEX
3300 for GIMPLE_PHI GS. */
3303 gimple_phi_set_arg (gimple gs, unsigned index, struct phi_arg_d * phiarg)
3305 GIMPLE_CHECK (gs, GIMPLE_PHI);
3306 gcc_gimple_checking_assert (index <= gs->gimple_phi.nargs);
3307 gs->gimple_phi.args[index] = *phiarg;
3310 /* Return the region number for GIMPLE_RESX GS. */
3313 gimple_resx_region (const_gimple gs)
3315 GIMPLE_CHECK (gs, GIMPLE_RESX);
3316 return gs->gimple_eh_ctrl.region;
3319 /* Set REGION to be the region number for GIMPLE_RESX GS. */
3322 gimple_resx_set_region (gimple gs, int region)
3324 GIMPLE_CHECK (gs, GIMPLE_RESX);
3325 gs->gimple_eh_ctrl.region = region;
3328 /* Return the region number for GIMPLE_EH_DISPATCH GS. */
3331 gimple_eh_dispatch_region (const_gimple gs)
3333 GIMPLE_CHECK (gs, GIMPLE_EH_DISPATCH);
3334 return gs->gimple_eh_ctrl.region;
3337 /* Set REGION to be the region number for GIMPLE_EH_DISPATCH GS. */
3340 gimple_eh_dispatch_set_region (gimple gs, int region)
3342 GIMPLE_CHECK (gs, GIMPLE_EH_DISPATCH);
3343 gs->gimple_eh_ctrl.region = region;
3346 /* Return the number of labels associated with the switch statement GS. */
3348 static inline unsigned
3349 gimple_switch_num_labels (const_gimple gs)
3352 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3353 num_ops = gimple_num_ops (gs);
3354 gcc_gimple_checking_assert (num_ops > 1);
3359 /* Set NLABELS to be the number of labels for the switch statement GS. */
3362 gimple_switch_set_num_labels (gimple g, unsigned nlabels)
3364 GIMPLE_CHECK (g, GIMPLE_SWITCH);
3365 gimple_set_num_ops (g, nlabels + 1);
3369 /* Return the index variable used by the switch statement GS. */
3372 gimple_switch_index (const_gimple gs)
3374 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3375 return gimple_op (gs, 0);
3379 /* Return a pointer to the index variable for the switch statement GS. */
3381 static inline tree *
3382 gimple_switch_index_ptr (const_gimple gs)
3384 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3385 return gimple_op_ptr (gs, 0);
3389 /* Set INDEX to be the index variable for switch statement GS. */
3392 gimple_switch_set_index (gimple gs, tree index)
3394 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3395 gcc_gimple_checking_assert (SSA_VAR_P (index) || CONSTANT_CLASS_P (index));
3396 gimple_set_op (gs, 0, index);
3400 /* Return the label numbered INDEX. The default label is 0, followed by any
3401 labels in a switch statement. */
3404 gimple_switch_label (const_gimple gs, unsigned index)
3406 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3407 gcc_gimple_checking_assert (gimple_num_ops (gs) > index + 1);
3408 return gimple_op (gs, index + 1);
3411 /* Set the label number INDEX to LABEL. 0 is always the default label. */
3414 gimple_switch_set_label (gimple gs, unsigned index, tree label)
3416 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3417 gcc_gimple_checking_assert (gimple_num_ops (gs) > index + 1
3418 && (label == NULL_TREE
3419 || TREE_CODE (label) == CASE_LABEL_EXPR));
3420 gimple_set_op (gs, index + 1, label);
3423 /* Return the default label for a switch statement. */
3426 gimple_switch_default_label (const_gimple gs)
3428 return gimple_switch_label (gs, 0);
3431 /* Set the default label for a switch statement. */
3434 gimple_switch_set_default_label (gimple gs, tree label)
3436 gimple_switch_set_label (gs, 0, label);
3439 /* Return true if GS is a GIMPLE_DEBUG statement. */
3442 is_gimple_debug (const_gimple gs)
3444 return gimple_code (gs) == GIMPLE_DEBUG;
3447 /* Return true if S is a GIMPLE_DEBUG BIND statement. */
3450 gimple_debug_bind_p (const_gimple s)
3452 if (is_gimple_debug (s))
3453 return s->gsbase.subcode == GIMPLE_DEBUG_BIND;
3458 /* Return the variable bound in a GIMPLE_DEBUG bind statement. */
3461 gimple_debug_bind_get_var (gimple dbg)
3463 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3464 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3465 return gimple_op (dbg, 0);
3468 /* Return the value bound to the variable in a GIMPLE_DEBUG bind
3472 gimple_debug_bind_get_value (gimple dbg)
3474 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3475 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3476 return gimple_op (dbg, 1);
3479 /* Return a pointer to the value bound to the variable in a
3480 GIMPLE_DEBUG bind statement. */
3482 static inline tree *
3483 gimple_debug_bind_get_value_ptr (gimple dbg)
3485 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3486 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3487 return gimple_op_ptr (dbg, 1);
3490 /* Set the variable bound in a GIMPLE_DEBUG bind statement. */
3493 gimple_debug_bind_set_var (gimple dbg, tree var)
3495 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3496 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3497 gimple_set_op (dbg, 0, var);
3500 /* Set the value bound to the variable in a GIMPLE_DEBUG bind
3504 gimple_debug_bind_set_value (gimple dbg, tree value)
3506 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3507 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3508 gimple_set_op (dbg, 1, value);
3511 /* The second operand of a GIMPLE_DEBUG_BIND, when the value was
3513 #define GIMPLE_DEBUG_BIND_NOVALUE NULL_TREE /* error_mark_node */
3515 /* Remove the value bound to the variable in a GIMPLE_DEBUG bind
3519 gimple_debug_bind_reset_value (gimple dbg)
3521 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3522 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3523 gimple_set_op (dbg, 1, GIMPLE_DEBUG_BIND_NOVALUE);
3526 /* Return true if the GIMPLE_DEBUG bind statement is bound to a
3530 gimple_debug_bind_has_value_p (gimple dbg)
3532 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3533 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3534 return gimple_op (dbg, 1) != GIMPLE_DEBUG_BIND_NOVALUE;
3537 #undef GIMPLE_DEBUG_BIND_NOVALUE
3539 /* Return the body for the OMP statement GS. */
3541 static inline gimple_seq
3542 gimple_omp_body (gimple gs)
3544 return gs->omp.body;
3547 /* Set BODY to be the body for the OMP statement GS. */
3550 gimple_omp_set_body (gimple gs, gimple_seq body)
3552 gs->omp.body = body;
3556 /* Return the name associated with OMP_CRITICAL statement GS. */
3559 gimple_omp_critical_name (const_gimple gs)
3561 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3562 return gs->gimple_omp_critical.name;
3566 /* Return a pointer to the name associated with OMP critical statement GS. */
3568 static inline tree *
3569 gimple_omp_critical_name_ptr (gimple gs)
3571 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3572 return &gs->gimple_omp_critical.name;
3576 /* Set NAME to be the name associated with OMP critical statement GS. */
3579 gimple_omp_critical_set_name (gimple gs, tree name)
3581 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3582 gs->gimple_omp_critical.name = name;
3586 /* Return the clauses associated with OMP_FOR GS. */
3589 gimple_omp_for_clauses (const_gimple gs)
3591 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3592 return gs->gimple_omp_for.clauses;
3596 /* Return a pointer to the OMP_FOR GS. */
3598 static inline tree *
3599 gimple_omp_for_clauses_ptr (gimple gs)
3601 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3602 return &gs->gimple_omp_for.clauses;
3606 /* Set CLAUSES to be the list of clauses associated with OMP_FOR GS. */
3609 gimple_omp_for_set_clauses (gimple gs, tree clauses)
3611 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3612 gs->gimple_omp_for.clauses = clauses;
3616 /* Get the collapse count of OMP_FOR GS. */
3618 static inline size_t
3619 gimple_omp_for_collapse (gimple gs)
3621 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3622 return gs->gimple_omp_for.collapse;
3626 /* Return the index variable for OMP_FOR GS. */
3629 gimple_omp_for_index (const_gimple gs, size_t i)
3631 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3632 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3633 return gs->gimple_omp_for.iter[i].index;
3637 /* Return a pointer to the index variable for OMP_FOR GS. */
3639 static inline tree *
3640 gimple_omp_for_index_ptr (gimple gs, size_t i)
3642 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3643 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3644 return &gs->gimple_omp_for.iter[i].index;
3648 /* Set INDEX to be the index variable for OMP_FOR GS. */
3651 gimple_omp_for_set_index (gimple gs, size_t i, tree index)
3653 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3654 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3655 gs->gimple_omp_for.iter[i].index = index;
3659 /* Return the initial value for OMP_FOR GS. */
3662 gimple_omp_for_initial (const_gimple gs, size_t i)
3664 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3665 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3666 return gs->gimple_omp_for.iter[i].initial;
3670 /* Return a pointer to the initial value for OMP_FOR GS. */
3672 static inline tree *
3673 gimple_omp_for_initial_ptr (gimple gs, size_t i)
3675 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3676 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3677 return &gs->gimple_omp_for.iter[i].initial;
3681 /* Set INITIAL to be the initial value for OMP_FOR GS. */
3684 gimple_omp_for_set_initial (gimple gs, size_t i, tree initial)
3686 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3687 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3688 gs->gimple_omp_for.iter[i].initial = initial;
3692 /* Return the final value for OMP_FOR GS. */
3695 gimple_omp_for_final (const_gimple gs, size_t i)
3697 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3698 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3699 return gs->gimple_omp_for.iter[i].final;
3703 /* Return a pointer to the final value for OMP_FOR GS. */
3705 static inline tree *
3706 gimple_omp_for_final_ptr (gimple gs, size_t i)
3708 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3709 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3710 return &gs->gimple_omp_for.iter[i].final;
3714 /* Set FINAL to be the final value for OMP_FOR GS. */
3717 gimple_omp_for_set_final (gimple gs, size_t i, tree final)
3719 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3720 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3721 gs->gimple_omp_for.iter[i].final = final;
3725 /* Return the increment value for OMP_FOR GS. */
3728 gimple_omp_for_incr (const_gimple gs, size_t i)
3730 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3731 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3732 return gs->gimple_omp_for.iter[i].incr;
3736 /* Return a pointer to the increment value for OMP_FOR GS. */
3738 static inline tree *
3739 gimple_omp_for_incr_ptr (gimple gs, size_t i)
3741 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3742 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3743 return &gs->gimple_omp_for.iter[i].incr;
3747 /* Set INCR to be the increment value for OMP_FOR GS. */
3750 gimple_omp_for_set_incr (gimple gs, size_t i, tree incr)
3752 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3753 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3754 gs->gimple_omp_for.iter[i].incr = incr;
3758 /* Return the sequence of statements to execute before the OMP_FOR
3759 statement GS starts. */
3761 static inline gimple_seq
3762 gimple_omp_for_pre_body (gimple gs)
3764 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3765 return gs->gimple_omp_for.pre_body;
3769 /* Set PRE_BODY to be the sequence of statements to execute before the
3770 OMP_FOR statement GS starts. */
3773 gimple_omp_for_set_pre_body (gimple gs, gimple_seq pre_body)
3775 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3776 gs->gimple_omp_for.pre_body = pre_body;
3780 /* Return the clauses associated with OMP_PARALLEL GS. */
3783 gimple_omp_parallel_clauses (const_gimple gs)
3785 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3786 return gs->gimple_omp_parallel.clauses;
3790 /* Return a pointer to the clauses associated with OMP_PARALLEL GS. */
3792 static inline tree *
3793 gimple_omp_parallel_clauses_ptr (gimple gs)
3795 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3796 return &gs->gimple_omp_parallel.clauses;
3800 /* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL
3804 gimple_omp_parallel_set_clauses (gimple gs, tree clauses)
3806 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3807 gs->gimple_omp_parallel.clauses = clauses;
3811 /* Return the child function used to hold the body of OMP_PARALLEL GS. */
3814 gimple_omp_parallel_child_fn (const_gimple gs)
3816 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3817 return gs->gimple_omp_parallel.child_fn;
3820 /* Return a pointer to the child function used to hold the body of
3823 static inline tree *
3824 gimple_omp_parallel_child_fn_ptr (gimple gs)
3826 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3827 return &gs->gimple_omp_parallel.child_fn;
3831 /* Set CHILD_FN to be the child function for OMP_PARALLEL GS. */
3834 gimple_omp_parallel_set_child_fn (gimple gs, tree child_fn)
3836 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3837 gs->gimple_omp_parallel.child_fn = child_fn;
3841 /* Return the artificial argument used to send variables and values
3842 from the parent to the children threads in OMP_PARALLEL GS. */
3845 gimple_omp_parallel_data_arg (const_gimple gs)
3847 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3848 return gs->gimple_omp_parallel.data_arg;
3852 /* Return a pointer to the data argument for OMP_PARALLEL GS. */
3854 static inline tree *
3855 gimple_omp_parallel_data_arg_ptr (gimple gs)
3857 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3858 return &gs->gimple_omp_parallel.data_arg;
3862 /* Set DATA_ARG to be the data argument for OMP_PARALLEL GS. */
3865 gimple_omp_parallel_set_data_arg (gimple gs, tree data_arg)
3867 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3868 gs->gimple_omp_parallel.data_arg = data_arg;
3872 /* Return the clauses associated with OMP_TASK GS. */
3875 gimple_omp_task_clauses (const_gimple gs)
3877 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3878 return gs->gimple_omp_parallel.clauses;
3882 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3884 static inline tree *
3885 gimple_omp_task_clauses_ptr (gimple gs)
3887 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3888 return &gs->gimple_omp_parallel.clauses;
3892 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3896 gimple_omp_task_set_clauses (gimple gs, tree clauses)
3898 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3899 gs->gimple_omp_parallel.clauses = clauses;
3903 /* Return the child function used to hold the body of OMP_TASK GS. */
3906 gimple_omp_task_child_fn (const_gimple gs)
3908 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3909 return gs->gimple_omp_parallel.child_fn;
3912 /* Return a pointer to the child function used to hold the body of
3915 static inline tree *
3916 gimple_omp_task_child_fn_ptr (gimple gs)
3918 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3919 return &gs->gimple_omp_parallel.child_fn;
3923 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3926 gimple_omp_task_set_child_fn (gimple gs, tree child_fn)
3928 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3929 gs->gimple_omp_parallel.child_fn = child_fn;
3933 /* Return the artificial argument used to send variables and values
3934 from the parent to the children threads in OMP_TASK GS. */
3937 gimple_omp_task_data_arg (const_gimple gs)
3939 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3940 return gs->gimple_omp_parallel.data_arg;
3944 /* Return a pointer to the data argument for OMP_TASK GS. */
3946 static inline tree *
3947 gimple_omp_task_data_arg_ptr (gimple gs)
3949 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3950 return &gs->gimple_omp_parallel.data_arg;
3954 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3957 gimple_omp_task_set_data_arg (gimple gs, tree data_arg)
3959 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3960 gs->gimple_omp_parallel.data_arg = data_arg;
3964 /* Return the clauses associated with OMP_TASK GS. */
3967 gimple_omp_taskreg_clauses (const_gimple gs)
3969 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3970 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3971 return gs->gimple_omp_parallel.clauses;
3975 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3977 static inline tree *
3978 gimple_omp_taskreg_clauses_ptr (gimple gs)
3980 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3981 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3982 return &gs->gimple_omp_parallel.clauses;
3986 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3990 gimple_omp_taskreg_set_clauses (gimple gs, tree clauses)
3992 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3993 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3994 gs->gimple_omp_parallel.clauses = clauses;
3998 /* Return the child function used to hold the body of OMP_TASK GS. */
4001 gimple_omp_taskreg_child_fn (const_gimple gs)
4003 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4004 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4005 return gs->gimple_omp_parallel.child_fn;
4008 /* Return a pointer to the child function used to hold the body of
4011 static inline tree *
4012 gimple_omp_taskreg_child_fn_ptr (gimple gs)
4014 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4015 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4016 return &gs->gimple_omp_parallel.child_fn;
4020 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
4023 gimple_omp_taskreg_set_child_fn (gimple gs, tree child_fn)
4025 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4026 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4027 gs->gimple_omp_parallel.child_fn = child_fn;
4031 /* Return the artificial argument used to send variables and values
4032 from the parent to the children threads in OMP_TASK GS. */
4035 gimple_omp_taskreg_data_arg (const_gimple gs)
4037 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4038 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4039 return gs->gimple_omp_parallel.data_arg;
4043 /* Return a pointer to the data argument for OMP_TASK GS. */
4045 static inline tree *
4046 gimple_omp_taskreg_data_arg_ptr (gimple gs)
4048 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4049 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4050 return &gs->gimple_omp_parallel.data_arg;
4054 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
4057 gimple_omp_taskreg_set_data_arg (gimple gs, tree data_arg)
4059 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4060 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4061 gs->gimple_omp_parallel.data_arg = data_arg;
4065 /* Return the copy function used to hold the body of OMP_TASK GS. */
4068 gimple_omp_task_copy_fn (const_gimple gs)
4070 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4071 return gs->gimple_omp_task.copy_fn;
4074 /* Return a pointer to the copy function used to hold the body of
4077 static inline tree *
4078 gimple_omp_task_copy_fn_ptr (gimple gs)
4080 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4081 return &gs->gimple_omp_task.copy_fn;
4085 /* Set CHILD_FN to be the copy function for OMP_TASK GS. */
4088 gimple_omp_task_set_copy_fn (gimple gs, tree copy_fn)
4090 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4091 gs->gimple_omp_task.copy_fn = copy_fn;
4095 /* Return size of the data block in bytes in OMP_TASK GS. */
4098 gimple_omp_task_arg_size (const_gimple gs)
4100 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4101 return gs->gimple_omp_task.arg_size;
4105 /* Return a pointer to the data block size for OMP_TASK GS. */
4107 static inline tree *
4108 gimple_omp_task_arg_size_ptr (gimple gs)
4110 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4111 return &gs->gimple_omp_task.arg_size;
4115 /* Set ARG_SIZE to be the data block size for OMP_TASK GS. */
4118 gimple_omp_task_set_arg_size (gimple gs, tree arg_size)
4120 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4121 gs->gimple_omp_task.arg_size = arg_size;
4125 /* Return align of the data block in bytes in OMP_TASK GS. */
4128 gimple_omp_task_arg_align (const_gimple gs)
4130 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4131 return gs->gimple_omp_task.arg_align;
4135 /* Return a pointer to the data block align for OMP_TASK GS. */
4137 static inline tree *
4138 gimple_omp_task_arg_align_ptr (gimple gs)
4140 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4141 return &gs->gimple_omp_task.arg_align;
4145 /* Set ARG_SIZE to be the data block align for OMP_TASK GS. */
4148 gimple_omp_task_set_arg_align (gimple gs, tree arg_align)
4150 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4151 gs->gimple_omp_task.arg_align = arg_align;
4155 /* Return the clauses associated with OMP_SINGLE GS. */
4158 gimple_omp_single_clauses (const_gimple gs)
4160 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
4161 return gs->gimple_omp_single.clauses;
4165 /* Return a pointer to the clauses associated with OMP_SINGLE GS. */
4167 static inline tree *
4168 gimple_omp_single_clauses_ptr (gimple gs)
4170 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
4171 return &gs->gimple_omp_single.clauses;
4175 /* Set CLAUSES to be the clauses associated with OMP_SINGLE GS. */
4178 gimple_omp_single_set_clauses (gimple gs, tree clauses)
4180 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
4181 gs->gimple_omp_single.clauses = clauses;
4185 /* Return the clauses associated with OMP_SECTIONS GS. */
4188 gimple_omp_sections_clauses (const_gimple gs)
4190 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4191 return gs->gimple_omp_sections.clauses;
4195 /* Return a pointer to the clauses associated with OMP_SECTIONS GS. */
4197 static inline tree *
4198 gimple_omp_sections_clauses_ptr (gimple gs)
4200 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4201 return &gs->gimple_omp_sections.clauses;
4205 /* Set CLAUSES to be the set of clauses associated with OMP_SECTIONS
4209 gimple_omp_sections_set_clauses (gimple gs, tree clauses)
4211 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4212 gs->gimple_omp_sections.clauses = clauses;
4216 /* Return the control variable associated with the GIMPLE_OMP_SECTIONS
4220 gimple_omp_sections_control (const_gimple gs)
4222 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4223 return gs->gimple_omp_sections.control;
4227 /* Return a pointer to the clauses associated with the GIMPLE_OMP_SECTIONS
4230 static inline tree *
4231 gimple_omp_sections_control_ptr (gimple gs)
4233 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4234 return &gs->gimple_omp_sections.control;
4238 /* Set CONTROL to be the set of clauses associated with the
4239 GIMPLE_OMP_SECTIONS in GS. */
4242 gimple_omp_sections_set_control (gimple gs, tree control)
4244 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4245 gs->gimple_omp_sections.control = control;
4249 /* Set COND to be the condition code for OMP_FOR GS. */
4252 gimple_omp_for_set_cond (gimple gs, size_t i, enum tree_code cond)
4254 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4255 gcc_gimple_checking_assert (TREE_CODE_CLASS (cond) == tcc_comparison
4256 && i < gs->gimple_omp_for.collapse);
4257 gs->gimple_omp_for.iter[i].cond = cond;
4261 /* Return the condition code associated with OMP_FOR GS. */
4263 static inline enum tree_code
4264 gimple_omp_for_cond (const_gimple gs, size_t i)
4266 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4267 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4268 return gs->gimple_omp_for.iter[i].cond;
4272 /* Set the value being stored in an atomic store. */
4275 gimple_omp_atomic_store_set_val (gimple g, tree val)
4277 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4278 g->gimple_omp_atomic_store.val = val;
4282 /* Return the value being stored in an atomic store. */
4285 gimple_omp_atomic_store_val (const_gimple g)
4287 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4288 return g->gimple_omp_atomic_store.val;
4292 /* Return a pointer to the value being stored in an atomic store. */
4294 static inline tree *
4295 gimple_omp_atomic_store_val_ptr (gimple g)
4297 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4298 return &g->gimple_omp_atomic_store.val;
4302 /* Set the LHS of an atomic load. */
4305 gimple_omp_atomic_load_set_lhs (gimple g, tree lhs)
4307 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4308 g->gimple_omp_atomic_load.lhs = lhs;
4312 /* Get the LHS of an atomic load. */
4315 gimple_omp_atomic_load_lhs (const_gimple g)
4317 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4318 return g->gimple_omp_atomic_load.lhs;
4322 /* Return a pointer to the LHS of an atomic load. */
4324 static inline tree *
4325 gimple_omp_atomic_load_lhs_ptr (gimple g)
4327 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4328 return &g->gimple_omp_atomic_load.lhs;
4332 /* Set the RHS of an atomic load. */
4335 gimple_omp_atomic_load_set_rhs (gimple g, tree rhs)
4337 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4338 g->gimple_omp_atomic_load.rhs = rhs;
4342 /* Get the RHS of an atomic load. */
4345 gimple_omp_atomic_load_rhs (const_gimple g)
4347 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4348 return g->gimple_omp_atomic_load.rhs;
4352 /* Return a pointer to the RHS of an atomic load. */
4354 static inline tree *
4355 gimple_omp_atomic_load_rhs_ptr (gimple g)
4357 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4358 return &g->gimple_omp_atomic_load.rhs;
4362 /* Get the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4365 gimple_omp_continue_control_def (const_gimple g)
4367 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4368 return g->gimple_omp_continue.control_def;
4371 /* The same as above, but return the address. */
4373 static inline tree *
4374 gimple_omp_continue_control_def_ptr (gimple g)
4376 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4377 return &g->gimple_omp_continue.control_def;
4380 /* Set the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4383 gimple_omp_continue_set_control_def (gimple g, tree def)
4385 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4386 g->gimple_omp_continue.control_def = def;
4390 /* Get the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4393 gimple_omp_continue_control_use (const_gimple g)
4395 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4396 return g->gimple_omp_continue.control_use;
4400 /* The same as above, but return the address. */
4402 static inline tree *
4403 gimple_omp_continue_control_use_ptr (gimple g)
4405 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4406 return &g->gimple_omp_continue.control_use;
4410 /* Set the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4413 gimple_omp_continue_set_control_use (gimple g, tree use)
4415 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4416 g->gimple_omp_continue.control_use = use;
4420 /* Return a pointer to the return value for GIMPLE_RETURN GS. */
4422 static inline tree *
4423 gimple_return_retval_ptr (const_gimple gs)
4425 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4426 return gimple_op_ptr (gs, 0);
4429 /* Return the return value for GIMPLE_RETURN GS. */
4432 gimple_return_retval (const_gimple gs)
4434 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4435 return gimple_op (gs, 0);
4439 /* Set RETVAL to be the return value for GIMPLE_RETURN GS. */
4442 gimple_return_set_retval (gimple gs, tree retval)
4444 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4445 gimple_set_op (gs, 0, retval);
4449 /* Returns true when the gimple statment STMT is any of the OpenMP types. */
4451 #define CASE_GIMPLE_OMP \
4452 case GIMPLE_OMP_PARALLEL: \
4453 case GIMPLE_OMP_TASK: \
4454 case GIMPLE_OMP_FOR: \
4455 case GIMPLE_OMP_SECTIONS: \
4456 case GIMPLE_OMP_SECTIONS_SWITCH: \
4457 case GIMPLE_OMP_SINGLE: \
4458 case GIMPLE_OMP_SECTION: \
4459 case GIMPLE_OMP_MASTER: \
4460 case GIMPLE_OMP_ORDERED: \
4461 case GIMPLE_OMP_CRITICAL: \
4462 case GIMPLE_OMP_RETURN: \
4463 case GIMPLE_OMP_ATOMIC_LOAD: \
4464 case GIMPLE_OMP_ATOMIC_STORE: \
4465 case GIMPLE_OMP_CONTINUE
4468 is_gimple_omp (const_gimple stmt)
4470 switch (gimple_code (stmt))
4480 /* Returns TRUE if statement G is a GIMPLE_NOP. */
4483 gimple_nop_p (const_gimple g)
4485 return gimple_code (g) == GIMPLE_NOP;
4489 /* Return true if GS is a GIMPLE_RESX. */
4492 is_gimple_resx (const_gimple gs)
4494 return gimple_code (gs) == GIMPLE_RESX;
4497 /* Return the predictor of GIMPLE_PREDICT statement GS. */
4499 static inline enum br_predictor
4500 gimple_predict_predictor (gimple gs)
4502 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4503 return (enum br_predictor) (gs->gsbase.subcode & ~GF_PREDICT_TAKEN);
4507 /* Set the predictor of GIMPLE_PREDICT statement GS to PREDICT. */
4510 gimple_predict_set_predictor (gimple gs, enum br_predictor predictor)
4512 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4513 gs->gsbase.subcode = (gs->gsbase.subcode & GF_PREDICT_TAKEN)
4514 | (unsigned) predictor;
4518 /* Return the outcome of GIMPLE_PREDICT statement GS. */
4520 static inline enum prediction
4521 gimple_predict_outcome (gimple gs)
4523 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4524 return (gs->gsbase.subcode & GF_PREDICT_TAKEN) ? TAKEN : NOT_TAKEN;
4528 /* Set the outcome of GIMPLE_PREDICT statement GS to OUTCOME. */
4531 gimple_predict_set_outcome (gimple gs, enum prediction outcome)
4533 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4534 if (outcome == TAKEN)
4535 gs->gsbase.subcode |= GF_PREDICT_TAKEN;
4537 gs->gsbase.subcode &= ~GF_PREDICT_TAKEN;
4541 /* Return the type of the main expression computed by STMT. Return
4542 void_type_node if the statement computes nothing. */
4545 gimple_expr_type (const_gimple stmt)
4547 enum gimple_code code = gimple_code (stmt);
4549 if (code == GIMPLE_ASSIGN || code == GIMPLE_CALL)
4552 /* In general we want to pass out a type that can be substituted
4553 for both the RHS and the LHS types if there is a possibly
4554 useless conversion involved. That means returning the
4555 original RHS type as far as we can reconstruct it. */
4556 if (code == GIMPLE_CALL)
4557 type = gimple_call_return_type (stmt);
4559 switch (gimple_assign_rhs_code (stmt))
4561 case POINTER_PLUS_EXPR:
4562 type = TREE_TYPE (gimple_assign_rhs1 (stmt));
4566 /* As fallback use the type of the LHS. */
4567 type = TREE_TYPE (gimple_get_lhs (stmt));
4572 else if (code == GIMPLE_COND)
4573 return boolean_type_node;
4575 return void_type_node;
4579 /* Return a new iterator pointing to GIMPLE_SEQ's first statement. */
4581 static inline gimple_stmt_iterator
4582 gsi_start (gimple_seq seq)
4584 gimple_stmt_iterator i;
4586 i.ptr = gimple_seq_first (seq);
4588 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4594 /* Return a new iterator pointing to the first statement in basic block BB. */
4596 static inline gimple_stmt_iterator
4597 gsi_start_bb (basic_block bb)
4599 gimple_stmt_iterator i;
4603 i.ptr = gimple_seq_first (seq);
4611 /* Return a new iterator initially pointing to GIMPLE_SEQ's last statement. */
4613 static inline gimple_stmt_iterator
4614 gsi_last (gimple_seq seq)
4616 gimple_stmt_iterator i;
4618 i.ptr = gimple_seq_last (seq);
4620 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4626 /* Return a new iterator pointing to the last statement in basic block BB. */
4628 static inline gimple_stmt_iterator
4629 gsi_last_bb (basic_block bb)
4631 gimple_stmt_iterator i;
4635 i.ptr = gimple_seq_last (seq);
4643 /* Return true if I is at the end of its sequence. */
4646 gsi_end_p (gimple_stmt_iterator i)
4648 return i.ptr == NULL;
4652 /* Return true if I is one statement before the end of its sequence. */
4655 gsi_one_before_end_p (gimple_stmt_iterator i)
4657 return i.ptr != NULL && i.ptr->next == NULL;
4661 /* Advance the iterator to the next gimple statement. */
4664 gsi_next (gimple_stmt_iterator *i)
4666 i->ptr = i->ptr->next;
4669 /* Advance the iterator to the previous gimple statement. */
4672 gsi_prev (gimple_stmt_iterator *i)
4674 i->ptr = i->ptr->prev;
4677 /* Return the current stmt. */
4679 static inline gimple
4680 gsi_stmt (gimple_stmt_iterator i)
4685 /* Return a block statement iterator that points to the first non-label
4686 statement in block BB. */
4688 static inline gimple_stmt_iterator
4689 gsi_after_labels (basic_block bb)
4691 gimple_stmt_iterator gsi = gsi_start_bb (bb);
4693 while (!gsi_end_p (gsi) && gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL)
4699 /* Advance the iterator to the next non-debug gimple statement. */
4702 gsi_next_nondebug (gimple_stmt_iterator *i)
4708 while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
4711 /* Advance the iterator to the next non-debug gimple statement. */
4714 gsi_prev_nondebug (gimple_stmt_iterator *i)
4720 while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
4723 /* Return a new iterator pointing to the first non-debug statement in
4726 static inline gimple_stmt_iterator
4727 gsi_start_nondebug_bb (basic_block bb)
4729 gimple_stmt_iterator i = gsi_start_bb (bb);
4731 if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
4732 gsi_next_nondebug (&i);
4737 /* Return a new iterator pointing to the last non-debug statement in
4740 static inline gimple_stmt_iterator
4741 gsi_last_nondebug_bb (basic_block bb)
4743 gimple_stmt_iterator i = gsi_last_bb (bb);
4745 if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
4746 gsi_prev_nondebug (&i);
4751 /* Return a pointer to the current stmt.
4753 NOTE: You may want to use gsi_replace on the iterator itself,
4754 as this performs additional bookkeeping that will not be done
4755 if you simply assign through a pointer returned by gsi_stmt_ptr. */
4757 static inline gimple *
4758 gsi_stmt_ptr (gimple_stmt_iterator *i)
4760 return &i->ptr->stmt;
4764 /* Return the basic block associated with this iterator. */
4766 static inline basic_block
4767 gsi_bb (gimple_stmt_iterator i)
4773 /* Return the sequence associated with this iterator. */
4775 static inline gimple_seq
4776 gsi_seq (gimple_stmt_iterator i)
4782 enum gsi_iterator_update
4784 GSI_NEW_STMT, /* Only valid when single statement is added, move
4786 GSI_SAME_STMT, /* Leave the iterator at the same statement. */
4787 GSI_CONTINUE_LINKING /* Move iterator to whatever position is suitable
4788 for linking other statements in the same
4792 /* In gimple-iterator.c */
4793 gimple_stmt_iterator gsi_start_phis (basic_block);
4794 gimple_seq gsi_split_seq_after (gimple_stmt_iterator);
4795 gimple_seq gsi_split_seq_before (gimple_stmt_iterator *);
4796 void gsi_replace (gimple_stmt_iterator *, gimple, bool);
4797 void gsi_insert_before (gimple_stmt_iterator *, gimple,
4798 enum gsi_iterator_update);
4799 void gsi_insert_before_without_update (gimple_stmt_iterator *, gimple,
4800 enum gsi_iterator_update);
4801 void gsi_insert_seq_before (gimple_stmt_iterator *, gimple_seq,
4802 enum gsi_iterator_update);
4803 void gsi_insert_seq_before_without_update (gimple_stmt_iterator *, gimple_seq,
4804 enum gsi_iterator_update);
4805 void gsi_insert_after (gimple_stmt_iterator *, gimple,
4806 enum gsi_iterator_update);
4807 void gsi_insert_after_without_update (gimple_stmt_iterator *, gimple,
4808 enum gsi_iterator_update);
4809 void gsi_insert_seq_after (gimple_stmt_iterator *, gimple_seq,
4810 enum gsi_iterator_update);
4811 void gsi_insert_seq_after_without_update (gimple_stmt_iterator *, gimple_seq,
4812 enum gsi_iterator_update);
4813 void gsi_remove (gimple_stmt_iterator *, bool);
4814 gimple_stmt_iterator gsi_for_stmt (gimple);
4815 void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *);
4816 void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *);
4817 void gsi_move_to_bb_end (gimple_stmt_iterator *, struct basic_block_def *);
4818 void gsi_insert_on_edge (edge, gimple);
4819 void gsi_insert_seq_on_edge (edge, gimple_seq);
4820 basic_block gsi_insert_on_edge_immediate (edge, gimple);
4821 basic_block gsi_insert_seq_on_edge_immediate (edge, gimple_seq);
4822 void gsi_commit_one_edge_insert (edge, basic_block *);
4823 void gsi_commit_edge_inserts (void);
4824 gimple gimple_call_copy_skip_args (gimple, bitmap);
4827 /* Convenience routines to walk all statements of a gimple function.
4828 Note that this is useful exclusively before the code is converted
4829 into SSA form. Once the program is in SSA form, the standard
4830 operand interface should be used to analyze/modify statements. */
4831 struct walk_stmt_info
4833 /* Points to the current statement being walked. */
4834 gimple_stmt_iterator gsi;
4836 /* Additional data that the callback functions may want to carry
4837 through the recursion. */
4840 /* Pointer map used to mark visited tree nodes when calling
4841 walk_tree on each operand. If set to NULL, duplicate tree nodes
4842 will be visited more than once. */
4843 struct pointer_set_t *pset;
4845 /* Indicates whether the operand being examined may be replaced
4846 with something that matches is_gimple_val (if true) or something
4847 slightly more complicated (if false). "Something" technically
4848 means the common subset of is_gimple_lvalue and is_gimple_rhs,
4849 but we never try to form anything more complicated than that, so
4850 we don't bother checking.
4852 Also note that CALLBACK should update this flag while walking the
4853 sub-expressions of a statement. For instance, when walking the
4854 statement 'foo (&var)', the flag VAL_ONLY will initially be set
4855 to true, however, when walking &var, the operand of that
4856 ADDR_EXPR does not need to be a GIMPLE value. */
4859 /* True if we are currently walking the LHS of an assignment. */
4862 /* Optional. Set to true by the callback functions if they made any
4866 /* True if we're interested in location information. */
4867 bool want_locations;
4869 /* Operand returned by the callbacks. This is set when calling
4870 walk_gimple_seq. If the walk_stmt_fn or walk_tree_fn callback
4871 returns non-NULL, this field will contain the tree returned by
4872 the last callback. */
4873 tree callback_result;
4876 /* Callback for walk_gimple_stmt. Called for every statement found
4877 during traversal. The first argument points to the statement to
4878 walk. The second argument is a flag that the callback sets to
4879 'true' if it the callback handled all the operands and
4880 sub-statements of the statement (the default value of this flag is
4881 'false'). The third argument is an anonymous pointer to data
4882 to be used by the callback. */
4883 typedef tree (*walk_stmt_fn) (gimple_stmt_iterator *, bool *,
4884 struct walk_stmt_info *);
4886 gimple walk_gimple_seq (gimple_seq, walk_stmt_fn, walk_tree_fn,
4887 struct walk_stmt_info *);
4888 tree walk_gimple_stmt (gimple_stmt_iterator *, walk_stmt_fn, walk_tree_fn,
4889 struct walk_stmt_info *);
4890 tree walk_gimple_op (gimple, walk_tree_fn, struct walk_stmt_info *);
4892 #ifdef GATHER_STATISTICS
4893 /* Enum and arrays used for allocation stats. Keep in sync with
4894 gimple.c:gimple_alloc_kind_names. */
4895 enum gimple_alloc_kind
4897 gimple_alloc_kind_assign, /* Assignments. */
4898 gimple_alloc_kind_phi, /* PHI nodes. */
4899 gimple_alloc_kind_cond, /* Conditionals. */
4900 gimple_alloc_kind_seq, /* Sequences. */
4901 gimple_alloc_kind_rest, /* Everything else. */
4902 gimple_alloc_kind_all
4905 extern int gimple_alloc_counts[];
4906 extern int gimple_alloc_sizes[];
4908 /* Return the allocation kind for a given stmt CODE. */
4909 static inline enum gimple_alloc_kind
4910 gimple_alloc_kind (enum gimple_code code)
4915 return gimple_alloc_kind_assign;
4917 return gimple_alloc_kind_phi;
4919 return gimple_alloc_kind_cond;
4921 return gimple_alloc_kind_rest;
4924 #endif /* GATHER_STATISTICS */
4926 extern void dump_gimple_statistics (void);
4928 /* In gimple-fold.c. */
4929 void gimplify_and_update_call_from_tree (gimple_stmt_iterator *, tree);
4930 tree gimple_fold_builtin (gimple);
4931 bool fold_stmt (gimple_stmt_iterator *);
4932 bool fold_stmt_inplace (gimple);
4933 tree maybe_fold_offset_to_address (location_t, tree, tree, tree);
4934 tree maybe_fold_offset_to_reference (location_t, tree, tree, tree);
4935 tree maybe_fold_stmt_addition (location_t, tree, tree, tree);
4936 tree get_symbol_constant_value (tree);
4937 tree canonicalize_constructor_val (tree);
4938 bool may_propagate_address_into_dereference (tree, tree);
4939 extern tree maybe_fold_and_comparisons (enum tree_code, tree, tree,
4940 enum tree_code, tree, tree);
4941 extern tree maybe_fold_or_comparisons (enum tree_code, tree, tree,
4942 enum tree_code, tree, tree);
4944 #endif /* GCC_GIMPLE_H */