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"
29 #include "hard-reg-set.h"
30 #include "basic-block.h"
31 #include "tree-ssa-operands.h"
32 #include "tree-ssa-alias.h"
35 DEF_VEC_ALLOC_P(gimple,heap);
36 DEF_VEC_ALLOC_P(gimple,gc);
38 typedef gimple *gimple_p;
40 DEF_VEC_ALLOC_P(gimple_p,heap);
42 DEF_VEC_P(gimple_seq);
43 DEF_VEC_ALLOC_P(gimple_seq,gc);
44 DEF_VEC_ALLOC_P(gimple_seq,heap);
46 /* For each block, the PHI nodes that need to be rewritten are stored into
48 typedef VEC(gimple, heap) *gimple_vec;
49 DEF_VEC_P (gimple_vec);
50 DEF_VEC_ALLOC_P (gimple_vec, heap);
53 #define DEFGSCODE(SYM, STRING, STRUCT) SYM,
56 LAST_AND_UNUSED_GIMPLE_CODE
59 extern const char *const gimple_code_name[];
60 extern const unsigned char gimple_rhs_class_table[];
62 /* Error out if a gimple tuple is addressed incorrectly. */
63 #if defined ENABLE_GIMPLE_CHECKING
64 extern void gimple_check_failed (const_gimple, const char *, int, \
65 const char *, enum gimple_code, \
66 enum tree_code) ATTRIBUTE_NORETURN;
68 #define GIMPLE_CHECK(GS, CODE) \
70 const_gimple __gs = (GS); \
71 if (gimple_code (__gs) != (CODE)) \
72 gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__, \
73 (CODE), ERROR_MARK); \
75 #else /* not ENABLE_GIMPLE_CHECKING */
76 #define GIMPLE_CHECK(GS, CODE) (void)0
79 /* Class of GIMPLE expressions suitable for the RHS of assignments. See
80 get_gimple_rhs_class. */
83 GIMPLE_INVALID_RHS, /* The expression cannot be used on the RHS. */
84 GIMPLE_BINARY_RHS, /* The expression is a binary operation. */
85 GIMPLE_UNARY_RHS, /* The expression is a unary operation. */
86 GIMPLE_SINGLE_RHS /* The expression is a single object (an SSA
87 name, a _DECL, a _REF, etc. */
90 /* Specific flags for individual GIMPLE statements. These flags are
91 always stored in gimple_statement_base.subcode and they may only be
92 defined for statement codes that do not use sub-codes.
94 Values for the masks can overlap as long as the overlapping values
95 are never used in the same statement class.
97 The maximum mask value that can be defined is 1 << 15 (i.e., each
98 statement code can hold up to 16 bitflags).
100 Keep this list sorted. */
102 GF_ASM_INPUT = 1 << 0,
103 GF_ASM_VOLATILE = 1 << 1,
104 GF_CALL_CANNOT_INLINE = 1 << 0,
105 GF_CALL_FROM_THUNK = 1 << 1,
106 GF_CALL_RETURN_SLOT_OPT = 1 << 2,
107 GF_CALL_TAILCALL = 1 << 3,
108 GF_CALL_VA_ARG_PACK = 1 << 4,
109 GF_OMP_PARALLEL_COMBINED = 1 << 0,
111 /* True on an GIMPLE_OMP_RETURN statement if the return does not require
112 a thread synchronization via some sort of barrier. The exact barrier
113 that would otherwise be emitted is dependent on the OMP statement with
114 which this return is associated. */
115 GF_OMP_RETURN_NOWAIT = 1 << 0,
117 GF_OMP_SECTION_LAST = 1 << 0,
118 GF_PREDICT_TAKEN = 1 << 15
121 /* Currently, there's only one type of gimple debug stmt. Others are
122 envisioned, for example, to enable the generation of is_stmt notes
123 in line number information, to mark sequence points, etc. This
124 subcode is to be used to tell them apart. */
125 enum gimple_debug_subcode {
126 GIMPLE_DEBUG_BIND = 0
129 /* Masks for selecting a pass local flag (PLF) to work on. These
130 masks are used by gimple_set_plf and gimple_plf. */
136 /* A node in a gimple_seq_d. */
137 struct GTY((chain_next ("%h.next"), chain_prev ("%h.prev"))) gimple_seq_node_d {
139 struct gimple_seq_node_d *prev;
140 struct gimple_seq_node_d *next;
143 /* A double-linked sequence of gimple statements. */
144 struct GTY ((chain_next ("%h.next_free"))) gimple_seq_d {
145 /* First and last statements in the sequence. */
146 gimple_seq_node first;
147 gimple_seq_node last;
149 /* Sequences are created/destroyed frequently. To minimize
150 allocation activity, deallocated sequences are kept in a pool of
151 available sequences. This is the pointer to the next free
152 sequence in the pool. */
153 gimple_seq next_free;
157 /* Return the first node in GIMPLE sequence S. */
159 static inline gimple_seq_node
160 gimple_seq_first (const_gimple_seq s)
162 return s ? s->first : NULL;
166 /* Return the first statement in GIMPLE sequence S. */
169 gimple_seq_first_stmt (const_gimple_seq s)
171 gimple_seq_node n = gimple_seq_first (s);
172 return (n) ? n->stmt : NULL;
176 /* Return the last node in GIMPLE sequence S. */
178 static inline gimple_seq_node
179 gimple_seq_last (const_gimple_seq s)
181 return s ? s->last : NULL;
185 /* Return the last statement in GIMPLE sequence S. */
188 gimple_seq_last_stmt (const_gimple_seq s)
190 gimple_seq_node n = gimple_seq_last (s);
191 return (n) ? n->stmt : NULL;
195 /* Set the last node in GIMPLE sequence S to LAST. */
198 gimple_seq_set_last (gimple_seq s, gimple_seq_node last)
204 /* Set the first node in GIMPLE sequence S to FIRST. */
207 gimple_seq_set_first (gimple_seq s, gimple_seq_node first)
213 /* Return true if GIMPLE sequence S is empty. */
216 gimple_seq_empty_p (const_gimple_seq s)
218 return s == NULL || s->first == NULL;
222 void gimple_seq_add_stmt (gimple_seq *, gimple);
224 /* Link gimple statement GS to the end of the sequence *SEQ_P. If
225 *SEQ_P is NULL, a new sequence is allocated. This function is
226 similar to gimple_seq_add_stmt, but does not scan the operands.
227 During gimplification, we need to manipulate statement sequences
228 before the def/use vectors have been constructed. */
229 void gimplify_seq_add_stmt (gimple_seq *, gimple);
231 /* Allocate a new sequence and initialize its first element with STMT. */
233 static inline gimple_seq
234 gimple_seq_alloc_with_stmt (gimple stmt)
236 gimple_seq seq = NULL;
237 gimple_seq_add_stmt (&seq, stmt);
242 /* Returns the sequence of statements in BB. */
244 static inline gimple_seq
245 bb_seq (const_basic_block bb)
247 return (!(bb->flags & BB_RTL) && bb->il.gimple) ? bb->il.gimple->seq : NULL;
251 /* Sets the sequence of statements in BB to SEQ. */
254 set_bb_seq (basic_block bb, gimple_seq seq)
256 gcc_assert (!(bb->flags & BB_RTL));
257 bb->il.gimple->seq = seq;
260 /* Iterator object for GIMPLE statement sequences. */
264 /* Sequence node holding the current statement. */
267 /* Sequence and basic block holding the statement. These fields
268 are necessary to handle edge cases such as when statement is
269 added to an empty basic block or when the last statement of a
270 block/sequence is removed. */
273 } gimple_stmt_iterator;
276 /* Data structure definitions for GIMPLE tuples. NOTE: word markers
277 are for 64 bit hosts. */
279 struct GTY(()) gimple_statement_base {
281 Main identifying code for a tuple. */
282 ENUM_BITFIELD(gimple_code) code : 8;
284 /* Nonzero if a warning should not be emitted on this tuple. */
285 unsigned int no_warning : 1;
287 /* Nonzero if this tuple has been visited. Passes are responsible
288 for clearing this bit before using it. */
289 unsigned int visited : 1;
291 /* Nonzero if this tuple represents a non-temporal move. */
292 unsigned int nontemporal_move : 1;
294 /* Pass local flags. These flags are free for any pass to use as
295 they see fit. Passes should not assume that these flags contain
296 any useful value when the pass starts. Any initial state that
297 the pass requires should be set on entry to the pass. See
298 gimple_set_plf and gimple_plf for usage. */
299 unsigned int plf : 2;
301 /* Nonzero if this statement has been modified and needs to have its
302 operands rescanned. */
303 unsigned modified : 1;
305 /* Nonzero if this statement contains volatile operands. */
306 unsigned has_volatile_ops : 1;
308 /* Padding to get subcode to 16 bit alignment. */
311 /* The SUBCODE field can be used for tuple-specific flags for tuples
312 that do not require subcodes. Note that SUBCODE should be at
313 least as wide as tree codes, as several tuples store tree codes
315 unsigned int subcode : 16;
317 /* UID of this statement. This is used by passes that want to
318 assign IDs to statements. It must be assigned and used by each
319 pass. By default it should be assumed to contain garbage. */
323 Locus information for debug info. */
326 /* Number of operands in this tuple. */
330 Basic block holding this statement. */
331 struct basic_block_def *bb;
334 Lexical block holding this statement. */
339 /* Base structure for tuples with operands. */
341 struct GTY(()) gimple_statement_with_ops_base
344 struct gimple_statement_base gsbase;
347 SSA operand vectors. NOTE: It should be possible to
348 amalgamate these vectors with the operand vector OP. However,
349 the SSA operand vectors are organized differently and contain
350 more information (like immediate use chaining). */
351 struct def_optype_d GTY((skip (""))) *def_ops;
352 struct use_optype_d GTY((skip (""))) *use_ops;
356 /* Statements that take register operands. */
358 struct GTY(()) gimple_statement_with_ops
361 struct gimple_statement_with_ops_base opbase;
364 Operand vector. NOTE! This must always be the last field
365 of this structure. In particular, this means that this
366 structure cannot be embedded inside another one. */
367 tree GTY((length ("%h.opbase.gsbase.num_ops"))) op[1];
371 /* Base for statements that take both memory and register operands. */
373 struct GTY(()) gimple_statement_with_memory_ops_base
376 struct gimple_statement_with_ops_base opbase;
379 Virtual operands for this statement. The GC will pick them
380 up via the ssa_names array. */
381 tree GTY((skip (""))) vdef;
382 tree GTY((skip (""))) vuse;
386 /* Statements that take both memory and register operands. */
388 struct GTY(()) gimple_statement_with_memory_ops
391 struct gimple_statement_with_memory_ops_base membase;
394 Operand vector. NOTE! This must always be the last field
395 of this structure. In particular, this means that this
396 structure cannot be embedded inside another one. */
397 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
401 /* Call statements that take both memory and register operands. */
403 struct GTY(()) gimple_statement_call
406 struct gimple_statement_with_memory_ops_base membase;
409 struct pt_solution call_used;
410 struct pt_solution call_clobbered;
413 Operand vector. NOTE! This must always be the last field
414 of this structure. In particular, this means that this
415 structure cannot be embedded inside another one. */
416 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
420 /* OpenMP statements (#pragma omp). */
422 struct GTY(()) gimple_statement_omp {
424 struct gimple_statement_base gsbase;
433 struct GTY(()) gimple_statement_bind {
435 struct gimple_statement_base gsbase;
438 Variables declared in this scope. */
442 This is different than the BLOCK field in gimple_statement_base,
443 which is analogous to TREE_BLOCK (i.e., the lexical block holding
444 this statement). This field is the equivalent of BIND_EXPR_BLOCK
445 in tree land (i.e., the lexical scope defined by this bind). See
456 struct GTY(()) gimple_statement_catch {
458 struct gimple_statement_base gsbase;
468 /* GIMPLE_EH_FILTER */
470 struct GTY(()) gimple_statement_eh_filter {
472 struct gimple_statement_base gsbase;
484 /* GIMPLE_EH_MUST_NOT_THROW */
486 struct GTY(()) gimple_statement_eh_mnt {
488 struct gimple_statement_base gsbase;
490 /* [ WORD 5 ] Abort function decl. */
496 struct GTY(()) gimple_statement_phi {
498 struct gimple_statement_base gsbase;
508 struct phi_arg_d GTY ((length ("%h.nargs"))) args[1];
512 /* GIMPLE_RESX, GIMPLE_EH_DISPATCH */
514 struct GTY(()) gimple_statement_eh_ctrl
517 struct gimple_statement_base gsbase;
520 Exception region number. */
527 struct GTY(()) gimple_statement_try {
529 struct gimple_statement_base gsbase;
532 Expression to evaluate. */
536 Cleanup expression. */
540 /* Kind of GIMPLE_TRY statements. */
541 enum gimple_try_flags
544 GIMPLE_TRY_CATCH = 1 << 0,
547 GIMPLE_TRY_FINALLY = 1 << 1,
548 GIMPLE_TRY_KIND = GIMPLE_TRY_CATCH | GIMPLE_TRY_FINALLY,
550 /* Analogous to TRY_CATCH_IS_CLEANUP. */
551 GIMPLE_TRY_CATCH_IS_CLEANUP = 1 << 2
554 /* GIMPLE_WITH_CLEANUP_EXPR */
556 struct GTY(()) gimple_statement_wce {
558 struct gimple_statement_base gsbase;
560 /* Subcode: CLEANUP_EH_ONLY. True if the cleanup should only be
561 executed if an exception is thrown, not on normal exit of its
562 scope. This flag is analogous to the CLEANUP_EH_ONLY flag
566 Cleanup expression. */
573 struct GTY(()) gimple_statement_asm
576 struct gimple_statement_with_memory_ops_base membase;
579 __asm__ statement. */
583 Number of inputs, outputs, clobbers, labels. */
590 Operand vector. NOTE! This must always be the last field
591 of this structure. In particular, this means that this
592 structure cannot be embedded inside another one. */
593 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
596 /* GIMPLE_OMP_CRITICAL */
598 struct GTY(()) gimple_statement_omp_critical {
600 struct gimple_statement_omp omp;
603 Critical section name. */
608 struct GTY(()) gimple_omp_for_iter {
609 /* Condition code. */
612 /* Index variable. */
627 struct GTY(()) gimple_statement_omp_for {
629 struct gimple_statement_omp omp;
635 Number of elements in iter array. */
639 struct gimple_omp_for_iter * GTY((length ("%h.collapse"))) iter;
642 Pre-body evaluated before the loop body begins. */
647 /* GIMPLE_OMP_PARALLEL */
649 struct GTY(()) gimple_statement_omp_parallel {
651 struct gimple_statement_omp omp;
658 Child function holding the body of the parallel region. */
662 Shared data argument. */
667 /* GIMPLE_OMP_TASK */
669 struct GTY(()) gimple_statement_omp_task {
671 struct gimple_statement_omp_parallel par;
674 Child function holding firstprivate initialization if needed. */
678 Size and alignment in bytes of the argument data block. */
684 /* GIMPLE_OMP_SECTION */
685 /* Uses struct gimple_statement_omp. */
688 /* GIMPLE_OMP_SECTIONS */
690 struct GTY(()) gimple_statement_omp_sections {
692 struct gimple_statement_omp omp;
698 The control variable used for deciding which of the sections to
703 /* GIMPLE_OMP_CONTINUE.
705 Note: This does not inherit from gimple_statement_omp, because we
706 do not need the body field. */
708 struct GTY(()) gimple_statement_omp_continue {
710 struct gimple_statement_base gsbase;
719 /* GIMPLE_OMP_SINGLE */
721 struct GTY(()) gimple_statement_omp_single {
723 struct gimple_statement_omp omp;
730 /* GIMPLE_OMP_ATOMIC_LOAD.
731 Note: This is based on gimple_statement_base, not g_s_omp, because g_s_omp
732 contains a sequence, which we don't need here. */
734 struct GTY(()) gimple_statement_omp_atomic_load {
736 struct gimple_statement_base gsbase;
742 /* GIMPLE_OMP_ATOMIC_STORE.
743 See note on GIMPLE_OMP_ATOMIC_LOAD. */
745 struct GTY(()) gimple_statement_omp_atomic_store {
747 struct gimple_statement_base gsbase;
753 #define DEFGSSTRUCT(SYM, STRUCT, HAS_TREE_OP) SYM,
754 enum gimple_statement_structure_enum {
755 #include "gsstruct.def"
761 /* Define the overall contents of a gimple tuple. It may be any of the
762 structures declared above for various types of tuples. */
764 union GTY ((desc ("gimple_statement_structure (&%h)"))) gimple_statement_d {
765 struct gimple_statement_base GTY ((tag ("GSS_BASE"))) gsbase;
766 struct gimple_statement_with_ops GTY ((tag ("GSS_WITH_OPS"))) gsops;
767 struct gimple_statement_with_memory_ops_base GTY ((tag ("GSS_WITH_MEM_OPS_BASE"))) gsmembase;
768 struct gimple_statement_with_memory_ops GTY ((tag ("GSS_WITH_MEM_OPS"))) gsmem;
769 struct gimple_statement_call GTY ((tag ("GSS_CALL"))) gimple_call;
770 struct gimple_statement_omp GTY ((tag ("GSS_OMP"))) omp;
771 struct gimple_statement_bind GTY ((tag ("GSS_BIND"))) gimple_bind;
772 struct gimple_statement_catch GTY ((tag ("GSS_CATCH"))) gimple_catch;
773 struct gimple_statement_eh_filter GTY ((tag ("GSS_EH_FILTER"))) gimple_eh_filter;
774 struct gimple_statement_eh_mnt GTY ((tag ("GSS_EH_MNT"))) gimple_eh_mnt;
775 struct gimple_statement_phi GTY ((tag ("GSS_PHI"))) gimple_phi;
776 struct gimple_statement_eh_ctrl GTY ((tag ("GSS_EH_CTRL"))) gimple_eh_ctrl;
777 struct gimple_statement_try GTY ((tag ("GSS_TRY"))) gimple_try;
778 struct gimple_statement_wce GTY ((tag ("GSS_WCE"))) gimple_wce;
779 struct gimple_statement_asm GTY ((tag ("GSS_ASM"))) gimple_asm;
780 struct gimple_statement_omp_critical GTY ((tag ("GSS_OMP_CRITICAL"))) gimple_omp_critical;
781 struct gimple_statement_omp_for GTY ((tag ("GSS_OMP_FOR"))) gimple_omp_for;
782 struct gimple_statement_omp_parallel GTY ((tag ("GSS_OMP_PARALLEL"))) gimple_omp_parallel;
783 struct gimple_statement_omp_task GTY ((tag ("GSS_OMP_TASK"))) gimple_omp_task;
784 struct gimple_statement_omp_sections GTY ((tag ("GSS_OMP_SECTIONS"))) gimple_omp_sections;
785 struct gimple_statement_omp_single GTY ((tag ("GSS_OMP_SINGLE"))) gimple_omp_single;
786 struct gimple_statement_omp_continue GTY ((tag ("GSS_OMP_CONTINUE"))) gimple_omp_continue;
787 struct gimple_statement_omp_atomic_load GTY ((tag ("GSS_OMP_ATOMIC_LOAD"))) gimple_omp_atomic_load;
788 struct gimple_statement_omp_atomic_store GTY ((tag ("GSS_OMP_ATOMIC_STORE"))) gimple_omp_atomic_store;
793 /* Offset in bytes to the location of the operand vector.
794 Zero if there is no operand vector for this tuple structure. */
795 extern size_t const gimple_ops_offset_[];
797 /* Map GIMPLE codes to GSS codes. */
798 extern enum gimple_statement_structure_enum const gss_for_code_[];
800 /* This variable holds the currently expanded gimple statement for purposes
801 of comminucating the profile info to the builtin expanders. */
802 extern gimple currently_expanding_gimple_stmt;
804 gimple gimple_build_return (tree);
806 gimple gimple_build_assign_stat (tree, tree MEM_STAT_DECL);
807 #define gimple_build_assign(l,r) gimple_build_assign_stat (l, r MEM_STAT_INFO)
809 void extract_ops_from_tree (tree, enum tree_code *, tree *, tree *);
811 gimple gimple_build_assign_with_ops_stat (enum tree_code, tree, tree,
813 #define gimple_build_assign_with_ops(c,o1,o2,o3) \
814 gimple_build_assign_with_ops_stat (c, o1, o2, o3 MEM_STAT_INFO)
816 gimple gimple_build_debug_bind_stat (tree, tree, gimple MEM_STAT_DECL);
817 #define gimple_build_debug_bind(var,val,stmt) \
818 gimple_build_debug_bind_stat ((var), (val), (stmt) MEM_STAT_INFO)
820 gimple gimple_build_call_vec (tree, VEC(tree, heap) *);
821 gimple gimple_build_call (tree, unsigned, ...);
822 gimple gimple_build_call_from_tree (tree);
823 gimple gimplify_assign (tree, tree, gimple_seq *);
824 gimple gimple_build_cond (enum tree_code, tree, tree, tree, tree);
825 gimple gimple_build_label (tree label);
826 gimple gimple_build_goto (tree dest);
827 gimple gimple_build_nop (void);
828 gimple gimple_build_bind (tree, gimple_seq, tree);
829 gimple gimple_build_asm_vec (const char *, VEC(tree,gc) *, VEC(tree,gc) *,
830 VEC(tree,gc) *, VEC(tree,gc) *);
831 gimple gimple_build_catch (tree, gimple_seq);
832 gimple gimple_build_eh_filter (tree, gimple_seq);
833 gimple gimple_build_eh_must_not_throw (tree);
834 gimple gimple_build_try (gimple_seq, gimple_seq, enum gimple_try_flags);
835 gimple gimple_build_wce (gimple_seq);
836 gimple gimple_build_resx (int);
837 gimple gimple_build_eh_dispatch (int);
838 gimple gimple_build_switch_nlabels (unsigned, tree, tree);
839 gimple gimple_build_switch (unsigned, tree, tree, ...);
840 gimple gimple_build_switch_vec (tree, tree, VEC(tree,heap) *);
841 gimple gimple_build_omp_parallel (gimple_seq, tree, tree, tree);
842 gimple gimple_build_omp_task (gimple_seq, tree, tree, tree, tree, tree, tree);
843 gimple gimple_build_omp_for (gimple_seq, tree, size_t, gimple_seq);
844 gimple gimple_build_omp_critical (gimple_seq, tree);
845 gimple gimple_build_omp_section (gimple_seq);
846 gimple gimple_build_omp_continue (tree, tree);
847 gimple gimple_build_omp_master (gimple_seq);
848 gimple gimple_build_omp_return (bool);
849 gimple gimple_build_omp_ordered (gimple_seq);
850 gimple gimple_build_omp_sections (gimple_seq, tree);
851 gimple gimple_build_omp_sections_switch (void);
852 gimple gimple_build_omp_single (gimple_seq, tree);
853 gimple gimple_build_cdt (tree, tree);
854 gimple gimple_build_omp_atomic_load (tree, tree);
855 gimple gimple_build_omp_atomic_store (tree);
856 gimple gimple_build_predict (enum br_predictor, enum prediction);
857 enum gimple_statement_structure_enum gss_for_assign (enum tree_code);
858 void sort_case_labels (VEC(tree,heap) *);
859 void gimple_set_body (tree, gimple_seq);
860 gimple_seq gimple_body (tree);
861 bool gimple_has_body_p (tree);
862 gimple_seq gimple_seq_alloc (void);
863 void gimple_seq_free (gimple_seq);
864 void gimple_seq_add_seq (gimple_seq *, gimple_seq);
865 gimple_seq gimple_seq_copy (gimple_seq);
866 int gimple_call_flags (const_gimple);
867 int gimple_call_return_flags (const_gimple);
868 int gimple_call_arg_flags (const_gimple, unsigned);
869 void gimple_call_reset_alias_info (gimple);
870 bool gimple_assign_copy_p (gimple);
871 bool gimple_assign_ssa_name_copy_p (gimple);
872 bool gimple_assign_single_p (gimple);
873 bool gimple_assign_unary_nop_p (gimple);
874 void gimple_set_bb (gimple, struct basic_block_def *);
875 void gimple_assign_set_rhs_from_tree (gimple_stmt_iterator *, tree);
876 void gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *, enum tree_code,
878 tree gimple_get_lhs (const_gimple);
879 void gimple_set_lhs (gimple, tree);
880 void gimple_replace_lhs (gimple, tree);
881 gimple gimple_copy (gimple);
882 bool is_gimple_operand (const_tree);
883 void gimple_set_modified (gimple, bool);
884 void gimple_cond_get_ops_from_tree (tree, enum tree_code *, tree *, tree *);
885 gimple gimple_build_cond_from_tree (tree, tree, tree);
886 void gimple_cond_set_condition_from_tree (gimple, tree);
887 bool gimple_has_side_effects (const_gimple);
888 bool gimple_rhs_has_side_effects (const_gimple);
889 bool gimple_could_trap_p (gimple);
890 bool gimple_assign_rhs_could_trap_p (gimple);
891 void gimple_regimplify_operands (gimple, gimple_stmt_iterator *);
892 bool empty_body_p (gimple_seq);
893 unsigned get_gimple_rhs_num_ops (enum tree_code);
894 #define gimple_alloc(c, n) gimple_alloc_stat (c, n MEM_STAT_INFO)
895 gimple gimple_alloc_stat (enum gimple_code, unsigned MEM_STAT_DECL);
896 const char *gimple_decl_printable_name (tree, int);
897 tree gimple_fold_obj_type_ref (tree, tree);
898 tree gimple_get_relevant_ref_binfo (tree ref, tree known_binfo);
899 tree gimple_fold_obj_type_ref_known_binfo (HOST_WIDE_INT, tree);
901 /* Returns true iff T is a valid GIMPLE statement. */
902 extern bool is_gimple_stmt (tree);
904 /* Returns true iff TYPE is a valid type for a scalar register variable. */
905 extern bool is_gimple_reg_type (tree);
906 /* Returns true iff T is a scalar register variable. */
907 extern bool is_gimple_reg (tree);
908 /* Returns true iff T is any sort of variable. */
909 extern bool is_gimple_variable (tree);
910 /* Returns true iff T is any sort of symbol. */
911 extern bool is_gimple_id (tree);
912 /* Returns true iff T is a variable or an INDIRECT_REF (of a variable). */
913 extern bool is_gimple_min_lval (tree);
914 /* Returns true iff T is something whose address can be taken. */
915 extern bool is_gimple_addressable (tree);
916 /* Returns true iff T is any valid GIMPLE lvalue. */
917 extern bool is_gimple_lvalue (tree);
919 /* Returns true iff T is a GIMPLE address. */
920 bool is_gimple_address (const_tree);
921 /* Returns true iff T is a GIMPLE invariant address. */
922 bool is_gimple_invariant_address (const_tree);
923 /* Returns true iff T is a GIMPLE invariant address at interprocedural
925 bool is_gimple_ip_invariant_address (const_tree);
926 /* Returns true iff T is a valid GIMPLE constant. */
927 bool is_gimple_constant (const_tree);
928 /* Returns true iff T is a GIMPLE restricted function invariant. */
929 extern bool is_gimple_min_invariant (const_tree);
930 /* Returns true iff T is a GIMPLE restricted interprecodural invariant. */
931 extern bool is_gimple_ip_invariant (const_tree);
932 /* Returns true iff T is a GIMPLE rvalue. */
933 extern bool is_gimple_val (tree);
934 /* Returns true iff T is a GIMPLE asm statement input. */
935 extern bool is_gimple_asm_val (tree);
936 /* Returns true iff T is a valid rhs for a MODIFY_EXPR where the LHS is a
937 GIMPLE temporary, a renamed user variable, or something else,
939 extern bool is_gimple_reg_rhs (tree);
940 extern bool is_gimple_mem_rhs (tree);
942 /* Returns true iff T is a valid if-statement condition. */
943 extern bool is_gimple_condexpr (tree);
945 /* Returns true iff T is a type conversion. */
946 extern bool is_gimple_cast (tree);
947 /* Returns true iff T is a variable that does not need to live in memory. */
948 extern bool is_gimple_non_addressable (tree t);
950 /* Returns true iff T is a valid call address expression. */
951 extern bool is_gimple_call_addr (tree);
952 /* If T makes a function call, returns the CALL_EXPR operand. */
953 extern tree get_call_expr_in (tree t);
955 extern void recalculate_side_effects (tree);
956 extern bool compare_field_offset (tree, tree);
957 extern tree gimple_register_type (tree);
958 extern void print_gimple_types_stats (void);
959 extern void free_gimple_type_tables (void);
960 extern tree gimple_unsigned_type (tree);
961 extern tree gimple_signed_type (tree);
962 extern alias_set_type gimple_get_alias_set (tree);
963 extern void count_uses_and_derefs (tree, gimple, unsigned *, unsigned *,
965 extern bool walk_stmt_load_store_addr_ops (gimple, void *,
966 bool (*)(gimple, tree, void *),
967 bool (*)(gimple, tree, void *),
968 bool (*)(gimple, tree, void *));
969 extern bool walk_stmt_load_store_ops (gimple, void *,
970 bool (*)(gimple, tree, void *),
971 bool (*)(gimple, tree, void *));
972 extern bool gimple_ior_addresses_taken (bitmap, gimple);
975 extern tree create_tmp_var_raw (tree, const char *);
976 extern tree create_tmp_var_name (const char *);
977 extern tree create_tmp_var (tree, const char *);
978 extern tree create_tmp_reg (tree, const char *);
979 extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq *);
980 extern tree get_formal_tmp_var (tree, gimple_seq *);
981 extern void declare_vars (tree, gimple, bool);
982 extern void annotate_all_with_location (gimple_seq, location_t);
984 /* Validation of GIMPLE expressions. Note that these predicates only check
985 the basic form of the expression, they don't recurse to make sure that
986 underlying nodes are also of the right form. */
987 typedef bool (*gimple_predicate)(tree);
990 /* FIXME we should deduce this from the predicate. */
992 fb_none = 0, /* Do not generate a temporary. */
994 fb_rvalue = 1, /* Generate an rvalue to hold the result of a
995 gimplified expression. */
997 fb_lvalue = 2, /* Generate an lvalue to hold the result of a
998 gimplified expression. */
1000 fb_mayfail = 4, /* Gimplification may fail. Error issued
1002 fb_either= fb_rvalue | fb_lvalue
1005 typedef int fallback_t;
1007 enum gimplify_status {
1008 GS_ERROR = -2, /* Something Bad Seen. */
1009 GS_UNHANDLED = -1, /* A langhook result for "I dunno". */
1010 GS_OK = 0, /* We did something, maybe more to do. */
1011 GS_ALL_DONE = 1 /* The expression is fully gimplified. */
1016 struct gimplify_ctx *prev_context;
1018 VEC(gimple,heap) *bind_expr_stack;
1020 gimple_seq conditional_cleanups;
1024 VEC(tree,heap) *case_labels;
1025 /* The formal temporary table. Should this be persistent? */
1031 bool allow_rhs_cond_expr;
1034 extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *,
1035 bool (*) (tree), fallback_t);
1036 extern void gimplify_type_sizes (tree, gimple_seq *);
1037 extern void gimplify_one_sizepos (tree *, gimple_seq *);
1038 extern bool gimplify_stmt (tree *, gimple_seq *);
1039 extern gimple gimplify_body (tree *, tree, bool);
1040 extern void push_gimplify_context (struct gimplify_ctx *);
1041 extern void pop_gimplify_context (gimple);
1042 extern void gimplify_and_add (tree, gimple_seq *);
1044 /* Miscellaneous helpers. */
1045 extern void gimple_add_tmp_var (tree);
1046 extern gimple gimple_current_bind_expr (void);
1047 extern VEC(gimple, heap) *gimple_bind_expr_stack (void);
1048 extern tree voidify_wrapper_expr (tree, tree);
1049 extern tree build_and_jump (tree *);
1050 extern tree alloc_stmt_list (void);
1051 extern void free_stmt_list (tree);
1052 extern tree force_labels_r (tree *, int *, void *);
1053 extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *,
1055 struct gimplify_omp_ctx;
1056 extern void omp_firstprivatize_variable (struct gimplify_omp_ctx *, tree);
1057 extern tree gimple_boolify (tree);
1058 extern gimple_predicate rhs_predicate_for (tree);
1059 extern tree canonicalize_cond_expr_cond (tree);
1062 extern tree omp_reduction_init (tree, tree);
1064 /* In tree-nested.c. */
1065 extern void lower_nested_functions (tree);
1066 extern void insert_field_into_struct (tree, tree);
1068 /* In gimplify.c. */
1069 extern void gimplify_function_tree (tree);
1071 /* In cfgexpand.c. */
1072 extern tree gimple_assign_rhs_to_tree (gimple);
1075 extern bool validate_gimple_arglist (const_gimple, ...);
1078 extern bool tree_ssa_useless_type_conversion (tree);
1079 extern tree tree_ssa_strip_useless_type_conversions (tree);
1080 extern bool useless_type_conversion_p (tree, tree);
1081 extern bool types_compatible_p (tree, tree);
1083 /* Return the code for GIMPLE statement G. */
1085 static inline enum gimple_code
1086 gimple_code (const_gimple g)
1088 return g->gsbase.code;
1092 /* Return the GSS code used by a GIMPLE code. */
1094 static inline enum gimple_statement_structure_enum
1095 gss_for_code (enum gimple_code code)
1097 #ifdef ENABLE_CHECKING
1098 gcc_assert ((unsigned int)code < LAST_AND_UNUSED_GIMPLE_CODE);
1100 return gss_for_code_[code];
1104 /* Return which GSS code is used by GS. */
1106 static inline enum gimple_statement_structure_enum
1107 gimple_statement_structure (gimple gs)
1109 return gss_for_code (gimple_code (gs));
1113 /* Return true if statement G has sub-statements. This is only true for
1114 High GIMPLE statements. */
1117 gimple_has_substatements (gimple g)
1119 switch (gimple_code (g))
1123 case GIMPLE_EH_FILTER:
1125 case GIMPLE_OMP_FOR:
1126 case GIMPLE_OMP_MASTER:
1127 case GIMPLE_OMP_ORDERED:
1128 case GIMPLE_OMP_SECTION:
1129 case GIMPLE_OMP_PARALLEL:
1130 case GIMPLE_OMP_TASK:
1131 case GIMPLE_OMP_SECTIONS:
1132 case GIMPLE_OMP_SINGLE:
1133 case GIMPLE_OMP_CRITICAL:
1134 case GIMPLE_WITH_CLEANUP_EXPR:
1143 /* Return the basic block holding statement G. */
1145 static inline struct basic_block_def *
1146 gimple_bb (const_gimple g)
1148 return g->gsbase.bb;
1152 /* Return the lexical scope block holding statement G. */
1155 gimple_block (const_gimple g)
1157 return g->gsbase.block;
1161 /* Set BLOCK to be the lexical scope block holding statement G. */
1164 gimple_set_block (gimple g, tree block)
1166 g->gsbase.block = block;
1170 /* Return location information for statement G. */
1172 static inline location_t
1173 gimple_location (const_gimple g)
1175 return g->gsbase.location;
1178 /* Return pointer to location information for statement G. */
1180 static inline const location_t *
1181 gimple_location_ptr (const_gimple g)
1183 return &g->gsbase.location;
1187 /* Set location information for statement G. */
1190 gimple_set_location (gimple g, location_t location)
1192 g->gsbase.location = location;
1196 /* Return true if G contains location information. */
1199 gimple_has_location (const_gimple g)
1201 return gimple_location (g) != UNKNOWN_LOCATION;
1205 /* Return the file name of the location of STMT. */
1207 static inline const char *
1208 gimple_filename (const_gimple stmt)
1210 return LOCATION_FILE (gimple_location (stmt));
1214 /* Return the line number of the location of STMT. */
1217 gimple_lineno (const_gimple stmt)
1219 return LOCATION_LINE (gimple_location (stmt));
1223 /* Determine whether SEQ is a singleton. */
1226 gimple_seq_singleton_p (gimple_seq seq)
1228 return ((gimple_seq_first (seq) != NULL)
1229 && (gimple_seq_first (seq) == gimple_seq_last (seq)));
1232 /* Return true if no warnings should be emitted for statement STMT. */
1235 gimple_no_warning_p (const_gimple stmt)
1237 return stmt->gsbase.no_warning;
1240 /* Set the no_warning flag of STMT to NO_WARNING. */
1243 gimple_set_no_warning (gimple stmt, bool no_warning)
1245 stmt->gsbase.no_warning = (unsigned) no_warning;
1248 /* Set the visited status on statement STMT to VISITED_P. */
1251 gimple_set_visited (gimple stmt, bool visited_p)
1253 stmt->gsbase.visited = (unsigned) visited_p;
1257 /* Return the visited status for statement STMT. */
1260 gimple_visited_p (gimple stmt)
1262 return stmt->gsbase.visited;
1266 /* Set pass local flag PLF on statement STMT to VAL_P. */
1269 gimple_set_plf (gimple stmt, enum plf_mask plf, bool val_p)
1272 stmt->gsbase.plf |= (unsigned int) plf;
1274 stmt->gsbase.plf &= ~((unsigned int) plf);
1278 /* Return the value of pass local flag PLF on statement STMT. */
1280 static inline unsigned int
1281 gimple_plf (gimple stmt, enum plf_mask plf)
1283 return stmt->gsbase.plf & ((unsigned int) plf);
1287 /* Set the UID of statement. */
1290 gimple_set_uid (gimple g, unsigned uid)
1292 g->gsbase.uid = uid;
1296 /* Return the UID of statement. */
1298 static inline unsigned
1299 gimple_uid (const_gimple g)
1301 return g->gsbase.uid;
1305 /* Return true if GIMPLE statement G has register or memory operands. */
1308 gimple_has_ops (const_gimple g)
1310 return gimple_code (g) >= GIMPLE_COND && gimple_code (g) <= GIMPLE_RETURN;
1314 /* Return true if GIMPLE statement G has memory operands. */
1317 gimple_has_mem_ops (const_gimple g)
1319 return gimple_code (g) >= GIMPLE_ASSIGN && gimple_code (g) <= GIMPLE_RETURN;
1323 /* Return the set of DEF operands for statement G. */
1325 static inline struct def_optype_d *
1326 gimple_def_ops (const_gimple g)
1328 if (!gimple_has_ops (g))
1330 return g->gsops.opbase.def_ops;
1334 /* Set DEF to be the set of DEF operands for statement G. */
1337 gimple_set_def_ops (gimple g, struct def_optype_d *def)
1339 gcc_assert (gimple_has_ops (g));
1340 g->gsops.opbase.def_ops = def;
1344 /* Return the set of USE operands for statement G. */
1346 static inline struct use_optype_d *
1347 gimple_use_ops (const_gimple g)
1349 if (!gimple_has_ops (g))
1351 return g->gsops.opbase.use_ops;
1355 /* Set USE to be the set of USE operands for statement G. */
1358 gimple_set_use_ops (gimple g, struct use_optype_d *use)
1360 gcc_assert (gimple_has_ops (g));
1361 g->gsops.opbase.use_ops = use;
1365 /* Return the set of VUSE operand for statement G. */
1367 static inline use_operand_p
1368 gimple_vuse_op (const_gimple g)
1370 struct use_optype_d *ops;
1371 if (!gimple_has_mem_ops (g))
1372 return NULL_USE_OPERAND_P;
1373 ops = g->gsops.opbase.use_ops;
1375 && USE_OP_PTR (ops)->use == &g->gsmembase.vuse)
1376 return USE_OP_PTR (ops);
1377 return NULL_USE_OPERAND_P;
1380 /* Return the set of VDEF operand for statement G. */
1382 static inline def_operand_p
1383 gimple_vdef_op (const_gimple g)
1385 struct def_optype_d *ops;
1386 if (!gimple_has_mem_ops (g))
1387 return NULL_DEF_OPERAND_P;
1388 ops = g->gsops.opbase.def_ops;
1390 && DEF_OP_PTR (ops) == &g->gsmembase.vdef)
1391 return DEF_OP_PTR (ops);
1392 return NULL_DEF_OPERAND_P;
1396 /* Return the single VUSE operand of the statement G. */
1399 gimple_vuse (const_gimple g)
1401 if (!gimple_has_mem_ops (g))
1403 return g->gsmembase.vuse;
1406 /* Return the single VDEF operand of the statement G. */
1409 gimple_vdef (const_gimple g)
1411 if (!gimple_has_mem_ops (g))
1413 return g->gsmembase.vdef;
1416 /* Return the single VUSE operand of the statement G. */
1418 static inline tree *
1419 gimple_vuse_ptr (gimple g)
1421 if (!gimple_has_mem_ops (g))
1423 return &g->gsmembase.vuse;
1426 /* Return the single VDEF operand of the statement G. */
1428 static inline tree *
1429 gimple_vdef_ptr (gimple g)
1431 if (!gimple_has_mem_ops (g))
1433 return &g->gsmembase.vdef;
1436 /* Set the single VUSE operand of the statement G. */
1439 gimple_set_vuse (gimple g, tree vuse)
1441 gcc_assert (gimple_has_mem_ops (g));
1442 g->gsmembase.vuse = vuse;
1445 /* Set the single VDEF operand of the statement G. */
1448 gimple_set_vdef (gimple g, tree vdef)
1450 gcc_assert (gimple_has_mem_ops (g));
1451 g->gsmembase.vdef = vdef;
1455 /* Return true if statement G has operands and the modified field has
1459 gimple_modified_p (const_gimple g)
1461 return (gimple_has_ops (g)) ? (bool) g->gsbase.modified : false;
1465 /* Return the tree code for the expression computed by STMT. This is
1466 only valid for GIMPLE_COND, GIMPLE_CALL and GIMPLE_ASSIGN. For
1467 GIMPLE_CALL, return CALL_EXPR as the expression code for
1468 consistency. This is useful when the caller needs to deal with the
1469 three kinds of computation that GIMPLE supports. */
1471 static inline enum tree_code
1472 gimple_expr_code (const_gimple stmt)
1474 enum gimple_code code = gimple_code (stmt);
1475 if (code == GIMPLE_ASSIGN || code == GIMPLE_COND)
1476 return (enum tree_code) stmt->gsbase.subcode;
1477 else if (code == GIMPLE_CALL)
1484 /* Mark statement S as modified, and update it. */
1487 update_stmt (gimple s)
1489 if (gimple_has_ops (s))
1491 gimple_set_modified (s, true);
1492 update_stmt_operands (s);
1496 /* Update statement S if it has been optimized. */
1499 update_stmt_if_modified (gimple s)
1501 if (gimple_modified_p (s))
1502 update_stmt_operands (s);
1505 /* Return true if statement STMT contains volatile operands. */
1508 gimple_has_volatile_ops (const_gimple stmt)
1510 if (gimple_has_mem_ops (stmt))
1511 return stmt->gsbase.has_volatile_ops;
1517 /* Set the HAS_VOLATILE_OPS flag to VOLATILEP. */
1520 gimple_set_has_volatile_ops (gimple stmt, bool volatilep)
1522 if (gimple_has_mem_ops (stmt))
1523 stmt->gsbase.has_volatile_ops = (unsigned) volatilep;
1527 /* Return true if statement STMT may access memory. */
1530 gimple_references_memory_p (gimple stmt)
1532 return gimple_has_mem_ops (stmt) && gimple_vuse (stmt);
1536 /* Return the subcode for OMP statement S. */
1538 static inline unsigned
1539 gimple_omp_subcode (const_gimple s)
1541 gcc_assert (gimple_code (s) >= GIMPLE_OMP_ATOMIC_LOAD
1542 && gimple_code (s) <= GIMPLE_OMP_SINGLE);
1543 return s->gsbase.subcode;
1546 /* Set the subcode for OMP statement S to SUBCODE. */
1549 gimple_omp_set_subcode (gimple s, unsigned int subcode)
1551 /* We only have 16 bits for the subcode. Assert that we are not
1553 gcc_assert (subcode < (1 << 16));
1554 s->gsbase.subcode = subcode;
1557 /* Set the nowait flag on OMP_RETURN statement S. */
1560 gimple_omp_return_set_nowait (gimple s)
1562 GIMPLE_CHECK (s, GIMPLE_OMP_RETURN);
1563 s->gsbase.subcode |= GF_OMP_RETURN_NOWAIT;
1567 /* Return true if OMP return statement G has the GF_OMP_RETURN_NOWAIT
1571 gimple_omp_return_nowait_p (const_gimple g)
1573 GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
1574 return (gimple_omp_subcode (g) & GF_OMP_RETURN_NOWAIT) != 0;
1578 /* Return true if OMP section statement G has the GF_OMP_SECTION_LAST
1582 gimple_omp_section_last_p (const_gimple g)
1584 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1585 return (gimple_omp_subcode (g) & GF_OMP_SECTION_LAST) != 0;
1589 /* Set the GF_OMP_SECTION_LAST flag on G. */
1592 gimple_omp_section_set_last (gimple g)
1594 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1595 g->gsbase.subcode |= GF_OMP_SECTION_LAST;
1599 /* Return true if OMP parallel statement G has the
1600 GF_OMP_PARALLEL_COMBINED flag set. */
1603 gimple_omp_parallel_combined_p (const_gimple g)
1605 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1606 return (gimple_omp_subcode (g) & GF_OMP_PARALLEL_COMBINED) != 0;
1610 /* Set the GF_OMP_PARALLEL_COMBINED field in G depending on the boolean
1611 value of COMBINED_P. */
1614 gimple_omp_parallel_set_combined_p (gimple g, bool combined_p)
1616 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1618 g->gsbase.subcode |= GF_OMP_PARALLEL_COMBINED;
1620 g->gsbase.subcode &= ~GF_OMP_PARALLEL_COMBINED;
1624 /* Return the number of operands for statement GS. */
1626 static inline unsigned
1627 gimple_num_ops (const_gimple gs)
1629 return gs->gsbase.num_ops;
1633 /* Set the number of operands for statement GS. */
1636 gimple_set_num_ops (gimple gs, unsigned num_ops)
1638 gs->gsbase.num_ops = num_ops;
1642 /* Return the array of operands for statement GS. */
1644 static inline tree *
1645 gimple_ops (gimple gs)
1649 /* All the tuples have their operand vector at the very bottom
1650 of the structure. Note that those structures that do not
1651 have an operand vector have a zero offset. */
1652 off = gimple_ops_offset_[gimple_statement_structure (gs)];
1653 gcc_assert (off != 0);
1655 return (tree *) ((char *) gs + off);
1659 /* Return operand I for statement GS. */
1662 gimple_op (const_gimple gs, unsigned i)
1664 if (gimple_has_ops (gs))
1666 #ifdef ENABLE_CHECKING
1667 gcc_assert (i < gimple_num_ops (gs));
1669 return gimple_ops (CONST_CAST_GIMPLE (gs))[i];
1675 /* Return a pointer to operand I for statement GS. */
1677 static inline tree *
1678 gimple_op_ptr (const_gimple gs, unsigned i)
1680 if (gimple_has_ops (gs))
1682 #ifdef ENABLE_CHECKING
1683 gcc_assert (i < gimple_num_ops (gs));
1685 return gimple_ops (CONST_CAST_GIMPLE (gs)) + i;
1691 /* Set operand I of statement GS to OP. */
1694 gimple_set_op (gimple gs, unsigned i, tree op)
1696 gcc_assert (gimple_has_ops (gs) && i < gimple_num_ops (gs));
1698 /* Note. It may be tempting to assert that OP matches
1699 is_gimple_operand, but that would be wrong. Different tuples
1700 accept slightly different sets of tree operands. Each caller
1701 should perform its own validation. */
1702 gimple_ops (gs)[i] = op;
1705 /* Return true if GS is a GIMPLE_ASSIGN. */
1708 is_gimple_assign (const_gimple gs)
1710 return gimple_code (gs) == GIMPLE_ASSIGN;
1713 /* Determine if expression CODE is one of the valid expressions that can
1714 be used on the RHS of GIMPLE assignments. */
1716 static inline enum gimple_rhs_class
1717 get_gimple_rhs_class (enum tree_code code)
1719 return (enum gimple_rhs_class) gimple_rhs_class_table[(int) code];
1722 /* Return the LHS of assignment statement GS. */
1725 gimple_assign_lhs (const_gimple gs)
1727 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1728 return gimple_op (gs, 0);
1732 /* Return a pointer to the LHS of assignment statement GS. */
1734 static inline tree *
1735 gimple_assign_lhs_ptr (const_gimple gs)
1737 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1738 return gimple_op_ptr (gs, 0);
1742 /* Set LHS to be the LHS operand of assignment statement GS. */
1745 gimple_assign_set_lhs (gimple gs, tree lhs)
1747 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1748 gimple_set_op (gs, 0, lhs);
1750 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1751 SSA_NAME_DEF_STMT (lhs) = gs;
1755 /* Return the first operand on the RHS of assignment statement GS. */
1758 gimple_assign_rhs1 (const_gimple gs)
1760 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1761 return gimple_op (gs, 1);
1765 /* Return a pointer to the first operand on the RHS of assignment
1768 static inline tree *
1769 gimple_assign_rhs1_ptr (const_gimple gs)
1771 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1772 return gimple_op_ptr (gs, 1);
1775 /* Set RHS to be the first operand on the RHS of assignment statement GS. */
1778 gimple_assign_set_rhs1 (gimple gs, tree rhs)
1780 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1782 gimple_set_op (gs, 1, rhs);
1786 /* Return the second operand on the RHS of assignment statement GS.
1787 If GS does not have two operands, NULL is returned instead. */
1790 gimple_assign_rhs2 (const_gimple gs)
1792 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1794 if (gimple_num_ops (gs) >= 3)
1795 return gimple_op (gs, 2);
1801 /* Return a pointer to the second operand on the RHS of assignment
1804 static inline tree *
1805 gimple_assign_rhs2_ptr (const_gimple gs)
1807 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1808 return gimple_op_ptr (gs, 2);
1812 /* Set RHS to be the second operand on the RHS of assignment statement GS. */
1815 gimple_assign_set_rhs2 (gimple gs, tree rhs)
1817 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1819 gimple_set_op (gs, 2, rhs);
1822 /* Returns true if GS is a nontemporal move. */
1825 gimple_assign_nontemporal_move_p (const_gimple gs)
1827 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1828 return gs->gsbase.nontemporal_move;
1831 /* Sets nontemporal move flag of GS to NONTEMPORAL. */
1834 gimple_assign_set_nontemporal_move (gimple gs, bool nontemporal)
1836 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1837 gs->gsbase.nontemporal_move = nontemporal;
1841 /* Return the code of the expression computed on the rhs of assignment
1842 statement GS. In case that the RHS is a single object, returns the
1843 tree code of the object. */
1845 static inline enum tree_code
1846 gimple_assign_rhs_code (const_gimple gs)
1848 enum tree_code code;
1849 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1851 code = gimple_expr_code (gs);
1852 if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS)
1853 code = TREE_CODE (gimple_assign_rhs1 (gs));
1859 /* Set CODE to be the code for the expression computed on the RHS of
1863 gimple_assign_set_rhs_code (gimple s, enum tree_code code)
1865 GIMPLE_CHECK (s, GIMPLE_ASSIGN);
1866 s->gsbase.subcode = code;
1870 /* Return the gimple rhs class of the code of the expression computed on
1871 the rhs of assignment statement GS.
1872 This will never return GIMPLE_INVALID_RHS. */
1874 static inline enum gimple_rhs_class
1875 gimple_assign_rhs_class (const_gimple gs)
1877 return get_gimple_rhs_class (gimple_assign_rhs_code (gs));
1881 /* Return true if S is a type-cast assignment. */
1884 gimple_assign_cast_p (gimple s)
1886 if (is_gimple_assign (s))
1888 enum tree_code sc = gimple_assign_rhs_code (s);
1889 return CONVERT_EXPR_CODE_P (sc)
1890 || sc == VIEW_CONVERT_EXPR
1891 || sc == FIX_TRUNC_EXPR;
1898 /* Return true if GS is a GIMPLE_CALL. */
1901 is_gimple_call (const_gimple gs)
1903 return gimple_code (gs) == GIMPLE_CALL;
1906 /* Return the LHS of call statement GS. */
1909 gimple_call_lhs (const_gimple gs)
1911 GIMPLE_CHECK (gs, GIMPLE_CALL);
1912 return gimple_op (gs, 0);
1916 /* Return a pointer to the LHS of call statement GS. */
1918 static inline tree *
1919 gimple_call_lhs_ptr (const_gimple gs)
1921 GIMPLE_CHECK (gs, GIMPLE_CALL);
1922 return gimple_op_ptr (gs, 0);
1926 /* Set LHS to be the LHS operand of call statement GS. */
1929 gimple_call_set_lhs (gimple gs, tree lhs)
1931 GIMPLE_CHECK (gs, GIMPLE_CALL);
1932 gimple_set_op (gs, 0, lhs);
1933 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1934 SSA_NAME_DEF_STMT (lhs) = gs;
1938 /* Return the tree node representing the function called by call
1942 gimple_call_fn (const_gimple gs)
1944 GIMPLE_CHECK (gs, GIMPLE_CALL);
1945 return gimple_op (gs, 1);
1949 /* Return a pointer to the tree node representing the function called by call
1952 static inline tree *
1953 gimple_call_fn_ptr (const_gimple gs)
1955 GIMPLE_CHECK (gs, GIMPLE_CALL);
1956 return gimple_op_ptr (gs, 1);
1960 /* Set FN to be the function called by call statement GS. */
1963 gimple_call_set_fn (gimple gs, tree fn)
1965 GIMPLE_CHECK (gs, GIMPLE_CALL);
1966 gimple_set_op (gs, 1, fn);
1970 /* Set FNDECL to be the function called by call statement GS. */
1973 gimple_call_set_fndecl (gimple gs, tree decl)
1975 GIMPLE_CHECK (gs, GIMPLE_CALL);
1976 gimple_set_op (gs, 1, build_fold_addr_expr_loc (gimple_location (gs), decl));
1980 /* If a given GIMPLE_CALL's callee is a FUNCTION_DECL, return it.
1981 Otherwise return NULL. This function is analogous to
1982 get_callee_fndecl in tree land. */
1985 gimple_call_fndecl (const_gimple gs)
1987 tree addr = gimple_call_fn (gs);
1988 if (TREE_CODE (addr) == ADDR_EXPR)
1989 return TREE_OPERAND (addr, 0);
1994 /* Return the type returned by call statement GS. */
1997 gimple_call_return_type (const_gimple gs)
1999 tree fn = gimple_call_fn (gs);
2000 tree type = TREE_TYPE (fn);
2002 /* See through the pointer. */
2003 type = TREE_TYPE (type);
2005 /* The type returned by a FUNCTION_DECL is the type of its
2007 return TREE_TYPE (type);
2011 /* Return the static chain for call statement GS. */
2014 gimple_call_chain (const_gimple gs)
2016 GIMPLE_CHECK (gs, GIMPLE_CALL);
2017 return gimple_op (gs, 2);
2021 /* Return a pointer to the static chain for call statement GS. */
2023 static inline tree *
2024 gimple_call_chain_ptr (const_gimple gs)
2026 GIMPLE_CHECK (gs, GIMPLE_CALL);
2027 return gimple_op_ptr (gs, 2);
2030 /* Set CHAIN to be the static chain for call statement GS. */
2033 gimple_call_set_chain (gimple gs, tree chain)
2035 GIMPLE_CHECK (gs, GIMPLE_CALL);
2037 gimple_set_op (gs, 2, chain);
2041 /* Return the number of arguments used by call statement GS. */
2043 static inline unsigned
2044 gimple_call_num_args (const_gimple gs)
2047 GIMPLE_CHECK (gs, GIMPLE_CALL);
2048 num_ops = gimple_num_ops (gs);
2053 /* Return the argument at position INDEX for call statement GS. */
2056 gimple_call_arg (const_gimple gs, unsigned index)
2058 GIMPLE_CHECK (gs, GIMPLE_CALL);
2059 return gimple_op (gs, index + 3);
2063 /* Return a pointer to the argument at position INDEX for call
2066 static inline tree *
2067 gimple_call_arg_ptr (const_gimple gs, unsigned index)
2069 GIMPLE_CHECK (gs, GIMPLE_CALL);
2070 return gimple_op_ptr (gs, index + 3);
2074 /* Set ARG to be the argument at position INDEX for call statement GS. */
2077 gimple_call_set_arg (gimple gs, unsigned index, tree arg)
2079 GIMPLE_CHECK (gs, GIMPLE_CALL);
2080 gimple_set_op (gs, index + 3, arg);
2084 /* If TAIL_P is true, mark call statement S as being a tail call
2085 (i.e., a call just before the exit of a function). These calls are
2086 candidate for tail call optimization. */
2089 gimple_call_set_tail (gimple s, bool tail_p)
2091 GIMPLE_CHECK (s, GIMPLE_CALL);
2093 s->gsbase.subcode |= GF_CALL_TAILCALL;
2095 s->gsbase.subcode &= ~GF_CALL_TAILCALL;
2099 /* Return true if GIMPLE_CALL S is marked as a tail call. */
2102 gimple_call_tail_p (gimple s)
2104 GIMPLE_CHECK (s, GIMPLE_CALL);
2105 return (s->gsbase.subcode & GF_CALL_TAILCALL) != 0;
2109 /* Set the inlinable status of GIMPLE_CALL S to INLINABLE_P. */
2112 gimple_call_set_cannot_inline (gimple s, bool inlinable_p)
2114 GIMPLE_CHECK (s, GIMPLE_CALL);
2116 s->gsbase.subcode |= GF_CALL_CANNOT_INLINE;
2118 s->gsbase.subcode &= ~GF_CALL_CANNOT_INLINE;
2122 /* Return true if GIMPLE_CALL S cannot be inlined. */
2125 gimple_call_cannot_inline_p (gimple s)
2127 GIMPLE_CHECK (s, GIMPLE_CALL);
2128 return (s->gsbase.subcode & GF_CALL_CANNOT_INLINE) != 0;
2132 /* If RETURN_SLOT_OPT_P is true mark GIMPLE_CALL S as valid for return
2133 slot optimization. This transformation uses the target of the call
2134 expansion as the return slot for calls that return in memory. */
2137 gimple_call_set_return_slot_opt (gimple s, bool return_slot_opt_p)
2139 GIMPLE_CHECK (s, GIMPLE_CALL);
2140 if (return_slot_opt_p)
2141 s->gsbase.subcode |= GF_CALL_RETURN_SLOT_OPT;
2143 s->gsbase.subcode &= ~GF_CALL_RETURN_SLOT_OPT;
2147 /* Return true if S is marked for return slot optimization. */
2150 gimple_call_return_slot_opt_p (gimple s)
2152 GIMPLE_CHECK (s, GIMPLE_CALL);
2153 return (s->gsbase.subcode & GF_CALL_RETURN_SLOT_OPT) != 0;
2157 /* If FROM_THUNK_P is true, mark GIMPLE_CALL S as being the jump from a
2158 thunk to the thunked-to function. */
2161 gimple_call_set_from_thunk (gimple s, bool from_thunk_p)
2163 GIMPLE_CHECK (s, GIMPLE_CALL);
2165 s->gsbase.subcode |= GF_CALL_FROM_THUNK;
2167 s->gsbase.subcode &= ~GF_CALL_FROM_THUNK;
2171 /* Return true if GIMPLE_CALL S is a jump from a thunk. */
2174 gimple_call_from_thunk_p (gimple s)
2176 GIMPLE_CHECK (s, GIMPLE_CALL);
2177 return (s->gsbase.subcode & GF_CALL_FROM_THUNK) != 0;
2181 /* If PASS_ARG_PACK_P is true, GIMPLE_CALL S is a stdarg call that needs the
2182 argument pack in its argument list. */
2185 gimple_call_set_va_arg_pack (gimple s, bool pass_arg_pack_p)
2187 GIMPLE_CHECK (s, GIMPLE_CALL);
2188 if (pass_arg_pack_p)
2189 s->gsbase.subcode |= GF_CALL_VA_ARG_PACK;
2191 s->gsbase.subcode &= ~GF_CALL_VA_ARG_PACK;
2195 /* Return true if GIMPLE_CALL S is a stdarg call that needs the
2196 argument pack in its argument list. */
2199 gimple_call_va_arg_pack_p (gimple s)
2201 GIMPLE_CHECK (s, GIMPLE_CALL);
2202 return (s->gsbase.subcode & GF_CALL_VA_ARG_PACK) != 0;
2206 /* Return true if S is a noreturn call. */
2209 gimple_call_noreturn_p (gimple s)
2211 GIMPLE_CHECK (s, GIMPLE_CALL);
2212 return (gimple_call_flags (s) & ECF_NORETURN) != 0;
2216 /* Return true if S is a nothrow call. */
2219 gimple_call_nothrow_p (gimple s)
2221 GIMPLE_CHECK (s, GIMPLE_CALL);
2222 return (gimple_call_flags (s) & ECF_NOTHROW) != 0;
2226 /* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL. */
2229 gimple_call_copy_flags (gimple dest_call, gimple orig_call)
2231 GIMPLE_CHECK (dest_call, GIMPLE_CALL);
2232 GIMPLE_CHECK (orig_call, GIMPLE_CALL);
2233 dest_call->gsbase.subcode = orig_call->gsbase.subcode;
2237 /* Return a pointer to the points-to solution for the set of call-used
2238 variables of the call CALL. */
2240 static inline struct pt_solution *
2241 gimple_call_use_set (gimple call)
2243 GIMPLE_CHECK (call, GIMPLE_CALL);
2244 return &call->gimple_call.call_used;
2248 /* Return a pointer to the points-to solution for the set of call-used
2249 variables of the call CALL. */
2251 static inline struct pt_solution *
2252 gimple_call_clobber_set (gimple call)
2254 GIMPLE_CHECK (call, GIMPLE_CALL);
2255 return &call->gimple_call.call_clobbered;
2259 /* Returns true if this is a GIMPLE_ASSIGN or a GIMPLE_CALL with a
2263 gimple_has_lhs (gimple stmt)
2265 return (is_gimple_assign (stmt)
2266 || (is_gimple_call (stmt)
2267 && gimple_call_lhs (stmt) != NULL_TREE));
2271 /* Return the code of the predicate computed by conditional statement GS. */
2273 static inline enum tree_code
2274 gimple_cond_code (const_gimple gs)
2276 GIMPLE_CHECK (gs, GIMPLE_COND);
2277 return (enum tree_code) gs->gsbase.subcode;
2281 /* Set CODE to be the predicate code for the conditional statement GS. */
2284 gimple_cond_set_code (gimple gs, enum tree_code code)
2286 GIMPLE_CHECK (gs, GIMPLE_COND);
2287 gs->gsbase.subcode = code;
2291 /* Return the LHS of the predicate computed by conditional statement GS. */
2294 gimple_cond_lhs (const_gimple gs)
2296 GIMPLE_CHECK (gs, GIMPLE_COND);
2297 return gimple_op (gs, 0);
2300 /* Return the pointer to the LHS of the predicate computed by conditional
2303 static inline tree *
2304 gimple_cond_lhs_ptr (const_gimple gs)
2306 GIMPLE_CHECK (gs, GIMPLE_COND);
2307 return gimple_op_ptr (gs, 0);
2310 /* Set LHS to be the LHS operand of the predicate computed by
2311 conditional statement GS. */
2314 gimple_cond_set_lhs (gimple gs, tree lhs)
2316 GIMPLE_CHECK (gs, GIMPLE_COND);
2317 gimple_set_op (gs, 0, lhs);
2321 /* Return the RHS operand of the predicate computed by conditional GS. */
2324 gimple_cond_rhs (const_gimple gs)
2326 GIMPLE_CHECK (gs, GIMPLE_COND);
2327 return gimple_op (gs, 1);
2330 /* Return the pointer to the RHS operand of the predicate computed by
2333 static inline tree *
2334 gimple_cond_rhs_ptr (const_gimple gs)
2336 GIMPLE_CHECK (gs, GIMPLE_COND);
2337 return gimple_op_ptr (gs, 1);
2341 /* Set RHS to be the RHS operand of the predicate computed by
2342 conditional statement GS. */
2345 gimple_cond_set_rhs (gimple gs, tree rhs)
2347 GIMPLE_CHECK (gs, GIMPLE_COND);
2348 gimple_set_op (gs, 1, rhs);
2352 /* Return the label used by conditional statement GS when its
2353 predicate evaluates to true. */
2356 gimple_cond_true_label (const_gimple gs)
2358 GIMPLE_CHECK (gs, GIMPLE_COND);
2359 return gimple_op (gs, 2);
2363 /* Set LABEL to be the label used by conditional statement GS when its
2364 predicate evaluates to true. */
2367 gimple_cond_set_true_label (gimple gs, tree label)
2369 GIMPLE_CHECK (gs, GIMPLE_COND);
2370 gimple_set_op (gs, 2, label);
2374 /* Set LABEL to be the label used by conditional statement GS when its
2375 predicate evaluates to false. */
2378 gimple_cond_set_false_label (gimple gs, tree label)
2380 GIMPLE_CHECK (gs, GIMPLE_COND);
2381 gimple_set_op (gs, 3, label);
2385 /* Return the label used by conditional statement GS when its
2386 predicate evaluates to false. */
2389 gimple_cond_false_label (const_gimple gs)
2391 GIMPLE_CHECK (gs, GIMPLE_COND);
2392 return gimple_op (gs, 3);
2396 /* Set the conditional COND_STMT to be of the form 'if (1 == 0)'. */
2399 gimple_cond_make_false (gimple gs)
2401 gimple_cond_set_lhs (gs, boolean_true_node);
2402 gimple_cond_set_rhs (gs, boolean_false_node);
2403 gs->gsbase.subcode = EQ_EXPR;
2407 /* Set the conditional COND_STMT to be of the form 'if (1 == 1)'. */
2410 gimple_cond_make_true (gimple gs)
2412 gimple_cond_set_lhs (gs, boolean_true_node);
2413 gimple_cond_set_rhs (gs, boolean_true_node);
2414 gs->gsbase.subcode = EQ_EXPR;
2417 /* Check if conditional statemente GS is of the form 'if (1 == 1)',
2418 'if (0 == 0)', 'if (1 != 0)' or 'if (0 != 1)' */
2421 gimple_cond_true_p (const_gimple gs)
2423 tree lhs = gimple_cond_lhs (gs);
2424 tree rhs = gimple_cond_rhs (gs);
2425 enum tree_code code = gimple_cond_code (gs);
2427 if (lhs != boolean_true_node && lhs != boolean_false_node)
2430 if (rhs != boolean_true_node && rhs != boolean_false_node)
2433 if (code == NE_EXPR && lhs != rhs)
2436 if (code == EQ_EXPR && lhs == rhs)
2442 /* Check if conditional statement GS is of the form 'if (1 != 1)',
2443 'if (0 != 0)', 'if (1 == 0)' or 'if (0 == 1)' */
2446 gimple_cond_false_p (const_gimple gs)
2448 tree lhs = gimple_cond_lhs (gs);
2449 tree rhs = gimple_cond_rhs (gs);
2450 enum tree_code code = gimple_cond_code (gs);
2452 if (lhs != boolean_true_node && lhs != boolean_false_node)
2455 if (rhs != boolean_true_node && rhs != boolean_false_node)
2458 if (code == NE_EXPR && lhs == rhs)
2461 if (code == EQ_EXPR && lhs != rhs)
2467 /* Check if conditional statement GS is of the form 'if (var != 0)' or
2471 gimple_cond_single_var_p (gimple gs)
2473 if (gimple_cond_code (gs) == NE_EXPR
2474 && gimple_cond_rhs (gs) == boolean_false_node)
2477 if (gimple_cond_code (gs) == EQ_EXPR
2478 && gimple_cond_rhs (gs) == boolean_true_node)
2484 /* Set the code, LHS and RHS of GIMPLE_COND STMT from CODE, LHS and RHS. */
2487 gimple_cond_set_condition (gimple stmt, enum tree_code code, tree lhs, tree rhs)
2489 gimple_cond_set_code (stmt, code);
2490 gimple_cond_set_lhs (stmt, lhs);
2491 gimple_cond_set_rhs (stmt, rhs);
2494 /* Return the LABEL_DECL node used by GIMPLE_LABEL statement GS. */
2497 gimple_label_label (const_gimple gs)
2499 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2500 return gimple_op (gs, 0);
2504 /* Set LABEL to be the LABEL_DECL node used by GIMPLE_LABEL statement
2508 gimple_label_set_label (gimple gs, tree label)
2510 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2511 gimple_set_op (gs, 0, label);
2515 /* Return the destination of the unconditional jump GS. */
2518 gimple_goto_dest (const_gimple gs)
2520 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2521 return gimple_op (gs, 0);
2525 /* Set DEST to be the destination of the unconditonal jump GS. */
2528 gimple_goto_set_dest (gimple gs, tree dest)
2530 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2531 gimple_set_op (gs, 0, dest);
2535 /* Return the variables declared in the GIMPLE_BIND statement GS. */
2538 gimple_bind_vars (const_gimple gs)
2540 GIMPLE_CHECK (gs, GIMPLE_BIND);
2541 return gs->gimple_bind.vars;
2545 /* Set VARS to be the set of variables declared in the GIMPLE_BIND
2549 gimple_bind_set_vars (gimple gs, tree vars)
2551 GIMPLE_CHECK (gs, GIMPLE_BIND);
2552 gs->gimple_bind.vars = vars;
2556 /* Append VARS to the set of variables declared in the GIMPLE_BIND
2560 gimple_bind_append_vars (gimple gs, tree vars)
2562 GIMPLE_CHECK (gs, GIMPLE_BIND);
2563 gs->gimple_bind.vars = chainon (gs->gimple_bind.vars, vars);
2567 /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS. */
2569 static inline gimple_seq
2570 gimple_bind_body (gimple gs)
2572 GIMPLE_CHECK (gs, GIMPLE_BIND);
2573 return gs->gimple_bind.body;
2577 /* Set SEQ to be the GIMPLE sequence contained in the GIMPLE_BIND
2581 gimple_bind_set_body (gimple gs, gimple_seq seq)
2583 GIMPLE_CHECK (gs, GIMPLE_BIND);
2584 gs->gimple_bind.body = seq;
2588 /* Append a statement to the end of a GIMPLE_BIND's body. */
2591 gimple_bind_add_stmt (gimple gs, gimple stmt)
2593 GIMPLE_CHECK (gs, GIMPLE_BIND);
2594 gimple_seq_add_stmt (&gs->gimple_bind.body, stmt);
2598 /* Append a sequence of statements to the end of a GIMPLE_BIND's body. */
2601 gimple_bind_add_seq (gimple gs, gimple_seq seq)
2603 GIMPLE_CHECK (gs, GIMPLE_BIND);
2604 gimple_seq_add_seq (&gs->gimple_bind.body, seq);
2608 /* Return the TREE_BLOCK node associated with GIMPLE_BIND statement
2609 GS. This is analogous to the BIND_EXPR_BLOCK field in trees. */
2612 gimple_bind_block (const_gimple gs)
2614 GIMPLE_CHECK (gs, GIMPLE_BIND);
2615 return gs->gimple_bind.block;
2619 /* Set BLOCK to be the TREE_BLOCK node associated with GIMPLE_BIND
2623 gimple_bind_set_block (gimple gs, tree block)
2625 GIMPLE_CHECK (gs, GIMPLE_BIND);
2626 gcc_assert (block == NULL_TREE || TREE_CODE (block) == BLOCK);
2627 gs->gimple_bind.block = block;
2631 /* Return the number of input operands for GIMPLE_ASM GS. */
2633 static inline unsigned
2634 gimple_asm_ninputs (const_gimple gs)
2636 GIMPLE_CHECK (gs, GIMPLE_ASM);
2637 return gs->gimple_asm.ni;
2641 /* Return the number of output operands for GIMPLE_ASM GS. */
2643 static inline unsigned
2644 gimple_asm_noutputs (const_gimple gs)
2646 GIMPLE_CHECK (gs, GIMPLE_ASM);
2647 return gs->gimple_asm.no;
2651 /* Return the number of clobber operands for GIMPLE_ASM GS. */
2653 static inline unsigned
2654 gimple_asm_nclobbers (const_gimple gs)
2656 GIMPLE_CHECK (gs, GIMPLE_ASM);
2657 return gs->gimple_asm.nc;
2660 /* Return the number of label operands for GIMPLE_ASM GS. */
2662 static inline unsigned
2663 gimple_asm_nlabels (const_gimple gs)
2665 GIMPLE_CHECK (gs, GIMPLE_ASM);
2666 return gs->gimple_asm.nl;
2669 /* Return input operand INDEX of GIMPLE_ASM GS. */
2672 gimple_asm_input_op (const_gimple gs, unsigned index)
2674 GIMPLE_CHECK (gs, GIMPLE_ASM);
2675 gcc_assert (index <= gs->gimple_asm.ni);
2676 return gimple_op (gs, index);
2679 /* Return a pointer to input operand INDEX of GIMPLE_ASM GS. */
2681 static inline tree *
2682 gimple_asm_input_op_ptr (const_gimple gs, unsigned index)
2684 GIMPLE_CHECK (gs, GIMPLE_ASM);
2685 gcc_assert (index <= gs->gimple_asm.ni);
2686 return gimple_op_ptr (gs, index);
2690 /* Set IN_OP to be input operand INDEX in GIMPLE_ASM GS. */
2693 gimple_asm_set_input_op (gimple gs, unsigned index, tree in_op)
2695 GIMPLE_CHECK (gs, GIMPLE_ASM);
2696 gcc_assert (index <= gs->gimple_asm.ni);
2697 gcc_assert (TREE_CODE (in_op) == TREE_LIST);
2698 gimple_set_op (gs, index, in_op);
2702 /* Return output operand INDEX of GIMPLE_ASM GS. */
2705 gimple_asm_output_op (const_gimple gs, unsigned index)
2707 GIMPLE_CHECK (gs, GIMPLE_ASM);
2708 gcc_assert (index <= gs->gimple_asm.no);
2709 return gimple_op (gs, index + gs->gimple_asm.ni);
2712 /* Return a pointer to output operand INDEX of GIMPLE_ASM GS. */
2714 static inline tree *
2715 gimple_asm_output_op_ptr (const_gimple gs, unsigned index)
2717 GIMPLE_CHECK (gs, GIMPLE_ASM);
2718 gcc_assert (index <= gs->gimple_asm.no);
2719 return gimple_op_ptr (gs, index + gs->gimple_asm.ni);
2723 /* Set OUT_OP to be output operand INDEX in GIMPLE_ASM GS. */
2726 gimple_asm_set_output_op (gimple gs, unsigned index, tree out_op)
2728 GIMPLE_CHECK (gs, GIMPLE_ASM);
2729 gcc_assert (index <= gs->gimple_asm.no);
2730 gcc_assert (TREE_CODE (out_op) == TREE_LIST);
2731 gimple_set_op (gs, index + gs->gimple_asm.ni, out_op);
2735 /* Return clobber operand INDEX of GIMPLE_ASM GS. */
2738 gimple_asm_clobber_op (const_gimple gs, unsigned index)
2740 GIMPLE_CHECK (gs, GIMPLE_ASM);
2741 gcc_assert (index <= gs->gimple_asm.nc);
2742 return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no);
2746 /* Set CLOBBER_OP to be clobber operand INDEX in GIMPLE_ASM GS. */
2749 gimple_asm_set_clobber_op (gimple gs, unsigned index, tree clobber_op)
2751 GIMPLE_CHECK (gs, GIMPLE_ASM);
2752 gcc_assert (index <= gs->gimple_asm.nc);
2753 gcc_assert (TREE_CODE (clobber_op) == TREE_LIST);
2754 gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no, clobber_op);
2757 /* Return label operand INDEX of GIMPLE_ASM GS. */
2760 gimple_asm_label_op (const_gimple gs, unsigned index)
2762 GIMPLE_CHECK (gs, GIMPLE_ASM);
2763 gcc_assert (index <= gs->gimple_asm.nl);
2764 return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.nc);
2767 /* Set LABEL_OP to be label operand INDEX in GIMPLE_ASM GS. */
2770 gimple_asm_set_label_op (gimple gs, unsigned index, tree label_op)
2772 GIMPLE_CHECK (gs, GIMPLE_ASM);
2773 gcc_assert (index <= gs->gimple_asm.nl);
2774 gcc_assert (TREE_CODE (label_op) == TREE_LIST);
2775 gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.nc, label_op);
2778 /* Return the string representing the assembly instruction in
2781 static inline const char *
2782 gimple_asm_string (const_gimple gs)
2784 GIMPLE_CHECK (gs, GIMPLE_ASM);
2785 return gs->gimple_asm.string;
2789 /* Return true if GS is an asm statement marked volatile. */
2792 gimple_asm_volatile_p (const_gimple gs)
2794 GIMPLE_CHECK (gs, GIMPLE_ASM);
2795 return (gs->gsbase.subcode & GF_ASM_VOLATILE) != 0;
2799 /* If VOLATLE_P is true, mark asm statement GS as volatile. */
2802 gimple_asm_set_volatile (gimple gs, bool volatile_p)
2804 GIMPLE_CHECK (gs, GIMPLE_ASM);
2806 gs->gsbase.subcode |= GF_ASM_VOLATILE;
2808 gs->gsbase.subcode &= ~GF_ASM_VOLATILE;
2812 /* If INPUT_P is true, mark asm GS as an ASM_INPUT. */
2815 gimple_asm_set_input (gimple gs, bool input_p)
2817 GIMPLE_CHECK (gs, GIMPLE_ASM);
2819 gs->gsbase.subcode |= GF_ASM_INPUT;
2821 gs->gsbase.subcode &= ~GF_ASM_INPUT;
2825 /* Return true if asm GS is an ASM_INPUT. */
2828 gimple_asm_input_p (const_gimple gs)
2830 GIMPLE_CHECK (gs, GIMPLE_ASM);
2831 return (gs->gsbase.subcode & GF_ASM_INPUT) != 0;
2835 /* Return the types handled by GIMPLE_CATCH statement GS. */
2838 gimple_catch_types (const_gimple gs)
2840 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2841 return gs->gimple_catch.types;
2845 /* Return a pointer to the types handled by GIMPLE_CATCH statement GS. */
2847 static inline tree *
2848 gimple_catch_types_ptr (gimple gs)
2850 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2851 return &gs->gimple_catch.types;
2855 /* Return the GIMPLE sequence representing the body of the handler of
2856 GIMPLE_CATCH statement GS. */
2858 static inline gimple_seq
2859 gimple_catch_handler (gimple gs)
2861 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2862 return gs->gimple_catch.handler;
2866 /* Return a pointer to the GIMPLE sequence representing the body of
2867 the handler of GIMPLE_CATCH statement GS. */
2869 static inline gimple_seq *
2870 gimple_catch_handler_ptr (gimple gs)
2872 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2873 return &gs->gimple_catch.handler;
2877 /* Set T to be the set of types handled by GIMPLE_CATCH GS. */
2880 gimple_catch_set_types (gimple gs, tree t)
2882 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2883 gs->gimple_catch.types = t;
2887 /* Set HANDLER to be the body of GIMPLE_CATCH GS. */
2890 gimple_catch_set_handler (gimple gs, gimple_seq handler)
2892 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2893 gs->gimple_catch.handler = handler;
2897 /* Return the types handled by GIMPLE_EH_FILTER statement GS. */
2900 gimple_eh_filter_types (const_gimple gs)
2902 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2903 return gs->gimple_eh_filter.types;
2907 /* Return a pointer to the types handled by GIMPLE_EH_FILTER statement
2910 static inline tree *
2911 gimple_eh_filter_types_ptr (gimple gs)
2913 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2914 return &gs->gimple_eh_filter.types;
2918 /* Return the sequence of statement to execute when GIMPLE_EH_FILTER
2921 static inline gimple_seq
2922 gimple_eh_filter_failure (gimple gs)
2924 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2925 return gs->gimple_eh_filter.failure;
2929 /* Set TYPES to be the set of types handled by GIMPLE_EH_FILTER GS. */
2932 gimple_eh_filter_set_types (gimple gs, tree types)
2934 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2935 gs->gimple_eh_filter.types = types;
2939 /* Set FAILURE to be the sequence of statements to execute on failure
2940 for GIMPLE_EH_FILTER GS. */
2943 gimple_eh_filter_set_failure (gimple gs, gimple_seq failure)
2945 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2946 gs->gimple_eh_filter.failure = failure;
2949 /* Get the function decl to be called by the MUST_NOT_THROW region. */
2952 gimple_eh_must_not_throw_fndecl (gimple gs)
2954 GIMPLE_CHECK (gs, GIMPLE_EH_MUST_NOT_THROW);
2955 return gs->gimple_eh_mnt.fndecl;
2958 /* Set the function decl to be called by GS to DECL. */
2961 gimple_eh_must_not_throw_set_fndecl (gimple gs, tree decl)
2963 GIMPLE_CHECK (gs, GIMPLE_EH_MUST_NOT_THROW);
2964 gs->gimple_eh_mnt.fndecl = decl;
2968 /* GIMPLE_TRY accessors. */
2970 /* Return the kind of try block represented by GIMPLE_TRY GS. This is
2971 either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY. */
2973 static inline enum gimple_try_flags
2974 gimple_try_kind (const_gimple gs)
2976 GIMPLE_CHECK (gs, GIMPLE_TRY);
2977 return (enum gimple_try_flags) (gs->gsbase.subcode & GIMPLE_TRY_KIND);
2981 /* Set the kind of try block represented by GIMPLE_TRY GS. */
2984 gimple_try_set_kind (gimple gs, enum gimple_try_flags kind)
2986 GIMPLE_CHECK (gs, GIMPLE_TRY);
2987 gcc_assert (kind == GIMPLE_TRY_CATCH || kind == GIMPLE_TRY_FINALLY);
2988 if (gimple_try_kind (gs) != kind)
2989 gs->gsbase.subcode = (unsigned int) kind;
2993 /* Return the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2996 gimple_try_catch_is_cleanup (const_gimple gs)
2998 gcc_assert (gimple_try_kind (gs) == GIMPLE_TRY_CATCH);
2999 return (gs->gsbase.subcode & GIMPLE_TRY_CATCH_IS_CLEANUP) != 0;
3003 /* Return the sequence of statements used as the body for GIMPLE_TRY GS. */
3005 static inline gimple_seq
3006 gimple_try_eval (gimple gs)
3008 GIMPLE_CHECK (gs, GIMPLE_TRY);
3009 return gs->gimple_try.eval;
3013 /* Return the sequence of statements used as the cleanup body for
3016 static inline gimple_seq
3017 gimple_try_cleanup (gimple gs)
3019 GIMPLE_CHECK (gs, GIMPLE_TRY);
3020 return gs->gimple_try.cleanup;
3024 /* Set the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
3027 gimple_try_set_catch_is_cleanup (gimple g, bool catch_is_cleanup)
3029 gcc_assert (gimple_try_kind (g) == GIMPLE_TRY_CATCH);
3030 if (catch_is_cleanup)
3031 g->gsbase.subcode |= GIMPLE_TRY_CATCH_IS_CLEANUP;
3033 g->gsbase.subcode &= ~GIMPLE_TRY_CATCH_IS_CLEANUP;
3037 /* Set EVAL to be the sequence of statements to use as the body for
3041 gimple_try_set_eval (gimple gs, gimple_seq eval)
3043 GIMPLE_CHECK (gs, GIMPLE_TRY);
3044 gs->gimple_try.eval = eval;
3048 /* Set CLEANUP to be the sequence of statements to use as the cleanup
3049 body for GIMPLE_TRY GS. */
3052 gimple_try_set_cleanup (gimple gs, gimple_seq cleanup)
3054 GIMPLE_CHECK (gs, GIMPLE_TRY);
3055 gs->gimple_try.cleanup = cleanup;
3059 /* Return the cleanup sequence for cleanup statement GS. */
3061 static inline gimple_seq
3062 gimple_wce_cleanup (gimple gs)
3064 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3065 return gs->gimple_wce.cleanup;
3069 /* Set CLEANUP to be the cleanup sequence for GS. */
3072 gimple_wce_set_cleanup (gimple gs, gimple_seq cleanup)
3074 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3075 gs->gimple_wce.cleanup = cleanup;
3079 /* Return the CLEANUP_EH_ONLY flag for a WCE tuple. */
3082 gimple_wce_cleanup_eh_only (const_gimple gs)
3084 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3085 return gs->gsbase.subcode != 0;
3089 /* Set the CLEANUP_EH_ONLY flag for a WCE tuple. */
3092 gimple_wce_set_cleanup_eh_only (gimple gs, bool eh_only_p)
3094 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3095 gs->gsbase.subcode = (unsigned int) eh_only_p;
3099 /* Return the maximum number of arguments supported by GIMPLE_PHI GS. */
3101 static inline unsigned
3102 gimple_phi_capacity (const_gimple gs)
3104 GIMPLE_CHECK (gs, GIMPLE_PHI);
3105 return gs->gimple_phi.capacity;
3109 /* Return the number of arguments in GIMPLE_PHI GS. This must always
3110 be exactly the number of incoming edges for the basic block holding
3113 static inline unsigned
3114 gimple_phi_num_args (const_gimple gs)
3116 GIMPLE_CHECK (gs, GIMPLE_PHI);
3117 return gs->gimple_phi.nargs;
3121 /* Return the SSA name created by GIMPLE_PHI GS. */
3124 gimple_phi_result (const_gimple gs)
3126 GIMPLE_CHECK (gs, GIMPLE_PHI);
3127 return gs->gimple_phi.result;
3130 /* Return a pointer to the SSA name created by GIMPLE_PHI GS. */
3132 static inline tree *
3133 gimple_phi_result_ptr (gimple gs)
3135 GIMPLE_CHECK (gs, GIMPLE_PHI);
3136 return &gs->gimple_phi.result;
3139 /* Set RESULT to be the SSA name created by GIMPLE_PHI GS. */
3142 gimple_phi_set_result (gimple gs, tree result)
3144 GIMPLE_CHECK (gs, GIMPLE_PHI);
3145 gs->gimple_phi.result = result;
3149 /* Return the PHI argument corresponding to incoming edge INDEX for
3152 static inline struct phi_arg_d *
3153 gimple_phi_arg (gimple gs, unsigned index)
3155 GIMPLE_CHECK (gs, GIMPLE_PHI);
3156 gcc_assert (index <= gs->gimple_phi.capacity);
3157 return &(gs->gimple_phi.args[index]);
3160 /* Set PHIARG to be the argument corresponding to incoming edge INDEX
3161 for GIMPLE_PHI GS. */
3164 gimple_phi_set_arg (gimple gs, unsigned index, struct phi_arg_d * phiarg)
3166 GIMPLE_CHECK (gs, GIMPLE_PHI);
3167 gcc_assert (index <= gs->gimple_phi.nargs);
3168 memcpy (gs->gimple_phi.args + index, phiarg, sizeof (struct phi_arg_d));
3171 /* Return the region number for GIMPLE_RESX GS. */
3174 gimple_resx_region (const_gimple gs)
3176 GIMPLE_CHECK (gs, GIMPLE_RESX);
3177 return gs->gimple_eh_ctrl.region;
3180 /* Set REGION to be the region number for GIMPLE_RESX GS. */
3183 gimple_resx_set_region (gimple gs, int region)
3185 GIMPLE_CHECK (gs, GIMPLE_RESX);
3186 gs->gimple_eh_ctrl.region = region;
3189 /* Return the region number for GIMPLE_EH_DISPATCH GS. */
3192 gimple_eh_dispatch_region (const_gimple gs)
3194 GIMPLE_CHECK (gs, GIMPLE_EH_DISPATCH);
3195 return gs->gimple_eh_ctrl.region;
3198 /* Set REGION to be the region number for GIMPLE_EH_DISPATCH GS. */
3201 gimple_eh_dispatch_set_region (gimple gs, int region)
3203 GIMPLE_CHECK (gs, GIMPLE_EH_DISPATCH);
3204 gs->gimple_eh_ctrl.region = region;
3207 /* Return the number of labels associated with the switch statement GS. */
3209 static inline unsigned
3210 gimple_switch_num_labels (const_gimple gs)
3213 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3214 num_ops = gimple_num_ops (gs);
3215 gcc_assert (num_ops > 1);
3220 /* Set NLABELS to be the number of labels for the switch statement GS. */
3223 gimple_switch_set_num_labels (gimple g, unsigned nlabels)
3225 GIMPLE_CHECK (g, GIMPLE_SWITCH);
3226 gimple_set_num_ops (g, nlabels + 1);
3230 /* Return the index variable used by the switch statement GS. */
3233 gimple_switch_index (const_gimple gs)
3235 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3236 return gimple_op (gs, 0);
3240 /* Return a pointer to the index variable for the switch statement GS. */
3242 static inline tree *
3243 gimple_switch_index_ptr (const_gimple gs)
3245 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3246 return gimple_op_ptr (gs, 0);
3250 /* Set INDEX to be the index variable for switch statement GS. */
3253 gimple_switch_set_index (gimple gs, tree index)
3255 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3256 gcc_assert (SSA_VAR_P (index) || CONSTANT_CLASS_P (index));
3257 gimple_set_op (gs, 0, index);
3261 /* Return the label numbered INDEX. The default label is 0, followed by any
3262 labels in a switch statement. */
3265 gimple_switch_label (const_gimple gs, unsigned index)
3267 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3268 gcc_assert (gimple_num_ops (gs) > index + 1);
3269 return gimple_op (gs, index + 1);
3272 /* Set the label number INDEX to LABEL. 0 is always the default label. */
3275 gimple_switch_set_label (gimple gs, unsigned index, tree label)
3277 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3278 gcc_assert (gimple_num_ops (gs) > index + 1);
3279 gcc_assert (label == NULL_TREE || TREE_CODE (label) == CASE_LABEL_EXPR);
3280 gimple_set_op (gs, index + 1, label);
3283 /* Return the default label for a switch statement. */
3286 gimple_switch_default_label (const_gimple gs)
3288 return gimple_switch_label (gs, 0);
3291 /* Set the default label for a switch statement. */
3294 gimple_switch_set_default_label (gimple gs, tree label)
3296 gimple_switch_set_label (gs, 0, label);
3299 /* Return true if GS is a GIMPLE_DEBUG statement. */
3302 is_gimple_debug (const_gimple gs)
3304 return gimple_code (gs) == GIMPLE_DEBUG;
3307 /* Return true if S is a GIMPLE_DEBUG BIND statement. */
3310 gimple_debug_bind_p (const_gimple s)
3312 if (is_gimple_debug (s))
3313 return s->gsbase.subcode == GIMPLE_DEBUG_BIND;
3318 /* Return the variable bound in a GIMPLE_DEBUG bind statement. */
3321 gimple_debug_bind_get_var (gimple dbg)
3323 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3324 #ifdef ENABLE_CHECKING
3325 gcc_assert (gimple_debug_bind_p (dbg));
3327 return gimple_op (dbg, 0);
3330 /* Return the value bound to the variable in a GIMPLE_DEBUG bind
3334 gimple_debug_bind_get_value (gimple dbg)
3336 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3337 #ifdef ENABLE_CHECKING
3338 gcc_assert (gimple_debug_bind_p (dbg));
3340 return gimple_op (dbg, 1);
3343 /* Return a pointer to the value bound to the variable in a
3344 GIMPLE_DEBUG bind statement. */
3346 static inline tree *
3347 gimple_debug_bind_get_value_ptr (gimple dbg)
3349 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3350 #ifdef ENABLE_CHECKING
3351 gcc_assert (gimple_debug_bind_p (dbg));
3353 return gimple_op_ptr (dbg, 1);
3356 /* Set the variable bound in a GIMPLE_DEBUG bind statement. */
3359 gimple_debug_bind_set_var (gimple dbg, tree var)
3361 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3362 #ifdef ENABLE_CHECKING
3363 gcc_assert (gimple_debug_bind_p (dbg));
3365 gimple_set_op (dbg, 0, var);
3368 /* Set the value bound to the variable in a GIMPLE_DEBUG bind
3372 gimple_debug_bind_set_value (gimple dbg, tree value)
3374 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3375 #ifdef ENABLE_CHECKING
3376 gcc_assert (gimple_debug_bind_p (dbg));
3378 gimple_set_op (dbg, 1, value);
3381 /* The second operand of a GIMPLE_DEBUG_BIND, when the value was
3383 #define GIMPLE_DEBUG_BIND_NOVALUE NULL_TREE /* error_mark_node */
3385 /* Remove the value bound to the variable in a GIMPLE_DEBUG bind
3389 gimple_debug_bind_reset_value (gimple dbg)
3391 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3392 #ifdef ENABLE_CHECKING
3393 gcc_assert (gimple_debug_bind_p (dbg));
3395 gimple_set_op (dbg, 1, GIMPLE_DEBUG_BIND_NOVALUE);
3398 /* Return true if the GIMPLE_DEBUG bind statement is bound to a
3402 gimple_debug_bind_has_value_p (gimple dbg)
3404 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3405 #ifdef ENABLE_CHECKING
3406 gcc_assert (gimple_debug_bind_p (dbg));
3408 return gimple_op (dbg, 1) != GIMPLE_DEBUG_BIND_NOVALUE;
3411 #undef GIMPLE_DEBUG_BIND_NOVALUE
3413 /* Return the body for the OMP statement GS. */
3415 static inline gimple_seq
3416 gimple_omp_body (gimple gs)
3418 return gs->omp.body;
3421 /* Set BODY to be the body for the OMP statement GS. */
3424 gimple_omp_set_body (gimple gs, gimple_seq body)
3426 gs->omp.body = body;
3430 /* Return the name associated with OMP_CRITICAL statement GS. */
3433 gimple_omp_critical_name (const_gimple gs)
3435 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3436 return gs->gimple_omp_critical.name;
3440 /* Return a pointer to the name associated with OMP critical statement GS. */
3442 static inline tree *
3443 gimple_omp_critical_name_ptr (gimple gs)
3445 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3446 return &gs->gimple_omp_critical.name;
3450 /* Set NAME to be the name associated with OMP critical statement GS. */
3453 gimple_omp_critical_set_name (gimple gs, tree name)
3455 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3456 gs->gimple_omp_critical.name = name;
3460 /* Return the clauses associated with OMP_FOR GS. */
3463 gimple_omp_for_clauses (const_gimple gs)
3465 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3466 return gs->gimple_omp_for.clauses;
3470 /* Return a pointer to the OMP_FOR GS. */
3472 static inline tree *
3473 gimple_omp_for_clauses_ptr (gimple gs)
3475 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3476 return &gs->gimple_omp_for.clauses;
3480 /* Set CLAUSES to be the list of clauses associated with OMP_FOR GS. */
3483 gimple_omp_for_set_clauses (gimple gs, tree clauses)
3485 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3486 gs->gimple_omp_for.clauses = clauses;
3490 /* Get the collapse count of OMP_FOR GS. */
3492 static inline size_t
3493 gimple_omp_for_collapse (gimple gs)
3495 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3496 return gs->gimple_omp_for.collapse;
3500 /* Return the index variable for OMP_FOR GS. */
3503 gimple_omp_for_index (const_gimple gs, size_t i)
3505 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3506 gcc_assert (i < gs->gimple_omp_for.collapse);
3507 return gs->gimple_omp_for.iter[i].index;
3511 /* Return a pointer to the index variable for OMP_FOR GS. */
3513 static inline tree *
3514 gimple_omp_for_index_ptr (gimple gs, size_t i)
3516 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3517 gcc_assert (i < gs->gimple_omp_for.collapse);
3518 return &gs->gimple_omp_for.iter[i].index;
3522 /* Set INDEX to be the index variable for OMP_FOR GS. */
3525 gimple_omp_for_set_index (gimple gs, size_t i, tree index)
3527 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3528 gcc_assert (i < gs->gimple_omp_for.collapse);
3529 gs->gimple_omp_for.iter[i].index = index;
3533 /* Return the initial value for OMP_FOR GS. */
3536 gimple_omp_for_initial (const_gimple gs, size_t i)
3538 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3539 gcc_assert (i < gs->gimple_omp_for.collapse);
3540 return gs->gimple_omp_for.iter[i].initial;
3544 /* Return a pointer to the initial value for OMP_FOR GS. */
3546 static inline tree *
3547 gimple_omp_for_initial_ptr (gimple gs, size_t i)
3549 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3550 gcc_assert (i < gs->gimple_omp_for.collapse);
3551 return &gs->gimple_omp_for.iter[i].initial;
3555 /* Set INITIAL to be the initial value for OMP_FOR GS. */
3558 gimple_omp_for_set_initial (gimple gs, size_t i, tree initial)
3560 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3561 gcc_assert (i < gs->gimple_omp_for.collapse);
3562 gs->gimple_omp_for.iter[i].initial = initial;
3566 /* Return the final value for OMP_FOR GS. */
3569 gimple_omp_for_final (const_gimple gs, size_t i)
3571 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3572 gcc_assert (i < gs->gimple_omp_for.collapse);
3573 return gs->gimple_omp_for.iter[i].final;
3577 /* Return a pointer to the final value for OMP_FOR GS. */
3579 static inline tree *
3580 gimple_omp_for_final_ptr (gimple gs, size_t i)
3582 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3583 gcc_assert (i < gs->gimple_omp_for.collapse);
3584 return &gs->gimple_omp_for.iter[i].final;
3588 /* Set FINAL to be the final value for OMP_FOR GS. */
3591 gimple_omp_for_set_final (gimple gs, size_t i, tree final)
3593 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3594 gcc_assert (i < gs->gimple_omp_for.collapse);
3595 gs->gimple_omp_for.iter[i].final = final;
3599 /* Return the increment value for OMP_FOR GS. */
3602 gimple_omp_for_incr (const_gimple gs, size_t i)
3604 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3605 gcc_assert (i < gs->gimple_omp_for.collapse);
3606 return gs->gimple_omp_for.iter[i].incr;
3610 /* Return a pointer to the increment value for OMP_FOR GS. */
3612 static inline tree *
3613 gimple_omp_for_incr_ptr (gimple gs, size_t i)
3615 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3616 gcc_assert (i < gs->gimple_omp_for.collapse);
3617 return &gs->gimple_omp_for.iter[i].incr;
3621 /* Set INCR to be the increment value for OMP_FOR GS. */
3624 gimple_omp_for_set_incr (gimple gs, size_t i, tree incr)
3626 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3627 gcc_assert (i < gs->gimple_omp_for.collapse);
3628 gs->gimple_omp_for.iter[i].incr = incr;
3632 /* Return the sequence of statements to execute before the OMP_FOR
3633 statement GS starts. */
3635 static inline gimple_seq
3636 gimple_omp_for_pre_body (gimple gs)
3638 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3639 return gs->gimple_omp_for.pre_body;
3643 /* Set PRE_BODY to be the sequence of statements to execute before the
3644 OMP_FOR statement GS starts. */
3647 gimple_omp_for_set_pre_body (gimple gs, gimple_seq pre_body)
3649 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3650 gs->gimple_omp_for.pre_body = pre_body;
3654 /* Return the clauses associated with OMP_PARALLEL GS. */
3657 gimple_omp_parallel_clauses (const_gimple gs)
3659 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3660 return gs->gimple_omp_parallel.clauses;
3664 /* Return a pointer to the clauses associated with OMP_PARALLEL GS. */
3666 static inline tree *
3667 gimple_omp_parallel_clauses_ptr (gimple gs)
3669 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3670 return &gs->gimple_omp_parallel.clauses;
3674 /* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL
3678 gimple_omp_parallel_set_clauses (gimple gs, tree clauses)
3680 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3681 gs->gimple_omp_parallel.clauses = clauses;
3685 /* Return the child function used to hold the body of OMP_PARALLEL GS. */
3688 gimple_omp_parallel_child_fn (const_gimple gs)
3690 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3691 return gs->gimple_omp_parallel.child_fn;
3694 /* Return a pointer to the child function used to hold the body of
3697 static inline tree *
3698 gimple_omp_parallel_child_fn_ptr (gimple gs)
3700 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3701 return &gs->gimple_omp_parallel.child_fn;
3705 /* Set CHILD_FN to be the child function for OMP_PARALLEL GS. */
3708 gimple_omp_parallel_set_child_fn (gimple gs, tree child_fn)
3710 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3711 gs->gimple_omp_parallel.child_fn = child_fn;
3715 /* Return the artificial argument used to send variables and values
3716 from the parent to the children threads in OMP_PARALLEL GS. */
3719 gimple_omp_parallel_data_arg (const_gimple gs)
3721 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3722 return gs->gimple_omp_parallel.data_arg;
3726 /* Return a pointer to the data argument for OMP_PARALLEL GS. */
3728 static inline tree *
3729 gimple_omp_parallel_data_arg_ptr (gimple gs)
3731 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3732 return &gs->gimple_omp_parallel.data_arg;
3736 /* Set DATA_ARG to be the data argument for OMP_PARALLEL GS. */
3739 gimple_omp_parallel_set_data_arg (gimple gs, tree data_arg)
3741 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3742 gs->gimple_omp_parallel.data_arg = data_arg;
3746 /* Return the clauses associated with OMP_TASK GS. */
3749 gimple_omp_task_clauses (const_gimple gs)
3751 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3752 return gs->gimple_omp_parallel.clauses;
3756 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3758 static inline tree *
3759 gimple_omp_task_clauses_ptr (gimple gs)
3761 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3762 return &gs->gimple_omp_parallel.clauses;
3766 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3770 gimple_omp_task_set_clauses (gimple gs, tree clauses)
3772 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3773 gs->gimple_omp_parallel.clauses = clauses;
3777 /* Return the child function used to hold the body of OMP_TASK GS. */
3780 gimple_omp_task_child_fn (const_gimple gs)
3782 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3783 return gs->gimple_omp_parallel.child_fn;
3786 /* Return a pointer to the child function used to hold the body of
3789 static inline tree *
3790 gimple_omp_task_child_fn_ptr (gimple gs)
3792 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3793 return &gs->gimple_omp_parallel.child_fn;
3797 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3800 gimple_omp_task_set_child_fn (gimple gs, tree child_fn)
3802 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3803 gs->gimple_omp_parallel.child_fn = child_fn;
3807 /* Return the artificial argument used to send variables and values
3808 from the parent to the children threads in OMP_TASK GS. */
3811 gimple_omp_task_data_arg (const_gimple gs)
3813 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3814 return gs->gimple_omp_parallel.data_arg;
3818 /* Return a pointer to the data argument for OMP_TASK GS. */
3820 static inline tree *
3821 gimple_omp_task_data_arg_ptr (gimple gs)
3823 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3824 return &gs->gimple_omp_parallel.data_arg;
3828 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3831 gimple_omp_task_set_data_arg (gimple gs, tree data_arg)
3833 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3834 gs->gimple_omp_parallel.data_arg = data_arg;
3838 /* Return the clauses associated with OMP_TASK GS. */
3841 gimple_omp_taskreg_clauses (const_gimple gs)
3843 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3844 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3845 return gs->gimple_omp_parallel.clauses;
3849 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3851 static inline tree *
3852 gimple_omp_taskreg_clauses_ptr (gimple gs)
3854 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3855 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3856 return &gs->gimple_omp_parallel.clauses;
3860 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3864 gimple_omp_taskreg_set_clauses (gimple gs, tree clauses)
3866 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3867 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3868 gs->gimple_omp_parallel.clauses = clauses;
3872 /* Return the child function used to hold the body of OMP_TASK GS. */
3875 gimple_omp_taskreg_child_fn (const_gimple gs)
3877 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3878 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3879 return gs->gimple_omp_parallel.child_fn;
3882 /* Return a pointer to the child function used to hold the body of
3885 static inline tree *
3886 gimple_omp_taskreg_child_fn_ptr (gimple gs)
3888 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3889 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3890 return &gs->gimple_omp_parallel.child_fn;
3894 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3897 gimple_omp_taskreg_set_child_fn (gimple gs, tree child_fn)
3899 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3900 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3901 gs->gimple_omp_parallel.child_fn = child_fn;
3905 /* Return the artificial argument used to send variables and values
3906 from the parent to the children threads in OMP_TASK GS. */
3909 gimple_omp_taskreg_data_arg (const_gimple gs)
3911 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3912 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3913 return gs->gimple_omp_parallel.data_arg;
3917 /* Return a pointer to the data argument for OMP_TASK GS. */
3919 static inline tree *
3920 gimple_omp_taskreg_data_arg_ptr (gimple gs)
3922 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3923 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3924 return &gs->gimple_omp_parallel.data_arg;
3928 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3931 gimple_omp_taskreg_set_data_arg (gimple gs, tree data_arg)
3933 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3934 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3935 gs->gimple_omp_parallel.data_arg = data_arg;
3939 /* Return the copy function used to hold the body of OMP_TASK GS. */
3942 gimple_omp_task_copy_fn (const_gimple gs)
3944 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3945 return gs->gimple_omp_task.copy_fn;
3948 /* Return a pointer to the copy function used to hold the body of
3951 static inline tree *
3952 gimple_omp_task_copy_fn_ptr (gimple gs)
3954 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3955 return &gs->gimple_omp_task.copy_fn;
3959 /* Set CHILD_FN to be the copy function for OMP_TASK GS. */
3962 gimple_omp_task_set_copy_fn (gimple gs, tree copy_fn)
3964 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3965 gs->gimple_omp_task.copy_fn = copy_fn;
3969 /* Return size of the data block in bytes in OMP_TASK GS. */
3972 gimple_omp_task_arg_size (const_gimple gs)
3974 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3975 return gs->gimple_omp_task.arg_size;
3979 /* Return a pointer to the data block size for OMP_TASK GS. */
3981 static inline tree *
3982 gimple_omp_task_arg_size_ptr (gimple gs)
3984 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3985 return &gs->gimple_omp_task.arg_size;
3989 /* Set ARG_SIZE to be the data block size for OMP_TASK GS. */
3992 gimple_omp_task_set_arg_size (gimple gs, tree arg_size)
3994 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3995 gs->gimple_omp_task.arg_size = arg_size;
3999 /* Return align of the data block in bytes in OMP_TASK GS. */
4002 gimple_omp_task_arg_align (const_gimple gs)
4004 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4005 return gs->gimple_omp_task.arg_align;
4009 /* Return a pointer to the data block align for OMP_TASK GS. */
4011 static inline tree *
4012 gimple_omp_task_arg_align_ptr (gimple gs)
4014 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4015 return &gs->gimple_omp_task.arg_align;
4019 /* Set ARG_SIZE to be the data block align for OMP_TASK GS. */
4022 gimple_omp_task_set_arg_align (gimple gs, tree arg_align)
4024 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4025 gs->gimple_omp_task.arg_align = arg_align;
4029 /* Return the clauses associated with OMP_SINGLE GS. */
4032 gimple_omp_single_clauses (const_gimple gs)
4034 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
4035 return gs->gimple_omp_single.clauses;
4039 /* Return a pointer to the clauses associated with OMP_SINGLE GS. */
4041 static inline tree *
4042 gimple_omp_single_clauses_ptr (gimple gs)
4044 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
4045 return &gs->gimple_omp_single.clauses;
4049 /* Set CLAUSES to be the clauses associated with OMP_SINGLE GS. */
4052 gimple_omp_single_set_clauses (gimple gs, tree clauses)
4054 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
4055 gs->gimple_omp_single.clauses = clauses;
4059 /* Return the clauses associated with OMP_SECTIONS GS. */
4062 gimple_omp_sections_clauses (const_gimple gs)
4064 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4065 return gs->gimple_omp_sections.clauses;
4069 /* Return a pointer to the clauses associated with OMP_SECTIONS GS. */
4071 static inline tree *
4072 gimple_omp_sections_clauses_ptr (gimple gs)
4074 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4075 return &gs->gimple_omp_sections.clauses;
4079 /* Set CLAUSES to be the set of clauses associated with OMP_SECTIONS
4083 gimple_omp_sections_set_clauses (gimple gs, tree clauses)
4085 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4086 gs->gimple_omp_sections.clauses = clauses;
4090 /* Return the control variable associated with the GIMPLE_OMP_SECTIONS
4094 gimple_omp_sections_control (const_gimple gs)
4096 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4097 return gs->gimple_omp_sections.control;
4101 /* Return a pointer to the clauses associated with the GIMPLE_OMP_SECTIONS
4104 static inline tree *
4105 gimple_omp_sections_control_ptr (gimple gs)
4107 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4108 return &gs->gimple_omp_sections.control;
4112 /* Set CONTROL to be the set of clauses associated with the
4113 GIMPLE_OMP_SECTIONS in GS. */
4116 gimple_omp_sections_set_control (gimple gs, tree control)
4118 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4119 gs->gimple_omp_sections.control = control;
4123 /* Set COND to be the condition code for OMP_FOR GS. */
4126 gimple_omp_for_set_cond (gimple gs, size_t i, enum tree_code cond)
4128 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4129 gcc_assert (TREE_CODE_CLASS (cond) == tcc_comparison);
4130 gcc_assert (i < gs->gimple_omp_for.collapse);
4131 gs->gimple_omp_for.iter[i].cond = cond;
4135 /* Return the condition code associated with OMP_FOR GS. */
4137 static inline enum tree_code
4138 gimple_omp_for_cond (const_gimple gs, size_t i)
4140 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4141 gcc_assert (i < gs->gimple_omp_for.collapse);
4142 return gs->gimple_omp_for.iter[i].cond;
4146 /* Set the value being stored in an atomic store. */
4149 gimple_omp_atomic_store_set_val (gimple g, tree val)
4151 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4152 g->gimple_omp_atomic_store.val = val;
4156 /* Return the value being stored in an atomic store. */
4159 gimple_omp_atomic_store_val (const_gimple g)
4161 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4162 return g->gimple_omp_atomic_store.val;
4166 /* Return a pointer to the value being stored in an atomic store. */
4168 static inline tree *
4169 gimple_omp_atomic_store_val_ptr (gimple g)
4171 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4172 return &g->gimple_omp_atomic_store.val;
4176 /* Set the LHS of an atomic load. */
4179 gimple_omp_atomic_load_set_lhs (gimple g, tree lhs)
4181 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4182 g->gimple_omp_atomic_load.lhs = lhs;
4186 /* Get the LHS of an atomic load. */
4189 gimple_omp_atomic_load_lhs (const_gimple g)
4191 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4192 return g->gimple_omp_atomic_load.lhs;
4196 /* Return a pointer to the LHS of an atomic load. */
4198 static inline tree *
4199 gimple_omp_atomic_load_lhs_ptr (gimple g)
4201 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4202 return &g->gimple_omp_atomic_load.lhs;
4206 /* Set the RHS of an atomic load. */
4209 gimple_omp_atomic_load_set_rhs (gimple g, tree rhs)
4211 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4212 g->gimple_omp_atomic_load.rhs = rhs;
4216 /* Get the RHS of an atomic load. */
4219 gimple_omp_atomic_load_rhs (const_gimple g)
4221 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4222 return g->gimple_omp_atomic_load.rhs;
4226 /* Return a pointer to the RHS of an atomic load. */
4228 static inline tree *
4229 gimple_omp_atomic_load_rhs_ptr (gimple g)
4231 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4232 return &g->gimple_omp_atomic_load.rhs;
4236 /* Get the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4239 gimple_omp_continue_control_def (const_gimple g)
4241 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4242 return g->gimple_omp_continue.control_def;
4245 /* The same as above, but return the address. */
4247 static inline tree *
4248 gimple_omp_continue_control_def_ptr (gimple g)
4250 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4251 return &g->gimple_omp_continue.control_def;
4254 /* Set the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4257 gimple_omp_continue_set_control_def (gimple g, tree def)
4259 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4260 g->gimple_omp_continue.control_def = def;
4264 /* Get the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4267 gimple_omp_continue_control_use (const_gimple g)
4269 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4270 return g->gimple_omp_continue.control_use;
4274 /* The same as above, but return the address. */
4276 static inline tree *
4277 gimple_omp_continue_control_use_ptr (gimple g)
4279 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4280 return &g->gimple_omp_continue.control_use;
4284 /* Set the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4287 gimple_omp_continue_set_control_use (gimple g, tree use)
4289 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4290 g->gimple_omp_continue.control_use = use;
4294 /* Return a pointer to the return value for GIMPLE_RETURN GS. */
4296 static inline tree *
4297 gimple_return_retval_ptr (const_gimple gs)
4299 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4300 return gimple_op_ptr (gs, 0);
4303 /* Return the return value for GIMPLE_RETURN GS. */
4306 gimple_return_retval (const_gimple gs)
4308 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4309 return gimple_op (gs, 0);
4313 /* Set RETVAL to be the return value for GIMPLE_RETURN GS. */
4316 gimple_return_set_retval (gimple gs, tree retval)
4318 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4319 gimple_set_op (gs, 0, retval);
4323 /* Returns true when the gimple statment STMT is any of the OpenMP types. */
4325 #define CASE_GIMPLE_OMP \
4326 case GIMPLE_OMP_PARALLEL: \
4327 case GIMPLE_OMP_TASK: \
4328 case GIMPLE_OMP_FOR: \
4329 case GIMPLE_OMP_SECTIONS: \
4330 case GIMPLE_OMP_SECTIONS_SWITCH: \
4331 case GIMPLE_OMP_SINGLE: \
4332 case GIMPLE_OMP_SECTION: \
4333 case GIMPLE_OMP_MASTER: \
4334 case GIMPLE_OMP_ORDERED: \
4335 case GIMPLE_OMP_CRITICAL: \
4336 case GIMPLE_OMP_RETURN: \
4337 case GIMPLE_OMP_ATOMIC_LOAD: \
4338 case GIMPLE_OMP_ATOMIC_STORE: \
4339 case GIMPLE_OMP_CONTINUE
4342 is_gimple_omp (const_gimple stmt)
4344 switch (gimple_code (stmt))
4354 /* Returns TRUE if statement G is a GIMPLE_NOP. */
4357 gimple_nop_p (const_gimple g)
4359 return gimple_code (g) == GIMPLE_NOP;
4363 /* Return true if GS is a GIMPLE_RESX. */
4366 is_gimple_resx (const_gimple gs)
4368 return gimple_code (gs) == GIMPLE_RESX;
4371 /* Return the predictor of GIMPLE_PREDICT statement GS. */
4373 static inline enum br_predictor
4374 gimple_predict_predictor (gimple gs)
4376 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4377 return (enum br_predictor) (gs->gsbase.subcode & ~GF_PREDICT_TAKEN);
4381 /* Set the predictor of GIMPLE_PREDICT statement GS to PREDICT. */
4384 gimple_predict_set_predictor (gimple gs, enum br_predictor predictor)
4386 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4387 gs->gsbase.subcode = (gs->gsbase.subcode & GF_PREDICT_TAKEN)
4388 | (unsigned) predictor;
4392 /* Return the outcome of GIMPLE_PREDICT statement GS. */
4394 static inline enum prediction
4395 gimple_predict_outcome (gimple gs)
4397 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4398 return (gs->gsbase.subcode & GF_PREDICT_TAKEN) ? TAKEN : NOT_TAKEN;
4402 /* Set the outcome of GIMPLE_PREDICT statement GS to OUTCOME. */
4405 gimple_predict_set_outcome (gimple gs, enum prediction outcome)
4407 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4408 if (outcome == TAKEN)
4409 gs->gsbase.subcode |= GF_PREDICT_TAKEN;
4411 gs->gsbase.subcode &= ~GF_PREDICT_TAKEN;
4415 /* Return the type of the main expression computed by STMT. Return
4416 void_type_node if the statement computes nothing. */
4419 gimple_expr_type (const_gimple stmt)
4421 enum gimple_code code = gimple_code (stmt);
4423 if (code == GIMPLE_ASSIGN || code == GIMPLE_CALL)
4426 /* In general we want to pass out a type that can be substituted
4427 for both the RHS and the LHS types if there is a possibly
4428 useless conversion involved. That means returning the
4429 original RHS type as far as we can reconstruct it. */
4430 if (code == GIMPLE_CALL)
4431 type = gimple_call_return_type (stmt);
4433 switch (gimple_assign_rhs_code (stmt))
4435 case POINTER_PLUS_EXPR:
4436 type = TREE_TYPE (gimple_assign_rhs1 (stmt));
4440 /* As fallback use the type of the LHS. */
4441 type = TREE_TYPE (gimple_get_lhs (stmt));
4446 else if (code == GIMPLE_COND)
4447 return boolean_type_node;
4449 return void_type_node;
4453 /* Return a new iterator pointing to GIMPLE_SEQ's first statement. */
4455 static inline gimple_stmt_iterator
4456 gsi_start (gimple_seq seq)
4458 gimple_stmt_iterator i;
4460 i.ptr = gimple_seq_first (seq);
4462 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4468 /* Return a new iterator pointing to the first statement in basic block BB. */
4470 static inline gimple_stmt_iterator
4471 gsi_start_bb (basic_block bb)
4473 gimple_stmt_iterator i;
4477 i.ptr = gimple_seq_first (seq);
4485 /* Return a new iterator initially pointing to GIMPLE_SEQ's last statement. */
4487 static inline gimple_stmt_iterator
4488 gsi_last (gimple_seq seq)
4490 gimple_stmt_iterator i;
4492 i.ptr = gimple_seq_last (seq);
4494 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4500 /* Return a new iterator pointing to the last statement in basic block BB. */
4502 static inline gimple_stmt_iterator
4503 gsi_last_bb (basic_block bb)
4505 gimple_stmt_iterator i;
4509 i.ptr = gimple_seq_last (seq);
4517 /* Return true if I is at the end of its sequence. */
4520 gsi_end_p (gimple_stmt_iterator i)
4522 return i.ptr == NULL;
4526 /* Return true if I is one statement before the end of its sequence. */
4529 gsi_one_before_end_p (gimple_stmt_iterator i)
4531 return i.ptr != NULL && i.ptr->next == NULL;
4535 /* Advance the iterator to the next gimple statement. */
4538 gsi_next (gimple_stmt_iterator *i)
4540 i->ptr = i->ptr->next;
4543 /* Advance the iterator to the previous gimple statement. */
4546 gsi_prev (gimple_stmt_iterator *i)
4548 i->ptr = i->ptr->prev;
4551 /* Return the current stmt. */
4553 static inline gimple
4554 gsi_stmt (gimple_stmt_iterator i)
4559 /* Return a block statement iterator that points to the first non-label
4560 statement in block BB. */
4562 static inline gimple_stmt_iterator
4563 gsi_after_labels (basic_block bb)
4565 gimple_stmt_iterator gsi = gsi_start_bb (bb);
4567 while (!gsi_end_p (gsi) && gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL)
4573 /* Advance the iterator to the next non-debug gimple statement. */
4576 gsi_next_nondebug (gimple_stmt_iterator *i)
4582 while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
4585 /* Advance the iterator to the next non-debug gimple statement. */
4588 gsi_prev_nondebug (gimple_stmt_iterator *i)
4594 while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
4597 /* Return a new iterator pointing to the first non-debug statement in
4600 static inline gimple_stmt_iterator
4601 gsi_start_nondebug_bb (basic_block bb)
4603 gimple_stmt_iterator i = gsi_start_bb (bb);
4605 if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
4606 gsi_next_nondebug (&i);
4611 /* Return a new iterator pointing to the last non-debug statement in
4614 static inline gimple_stmt_iterator
4615 gsi_last_nondebug_bb (basic_block bb)
4617 gimple_stmt_iterator i = gsi_last_bb (bb);
4619 if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
4620 gsi_prev_nondebug (&i);
4625 /* Return a pointer to the current stmt.
4627 NOTE: You may want to use gsi_replace on the iterator itself,
4628 as this performs additional bookkeeping that will not be done
4629 if you simply assign through a pointer returned by gsi_stmt_ptr. */
4631 static inline gimple *
4632 gsi_stmt_ptr (gimple_stmt_iterator *i)
4634 return &i->ptr->stmt;
4638 /* Return the basic block associated with this iterator. */
4640 static inline basic_block
4641 gsi_bb (gimple_stmt_iterator i)
4647 /* Return the sequence associated with this iterator. */
4649 static inline gimple_seq
4650 gsi_seq (gimple_stmt_iterator i)
4656 enum gsi_iterator_update
4658 GSI_NEW_STMT, /* Only valid when single statement is added, move
4660 GSI_SAME_STMT, /* Leave the iterator at the same statement. */
4661 GSI_CONTINUE_LINKING /* Move iterator to whatever position is suitable
4662 for linking other statements in the same
4666 /* In gimple-iterator.c */
4667 gimple_stmt_iterator gsi_start_phis (basic_block);
4668 gimple_seq gsi_split_seq_after (gimple_stmt_iterator);
4669 gimple_seq gsi_split_seq_before (gimple_stmt_iterator *);
4670 void gsi_replace (gimple_stmt_iterator *, gimple, bool);
4671 void gsi_insert_before (gimple_stmt_iterator *, gimple,
4672 enum gsi_iterator_update);
4673 void gsi_insert_before_without_update (gimple_stmt_iterator *, gimple,
4674 enum gsi_iterator_update);
4675 void gsi_insert_seq_before (gimple_stmt_iterator *, gimple_seq,
4676 enum gsi_iterator_update);
4677 void gsi_insert_seq_before_without_update (gimple_stmt_iterator *, gimple_seq,
4678 enum gsi_iterator_update);
4679 void gsi_insert_after (gimple_stmt_iterator *, gimple,
4680 enum gsi_iterator_update);
4681 void gsi_insert_after_without_update (gimple_stmt_iterator *, gimple,
4682 enum gsi_iterator_update);
4683 void gsi_insert_seq_after (gimple_stmt_iterator *, gimple_seq,
4684 enum gsi_iterator_update);
4685 void gsi_insert_seq_after_without_update (gimple_stmt_iterator *, gimple_seq,
4686 enum gsi_iterator_update);
4687 void gsi_remove (gimple_stmt_iterator *, bool);
4688 gimple_stmt_iterator gsi_for_stmt (gimple);
4689 void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *);
4690 void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *);
4691 void gsi_move_to_bb_end (gimple_stmt_iterator *, struct basic_block_def *);
4692 void gsi_insert_on_edge (edge, gimple);
4693 void gsi_insert_seq_on_edge (edge, gimple_seq);
4694 basic_block gsi_insert_on_edge_immediate (edge, gimple);
4695 basic_block gsi_insert_seq_on_edge_immediate (edge, gimple_seq);
4696 void gsi_commit_one_edge_insert (edge, basic_block *);
4697 void gsi_commit_edge_inserts (void);
4698 gimple gimple_call_copy_skip_args (gimple, bitmap);
4701 /* Convenience routines to walk all statements of a gimple function.
4702 Note that this is useful exclusively before the code is converted
4703 into SSA form. Once the program is in SSA form, the standard
4704 operand interface should be used to analyze/modify statements. */
4705 struct walk_stmt_info
4707 /* Points to the current statement being walked. */
4708 gimple_stmt_iterator gsi;
4710 /* Additional data that the callback functions may want to carry
4711 through the recursion. */
4714 /* Pointer map used to mark visited tree nodes when calling
4715 walk_tree on each operand. If set to NULL, duplicate tree nodes
4716 will be visited more than once. */
4717 struct pointer_set_t *pset;
4719 /* Indicates whether the operand being examined may be replaced
4720 with something that matches is_gimple_val (if true) or something
4721 slightly more complicated (if false). "Something" technically
4722 means the common subset of is_gimple_lvalue and is_gimple_rhs,
4723 but we never try to form anything more complicated than that, so
4724 we don't bother checking.
4726 Also note that CALLBACK should update this flag while walking the
4727 sub-expressions of a statement. For instance, when walking the
4728 statement 'foo (&var)', the flag VAL_ONLY will initially be set
4729 to true, however, when walking &var, the operand of that
4730 ADDR_EXPR does not need to be a GIMPLE value. */
4733 /* True if we are currently walking the LHS of an assignment. */
4736 /* Optional. Set to true by the callback functions if they made any
4740 /* True if we're interested in location information. */
4741 bool want_locations;
4743 /* Operand returned by the callbacks. This is set when calling
4744 walk_gimple_seq. If the walk_stmt_fn or walk_tree_fn callback
4745 returns non-NULL, this field will contain the tree returned by
4746 the last callback. */
4747 tree callback_result;
4750 /* Callback for walk_gimple_stmt. Called for every statement found
4751 during traversal. The first argument points to the statement to
4752 walk. The second argument is a flag that the callback sets to
4753 'true' if it the callback handled all the operands and
4754 sub-statements of the statement (the default value of this flag is
4755 'false'). The third argument is an anonymous pointer to data
4756 to be used by the callback. */
4757 typedef tree (*walk_stmt_fn) (gimple_stmt_iterator *, bool *,
4758 struct walk_stmt_info *);
4760 gimple walk_gimple_seq (gimple_seq, walk_stmt_fn, walk_tree_fn,
4761 struct walk_stmt_info *);
4762 tree walk_gimple_stmt (gimple_stmt_iterator *, walk_stmt_fn, walk_tree_fn,
4763 struct walk_stmt_info *);
4764 tree walk_gimple_op (gimple, walk_tree_fn, struct walk_stmt_info *);
4766 #ifdef GATHER_STATISTICS
4767 /* Enum and arrays used for allocation stats. Keep in sync with
4768 gimple.c:gimple_alloc_kind_names. */
4769 enum gimple_alloc_kind
4771 gimple_alloc_kind_assign, /* Assignments. */
4772 gimple_alloc_kind_phi, /* PHI nodes. */
4773 gimple_alloc_kind_cond, /* Conditionals. */
4774 gimple_alloc_kind_seq, /* Sequences. */
4775 gimple_alloc_kind_rest, /* Everything else. */
4776 gimple_alloc_kind_all
4779 extern int gimple_alloc_counts[];
4780 extern int gimple_alloc_sizes[];
4782 /* Return the allocation kind for a given stmt CODE. */
4783 static inline enum gimple_alloc_kind
4784 gimple_alloc_kind (enum gimple_code code)
4789 return gimple_alloc_kind_assign;
4791 return gimple_alloc_kind_phi;
4793 return gimple_alloc_kind_cond;
4795 return gimple_alloc_kind_rest;
4798 #endif /* GATHER_STATISTICS */
4800 extern void dump_gimple_statistics (void);
4802 /* In gimple-fold.c. */
4803 void gimplify_and_update_call_from_tree (gimple_stmt_iterator *, tree);
4804 tree gimple_fold_builtin (gimple);
4805 bool fold_stmt (gimple_stmt_iterator *);
4806 bool fold_stmt_inplace (gimple);
4807 tree maybe_fold_offset_to_reference (location_t, tree, tree, tree);
4808 tree maybe_fold_offset_to_address (location_t, tree, tree, tree);
4809 tree maybe_fold_stmt_addition (location_t, tree, tree, tree);
4810 tree get_symbol_constant_value (tree);
4811 bool may_propagate_address_into_dereference (tree, tree);
4814 #endif /* GCC_GIMPLE_H */