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"
31 #include "hard-reg-set.h"
32 #include "basic-block.h"
33 #include "tree-ssa-operands.h"
34 #include "tree-ssa-alias.h"
36 /* For each block, the PHI nodes that need to be rewritten are stored into
38 typedef VEC(gimple, heap) *gimple_vec;
39 DEF_VEC_P (gimple_vec);
40 DEF_VEC_ALLOC_P (gimple_vec, heap);
43 #define DEFGSCODE(SYM, STRING, STRUCT) SYM,
46 LAST_AND_UNUSED_GIMPLE_CODE
49 extern const char *const gimple_code_name[];
50 extern const unsigned char gimple_rhs_class_table[];
52 /* Error out if a gimple tuple is addressed incorrectly. */
53 #if defined ENABLE_GIMPLE_CHECKING
54 #define gcc_gimple_checking_assert(EXPR) gcc_assert (EXPR)
55 extern void gimple_check_failed (const_gimple, const char *, int, \
56 const char *, enum gimple_code, \
57 enum tree_code) ATTRIBUTE_NORETURN;
59 #define GIMPLE_CHECK(GS, CODE) \
61 const_gimple __gs = (GS); \
62 if (gimple_code (__gs) != (CODE)) \
63 gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__, \
64 (CODE), ERROR_MARK); \
66 #else /* not ENABLE_GIMPLE_CHECKING */
67 #define gcc_gimple_checking_assert(EXPR) ((void)(0 && (EXPR)))
68 #define GIMPLE_CHECK(GS, CODE) (void)0
71 /* Class of GIMPLE expressions suitable for the RHS of assignments. See
72 get_gimple_rhs_class. */
75 GIMPLE_INVALID_RHS, /* The expression cannot be used on the RHS. */
76 GIMPLE_BINARY_RHS, /* The expression is a binary operation. */
77 GIMPLE_UNARY_RHS, /* The expression is a unary operation. */
78 GIMPLE_SINGLE_RHS /* The expression is a single object (an SSA
79 name, a _DECL, a _REF, etc. */
82 /* Specific flags for individual GIMPLE statements. These flags are
83 always stored in gimple_statement_base.subcode and they may only be
84 defined for statement codes that do not use sub-codes.
86 Values for the masks can overlap as long as the overlapping values
87 are never used in the same statement class.
89 The maximum mask value that can be defined is 1 << 15 (i.e., each
90 statement code can hold up to 16 bitflags).
92 Keep this list sorted. */
94 GF_ASM_INPUT = 1 << 0,
95 GF_ASM_VOLATILE = 1 << 1,
96 GF_CALL_CANNOT_INLINE = 1 << 0,
97 GF_CALL_FROM_THUNK = 1 << 1,
98 GF_CALL_RETURN_SLOT_OPT = 1 << 2,
99 GF_CALL_TAILCALL = 1 << 3,
100 GF_CALL_VA_ARG_PACK = 1 << 4,
101 GF_CALL_NOTHROW = 1 << 5,
102 GF_OMP_PARALLEL_COMBINED = 1 << 0,
104 /* True on an GIMPLE_OMP_RETURN statement if the return does not require
105 a thread synchronization via some sort of barrier. The exact barrier
106 that would otherwise be emitted is dependent on the OMP statement with
107 which this return is associated. */
108 GF_OMP_RETURN_NOWAIT = 1 << 0,
110 GF_OMP_SECTION_LAST = 1 << 0,
111 GF_PREDICT_TAKEN = 1 << 15
114 /* Currently, there's only one type of gimple debug stmt. Others are
115 envisioned, for example, to enable the generation of is_stmt notes
116 in line number information, to mark sequence points, etc. This
117 subcode is to be used to tell them apart. */
118 enum gimple_debug_subcode {
119 GIMPLE_DEBUG_BIND = 0
122 /* Masks for selecting a pass local flag (PLF) to work on. These
123 masks are used by gimple_set_plf and gimple_plf. */
129 /* A node in a gimple_seq_d. */
130 struct GTY((chain_next ("%h.next"), chain_prev ("%h.prev"))) gimple_seq_node_d {
132 struct gimple_seq_node_d *prev;
133 struct gimple_seq_node_d *next;
136 /* A double-linked sequence of gimple statements. */
137 struct GTY ((chain_next ("%h.next_free"))) gimple_seq_d {
138 /* First and last statements in the sequence. */
139 gimple_seq_node first;
140 gimple_seq_node last;
142 /* Sequences are created/destroyed frequently. To minimize
143 allocation activity, deallocated sequences are kept in a pool of
144 available sequences. This is the pointer to the next free
145 sequence in the pool. */
146 gimple_seq next_free;
150 /* Return the first node in GIMPLE sequence S. */
152 static inline gimple_seq_node
153 gimple_seq_first (const_gimple_seq s)
155 return s ? s->first : NULL;
159 /* Return the first statement in GIMPLE sequence S. */
162 gimple_seq_first_stmt (const_gimple_seq s)
164 gimple_seq_node n = gimple_seq_first (s);
165 return (n) ? n->stmt : NULL;
169 /* Return the last node in GIMPLE sequence S. */
171 static inline gimple_seq_node
172 gimple_seq_last (const_gimple_seq s)
174 return s ? s->last : NULL;
178 /* Return the last statement in GIMPLE sequence S. */
181 gimple_seq_last_stmt (const_gimple_seq s)
183 gimple_seq_node n = gimple_seq_last (s);
184 return (n) ? n->stmt : NULL;
188 /* Set the last node in GIMPLE sequence S to LAST. */
191 gimple_seq_set_last (gimple_seq s, gimple_seq_node last)
197 /* Set the first node in GIMPLE sequence S to FIRST. */
200 gimple_seq_set_first (gimple_seq s, gimple_seq_node first)
206 /* Return true if GIMPLE sequence S is empty. */
209 gimple_seq_empty_p (const_gimple_seq s)
211 return s == NULL || s->first == NULL;
215 void gimple_seq_add_stmt (gimple_seq *, gimple);
217 /* Link gimple statement GS to the end of the sequence *SEQ_P. If
218 *SEQ_P is NULL, a new sequence is allocated. This function is
219 similar to gimple_seq_add_stmt, but does not scan the operands.
220 During gimplification, we need to manipulate statement sequences
221 before the def/use vectors have been constructed. */
222 void gimplify_seq_add_stmt (gimple_seq *, gimple);
224 /* Allocate a new sequence and initialize its first element with STMT. */
226 static inline gimple_seq
227 gimple_seq_alloc_with_stmt (gimple stmt)
229 gimple_seq seq = NULL;
230 gimple_seq_add_stmt (&seq, stmt);
235 /* Returns the sequence of statements in BB. */
237 static inline gimple_seq
238 bb_seq (const_basic_block bb)
240 return (!(bb->flags & BB_RTL) && bb->il.gimple) ? bb->il.gimple->seq : NULL;
244 /* Sets the sequence of statements in BB to SEQ. */
247 set_bb_seq (basic_block bb, gimple_seq seq)
249 gcc_checking_assert (!(bb->flags & BB_RTL));
250 bb->il.gimple->seq = seq;
253 /* Iterator object for GIMPLE statement sequences. */
257 /* Sequence node holding the current statement. */
260 /* Sequence and basic block holding the statement. These fields
261 are necessary to handle edge cases such as when statement is
262 added to an empty basic block or when the last statement of a
263 block/sequence is removed. */
266 } gimple_stmt_iterator;
269 /* Data structure definitions for GIMPLE tuples. NOTE: word markers
270 are for 64 bit hosts. */
272 struct GTY(()) gimple_statement_base {
274 Main identifying code for a tuple. */
275 ENUM_BITFIELD(gimple_code) code : 8;
277 /* Nonzero if a warning should not be emitted on this tuple. */
278 unsigned int no_warning : 1;
280 /* Nonzero if this tuple has been visited. Passes are responsible
281 for clearing this bit before using it. */
282 unsigned int visited : 1;
284 /* Nonzero if this tuple represents a non-temporal move. */
285 unsigned int nontemporal_move : 1;
287 /* Pass local flags. These flags are free for any pass to use as
288 they see fit. Passes should not assume that these flags contain
289 any useful value when the pass starts. Any initial state that
290 the pass requires should be set on entry to the pass. See
291 gimple_set_plf and gimple_plf for usage. */
292 unsigned int plf : 2;
294 /* Nonzero if this statement has been modified and needs to have its
295 operands rescanned. */
296 unsigned modified : 1;
298 /* Nonzero if this statement contains volatile operands. */
299 unsigned has_volatile_ops : 1;
301 /* Padding to get subcode to 16 bit alignment. */
304 /* The SUBCODE field can be used for tuple-specific flags for tuples
305 that do not require subcodes. Note that SUBCODE should be at
306 least as wide as tree codes, as several tuples store tree codes
308 unsigned int subcode : 16;
310 /* UID of this statement. This is used by passes that want to
311 assign IDs to statements. It must be assigned and used by each
312 pass. By default it should be assumed to contain garbage. */
316 Locus information for debug info. */
319 /* Number of operands in this tuple. */
323 Basic block holding this statement. */
324 struct basic_block_def *bb;
327 Lexical block holding this statement. */
332 /* Base structure for tuples with operands. */
334 struct GTY(()) gimple_statement_with_ops_base
337 struct gimple_statement_base gsbase;
340 SSA operand vectors. NOTE: It should be possible to
341 amalgamate these vectors with the operand vector OP. However,
342 the SSA operand vectors are organized differently and contain
343 more information (like immediate use chaining). */
344 struct def_optype_d GTY((skip (""))) *def_ops;
345 struct use_optype_d GTY((skip (""))) *use_ops;
349 /* Statements that take register operands. */
351 struct GTY(()) gimple_statement_with_ops
354 struct gimple_statement_with_ops_base opbase;
357 Operand vector. NOTE! This must always be the last field
358 of this structure. In particular, this means that this
359 structure cannot be embedded inside another one. */
360 tree GTY((length ("%h.opbase.gsbase.num_ops"))) op[1];
364 /* Base for statements that take both memory and register operands. */
366 struct GTY(()) gimple_statement_with_memory_ops_base
369 struct gimple_statement_with_ops_base opbase;
372 Virtual operands for this statement. The GC will pick them
373 up via the ssa_names array. */
374 tree GTY((skip (""))) vdef;
375 tree GTY((skip (""))) vuse;
379 /* Statements that take both memory and register operands. */
381 struct GTY(()) gimple_statement_with_memory_ops
384 struct gimple_statement_with_memory_ops_base membase;
387 Operand vector. NOTE! This must always be the last field
388 of this structure. In particular, this means that this
389 structure cannot be embedded inside another one. */
390 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
394 /* Call statements that take both memory and register operands. */
396 struct GTY(()) gimple_statement_call
399 struct gimple_statement_with_memory_ops_base membase;
402 struct pt_solution call_used;
403 struct pt_solution call_clobbered;
406 Operand vector. NOTE! This must always be the last field
407 of this structure. In particular, this means that this
408 structure cannot be embedded inside another one. */
409 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
413 /* OpenMP statements (#pragma omp). */
415 struct GTY(()) gimple_statement_omp {
417 struct gimple_statement_base gsbase;
426 struct GTY(()) gimple_statement_bind {
428 struct gimple_statement_base gsbase;
431 Variables declared in this scope. */
435 This is different than the BLOCK field in gimple_statement_base,
436 which is analogous to TREE_BLOCK (i.e., the lexical block holding
437 this statement). This field is the equivalent of BIND_EXPR_BLOCK
438 in tree land (i.e., the lexical scope defined by this bind). See
449 struct GTY(()) gimple_statement_catch {
451 struct gimple_statement_base gsbase;
461 /* GIMPLE_EH_FILTER */
463 struct GTY(()) gimple_statement_eh_filter {
465 struct gimple_statement_base gsbase;
477 /* GIMPLE_EH_MUST_NOT_THROW */
479 struct GTY(()) gimple_statement_eh_mnt {
481 struct gimple_statement_base gsbase;
483 /* [ WORD 5 ] Abort function decl. */
489 struct GTY(()) gimple_statement_phi {
491 struct gimple_statement_base gsbase;
501 struct phi_arg_d GTY ((length ("%h.nargs"))) args[1];
505 /* GIMPLE_RESX, GIMPLE_EH_DISPATCH */
507 struct GTY(()) gimple_statement_eh_ctrl
510 struct gimple_statement_base gsbase;
513 Exception region number. */
520 struct GTY(()) gimple_statement_try {
522 struct gimple_statement_base gsbase;
525 Expression to evaluate. */
529 Cleanup expression. */
533 /* Kind of GIMPLE_TRY statements. */
534 enum gimple_try_flags
537 GIMPLE_TRY_CATCH = 1 << 0,
540 GIMPLE_TRY_FINALLY = 1 << 1,
541 GIMPLE_TRY_KIND = GIMPLE_TRY_CATCH | GIMPLE_TRY_FINALLY,
543 /* Analogous to TRY_CATCH_IS_CLEANUP. */
544 GIMPLE_TRY_CATCH_IS_CLEANUP = 1 << 2
547 /* GIMPLE_WITH_CLEANUP_EXPR */
549 struct GTY(()) gimple_statement_wce {
551 struct gimple_statement_base gsbase;
553 /* Subcode: CLEANUP_EH_ONLY. True if the cleanup should only be
554 executed if an exception is thrown, not on normal exit of its
555 scope. This flag is analogous to the CLEANUP_EH_ONLY flag
559 Cleanup expression. */
566 struct GTY(()) gimple_statement_asm
569 struct gimple_statement_with_memory_ops_base membase;
572 __asm__ statement. */
576 Number of inputs, outputs, clobbers, labels. */
583 Operand vector. NOTE! This must always be the last field
584 of this structure. In particular, this means that this
585 structure cannot be embedded inside another one. */
586 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
589 /* GIMPLE_OMP_CRITICAL */
591 struct GTY(()) gimple_statement_omp_critical {
593 struct gimple_statement_omp omp;
596 Critical section name. */
601 struct GTY(()) gimple_omp_for_iter {
602 /* Condition code. */
605 /* Index variable. */
620 struct GTY(()) gimple_statement_omp_for {
622 struct gimple_statement_omp omp;
628 Number of elements in iter array. */
632 struct gimple_omp_for_iter * GTY((length ("%h.collapse"))) iter;
635 Pre-body evaluated before the loop body begins. */
640 /* GIMPLE_OMP_PARALLEL */
642 struct GTY(()) gimple_statement_omp_parallel {
644 struct gimple_statement_omp omp;
651 Child function holding the body of the parallel region. */
655 Shared data argument. */
660 /* GIMPLE_OMP_TASK */
662 struct GTY(()) gimple_statement_omp_task {
664 struct gimple_statement_omp_parallel par;
667 Child function holding firstprivate initialization if needed. */
671 Size and alignment in bytes of the argument data block. */
677 /* GIMPLE_OMP_SECTION */
678 /* Uses struct gimple_statement_omp. */
681 /* GIMPLE_OMP_SECTIONS */
683 struct GTY(()) gimple_statement_omp_sections {
685 struct gimple_statement_omp omp;
691 The control variable used for deciding which of the sections to
696 /* GIMPLE_OMP_CONTINUE.
698 Note: This does not inherit from gimple_statement_omp, because we
699 do not need the body field. */
701 struct GTY(()) gimple_statement_omp_continue {
703 struct gimple_statement_base gsbase;
712 /* GIMPLE_OMP_SINGLE */
714 struct GTY(()) gimple_statement_omp_single {
716 struct gimple_statement_omp omp;
723 /* GIMPLE_OMP_ATOMIC_LOAD.
724 Note: This is based on gimple_statement_base, not g_s_omp, because g_s_omp
725 contains a sequence, which we don't need here. */
727 struct GTY(()) gimple_statement_omp_atomic_load {
729 struct gimple_statement_base gsbase;
735 /* GIMPLE_OMP_ATOMIC_STORE.
736 See note on GIMPLE_OMP_ATOMIC_LOAD. */
738 struct GTY(()) gimple_statement_omp_atomic_store {
740 struct gimple_statement_base gsbase;
746 #define DEFGSSTRUCT(SYM, STRUCT, HAS_TREE_OP) SYM,
747 enum gimple_statement_structure_enum {
748 #include "gsstruct.def"
754 /* Define the overall contents of a gimple tuple. It may be any of the
755 structures declared above for various types of tuples. */
757 union GTY ((desc ("gimple_statement_structure (&%h)"), variable_size)) gimple_statement_d {
758 struct gimple_statement_base GTY ((tag ("GSS_BASE"))) gsbase;
759 struct gimple_statement_with_ops GTY ((tag ("GSS_WITH_OPS"))) gsops;
760 struct gimple_statement_with_memory_ops_base GTY ((tag ("GSS_WITH_MEM_OPS_BASE"))) gsmembase;
761 struct gimple_statement_with_memory_ops GTY ((tag ("GSS_WITH_MEM_OPS"))) gsmem;
762 struct gimple_statement_call GTY ((tag ("GSS_CALL"))) gimple_call;
763 struct gimple_statement_omp GTY ((tag ("GSS_OMP"))) omp;
764 struct gimple_statement_bind GTY ((tag ("GSS_BIND"))) gimple_bind;
765 struct gimple_statement_catch GTY ((tag ("GSS_CATCH"))) gimple_catch;
766 struct gimple_statement_eh_filter GTY ((tag ("GSS_EH_FILTER"))) gimple_eh_filter;
767 struct gimple_statement_eh_mnt GTY ((tag ("GSS_EH_MNT"))) gimple_eh_mnt;
768 struct gimple_statement_phi GTY ((tag ("GSS_PHI"))) gimple_phi;
769 struct gimple_statement_eh_ctrl GTY ((tag ("GSS_EH_CTRL"))) gimple_eh_ctrl;
770 struct gimple_statement_try GTY ((tag ("GSS_TRY"))) gimple_try;
771 struct gimple_statement_wce GTY ((tag ("GSS_WCE"))) gimple_wce;
772 struct gimple_statement_asm GTY ((tag ("GSS_ASM"))) gimple_asm;
773 struct gimple_statement_omp_critical GTY ((tag ("GSS_OMP_CRITICAL"))) gimple_omp_critical;
774 struct gimple_statement_omp_for GTY ((tag ("GSS_OMP_FOR"))) gimple_omp_for;
775 struct gimple_statement_omp_parallel GTY ((tag ("GSS_OMP_PARALLEL"))) gimple_omp_parallel;
776 struct gimple_statement_omp_task GTY ((tag ("GSS_OMP_TASK"))) gimple_omp_task;
777 struct gimple_statement_omp_sections GTY ((tag ("GSS_OMP_SECTIONS"))) gimple_omp_sections;
778 struct gimple_statement_omp_single GTY ((tag ("GSS_OMP_SINGLE"))) gimple_omp_single;
779 struct gimple_statement_omp_continue GTY ((tag ("GSS_OMP_CONTINUE"))) gimple_omp_continue;
780 struct gimple_statement_omp_atomic_load GTY ((tag ("GSS_OMP_ATOMIC_LOAD"))) gimple_omp_atomic_load;
781 struct gimple_statement_omp_atomic_store GTY ((tag ("GSS_OMP_ATOMIC_STORE"))) gimple_omp_atomic_store;
786 /* Offset in bytes to the location of the operand vector.
787 Zero if there is no operand vector for this tuple structure. */
788 extern size_t const gimple_ops_offset_[];
790 /* Map GIMPLE codes to GSS codes. */
791 extern enum gimple_statement_structure_enum const gss_for_code_[];
793 /* This variable holds the currently expanded gimple statement for purposes
794 of comminucating the profile info to the builtin expanders. */
795 extern gimple currently_expanding_gimple_stmt;
797 gimple gimple_build_return (tree);
799 gimple gimple_build_assign_stat (tree, tree MEM_STAT_DECL);
800 #define gimple_build_assign(l,r) gimple_build_assign_stat (l, r MEM_STAT_INFO)
802 void extract_ops_from_tree (tree, enum tree_code *, tree *, tree *);
804 gimple gimple_build_assign_with_ops_stat (enum tree_code, tree, tree,
806 #define gimple_build_assign_with_ops(c,o1,o2,o3) \
807 gimple_build_assign_with_ops_stat (c, o1, o2, o3 MEM_STAT_INFO)
809 gimple gimple_build_debug_bind_stat (tree, tree, gimple MEM_STAT_DECL);
810 #define gimple_build_debug_bind(var,val,stmt) \
811 gimple_build_debug_bind_stat ((var), (val), (stmt) MEM_STAT_INFO)
813 gimple gimple_build_call_vec (tree, VEC(tree, heap) *);
814 gimple gimple_build_call (tree, unsigned, ...);
815 gimple gimple_build_call_from_tree (tree);
816 gimple gimplify_assign (tree, tree, gimple_seq *);
817 gimple gimple_build_cond (enum tree_code, tree, tree, tree, tree);
818 gimple gimple_build_label (tree label);
819 gimple gimple_build_goto (tree dest);
820 gimple gimple_build_nop (void);
821 gimple gimple_build_bind (tree, gimple_seq, tree);
822 gimple gimple_build_asm_vec (const char *, VEC(tree,gc) *, VEC(tree,gc) *,
823 VEC(tree,gc) *, VEC(tree,gc) *);
824 gimple gimple_build_catch (tree, gimple_seq);
825 gimple gimple_build_eh_filter (tree, gimple_seq);
826 gimple gimple_build_eh_must_not_throw (tree);
827 gimple gimple_build_try (gimple_seq, gimple_seq, enum gimple_try_flags);
828 gimple gimple_build_wce (gimple_seq);
829 gimple gimple_build_resx (int);
830 gimple gimple_build_eh_dispatch (int);
831 gimple gimple_build_switch_nlabels (unsigned, tree, tree);
832 gimple gimple_build_switch (unsigned, tree, tree, ...);
833 gimple gimple_build_switch_vec (tree, tree, VEC(tree,heap) *);
834 gimple gimple_build_omp_parallel (gimple_seq, tree, tree, tree);
835 gimple gimple_build_omp_task (gimple_seq, tree, tree, tree, tree, tree, tree);
836 gimple gimple_build_omp_for (gimple_seq, tree, size_t, gimple_seq);
837 gimple gimple_build_omp_critical (gimple_seq, tree);
838 gimple gimple_build_omp_section (gimple_seq);
839 gimple gimple_build_omp_continue (tree, tree);
840 gimple gimple_build_omp_master (gimple_seq);
841 gimple gimple_build_omp_return (bool);
842 gimple gimple_build_omp_ordered (gimple_seq);
843 gimple gimple_build_omp_sections (gimple_seq, tree);
844 gimple gimple_build_omp_sections_switch (void);
845 gimple gimple_build_omp_single (gimple_seq, tree);
846 gimple gimple_build_cdt (tree, tree);
847 gimple gimple_build_omp_atomic_load (tree, tree);
848 gimple gimple_build_omp_atomic_store (tree);
849 gimple gimple_build_predict (enum br_predictor, enum prediction);
850 enum gimple_statement_structure_enum gss_for_assign (enum tree_code);
851 void sort_case_labels (VEC(tree,heap) *);
852 void gimple_set_body (tree, gimple_seq);
853 gimple_seq gimple_body (tree);
854 bool gimple_has_body_p (tree);
855 gimple_seq gimple_seq_alloc (void);
856 void gimple_seq_free (gimple_seq);
857 void gimple_seq_add_seq (gimple_seq *, gimple_seq);
858 gimple_seq gimple_seq_copy (gimple_seq);
859 int gimple_call_flags (const_gimple);
860 int gimple_call_return_flags (const_gimple);
861 int gimple_call_arg_flags (const_gimple, unsigned);
862 void gimple_call_reset_alias_info (gimple);
863 bool gimple_assign_copy_p (gimple);
864 bool gimple_assign_ssa_name_copy_p (gimple);
865 bool gimple_assign_single_p (gimple);
866 bool gimple_assign_unary_nop_p (gimple);
867 void gimple_set_bb (gimple, struct basic_block_def *);
868 void gimple_assign_set_rhs_from_tree (gimple_stmt_iterator *, tree);
869 void gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *, enum tree_code,
871 tree gimple_get_lhs (const_gimple);
872 void gimple_set_lhs (gimple, tree);
873 void gimple_replace_lhs (gimple, tree);
874 gimple gimple_copy (gimple);
875 bool is_gimple_operand (const_tree);
876 void gimple_set_modified (gimple, bool);
877 void gimple_cond_get_ops_from_tree (tree, enum tree_code *, tree *, tree *);
878 gimple gimple_build_cond_from_tree (tree, tree, tree);
879 void gimple_cond_set_condition_from_tree (gimple, tree);
880 bool gimple_has_side_effects (const_gimple);
881 bool gimple_rhs_has_side_effects (const_gimple);
882 bool gimple_could_trap_p (gimple);
883 bool gimple_assign_rhs_could_trap_p (gimple);
884 void gimple_regimplify_operands (gimple, gimple_stmt_iterator *);
885 bool empty_body_p (gimple_seq);
886 unsigned get_gimple_rhs_num_ops (enum tree_code);
887 #define gimple_alloc(c, n) gimple_alloc_stat (c, n MEM_STAT_INFO)
888 gimple gimple_alloc_stat (enum gimple_code, unsigned MEM_STAT_DECL);
889 const char *gimple_decl_printable_name (tree, int);
890 tree gimple_fold_obj_type_ref (tree, tree);
891 tree gimple_get_relevant_ref_binfo (tree ref, tree known_binfo);
892 tree gimple_fold_obj_type_ref_known_binfo (HOST_WIDE_INT, tree);
894 /* Returns true iff T is a valid GIMPLE statement. */
895 extern bool is_gimple_stmt (tree);
897 /* Returns true iff TYPE is a valid type for a scalar register variable. */
898 extern bool is_gimple_reg_type (tree);
899 /* Returns true iff T is a scalar register variable. */
900 extern bool is_gimple_reg (tree);
901 /* Returns true iff T is any sort of variable. */
902 extern bool is_gimple_variable (tree);
903 /* Returns true iff T is any sort of symbol. */
904 extern bool is_gimple_id (tree);
905 /* Returns true iff T is a variable or an INDIRECT_REF (of a variable). */
906 extern bool is_gimple_min_lval (tree);
907 /* Returns true iff T is something whose address can be taken. */
908 extern bool is_gimple_addressable (tree);
909 /* Returns true iff T is any valid GIMPLE lvalue. */
910 extern bool is_gimple_lvalue (tree);
912 /* Returns true iff T is a GIMPLE address. */
913 bool is_gimple_address (const_tree);
914 /* Returns true iff T is a GIMPLE invariant address. */
915 bool is_gimple_invariant_address (const_tree);
916 /* Returns true iff T is a GIMPLE invariant address at interprocedural
918 bool is_gimple_ip_invariant_address (const_tree);
919 /* Returns true iff T is a valid GIMPLE constant. */
920 bool is_gimple_constant (const_tree);
921 /* Returns true iff T is a GIMPLE restricted function invariant. */
922 extern bool is_gimple_min_invariant (const_tree);
923 /* Returns true iff T is a GIMPLE restricted interprecodural invariant. */
924 extern bool is_gimple_ip_invariant (const_tree);
925 /* Returns true iff T is a GIMPLE rvalue. */
926 extern bool is_gimple_val (tree);
927 /* Returns true iff T is a GIMPLE asm statement input. */
928 extern bool is_gimple_asm_val (tree);
929 /* Returns true iff T is a valid rhs for a MODIFY_EXPR where the LHS is a
930 GIMPLE temporary, a renamed user variable, or something else,
932 extern bool is_gimple_reg_rhs (tree);
933 extern bool is_gimple_mem_rhs (tree);
935 /* Returns true iff T is a valid if-statement condition. */
936 extern bool is_gimple_condexpr (tree);
938 /* Returns true iff T is a type conversion. */
939 extern bool is_gimple_cast (tree);
940 /* Returns true iff T is a variable that does not need to live in memory. */
941 extern bool is_gimple_non_addressable (tree t);
943 /* Returns true iff T is a valid call address expression. */
944 extern bool is_gimple_call_addr (tree);
945 /* If T makes a function call, returns the CALL_EXPR operand. */
946 extern tree get_call_expr_in (tree t);
948 extern void recalculate_side_effects (tree);
949 extern bool gimple_compare_field_offset (tree, tree);
950 extern tree gimple_register_type (tree);
951 extern void print_gimple_types_stats (void);
952 extern void free_gimple_type_tables (void);
953 extern tree gimple_unsigned_type (tree);
954 extern tree gimple_signed_type (tree);
955 extern alias_set_type gimple_get_alias_set (tree);
956 extern void count_uses_and_derefs (tree, gimple, unsigned *, unsigned *,
958 extern bool walk_stmt_load_store_addr_ops (gimple, void *,
959 bool (*)(gimple, tree, void *),
960 bool (*)(gimple, tree, void *),
961 bool (*)(gimple, tree, void *));
962 extern bool walk_stmt_load_store_ops (gimple, void *,
963 bool (*)(gimple, tree, void *),
964 bool (*)(gimple, tree, void *));
965 extern bool gimple_ior_addresses_taken (bitmap, gimple);
966 extern bool gimple_call_builtin_p (gimple, enum built_in_function);
969 extern tree create_tmp_var_raw (tree, const char *);
970 extern tree create_tmp_var_name (const char *);
971 extern tree create_tmp_var (tree, const char *);
972 extern tree create_tmp_reg (tree, const char *);
973 extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq *);
974 extern tree get_formal_tmp_var (tree, gimple_seq *);
975 extern void declare_vars (tree, gimple, bool);
976 extern void annotate_all_with_location (gimple_seq, location_t);
978 /* Validation of GIMPLE expressions. Note that these predicates only check
979 the basic form of the expression, they don't recurse to make sure that
980 underlying nodes are also of the right form. */
981 typedef bool (*gimple_predicate)(tree);
984 /* FIXME we should deduce this from the predicate. */
986 fb_none = 0, /* Do not generate a temporary. */
988 fb_rvalue = 1, /* Generate an rvalue to hold the result of a
989 gimplified expression. */
991 fb_lvalue = 2, /* Generate an lvalue to hold the result of a
992 gimplified expression. */
994 fb_mayfail = 4, /* Gimplification may fail. Error issued
996 fb_either= fb_rvalue | fb_lvalue
999 typedef int fallback_t;
1001 enum gimplify_status {
1002 GS_ERROR = -2, /* Something Bad Seen. */
1003 GS_UNHANDLED = -1, /* A langhook result for "I dunno". */
1004 GS_OK = 0, /* We did something, maybe more to do. */
1005 GS_ALL_DONE = 1 /* The expression is fully gimplified. */
1010 struct gimplify_ctx *prev_context;
1012 VEC(gimple,heap) *bind_expr_stack;
1014 gimple_seq conditional_cleanups;
1018 VEC(tree,heap) *case_labels;
1019 /* The formal temporary table. Should this be persistent? */
1025 bool allow_rhs_cond_expr;
1028 extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *,
1029 bool (*) (tree), fallback_t);
1030 extern void gimplify_type_sizes (tree, gimple_seq *);
1031 extern void gimplify_one_sizepos (tree *, gimple_seq *);
1032 extern bool gimplify_stmt (tree *, gimple_seq *);
1033 extern gimple gimplify_body (tree *, tree, bool);
1034 extern void push_gimplify_context (struct gimplify_ctx *);
1035 extern void pop_gimplify_context (gimple);
1036 extern void gimplify_and_add (tree, gimple_seq *);
1038 /* Miscellaneous helpers. */
1039 extern void gimple_add_tmp_var (tree);
1040 extern gimple gimple_current_bind_expr (void);
1041 extern VEC(gimple, heap) *gimple_bind_expr_stack (void);
1042 extern tree voidify_wrapper_expr (tree, tree);
1043 extern tree build_and_jump (tree *);
1044 extern tree force_labels_r (tree *, int *, void *);
1045 extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *,
1047 struct gimplify_omp_ctx;
1048 extern void omp_firstprivatize_variable (struct gimplify_omp_ctx *, tree);
1049 extern tree gimple_boolify (tree);
1050 extern gimple_predicate rhs_predicate_for (tree);
1051 extern tree canonicalize_cond_expr_cond (tree);
1054 extern tree omp_reduction_init (tree, tree);
1056 /* In tree-nested.c. */
1057 extern void lower_nested_functions (tree);
1058 extern void insert_field_into_struct (tree, tree);
1060 /* In gimplify.c. */
1061 extern void gimplify_function_tree (tree);
1063 /* In cfgexpand.c. */
1064 extern tree gimple_assign_rhs_to_tree (gimple);
1067 extern bool validate_gimple_arglist (const_gimple, ...);
1070 extern bool tree_ssa_useless_type_conversion (tree);
1071 extern tree tree_ssa_strip_useless_type_conversions (tree);
1072 extern bool useless_type_conversion_p (tree, tree);
1073 extern bool types_compatible_p (tree, tree);
1075 /* Return the code for GIMPLE statement G. */
1077 static inline enum gimple_code
1078 gimple_code (const_gimple g)
1080 return g->gsbase.code;
1084 /* Return the GSS code used by a GIMPLE code. */
1086 static inline enum gimple_statement_structure_enum
1087 gss_for_code (enum gimple_code code)
1089 gcc_gimple_checking_assert ((unsigned int)code < LAST_AND_UNUSED_GIMPLE_CODE);
1090 return gss_for_code_[code];
1094 /* Return which GSS code is used by GS. */
1096 static inline enum gimple_statement_structure_enum
1097 gimple_statement_structure (gimple gs)
1099 return gss_for_code (gimple_code (gs));
1103 /* Return true if statement G has sub-statements. This is only true for
1104 High GIMPLE statements. */
1107 gimple_has_substatements (gimple g)
1109 switch (gimple_code (g))
1113 case GIMPLE_EH_FILTER:
1115 case GIMPLE_OMP_FOR:
1116 case GIMPLE_OMP_MASTER:
1117 case GIMPLE_OMP_ORDERED:
1118 case GIMPLE_OMP_SECTION:
1119 case GIMPLE_OMP_PARALLEL:
1120 case GIMPLE_OMP_TASK:
1121 case GIMPLE_OMP_SECTIONS:
1122 case GIMPLE_OMP_SINGLE:
1123 case GIMPLE_OMP_CRITICAL:
1124 case GIMPLE_WITH_CLEANUP_EXPR:
1133 /* Return the basic block holding statement G. */
1135 static inline struct basic_block_def *
1136 gimple_bb (const_gimple g)
1138 return g->gsbase.bb;
1142 /* Return the lexical scope block holding statement G. */
1145 gimple_block (const_gimple g)
1147 return g->gsbase.block;
1151 /* Set BLOCK to be the lexical scope block holding statement G. */
1154 gimple_set_block (gimple g, tree block)
1156 g->gsbase.block = block;
1160 /* Return location information for statement G. */
1162 static inline location_t
1163 gimple_location (const_gimple g)
1165 return g->gsbase.location;
1168 /* Return pointer to location information for statement G. */
1170 static inline const location_t *
1171 gimple_location_ptr (const_gimple g)
1173 return &g->gsbase.location;
1177 /* Set location information for statement G. */
1180 gimple_set_location (gimple g, location_t location)
1182 g->gsbase.location = location;
1186 /* Return true if G contains location information. */
1189 gimple_has_location (const_gimple g)
1191 return gimple_location (g) != UNKNOWN_LOCATION;
1195 /* Return the file name of the location of STMT. */
1197 static inline const char *
1198 gimple_filename (const_gimple stmt)
1200 return LOCATION_FILE (gimple_location (stmt));
1204 /* Return the line number of the location of STMT. */
1207 gimple_lineno (const_gimple stmt)
1209 return LOCATION_LINE (gimple_location (stmt));
1213 /* Determine whether SEQ is a singleton. */
1216 gimple_seq_singleton_p (gimple_seq seq)
1218 return ((gimple_seq_first (seq) != NULL)
1219 && (gimple_seq_first (seq) == gimple_seq_last (seq)));
1222 /* Return true if no warnings should be emitted for statement STMT. */
1225 gimple_no_warning_p (const_gimple stmt)
1227 return stmt->gsbase.no_warning;
1230 /* Set the no_warning flag of STMT to NO_WARNING. */
1233 gimple_set_no_warning (gimple stmt, bool no_warning)
1235 stmt->gsbase.no_warning = (unsigned) no_warning;
1238 /* Set the visited status on statement STMT to VISITED_P. */
1241 gimple_set_visited (gimple stmt, bool visited_p)
1243 stmt->gsbase.visited = (unsigned) visited_p;
1247 /* Return the visited status for statement STMT. */
1250 gimple_visited_p (gimple stmt)
1252 return stmt->gsbase.visited;
1256 /* Set pass local flag PLF on statement STMT to VAL_P. */
1259 gimple_set_plf (gimple stmt, enum plf_mask plf, bool val_p)
1262 stmt->gsbase.plf |= (unsigned int) plf;
1264 stmt->gsbase.plf &= ~((unsigned int) plf);
1268 /* Return the value of pass local flag PLF on statement STMT. */
1270 static inline unsigned int
1271 gimple_plf (gimple stmt, enum plf_mask plf)
1273 return stmt->gsbase.plf & ((unsigned int) plf);
1277 /* Set the UID of statement. */
1280 gimple_set_uid (gimple g, unsigned uid)
1282 g->gsbase.uid = uid;
1286 /* Return the UID of statement. */
1288 static inline unsigned
1289 gimple_uid (const_gimple g)
1291 return g->gsbase.uid;
1295 /* Return true if GIMPLE statement G has register or memory operands. */
1298 gimple_has_ops (const_gimple g)
1300 return gimple_code (g) >= GIMPLE_COND && gimple_code (g) <= GIMPLE_RETURN;
1304 /* Return true if GIMPLE statement G has memory operands. */
1307 gimple_has_mem_ops (const_gimple g)
1309 return gimple_code (g) >= GIMPLE_ASSIGN && gimple_code (g) <= GIMPLE_RETURN;
1313 /* Return the set of DEF operands for statement G. */
1315 static inline struct def_optype_d *
1316 gimple_def_ops (const_gimple g)
1318 if (!gimple_has_ops (g))
1320 return g->gsops.opbase.def_ops;
1324 /* Set DEF to be the set of DEF operands for statement G. */
1327 gimple_set_def_ops (gimple g, struct def_optype_d *def)
1329 gcc_gimple_checking_assert (gimple_has_ops (g));
1330 g->gsops.opbase.def_ops = def;
1334 /* Return the set of USE operands for statement G. */
1336 static inline struct use_optype_d *
1337 gimple_use_ops (const_gimple g)
1339 if (!gimple_has_ops (g))
1341 return g->gsops.opbase.use_ops;
1345 /* Set USE to be the set of USE operands for statement G. */
1348 gimple_set_use_ops (gimple g, struct use_optype_d *use)
1350 gcc_gimple_checking_assert (gimple_has_ops (g));
1351 g->gsops.opbase.use_ops = use;
1355 /* Return the set of VUSE operand for statement G. */
1357 static inline use_operand_p
1358 gimple_vuse_op (const_gimple g)
1360 struct use_optype_d *ops;
1361 if (!gimple_has_mem_ops (g))
1362 return NULL_USE_OPERAND_P;
1363 ops = g->gsops.opbase.use_ops;
1365 && USE_OP_PTR (ops)->use == &g->gsmembase.vuse)
1366 return USE_OP_PTR (ops);
1367 return NULL_USE_OPERAND_P;
1370 /* Return the set of VDEF operand for statement G. */
1372 static inline def_operand_p
1373 gimple_vdef_op (const_gimple g)
1375 struct def_optype_d *ops;
1376 if (!gimple_has_mem_ops (g))
1377 return NULL_DEF_OPERAND_P;
1378 ops = g->gsops.opbase.def_ops;
1380 && DEF_OP_PTR (ops) == &g->gsmembase.vdef)
1381 return DEF_OP_PTR (ops);
1382 return NULL_DEF_OPERAND_P;
1386 /* Return the single VUSE operand of the statement G. */
1389 gimple_vuse (const_gimple g)
1391 if (!gimple_has_mem_ops (g))
1393 return g->gsmembase.vuse;
1396 /* Return the single VDEF operand of the statement G. */
1399 gimple_vdef (const_gimple g)
1401 if (!gimple_has_mem_ops (g))
1403 return g->gsmembase.vdef;
1406 /* Return the single VUSE operand of the statement G. */
1408 static inline tree *
1409 gimple_vuse_ptr (gimple g)
1411 if (!gimple_has_mem_ops (g))
1413 return &g->gsmembase.vuse;
1416 /* Return the single VDEF operand of the statement G. */
1418 static inline tree *
1419 gimple_vdef_ptr (gimple g)
1421 if (!gimple_has_mem_ops (g))
1423 return &g->gsmembase.vdef;
1426 /* Set the single VUSE operand of the statement G. */
1429 gimple_set_vuse (gimple g, tree vuse)
1431 gcc_gimple_checking_assert (gimple_has_mem_ops (g));
1432 g->gsmembase.vuse = vuse;
1435 /* Set the single VDEF operand of the statement G. */
1438 gimple_set_vdef (gimple g, tree vdef)
1440 gcc_gimple_checking_assert (gimple_has_mem_ops (g));
1441 g->gsmembase.vdef = vdef;
1445 /* Return true if statement G has operands and the modified field has
1449 gimple_modified_p (const_gimple g)
1451 return (gimple_has_ops (g)) ? (bool) g->gsbase.modified : false;
1455 /* Return the tree code for the expression computed by STMT. This is
1456 only valid for GIMPLE_COND, GIMPLE_CALL and GIMPLE_ASSIGN. For
1457 GIMPLE_CALL, return CALL_EXPR as the expression code for
1458 consistency. This is useful when the caller needs to deal with the
1459 three kinds of computation that GIMPLE supports. */
1461 static inline enum tree_code
1462 gimple_expr_code (const_gimple stmt)
1464 enum gimple_code code = gimple_code (stmt);
1465 if (code == GIMPLE_ASSIGN || code == GIMPLE_COND)
1466 return (enum tree_code) stmt->gsbase.subcode;
1469 gcc_gimple_checking_assert (code == GIMPLE_CALL);
1475 /* Mark statement S as modified, and update it. */
1478 update_stmt (gimple s)
1480 if (gimple_has_ops (s))
1482 gimple_set_modified (s, true);
1483 update_stmt_operands (s);
1487 /* Update statement S if it has been optimized. */
1490 update_stmt_if_modified (gimple s)
1492 if (gimple_modified_p (s))
1493 update_stmt_operands (s);
1496 /* Return true if statement STMT contains volatile operands. */
1499 gimple_has_volatile_ops (const_gimple stmt)
1501 if (gimple_has_mem_ops (stmt))
1502 return stmt->gsbase.has_volatile_ops;
1508 /* Set the HAS_VOLATILE_OPS flag to VOLATILEP. */
1511 gimple_set_has_volatile_ops (gimple stmt, bool volatilep)
1513 if (gimple_has_mem_ops (stmt))
1514 stmt->gsbase.has_volatile_ops = (unsigned) volatilep;
1518 /* Return true if statement STMT may access memory. */
1521 gimple_references_memory_p (gimple stmt)
1523 return gimple_has_mem_ops (stmt) && gimple_vuse (stmt);
1527 /* Return the subcode for OMP statement S. */
1529 static inline unsigned
1530 gimple_omp_subcode (const_gimple s)
1532 gcc_gimple_checking_assert (gimple_code (s) >= GIMPLE_OMP_ATOMIC_LOAD
1533 && gimple_code (s) <= GIMPLE_OMP_SINGLE);
1534 return s->gsbase.subcode;
1537 /* Set the subcode for OMP statement S to SUBCODE. */
1540 gimple_omp_set_subcode (gimple s, unsigned int subcode)
1542 /* We only have 16 bits for the subcode. Assert that we are not
1544 gcc_gimple_checking_assert (subcode < (1 << 16));
1545 s->gsbase.subcode = subcode;
1548 /* Set the nowait flag on OMP_RETURN statement S. */
1551 gimple_omp_return_set_nowait (gimple s)
1553 GIMPLE_CHECK (s, GIMPLE_OMP_RETURN);
1554 s->gsbase.subcode |= GF_OMP_RETURN_NOWAIT;
1558 /* Return true if OMP return statement G has the GF_OMP_RETURN_NOWAIT
1562 gimple_omp_return_nowait_p (const_gimple g)
1564 GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
1565 return (gimple_omp_subcode (g) & GF_OMP_RETURN_NOWAIT) != 0;
1569 /* Return true if OMP section statement G has the GF_OMP_SECTION_LAST
1573 gimple_omp_section_last_p (const_gimple g)
1575 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1576 return (gimple_omp_subcode (g) & GF_OMP_SECTION_LAST) != 0;
1580 /* Set the GF_OMP_SECTION_LAST flag on G. */
1583 gimple_omp_section_set_last (gimple g)
1585 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1586 g->gsbase.subcode |= GF_OMP_SECTION_LAST;
1590 /* Return true if OMP parallel statement G has the
1591 GF_OMP_PARALLEL_COMBINED flag set. */
1594 gimple_omp_parallel_combined_p (const_gimple g)
1596 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1597 return (gimple_omp_subcode (g) & GF_OMP_PARALLEL_COMBINED) != 0;
1601 /* Set the GF_OMP_PARALLEL_COMBINED field in G depending on the boolean
1602 value of COMBINED_P. */
1605 gimple_omp_parallel_set_combined_p (gimple g, bool combined_p)
1607 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1609 g->gsbase.subcode |= GF_OMP_PARALLEL_COMBINED;
1611 g->gsbase.subcode &= ~GF_OMP_PARALLEL_COMBINED;
1615 /* Return the number of operands for statement GS. */
1617 static inline unsigned
1618 gimple_num_ops (const_gimple gs)
1620 return gs->gsbase.num_ops;
1624 /* Set the number of operands for statement GS. */
1627 gimple_set_num_ops (gimple gs, unsigned num_ops)
1629 gs->gsbase.num_ops = num_ops;
1633 /* Return the array of operands for statement GS. */
1635 static inline tree *
1636 gimple_ops (gimple gs)
1640 /* All the tuples have their operand vector at the very bottom
1641 of the structure. Note that those structures that do not
1642 have an operand vector have a zero offset. */
1643 off = gimple_ops_offset_[gimple_statement_structure (gs)];
1644 gcc_gimple_checking_assert (off != 0);
1646 return (tree *) ((char *) gs + off);
1650 /* Return operand I for statement GS. */
1653 gimple_op (const_gimple gs, unsigned i)
1655 if (gimple_has_ops (gs))
1657 gcc_gimple_checking_assert (i < gimple_num_ops (gs));
1658 return gimple_ops (CONST_CAST_GIMPLE (gs))[i];
1664 /* Return a pointer to operand I for statement GS. */
1666 static inline tree *
1667 gimple_op_ptr (const_gimple gs, unsigned i)
1669 if (gimple_has_ops (gs))
1671 gcc_gimple_checking_assert (i < gimple_num_ops (gs));
1672 return gimple_ops (CONST_CAST_GIMPLE (gs)) + i;
1678 /* Set operand I of statement GS to OP. */
1681 gimple_set_op (gimple gs, unsigned i, tree op)
1683 gcc_gimple_checking_assert (gimple_has_ops (gs) && i < gimple_num_ops (gs));
1685 /* Note. It may be tempting to assert that OP matches
1686 is_gimple_operand, but that would be wrong. Different tuples
1687 accept slightly different sets of tree operands. Each caller
1688 should perform its own validation. */
1689 gimple_ops (gs)[i] = op;
1692 /* Return true if GS is a GIMPLE_ASSIGN. */
1695 is_gimple_assign (const_gimple gs)
1697 return gimple_code (gs) == GIMPLE_ASSIGN;
1700 /* Determine if expression CODE is one of the valid expressions that can
1701 be used on the RHS of GIMPLE assignments. */
1703 static inline enum gimple_rhs_class
1704 get_gimple_rhs_class (enum tree_code code)
1706 return (enum gimple_rhs_class) gimple_rhs_class_table[(int) code];
1709 /* Return the LHS of assignment statement GS. */
1712 gimple_assign_lhs (const_gimple gs)
1714 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1715 return gimple_op (gs, 0);
1719 /* Return a pointer to the LHS of assignment statement GS. */
1721 static inline tree *
1722 gimple_assign_lhs_ptr (const_gimple gs)
1724 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1725 return gimple_op_ptr (gs, 0);
1729 /* Set LHS to be the LHS operand of assignment statement GS. */
1732 gimple_assign_set_lhs (gimple gs, tree lhs)
1734 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1735 gimple_set_op (gs, 0, lhs);
1737 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1738 SSA_NAME_DEF_STMT (lhs) = gs;
1742 /* Return the first operand on the RHS of assignment statement GS. */
1745 gimple_assign_rhs1 (const_gimple gs)
1747 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1748 return gimple_op (gs, 1);
1752 /* Return a pointer to the first operand on the RHS of assignment
1755 static inline tree *
1756 gimple_assign_rhs1_ptr (const_gimple gs)
1758 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1759 return gimple_op_ptr (gs, 1);
1762 /* Set RHS to be the first operand on the RHS of assignment statement GS. */
1765 gimple_assign_set_rhs1 (gimple gs, tree rhs)
1767 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1769 gimple_set_op (gs, 1, rhs);
1773 /* Return the second operand on the RHS of assignment statement GS.
1774 If GS does not have two operands, NULL is returned instead. */
1777 gimple_assign_rhs2 (const_gimple gs)
1779 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1781 if (gimple_num_ops (gs) >= 3)
1782 return gimple_op (gs, 2);
1788 /* Return a pointer to the second operand on the RHS of assignment
1791 static inline tree *
1792 gimple_assign_rhs2_ptr (const_gimple gs)
1794 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1795 return gimple_op_ptr (gs, 2);
1799 /* Set RHS to be the second operand on the RHS of assignment statement GS. */
1802 gimple_assign_set_rhs2 (gimple gs, tree rhs)
1804 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1806 gimple_set_op (gs, 2, rhs);
1809 /* Returns true if GS is a nontemporal move. */
1812 gimple_assign_nontemporal_move_p (const_gimple gs)
1814 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1815 return gs->gsbase.nontemporal_move;
1818 /* Sets nontemporal move flag of GS to NONTEMPORAL. */
1821 gimple_assign_set_nontemporal_move (gimple gs, bool nontemporal)
1823 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1824 gs->gsbase.nontemporal_move = nontemporal;
1828 /* Return the code of the expression computed on the rhs of assignment
1829 statement GS. In case that the RHS is a single object, returns the
1830 tree code of the object. */
1832 static inline enum tree_code
1833 gimple_assign_rhs_code (const_gimple gs)
1835 enum tree_code code;
1836 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1838 code = gimple_expr_code (gs);
1839 if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS)
1840 code = TREE_CODE (gimple_assign_rhs1 (gs));
1846 /* Set CODE to be the code for the expression computed on the RHS of
1850 gimple_assign_set_rhs_code (gimple s, enum tree_code code)
1852 GIMPLE_CHECK (s, GIMPLE_ASSIGN);
1853 s->gsbase.subcode = code;
1857 /* Return the gimple rhs class of the code of the expression computed on
1858 the rhs of assignment statement GS.
1859 This will never return GIMPLE_INVALID_RHS. */
1861 static inline enum gimple_rhs_class
1862 gimple_assign_rhs_class (const_gimple gs)
1864 return get_gimple_rhs_class (gimple_assign_rhs_code (gs));
1868 /* Return true if S is a type-cast assignment. */
1871 gimple_assign_cast_p (gimple s)
1873 if (is_gimple_assign (s))
1875 enum tree_code sc = gimple_assign_rhs_code (s);
1876 return CONVERT_EXPR_CODE_P (sc)
1877 || sc == VIEW_CONVERT_EXPR
1878 || sc == FIX_TRUNC_EXPR;
1885 /* Return true if GS is a GIMPLE_CALL. */
1888 is_gimple_call (const_gimple gs)
1890 return gimple_code (gs) == GIMPLE_CALL;
1893 /* Return the LHS of call statement GS. */
1896 gimple_call_lhs (const_gimple gs)
1898 GIMPLE_CHECK (gs, GIMPLE_CALL);
1899 return gimple_op (gs, 0);
1903 /* Return a pointer to the LHS of call statement GS. */
1905 static inline tree *
1906 gimple_call_lhs_ptr (const_gimple gs)
1908 GIMPLE_CHECK (gs, GIMPLE_CALL);
1909 return gimple_op_ptr (gs, 0);
1913 /* Set LHS to be the LHS operand of call statement GS. */
1916 gimple_call_set_lhs (gimple gs, tree lhs)
1918 GIMPLE_CHECK (gs, GIMPLE_CALL);
1919 gimple_set_op (gs, 0, lhs);
1920 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1921 SSA_NAME_DEF_STMT (lhs) = gs;
1925 /* Return the tree node representing the function called by call
1929 gimple_call_fn (const_gimple gs)
1931 GIMPLE_CHECK (gs, GIMPLE_CALL);
1932 return gimple_op (gs, 1);
1936 /* Return a pointer to the tree node representing the function called by call
1939 static inline tree *
1940 gimple_call_fn_ptr (const_gimple gs)
1942 GIMPLE_CHECK (gs, GIMPLE_CALL);
1943 return gimple_op_ptr (gs, 1);
1947 /* Set FN to be the function called by call statement GS. */
1950 gimple_call_set_fn (gimple gs, tree fn)
1952 GIMPLE_CHECK (gs, GIMPLE_CALL);
1953 gimple_set_op (gs, 1, fn);
1957 /* Set FNDECL to be the function called by call statement GS. */
1960 gimple_call_set_fndecl (gimple gs, tree decl)
1962 GIMPLE_CHECK (gs, GIMPLE_CALL);
1963 gimple_set_op (gs, 1, build_fold_addr_expr_loc (gimple_location (gs), decl));
1967 /* If a given GIMPLE_CALL's callee is a FUNCTION_DECL, return it.
1968 Otherwise return NULL. This function is analogous to
1969 get_callee_fndecl in tree land. */
1972 gimple_call_fndecl (const_gimple gs)
1974 tree addr = gimple_call_fn (gs);
1975 if (TREE_CODE (addr) == ADDR_EXPR)
1976 return TREE_OPERAND (addr, 0);
1981 /* Return the type returned by call statement GS. */
1984 gimple_call_return_type (const_gimple gs)
1986 tree fn = gimple_call_fn (gs);
1987 tree type = TREE_TYPE (fn);
1989 /* See through the pointer. */
1990 type = TREE_TYPE (type);
1992 /* The type returned by a FUNCTION_DECL is the type of its
1994 return TREE_TYPE (type);
1998 /* Return the static chain for call statement GS. */
2001 gimple_call_chain (const_gimple gs)
2003 GIMPLE_CHECK (gs, GIMPLE_CALL);
2004 return gimple_op (gs, 2);
2008 /* Return a pointer to the static chain for call statement GS. */
2010 static inline tree *
2011 gimple_call_chain_ptr (const_gimple gs)
2013 GIMPLE_CHECK (gs, GIMPLE_CALL);
2014 return gimple_op_ptr (gs, 2);
2017 /* Set CHAIN to be the static chain for call statement GS. */
2020 gimple_call_set_chain (gimple gs, tree chain)
2022 GIMPLE_CHECK (gs, GIMPLE_CALL);
2024 gimple_set_op (gs, 2, chain);
2028 /* Return the number of arguments used by call statement GS. */
2030 static inline unsigned
2031 gimple_call_num_args (const_gimple gs)
2034 GIMPLE_CHECK (gs, GIMPLE_CALL);
2035 num_ops = gimple_num_ops (gs);
2040 /* Return the argument at position INDEX for call statement GS. */
2043 gimple_call_arg (const_gimple gs, unsigned index)
2045 GIMPLE_CHECK (gs, GIMPLE_CALL);
2046 return gimple_op (gs, index + 3);
2050 /* Return a pointer to the argument at position INDEX for call
2053 static inline tree *
2054 gimple_call_arg_ptr (const_gimple gs, unsigned index)
2056 GIMPLE_CHECK (gs, GIMPLE_CALL);
2057 return gimple_op_ptr (gs, index + 3);
2061 /* Set ARG to be the argument at position INDEX for call statement GS. */
2064 gimple_call_set_arg (gimple gs, unsigned index, tree arg)
2066 GIMPLE_CHECK (gs, GIMPLE_CALL);
2067 gimple_set_op (gs, index + 3, arg);
2071 /* If TAIL_P is true, mark call statement S as being a tail call
2072 (i.e., a call just before the exit of a function). These calls are
2073 candidate for tail call optimization. */
2076 gimple_call_set_tail (gimple s, bool tail_p)
2078 GIMPLE_CHECK (s, GIMPLE_CALL);
2080 s->gsbase.subcode |= GF_CALL_TAILCALL;
2082 s->gsbase.subcode &= ~GF_CALL_TAILCALL;
2086 /* Return true if GIMPLE_CALL S is marked as a tail call. */
2089 gimple_call_tail_p (gimple s)
2091 GIMPLE_CHECK (s, GIMPLE_CALL);
2092 return (s->gsbase.subcode & GF_CALL_TAILCALL) != 0;
2096 /* Set the inlinable status of GIMPLE_CALL S to INLINABLE_P. */
2099 gimple_call_set_cannot_inline (gimple s, bool inlinable_p)
2101 GIMPLE_CHECK (s, GIMPLE_CALL);
2103 s->gsbase.subcode |= GF_CALL_CANNOT_INLINE;
2105 s->gsbase.subcode &= ~GF_CALL_CANNOT_INLINE;
2109 /* Return true if GIMPLE_CALL S cannot be inlined. */
2112 gimple_call_cannot_inline_p (gimple s)
2114 GIMPLE_CHECK (s, GIMPLE_CALL);
2115 return (s->gsbase.subcode & GF_CALL_CANNOT_INLINE) != 0;
2119 /* If RETURN_SLOT_OPT_P is true mark GIMPLE_CALL S as valid for return
2120 slot optimization. This transformation uses the target of the call
2121 expansion as the return slot for calls that return in memory. */
2124 gimple_call_set_return_slot_opt (gimple s, bool return_slot_opt_p)
2126 GIMPLE_CHECK (s, GIMPLE_CALL);
2127 if (return_slot_opt_p)
2128 s->gsbase.subcode |= GF_CALL_RETURN_SLOT_OPT;
2130 s->gsbase.subcode &= ~GF_CALL_RETURN_SLOT_OPT;
2134 /* Return true if S is marked for return slot optimization. */
2137 gimple_call_return_slot_opt_p (gimple s)
2139 GIMPLE_CHECK (s, GIMPLE_CALL);
2140 return (s->gsbase.subcode & GF_CALL_RETURN_SLOT_OPT) != 0;
2144 /* If FROM_THUNK_P is true, mark GIMPLE_CALL S as being the jump from a
2145 thunk to the thunked-to function. */
2148 gimple_call_set_from_thunk (gimple s, bool from_thunk_p)
2150 GIMPLE_CHECK (s, GIMPLE_CALL);
2152 s->gsbase.subcode |= GF_CALL_FROM_THUNK;
2154 s->gsbase.subcode &= ~GF_CALL_FROM_THUNK;
2158 /* Return true if GIMPLE_CALL S is a jump from a thunk. */
2161 gimple_call_from_thunk_p (gimple s)
2163 GIMPLE_CHECK (s, GIMPLE_CALL);
2164 return (s->gsbase.subcode & GF_CALL_FROM_THUNK) != 0;
2168 /* If PASS_ARG_PACK_P is true, GIMPLE_CALL S is a stdarg call that needs the
2169 argument pack in its argument list. */
2172 gimple_call_set_va_arg_pack (gimple s, bool pass_arg_pack_p)
2174 GIMPLE_CHECK (s, GIMPLE_CALL);
2175 if (pass_arg_pack_p)
2176 s->gsbase.subcode |= GF_CALL_VA_ARG_PACK;
2178 s->gsbase.subcode &= ~GF_CALL_VA_ARG_PACK;
2182 /* Return true if GIMPLE_CALL S is a stdarg call that needs the
2183 argument pack in its argument list. */
2186 gimple_call_va_arg_pack_p (gimple s)
2188 GIMPLE_CHECK (s, GIMPLE_CALL);
2189 return (s->gsbase.subcode & GF_CALL_VA_ARG_PACK) != 0;
2193 /* Return true if S is a noreturn call. */
2196 gimple_call_noreturn_p (gimple s)
2198 GIMPLE_CHECK (s, GIMPLE_CALL);
2199 return (gimple_call_flags (s) & ECF_NORETURN) != 0;
2203 /* If NOTHROW_P is true, GIMPLE_CALL S is a call that is known to not throw
2204 even if the called function can throw in other cases. */
2207 gimple_call_set_nothrow (gimple s, bool nothrow_p)
2209 GIMPLE_CHECK (s, GIMPLE_CALL);
2211 s->gsbase.subcode |= GF_CALL_NOTHROW;
2213 s->gsbase.subcode &= ~GF_CALL_NOTHROW;
2216 /* Return true if S is a nothrow call. */
2219 gimple_call_nothrow_p (gimple s)
2221 GIMPLE_CHECK (s, GIMPLE_CALL);
2222 return (gimple_call_flags (s) & ECF_NOTHROW) != 0;
2226 /* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL. */
2229 gimple_call_copy_flags (gimple dest_call, gimple orig_call)
2231 GIMPLE_CHECK (dest_call, GIMPLE_CALL);
2232 GIMPLE_CHECK (orig_call, GIMPLE_CALL);
2233 dest_call->gsbase.subcode = orig_call->gsbase.subcode;
2237 /* Return a pointer to the points-to solution for the set of call-used
2238 variables of the call CALL. */
2240 static inline struct pt_solution *
2241 gimple_call_use_set (gimple call)
2243 GIMPLE_CHECK (call, GIMPLE_CALL);
2244 return &call->gimple_call.call_used;
2248 /* Return a pointer to the points-to solution for the set of call-used
2249 variables of the call CALL. */
2251 static inline struct pt_solution *
2252 gimple_call_clobber_set (gimple call)
2254 GIMPLE_CHECK (call, GIMPLE_CALL);
2255 return &call->gimple_call.call_clobbered;
2259 /* Returns true if this is a GIMPLE_ASSIGN or a GIMPLE_CALL with a
2263 gimple_has_lhs (gimple stmt)
2265 return (is_gimple_assign (stmt)
2266 || (is_gimple_call (stmt)
2267 && gimple_call_lhs (stmt) != NULL_TREE));
2271 /* Return the code of the predicate computed by conditional statement GS. */
2273 static inline enum tree_code
2274 gimple_cond_code (const_gimple gs)
2276 GIMPLE_CHECK (gs, GIMPLE_COND);
2277 return (enum tree_code) gs->gsbase.subcode;
2281 /* Set CODE to be the predicate code for the conditional statement GS. */
2284 gimple_cond_set_code (gimple gs, enum tree_code code)
2286 GIMPLE_CHECK (gs, GIMPLE_COND);
2287 gs->gsbase.subcode = code;
2291 /* Return the LHS of the predicate computed by conditional statement GS. */
2294 gimple_cond_lhs (const_gimple gs)
2296 GIMPLE_CHECK (gs, GIMPLE_COND);
2297 return gimple_op (gs, 0);
2300 /* Return the pointer to the LHS of the predicate computed by conditional
2303 static inline tree *
2304 gimple_cond_lhs_ptr (const_gimple gs)
2306 GIMPLE_CHECK (gs, GIMPLE_COND);
2307 return gimple_op_ptr (gs, 0);
2310 /* Set LHS to be the LHS operand of the predicate computed by
2311 conditional statement GS. */
2314 gimple_cond_set_lhs (gimple gs, tree lhs)
2316 GIMPLE_CHECK (gs, GIMPLE_COND);
2317 gimple_set_op (gs, 0, lhs);
2321 /* Return the RHS operand of the predicate computed by conditional GS. */
2324 gimple_cond_rhs (const_gimple gs)
2326 GIMPLE_CHECK (gs, GIMPLE_COND);
2327 return gimple_op (gs, 1);
2330 /* Return the pointer to the RHS operand of the predicate computed by
2333 static inline tree *
2334 gimple_cond_rhs_ptr (const_gimple gs)
2336 GIMPLE_CHECK (gs, GIMPLE_COND);
2337 return gimple_op_ptr (gs, 1);
2341 /* Set RHS to be the RHS operand of the predicate computed by
2342 conditional statement GS. */
2345 gimple_cond_set_rhs (gimple gs, tree rhs)
2347 GIMPLE_CHECK (gs, GIMPLE_COND);
2348 gimple_set_op (gs, 1, rhs);
2352 /* Return the label used by conditional statement GS when its
2353 predicate evaluates to true. */
2356 gimple_cond_true_label (const_gimple gs)
2358 GIMPLE_CHECK (gs, GIMPLE_COND);
2359 return gimple_op (gs, 2);
2363 /* Set LABEL to be the label used by conditional statement GS when its
2364 predicate evaluates to true. */
2367 gimple_cond_set_true_label (gimple gs, tree label)
2369 GIMPLE_CHECK (gs, GIMPLE_COND);
2370 gimple_set_op (gs, 2, label);
2374 /* Set LABEL to be the label used by conditional statement GS when its
2375 predicate evaluates to false. */
2378 gimple_cond_set_false_label (gimple gs, tree label)
2380 GIMPLE_CHECK (gs, GIMPLE_COND);
2381 gimple_set_op (gs, 3, label);
2385 /* Return the label used by conditional statement GS when its
2386 predicate evaluates to false. */
2389 gimple_cond_false_label (const_gimple gs)
2391 GIMPLE_CHECK (gs, GIMPLE_COND);
2392 return gimple_op (gs, 3);
2396 /* Set the conditional COND_STMT to be of the form 'if (1 == 0)'. */
2399 gimple_cond_make_false (gimple gs)
2401 gimple_cond_set_lhs (gs, boolean_true_node);
2402 gimple_cond_set_rhs (gs, boolean_false_node);
2403 gs->gsbase.subcode = EQ_EXPR;
2407 /* Set the conditional COND_STMT to be of the form 'if (1 == 1)'. */
2410 gimple_cond_make_true (gimple gs)
2412 gimple_cond_set_lhs (gs, boolean_true_node);
2413 gimple_cond_set_rhs (gs, boolean_true_node);
2414 gs->gsbase.subcode = EQ_EXPR;
2417 /* Check if conditional statemente GS is of the form 'if (1 == 1)',
2418 'if (0 == 0)', 'if (1 != 0)' or 'if (0 != 1)' */
2421 gimple_cond_true_p (const_gimple gs)
2423 tree lhs = gimple_cond_lhs (gs);
2424 tree rhs = gimple_cond_rhs (gs);
2425 enum tree_code code = gimple_cond_code (gs);
2427 if (lhs != boolean_true_node && lhs != boolean_false_node)
2430 if (rhs != boolean_true_node && rhs != boolean_false_node)
2433 if (code == NE_EXPR && lhs != rhs)
2436 if (code == EQ_EXPR && lhs == rhs)
2442 /* Check if conditional statement GS is of the form 'if (1 != 1)',
2443 'if (0 != 0)', 'if (1 == 0)' or 'if (0 == 1)' */
2446 gimple_cond_false_p (const_gimple gs)
2448 tree lhs = gimple_cond_lhs (gs);
2449 tree rhs = gimple_cond_rhs (gs);
2450 enum tree_code code = gimple_cond_code (gs);
2452 if (lhs != boolean_true_node && lhs != boolean_false_node)
2455 if (rhs != boolean_true_node && rhs != boolean_false_node)
2458 if (code == NE_EXPR && lhs == rhs)
2461 if (code == EQ_EXPR && lhs != rhs)
2467 /* Check if conditional statement GS is of the form 'if (var != 0)' or
2471 gimple_cond_single_var_p (gimple gs)
2473 if (gimple_cond_code (gs) == NE_EXPR
2474 && gimple_cond_rhs (gs) == boolean_false_node)
2477 if (gimple_cond_code (gs) == EQ_EXPR
2478 && gimple_cond_rhs (gs) == boolean_true_node)
2484 /* Set the code, LHS and RHS of GIMPLE_COND STMT from CODE, LHS and RHS. */
2487 gimple_cond_set_condition (gimple stmt, enum tree_code code, tree lhs, tree rhs)
2489 gimple_cond_set_code (stmt, code);
2490 gimple_cond_set_lhs (stmt, lhs);
2491 gimple_cond_set_rhs (stmt, rhs);
2494 /* Return the LABEL_DECL node used by GIMPLE_LABEL statement GS. */
2497 gimple_label_label (const_gimple gs)
2499 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2500 return gimple_op (gs, 0);
2504 /* Set LABEL to be the LABEL_DECL node used by GIMPLE_LABEL statement
2508 gimple_label_set_label (gimple gs, tree label)
2510 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2511 gimple_set_op (gs, 0, label);
2515 /* Return the destination of the unconditional jump GS. */
2518 gimple_goto_dest (const_gimple gs)
2520 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2521 return gimple_op (gs, 0);
2525 /* Set DEST to be the destination of the unconditonal jump GS. */
2528 gimple_goto_set_dest (gimple gs, tree dest)
2530 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2531 gimple_set_op (gs, 0, dest);
2535 /* Return the variables declared in the GIMPLE_BIND statement GS. */
2538 gimple_bind_vars (const_gimple gs)
2540 GIMPLE_CHECK (gs, GIMPLE_BIND);
2541 return gs->gimple_bind.vars;
2545 /* Set VARS to be the set of variables declared in the GIMPLE_BIND
2549 gimple_bind_set_vars (gimple gs, tree vars)
2551 GIMPLE_CHECK (gs, GIMPLE_BIND);
2552 gs->gimple_bind.vars = vars;
2556 /* Append VARS to the set of variables declared in the GIMPLE_BIND
2560 gimple_bind_append_vars (gimple gs, tree vars)
2562 GIMPLE_CHECK (gs, GIMPLE_BIND);
2563 gs->gimple_bind.vars = chainon (gs->gimple_bind.vars, vars);
2567 /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS. */
2569 static inline gimple_seq
2570 gimple_bind_body (gimple gs)
2572 GIMPLE_CHECK (gs, GIMPLE_BIND);
2573 return gs->gimple_bind.body;
2577 /* Set SEQ to be the GIMPLE sequence contained in the GIMPLE_BIND
2581 gimple_bind_set_body (gimple gs, gimple_seq seq)
2583 GIMPLE_CHECK (gs, GIMPLE_BIND);
2584 gs->gimple_bind.body = seq;
2588 /* Append a statement to the end of a GIMPLE_BIND's body. */
2591 gimple_bind_add_stmt (gimple gs, gimple stmt)
2593 GIMPLE_CHECK (gs, GIMPLE_BIND);
2594 gimple_seq_add_stmt (&gs->gimple_bind.body, stmt);
2598 /* Append a sequence of statements to the end of a GIMPLE_BIND's body. */
2601 gimple_bind_add_seq (gimple gs, gimple_seq seq)
2603 GIMPLE_CHECK (gs, GIMPLE_BIND);
2604 gimple_seq_add_seq (&gs->gimple_bind.body, seq);
2608 /* Return the TREE_BLOCK node associated with GIMPLE_BIND statement
2609 GS. This is analogous to the BIND_EXPR_BLOCK field in trees. */
2612 gimple_bind_block (const_gimple gs)
2614 GIMPLE_CHECK (gs, GIMPLE_BIND);
2615 return gs->gimple_bind.block;
2619 /* Set BLOCK to be the TREE_BLOCK node associated with GIMPLE_BIND
2623 gimple_bind_set_block (gimple gs, tree block)
2625 GIMPLE_CHECK (gs, GIMPLE_BIND);
2626 gcc_gimple_checking_assert (block == NULL_TREE
2627 || TREE_CODE (block) == BLOCK);
2628 gs->gimple_bind.block = block;
2632 /* Return the number of input operands for GIMPLE_ASM GS. */
2634 static inline unsigned
2635 gimple_asm_ninputs (const_gimple gs)
2637 GIMPLE_CHECK (gs, GIMPLE_ASM);
2638 return gs->gimple_asm.ni;
2642 /* Return the number of output operands for GIMPLE_ASM GS. */
2644 static inline unsigned
2645 gimple_asm_noutputs (const_gimple gs)
2647 GIMPLE_CHECK (gs, GIMPLE_ASM);
2648 return gs->gimple_asm.no;
2652 /* Return the number of clobber operands for GIMPLE_ASM GS. */
2654 static inline unsigned
2655 gimple_asm_nclobbers (const_gimple gs)
2657 GIMPLE_CHECK (gs, GIMPLE_ASM);
2658 return gs->gimple_asm.nc;
2661 /* Return the number of label operands for GIMPLE_ASM GS. */
2663 static inline unsigned
2664 gimple_asm_nlabels (const_gimple gs)
2666 GIMPLE_CHECK (gs, GIMPLE_ASM);
2667 return gs->gimple_asm.nl;
2670 /* Return input operand INDEX of GIMPLE_ASM GS. */
2673 gimple_asm_input_op (const_gimple gs, unsigned index)
2675 GIMPLE_CHECK (gs, GIMPLE_ASM);
2676 gcc_gimple_checking_assert (index <= gs->gimple_asm.ni);
2677 return gimple_op (gs, index);
2680 /* Return a pointer to input operand INDEX of GIMPLE_ASM GS. */
2682 static inline tree *
2683 gimple_asm_input_op_ptr (const_gimple gs, unsigned index)
2685 GIMPLE_CHECK (gs, GIMPLE_ASM);
2686 gcc_gimple_checking_assert (index <= gs->gimple_asm.ni);
2687 return gimple_op_ptr (gs, index);
2691 /* Set IN_OP to be input operand INDEX in GIMPLE_ASM GS. */
2694 gimple_asm_set_input_op (gimple gs, unsigned index, tree in_op)
2696 GIMPLE_CHECK (gs, GIMPLE_ASM);
2697 gcc_gimple_checking_assert (index <= gs->gimple_asm.ni
2698 && TREE_CODE (in_op) == TREE_LIST);
2699 gimple_set_op (gs, index, in_op);
2703 /* Return output operand INDEX of GIMPLE_ASM GS. */
2706 gimple_asm_output_op (const_gimple gs, unsigned index)
2708 GIMPLE_CHECK (gs, GIMPLE_ASM);
2709 gcc_gimple_checking_assert (index <= gs->gimple_asm.no);
2710 return gimple_op (gs, index + gs->gimple_asm.ni);
2713 /* Return a pointer to output operand INDEX of GIMPLE_ASM GS. */
2715 static inline tree *
2716 gimple_asm_output_op_ptr (const_gimple gs, unsigned index)
2718 GIMPLE_CHECK (gs, GIMPLE_ASM);
2719 gcc_gimple_checking_assert (index <= gs->gimple_asm.no);
2720 return gimple_op_ptr (gs, index + gs->gimple_asm.ni);
2724 /* Set OUT_OP to be output operand INDEX in GIMPLE_ASM GS. */
2727 gimple_asm_set_output_op (gimple gs, unsigned index, tree out_op)
2729 GIMPLE_CHECK (gs, GIMPLE_ASM);
2730 gcc_gimple_checking_assert (index <= gs->gimple_asm.no
2731 && TREE_CODE (out_op) == TREE_LIST);
2732 gimple_set_op (gs, index + gs->gimple_asm.ni, out_op);
2736 /* Return clobber operand INDEX of GIMPLE_ASM GS. */
2739 gimple_asm_clobber_op (const_gimple gs, unsigned index)
2741 GIMPLE_CHECK (gs, GIMPLE_ASM);
2742 gcc_gimple_checking_assert (index <= gs->gimple_asm.nc);
2743 return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no);
2747 /* Set CLOBBER_OP to be clobber operand INDEX in GIMPLE_ASM GS. */
2750 gimple_asm_set_clobber_op (gimple gs, unsigned index, tree clobber_op)
2752 GIMPLE_CHECK (gs, GIMPLE_ASM);
2753 gcc_gimple_checking_assert (index <= gs->gimple_asm.nc
2754 && TREE_CODE (clobber_op) == TREE_LIST);
2755 gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no, clobber_op);
2758 /* Return label operand INDEX of GIMPLE_ASM GS. */
2761 gimple_asm_label_op (const_gimple gs, unsigned index)
2763 GIMPLE_CHECK (gs, GIMPLE_ASM);
2764 gcc_gimple_checking_assert (index <= gs->gimple_asm.nl);
2765 return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.nc);
2768 /* Set LABEL_OP to be label operand INDEX in GIMPLE_ASM GS. */
2771 gimple_asm_set_label_op (gimple gs, unsigned index, tree label_op)
2773 GIMPLE_CHECK (gs, GIMPLE_ASM);
2774 gcc_gimple_checking_assert (index <= gs->gimple_asm.nl
2775 && TREE_CODE (label_op) == TREE_LIST);
2776 gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.nc, label_op);
2779 /* Return the string representing the assembly instruction in
2782 static inline const char *
2783 gimple_asm_string (const_gimple gs)
2785 GIMPLE_CHECK (gs, GIMPLE_ASM);
2786 return gs->gimple_asm.string;
2790 /* Return true if GS is an asm statement marked volatile. */
2793 gimple_asm_volatile_p (const_gimple gs)
2795 GIMPLE_CHECK (gs, GIMPLE_ASM);
2796 return (gs->gsbase.subcode & GF_ASM_VOLATILE) != 0;
2800 /* If VOLATLE_P is true, mark asm statement GS as volatile. */
2803 gimple_asm_set_volatile (gimple gs, bool volatile_p)
2805 GIMPLE_CHECK (gs, GIMPLE_ASM);
2807 gs->gsbase.subcode |= GF_ASM_VOLATILE;
2809 gs->gsbase.subcode &= ~GF_ASM_VOLATILE;
2813 /* If INPUT_P is true, mark asm GS as an ASM_INPUT. */
2816 gimple_asm_set_input (gimple gs, bool input_p)
2818 GIMPLE_CHECK (gs, GIMPLE_ASM);
2820 gs->gsbase.subcode |= GF_ASM_INPUT;
2822 gs->gsbase.subcode &= ~GF_ASM_INPUT;
2826 /* Return true if asm GS is an ASM_INPUT. */
2829 gimple_asm_input_p (const_gimple gs)
2831 GIMPLE_CHECK (gs, GIMPLE_ASM);
2832 return (gs->gsbase.subcode & GF_ASM_INPUT) != 0;
2836 /* Return the types handled by GIMPLE_CATCH statement GS. */
2839 gimple_catch_types (const_gimple gs)
2841 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2842 return gs->gimple_catch.types;
2846 /* Return a pointer to the types handled by GIMPLE_CATCH statement GS. */
2848 static inline tree *
2849 gimple_catch_types_ptr (gimple gs)
2851 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2852 return &gs->gimple_catch.types;
2856 /* Return the GIMPLE sequence representing the body of the handler of
2857 GIMPLE_CATCH statement GS. */
2859 static inline gimple_seq
2860 gimple_catch_handler (gimple gs)
2862 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2863 return gs->gimple_catch.handler;
2867 /* Return a pointer to the GIMPLE sequence representing the body of
2868 the handler of GIMPLE_CATCH statement GS. */
2870 static inline gimple_seq *
2871 gimple_catch_handler_ptr (gimple gs)
2873 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2874 return &gs->gimple_catch.handler;
2878 /* Set T to be the set of types handled by GIMPLE_CATCH GS. */
2881 gimple_catch_set_types (gimple gs, tree t)
2883 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2884 gs->gimple_catch.types = t;
2888 /* Set HANDLER to be the body of GIMPLE_CATCH GS. */
2891 gimple_catch_set_handler (gimple gs, gimple_seq handler)
2893 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2894 gs->gimple_catch.handler = handler;
2898 /* Return the types handled by GIMPLE_EH_FILTER statement GS. */
2901 gimple_eh_filter_types (const_gimple gs)
2903 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2904 return gs->gimple_eh_filter.types;
2908 /* Return a pointer to the types handled by GIMPLE_EH_FILTER statement
2911 static inline tree *
2912 gimple_eh_filter_types_ptr (gimple gs)
2914 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2915 return &gs->gimple_eh_filter.types;
2919 /* Return the sequence of statement to execute when GIMPLE_EH_FILTER
2922 static inline gimple_seq
2923 gimple_eh_filter_failure (gimple gs)
2925 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2926 return gs->gimple_eh_filter.failure;
2930 /* Set TYPES to be the set of types handled by GIMPLE_EH_FILTER GS. */
2933 gimple_eh_filter_set_types (gimple gs, tree types)
2935 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2936 gs->gimple_eh_filter.types = types;
2940 /* Set FAILURE to be the sequence of statements to execute on failure
2941 for GIMPLE_EH_FILTER GS. */
2944 gimple_eh_filter_set_failure (gimple gs, gimple_seq failure)
2946 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2947 gs->gimple_eh_filter.failure = failure;
2950 /* Get the function decl to be called by the MUST_NOT_THROW region. */
2953 gimple_eh_must_not_throw_fndecl (gimple gs)
2955 GIMPLE_CHECK (gs, GIMPLE_EH_MUST_NOT_THROW);
2956 return gs->gimple_eh_mnt.fndecl;
2959 /* Set the function decl to be called by GS to DECL. */
2962 gimple_eh_must_not_throw_set_fndecl (gimple gs, tree decl)
2964 GIMPLE_CHECK (gs, GIMPLE_EH_MUST_NOT_THROW);
2965 gs->gimple_eh_mnt.fndecl = decl;
2969 /* GIMPLE_TRY accessors. */
2971 /* Return the kind of try block represented by GIMPLE_TRY GS. This is
2972 either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY. */
2974 static inline enum gimple_try_flags
2975 gimple_try_kind (const_gimple gs)
2977 GIMPLE_CHECK (gs, GIMPLE_TRY);
2978 return (enum gimple_try_flags) (gs->gsbase.subcode & GIMPLE_TRY_KIND);
2982 /* Set the kind of try block represented by GIMPLE_TRY GS. */
2985 gimple_try_set_kind (gimple gs, enum gimple_try_flags kind)
2987 GIMPLE_CHECK (gs, GIMPLE_TRY);
2988 gcc_gimple_checking_assert (kind == GIMPLE_TRY_CATCH
2989 || kind == GIMPLE_TRY_FINALLY);
2990 if (gimple_try_kind (gs) != kind)
2991 gs->gsbase.subcode = (unsigned int) kind;
2995 /* Return the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2998 gimple_try_catch_is_cleanup (const_gimple gs)
3000 gcc_gimple_checking_assert (gimple_try_kind (gs) == GIMPLE_TRY_CATCH);
3001 return (gs->gsbase.subcode & GIMPLE_TRY_CATCH_IS_CLEANUP) != 0;
3005 /* Return the sequence of statements used as the body for GIMPLE_TRY GS. */
3007 static inline gimple_seq
3008 gimple_try_eval (gimple gs)
3010 GIMPLE_CHECK (gs, GIMPLE_TRY);
3011 return gs->gimple_try.eval;
3015 /* Return the sequence of statements used as the cleanup body for
3018 static inline gimple_seq
3019 gimple_try_cleanup (gimple gs)
3021 GIMPLE_CHECK (gs, GIMPLE_TRY);
3022 return gs->gimple_try.cleanup;
3026 /* Set the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
3029 gimple_try_set_catch_is_cleanup (gimple g, bool catch_is_cleanup)
3031 gcc_gimple_checking_assert (gimple_try_kind (g) == GIMPLE_TRY_CATCH);
3032 if (catch_is_cleanup)
3033 g->gsbase.subcode |= GIMPLE_TRY_CATCH_IS_CLEANUP;
3035 g->gsbase.subcode &= ~GIMPLE_TRY_CATCH_IS_CLEANUP;
3039 /* Set EVAL to be the sequence of statements to use as the body for
3043 gimple_try_set_eval (gimple gs, gimple_seq eval)
3045 GIMPLE_CHECK (gs, GIMPLE_TRY);
3046 gs->gimple_try.eval = eval;
3050 /* Set CLEANUP to be the sequence of statements to use as the cleanup
3051 body for GIMPLE_TRY GS. */
3054 gimple_try_set_cleanup (gimple gs, gimple_seq cleanup)
3056 GIMPLE_CHECK (gs, GIMPLE_TRY);
3057 gs->gimple_try.cleanup = cleanup;
3061 /* Return the cleanup sequence for cleanup statement GS. */
3063 static inline gimple_seq
3064 gimple_wce_cleanup (gimple gs)
3066 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3067 return gs->gimple_wce.cleanup;
3071 /* Set CLEANUP to be the cleanup sequence for GS. */
3074 gimple_wce_set_cleanup (gimple gs, gimple_seq cleanup)
3076 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3077 gs->gimple_wce.cleanup = cleanup;
3081 /* Return the CLEANUP_EH_ONLY flag for a WCE tuple. */
3084 gimple_wce_cleanup_eh_only (const_gimple gs)
3086 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3087 return gs->gsbase.subcode != 0;
3091 /* Set the CLEANUP_EH_ONLY flag for a WCE tuple. */
3094 gimple_wce_set_cleanup_eh_only (gimple gs, bool eh_only_p)
3096 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3097 gs->gsbase.subcode = (unsigned int) eh_only_p;
3101 /* Return the maximum number of arguments supported by GIMPLE_PHI GS. */
3103 static inline unsigned
3104 gimple_phi_capacity (const_gimple gs)
3106 GIMPLE_CHECK (gs, GIMPLE_PHI);
3107 return gs->gimple_phi.capacity;
3111 /* Return the number of arguments in GIMPLE_PHI GS. This must always
3112 be exactly the number of incoming edges for the basic block holding
3115 static inline unsigned
3116 gimple_phi_num_args (const_gimple gs)
3118 GIMPLE_CHECK (gs, GIMPLE_PHI);
3119 return gs->gimple_phi.nargs;
3123 /* Return the SSA name created by GIMPLE_PHI GS. */
3126 gimple_phi_result (const_gimple gs)
3128 GIMPLE_CHECK (gs, GIMPLE_PHI);
3129 return gs->gimple_phi.result;
3132 /* Return a pointer to the SSA name created by GIMPLE_PHI GS. */
3134 static inline tree *
3135 gimple_phi_result_ptr (gimple gs)
3137 GIMPLE_CHECK (gs, GIMPLE_PHI);
3138 return &gs->gimple_phi.result;
3141 /* Set RESULT to be the SSA name created by GIMPLE_PHI GS. */
3144 gimple_phi_set_result (gimple gs, tree result)
3146 GIMPLE_CHECK (gs, GIMPLE_PHI);
3147 gs->gimple_phi.result = result;
3151 /* Return the PHI argument corresponding to incoming edge INDEX for
3154 static inline struct phi_arg_d *
3155 gimple_phi_arg (gimple gs, unsigned index)
3157 GIMPLE_CHECK (gs, GIMPLE_PHI);
3158 gcc_gimple_checking_assert (index <= gs->gimple_phi.capacity);
3159 return &(gs->gimple_phi.args[index]);
3162 /* Set PHIARG to be the argument corresponding to incoming edge INDEX
3163 for GIMPLE_PHI GS. */
3166 gimple_phi_set_arg (gimple gs, unsigned index, struct phi_arg_d * phiarg)
3168 GIMPLE_CHECK (gs, GIMPLE_PHI);
3169 gcc_gimple_checking_assert (index <= gs->gimple_phi.nargs);
3170 gs->gimple_phi.args[index] = *phiarg;
3173 /* Return the region number for GIMPLE_RESX GS. */
3176 gimple_resx_region (const_gimple gs)
3178 GIMPLE_CHECK (gs, GIMPLE_RESX);
3179 return gs->gimple_eh_ctrl.region;
3182 /* Set REGION to be the region number for GIMPLE_RESX GS. */
3185 gimple_resx_set_region (gimple gs, int region)
3187 GIMPLE_CHECK (gs, GIMPLE_RESX);
3188 gs->gimple_eh_ctrl.region = region;
3191 /* Return the region number for GIMPLE_EH_DISPATCH GS. */
3194 gimple_eh_dispatch_region (const_gimple gs)
3196 GIMPLE_CHECK (gs, GIMPLE_EH_DISPATCH);
3197 return gs->gimple_eh_ctrl.region;
3200 /* Set REGION to be the region number for GIMPLE_EH_DISPATCH GS. */
3203 gimple_eh_dispatch_set_region (gimple gs, int region)
3205 GIMPLE_CHECK (gs, GIMPLE_EH_DISPATCH);
3206 gs->gimple_eh_ctrl.region = region;
3209 /* Return the number of labels associated with the switch statement GS. */
3211 static inline unsigned
3212 gimple_switch_num_labels (const_gimple gs)
3215 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3216 num_ops = gimple_num_ops (gs);
3217 gcc_gimple_checking_assert (num_ops > 1);
3222 /* Set NLABELS to be the number of labels for the switch statement GS. */
3225 gimple_switch_set_num_labels (gimple g, unsigned nlabels)
3227 GIMPLE_CHECK (g, GIMPLE_SWITCH);
3228 gimple_set_num_ops (g, nlabels + 1);
3232 /* Return the index variable used by the switch statement GS. */
3235 gimple_switch_index (const_gimple gs)
3237 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3238 return gimple_op (gs, 0);
3242 /* Return a pointer to the index variable for the switch statement GS. */
3244 static inline tree *
3245 gimple_switch_index_ptr (const_gimple gs)
3247 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3248 return gimple_op_ptr (gs, 0);
3252 /* Set INDEX to be the index variable for switch statement GS. */
3255 gimple_switch_set_index (gimple gs, tree index)
3257 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3258 gcc_gimple_checking_assert (SSA_VAR_P (index) || CONSTANT_CLASS_P (index));
3259 gimple_set_op (gs, 0, index);
3263 /* Return the label numbered INDEX. The default label is 0, followed by any
3264 labels in a switch statement. */
3267 gimple_switch_label (const_gimple gs, unsigned index)
3269 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3270 gcc_gimple_checking_assert (gimple_num_ops (gs) > index + 1);
3271 return gimple_op (gs, index + 1);
3274 /* Set the label number INDEX to LABEL. 0 is always the default label. */
3277 gimple_switch_set_label (gimple gs, unsigned index, tree label)
3279 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3280 gcc_gimple_checking_assert (gimple_num_ops (gs) > index + 1
3281 && (label == NULL_TREE
3282 || TREE_CODE (label) == CASE_LABEL_EXPR));
3283 gimple_set_op (gs, index + 1, label);
3286 /* Return the default label for a switch statement. */
3289 gimple_switch_default_label (const_gimple gs)
3291 return gimple_switch_label (gs, 0);
3294 /* Set the default label for a switch statement. */
3297 gimple_switch_set_default_label (gimple gs, tree label)
3299 gimple_switch_set_label (gs, 0, label);
3302 /* Return true if GS is a GIMPLE_DEBUG statement. */
3305 is_gimple_debug (const_gimple gs)
3307 return gimple_code (gs) == GIMPLE_DEBUG;
3310 /* Return true if S is a GIMPLE_DEBUG BIND statement. */
3313 gimple_debug_bind_p (const_gimple s)
3315 if (is_gimple_debug (s))
3316 return s->gsbase.subcode == GIMPLE_DEBUG_BIND;
3321 /* Return the variable bound in a GIMPLE_DEBUG bind statement. */
3324 gimple_debug_bind_get_var (gimple dbg)
3326 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3327 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3328 return gimple_op (dbg, 0);
3331 /* Return the value bound to the variable in a GIMPLE_DEBUG bind
3335 gimple_debug_bind_get_value (gimple dbg)
3337 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3338 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3339 return gimple_op (dbg, 1);
3342 /* Return a pointer to the value bound to the variable in a
3343 GIMPLE_DEBUG bind statement. */
3345 static inline tree *
3346 gimple_debug_bind_get_value_ptr (gimple dbg)
3348 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3349 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3350 return gimple_op_ptr (dbg, 1);
3353 /* Set the variable bound in a GIMPLE_DEBUG bind statement. */
3356 gimple_debug_bind_set_var (gimple dbg, tree var)
3358 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3359 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3360 gimple_set_op (dbg, 0, var);
3363 /* Set the value bound to the variable in a GIMPLE_DEBUG bind
3367 gimple_debug_bind_set_value (gimple dbg, tree value)
3369 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3370 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3371 gimple_set_op (dbg, 1, value);
3374 /* The second operand of a GIMPLE_DEBUG_BIND, when the value was
3376 #define GIMPLE_DEBUG_BIND_NOVALUE NULL_TREE /* error_mark_node */
3378 /* Remove the value bound to the variable in a GIMPLE_DEBUG bind
3382 gimple_debug_bind_reset_value (gimple dbg)
3384 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3385 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3386 gimple_set_op (dbg, 1, GIMPLE_DEBUG_BIND_NOVALUE);
3389 /* Return true if the GIMPLE_DEBUG bind statement is bound to a
3393 gimple_debug_bind_has_value_p (gimple dbg)
3395 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3396 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3397 return gimple_op (dbg, 1) != GIMPLE_DEBUG_BIND_NOVALUE;
3400 #undef GIMPLE_DEBUG_BIND_NOVALUE
3402 /* Return the body for the OMP statement GS. */
3404 static inline gimple_seq
3405 gimple_omp_body (gimple gs)
3407 return gs->omp.body;
3410 /* Set BODY to be the body for the OMP statement GS. */
3413 gimple_omp_set_body (gimple gs, gimple_seq body)
3415 gs->omp.body = body;
3419 /* Return the name associated with OMP_CRITICAL statement GS. */
3422 gimple_omp_critical_name (const_gimple gs)
3424 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3425 return gs->gimple_omp_critical.name;
3429 /* Return a pointer to the name associated with OMP critical statement GS. */
3431 static inline tree *
3432 gimple_omp_critical_name_ptr (gimple gs)
3434 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3435 return &gs->gimple_omp_critical.name;
3439 /* Set NAME to be the name associated with OMP critical statement GS. */
3442 gimple_omp_critical_set_name (gimple gs, tree name)
3444 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3445 gs->gimple_omp_critical.name = name;
3449 /* Return the clauses associated with OMP_FOR GS. */
3452 gimple_omp_for_clauses (const_gimple gs)
3454 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3455 return gs->gimple_omp_for.clauses;
3459 /* Return a pointer to the OMP_FOR GS. */
3461 static inline tree *
3462 gimple_omp_for_clauses_ptr (gimple gs)
3464 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3465 return &gs->gimple_omp_for.clauses;
3469 /* Set CLAUSES to be the list of clauses associated with OMP_FOR GS. */
3472 gimple_omp_for_set_clauses (gimple gs, tree clauses)
3474 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3475 gs->gimple_omp_for.clauses = clauses;
3479 /* Get the collapse count of OMP_FOR GS. */
3481 static inline size_t
3482 gimple_omp_for_collapse (gimple gs)
3484 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3485 return gs->gimple_omp_for.collapse;
3489 /* Return the index variable for OMP_FOR GS. */
3492 gimple_omp_for_index (const_gimple gs, size_t i)
3494 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3495 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3496 return gs->gimple_omp_for.iter[i].index;
3500 /* Return a pointer to the index variable for OMP_FOR GS. */
3502 static inline tree *
3503 gimple_omp_for_index_ptr (gimple gs, size_t i)
3505 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3506 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3507 return &gs->gimple_omp_for.iter[i].index;
3511 /* Set INDEX to be the index variable for OMP_FOR GS. */
3514 gimple_omp_for_set_index (gimple gs, size_t i, tree index)
3516 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3517 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3518 gs->gimple_omp_for.iter[i].index = index;
3522 /* Return the initial value for OMP_FOR GS. */
3525 gimple_omp_for_initial (const_gimple gs, size_t i)
3527 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3528 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3529 return gs->gimple_omp_for.iter[i].initial;
3533 /* Return a pointer to the initial value for OMP_FOR GS. */
3535 static inline tree *
3536 gimple_omp_for_initial_ptr (gimple gs, size_t i)
3538 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3539 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3540 return &gs->gimple_omp_for.iter[i].initial;
3544 /* Set INITIAL to be the initial value for OMP_FOR GS. */
3547 gimple_omp_for_set_initial (gimple gs, size_t i, tree initial)
3549 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3550 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3551 gs->gimple_omp_for.iter[i].initial = initial;
3555 /* Return the final value for OMP_FOR GS. */
3558 gimple_omp_for_final (const_gimple gs, size_t i)
3560 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3561 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3562 return gs->gimple_omp_for.iter[i].final;
3566 /* Return a pointer to the final value for OMP_FOR GS. */
3568 static inline tree *
3569 gimple_omp_for_final_ptr (gimple gs, size_t i)
3571 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3572 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3573 return &gs->gimple_omp_for.iter[i].final;
3577 /* Set FINAL to be the final value for OMP_FOR GS. */
3580 gimple_omp_for_set_final (gimple gs, size_t i, tree final)
3582 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3583 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3584 gs->gimple_omp_for.iter[i].final = final;
3588 /* Return the increment value for OMP_FOR GS. */
3591 gimple_omp_for_incr (const_gimple gs, size_t i)
3593 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3594 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3595 return gs->gimple_omp_for.iter[i].incr;
3599 /* Return a pointer to the increment value for OMP_FOR GS. */
3601 static inline tree *
3602 gimple_omp_for_incr_ptr (gimple gs, size_t i)
3604 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3605 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3606 return &gs->gimple_omp_for.iter[i].incr;
3610 /* Set INCR to be the increment value for OMP_FOR GS. */
3613 gimple_omp_for_set_incr (gimple gs, size_t i, tree incr)
3615 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3616 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3617 gs->gimple_omp_for.iter[i].incr = incr;
3621 /* Return the sequence of statements to execute before the OMP_FOR
3622 statement GS starts. */
3624 static inline gimple_seq
3625 gimple_omp_for_pre_body (gimple gs)
3627 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3628 return gs->gimple_omp_for.pre_body;
3632 /* Set PRE_BODY to be the sequence of statements to execute before the
3633 OMP_FOR statement GS starts. */
3636 gimple_omp_for_set_pre_body (gimple gs, gimple_seq pre_body)
3638 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3639 gs->gimple_omp_for.pre_body = pre_body;
3643 /* Return the clauses associated with OMP_PARALLEL GS. */
3646 gimple_omp_parallel_clauses (const_gimple gs)
3648 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3649 return gs->gimple_omp_parallel.clauses;
3653 /* Return a pointer to the clauses associated with OMP_PARALLEL GS. */
3655 static inline tree *
3656 gimple_omp_parallel_clauses_ptr (gimple gs)
3658 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3659 return &gs->gimple_omp_parallel.clauses;
3663 /* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL
3667 gimple_omp_parallel_set_clauses (gimple gs, tree clauses)
3669 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3670 gs->gimple_omp_parallel.clauses = clauses;
3674 /* Return the child function used to hold the body of OMP_PARALLEL GS. */
3677 gimple_omp_parallel_child_fn (const_gimple gs)
3679 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3680 return gs->gimple_omp_parallel.child_fn;
3683 /* Return a pointer to the child function used to hold the body of
3686 static inline tree *
3687 gimple_omp_parallel_child_fn_ptr (gimple gs)
3689 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3690 return &gs->gimple_omp_parallel.child_fn;
3694 /* Set CHILD_FN to be the child function for OMP_PARALLEL GS. */
3697 gimple_omp_parallel_set_child_fn (gimple gs, tree child_fn)
3699 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3700 gs->gimple_omp_parallel.child_fn = child_fn;
3704 /* Return the artificial argument used to send variables and values
3705 from the parent to the children threads in OMP_PARALLEL GS. */
3708 gimple_omp_parallel_data_arg (const_gimple gs)
3710 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3711 return gs->gimple_omp_parallel.data_arg;
3715 /* Return a pointer to the data argument for OMP_PARALLEL GS. */
3717 static inline tree *
3718 gimple_omp_parallel_data_arg_ptr (gimple gs)
3720 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3721 return &gs->gimple_omp_parallel.data_arg;
3725 /* Set DATA_ARG to be the data argument for OMP_PARALLEL GS. */
3728 gimple_omp_parallel_set_data_arg (gimple gs, tree data_arg)
3730 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3731 gs->gimple_omp_parallel.data_arg = data_arg;
3735 /* Return the clauses associated with OMP_TASK GS. */
3738 gimple_omp_task_clauses (const_gimple gs)
3740 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3741 return gs->gimple_omp_parallel.clauses;
3745 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3747 static inline tree *
3748 gimple_omp_task_clauses_ptr (gimple gs)
3750 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3751 return &gs->gimple_omp_parallel.clauses;
3755 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3759 gimple_omp_task_set_clauses (gimple gs, tree clauses)
3761 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3762 gs->gimple_omp_parallel.clauses = clauses;
3766 /* Return the child function used to hold the body of OMP_TASK GS. */
3769 gimple_omp_task_child_fn (const_gimple gs)
3771 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3772 return gs->gimple_omp_parallel.child_fn;
3775 /* Return a pointer to the child function used to hold the body of
3778 static inline tree *
3779 gimple_omp_task_child_fn_ptr (gimple gs)
3781 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3782 return &gs->gimple_omp_parallel.child_fn;
3786 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3789 gimple_omp_task_set_child_fn (gimple gs, tree child_fn)
3791 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3792 gs->gimple_omp_parallel.child_fn = child_fn;
3796 /* Return the artificial argument used to send variables and values
3797 from the parent to the children threads in OMP_TASK GS. */
3800 gimple_omp_task_data_arg (const_gimple gs)
3802 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3803 return gs->gimple_omp_parallel.data_arg;
3807 /* Return a pointer to the data argument for OMP_TASK GS. */
3809 static inline tree *
3810 gimple_omp_task_data_arg_ptr (gimple gs)
3812 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3813 return &gs->gimple_omp_parallel.data_arg;
3817 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3820 gimple_omp_task_set_data_arg (gimple gs, tree data_arg)
3822 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3823 gs->gimple_omp_parallel.data_arg = data_arg;
3827 /* Return the clauses associated with OMP_TASK GS. */
3830 gimple_omp_taskreg_clauses (const_gimple gs)
3832 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3833 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3834 return gs->gimple_omp_parallel.clauses;
3838 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3840 static inline tree *
3841 gimple_omp_taskreg_clauses_ptr (gimple gs)
3843 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3844 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3845 return &gs->gimple_omp_parallel.clauses;
3849 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3853 gimple_omp_taskreg_set_clauses (gimple gs, tree clauses)
3855 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3856 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3857 gs->gimple_omp_parallel.clauses = clauses;
3861 /* Return the child function used to hold the body of OMP_TASK GS. */
3864 gimple_omp_taskreg_child_fn (const_gimple gs)
3866 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3867 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3868 return gs->gimple_omp_parallel.child_fn;
3871 /* Return a pointer to the child function used to hold the body of
3874 static inline tree *
3875 gimple_omp_taskreg_child_fn_ptr (gimple gs)
3877 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3878 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3879 return &gs->gimple_omp_parallel.child_fn;
3883 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3886 gimple_omp_taskreg_set_child_fn (gimple gs, tree child_fn)
3888 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3889 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3890 gs->gimple_omp_parallel.child_fn = child_fn;
3894 /* Return the artificial argument used to send variables and values
3895 from the parent to the children threads in OMP_TASK GS. */
3898 gimple_omp_taskreg_data_arg (const_gimple gs)
3900 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3901 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3902 return gs->gimple_omp_parallel.data_arg;
3906 /* Return a pointer to the data argument for OMP_TASK GS. */
3908 static inline tree *
3909 gimple_omp_taskreg_data_arg_ptr (gimple gs)
3911 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3912 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3913 return &gs->gimple_omp_parallel.data_arg;
3917 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3920 gimple_omp_taskreg_set_data_arg (gimple gs, tree data_arg)
3922 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3923 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3924 gs->gimple_omp_parallel.data_arg = data_arg;
3928 /* Return the copy function used to hold the body of OMP_TASK GS. */
3931 gimple_omp_task_copy_fn (const_gimple gs)
3933 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3934 return gs->gimple_omp_task.copy_fn;
3937 /* Return a pointer to the copy function used to hold the body of
3940 static inline tree *
3941 gimple_omp_task_copy_fn_ptr (gimple gs)
3943 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3944 return &gs->gimple_omp_task.copy_fn;
3948 /* Set CHILD_FN to be the copy function for OMP_TASK GS. */
3951 gimple_omp_task_set_copy_fn (gimple gs, tree copy_fn)
3953 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3954 gs->gimple_omp_task.copy_fn = copy_fn;
3958 /* Return size of the data block in bytes in OMP_TASK GS. */
3961 gimple_omp_task_arg_size (const_gimple gs)
3963 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3964 return gs->gimple_omp_task.arg_size;
3968 /* Return a pointer to the data block size for OMP_TASK GS. */
3970 static inline tree *
3971 gimple_omp_task_arg_size_ptr (gimple gs)
3973 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3974 return &gs->gimple_omp_task.arg_size;
3978 /* Set ARG_SIZE to be the data block size for OMP_TASK GS. */
3981 gimple_omp_task_set_arg_size (gimple gs, tree arg_size)
3983 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3984 gs->gimple_omp_task.arg_size = arg_size;
3988 /* Return align of the data block in bytes in OMP_TASK GS. */
3991 gimple_omp_task_arg_align (const_gimple gs)
3993 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3994 return gs->gimple_omp_task.arg_align;
3998 /* Return a pointer to the data block align for OMP_TASK GS. */
4000 static inline tree *
4001 gimple_omp_task_arg_align_ptr (gimple gs)
4003 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4004 return &gs->gimple_omp_task.arg_align;
4008 /* Set ARG_SIZE to be the data block align for OMP_TASK GS. */
4011 gimple_omp_task_set_arg_align (gimple gs, tree arg_align)
4013 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4014 gs->gimple_omp_task.arg_align = arg_align;
4018 /* Return the clauses associated with OMP_SINGLE GS. */
4021 gimple_omp_single_clauses (const_gimple gs)
4023 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
4024 return gs->gimple_omp_single.clauses;
4028 /* Return a pointer to the clauses associated with OMP_SINGLE GS. */
4030 static inline tree *
4031 gimple_omp_single_clauses_ptr (gimple gs)
4033 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
4034 return &gs->gimple_omp_single.clauses;
4038 /* Set CLAUSES to be the clauses associated with OMP_SINGLE GS. */
4041 gimple_omp_single_set_clauses (gimple gs, tree clauses)
4043 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
4044 gs->gimple_omp_single.clauses = clauses;
4048 /* Return the clauses associated with OMP_SECTIONS GS. */
4051 gimple_omp_sections_clauses (const_gimple gs)
4053 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4054 return gs->gimple_omp_sections.clauses;
4058 /* Return a pointer to the clauses associated with OMP_SECTIONS GS. */
4060 static inline tree *
4061 gimple_omp_sections_clauses_ptr (gimple gs)
4063 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4064 return &gs->gimple_omp_sections.clauses;
4068 /* Set CLAUSES to be the set of clauses associated with OMP_SECTIONS
4072 gimple_omp_sections_set_clauses (gimple gs, tree clauses)
4074 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4075 gs->gimple_omp_sections.clauses = clauses;
4079 /* Return the control variable associated with the GIMPLE_OMP_SECTIONS
4083 gimple_omp_sections_control (const_gimple gs)
4085 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4086 return gs->gimple_omp_sections.control;
4090 /* Return a pointer to the clauses associated with the GIMPLE_OMP_SECTIONS
4093 static inline tree *
4094 gimple_omp_sections_control_ptr (gimple gs)
4096 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4097 return &gs->gimple_omp_sections.control;
4101 /* Set CONTROL to be the set of clauses associated with the
4102 GIMPLE_OMP_SECTIONS in GS. */
4105 gimple_omp_sections_set_control (gimple gs, tree control)
4107 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4108 gs->gimple_omp_sections.control = control;
4112 /* Set COND to be the condition code for OMP_FOR GS. */
4115 gimple_omp_for_set_cond (gimple gs, size_t i, enum tree_code cond)
4117 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4118 gcc_gimple_checking_assert (TREE_CODE_CLASS (cond) == tcc_comparison
4119 && i < gs->gimple_omp_for.collapse);
4120 gs->gimple_omp_for.iter[i].cond = cond;
4124 /* Return the condition code associated with OMP_FOR GS. */
4126 static inline enum tree_code
4127 gimple_omp_for_cond (const_gimple gs, size_t i)
4129 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4130 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4131 return gs->gimple_omp_for.iter[i].cond;
4135 /* Set the value being stored in an atomic store. */
4138 gimple_omp_atomic_store_set_val (gimple g, tree val)
4140 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4141 g->gimple_omp_atomic_store.val = val;
4145 /* Return the value being stored in an atomic store. */
4148 gimple_omp_atomic_store_val (const_gimple g)
4150 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4151 return g->gimple_omp_atomic_store.val;
4155 /* Return a pointer to the value being stored in an atomic store. */
4157 static inline tree *
4158 gimple_omp_atomic_store_val_ptr (gimple g)
4160 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4161 return &g->gimple_omp_atomic_store.val;
4165 /* Set the LHS of an atomic load. */
4168 gimple_omp_atomic_load_set_lhs (gimple g, tree lhs)
4170 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4171 g->gimple_omp_atomic_load.lhs = lhs;
4175 /* Get the LHS of an atomic load. */
4178 gimple_omp_atomic_load_lhs (const_gimple g)
4180 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4181 return g->gimple_omp_atomic_load.lhs;
4185 /* Return a pointer to the LHS of an atomic load. */
4187 static inline tree *
4188 gimple_omp_atomic_load_lhs_ptr (gimple g)
4190 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4191 return &g->gimple_omp_atomic_load.lhs;
4195 /* Set the RHS of an atomic load. */
4198 gimple_omp_atomic_load_set_rhs (gimple g, tree rhs)
4200 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4201 g->gimple_omp_atomic_load.rhs = rhs;
4205 /* Get the RHS of an atomic load. */
4208 gimple_omp_atomic_load_rhs (const_gimple g)
4210 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4211 return g->gimple_omp_atomic_load.rhs;
4215 /* Return a pointer to the RHS of an atomic load. */
4217 static inline tree *
4218 gimple_omp_atomic_load_rhs_ptr (gimple g)
4220 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4221 return &g->gimple_omp_atomic_load.rhs;
4225 /* Get the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4228 gimple_omp_continue_control_def (const_gimple g)
4230 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4231 return g->gimple_omp_continue.control_def;
4234 /* The same as above, but return the address. */
4236 static inline tree *
4237 gimple_omp_continue_control_def_ptr (gimple g)
4239 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4240 return &g->gimple_omp_continue.control_def;
4243 /* Set the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4246 gimple_omp_continue_set_control_def (gimple g, tree def)
4248 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4249 g->gimple_omp_continue.control_def = def;
4253 /* Get the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4256 gimple_omp_continue_control_use (const_gimple g)
4258 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4259 return g->gimple_omp_continue.control_use;
4263 /* The same as above, but return the address. */
4265 static inline tree *
4266 gimple_omp_continue_control_use_ptr (gimple g)
4268 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4269 return &g->gimple_omp_continue.control_use;
4273 /* Set the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4276 gimple_omp_continue_set_control_use (gimple g, tree use)
4278 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4279 g->gimple_omp_continue.control_use = use;
4283 /* Return a pointer to the return value for GIMPLE_RETURN GS. */
4285 static inline tree *
4286 gimple_return_retval_ptr (const_gimple gs)
4288 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4289 return gimple_op_ptr (gs, 0);
4292 /* Return the return value for GIMPLE_RETURN GS. */
4295 gimple_return_retval (const_gimple gs)
4297 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4298 return gimple_op (gs, 0);
4302 /* Set RETVAL to be the return value for GIMPLE_RETURN GS. */
4305 gimple_return_set_retval (gimple gs, tree retval)
4307 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4308 gimple_set_op (gs, 0, retval);
4312 /* Returns true when the gimple statment STMT is any of the OpenMP types. */
4314 #define CASE_GIMPLE_OMP \
4315 case GIMPLE_OMP_PARALLEL: \
4316 case GIMPLE_OMP_TASK: \
4317 case GIMPLE_OMP_FOR: \
4318 case GIMPLE_OMP_SECTIONS: \
4319 case GIMPLE_OMP_SECTIONS_SWITCH: \
4320 case GIMPLE_OMP_SINGLE: \
4321 case GIMPLE_OMP_SECTION: \
4322 case GIMPLE_OMP_MASTER: \
4323 case GIMPLE_OMP_ORDERED: \
4324 case GIMPLE_OMP_CRITICAL: \
4325 case GIMPLE_OMP_RETURN: \
4326 case GIMPLE_OMP_ATOMIC_LOAD: \
4327 case GIMPLE_OMP_ATOMIC_STORE: \
4328 case GIMPLE_OMP_CONTINUE
4331 is_gimple_omp (const_gimple stmt)
4333 switch (gimple_code (stmt))
4343 /* Returns TRUE if statement G is a GIMPLE_NOP. */
4346 gimple_nop_p (const_gimple g)
4348 return gimple_code (g) == GIMPLE_NOP;
4352 /* Return true if GS is a GIMPLE_RESX. */
4355 is_gimple_resx (const_gimple gs)
4357 return gimple_code (gs) == GIMPLE_RESX;
4360 /* Return the predictor of GIMPLE_PREDICT statement GS. */
4362 static inline enum br_predictor
4363 gimple_predict_predictor (gimple gs)
4365 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4366 return (enum br_predictor) (gs->gsbase.subcode & ~GF_PREDICT_TAKEN);
4370 /* Set the predictor of GIMPLE_PREDICT statement GS to PREDICT. */
4373 gimple_predict_set_predictor (gimple gs, enum br_predictor predictor)
4375 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4376 gs->gsbase.subcode = (gs->gsbase.subcode & GF_PREDICT_TAKEN)
4377 | (unsigned) predictor;
4381 /* Return the outcome of GIMPLE_PREDICT statement GS. */
4383 static inline enum prediction
4384 gimple_predict_outcome (gimple gs)
4386 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4387 return (gs->gsbase.subcode & GF_PREDICT_TAKEN) ? TAKEN : NOT_TAKEN;
4391 /* Set the outcome of GIMPLE_PREDICT statement GS to OUTCOME. */
4394 gimple_predict_set_outcome (gimple gs, enum prediction outcome)
4396 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4397 if (outcome == TAKEN)
4398 gs->gsbase.subcode |= GF_PREDICT_TAKEN;
4400 gs->gsbase.subcode &= ~GF_PREDICT_TAKEN;
4404 /* Return the type of the main expression computed by STMT. Return
4405 void_type_node if the statement computes nothing. */
4408 gimple_expr_type (const_gimple stmt)
4410 enum gimple_code code = gimple_code (stmt);
4412 if (code == GIMPLE_ASSIGN || code == GIMPLE_CALL)
4415 /* In general we want to pass out a type that can be substituted
4416 for both the RHS and the LHS types if there is a possibly
4417 useless conversion involved. That means returning the
4418 original RHS type as far as we can reconstruct it. */
4419 if (code == GIMPLE_CALL)
4420 type = gimple_call_return_type (stmt);
4422 switch (gimple_assign_rhs_code (stmt))
4424 case POINTER_PLUS_EXPR:
4425 type = TREE_TYPE (gimple_assign_rhs1 (stmt));
4429 /* As fallback use the type of the LHS. */
4430 type = TREE_TYPE (gimple_get_lhs (stmt));
4435 else if (code == GIMPLE_COND)
4436 return boolean_type_node;
4438 return void_type_node;
4442 /* Return a new iterator pointing to GIMPLE_SEQ's first statement. */
4444 static inline gimple_stmt_iterator
4445 gsi_start (gimple_seq seq)
4447 gimple_stmt_iterator i;
4449 i.ptr = gimple_seq_first (seq);
4451 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4457 /* Return a new iterator pointing to the first statement in basic block BB. */
4459 static inline gimple_stmt_iterator
4460 gsi_start_bb (basic_block bb)
4462 gimple_stmt_iterator i;
4466 i.ptr = gimple_seq_first (seq);
4474 /* Return a new iterator initially pointing to GIMPLE_SEQ's last statement. */
4476 static inline gimple_stmt_iterator
4477 gsi_last (gimple_seq seq)
4479 gimple_stmt_iterator i;
4481 i.ptr = gimple_seq_last (seq);
4483 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4489 /* Return a new iterator pointing to the last statement in basic block BB. */
4491 static inline gimple_stmt_iterator
4492 gsi_last_bb (basic_block bb)
4494 gimple_stmt_iterator i;
4498 i.ptr = gimple_seq_last (seq);
4506 /* Return true if I is at the end of its sequence. */
4509 gsi_end_p (gimple_stmt_iterator i)
4511 return i.ptr == NULL;
4515 /* Return true if I is one statement before the end of its sequence. */
4518 gsi_one_before_end_p (gimple_stmt_iterator i)
4520 return i.ptr != NULL && i.ptr->next == NULL;
4524 /* Advance the iterator to the next gimple statement. */
4527 gsi_next (gimple_stmt_iterator *i)
4529 i->ptr = i->ptr->next;
4532 /* Advance the iterator to the previous gimple statement. */
4535 gsi_prev (gimple_stmt_iterator *i)
4537 i->ptr = i->ptr->prev;
4540 /* Return the current stmt. */
4542 static inline gimple
4543 gsi_stmt (gimple_stmt_iterator i)
4548 /* Return a block statement iterator that points to the first non-label
4549 statement in block BB. */
4551 static inline gimple_stmt_iterator
4552 gsi_after_labels (basic_block bb)
4554 gimple_stmt_iterator gsi = gsi_start_bb (bb);
4556 while (!gsi_end_p (gsi) && gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL)
4562 /* Advance the iterator to the next non-debug gimple statement. */
4565 gsi_next_nondebug (gimple_stmt_iterator *i)
4571 while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
4574 /* Advance the iterator to the next non-debug gimple statement. */
4577 gsi_prev_nondebug (gimple_stmt_iterator *i)
4583 while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
4586 /* Return a new iterator pointing to the first non-debug statement in
4589 static inline gimple_stmt_iterator
4590 gsi_start_nondebug_bb (basic_block bb)
4592 gimple_stmt_iterator i = gsi_start_bb (bb);
4594 if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
4595 gsi_next_nondebug (&i);
4600 /* Return a new iterator pointing to the last non-debug statement in
4603 static inline gimple_stmt_iterator
4604 gsi_last_nondebug_bb (basic_block bb)
4606 gimple_stmt_iterator i = gsi_last_bb (bb);
4608 if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
4609 gsi_prev_nondebug (&i);
4614 /* Return a pointer to the current stmt.
4616 NOTE: You may want to use gsi_replace on the iterator itself,
4617 as this performs additional bookkeeping that will not be done
4618 if you simply assign through a pointer returned by gsi_stmt_ptr. */
4620 static inline gimple *
4621 gsi_stmt_ptr (gimple_stmt_iterator *i)
4623 return &i->ptr->stmt;
4627 /* Return the basic block associated with this iterator. */
4629 static inline basic_block
4630 gsi_bb (gimple_stmt_iterator i)
4636 /* Return the sequence associated with this iterator. */
4638 static inline gimple_seq
4639 gsi_seq (gimple_stmt_iterator i)
4645 enum gsi_iterator_update
4647 GSI_NEW_STMT, /* Only valid when single statement is added, move
4649 GSI_SAME_STMT, /* Leave the iterator at the same statement. */
4650 GSI_CONTINUE_LINKING /* Move iterator to whatever position is suitable
4651 for linking other statements in the same
4655 /* In gimple-iterator.c */
4656 gimple_stmt_iterator gsi_start_phis (basic_block);
4657 gimple_seq gsi_split_seq_after (gimple_stmt_iterator);
4658 gimple_seq gsi_split_seq_before (gimple_stmt_iterator *);
4659 void gsi_replace (gimple_stmt_iterator *, gimple, bool);
4660 void gsi_insert_before (gimple_stmt_iterator *, gimple,
4661 enum gsi_iterator_update);
4662 void gsi_insert_before_without_update (gimple_stmt_iterator *, gimple,
4663 enum gsi_iterator_update);
4664 void gsi_insert_seq_before (gimple_stmt_iterator *, gimple_seq,
4665 enum gsi_iterator_update);
4666 void gsi_insert_seq_before_without_update (gimple_stmt_iterator *, gimple_seq,
4667 enum gsi_iterator_update);
4668 void gsi_insert_after (gimple_stmt_iterator *, gimple,
4669 enum gsi_iterator_update);
4670 void gsi_insert_after_without_update (gimple_stmt_iterator *, gimple,
4671 enum gsi_iterator_update);
4672 void gsi_insert_seq_after (gimple_stmt_iterator *, gimple_seq,
4673 enum gsi_iterator_update);
4674 void gsi_insert_seq_after_without_update (gimple_stmt_iterator *, gimple_seq,
4675 enum gsi_iterator_update);
4676 void gsi_remove (gimple_stmt_iterator *, bool);
4677 gimple_stmt_iterator gsi_for_stmt (gimple);
4678 void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *);
4679 void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *);
4680 void gsi_move_to_bb_end (gimple_stmt_iterator *, struct basic_block_def *);
4681 void gsi_insert_on_edge (edge, gimple);
4682 void gsi_insert_seq_on_edge (edge, gimple_seq);
4683 basic_block gsi_insert_on_edge_immediate (edge, gimple);
4684 basic_block gsi_insert_seq_on_edge_immediate (edge, gimple_seq);
4685 void gsi_commit_one_edge_insert (edge, basic_block *);
4686 void gsi_commit_edge_inserts (void);
4687 gimple gimple_call_copy_skip_args (gimple, bitmap);
4690 /* Convenience routines to walk all statements of a gimple function.
4691 Note that this is useful exclusively before the code is converted
4692 into SSA form. Once the program is in SSA form, the standard
4693 operand interface should be used to analyze/modify statements. */
4694 struct walk_stmt_info
4696 /* Points to the current statement being walked. */
4697 gimple_stmt_iterator gsi;
4699 /* Additional data that the callback functions may want to carry
4700 through the recursion. */
4703 /* Pointer map used to mark visited tree nodes when calling
4704 walk_tree on each operand. If set to NULL, duplicate tree nodes
4705 will be visited more than once. */
4706 struct pointer_set_t *pset;
4708 /* Indicates whether the operand being examined may be replaced
4709 with something that matches is_gimple_val (if true) or something
4710 slightly more complicated (if false). "Something" technically
4711 means the common subset of is_gimple_lvalue and is_gimple_rhs,
4712 but we never try to form anything more complicated than that, so
4713 we don't bother checking.
4715 Also note that CALLBACK should update this flag while walking the
4716 sub-expressions of a statement. For instance, when walking the
4717 statement 'foo (&var)', the flag VAL_ONLY will initially be set
4718 to true, however, when walking &var, the operand of that
4719 ADDR_EXPR does not need to be a GIMPLE value. */
4722 /* True if we are currently walking the LHS of an assignment. */
4725 /* Optional. Set to true by the callback functions if they made any
4729 /* True if we're interested in location information. */
4730 bool want_locations;
4732 /* Operand returned by the callbacks. This is set when calling
4733 walk_gimple_seq. If the walk_stmt_fn or walk_tree_fn callback
4734 returns non-NULL, this field will contain the tree returned by
4735 the last callback. */
4736 tree callback_result;
4739 /* Callback for walk_gimple_stmt. Called for every statement found
4740 during traversal. The first argument points to the statement to
4741 walk. The second argument is a flag that the callback sets to
4742 'true' if it the callback handled all the operands and
4743 sub-statements of the statement (the default value of this flag is
4744 'false'). The third argument is an anonymous pointer to data
4745 to be used by the callback. */
4746 typedef tree (*walk_stmt_fn) (gimple_stmt_iterator *, bool *,
4747 struct walk_stmt_info *);
4749 gimple walk_gimple_seq (gimple_seq, walk_stmt_fn, walk_tree_fn,
4750 struct walk_stmt_info *);
4751 tree walk_gimple_stmt (gimple_stmt_iterator *, walk_stmt_fn, walk_tree_fn,
4752 struct walk_stmt_info *);
4753 tree walk_gimple_op (gimple, walk_tree_fn, struct walk_stmt_info *);
4755 #ifdef GATHER_STATISTICS
4756 /* Enum and arrays used for allocation stats. Keep in sync with
4757 gimple.c:gimple_alloc_kind_names. */
4758 enum gimple_alloc_kind
4760 gimple_alloc_kind_assign, /* Assignments. */
4761 gimple_alloc_kind_phi, /* PHI nodes. */
4762 gimple_alloc_kind_cond, /* Conditionals. */
4763 gimple_alloc_kind_seq, /* Sequences. */
4764 gimple_alloc_kind_rest, /* Everything else. */
4765 gimple_alloc_kind_all
4768 extern int gimple_alloc_counts[];
4769 extern int gimple_alloc_sizes[];
4771 /* Return the allocation kind for a given stmt CODE. */
4772 static inline enum gimple_alloc_kind
4773 gimple_alloc_kind (enum gimple_code code)
4778 return gimple_alloc_kind_assign;
4780 return gimple_alloc_kind_phi;
4782 return gimple_alloc_kind_cond;
4784 return gimple_alloc_kind_rest;
4787 #endif /* GATHER_STATISTICS */
4789 extern void dump_gimple_statistics (void);
4791 /* In gimple-fold.c. */
4792 void gimplify_and_update_call_from_tree (gimple_stmt_iterator *, tree);
4793 tree gimple_fold_builtin (gimple);
4794 bool fold_stmt (gimple_stmt_iterator *);
4795 bool fold_stmt_inplace (gimple);
4796 tree maybe_fold_offset_to_reference (location_t, tree, tree, tree);
4797 tree maybe_fold_offset_to_address (location_t, tree, tree, tree);
4798 tree maybe_fold_stmt_addition (location_t, tree, tree, tree);
4799 tree get_symbol_constant_value (tree);
4800 bool may_propagate_address_into_dereference (tree, tree);
4801 extern tree maybe_fold_and_comparisons (enum tree_code, tree, tree,
4802 enum tree_code, tree, tree);
4803 extern tree maybe_fold_or_comparisons (enum tree_code, tree, tree,
4804 enum tree_code, tree, tree);
4806 #endif /* GCC_GIMPLE_H */