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 extern void gimple_check_failed (const_gimple, const char *, int, \
55 const char *, enum gimple_code, \
56 enum tree_code) ATTRIBUTE_NORETURN;
58 #define GIMPLE_CHECK(GS, CODE) \
60 const_gimple __gs = (GS); \
61 if (gimple_code (__gs) != (CODE)) \
62 gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__, \
63 (CODE), ERROR_MARK); \
65 #else /* not ENABLE_GIMPLE_CHECKING */
66 #define GIMPLE_CHECK(GS, CODE) (void)0
69 /* Class of GIMPLE expressions suitable for the RHS of assignments. See
70 get_gimple_rhs_class. */
73 GIMPLE_INVALID_RHS, /* The expression cannot be used on the RHS. */
74 GIMPLE_BINARY_RHS, /* The expression is a binary operation. */
75 GIMPLE_UNARY_RHS, /* The expression is a unary operation. */
76 GIMPLE_SINGLE_RHS /* The expression is a single object (an SSA
77 name, a _DECL, a _REF, etc. */
80 /* Specific flags for individual GIMPLE statements. These flags are
81 always stored in gimple_statement_base.subcode and they may only be
82 defined for statement codes that do not use sub-codes.
84 Values for the masks can overlap as long as the overlapping values
85 are never used in the same statement class.
87 The maximum mask value that can be defined is 1 << 15 (i.e., each
88 statement code can hold up to 16 bitflags).
90 Keep this list sorted. */
92 GF_ASM_INPUT = 1 << 0,
93 GF_ASM_VOLATILE = 1 << 1,
94 GF_CALL_CANNOT_INLINE = 1 << 0,
95 GF_CALL_FROM_THUNK = 1 << 1,
96 GF_CALL_RETURN_SLOT_OPT = 1 << 2,
97 GF_CALL_TAILCALL = 1 << 3,
98 GF_CALL_VA_ARG_PACK = 1 << 4,
99 GF_CALL_NOTHROW = 1 << 5,
100 GF_OMP_PARALLEL_COMBINED = 1 << 0,
102 /* True on an GIMPLE_OMP_RETURN statement if the return does not require
103 a thread synchronization via some sort of barrier. The exact barrier
104 that would otherwise be emitted is dependent on the OMP statement with
105 which this return is associated. */
106 GF_OMP_RETURN_NOWAIT = 1 << 0,
108 GF_OMP_SECTION_LAST = 1 << 0,
109 GF_PREDICT_TAKEN = 1 << 15
112 /* Currently, there's only one type of gimple debug stmt. Others are
113 envisioned, for example, to enable the generation of is_stmt notes
114 in line number information, to mark sequence points, etc. This
115 subcode is to be used to tell them apart. */
116 enum gimple_debug_subcode {
117 GIMPLE_DEBUG_BIND = 0
120 /* Masks for selecting a pass local flag (PLF) to work on. These
121 masks are used by gimple_set_plf and gimple_plf. */
127 /* A node in a gimple_seq_d. */
128 struct GTY((chain_next ("%h.next"), chain_prev ("%h.prev"))) gimple_seq_node_d {
130 struct gimple_seq_node_d *prev;
131 struct gimple_seq_node_d *next;
134 /* A double-linked sequence of gimple statements. */
135 struct GTY ((chain_next ("%h.next_free"))) gimple_seq_d {
136 /* First and last statements in the sequence. */
137 gimple_seq_node first;
138 gimple_seq_node last;
140 /* Sequences are created/destroyed frequently. To minimize
141 allocation activity, deallocated sequences are kept in a pool of
142 available sequences. This is the pointer to the next free
143 sequence in the pool. */
144 gimple_seq next_free;
148 /* Return the first node in GIMPLE sequence S. */
150 static inline gimple_seq_node
151 gimple_seq_first (const_gimple_seq s)
153 return s ? s->first : NULL;
157 /* Return the first statement in GIMPLE sequence S. */
160 gimple_seq_first_stmt (const_gimple_seq s)
162 gimple_seq_node n = gimple_seq_first (s);
163 return (n) ? n->stmt : NULL;
167 /* Return the last node in GIMPLE sequence S. */
169 static inline gimple_seq_node
170 gimple_seq_last (const_gimple_seq s)
172 return s ? s->last : NULL;
176 /* Return the last statement in GIMPLE sequence S. */
179 gimple_seq_last_stmt (const_gimple_seq s)
181 gimple_seq_node n = gimple_seq_last (s);
182 return (n) ? n->stmt : NULL;
186 /* Set the last node in GIMPLE sequence S to LAST. */
189 gimple_seq_set_last (gimple_seq s, gimple_seq_node last)
195 /* Set the first node in GIMPLE sequence S to FIRST. */
198 gimple_seq_set_first (gimple_seq s, gimple_seq_node first)
204 /* Return true if GIMPLE sequence S is empty. */
207 gimple_seq_empty_p (const_gimple_seq s)
209 return s == NULL || s->first == NULL;
213 void gimple_seq_add_stmt (gimple_seq *, gimple);
215 /* Link gimple statement GS to the end of the sequence *SEQ_P. If
216 *SEQ_P is NULL, a new sequence is allocated. This function is
217 similar to gimple_seq_add_stmt, but does not scan the operands.
218 During gimplification, we need to manipulate statement sequences
219 before the def/use vectors have been constructed. */
220 void gimplify_seq_add_stmt (gimple_seq *, gimple);
222 /* Allocate a new sequence and initialize its first element with STMT. */
224 static inline gimple_seq
225 gimple_seq_alloc_with_stmt (gimple stmt)
227 gimple_seq seq = NULL;
228 gimple_seq_add_stmt (&seq, stmt);
233 /* Returns the sequence of statements in BB. */
235 static inline gimple_seq
236 bb_seq (const_basic_block bb)
238 return (!(bb->flags & BB_RTL) && bb->il.gimple) ? bb->il.gimple->seq : NULL;
242 /* Sets the sequence of statements in BB to SEQ. */
245 set_bb_seq (basic_block bb, gimple_seq seq)
247 gcc_assert (!(bb->flags & BB_RTL));
248 bb->il.gimple->seq = seq;
251 /* Iterator object for GIMPLE statement sequences. */
255 /* Sequence node holding the current statement. */
258 /* Sequence and basic block holding the statement. These fields
259 are necessary to handle edge cases such as when statement is
260 added to an empty basic block or when the last statement of a
261 block/sequence is removed. */
264 } gimple_stmt_iterator;
267 /* Data structure definitions for GIMPLE tuples. NOTE: word markers
268 are for 64 bit hosts. */
270 struct GTY(()) gimple_statement_base {
272 Main identifying code for a tuple. */
273 ENUM_BITFIELD(gimple_code) code : 8;
275 /* Nonzero if a warning should not be emitted on this tuple. */
276 unsigned int no_warning : 1;
278 /* Nonzero if this tuple has been visited. Passes are responsible
279 for clearing this bit before using it. */
280 unsigned int visited : 1;
282 /* Nonzero if this tuple represents a non-temporal move. */
283 unsigned int nontemporal_move : 1;
285 /* Pass local flags. These flags are free for any pass to use as
286 they see fit. Passes should not assume that these flags contain
287 any useful value when the pass starts. Any initial state that
288 the pass requires should be set on entry to the pass. See
289 gimple_set_plf and gimple_plf for usage. */
290 unsigned int plf : 2;
292 /* Nonzero if this statement has been modified and needs to have its
293 operands rescanned. */
294 unsigned modified : 1;
296 /* Nonzero if this statement contains volatile operands. */
297 unsigned has_volatile_ops : 1;
299 /* Padding to get subcode to 16 bit alignment. */
302 /* The SUBCODE field can be used for tuple-specific flags for tuples
303 that do not require subcodes. Note that SUBCODE should be at
304 least as wide as tree codes, as several tuples store tree codes
306 unsigned int subcode : 16;
308 /* UID of this statement. This is used by passes that want to
309 assign IDs to statements. It must be assigned and used by each
310 pass. By default it should be assumed to contain garbage. */
314 Locus information for debug info. */
317 /* Number of operands in this tuple. */
321 Basic block holding this statement. */
322 struct basic_block_def *bb;
325 Lexical block holding this statement. */
330 /* Base structure for tuples with operands. */
332 struct GTY(()) gimple_statement_with_ops_base
335 struct gimple_statement_base gsbase;
338 SSA operand vectors. NOTE: It should be possible to
339 amalgamate these vectors with the operand vector OP. However,
340 the SSA operand vectors are organized differently and contain
341 more information (like immediate use chaining). */
342 struct def_optype_d GTY((skip (""))) *def_ops;
343 struct use_optype_d GTY((skip (""))) *use_ops;
347 /* Statements that take register operands. */
349 struct GTY(()) gimple_statement_with_ops
352 struct gimple_statement_with_ops_base opbase;
355 Operand vector. NOTE! This must always be the last field
356 of this structure. In particular, this means that this
357 structure cannot be embedded inside another one. */
358 tree GTY((length ("%h.opbase.gsbase.num_ops"))) op[1];
362 /* Base for statements that take both memory and register operands. */
364 struct GTY(()) gimple_statement_with_memory_ops_base
367 struct gimple_statement_with_ops_base opbase;
370 Virtual operands for this statement. The GC will pick them
371 up via the ssa_names array. */
372 tree GTY((skip (""))) vdef;
373 tree GTY((skip (""))) vuse;
377 /* Statements that take both memory and register operands. */
379 struct GTY(()) gimple_statement_with_memory_ops
382 struct gimple_statement_with_memory_ops_base membase;
385 Operand vector. NOTE! This must always be the last field
386 of this structure. In particular, this means that this
387 structure cannot be embedded inside another one. */
388 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
392 /* Call statements that take both memory and register operands. */
394 struct GTY(()) gimple_statement_call
397 struct gimple_statement_with_memory_ops_base membase;
400 struct pt_solution call_used;
401 struct pt_solution call_clobbered;
404 Operand vector. NOTE! This must always be the last field
405 of this structure. In particular, this means that this
406 structure cannot be embedded inside another one. */
407 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
411 /* OpenMP statements (#pragma omp). */
413 struct GTY(()) gimple_statement_omp {
415 struct gimple_statement_base gsbase;
424 struct GTY(()) gimple_statement_bind {
426 struct gimple_statement_base gsbase;
429 Variables declared in this scope. */
433 This is different than the BLOCK field in gimple_statement_base,
434 which is analogous to TREE_BLOCK (i.e., the lexical block holding
435 this statement). This field is the equivalent of BIND_EXPR_BLOCK
436 in tree land (i.e., the lexical scope defined by this bind). See
447 struct GTY(()) gimple_statement_catch {
449 struct gimple_statement_base gsbase;
459 /* GIMPLE_EH_FILTER */
461 struct GTY(()) gimple_statement_eh_filter {
463 struct gimple_statement_base gsbase;
475 /* GIMPLE_EH_MUST_NOT_THROW */
477 struct GTY(()) gimple_statement_eh_mnt {
479 struct gimple_statement_base gsbase;
481 /* [ WORD 5 ] Abort function decl. */
487 struct GTY(()) gimple_statement_phi {
489 struct gimple_statement_base gsbase;
499 struct phi_arg_d GTY ((length ("%h.nargs"))) args[1];
503 /* GIMPLE_RESX, GIMPLE_EH_DISPATCH */
505 struct GTY(()) gimple_statement_eh_ctrl
508 struct gimple_statement_base gsbase;
511 Exception region number. */
518 struct GTY(()) gimple_statement_try {
520 struct gimple_statement_base gsbase;
523 Expression to evaluate. */
527 Cleanup expression. */
531 /* Kind of GIMPLE_TRY statements. */
532 enum gimple_try_flags
535 GIMPLE_TRY_CATCH = 1 << 0,
538 GIMPLE_TRY_FINALLY = 1 << 1,
539 GIMPLE_TRY_KIND = GIMPLE_TRY_CATCH | GIMPLE_TRY_FINALLY,
541 /* Analogous to TRY_CATCH_IS_CLEANUP. */
542 GIMPLE_TRY_CATCH_IS_CLEANUP = 1 << 2
545 /* GIMPLE_WITH_CLEANUP_EXPR */
547 struct GTY(()) gimple_statement_wce {
549 struct gimple_statement_base gsbase;
551 /* Subcode: CLEANUP_EH_ONLY. True if the cleanup should only be
552 executed if an exception is thrown, not on normal exit of its
553 scope. This flag is analogous to the CLEANUP_EH_ONLY flag
557 Cleanup expression. */
564 struct GTY(()) gimple_statement_asm
567 struct gimple_statement_with_memory_ops_base membase;
570 __asm__ statement. */
574 Number of inputs, outputs, clobbers, labels. */
581 Operand vector. NOTE! This must always be the last field
582 of this structure. In particular, this means that this
583 structure cannot be embedded inside another one. */
584 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
587 /* GIMPLE_OMP_CRITICAL */
589 struct GTY(()) gimple_statement_omp_critical {
591 struct gimple_statement_omp omp;
594 Critical section name. */
599 struct GTY(()) gimple_omp_for_iter {
600 /* Condition code. */
603 /* Index variable. */
618 struct GTY(()) gimple_statement_omp_for {
620 struct gimple_statement_omp omp;
626 Number of elements in iter array. */
630 struct gimple_omp_for_iter * GTY((length ("%h.collapse"))) iter;
633 Pre-body evaluated before the loop body begins. */
638 /* GIMPLE_OMP_PARALLEL */
640 struct GTY(()) gimple_statement_omp_parallel {
642 struct gimple_statement_omp omp;
649 Child function holding the body of the parallel region. */
653 Shared data argument. */
658 /* GIMPLE_OMP_TASK */
660 struct GTY(()) gimple_statement_omp_task {
662 struct gimple_statement_omp_parallel par;
665 Child function holding firstprivate initialization if needed. */
669 Size and alignment in bytes of the argument data block. */
675 /* GIMPLE_OMP_SECTION */
676 /* Uses struct gimple_statement_omp. */
679 /* GIMPLE_OMP_SECTIONS */
681 struct GTY(()) gimple_statement_omp_sections {
683 struct gimple_statement_omp omp;
689 The control variable used for deciding which of the sections to
694 /* GIMPLE_OMP_CONTINUE.
696 Note: This does not inherit from gimple_statement_omp, because we
697 do not need the body field. */
699 struct GTY(()) gimple_statement_omp_continue {
701 struct gimple_statement_base gsbase;
710 /* GIMPLE_OMP_SINGLE */
712 struct GTY(()) gimple_statement_omp_single {
714 struct gimple_statement_omp omp;
721 /* GIMPLE_OMP_ATOMIC_LOAD.
722 Note: This is based on gimple_statement_base, not g_s_omp, because g_s_omp
723 contains a sequence, which we don't need here. */
725 struct GTY(()) gimple_statement_omp_atomic_load {
727 struct gimple_statement_base gsbase;
733 /* GIMPLE_OMP_ATOMIC_STORE.
734 See note on GIMPLE_OMP_ATOMIC_LOAD. */
736 struct GTY(()) gimple_statement_omp_atomic_store {
738 struct gimple_statement_base gsbase;
744 #define DEFGSSTRUCT(SYM, STRUCT, HAS_TREE_OP) SYM,
745 enum gimple_statement_structure_enum {
746 #include "gsstruct.def"
752 /* Define the overall contents of a gimple tuple. It may be any of the
753 structures declared above for various types of tuples. */
755 union GTY ((desc ("gimple_statement_structure (&%h)"), variable_size)) gimple_statement_d {
756 struct gimple_statement_base GTY ((tag ("GSS_BASE"))) gsbase;
757 struct gimple_statement_with_ops GTY ((tag ("GSS_WITH_OPS"))) gsops;
758 struct gimple_statement_with_memory_ops_base GTY ((tag ("GSS_WITH_MEM_OPS_BASE"))) gsmembase;
759 struct gimple_statement_with_memory_ops GTY ((tag ("GSS_WITH_MEM_OPS"))) gsmem;
760 struct gimple_statement_call GTY ((tag ("GSS_CALL"))) gimple_call;
761 struct gimple_statement_omp GTY ((tag ("GSS_OMP"))) omp;
762 struct gimple_statement_bind GTY ((tag ("GSS_BIND"))) gimple_bind;
763 struct gimple_statement_catch GTY ((tag ("GSS_CATCH"))) gimple_catch;
764 struct gimple_statement_eh_filter GTY ((tag ("GSS_EH_FILTER"))) gimple_eh_filter;
765 struct gimple_statement_eh_mnt GTY ((tag ("GSS_EH_MNT"))) gimple_eh_mnt;
766 struct gimple_statement_phi GTY ((tag ("GSS_PHI"))) gimple_phi;
767 struct gimple_statement_eh_ctrl GTY ((tag ("GSS_EH_CTRL"))) gimple_eh_ctrl;
768 struct gimple_statement_try GTY ((tag ("GSS_TRY"))) gimple_try;
769 struct gimple_statement_wce GTY ((tag ("GSS_WCE"))) gimple_wce;
770 struct gimple_statement_asm GTY ((tag ("GSS_ASM"))) gimple_asm;
771 struct gimple_statement_omp_critical GTY ((tag ("GSS_OMP_CRITICAL"))) gimple_omp_critical;
772 struct gimple_statement_omp_for GTY ((tag ("GSS_OMP_FOR"))) gimple_omp_for;
773 struct gimple_statement_omp_parallel GTY ((tag ("GSS_OMP_PARALLEL"))) gimple_omp_parallel;
774 struct gimple_statement_omp_task GTY ((tag ("GSS_OMP_TASK"))) gimple_omp_task;
775 struct gimple_statement_omp_sections GTY ((tag ("GSS_OMP_SECTIONS"))) gimple_omp_sections;
776 struct gimple_statement_omp_single GTY ((tag ("GSS_OMP_SINGLE"))) gimple_omp_single;
777 struct gimple_statement_omp_continue GTY ((tag ("GSS_OMP_CONTINUE"))) gimple_omp_continue;
778 struct gimple_statement_omp_atomic_load GTY ((tag ("GSS_OMP_ATOMIC_LOAD"))) gimple_omp_atomic_load;
779 struct gimple_statement_omp_atomic_store GTY ((tag ("GSS_OMP_ATOMIC_STORE"))) gimple_omp_atomic_store;
784 /* Offset in bytes to the location of the operand vector.
785 Zero if there is no operand vector for this tuple structure. */
786 extern size_t const gimple_ops_offset_[];
788 /* Map GIMPLE codes to GSS codes. */
789 extern enum gimple_statement_structure_enum const gss_for_code_[];
791 /* This variable holds the currently expanded gimple statement for purposes
792 of comminucating the profile info to the builtin expanders. */
793 extern gimple currently_expanding_gimple_stmt;
795 gimple gimple_build_return (tree);
797 gimple gimple_build_assign_stat (tree, tree MEM_STAT_DECL);
798 #define gimple_build_assign(l,r) gimple_build_assign_stat (l, r MEM_STAT_INFO)
800 void extract_ops_from_tree (tree, enum tree_code *, tree *, tree *);
802 gimple gimple_build_assign_with_ops_stat (enum tree_code, tree, tree,
804 #define gimple_build_assign_with_ops(c,o1,o2,o3) \
805 gimple_build_assign_with_ops_stat (c, o1, o2, o3 MEM_STAT_INFO)
807 gimple gimple_build_debug_bind_stat (tree, tree, gimple MEM_STAT_DECL);
808 #define gimple_build_debug_bind(var,val,stmt) \
809 gimple_build_debug_bind_stat ((var), (val), (stmt) MEM_STAT_INFO)
811 gimple gimple_build_call_vec (tree, VEC(tree, heap) *);
812 gimple gimple_build_call (tree, unsigned, ...);
813 gimple gimple_build_call_from_tree (tree);
814 gimple gimplify_assign (tree, tree, gimple_seq *);
815 gimple gimple_build_cond (enum tree_code, tree, tree, tree, tree);
816 gimple gimple_build_label (tree label);
817 gimple gimple_build_goto (tree dest);
818 gimple gimple_build_nop (void);
819 gimple gimple_build_bind (tree, gimple_seq, tree);
820 gimple gimple_build_asm_vec (const char *, VEC(tree,gc) *, VEC(tree,gc) *,
821 VEC(tree,gc) *, VEC(tree,gc) *);
822 gimple gimple_build_catch (tree, gimple_seq);
823 gimple gimple_build_eh_filter (tree, gimple_seq);
824 gimple gimple_build_eh_must_not_throw (tree);
825 gimple gimple_build_try (gimple_seq, gimple_seq, enum gimple_try_flags);
826 gimple gimple_build_wce (gimple_seq);
827 gimple gimple_build_resx (int);
828 gimple gimple_build_eh_dispatch (int);
829 gimple gimple_build_switch_nlabels (unsigned, tree, tree);
830 gimple gimple_build_switch (unsigned, tree, tree, ...);
831 gimple gimple_build_switch_vec (tree, tree, VEC(tree,heap) *);
832 gimple gimple_build_omp_parallel (gimple_seq, tree, tree, tree);
833 gimple gimple_build_omp_task (gimple_seq, tree, tree, tree, tree, tree, tree);
834 gimple gimple_build_omp_for (gimple_seq, tree, size_t, gimple_seq);
835 gimple gimple_build_omp_critical (gimple_seq, tree);
836 gimple gimple_build_omp_section (gimple_seq);
837 gimple gimple_build_omp_continue (tree, tree);
838 gimple gimple_build_omp_master (gimple_seq);
839 gimple gimple_build_omp_return (bool);
840 gimple gimple_build_omp_ordered (gimple_seq);
841 gimple gimple_build_omp_sections (gimple_seq, tree);
842 gimple gimple_build_omp_sections_switch (void);
843 gimple gimple_build_omp_single (gimple_seq, tree);
844 gimple gimple_build_cdt (tree, tree);
845 gimple gimple_build_omp_atomic_load (tree, tree);
846 gimple gimple_build_omp_atomic_store (tree);
847 gimple gimple_build_predict (enum br_predictor, enum prediction);
848 enum gimple_statement_structure_enum gss_for_assign (enum tree_code);
849 void sort_case_labels (VEC(tree,heap) *);
850 void gimple_set_body (tree, gimple_seq);
851 gimple_seq gimple_body (tree);
852 bool gimple_has_body_p (tree);
853 gimple_seq gimple_seq_alloc (void);
854 void gimple_seq_free (gimple_seq);
855 void gimple_seq_add_seq (gimple_seq *, gimple_seq);
856 gimple_seq gimple_seq_copy (gimple_seq);
857 int gimple_call_flags (const_gimple);
858 int gimple_call_return_flags (const_gimple);
859 int gimple_call_arg_flags (const_gimple, unsigned);
860 void gimple_call_reset_alias_info (gimple);
861 bool gimple_assign_copy_p (gimple);
862 bool gimple_assign_ssa_name_copy_p (gimple);
863 bool gimple_assign_single_p (gimple);
864 bool gimple_assign_unary_nop_p (gimple);
865 void gimple_set_bb (gimple, struct basic_block_def *);
866 void gimple_assign_set_rhs_from_tree (gimple_stmt_iterator *, tree);
867 void gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *, enum tree_code,
869 tree gimple_get_lhs (const_gimple);
870 void gimple_set_lhs (gimple, tree);
871 void gimple_replace_lhs (gimple, tree);
872 gimple gimple_copy (gimple);
873 bool is_gimple_operand (const_tree);
874 void gimple_set_modified (gimple, bool);
875 void gimple_cond_get_ops_from_tree (tree, enum tree_code *, tree *, tree *);
876 gimple gimple_build_cond_from_tree (tree, tree, tree);
877 void gimple_cond_set_condition_from_tree (gimple, tree);
878 bool gimple_has_side_effects (const_gimple);
879 bool gimple_rhs_has_side_effects (const_gimple);
880 bool gimple_could_trap_p (gimple);
881 bool gimple_assign_rhs_could_trap_p (gimple);
882 void gimple_regimplify_operands (gimple, gimple_stmt_iterator *);
883 bool empty_body_p (gimple_seq);
884 unsigned get_gimple_rhs_num_ops (enum tree_code);
885 #define gimple_alloc(c, n) gimple_alloc_stat (c, n MEM_STAT_INFO)
886 gimple gimple_alloc_stat (enum gimple_code, unsigned MEM_STAT_DECL);
887 const char *gimple_decl_printable_name (tree, int);
888 tree gimple_fold_obj_type_ref (tree, tree);
889 tree gimple_get_relevant_ref_binfo (tree ref, tree known_binfo);
890 tree gimple_fold_obj_type_ref_known_binfo (HOST_WIDE_INT, tree);
892 /* Returns true iff T is a valid GIMPLE statement. */
893 extern bool is_gimple_stmt (tree);
895 /* Returns true iff TYPE is a valid type for a scalar register variable. */
896 extern bool is_gimple_reg_type (tree);
897 /* Returns true iff T is a scalar register variable. */
898 extern bool is_gimple_reg (tree);
899 /* Returns true iff T is any sort of variable. */
900 extern bool is_gimple_variable (tree);
901 /* Returns true iff T is any sort of symbol. */
902 extern bool is_gimple_id (tree);
903 /* Returns true iff T is a variable or an INDIRECT_REF (of a variable). */
904 extern bool is_gimple_min_lval (tree);
905 /* Returns true iff T is something whose address can be taken. */
906 extern bool is_gimple_addressable (tree);
907 /* Returns true iff T is any valid GIMPLE lvalue. */
908 extern bool is_gimple_lvalue (tree);
910 /* Returns true iff T is a GIMPLE address. */
911 bool is_gimple_address (const_tree);
912 /* Returns true iff T is a GIMPLE invariant address. */
913 bool is_gimple_invariant_address (const_tree);
914 /* Returns true iff T is a GIMPLE invariant address at interprocedural
916 bool is_gimple_ip_invariant_address (const_tree);
917 /* Returns true iff T is a valid GIMPLE constant. */
918 bool is_gimple_constant (const_tree);
919 /* Returns true iff T is a GIMPLE restricted function invariant. */
920 extern bool is_gimple_min_invariant (const_tree);
921 /* Returns true iff T is a GIMPLE restricted interprecodural invariant. */
922 extern bool is_gimple_ip_invariant (const_tree);
923 /* Returns true iff T is a GIMPLE rvalue. */
924 extern bool is_gimple_val (tree);
925 /* Returns true iff T is a GIMPLE asm statement input. */
926 extern bool is_gimple_asm_val (tree);
927 /* Returns true iff T is a valid rhs for a MODIFY_EXPR where the LHS is a
928 GIMPLE temporary, a renamed user variable, or something else,
930 extern bool is_gimple_reg_rhs (tree);
931 extern bool is_gimple_mem_rhs (tree);
933 /* Returns true iff T is a valid if-statement condition. */
934 extern bool is_gimple_condexpr (tree);
936 /* Returns true iff T is a type conversion. */
937 extern bool is_gimple_cast (tree);
938 /* Returns true iff T is a variable that does not need to live in memory. */
939 extern bool is_gimple_non_addressable (tree t);
941 /* Returns true iff T is a valid call address expression. */
942 extern bool is_gimple_call_addr (tree);
943 /* If T makes a function call, returns the CALL_EXPR operand. */
944 extern tree get_call_expr_in (tree t);
946 extern void recalculate_side_effects (tree);
947 extern bool gimple_compare_field_offset (tree, tree);
948 extern tree gimple_register_type (tree);
949 extern void print_gimple_types_stats (void);
950 extern void free_gimple_type_tables (void);
951 extern tree gimple_unsigned_type (tree);
952 extern tree gimple_signed_type (tree);
953 extern alias_set_type gimple_get_alias_set (tree);
954 extern void count_uses_and_derefs (tree, gimple, unsigned *, unsigned *,
956 extern bool walk_stmt_load_store_addr_ops (gimple, void *,
957 bool (*)(gimple, tree, void *),
958 bool (*)(gimple, tree, void *),
959 bool (*)(gimple, tree, void *));
960 extern bool walk_stmt_load_store_ops (gimple, void *,
961 bool (*)(gimple, tree, void *),
962 bool (*)(gimple, tree, void *));
963 extern bool gimple_ior_addresses_taken (bitmap, gimple);
964 extern bool gimple_call_builtin_p (gimple, enum built_in_function);
967 extern tree create_tmp_var_raw (tree, const char *);
968 extern tree create_tmp_var_name (const char *);
969 extern tree create_tmp_var (tree, const char *);
970 extern tree create_tmp_reg (tree, const char *);
971 extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq *);
972 extern tree get_formal_tmp_var (tree, gimple_seq *);
973 extern void declare_vars (tree, gimple, bool);
974 extern void annotate_all_with_location (gimple_seq, location_t);
976 /* Validation of GIMPLE expressions. Note that these predicates only check
977 the basic form of the expression, they don't recurse to make sure that
978 underlying nodes are also of the right form. */
979 typedef bool (*gimple_predicate)(tree);
982 /* FIXME we should deduce this from the predicate. */
984 fb_none = 0, /* Do not generate a temporary. */
986 fb_rvalue = 1, /* Generate an rvalue to hold the result of a
987 gimplified expression. */
989 fb_lvalue = 2, /* Generate an lvalue to hold the result of a
990 gimplified expression. */
992 fb_mayfail = 4, /* Gimplification may fail. Error issued
994 fb_either= fb_rvalue | fb_lvalue
997 typedef int fallback_t;
999 enum gimplify_status {
1000 GS_ERROR = -2, /* Something Bad Seen. */
1001 GS_UNHANDLED = -1, /* A langhook result for "I dunno". */
1002 GS_OK = 0, /* We did something, maybe more to do. */
1003 GS_ALL_DONE = 1 /* The expression is fully gimplified. */
1008 struct gimplify_ctx *prev_context;
1010 VEC(gimple,heap) *bind_expr_stack;
1012 gimple_seq conditional_cleanups;
1016 VEC(tree,heap) *case_labels;
1017 /* The formal temporary table. Should this be persistent? */
1023 bool allow_rhs_cond_expr;
1026 extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *,
1027 bool (*) (tree), fallback_t);
1028 extern void gimplify_type_sizes (tree, gimple_seq *);
1029 extern void gimplify_one_sizepos (tree *, gimple_seq *);
1030 extern bool gimplify_stmt (tree *, gimple_seq *);
1031 extern gimple gimplify_body (tree *, tree, bool);
1032 extern void push_gimplify_context (struct gimplify_ctx *);
1033 extern void pop_gimplify_context (gimple);
1034 extern void gimplify_and_add (tree, gimple_seq *);
1036 /* Miscellaneous helpers. */
1037 extern void gimple_add_tmp_var (tree);
1038 extern gimple gimple_current_bind_expr (void);
1039 extern VEC(gimple, heap) *gimple_bind_expr_stack (void);
1040 extern tree voidify_wrapper_expr (tree, tree);
1041 extern tree build_and_jump (tree *);
1042 extern tree force_labels_r (tree *, int *, void *);
1043 extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *,
1045 struct gimplify_omp_ctx;
1046 extern void omp_firstprivatize_variable (struct gimplify_omp_ctx *, tree);
1047 extern tree gimple_boolify (tree);
1048 extern gimple_predicate rhs_predicate_for (tree);
1049 extern tree canonicalize_cond_expr_cond (tree);
1052 extern tree omp_reduction_init (tree, tree);
1054 /* In tree-nested.c. */
1055 extern void lower_nested_functions (tree);
1056 extern void insert_field_into_struct (tree, tree);
1058 /* In gimplify.c. */
1059 extern void gimplify_function_tree (tree);
1061 /* In cfgexpand.c. */
1062 extern tree gimple_assign_rhs_to_tree (gimple);
1065 extern bool validate_gimple_arglist (const_gimple, ...);
1068 extern bool tree_ssa_useless_type_conversion (tree);
1069 extern tree tree_ssa_strip_useless_type_conversions (tree);
1070 extern bool useless_type_conversion_p (tree, tree);
1071 extern bool types_compatible_p (tree, tree);
1073 /* Return the code for GIMPLE statement G. */
1075 static inline enum gimple_code
1076 gimple_code (const_gimple g)
1078 return g->gsbase.code;
1082 /* Return the GSS code used by a GIMPLE code. */
1084 static inline enum gimple_statement_structure_enum
1085 gss_for_code (enum gimple_code code)
1087 #ifdef ENABLE_CHECKING
1088 gcc_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_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_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_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_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;
1467 else if (code == GIMPLE_CALL)
1474 /* Mark statement S as modified, and update it. */
1477 update_stmt (gimple s)
1479 if (gimple_has_ops (s))
1481 gimple_set_modified (s, true);
1482 update_stmt_operands (s);
1486 /* Update statement S if it has been optimized. */
1489 update_stmt_if_modified (gimple s)
1491 if (gimple_modified_p (s))
1492 update_stmt_operands (s);
1495 /* Return true if statement STMT contains volatile operands. */
1498 gimple_has_volatile_ops (const_gimple stmt)
1500 if (gimple_has_mem_ops (stmt))
1501 return stmt->gsbase.has_volatile_ops;
1507 /* Set the HAS_VOLATILE_OPS flag to VOLATILEP. */
1510 gimple_set_has_volatile_ops (gimple stmt, bool volatilep)
1512 if (gimple_has_mem_ops (stmt))
1513 stmt->gsbase.has_volatile_ops = (unsigned) volatilep;
1517 /* Return true if statement STMT may access memory. */
1520 gimple_references_memory_p (gimple stmt)
1522 return gimple_has_mem_ops (stmt) && gimple_vuse (stmt);
1526 /* Return the subcode for OMP statement S. */
1528 static inline unsigned
1529 gimple_omp_subcode (const_gimple s)
1531 gcc_assert (gimple_code (s) >= GIMPLE_OMP_ATOMIC_LOAD
1532 && gimple_code (s) <= GIMPLE_OMP_SINGLE);
1533 return s->gsbase.subcode;
1536 /* Set the subcode for OMP statement S to SUBCODE. */
1539 gimple_omp_set_subcode (gimple s, unsigned int subcode)
1541 /* We only have 16 bits for the subcode. Assert that we are not
1543 gcc_assert (subcode < (1 << 16));
1544 s->gsbase.subcode = subcode;
1547 /* Set the nowait flag on OMP_RETURN statement S. */
1550 gimple_omp_return_set_nowait (gimple s)
1552 GIMPLE_CHECK (s, GIMPLE_OMP_RETURN);
1553 s->gsbase.subcode |= GF_OMP_RETURN_NOWAIT;
1557 /* Return true if OMP return statement G has the GF_OMP_RETURN_NOWAIT
1561 gimple_omp_return_nowait_p (const_gimple g)
1563 GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
1564 return (gimple_omp_subcode (g) & GF_OMP_RETURN_NOWAIT) != 0;
1568 /* Return true if OMP section statement G has the GF_OMP_SECTION_LAST
1572 gimple_omp_section_last_p (const_gimple g)
1574 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1575 return (gimple_omp_subcode (g) & GF_OMP_SECTION_LAST) != 0;
1579 /* Set the GF_OMP_SECTION_LAST flag on G. */
1582 gimple_omp_section_set_last (gimple g)
1584 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1585 g->gsbase.subcode |= GF_OMP_SECTION_LAST;
1589 /* Return true if OMP parallel statement G has the
1590 GF_OMP_PARALLEL_COMBINED flag set. */
1593 gimple_omp_parallel_combined_p (const_gimple g)
1595 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1596 return (gimple_omp_subcode (g) & GF_OMP_PARALLEL_COMBINED) != 0;
1600 /* Set the GF_OMP_PARALLEL_COMBINED field in G depending on the boolean
1601 value of COMBINED_P. */
1604 gimple_omp_parallel_set_combined_p (gimple g, bool combined_p)
1606 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1608 g->gsbase.subcode |= GF_OMP_PARALLEL_COMBINED;
1610 g->gsbase.subcode &= ~GF_OMP_PARALLEL_COMBINED;
1614 /* Return the number of operands for statement GS. */
1616 static inline unsigned
1617 gimple_num_ops (const_gimple gs)
1619 return gs->gsbase.num_ops;
1623 /* Set the number of operands for statement GS. */
1626 gimple_set_num_ops (gimple gs, unsigned num_ops)
1628 gs->gsbase.num_ops = num_ops;
1632 /* Return the array of operands for statement GS. */
1634 static inline tree *
1635 gimple_ops (gimple gs)
1639 /* All the tuples have their operand vector at the very bottom
1640 of the structure. Note that those structures that do not
1641 have an operand vector have a zero offset. */
1642 off = gimple_ops_offset_[gimple_statement_structure (gs)];
1643 gcc_assert (off != 0);
1645 return (tree *) ((char *) gs + off);
1649 /* Return operand I for statement GS. */
1652 gimple_op (const_gimple gs, unsigned i)
1654 if (gimple_has_ops (gs))
1656 #ifdef ENABLE_CHECKING
1657 gcc_assert (i < gimple_num_ops (gs));
1659 return gimple_ops (CONST_CAST_GIMPLE (gs))[i];
1665 /* Return a pointer to operand I for statement GS. */
1667 static inline tree *
1668 gimple_op_ptr (const_gimple gs, unsigned i)
1670 if (gimple_has_ops (gs))
1672 #ifdef ENABLE_CHECKING
1673 gcc_assert (i < gimple_num_ops (gs));
1675 return gimple_ops (CONST_CAST_GIMPLE (gs)) + i;
1681 /* Set operand I of statement GS to OP. */
1684 gimple_set_op (gimple gs, unsigned i, tree op)
1686 gcc_assert (gimple_has_ops (gs) && i < gimple_num_ops (gs));
1688 /* Note. It may be tempting to assert that OP matches
1689 is_gimple_operand, but that would be wrong. Different tuples
1690 accept slightly different sets of tree operands. Each caller
1691 should perform its own validation. */
1692 gimple_ops (gs)[i] = op;
1695 /* Return true if GS is a GIMPLE_ASSIGN. */
1698 is_gimple_assign (const_gimple gs)
1700 return gimple_code (gs) == GIMPLE_ASSIGN;
1703 /* Determine if expression CODE is one of the valid expressions that can
1704 be used on the RHS of GIMPLE assignments. */
1706 static inline enum gimple_rhs_class
1707 get_gimple_rhs_class (enum tree_code code)
1709 return (enum gimple_rhs_class) gimple_rhs_class_table[(int) code];
1712 /* Return the LHS of assignment statement GS. */
1715 gimple_assign_lhs (const_gimple gs)
1717 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1718 return gimple_op (gs, 0);
1722 /* Return a pointer to the LHS of assignment statement GS. */
1724 static inline tree *
1725 gimple_assign_lhs_ptr (const_gimple gs)
1727 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1728 return gimple_op_ptr (gs, 0);
1732 /* Set LHS to be the LHS operand of assignment statement GS. */
1735 gimple_assign_set_lhs (gimple gs, tree lhs)
1737 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1738 gimple_set_op (gs, 0, lhs);
1740 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1741 SSA_NAME_DEF_STMT (lhs) = gs;
1745 /* Return the first operand on the RHS of assignment statement GS. */
1748 gimple_assign_rhs1 (const_gimple gs)
1750 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1751 return gimple_op (gs, 1);
1755 /* Return a pointer to the first operand on the RHS of assignment
1758 static inline tree *
1759 gimple_assign_rhs1_ptr (const_gimple gs)
1761 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1762 return gimple_op_ptr (gs, 1);
1765 /* Set RHS to be the first operand on the RHS of assignment statement GS. */
1768 gimple_assign_set_rhs1 (gimple gs, tree rhs)
1770 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1772 gimple_set_op (gs, 1, rhs);
1776 /* Return the second operand on the RHS of assignment statement GS.
1777 If GS does not have two operands, NULL is returned instead. */
1780 gimple_assign_rhs2 (const_gimple gs)
1782 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1784 if (gimple_num_ops (gs) >= 3)
1785 return gimple_op (gs, 2);
1791 /* Return a pointer to the second operand on the RHS of assignment
1794 static inline tree *
1795 gimple_assign_rhs2_ptr (const_gimple gs)
1797 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1798 return gimple_op_ptr (gs, 2);
1802 /* Set RHS to be the second operand on the RHS of assignment statement GS. */
1805 gimple_assign_set_rhs2 (gimple gs, tree rhs)
1807 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1809 gimple_set_op (gs, 2, rhs);
1812 /* Returns true if GS is a nontemporal move. */
1815 gimple_assign_nontemporal_move_p (const_gimple gs)
1817 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1818 return gs->gsbase.nontemporal_move;
1821 /* Sets nontemporal move flag of GS to NONTEMPORAL. */
1824 gimple_assign_set_nontemporal_move (gimple gs, bool nontemporal)
1826 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1827 gs->gsbase.nontemporal_move = nontemporal;
1831 /* Return the code of the expression computed on the rhs of assignment
1832 statement GS. In case that the RHS is a single object, returns the
1833 tree code of the object. */
1835 static inline enum tree_code
1836 gimple_assign_rhs_code (const_gimple gs)
1838 enum tree_code code;
1839 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1841 code = gimple_expr_code (gs);
1842 if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS)
1843 code = TREE_CODE (gimple_assign_rhs1 (gs));
1849 /* Set CODE to be the code for the expression computed on the RHS of
1853 gimple_assign_set_rhs_code (gimple s, enum tree_code code)
1855 GIMPLE_CHECK (s, GIMPLE_ASSIGN);
1856 s->gsbase.subcode = code;
1860 /* Return the gimple rhs class of the code of the expression computed on
1861 the rhs of assignment statement GS.
1862 This will never return GIMPLE_INVALID_RHS. */
1864 static inline enum gimple_rhs_class
1865 gimple_assign_rhs_class (const_gimple gs)
1867 return get_gimple_rhs_class (gimple_assign_rhs_code (gs));
1871 /* Return true if S is a type-cast assignment. */
1874 gimple_assign_cast_p (gimple s)
1876 if (is_gimple_assign (s))
1878 enum tree_code sc = gimple_assign_rhs_code (s);
1879 return CONVERT_EXPR_CODE_P (sc)
1880 || sc == VIEW_CONVERT_EXPR
1881 || sc == FIX_TRUNC_EXPR;
1888 /* Return true if GS is a GIMPLE_CALL. */
1891 is_gimple_call (const_gimple gs)
1893 return gimple_code (gs) == GIMPLE_CALL;
1896 /* Return the LHS of call statement GS. */
1899 gimple_call_lhs (const_gimple gs)
1901 GIMPLE_CHECK (gs, GIMPLE_CALL);
1902 return gimple_op (gs, 0);
1906 /* Return a pointer to the LHS of call statement GS. */
1908 static inline tree *
1909 gimple_call_lhs_ptr (const_gimple gs)
1911 GIMPLE_CHECK (gs, GIMPLE_CALL);
1912 return gimple_op_ptr (gs, 0);
1916 /* Set LHS to be the LHS operand of call statement GS. */
1919 gimple_call_set_lhs (gimple gs, tree lhs)
1921 GIMPLE_CHECK (gs, GIMPLE_CALL);
1922 gimple_set_op (gs, 0, lhs);
1923 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1924 SSA_NAME_DEF_STMT (lhs) = gs;
1928 /* Return the tree node representing the function called by call
1932 gimple_call_fn (const_gimple gs)
1934 GIMPLE_CHECK (gs, GIMPLE_CALL);
1935 return gimple_op (gs, 1);
1939 /* Return a pointer to the tree node representing the function called by call
1942 static inline tree *
1943 gimple_call_fn_ptr (const_gimple gs)
1945 GIMPLE_CHECK (gs, GIMPLE_CALL);
1946 return gimple_op_ptr (gs, 1);
1950 /* Set FN to be the function called by call statement GS. */
1953 gimple_call_set_fn (gimple gs, tree fn)
1955 GIMPLE_CHECK (gs, GIMPLE_CALL);
1956 gimple_set_op (gs, 1, fn);
1960 /* Set FNDECL to be the function called by call statement GS. */
1963 gimple_call_set_fndecl (gimple gs, tree decl)
1965 GIMPLE_CHECK (gs, GIMPLE_CALL);
1966 gimple_set_op (gs, 1, build_fold_addr_expr_loc (gimple_location (gs), decl));
1970 /* If a given GIMPLE_CALL's callee is a FUNCTION_DECL, return it.
1971 Otherwise return NULL. This function is analogous to
1972 get_callee_fndecl in tree land. */
1975 gimple_call_fndecl (const_gimple gs)
1977 tree addr = gimple_call_fn (gs);
1978 if (TREE_CODE (addr) == ADDR_EXPR)
1979 return TREE_OPERAND (addr, 0);
1984 /* Return the type returned by call statement GS. */
1987 gimple_call_return_type (const_gimple gs)
1989 tree fn = gimple_call_fn (gs);
1990 tree type = TREE_TYPE (fn);
1992 /* See through the pointer. */
1993 type = TREE_TYPE (type);
1995 /* The type returned by a FUNCTION_DECL is the type of its
1997 return TREE_TYPE (type);
2001 /* Return the static chain for call statement GS. */
2004 gimple_call_chain (const_gimple gs)
2006 GIMPLE_CHECK (gs, GIMPLE_CALL);
2007 return gimple_op (gs, 2);
2011 /* Return a pointer to the static chain for call statement GS. */
2013 static inline tree *
2014 gimple_call_chain_ptr (const_gimple gs)
2016 GIMPLE_CHECK (gs, GIMPLE_CALL);
2017 return gimple_op_ptr (gs, 2);
2020 /* Set CHAIN to be the static chain for call statement GS. */
2023 gimple_call_set_chain (gimple gs, tree chain)
2025 GIMPLE_CHECK (gs, GIMPLE_CALL);
2027 gimple_set_op (gs, 2, chain);
2031 /* Return the number of arguments used by call statement GS. */
2033 static inline unsigned
2034 gimple_call_num_args (const_gimple gs)
2037 GIMPLE_CHECK (gs, GIMPLE_CALL);
2038 num_ops = gimple_num_ops (gs);
2043 /* Return the argument at position INDEX for call statement GS. */
2046 gimple_call_arg (const_gimple gs, unsigned index)
2048 GIMPLE_CHECK (gs, GIMPLE_CALL);
2049 return gimple_op (gs, index + 3);
2053 /* Return a pointer to the argument at position INDEX for call
2056 static inline tree *
2057 gimple_call_arg_ptr (const_gimple gs, unsigned index)
2059 GIMPLE_CHECK (gs, GIMPLE_CALL);
2060 return gimple_op_ptr (gs, index + 3);
2064 /* Set ARG to be the argument at position INDEX for call statement GS. */
2067 gimple_call_set_arg (gimple gs, unsigned index, tree arg)
2069 GIMPLE_CHECK (gs, GIMPLE_CALL);
2070 gimple_set_op (gs, index + 3, arg);
2074 /* If TAIL_P is true, mark call statement S as being a tail call
2075 (i.e., a call just before the exit of a function). These calls are
2076 candidate for tail call optimization. */
2079 gimple_call_set_tail (gimple s, bool tail_p)
2081 GIMPLE_CHECK (s, GIMPLE_CALL);
2083 s->gsbase.subcode |= GF_CALL_TAILCALL;
2085 s->gsbase.subcode &= ~GF_CALL_TAILCALL;
2089 /* Return true if GIMPLE_CALL S is marked as a tail call. */
2092 gimple_call_tail_p (gimple s)
2094 GIMPLE_CHECK (s, GIMPLE_CALL);
2095 return (s->gsbase.subcode & GF_CALL_TAILCALL) != 0;
2099 /* Set the inlinable status of GIMPLE_CALL S to INLINABLE_P. */
2102 gimple_call_set_cannot_inline (gimple s, bool inlinable_p)
2104 GIMPLE_CHECK (s, GIMPLE_CALL);
2106 s->gsbase.subcode |= GF_CALL_CANNOT_INLINE;
2108 s->gsbase.subcode &= ~GF_CALL_CANNOT_INLINE;
2112 /* Return true if GIMPLE_CALL S cannot be inlined. */
2115 gimple_call_cannot_inline_p (gimple s)
2117 GIMPLE_CHECK (s, GIMPLE_CALL);
2118 return (s->gsbase.subcode & GF_CALL_CANNOT_INLINE) != 0;
2122 /* If RETURN_SLOT_OPT_P is true mark GIMPLE_CALL S as valid for return
2123 slot optimization. This transformation uses the target of the call
2124 expansion as the return slot for calls that return in memory. */
2127 gimple_call_set_return_slot_opt (gimple s, bool return_slot_opt_p)
2129 GIMPLE_CHECK (s, GIMPLE_CALL);
2130 if (return_slot_opt_p)
2131 s->gsbase.subcode |= GF_CALL_RETURN_SLOT_OPT;
2133 s->gsbase.subcode &= ~GF_CALL_RETURN_SLOT_OPT;
2137 /* Return true if S is marked for return slot optimization. */
2140 gimple_call_return_slot_opt_p (gimple s)
2142 GIMPLE_CHECK (s, GIMPLE_CALL);
2143 return (s->gsbase.subcode & GF_CALL_RETURN_SLOT_OPT) != 0;
2147 /* If FROM_THUNK_P is true, mark GIMPLE_CALL S as being the jump from a
2148 thunk to the thunked-to function. */
2151 gimple_call_set_from_thunk (gimple s, bool from_thunk_p)
2153 GIMPLE_CHECK (s, GIMPLE_CALL);
2155 s->gsbase.subcode |= GF_CALL_FROM_THUNK;
2157 s->gsbase.subcode &= ~GF_CALL_FROM_THUNK;
2161 /* Return true if GIMPLE_CALL S is a jump from a thunk. */
2164 gimple_call_from_thunk_p (gimple s)
2166 GIMPLE_CHECK (s, GIMPLE_CALL);
2167 return (s->gsbase.subcode & GF_CALL_FROM_THUNK) != 0;
2171 /* If PASS_ARG_PACK_P is true, GIMPLE_CALL S is a stdarg call that needs the
2172 argument pack in its argument list. */
2175 gimple_call_set_va_arg_pack (gimple s, bool pass_arg_pack_p)
2177 GIMPLE_CHECK (s, GIMPLE_CALL);
2178 if (pass_arg_pack_p)
2179 s->gsbase.subcode |= GF_CALL_VA_ARG_PACK;
2181 s->gsbase.subcode &= ~GF_CALL_VA_ARG_PACK;
2185 /* Return true if GIMPLE_CALL S is a stdarg call that needs the
2186 argument pack in its argument list. */
2189 gimple_call_va_arg_pack_p (gimple s)
2191 GIMPLE_CHECK (s, GIMPLE_CALL);
2192 return (s->gsbase.subcode & GF_CALL_VA_ARG_PACK) != 0;
2196 /* Return true if S is a noreturn call. */
2199 gimple_call_noreturn_p (gimple s)
2201 GIMPLE_CHECK (s, GIMPLE_CALL);
2202 return (gimple_call_flags (s) & ECF_NORETURN) != 0;
2206 /* If NOTHROW_P is true, GIMPLE_CALL S is a call that is known to not throw
2207 even if the called function can throw in other cases. */
2210 gimple_call_set_nothrow (gimple s, bool nothrow_p)
2212 GIMPLE_CHECK (s, GIMPLE_CALL);
2214 s->gsbase.subcode |= GF_CALL_NOTHROW;
2216 s->gsbase.subcode &= ~GF_CALL_NOTHROW;
2219 /* Return true if S is a nothrow call. */
2222 gimple_call_nothrow_p (gimple s)
2224 GIMPLE_CHECK (s, GIMPLE_CALL);
2225 return (gimple_call_flags (s) & ECF_NOTHROW) != 0;
2229 /* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL. */
2232 gimple_call_copy_flags (gimple dest_call, gimple orig_call)
2234 GIMPLE_CHECK (dest_call, GIMPLE_CALL);
2235 GIMPLE_CHECK (orig_call, GIMPLE_CALL);
2236 dest_call->gsbase.subcode = orig_call->gsbase.subcode;
2240 /* Return a pointer to the points-to solution for the set of call-used
2241 variables of the call CALL. */
2243 static inline struct pt_solution *
2244 gimple_call_use_set (gimple call)
2246 GIMPLE_CHECK (call, GIMPLE_CALL);
2247 return &call->gimple_call.call_used;
2251 /* Return a pointer to the points-to solution for the set of call-used
2252 variables of the call CALL. */
2254 static inline struct pt_solution *
2255 gimple_call_clobber_set (gimple call)
2257 GIMPLE_CHECK (call, GIMPLE_CALL);
2258 return &call->gimple_call.call_clobbered;
2262 /* Returns true if this is a GIMPLE_ASSIGN or a GIMPLE_CALL with a
2266 gimple_has_lhs (gimple stmt)
2268 return (is_gimple_assign (stmt)
2269 || (is_gimple_call (stmt)
2270 && gimple_call_lhs (stmt) != NULL_TREE));
2274 /* Return the code of the predicate computed by conditional statement GS. */
2276 static inline enum tree_code
2277 gimple_cond_code (const_gimple gs)
2279 GIMPLE_CHECK (gs, GIMPLE_COND);
2280 return (enum tree_code) gs->gsbase.subcode;
2284 /* Set CODE to be the predicate code for the conditional statement GS. */
2287 gimple_cond_set_code (gimple gs, enum tree_code code)
2289 GIMPLE_CHECK (gs, GIMPLE_COND);
2290 gs->gsbase.subcode = code;
2294 /* Return the LHS of the predicate computed by conditional statement GS. */
2297 gimple_cond_lhs (const_gimple gs)
2299 GIMPLE_CHECK (gs, GIMPLE_COND);
2300 return gimple_op (gs, 0);
2303 /* Return the pointer to the LHS of the predicate computed by conditional
2306 static inline tree *
2307 gimple_cond_lhs_ptr (const_gimple gs)
2309 GIMPLE_CHECK (gs, GIMPLE_COND);
2310 return gimple_op_ptr (gs, 0);
2313 /* Set LHS to be the LHS operand of the predicate computed by
2314 conditional statement GS. */
2317 gimple_cond_set_lhs (gimple gs, tree lhs)
2319 GIMPLE_CHECK (gs, GIMPLE_COND);
2320 gimple_set_op (gs, 0, lhs);
2324 /* Return the RHS operand of the predicate computed by conditional GS. */
2327 gimple_cond_rhs (const_gimple gs)
2329 GIMPLE_CHECK (gs, GIMPLE_COND);
2330 return gimple_op (gs, 1);
2333 /* Return the pointer to the RHS operand of the predicate computed by
2336 static inline tree *
2337 gimple_cond_rhs_ptr (const_gimple gs)
2339 GIMPLE_CHECK (gs, GIMPLE_COND);
2340 return gimple_op_ptr (gs, 1);
2344 /* Set RHS to be the RHS operand of the predicate computed by
2345 conditional statement GS. */
2348 gimple_cond_set_rhs (gimple gs, tree rhs)
2350 GIMPLE_CHECK (gs, GIMPLE_COND);
2351 gimple_set_op (gs, 1, rhs);
2355 /* Return the label used by conditional statement GS when its
2356 predicate evaluates to true. */
2359 gimple_cond_true_label (const_gimple gs)
2361 GIMPLE_CHECK (gs, GIMPLE_COND);
2362 return gimple_op (gs, 2);
2366 /* Set LABEL to be the label used by conditional statement GS when its
2367 predicate evaluates to true. */
2370 gimple_cond_set_true_label (gimple gs, tree label)
2372 GIMPLE_CHECK (gs, GIMPLE_COND);
2373 gimple_set_op (gs, 2, label);
2377 /* Set LABEL to be the label used by conditional statement GS when its
2378 predicate evaluates to false. */
2381 gimple_cond_set_false_label (gimple gs, tree label)
2383 GIMPLE_CHECK (gs, GIMPLE_COND);
2384 gimple_set_op (gs, 3, label);
2388 /* Return the label used by conditional statement GS when its
2389 predicate evaluates to false. */
2392 gimple_cond_false_label (const_gimple gs)
2394 GIMPLE_CHECK (gs, GIMPLE_COND);
2395 return gimple_op (gs, 3);
2399 /* Set the conditional COND_STMT to be of the form 'if (1 == 0)'. */
2402 gimple_cond_make_false (gimple gs)
2404 gimple_cond_set_lhs (gs, boolean_true_node);
2405 gimple_cond_set_rhs (gs, boolean_false_node);
2406 gs->gsbase.subcode = EQ_EXPR;
2410 /* Set the conditional COND_STMT to be of the form 'if (1 == 1)'. */
2413 gimple_cond_make_true (gimple gs)
2415 gimple_cond_set_lhs (gs, boolean_true_node);
2416 gimple_cond_set_rhs (gs, boolean_true_node);
2417 gs->gsbase.subcode = EQ_EXPR;
2420 /* Check if conditional statemente GS is of the form 'if (1 == 1)',
2421 'if (0 == 0)', 'if (1 != 0)' or 'if (0 != 1)' */
2424 gimple_cond_true_p (const_gimple gs)
2426 tree lhs = gimple_cond_lhs (gs);
2427 tree rhs = gimple_cond_rhs (gs);
2428 enum tree_code code = gimple_cond_code (gs);
2430 if (lhs != boolean_true_node && lhs != boolean_false_node)
2433 if (rhs != boolean_true_node && rhs != boolean_false_node)
2436 if (code == NE_EXPR && lhs != rhs)
2439 if (code == EQ_EXPR && lhs == rhs)
2445 /* Check if conditional statement GS is of the form 'if (1 != 1)',
2446 'if (0 != 0)', 'if (1 == 0)' or 'if (0 == 1)' */
2449 gimple_cond_false_p (const_gimple gs)
2451 tree lhs = gimple_cond_lhs (gs);
2452 tree rhs = gimple_cond_rhs (gs);
2453 enum tree_code code = gimple_cond_code (gs);
2455 if (lhs != boolean_true_node && lhs != boolean_false_node)
2458 if (rhs != boolean_true_node && rhs != boolean_false_node)
2461 if (code == NE_EXPR && lhs == rhs)
2464 if (code == EQ_EXPR && lhs != rhs)
2470 /* Check if conditional statement GS is of the form 'if (var != 0)' or
2474 gimple_cond_single_var_p (gimple gs)
2476 if (gimple_cond_code (gs) == NE_EXPR
2477 && gimple_cond_rhs (gs) == boolean_false_node)
2480 if (gimple_cond_code (gs) == EQ_EXPR
2481 && gimple_cond_rhs (gs) == boolean_true_node)
2487 /* Set the code, LHS and RHS of GIMPLE_COND STMT from CODE, LHS and RHS. */
2490 gimple_cond_set_condition (gimple stmt, enum tree_code code, tree lhs, tree rhs)
2492 gimple_cond_set_code (stmt, code);
2493 gimple_cond_set_lhs (stmt, lhs);
2494 gimple_cond_set_rhs (stmt, rhs);
2497 /* Return the LABEL_DECL node used by GIMPLE_LABEL statement GS. */
2500 gimple_label_label (const_gimple gs)
2502 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2503 return gimple_op (gs, 0);
2507 /* Set LABEL to be the LABEL_DECL node used by GIMPLE_LABEL statement
2511 gimple_label_set_label (gimple gs, tree label)
2513 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2514 gimple_set_op (gs, 0, label);
2518 /* Return the destination of the unconditional jump GS. */
2521 gimple_goto_dest (const_gimple gs)
2523 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2524 return gimple_op (gs, 0);
2528 /* Set DEST to be the destination of the unconditonal jump GS. */
2531 gimple_goto_set_dest (gimple gs, tree dest)
2533 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2534 gimple_set_op (gs, 0, dest);
2538 /* Return the variables declared in the GIMPLE_BIND statement GS. */
2541 gimple_bind_vars (const_gimple gs)
2543 GIMPLE_CHECK (gs, GIMPLE_BIND);
2544 return gs->gimple_bind.vars;
2548 /* Set VARS to be the set of variables declared in the GIMPLE_BIND
2552 gimple_bind_set_vars (gimple gs, tree vars)
2554 GIMPLE_CHECK (gs, GIMPLE_BIND);
2555 gs->gimple_bind.vars = vars;
2559 /* Append VARS to the set of variables declared in the GIMPLE_BIND
2563 gimple_bind_append_vars (gimple gs, tree vars)
2565 GIMPLE_CHECK (gs, GIMPLE_BIND);
2566 gs->gimple_bind.vars = chainon (gs->gimple_bind.vars, vars);
2570 /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS. */
2572 static inline gimple_seq
2573 gimple_bind_body (gimple gs)
2575 GIMPLE_CHECK (gs, GIMPLE_BIND);
2576 return gs->gimple_bind.body;
2580 /* Set SEQ to be the GIMPLE sequence contained in the GIMPLE_BIND
2584 gimple_bind_set_body (gimple gs, gimple_seq seq)
2586 GIMPLE_CHECK (gs, GIMPLE_BIND);
2587 gs->gimple_bind.body = seq;
2591 /* Append a statement to the end of a GIMPLE_BIND's body. */
2594 gimple_bind_add_stmt (gimple gs, gimple stmt)
2596 GIMPLE_CHECK (gs, GIMPLE_BIND);
2597 gimple_seq_add_stmt (&gs->gimple_bind.body, stmt);
2601 /* Append a sequence of statements to the end of a GIMPLE_BIND's body. */
2604 gimple_bind_add_seq (gimple gs, gimple_seq seq)
2606 GIMPLE_CHECK (gs, GIMPLE_BIND);
2607 gimple_seq_add_seq (&gs->gimple_bind.body, seq);
2611 /* Return the TREE_BLOCK node associated with GIMPLE_BIND statement
2612 GS. This is analogous to the BIND_EXPR_BLOCK field in trees. */
2615 gimple_bind_block (const_gimple gs)
2617 GIMPLE_CHECK (gs, GIMPLE_BIND);
2618 return gs->gimple_bind.block;
2622 /* Set BLOCK to be the TREE_BLOCK node associated with GIMPLE_BIND
2626 gimple_bind_set_block (gimple gs, tree block)
2628 GIMPLE_CHECK (gs, GIMPLE_BIND);
2629 gcc_assert (block == NULL_TREE || TREE_CODE (block) == BLOCK);
2630 gs->gimple_bind.block = block;
2634 /* Return the number of input operands for GIMPLE_ASM GS. */
2636 static inline unsigned
2637 gimple_asm_ninputs (const_gimple gs)
2639 GIMPLE_CHECK (gs, GIMPLE_ASM);
2640 return gs->gimple_asm.ni;
2644 /* Return the number of output operands for GIMPLE_ASM GS. */
2646 static inline unsigned
2647 gimple_asm_noutputs (const_gimple gs)
2649 GIMPLE_CHECK (gs, GIMPLE_ASM);
2650 return gs->gimple_asm.no;
2654 /* Return the number of clobber operands for GIMPLE_ASM GS. */
2656 static inline unsigned
2657 gimple_asm_nclobbers (const_gimple gs)
2659 GIMPLE_CHECK (gs, GIMPLE_ASM);
2660 return gs->gimple_asm.nc;
2663 /* Return the number of label operands for GIMPLE_ASM GS. */
2665 static inline unsigned
2666 gimple_asm_nlabels (const_gimple gs)
2668 GIMPLE_CHECK (gs, GIMPLE_ASM);
2669 return gs->gimple_asm.nl;
2672 /* Return input operand INDEX of GIMPLE_ASM GS. */
2675 gimple_asm_input_op (const_gimple gs, unsigned index)
2677 GIMPLE_CHECK (gs, GIMPLE_ASM);
2678 gcc_assert (index <= gs->gimple_asm.ni);
2679 return gimple_op (gs, index);
2682 /* Return a pointer to input operand INDEX of GIMPLE_ASM GS. */
2684 static inline tree *
2685 gimple_asm_input_op_ptr (const_gimple gs, unsigned index)
2687 GIMPLE_CHECK (gs, GIMPLE_ASM);
2688 gcc_assert (index <= gs->gimple_asm.ni);
2689 return gimple_op_ptr (gs, index);
2693 /* Set IN_OP to be input operand INDEX in GIMPLE_ASM GS. */
2696 gimple_asm_set_input_op (gimple gs, unsigned index, tree in_op)
2698 GIMPLE_CHECK (gs, GIMPLE_ASM);
2699 gcc_assert (index <= gs->gimple_asm.ni);
2700 gcc_assert (TREE_CODE (in_op) == TREE_LIST);
2701 gimple_set_op (gs, index, in_op);
2705 /* Return output operand INDEX of GIMPLE_ASM GS. */
2708 gimple_asm_output_op (const_gimple gs, unsigned index)
2710 GIMPLE_CHECK (gs, GIMPLE_ASM);
2711 gcc_assert (index <= gs->gimple_asm.no);
2712 return gimple_op (gs, index + gs->gimple_asm.ni);
2715 /* Return a pointer to output operand INDEX of GIMPLE_ASM GS. */
2717 static inline tree *
2718 gimple_asm_output_op_ptr (const_gimple gs, unsigned index)
2720 GIMPLE_CHECK (gs, GIMPLE_ASM);
2721 gcc_assert (index <= gs->gimple_asm.no);
2722 return gimple_op_ptr (gs, index + gs->gimple_asm.ni);
2726 /* Set OUT_OP to be output operand INDEX in GIMPLE_ASM GS. */
2729 gimple_asm_set_output_op (gimple gs, unsigned index, tree out_op)
2731 GIMPLE_CHECK (gs, GIMPLE_ASM);
2732 gcc_assert (index <= gs->gimple_asm.no);
2733 gcc_assert (TREE_CODE (out_op) == TREE_LIST);
2734 gimple_set_op (gs, index + gs->gimple_asm.ni, out_op);
2738 /* Return clobber operand INDEX of GIMPLE_ASM GS. */
2741 gimple_asm_clobber_op (const_gimple gs, unsigned index)
2743 GIMPLE_CHECK (gs, GIMPLE_ASM);
2744 gcc_assert (index <= gs->gimple_asm.nc);
2745 return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no);
2749 /* Set CLOBBER_OP to be clobber operand INDEX in GIMPLE_ASM GS. */
2752 gimple_asm_set_clobber_op (gimple gs, unsigned index, tree clobber_op)
2754 GIMPLE_CHECK (gs, GIMPLE_ASM);
2755 gcc_assert (index <= gs->gimple_asm.nc);
2756 gcc_assert (TREE_CODE (clobber_op) == TREE_LIST);
2757 gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no, clobber_op);
2760 /* Return label operand INDEX of GIMPLE_ASM GS. */
2763 gimple_asm_label_op (const_gimple gs, unsigned index)
2765 GIMPLE_CHECK (gs, GIMPLE_ASM);
2766 gcc_assert (index <= gs->gimple_asm.nl);
2767 return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.nc);
2770 /* Set LABEL_OP to be label operand INDEX in GIMPLE_ASM GS. */
2773 gimple_asm_set_label_op (gimple gs, unsigned index, tree label_op)
2775 GIMPLE_CHECK (gs, GIMPLE_ASM);
2776 gcc_assert (index <= gs->gimple_asm.nl);
2777 gcc_assert (TREE_CODE (label_op) == TREE_LIST);
2778 gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.nc, label_op);
2781 /* Return the string representing the assembly instruction in
2784 static inline const char *
2785 gimple_asm_string (const_gimple gs)
2787 GIMPLE_CHECK (gs, GIMPLE_ASM);
2788 return gs->gimple_asm.string;
2792 /* Return true if GS is an asm statement marked volatile. */
2795 gimple_asm_volatile_p (const_gimple gs)
2797 GIMPLE_CHECK (gs, GIMPLE_ASM);
2798 return (gs->gsbase.subcode & GF_ASM_VOLATILE) != 0;
2802 /* If VOLATLE_P is true, mark asm statement GS as volatile. */
2805 gimple_asm_set_volatile (gimple gs, bool volatile_p)
2807 GIMPLE_CHECK (gs, GIMPLE_ASM);
2809 gs->gsbase.subcode |= GF_ASM_VOLATILE;
2811 gs->gsbase.subcode &= ~GF_ASM_VOLATILE;
2815 /* If INPUT_P is true, mark asm GS as an ASM_INPUT. */
2818 gimple_asm_set_input (gimple gs, bool input_p)
2820 GIMPLE_CHECK (gs, GIMPLE_ASM);
2822 gs->gsbase.subcode |= GF_ASM_INPUT;
2824 gs->gsbase.subcode &= ~GF_ASM_INPUT;
2828 /* Return true if asm GS is an ASM_INPUT. */
2831 gimple_asm_input_p (const_gimple gs)
2833 GIMPLE_CHECK (gs, GIMPLE_ASM);
2834 return (gs->gsbase.subcode & GF_ASM_INPUT) != 0;
2838 /* Return the types handled by GIMPLE_CATCH statement GS. */
2841 gimple_catch_types (const_gimple gs)
2843 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2844 return gs->gimple_catch.types;
2848 /* Return a pointer to the types handled by GIMPLE_CATCH statement GS. */
2850 static inline tree *
2851 gimple_catch_types_ptr (gimple gs)
2853 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2854 return &gs->gimple_catch.types;
2858 /* Return the GIMPLE sequence representing the body of the handler of
2859 GIMPLE_CATCH statement GS. */
2861 static inline gimple_seq
2862 gimple_catch_handler (gimple gs)
2864 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2865 return gs->gimple_catch.handler;
2869 /* Return a pointer to the GIMPLE sequence representing the body of
2870 the handler of GIMPLE_CATCH statement GS. */
2872 static inline gimple_seq *
2873 gimple_catch_handler_ptr (gimple gs)
2875 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2876 return &gs->gimple_catch.handler;
2880 /* Set T to be the set of types handled by GIMPLE_CATCH GS. */
2883 gimple_catch_set_types (gimple gs, tree t)
2885 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2886 gs->gimple_catch.types = t;
2890 /* Set HANDLER to be the body of GIMPLE_CATCH GS. */
2893 gimple_catch_set_handler (gimple gs, gimple_seq handler)
2895 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2896 gs->gimple_catch.handler = handler;
2900 /* Return the types handled by GIMPLE_EH_FILTER statement GS. */
2903 gimple_eh_filter_types (const_gimple gs)
2905 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2906 return gs->gimple_eh_filter.types;
2910 /* Return a pointer to the types handled by GIMPLE_EH_FILTER statement
2913 static inline tree *
2914 gimple_eh_filter_types_ptr (gimple gs)
2916 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2917 return &gs->gimple_eh_filter.types;
2921 /* Return the sequence of statement to execute when GIMPLE_EH_FILTER
2924 static inline gimple_seq
2925 gimple_eh_filter_failure (gimple gs)
2927 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2928 return gs->gimple_eh_filter.failure;
2932 /* Set TYPES to be the set of types handled by GIMPLE_EH_FILTER GS. */
2935 gimple_eh_filter_set_types (gimple gs, tree types)
2937 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2938 gs->gimple_eh_filter.types = types;
2942 /* Set FAILURE to be the sequence of statements to execute on failure
2943 for GIMPLE_EH_FILTER GS. */
2946 gimple_eh_filter_set_failure (gimple gs, gimple_seq failure)
2948 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2949 gs->gimple_eh_filter.failure = failure;
2952 /* Get the function decl to be called by the MUST_NOT_THROW region. */
2955 gimple_eh_must_not_throw_fndecl (gimple gs)
2957 GIMPLE_CHECK (gs, GIMPLE_EH_MUST_NOT_THROW);
2958 return gs->gimple_eh_mnt.fndecl;
2961 /* Set the function decl to be called by GS to DECL. */
2964 gimple_eh_must_not_throw_set_fndecl (gimple gs, tree decl)
2966 GIMPLE_CHECK (gs, GIMPLE_EH_MUST_NOT_THROW);
2967 gs->gimple_eh_mnt.fndecl = decl;
2971 /* GIMPLE_TRY accessors. */
2973 /* Return the kind of try block represented by GIMPLE_TRY GS. This is
2974 either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY. */
2976 static inline enum gimple_try_flags
2977 gimple_try_kind (const_gimple gs)
2979 GIMPLE_CHECK (gs, GIMPLE_TRY);
2980 return (enum gimple_try_flags) (gs->gsbase.subcode & GIMPLE_TRY_KIND);
2984 /* Set the kind of try block represented by GIMPLE_TRY GS. */
2987 gimple_try_set_kind (gimple gs, enum gimple_try_flags kind)
2989 GIMPLE_CHECK (gs, GIMPLE_TRY);
2990 gcc_assert (kind == GIMPLE_TRY_CATCH || kind == GIMPLE_TRY_FINALLY);
2991 if (gimple_try_kind (gs) != kind)
2992 gs->gsbase.subcode = (unsigned int) kind;
2996 /* Return the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2999 gimple_try_catch_is_cleanup (const_gimple gs)
3001 gcc_assert (gimple_try_kind (gs) == GIMPLE_TRY_CATCH);
3002 return (gs->gsbase.subcode & GIMPLE_TRY_CATCH_IS_CLEANUP) != 0;
3006 /* Return the sequence of statements used as the body for GIMPLE_TRY GS. */
3008 static inline gimple_seq
3009 gimple_try_eval (gimple gs)
3011 GIMPLE_CHECK (gs, GIMPLE_TRY);
3012 return gs->gimple_try.eval;
3016 /* Return the sequence of statements used as the cleanup body for
3019 static inline gimple_seq
3020 gimple_try_cleanup (gimple gs)
3022 GIMPLE_CHECK (gs, GIMPLE_TRY);
3023 return gs->gimple_try.cleanup;
3027 /* Set the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
3030 gimple_try_set_catch_is_cleanup (gimple g, bool catch_is_cleanup)
3032 gcc_assert (gimple_try_kind (g) == GIMPLE_TRY_CATCH);
3033 if (catch_is_cleanup)
3034 g->gsbase.subcode |= GIMPLE_TRY_CATCH_IS_CLEANUP;
3036 g->gsbase.subcode &= ~GIMPLE_TRY_CATCH_IS_CLEANUP;
3040 /* Set EVAL to be the sequence of statements to use as the body for
3044 gimple_try_set_eval (gimple gs, gimple_seq eval)
3046 GIMPLE_CHECK (gs, GIMPLE_TRY);
3047 gs->gimple_try.eval = eval;
3051 /* Set CLEANUP to be the sequence of statements to use as the cleanup
3052 body for GIMPLE_TRY GS. */
3055 gimple_try_set_cleanup (gimple gs, gimple_seq cleanup)
3057 GIMPLE_CHECK (gs, GIMPLE_TRY);
3058 gs->gimple_try.cleanup = cleanup;
3062 /* Return the cleanup sequence for cleanup statement GS. */
3064 static inline gimple_seq
3065 gimple_wce_cleanup (gimple gs)
3067 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3068 return gs->gimple_wce.cleanup;
3072 /* Set CLEANUP to be the cleanup sequence for GS. */
3075 gimple_wce_set_cleanup (gimple gs, gimple_seq cleanup)
3077 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3078 gs->gimple_wce.cleanup = cleanup;
3082 /* Return the CLEANUP_EH_ONLY flag for a WCE tuple. */
3085 gimple_wce_cleanup_eh_only (const_gimple gs)
3087 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3088 return gs->gsbase.subcode != 0;
3092 /* Set the CLEANUP_EH_ONLY flag for a WCE tuple. */
3095 gimple_wce_set_cleanup_eh_only (gimple gs, bool eh_only_p)
3097 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3098 gs->gsbase.subcode = (unsigned int) eh_only_p;
3102 /* Return the maximum number of arguments supported by GIMPLE_PHI GS. */
3104 static inline unsigned
3105 gimple_phi_capacity (const_gimple gs)
3107 GIMPLE_CHECK (gs, GIMPLE_PHI);
3108 return gs->gimple_phi.capacity;
3112 /* Return the number of arguments in GIMPLE_PHI GS. This must always
3113 be exactly the number of incoming edges for the basic block holding
3116 static inline unsigned
3117 gimple_phi_num_args (const_gimple gs)
3119 GIMPLE_CHECK (gs, GIMPLE_PHI);
3120 return gs->gimple_phi.nargs;
3124 /* Return the SSA name created by GIMPLE_PHI GS. */
3127 gimple_phi_result (const_gimple gs)
3129 GIMPLE_CHECK (gs, GIMPLE_PHI);
3130 return gs->gimple_phi.result;
3133 /* Return a pointer to the SSA name created by GIMPLE_PHI GS. */
3135 static inline tree *
3136 gimple_phi_result_ptr (gimple gs)
3138 GIMPLE_CHECK (gs, GIMPLE_PHI);
3139 return &gs->gimple_phi.result;
3142 /* Set RESULT to be the SSA name created by GIMPLE_PHI GS. */
3145 gimple_phi_set_result (gimple gs, tree result)
3147 GIMPLE_CHECK (gs, GIMPLE_PHI);
3148 gs->gimple_phi.result = result;
3152 /* Return the PHI argument corresponding to incoming edge INDEX for
3155 static inline struct phi_arg_d *
3156 gimple_phi_arg (gimple gs, unsigned index)
3158 GIMPLE_CHECK (gs, GIMPLE_PHI);
3159 gcc_assert (index <= gs->gimple_phi.capacity);
3160 return &(gs->gimple_phi.args[index]);
3163 /* Set PHIARG to be the argument corresponding to incoming edge INDEX
3164 for GIMPLE_PHI GS. */
3167 gimple_phi_set_arg (gimple gs, unsigned index, struct phi_arg_d * phiarg)
3169 GIMPLE_CHECK (gs, GIMPLE_PHI);
3170 gcc_assert (index <= gs->gimple_phi.nargs);
3171 memcpy (gs->gimple_phi.args + index, phiarg, sizeof (struct phi_arg_d));
3174 /* Return the region number for GIMPLE_RESX GS. */
3177 gimple_resx_region (const_gimple gs)
3179 GIMPLE_CHECK (gs, GIMPLE_RESX);
3180 return gs->gimple_eh_ctrl.region;
3183 /* Set REGION to be the region number for GIMPLE_RESX GS. */
3186 gimple_resx_set_region (gimple gs, int region)
3188 GIMPLE_CHECK (gs, GIMPLE_RESX);
3189 gs->gimple_eh_ctrl.region = region;
3192 /* Return the region number for GIMPLE_EH_DISPATCH GS. */
3195 gimple_eh_dispatch_region (const_gimple gs)
3197 GIMPLE_CHECK (gs, GIMPLE_EH_DISPATCH);
3198 return gs->gimple_eh_ctrl.region;
3201 /* Set REGION to be the region number for GIMPLE_EH_DISPATCH GS. */
3204 gimple_eh_dispatch_set_region (gimple gs, int region)
3206 GIMPLE_CHECK (gs, GIMPLE_EH_DISPATCH);
3207 gs->gimple_eh_ctrl.region = region;
3210 /* Return the number of labels associated with the switch statement GS. */
3212 static inline unsigned
3213 gimple_switch_num_labels (const_gimple gs)
3216 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3217 num_ops = gimple_num_ops (gs);
3218 gcc_assert (num_ops > 1);
3223 /* Set NLABELS to be the number of labels for the switch statement GS. */
3226 gimple_switch_set_num_labels (gimple g, unsigned nlabels)
3228 GIMPLE_CHECK (g, GIMPLE_SWITCH);
3229 gimple_set_num_ops (g, nlabels + 1);
3233 /* Return the index variable used by the switch statement GS. */
3236 gimple_switch_index (const_gimple gs)
3238 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3239 return gimple_op (gs, 0);
3243 /* Return a pointer to the index variable for the switch statement GS. */
3245 static inline tree *
3246 gimple_switch_index_ptr (const_gimple gs)
3248 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3249 return gimple_op_ptr (gs, 0);
3253 /* Set INDEX to be the index variable for switch statement GS. */
3256 gimple_switch_set_index (gimple gs, tree index)
3258 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3259 gcc_assert (SSA_VAR_P (index) || CONSTANT_CLASS_P (index));
3260 gimple_set_op (gs, 0, index);
3264 /* Return the label numbered INDEX. The default label is 0, followed by any
3265 labels in a switch statement. */
3268 gimple_switch_label (const_gimple gs, unsigned index)
3270 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3271 gcc_assert (gimple_num_ops (gs) > index + 1);
3272 return gimple_op (gs, index + 1);
3275 /* Set the label number INDEX to LABEL. 0 is always the default label. */
3278 gimple_switch_set_label (gimple gs, unsigned index, tree label)
3280 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3281 gcc_assert (gimple_num_ops (gs) > index + 1);
3282 gcc_assert (label == NULL_TREE || 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 #ifdef ENABLE_CHECKING
3328 gcc_assert (gimple_debug_bind_p (dbg));
3330 return gimple_op (dbg, 0);
3333 /* Return the value bound to the variable in a GIMPLE_DEBUG bind
3337 gimple_debug_bind_get_value (gimple dbg)
3339 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3340 #ifdef ENABLE_CHECKING
3341 gcc_assert (gimple_debug_bind_p (dbg));
3343 return gimple_op (dbg, 1);
3346 /* Return a pointer to the value bound to the variable in a
3347 GIMPLE_DEBUG bind statement. */
3349 static inline tree *
3350 gimple_debug_bind_get_value_ptr (gimple dbg)
3352 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3353 #ifdef ENABLE_CHECKING
3354 gcc_assert (gimple_debug_bind_p (dbg));
3356 return gimple_op_ptr (dbg, 1);
3359 /* Set the variable bound in a GIMPLE_DEBUG bind statement. */
3362 gimple_debug_bind_set_var (gimple dbg, tree var)
3364 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3365 #ifdef ENABLE_CHECKING
3366 gcc_assert (gimple_debug_bind_p (dbg));
3368 gimple_set_op (dbg, 0, var);
3371 /* Set the value bound to the variable in a GIMPLE_DEBUG bind
3375 gimple_debug_bind_set_value (gimple dbg, tree value)
3377 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3378 #ifdef ENABLE_CHECKING
3379 gcc_assert (gimple_debug_bind_p (dbg));
3381 gimple_set_op (dbg, 1, value);
3384 /* The second operand of a GIMPLE_DEBUG_BIND, when the value was
3386 #define GIMPLE_DEBUG_BIND_NOVALUE NULL_TREE /* error_mark_node */
3388 /* Remove the value bound to the variable in a GIMPLE_DEBUG bind
3392 gimple_debug_bind_reset_value (gimple dbg)
3394 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3395 #ifdef ENABLE_CHECKING
3396 gcc_assert (gimple_debug_bind_p (dbg));
3398 gimple_set_op (dbg, 1, GIMPLE_DEBUG_BIND_NOVALUE);
3401 /* Return true if the GIMPLE_DEBUG bind statement is bound to a
3405 gimple_debug_bind_has_value_p (gimple dbg)
3407 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3408 #ifdef ENABLE_CHECKING
3409 gcc_assert (gimple_debug_bind_p (dbg));
3411 return gimple_op (dbg, 1) != GIMPLE_DEBUG_BIND_NOVALUE;
3414 #undef GIMPLE_DEBUG_BIND_NOVALUE
3416 /* Return the body for the OMP statement GS. */
3418 static inline gimple_seq
3419 gimple_omp_body (gimple gs)
3421 return gs->omp.body;
3424 /* Set BODY to be the body for the OMP statement GS. */
3427 gimple_omp_set_body (gimple gs, gimple_seq body)
3429 gs->omp.body = body;
3433 /* Return the name associated with OMP_CRITICAL statement GS. */
3436 gimple_omp_critical_name (const_gimple gs)
3438 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3439 return gs->gimple_omp_critical.name;
3443 /* Return a pointer to the name associated with OMP critical statement GS. */
3445 static inline tree *
3446 gimple_omp_critical_name_ptr (gimple gs)
3448 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3449 return &gs->gimple_omp_critical.name;
3453 /* Set NAME to be the name associated with OMP critical statement GS. */
3456 gimple_omp_critical_set_name (gimple gs, tree name)
3458 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3459 gs->gimple_omp_critical.name = name;
3463 /* Return the clauses associated with OMP_FOR GS. */
3466 gimple_omp_for_clauses (const_gimple gs)
3468 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3469 return gs->gimple_omp_for.clauses;
3473 /* Return a pointer to the OMP_FOR GS. */
3475 static inline tree *
3476 gimple_omp_for_clauses_ptr (gimple gs)
3478 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3479 return &gs->gimple_omp_for.clauses;
3483 /* Set CLAUSES to be the list of clauses associated with OMP_FOR GS. */
3486 gimple_omp_for_set_clauses (gimple gs, tree clauses)
3488 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3489 gs->gimple_omp_for.clauses = clauses;
3493 /* Get the collapse count of OMP_FOR GS. */
3495 static inline size_t
3496 gimple_omp_for_collapse (gimple gs)
3498 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3499 return gs->gimple_omp_for.collapse;
3503 /* Return the index variable for OMP_FOR GS. */
3506 gimple_omp_for_index (const_gimple gs, size_t i)
3508 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3509 gcc_assert (i < gs->gimple_omp_for.collapse);
3510 return gs->gimple_omp_for.iter[i].index;
3514 /* Return a pointer to the index variable for OMP_FOR GS. */
3516 static inline tree *
3517 gimple_omp_for_index_ptr (gimple gs, size_t i)
3519 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3520 gcc_assert (i < gs->gimple_omp_for.collapse);
3521 return &gs->gimple_omp_for.iter[i].index;
3525 /* Set INDEX to be the index variable for OMP_FOR GS. */
3528 gimple_omp_for_set_index (gimple gs, size_t i, tree index)
3530 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3531 gcc_assert (i < gs->gimple_omp_for.collapse);
3532 gs->gimple_omp_for.iter[i].index = index;
3536 /* Return the initial value for OMP_FOR GS. */
3539 gimple_omp_for_initial (const_gimple gs, size_t i)
3541 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3542 gcc_assert (i < gs->gimple_omp_for.collapse);
3543 return gs->gimple_omp_for.iter[i].initial;
3547 /* Return a pointer to the initial value for OMP_FOR GS. */
3549 static inline tree *
3550 gimple_omp_for_initial_ptr (gimple gs, size_t i)
3552 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3553 gcc_assert (i < gs->gimple_omp_for.collapse);
3554 return &gs->gimple_omp_for.iter[i].initial;
3558 /* Set INITIAL to be the initial value for OMP_FOR GS. */
3561 gimple_omp_for_set_initial (gimple gs, size_t i, tree initial)
3563 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3564 gcc_assert (i < gs->gimple_omp_for.collapse);
3565 gs->gimple_omp_for.iter[i].initial = initial;
3569 /* Return the final value for OMP_FOR GS. */
3572 gimple_omp_for_final (const_gimple gs, size_t i)
3574 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3575 gcc_assert (i < gs->gimple_omp_for.collapse);
3576 return gs->gimple_omp_for.iter[i].final;
3580 /* Return a pointer to the final value for OMP_FOR GS. */
3582 static inline tree *
3583 gimple_omp_for_final_ptr (gimple gs, size_t i)
3585 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3586 gcc_assert (i < gs->gimple_omp_for.collapse);
3587 return &gs->gimple_omp_for.iter[i].final;
3591 /* Set FINAL to be the final value for OMP_FOR GS. */
3594 gimple_omp_for_set_final (gimple gs, size_t i, tree final)
3596 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3597 gcc_assert (i < gs->gimple_omp_for.collapse);
3598 gs->gimple_omp_for.iter[i].final = final;
3602 /* Return the increment value for OMP_FOR GS. */
3605 gimple_omp_for_incr (const_gimple gs, size_t i)
3607 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3608 gcc_assert (i < gs->gimple_omp_for.collapse);
3609 return gs->gimple_omp_for.iter[i].incr;
3613 /* Return a pointer to the increment value for OMP_FOR GS. */
3615 static inline tree *
3616 gimple_omp_for_incr_ptr (gimple gs, size_t i)
3618 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3619 gcc_assert (i < gs->gimple_omp_for.collapse);
3620 return &gs->gimple_omp_for.iter[i].incr;
3624 /* Set INCR to be the increment value for OMP_FOR GS. */
3627 gimple_omp_for_set_incr (gimple gs, size_t i, tree incr)
3629 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3630 gcc_assert (i < gs->gimple_omp_for.collapse);
3631 gs->gimple_omp_for.iter[i].incr = incr;
3635 /* Return the sequence of statements to execute before the OMP_FOR
3636 statement GS starts. */
3638 static inline gimple_seq
3639 gimple_omp_for_pre_body (gimple gs)
3641 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3642 return gs->gimple_omp_for.pre_body;
3646 /* Set PRE_BODY to be the sequence of statements to execute before the
3647 OMP_FOR statement GS starts. */
3650 gimple_omp_for_set_pre_body (gimple gs, gimple_seq pre_body)
3652 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3653 gs->gimple_omp_for.pre_body = pre_body;
3657 /* Return the clauses associated with OMP_PARALLEL GS. */
3660 gimple_omp_parallel_clauses (const_gimple gs)
3662 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3663 return gs->gimple_omp_parallel.clauses;
3667 /* Return a pointer to the clauses associated with OMP_PARALLEL GS. */
3669 static inline tree *
3670 gimple_omp_parallel_clauses_ptr (gimple gs)
3672 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3673 return &gs->gimple_omp_parallel.clauses;
3677 /* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL
3681 gimple_omp_parallel_set_clauses (gimple gs, tree clauses)
3683 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3684 gs->gimple_omp_parallel.clauses = clauses;
3688 /* Return the child function used to hold the body of OMP_PARALLEL GS. */
3691 gimple_omp_parallel_child_fn (const_gimple gs)
3693 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3694 return gs->gimple_omp_parallel.child_fn;
3697 /* Return a pointer to the child function used to hold the body of
3700 static inline tree *
3701 gimple_omp_parallel_child_fn_ptr (gimple gs)
3703 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3704 return &gs->gimple_omp_parallel.child_fn;
3708 /* Set CHILD_FN to be the child function for OMP_PARALLEL GS. */
3711 gimple_omp_parallel_set_child_fn (gimple gs, tree child_fn)
3713 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3714 gs->gimple_omp_parallel.child_fn = child_fn;
3718 /* Return the artificial argument used to send variables and values
3719 from the parent to the children threads in OMP_PARALLEL GS. */
3722 gimple_omp_parallel_data_arg (const_gimple gs)
3724 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3725 return gs->gimple_omp_parallel.data_arg;
3729 /* Return a pointer to the data argument for OMP_PARALLEL GS. */
3731 static inline tree *
3732 gimple_omp_parallel_data_arg_ptr (gimple gs)
3734 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3735 return &gs->gimple_omp_parallel.data_arg;
3739 /* Set DATA_ARG to be the data argument for OMP_PARALLEL GS. */
3742 gimple_omp_parallel_set_data_arg (gimple gs, tree data_arg)
3744 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3745 gs->gimple_omp_parallel.data_arg = data_arg;
3749 /* Return the clauses associated with OMP_TASK GS. */
3752 gimple_omp_task_clauses (const_gimple gs)
3754 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3755 return gs->gimple_omp_parallel.clauses;
3759 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3761 static inline tree *
3762 gimple_omp_task_clauses_ptr (gimple gs)
3764 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3765 return &gs->gimple_omp_parallel.clauses;
3769 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3773 gimple_omp_task_set_clauses (gimple gs, tree clauses)
3775 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3776 gs->gimple_omp_parallel.clauses = clauses;
3780 /* Return the child function used to hold the body of OMP_TASK GS. */
3783 gimple_omp_task_child_fn (const_gimple gs)
3785 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3786 return gs->gimple_omp_parallel.child_fn;
3789 /* Return a pointer to the child function used to hold the body of
3792 static inline tree *
3793 gimple_omp_task_child_fn_ptr (gimple gs)
3795 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3796 return &gs->gimple_omp_parallel.child_fn;
3800 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3803 gimple_omp_task_set_child_fn (gimple gs, tree child_fn)
3805 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3806 gs->gimple_omp_parallel.child_fn = child_fn;
3810 /* Return the artificial argument used to send variables and values
3811 from the parent to the children threads in OMP_TASK GS. */
3814 gimple_omp_task_data_arg (const_gimple gs)
3816 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3817 return gs->gimple_omp_parallel.data_arg;
3821 /* Return a pointer to the data argument for OMP_TASK GS. */
3823 static inline tree *
3824 gimple_omp_task_data_arg_ptr (gimple gs)
3826 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3827 return &gs->gimple_omp_parallel.data_arg;
3831 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3834 gimple_omp_task_set_data_arg (gimple gs, tree data_arg)
3836 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3837 gs->gimple_omp_parallel.data_arg = data_arg;
3841 /* Return the clauses associated with OMP_TASK GS. */
3844 gimple_omp_taskreg_clauses (const_gimple gs)
3846 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3847 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3848 return gs->gimple_omp_parallel.clauses;
3852 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3854 static inline tree *
3855 gimple_omp_taskreg_clauses_ptr (gimple gs)
3857 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3858 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3859 return &gs->gimple_omp_parallel.clauses;
3863 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3867 gimple_omp_taskreg_set_clauses (gimple gs, tree clauses)
3869 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3870 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3871 gs->gimple_omp_parallel.clauses = clauses;
3875 /* Return the child function used to hold the body of OMP_TASK GS. */
3878 gimple_omp_taskreg_child_fn (const_gimple gs)
3880 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3881 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3882 return gs->gimple_omp_parallel.child_fn;
3885 /* Return a pointer to the child function used to hold the body of
3888 static inline tree *
3889 gimple_omp_taskreg_child_fn_ptr (gimple gs)
3891 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3892 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3893 return &gs->gimple_omp_parallel.child_fn;
3897 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3900 gimple_omp_taskreg_set_child_fn (gimple gs, tree child_fn)
3902 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3903 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3904 gs->gimple_omp_parallel.child_fn = child_fn;
3908 /* Return the artificial argument used to send variables and values
3909 from the parent to the children threads in OMP_TASK GS. */
3912 gimple_omp_taskreg_data_arg (const_gimple gs)
3914 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3915 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3916 return gs->gimple_omp_parallel.data_arg;
3920 /* Return a pointer to the data argument for OMP_TASK GS. */
3922 static inline tree *
3923 gimple_omp_taskreg_data_arg_ptr (gimple gs)
3925 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3926 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3927 return &gs->gimple_omp_parallel.data_arg;
3931 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3934 gimple_omp_taskreg_set_data_arg (gimple gs, tree data_arg)
3936 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3937 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3938 gs->gimple_omp_parallel.data_arg = data_arg;
3942 /* Return the copy function used to hold the body of OMP_TASK GS. */
3945 gimple_omp_task_copy_fn (const_gimple gs)
3947 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3948 return gs->gimple_omp_task.copy_fn;
3951 /* Return a pointer to the copy function used to hold the body of
3954 static inline tree *
3955 gimple_omp_task_copy_fn_ptr (gimple gs)
3957 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3958 return &gs->gimple_omp_task.copy_fn;
3962 /* Set CHILD_FN to be the copy function for OMP_TASK GS. */
3965 gimple_omp_task_set_copy_fn (gimple gs, tree copy_fn)
3967 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3968 gs->gimple_omp_task.copy_fn = copy_fn;
3972 /* Return size of the data block in bytes in OMP_TASK GS. */
3975 gimple_omp_task_arg_size (const_gimple gs)
3977 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3978 return gs->gimple_omp_task.arg_size;
3982 /* Return a pointer to the data block size for OMP_TASK GS. */
3984 static inline tree *
3985 gimple_omp_task_arg_size_ptr (gimple gs)
3987 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3988 return &gs->gimple_omp_task.arg_size;
3992 /* Set ARG_SIZE to be the data block size for OMP_TASK GS. */
3995 gimple_omp_task_set_arg_size (gimple gs, tree arg_size)
3997 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3998 gs->gimple_omp_task.arg_size = arg_size;
4002 /* Return align of the data block in bytes in OMP_TASK GS. */
4005 gimple_omp_task_arg_align (const_gimple gs)
4007 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4008 return gs->gimple_omp_task.arg_align;
4012 /* Return a pointer to the data block align for OMP_TASK GS. */
4014 static inline tree *
4015 gimple_omp_task_arg_align_ptr (gimple gs)
4017 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4018 return &gs->gimple_omp_task.arg_align;
4022 /* Set ARG_SIZE to be the data block align for OMP_TASK GS. */
4025 gimple_omp_task_set_arg_align (gimple gs, tree arg_align)
4027 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4028 gs->gimple_omp_task.arg_align = arg_align;
4032 /* Return the clauses associated with OMP_SINGLE GS. */
4035 gimple_omp_single_clauses (const_gimple gs)
4037 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
4038 return gs->gimple_omp_single.clauses;
4042 /* Return a pointer to the clauses associated with OMP_SINGLE GS. */
4044 static inline tree *
4045 gimple_omp_single_clauses_ptr (gimple gs)
4047 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
4048 return &gs->gimple_omp_single.clauses;
4052 /* Set CLAUSES to be the clauses associated with OMP_SINGLE GS. */
4055 gimple_omp_single_set_clauses (gimple gs, tree clauses)
4057 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
4058 gs->gimple_omp_single.clauses = clauses;
4062 /* Return the clauses associated with OMP_SECTIONS GS. */
4065 gimple_omp_sections_clauses (const_gimple gs)
4067 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4068 return gs->gimple_omp_sections.clauses;
4072 /* Return a pointer to the clauses associated with OMP_SECTIONS GS. */
4074 static inline tree *
4075 gimple_omp_sections_clauses_ptr (gimple gs)
4077 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4078 return &gs->gimple_omp_sections.clauses;
4082 /* Set CLAUSES to be the set of clauses associated with OMP_SECTIONS
4086 gimple_omp_sections_set_clauses (gimple gs, tree clauses)
4088 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4089 gs->gimple_omp_sections.clauses = clauses;
4093 /* Return the control variable associated with the GIMPLE_OMP_SECTIONS
4097 gimple_omp_sections_control (const_gimple gs)
4099 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4100 return gs->gimple_omp_sections.control;
4104 /* Return a pointer to the clauses associated with the GIMPLE_OMP_SECTIONS
4107 static inline tree *
4108 gimple_omp_sections_control_ptr (gimple gs)
4110 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4111 return &gs->gimple_omp_sections.control;
4115 /* Set CONTROL to be the set of clauses associated with the
4116 GIMPLE_OMP_SECTIONS in GS. */
4119 gimple_omp_sections_set_control (gimple gs, tree control)
4121 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4122 gs->gimple_omp_sections.control = control;
4126 /* Set COND to be the condition code for OMP_FOR GS. */
4129 gimple_omp_for_set_cond (gimple gs, size_t i, enum tree_code cond)
4131 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4132 gcc_assert (TREE_CODE_CLASS (cond) == tcc_comparison);
4133 gcc_assert (i < gs->gimple_omp_for.collapse);
4134 gs->gimple_omp_for.iter[i].cond = cond;
4138 /* Return the condition code associated with OMP_FOR GS. */
4140 static inline enum tree_code
4141 gimple_omp_for_cond (const_gimple gs, size_t i)
4143 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4144 gcc_assert (i < gs->gimple_omp_for.collapse);
4145 return gs->gimple_omp_for.iter[i].cond;
4149 /* Set the value being stored in an atomic store. */
4152 gimple_omp_atomic_store_set_val (gimple g, tree val)
4154 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4155 g->gimple_omp_atomic_store.val = val;
4159 /* Return the value being stored in an atomic store. */
4162 gimple_omp_atomic_store_val (const_gimple g)
4164 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4165 return g->gimple_omp_atomic_store.val;
4169 /* Return a pointer to the value being stored in an atomic store. */
4171 static inline tree *
4172 gimple_omp_atomic_store_val_ptr (gimple g)
4174 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4175 return &g->gimple_omp_atomic_store.val;
4179 /* Set the LHS of an atomic load. */
4182 gimple_omp_atomic_load_set_lhs (gimple g, tree lhs)
4184 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4185 g->gimple_omp_atomic_load.lhs = lhs;
4189 /* Get the LHS of an atomic load. */
4192 gimple_omp_atomic_load_lhs (const_gimple g)
4194 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4195 return g->gimple_omp_atomic_load.lhs;
4199 /* Return a pointer to the LHS of an atomic load. */
4201 static inline tree *
4202 gimple_omp_atomic_load_lhs_ptr (gimple g)
4204 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4205 return &g->gimple_omp_atomic_load.lhs;
4209 /* Set the RHS of an atomic load. */
4212 gimple_omp_atomic_load_set_rhs (gimple g, tree rhs)
4214 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4215 g->gimple_omp_atomic_load.rhs = rhs;
4219 /* Get the RHS of an atomic load. */
4222 gimple_omp_atomic_load_rhs (const_gimple g)
4224 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4225 return g->gimple_omp_atomic_load.rhs;
4229 /* Return a pointer to the RHS of an atomic load. */
4231 static inline tree *
4232 gimple_omp_atomic_load_rhs_ptr (gimple g)
4234 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4235 return &g->gimple_omp_atomic_load.rhs;
4239 /* Get the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4242 gimple_omp_continue_control_def (const_gimple g)
4244 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4245 return g->gimple_omp_continue.control_def;
4248 /* The same as above, but return the address. */
4250 static inline tree *
4251 gimple_omp_continue_control_def_ptr (gimple g)
4253 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4254 return &g->gimple_omp_continue.control_def;
4257 /* Set the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4260 gimple_omp_continue_set_control_def (gimple g, tree def)
4262 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4263 g->gimple_omp_continue.control_def = def;
4267 /* Get the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4270 gimple_omp_continue_control_use (const_gimple g)
4272 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4273 return g->gimple_omp_continue.control_use;
4277 /* The same as above, but return the address. */
4279 static inline tree *
4280 gimple_omp_continue_control_use_ptr (gimple g)
4282 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4283 return &g->gimple_omp_continue.control_use;
4287 /* Set the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4290 gimple_omp_continue_set_control_use (gimple g, tree use)
4292 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4293 g->gimple_omp_continue.control_use = use;
4297 /* Return a pointer to the return value for GIMPLE_RETURN GS. */
4299 static inline tree *
4300 gimple_return_retval_ptr (const_gimple gs)
4302 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4303 return gimple_op_ptr (gs, 0);
4306 /* Return the return value for GIMPLE_RETURN GS. */
4309 gimple_return_retval (const_gimple gs)
4311 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4312 return gimple_op (gs, 0);
4316 /* Set RETVAL to be the return value for GIMPLE_RETURN GS. */
4319 gimple_return_set_retval (gimple gs, tree retval)
4321 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4322 gimple_set_op (gs, 0, retval);
4326 /* Returns true when the gimple statment STMT is any of the OpenMP types. */
4328 #define CASE_GIMPLE_OMP \
4329 case GIMPLE_OMP_PARALLEL: \
4330 case GIMPLE_OMP_TASK: \
4331 case GIMPLE_OMP_FOR: \
4332 case GIMPLE_OMP_SECTIONS: \
4333 case GIMPLE_OMP_SECTIONS_SWITCH: \
4334 case GIMPLE_OMP_SINGLE: \
4335 case GIMPLE_OMP_SECTION: \
4336 case GIMPLE_OMP_MASTER: \
4337 case GIMPLE_OMP_ORDERED: \
4338 case GIMPLE_OMP_CRITICAL: \
4339 case GIMPLE_OMP_RETURN: \
4340 case GIMPLE_OMP_ATOMIC_LOAD: \
4341 case GIMPLE_OMP_ATOMIC_STORE: \
4342 case GIMPLE_OMP_CONTINUE
4345 is_gimple_omp (const_gimple stmt)
4347 switch (gimple_code (stmt))
4357 /* Returns TRUE if statement G is a GIMPLE_NOP. */
4360 gimple_nop_p (const_gimple g)
4362 return gimple_code (g) == GIMPLE_NOP;
4366 /* Return true if GS is a GIMPLE_RESX. */
4369 is_gimple_resx (const_gimple gs)
4371 return gimple_code (gs) == GIMPLE_RESX;
4374 /* Return the predictor of GIMPLE_PREDICT statement GS. */
4376 static inline enum br_predictor
4377 gimple_predict_predictor (gimple gs)
4379 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4380 return (enum br_predictor) (gs->gsbase.subcode & ~GF_PREDICT_TAKEN);
4384 /* Set the predictor of GIMPLE_PREDICT statement GS to PREDICT. */
4387 gimple_predict_set_predictor (gimple gs, enum br_predictor predictor)
4389 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4390 gs->gsbase.subcode = (gs->gsbase.subcode & GF_PREDICT_TAKEN)
4391 | (unsigned) predictor;
4395 /* Return the outcome of GIMPLE_PREDICT statement GS. */
4397 static inline enum prediction
4398 gimple_predict_outcome (gimple gs)
4400 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4401 return (gs->gsbase.subcode & GF_PREDICT_TAKEN) ? TAKEN : NOT_TAKEN;
4405 /* Set the outcome of GIMPLE_PREDICT statement GS to OUTCOME. */
4408 gimple_predict_set_outcome (gimple gs, enum prediction outcome)
4410 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4411 if (outcome == TAKEN)
4412 gs->gsbase.subcode |= GF_PREDICT_TAKEN;
4414 gs->gsbase.subcode &= ~GF_PREDICT_TAKEN;
4418 /* Return the type of the main expression computed by STMT. Return
4419 void_type_node if the statement computes nothing. */
4422 gimple_expr_type (const_gimple stmt)
4424 enum gimple_code code = gimple_code (stmt);
4426 if (code == GIMPLE_ASSIGN || code == GIMPLE_CALL)
4429 /* In general we want to pass out a type that can be substituted
4430 for both the RHS and the LHS types if there is a possibly
4431 useless conversion involved. That means returning the
4432 original RHS type as far as we can reconstruct it. */
4433 if (code == GIMPLE_CALL)
4434 type = gimple_call_return_type (stmt);
4436 switch (gimple_assign_rhs_code (stmt))
4438 case POINTER_PLUS_EXPR:
4439 type = TREE_TYPE (gimple_assign_rhs1 (stmt));
4443 /* As fallback use the type of the LHS. */
4444 type = TREE_TYPE (gimple_get_lhs (stmt));
4449 else if (code == GIMPLE_COND)
4450 return boolean_type_node;
4452 return void_type_node;
4456 /* Return a new iterator pointing to GIMPLE_SEQ's first statement. */
4458 static inline gimple_stmt_iterator
4459 gsi_start (gimple_seq seq)
4461 gimple_stmt_iterator i;
4463 i.ptr = gimple_seq_first (seq);
4465 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4471 /* Return a new iterator pointing to the first statement in basic block BB. */
4473 static inline gimple_stmt_iterator
4474 gsi_start_bb (basic_block bb)
4476 gimple_stmt_iterator i;
4480 i.ptr = gimple_seq_first (seq);
4488 /* Return a new iterator initially pointing to GIMPLE_SEQ's last statement. */
4490 static inline gimple_stmt_iterator
4491 gsi_last (gimple_seq seq)
4493 gimple_stmt_iterator i;
4495 i.ptr = gimple_seq_last (seq);
4497 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4503 /* Return a new iterator pointing to the last statement in basic block BB. */
4505 static inline gimple_stmt_iterator
4506 gsi_last_bb (basic_block bb)
4508 gimple_stmt_iterator i;
4512 i.ptr = gimple_seq_last (seq);
4520 /* Return true if I is at the end of its sequence. */
4523 gsi_end_p (gimple_stmt_iterator i)
4525 return i.ptr == NULL;
4529 /* Return true if I is one statement before the end of its sequence. */
4532 gsi_one_before_end_p (gimple_stmt_iterator i)
4534 return i.ptr != NULL && i.ptr->next == NULL;
4538 /* Advance the iterator to the next gimple statement. */
4541 gsi_next (gimple_stmt_iterator *i)
4543 i->ptr = i->ptr->next;
4546 /* Advance the iterator to the previous gimple statement. */
4549 gsi_prev (gimple_stmt_iterator *i)
4551 i->ptr = i->ptr->prev;
4554 /* Return the current stmt. */
4556 static inline gimple
4557 gsi_stmt (gimple_stmt_iterator i)
4562 /* Return a block statement iterator that points to the first non-label
4563 statement in block BB. */
4565 static inline gimple_stmt_iterator
4566 gsi_after_labels (basic_block bb)
4568 gimple_stmt_iterator gsi = gsi_start_bb (bb);
4570 while (!gsi_end_p (gsi) && gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL)
4576 /* Advance the iterator to the next non-debug gimple statement. */
4579 gsi_next_nondebug (gimple_stmt_iterator *i)
4585 while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
4588 /* Advance the iterator to the next non-debug gimple statement. */
4591 gsi_prev_nondebug (gimple_stmt_iterator *i)
4597 while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
4600 /* Return a new iterator pointing to the first non-debug statement in
4603 static inline gimple_stmt_iterator
4604 gsi_start_nondebug_bb (basic_block bb)
4606 gimple_stmt_iterator i = gsi_start_bb (bb);
4608 if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
4609 gsi_next_nondebug (&i);
4614 /* Return a new iterator pointing to the last non-debug statement in
4617 static inline gimple_stmt_iterator
4618 gsi_last_nondebug_bb (basic_block bb)
4620 gimple_stmt_iterator i = gsi_last_bb (bb);
4622 if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
4623 gsi_prev_nondebug (&i);
4628 /* Return a pointer to the current stmt.
4630 NOTE: You may want to use gsi_replace on the iterator itself,
4631 as this performs additional bookkeeping that will not be done
4632 if you simply assign through a pointer returned by gsi_stmt_ptr. */
4634 static inline gimple *
4635 gsi_stmt_ptr (gimple_stmt_iterator *i)
4637 return &i->ptr->stmt;
4641 /* Return the basic block associated with this iterator. */
4643 static inline basic_block
4644 gsi_bb (gimple_stmt_iterator i)
4650 /* Return the sequence associated with this iterator. */
4652 static inline gimple_seq
4653 gsi_seq (gimple_stmt_iterator i)
4659 enum gsi_iterator_update
4661 GSI_NEW_STMT, /* Only valid when single statement is added, move
4663 GSI_SAME_STMT, /* Leave the iterator at the same statement. */
4664 GSI_CONTINUE_LINKING /* Move iterator to whatever position is suitable
4665 for linking other statements in the same
4669 /* In gimple-iterator.c */
4670 gimple_stmt_iterator gsi_start_phis (basic_block);
4671 gimple_seq gsi_split_seq_after (gimple_stmt_iterator);
4672 gimple_seq gsi_split_seq_before (gimple_stmt_iterator *);
4673 void gsi_replace (gimple_stmt_iterator *, gimple, bool);
4674 void gsi_insert_before (gimple_stmt_iterator *, gimple,
4675 enum gsi_iterator_update);
4676 void gsi_insert_before_without_update (gimple_stmt_iterator *, gimple,
4677 enum gsi_iterator_update);
4678 void gsi_insert_seq_before (gimple_stmt_iterator *, gimple_seq,
4679 enum gsi_iterator_update);
4680 void gsi_insert_seq_before_without_update (gimple_stmt_iterator *, gimple_seq,
4681 enum gsi_iterator_update);
4682 void gsi_insert_after (gimple_stmt_iterator *, gimple,
4683 enum gsi_iterator_update);
4684 void gsi_insert_after_without_update (gimple_stmt_iterator *, gimple,
4685 enum gsi_iterator_update);
4686 void gsi_insert_seq_after (gimple_stmt_iterator *, gimple_seq,
4687 enum gsi_iterator_update);
4688 void gsi_insert_seq_after_without_update (gimple_stmt_iterator *, gimple_seq,
4689 enum gsi_iterator_update);
4690 void gsi_remove (gimple_stmt_iterator *, bool);
4691 gimple_stmt_iterator gsi_for_stmt (gimple);
4692 void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *);
4693 void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *);
4694 void gsi_move_to_bb_end (gimple_stmt_iterator *, struct basic_block_def *);
4695 void gsi_insert_on_edge (edge, gimple);
4696 void gsi_insert_seq_on_edge (edge, gimple_seq);
4697 basic_block gsi_insert_on_edge_immediate (edge, gimple);
4698 basic_block gsi_insert_seq_on_edge_immediate (edge, gimple_seq);
4699 void gsi_commit_one_edge_insert (edge, basic_block *);
4700 void gsi_commit_edge_inserts (void);
4701 gimple gimple_call_copy_skip_args (gimple, bitmap);
4704 /* Convenience routines to walk all statements of a gimple function.
4705 Note that this is useful exclusively before the code is converted
4706 into SSA form. Once the program is in SSA form, the standard
4707 operand interface should be used to analyze/modify statements. */
4708 struct walk_stmt_info
4710 /* Points to the current statement being walked. */
4711 gimple_stmt_iterator gsi;
4713 /* Additional data that the callback functions may want to carry
4714 through the recursion. */
4717 /* Pointer map used to mark visited tree nodes when calling
4718 walk_tree on each operand. If set to NULL, duplicate tree nodes
4719 will be visited more than once. */
4720 struct pointer_set_t *pset;
4722 /* Indicates whether the operand being examined may be replaced
4723 with something that matches is_gimple_val (if true) or something
4724 slightly more complicated (if false). "Something" technically
4725 means the common subset of is_gimple_lvalue and is_gimple_rhs,
4726 but we never try to form anything more complicated than that, so
4727 we don't bother checking.
4729 Also note that CALLBACK should update this flag while walking the
4730 sub-expressions of a statement. For instance, when walking the
4731 statement 'foo (&var)', the flag VAL_ONLY will initially be set
4732 to true, however, when walking &var, the operand of that
4733 ADDR_EXPR does not need to be a GIMPLE value. */
4736 /* True if we are currently walking the LHS of an assignment. */
4739 /* Optional. Set to true by the callback functions if they made any
4743 /* True if we're interested in location information. */
4744 bool want_locations;
4746 /* Operand returned by the callbacks. This is set when calling
4747 walk_gimple_seq. If the walk_stmt_fn or walk_tree_fn callback
4748 returns non-NULL, this field will contain the tree returned by
4749 the last callback. */
4750 tree callback_result;
4753 /* Callback for walk_gimple_stmt. Called for every statement found
4754 during traversal. The first argument points to the statement to
4755 walk. The second argument is a flag that the callback sets to
4756 'true' if it the callback handled all the operands and
4757 sub-statements of the statement (the default value of this flag is
4758 'false'). The third argument is an anonymous pointer to data
4759 to be used by the callback. */
4760 typedef tree (*walk_stmt_fn) (gimple_stmt_iterator *, bool *,
4761 struct walk_stmt_info *);
4763 gimple walk_gimple_seq (gimple_seq, walk_stmt_fn, walk_tree_fn,
4764 struct walk_stmt_info *);
4765 tree walk_gimple_stmt (gimple_stmt_iterator *, walk_stmt_fn, walk_tree_fn,
4766 struct walk_stmt_info *);
4767 tree walk_gimple_op (gimple, walk_tree_fn, struct walk_stmt_info *);
4769 #ifdef GATHER_STATISTICS
4770 /* Enum and arrays used for allocation stats. Keep in sync with
4771 gimple.c:gimple_alloc_kind_names. */
4772 enum gimple_alloc_kind
4774 gimple_alloc_kind_assign, /* Assignments. */
4775 gimple_alloc_kind_phi, /* PHI nodes. */
4776 gimple_alloc_kind_cond, /* Conditionals. */
4777 gimple_alloc_kind_seq, /* Sequences. */
4778 gimple_alloc_kind_rest, /* Everything else. */
4779 gimple_alloc_kind_all
4782 extern int gimple_alloc_counts[];
4783 extern int gimple_alloc_sizes[];
4785 /* Return the allocation kind for a given stmt CODE. */
4786 static inline enum gimple_alloc_kind
4787 gimple_alloc_kind (enum gimple_code code)
4792 return gimple_alloc_kind_assign;
4794 return gimple_alloc_kind_phi;
4796 return gimple_alloc_kind_cond;
4798 return gimple_alloc_kind_rest;
4801 #endif /* GATHER_STATISTICS */
4803 extern void dump_gimple_statistics (void);
4805 /* In gimple-fold.c. */
4806 void gimplify_and_update_call_from_tree (gimple_stmt_iterator *, tree);
4807 tree gimple_fold_builtin (gimple);
4808 bool fold_stmt (gimple_stmt_iterator *);
4809 bool fold_stmt_inplace (gimple);
4810 tree maybe_fold_offset_to_reference (location_t, tree, tree, tree);
4811 tree maybe_fold_offset_to_address (location_t, tree, tree, tree);
4812 tree maybe_fold_stmt_addition (location_t, tree, tree, tree);
4813 tree get_symbol_constant_value (tree);
4814 bool may_propagate_address_into_dereference (tree, tree);
4817 #endif /* GCC_GIMPLE_H */