1 /* Gimple IR definitions.
3 Copyright 2007, 2008, 2009 Free Software Foundation, Inc.
4 Contributed by Aldy Hernandez <aldyh@redhat.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
25 #include "pointer-set.h"
29 #include "hard-reg-set.h"
30 #include "basic-block.h"
31 #include "tree-ssa-operands.h"
34 DEF_VEC_ALLOC_P(gimple
,heap
);
35 DEF_VEC_ALLOC_P(gimple
,gc
);
37 typedef gimple
*gimple_p
;
39 DEF_VEC_ALLOC_P(gimple_p
,heap
);
41 DEF_VEC_P(gimple_seq
);
42 DEF_VEC_ALLOC_P(gimple_seq
,gc
);
43 DEF_VEC_ALLOC_P(gimple_seq
,heap
);
45 /* For each block, the PHI nodes that need to be rewritten are stored into
47 typedef VEC(gimple
, heap
) *gimple_vec
;
48 DEF_VEC_P (gimple_vec
);
49 DEF_VEC_ALLOC_P (gimple_vec
, heap
);
52 #define DEFGSCODE(SYM, STRING, STRUCT) SYM,
55 LAST_AND_UNUSED_GIMPLE_CODE
58 extern const char *const gimple_code_name
[];
59 extern const unsigned char gimple_rhs_class_table
[];
61 /* Error out if a gimple tuple is addressed incorrectly. */
62 #if defined ENABLE_GIMPLE_CHECKING
63 extern void gimple_check_failed (const_gimple
, const char *, int, \
64 const char *, enum gimple_code
, \
65 enum tree_code
) ATTRIBUTE_NORETURN
;
67 #define GIMPLE_CHECK(GS, CODE) \
69 const_gimple __gs = (GS); \
70 if (gimple_code (__gs) != (CODE)) \
71 gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__, \
72 (CODE), ERROR_MARK); \
74 #else /* not ENABLE_GIMPLE_CHECKING */
75 #define GIMPLE_CHECK(GS, CODE) (void)0
78 /* Class of GIMPLE expressions suitable for the RHS of assignments. See
79 get_gimple_rhs_class. */
82 GIMPLE_INVALID_RHS
, /* The expression cannot be used on the RHS. */
83 GIMPLE_BINARY_RHS
, /* The expression is a binary operation. */
84 GIMPLE_UNARY_RHS
, /* The expression is a unary operation. */
85 GIMPLE_SINGLE_RHS
/* The expression is a single object (an SSA
86 name, a _DECL, a _REF, etc. */
89 /* Specific flags for individual GIMPLE statements. These flags are
90 always stored in gimple_statement_base.subcode and they may only be
91 defined for statement codes that do not use sub-codes.
93 Values for the masks can overlap as long as the overlapping values
94 are never used in the same statement class.
96 The maximum mask value that can be defined is 1 << 15 (i.e., each
97 statement code can hold up to 16 bitflags).
99 Keep this list sorted. */
101 GF_ASM_INPUT
= 1 << 0,
102 GF_ASM_VOLATILE
= 1 << 1,
103 GF_CALL_CANNOT_INLINE
= 1 << 0,
104 GF_CALL_FROM_THUNK
= 1 << 1,
105 GF_CALL_RETURN_SLOT_OPT
= 1 << 2,
106 GF_CALL_TAILCALL
= 1 << 3,
107 GF_CALL_VA_ARG_PACK
= 1 << 4,
108 GF_OMP_PARALLEL_COMBINED
= 1 << 0,
110 /* True on an GIMPLE_OMP_RETURN statement if the return does not require
111 a thread synchronization via some sort of barrier. The exact barrier
112 that would otherwise be emitted is dependent on the OMP statement with
113 which this return is associated. */
114 GF_OMP_RETURN_NOWAIT
= 1 << 0,
116 GF_OMP_SECTION_LAST
= 1 << 0,
117 GF_PREDICT_TAKEN
= 1 << 15
120 /* Masks for selecting a pass local flag (PLF) to work on. These
121 masks are used by gimple_set_plf and gimple_plf. */
127 /* A node in a gimple_seq_d. */
128 struct GTY((chain_next ("%h.next"), chain_prev ("%h.prev"))) gimple_seq_node_d
{
130 struct gimple_seq_node_d
*prev
;
131 struct gimple_seq_node_d
*next
;
134 /* A double-linked sequence of gimple statements. */
135 struct GTY ((chain_next ("%h.next_free"))) gimple_seq_d
{
136 /* First and last statements in the sequence. */
137 gimple_seq_node first
;
138 gimple_seq_node last
;
140 /* Sequences are created/destroyed frequently. To minimize
141 allocation activity, deallocated sequences are kept in a pool of
142 available sequences. This is the pointer to the next free
143 sequence in the pool. */
144 gimple_seq next_free
;
148 /* Return the first node in GIMPLE sequence S. */
150 static inline gimple_seq_node
151 gimple_seq_first (const_gimple_seq s
)
153 return s
? s
->first
: NULL
;
157 /* Return the first statement in GIMPLE sequence S. */
160 gimple_seq_first_stmt (const_gimple_seq s
)
162 gimple_seq_node n
= gimple_seq_first (s
);
163 return (n
) ? n
->stmt
: NULL
;
167 /* Return the last node in GIMPLE sequence S. */
169 static inline gimple_seq_node
170 gimple_seq_last (const_gimple_seq s
)
172 return s
? s
->last
: NULL
;
176 /* Return the last statement in GIMPLE sequence S. */
179 gimple_seq_last_stmt (const_gimple_seq s
)
181 gimple_seq_node n
= gimple_seq_last (s
);
182 return (n
) ? n
->stmt
: NULL
;
186 /* Set the last node in GIMPLE sequence S to LAST. */
189 gimple_seq_set_last (gimple_seq s
, gimple_seq_node last
)
195 /* Set the first node in GIMPLE sequence S to FIRST. */
198 gimple_seq_set_first (gimple_seq s
, gimple_seq_node first
)
204 /* Return true if GIMPLE sequence S is empty. */
207 gimple_seq_empty_p (const_gimple_seq s
)
209 return s
== NULL
|| s
->first
== NULL
;
213 void gimple_seq_add_stmt (gimple_seq
*, gimple
);
215 /* Allocate a new sequence and initialize its first element with STMT. */
217 static inline gimple_seq
218 gimple_seq_alloc_with_stmt (gimple stmt
)
220 gimple_seq seq
= NULL
;
221 gimple_seq_add_stmt (&seq
, stmt
);
226 /* Returns the sequence of statements in BB. */
228 static inline gimple_seq
229 bb_seq (const_basic_block bb
)
231 return (!(bb
->flags
& BB_RTL
) && bb
->il
.gimple
) ? bb
->il
.gimple
->seq
: NULL
;
235 /* Sets the sequence of statements in BB to SEQ. */
238 set_bb_seq (basic_block bb
, gimple_seq seq
)
240 gcc_assert (!(bb
->flags
& BB_RTL
));
241 bb
->il
.gimple
->seq
= seq
;
244 /* Iterator object for GIMPLE statement sequences. */
248 /* Sequence node holding the current statement. */
251 /* Sequence and basic block holding the statement. These fields
252 are necessary to handle edge cases such as when statement is
253 added to an empty basic block or when the last statement of a
254 block/sequence is removed. */
257 } gimple_stmt_iterator
;
260 /* Data structure definitions for GIMPLE tuples. NOTE: word markers
261 are for 64 bit hosts. */
263 struct GTY(()) gimple_statement_base
{
265 Main identifying code for a tuple. */
266 ENUM_BITFIELD(gimple_code
) code
: 8;
268 /* Nonzero if a warning should not be emitted on this tuple. */
269 unsigned int no_warning
: 1;
271 /* Nonzero if this tuple has been visited. Passes are responsible
272 for clearing this bit before using it. */
273 unsigned int visited
: 1;
275 /* Nonzero if this tuple represents a non-temporal move. */
276 unsigned int nontemporal_move
: 1;
278 /* Pass local flags. These flags are free for any pass to use as
279 they see fit. Passes should not assume that these flags contain
280 any useful value when the pass starts. Any initial state that
281 the pass requires should be set on entry to the pass. See
282 gimple_set_plf and gimple_plf for usage. */
283 unsigned int plf
: 2;
285 /* Nonzero if this statement has been modified and needs to have its
286 operands rescanned. */
287 unsigned modified
: 1;
289 /* Nonzero if this statement contains volatile operands. */
290 unsigned has_volatile_ops
: 1;
292 /* Padding to get subcode to 16 bit alignment. */
295 /* The SUBCODE field can be used for tuple-specific flags for tuples
296 that do not require subcodes. Note that SUBCODE should be at
297 least as wide as tree codes, as several tuples store tree codes
299 unsigned int subcode
: 16;
301 /* UID of this statement. This is used by passes that want to
302 assign IDs to statements. It must be assigned and used by each
303 pass. By default it should be assumed to contain garbage. */
307 Locus information for debug info. */
310 /* Number of operands in this tuple. */
314 Basic block holding this statement. */
315 struct basic_block_def
*bb
;
318 Lexical block holding this statement. */
323 /* Base structure for tuples with operands. */
325 struct GTY(()) gimple_statement_with_ops_base
328 struct gimple_statement_base gsbase
;
331 SSA operand vectors. NOTE: It should be possible to
332 amalgamate these vectors with the operand vector OP. However,
333 the SSA operand vectors are organized differently and contain
334 more information (like immediate use chaining). */
335 struct def_optype_d
GTY((skip (""))) *def_ops
;
336 struct use_optype_d
GTY((skip (""))) *use_ops
;
340 /* Statements that take register operands. */
342 struct GTY(()) gimple_statement_with_ops
345 struct gimple_statement_with_ops_base opbase
;
348 Operand vector. NOTE! This must always be the last field
349 of this structure. In particular, this means that this
350 structure cannot be embedded inside another one. */
351 tree
GTY((length ("%h.opbase.gsbase.num_ops"))) op
[1];
355 /* Base for statements that take both memory and register operands. */
357 struct GTY(()) gimple_statement_with_memory_ops_base
360 struct gimple_statement_with_ops_base opbase
;
363 Virtual operands for this statement. The GC will pick them
364 up via the ssa_names array. */
365 tree
GTY((skip (""))) vdef
;
366 tree
GTY((skip (""))) vuse
;
370 /* Statements that take both memory and register operands. */
372 struct GTY(()) gimple_statement_with_memory_ops
375 struct gimple_statement_with_memory_ops_base membase
;
378 Operand vector. NOTE! This must always be the last field
379 of this structure. In particular, this means that this
380 structure cannot be embedded inside another one. */
381 tree
GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op
[1];
385 /* OpenMP statements (#pragma omp). */
387 struct GTY(()) gimple_statement_omp
{
389 struct gimple_statement_base gsbase
;
398 struct GTY(()) gimple_statement_bind
{
400 struct gimple_statement_base gsbase
;
403 Variables declared in this scope. */
407 This is different than the BLOCK field in gimple_statement_base,
408 which is analogous to TREE_BLOCK (i.e., the lexical block holding
409 this statement). This field is the equivalent of BIND_EXPR_BLOCK
410 in tree land (i.e., the lexical scope defined by this bind). See
421 struct GTY(()) gimple_statement_catch
{
423 struct gimple_statement_base gsbase
;
433 /* GIMPLE_EH_FILTER */
435 struct GTY(()) gimple_statement_eh_filter
{
437 struct gimple_statement_base gsbase
;
439 /* Subcode: EH_FILTER_MUST_NOT_THROW. A boolean flag analogous to
440 the tree counterpart. */
454 struct GTY(()) gimple_statement_phi
{
456 struct gimple_statement_base gsbase
;
466 struct phi_arg_d
GTY ((length ("%h.nargs"))) args
[1];
472 struct GTY(()) gimple_statement_resx
{
474 struct gimple_statement_base gsbase
;
477 Exception region number. */
484 struct GTY(()) gimple_statement_try
{
486 struct gimple_statement_base gsbase
;
489 Expression to evaluate. */
493 Cleanup expression. */
497 /* Kind of GIMPLE_TRY statements. */
498 enum gimple_try_flags
501 GIMPLE_TRY_CATCH
= 1 << 0,
504 GIMPLE_TRY_FINALLY
= 1 << 1,
505 GIMPLE_TRY_KIND
= GIMPLE_TRY_CATCH
| GIMPLE_TRY_FINALLY
,
507 /* Analogous to TRY_CATCH_IS_CLEANUP. */
508 GIMPLE_TRY_CATCH_IS_CLEANUP
= 1 << 2
511 /* GIMPLE_WITH_CLEANUP_EXPR */
513 struct GTY(()) gimple_statement_wce
{
515 struct gimple_statement_base gsbase
;
517 /* Subcode: CLEANUP_EH_ONLY. True if the cleanup should only be
518 executed if an exception is thrown, not on normal exit of its
519 scope. This flag is analogous to the CLEANUP_EH_ONLY flag
523 Cleanup expression. */
530 struct GTY(()) gimple_statement_asm
533 struct gimple_statement_with_memory_ops_base membase
;
536 __asm__ statement. */
540 Number of inputs, outputs and clobbers. */
546 Operand vector. NOTE! This must always be the last field
547 of this structure. In particular, this means that this
548 structure cannot be embedded inside another one. */
549 tree
GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op
[1];
552 /* GIMPLE_OMP_CRITICAL */
554 struct GTY(()) gimple_statement_omp_critical
{
556 struct gimple_statement_omp omp
;
559 Critical section name. */
564 struct GTY(()) gimple_omp_for_iter
{
565 /* Condition code. */
568 /* Index variable. */
583 struct GTY(()) gimple_statement_omp_for
{
585 struct gimple_statement_omp omp
;
591 Number of elements in iter array. */
595 struct gimple_omp_for_iter
* GTY((length ("%h.collapse"))) iter
;
598 Pre-body evaluated before the loop body begins. */
603 /* GIMPLE_OMP_PARALLEL */
605 struct GTY(()) gimple_statement_omp_parallel
{
607 struct gimple_statement_omp omp
;
614 Child function holding the body of the parallel region. */
618 Shared data argument. */
623 /* GIMPLE_OMP_TASK */
625 struct GTY(()) gimple_statement_omp_task
{
627 struct gimple_statement_omp_parallel par
;
630 Child function holding firstprivate initialization if needed. */
634 Size and alignment in bytes of the argument data block. */
640 /* GIMPLE_OMP_SECTION */
641 /* Uses struct gimple_statement_omp. */
644 /* GIMPLE_OMP_SECTIONS */
646 struct GTY(()) gimple_statement_omp_sections
{
648 struct gimple_statement_omp omp
;
654 The control variable used for deciding which of the sections to
659 /* GIMPLE_OMP_CONTINUE.
661 Note: This does not inherit from gimple_statement_omp, because we
662 do not need the body field. */
664 struct GTY(()) gimple_statement_omp_continue
{
666 struct gimple_statement_base gsbase
;
675 /* GIMPLE_OMP_SINGLE */
677 struct GTY(()) gimple_statement_omp_single
{
679 struct gimple_statement_omp omp
;
686 /* GIMPLE_OMP_ATOMIC_LOAD.
687 Note: This is based on gimple_statement_base, not g_s_omp, because g_s_omp
688 contains a sequence, which we don't need here. */
690 struct GTY(()) gimple_statement_omp_atomic_load
{
692 struct gimple_statement_base gsbase
;
698 /* GIMPLE_OMP_ATOMIC_STORE.
699 See note on GIMPLE_OMP_ATOMIC_LOAD. */
701 struct GTY(()) gimple_statement_omp_atomic_store
{
703 struct gimple_statement_base gsbase
;
709 enum gimple_statement_structure_enum
{
710 #define DEFGSSTRUCT(SYM, STRING) SYM,
711 #include "gsstruct.def"
717 /* Define the overall contents of a gimple tuple. It may be any of the
718 structures declared above for various types of tuples. */
720 union GTY ((desc ("gimple_statement_structure (&%h)"))) gimple_statement_d
{
721 struct gimple_statement_base
GTY ((tag ("GSS_BASE"))) gsbase
;
722 struct gimple_statement_with_ops
GTY ((tag ("GSS_WITH_OPS"))) gsops
;
723 struct gimple_statement_with_memory_ops
GTY ((tag ("GSS_WITH_MEM_OPS"))) gsmem
;
724 struct gimple_statement_omp
GTY ((tag ("GSS_OMP"))) omp
;
725 struct gimple_statement_bind
GTY ((tag ("GSS_BIND"))) gimple_bind
;
726 struct gimple_statement_catch
GTY ((tag ("GSS_CATCH"))) gimple_catch
;
727 struct gimple_statement_eh_filter
GTY ((tag ("GSS_EH_FILTER"))) gimple_eh_filter
;
728 struct gimple_statement_phi
GTY ((tag ("GSS_PHI"))) gimple_phi
;
729 struct gimple_statement_resx
GTY ((tag ("GSS_RESX"))) gimple_resx
;
730 struct gimple_statement_try
GTY ((tag ("GSS_TRY"))) gimple_try
;
731 struct gimple_statement_wce
GTY ((tag ("GSS_WCE"))) gimple_wce
;
732 struct gimple_statement_asm
GTY ((tag ("GSS_ASM"))) gimple_asm
;
733 struct gimple_statement_omp_critical
GTY ((tag ("GSS_OMP_CRITICAL"))) gimple_omp_critical
;
734 struct gimple_statement_omp_for
GTY ((tag ("GSS_OMP_FOR"))) gimple_omp_for
;
735 struct gimple_statement_omp_parallel
GTY ((tag ("GSS_OMP_PARALLEL"))) gimple_omp_parallel
;
736 struct gimple_statement_omp_task
GTY ((tag ("GSS_OMP_TASK"))) gimple_omp_task
;
737 struct gimple_statement_omp_sections
GTY ((tag ("GSS_OMP_SECTIONS"))) gimple_omp_sections
;
738 struct gimple_statement_omp_single
GTY ((tag ("GSS_OMP_SINGLE"))) gimple_omp_single
;
739 struct gimple_statement_omp_continue
GTY ((tag ("GSS_OMP_CONTINUE"))) gimple_omp_continue
;
740 struct gimple_statement_omp_atomic_load
GTY ((tag ("GSS_OMP_ATOMIC_LOAD"))) gimple_omp_atomic_load
;
741 struct gimple_statement_omp_atomic_store
GTY ((tag ("GSS_OMP_ATOMIC_STORE"))) gimple_omp_atomic_store
;
745 gimple
gimple_build_return (tree
);
747 gimple
gimple_build_assign_stat (tree
, tree MEM_STAT_DECL
);
748 #define gimple_build_assign(l,r) gimple_build_assign_stat (l, r MEM_STAT_INFO)
750 void extract_ops_from_tree (tree
, enum tree_code
*, tree
*, tree
*);
752 gimple
gimple_build_assign_with_ops_stat (enum tree_code
, tree
, tree
,
754 #define gimple_build_assign_with_ops(c,o1,o2,o3) \
755 gimple_build_assign_with_ops_stat (c, o1, o2, o3 MEM_STAT_INFO)
757 gimple
gimple_build_call_vec (tree
, VEC(tree
, heap
) *);
758 gimple
gimple_build_call (tree
, unsigned, ...);
759 gimple
gimple_build_call_from_tree (tree
);
760 gimple
gimplify_assign (tree
, tree
, gimple_seq
*);
761 gimple
gimple_build_cond (enum tree_code
, tree
, tree
, tree
, tree
);
762 gimple
gimple_build_label (tree label
);
763 gimple
gimple_build_goto (tree dest
);
764 gimple
gimple_build_nop (void);
765 gimple
gimple_build_bind (tree
, gimple_seq
, tree
);
766 gimple
gimple_build_asm (const char *, unsigned, unsigned, unsigned, ...);
767 gimple
gimple_build_asm_vec (const char *, VEC(tree
,gc
) *, VEC(tree
,gc
) *,
769 gimple
gimple_build_catch (tree
, gimple_seq
);
770 gimple
gimple_build_eh_filter (tree
, gimple_seq
);
771 gimple
gimple_build_try (gimple_seq
, gimple_seq
, enum gimple_try_flags
);
772 gimple
gimple_build_wce (gimple_seq
);
773 gimple
gimple_build_resx (int);
774 gimple
gimple_build_switch (unsigned, tree
, tree
, ...);
775 gimple
gimple_build_switch_vec (tree
, tree
, VEC(tree
,heap
) *);
776 gimple
gimple_build_omp_parallel (gimple_seq
, tree
, tree
, tree
);
777 gimple
gimple_build_omp_task (gimple_seq
, tree
, tree
, tree
, tree
, tree
, tree
);
778 gimple
gimple_build_omp_for (gimple_seq
, tree
, size_t, gimple_seq
);
779 gimple
gimple_build_omp_critical (gimple_seq
, tree
);
780 gimple
gimple_build_omp_section (gimple_seq
);
781 gimple
gimple_build_omp_continue (tree
, tree
);
782 gimple
gimple_build_omp_master (gimple_seq
);
783 gimple
gimple_build_omp_return (bool);
784 gimple
gimple_build_omp_ordered (gimple_seq
);
785 gimple
gimple_build_omp_sections (gimple_seq
, tree
);
786 gimple
gimple_build_omp_sections_switch (void);
787 gimple
gimple_build_omp_single (gimple_seq
, tree
);
788 gimple
gimple_build_cdt (tree
, tree
);
789 gimple
gimple_build_omp_atomic_load (tree
, tree
);
790 gimple
gimple_build_omp_atomic_store (tree
);
791 gimple
gimple_build_predict (enum br_predictor
, enum prediction
);
792 enum gimple_statement_structure_enum
gimple_statement_structure (gimple
);
793 enum gimple_statement_structure_enum
gss_for_assign (enum tree_code
);
794 void sort_case_labels (VEC(tree
,heap
) *);
795 void gimple_set_body (tree
, gimple_seq
);
796 gimple_seq
gimple_body (tree
);
797 bool gimple_has_body_p (tree
);
798 gimple_seq
gimple_seq_alloc (void);
799 void gimple_seq_free (gimple_seq
);
800 void gimple_seq_add_seq (gimple_seq
*, gimple_seq
);
801 gimple_seq
gimple_seq_copy (gimple_seq
);
802 int gimple_call_flags (const_gimple
);
803 bool gimple_assign_copy_p (gimple
);
804 bool gimple_assign_ssa_name_copy_p (gimple
);
805 bool gimple_assign_single_p (gimple
);
806 bool gimple_assign_unary_nop_p (gimple
);
807 void gimple_set_bb (gimple
, struct basic_block_def
*);
808 tree
gimple_fold (const_gimple
);
809 void gimple_assign_set_rhs_from_tree (gimple_stmt_iterator
*, tree
);
810 void gimple_assign_set_rhs_with_ops (gimple_stmt_iterator
*, enum tree_code
,
812 tree
gimple_get_lhs (const_gimple
);
813 void gimple_set_lhs (gimple
, tree
);
814 gimple
gimple_copy (gimple
);
815 bool is_gimple_operand (const_tree
);
816 void gimple_set_modified (gimple
, bool);
817 void gimple_cond_get_ops_from_tree (tree
, enum tree_code
*, tree
*, tree
*);
818 gimple
gimple_build_cond_from_tree (tree
, tree
, tree
);
819 void gimple_cond_set_condition_from_tree (gimple
, tree
);
820 bool gimple_has_side_effects (const_gimple
);
821 bool gimple_rhs_has_side_effects (const_gimple
);
822 bool gimple_could_trap_p (gimple
);
823 bool gimple_assign_rhs_could_trap_p (gimple
);
824 void gimple_regimplify_operands (gimple
, gimple_stmt_iterator
*);
825 bool empty_body_p (gimple_seq
);
826 unsigned get_gimple_rhs_num_ops (enum tree_code
);
828 /* Returns true iff T is a valid GIMPLE statement. */
829 extern bool is_gimple_stmt (tree
);
831 /* Returns true iff TYPE is a valid type for a scalar register variable. */
832 extern bool is_gimple_reg_type (tree
);
833 /* Returns true iff T is a scalar register variable. */
834 extern bool is_gimple_reg (tree
);
835 /* Returns true iff T is any sort of variable. */
836 extern bool is_gimple_variable (tree
);
837 /* Returns true iff T is any sort of symbol. */
838 extern bool is_gimple_id (tree
);
839 /* Returns true iff T is a variable or an INDIRECT_REF (of a variable). */
840 extern bool is_gimple_min_lval (tree
);
841 /* Returns true iff T is something whose address can be taken. */
842 extern bool is_gimple_addressable (tree
);
843 /* Returns true iff T is any valid GIMPLE lvalue. */
844 extern bool is_gimple_lvalue (tree
);
846 /* Returns true iff T is a GIMPLE address. */
847 bool is_gimple_address (const_tree
);
848 /* Returns true iff T is a GIMPLE invariant address. */
849 bool is_gimple_invariant_address (const_tree
);
850 /* Returns true iff T is a GIMPLE invariant address at interprocedural
852 bool is_gimple_ip_invariant_address (const_tree
);
853 /* Returns true iff T is a valid GIMPLE constant. */
854 bool is_gimple_constant (const_tree
);
855 /* Returns true iff T is a GIMPLE restricted function invariant. */
856 extern bool is_gimple_min_invariant (const_tree
);
857 /* Returns true iff T is a GIMPLE restricted interprecodural invariant. */
858 extern bool is_gimple_ip_invariant (const_tree
);
859 /* Returns true iff T is a GIMPLE rvalue. */
860 extern bool is_gimple_val (tree
);
861 /* Returns true iff T is a GIMPLE asm statement input. */
862 extern bool is_gimple_asm_val (tree
);
863 /* Returns true iff T is a valid rhs for a MODIFY_EXPR where the LHS is a
864 GIMPLE temporary, a renamed user variable, or something else,
866 extern bool is_gimple_reg_rhs (tree
);
867 extern bool is_gimple_mem_rhs (tree
);
869 /* Returns true iff T is a valid if-statement condition. */
870 extern bool is_gimple_condexpr (tree
);
872 /* Returns true iff T is a type conversion. */
873 extern bool is_gimple_cast (tree
);
874 /* Returns true iff T is a variable that does not need to live in memory. */
875 extern bool is_gimple_non_addressable (tree t
);
877 /* Returns true iff T is a valid call address expression. */
878 extern bool is_gimple_call_addr (tree
);
879 /* If T makes a function call, returns the CALL_EXPR operand. */
880 extern tree
get_call_expr_in (tree t
);
882 extern void recalculate_side_effects (tree
);
883 extern void count_uses_and_derefs (tree
, gimple
, unsigned *, unsigned *,
885 extern bool walk_stmt_load_store_addr_ops (gimple
, void *,
886 bool (*)(gimple
, tree
, void *),
887 bool (*)(gimple
, tree
, void *),
888 bool (*)(gimple
, tree
, void *));
889 extern bool walk_stmt_load_store_ops (gimple
, void *,
890 bool (*)(gimple
, tree
, void *),
891 bool (*)(gimple
, tree
, void *));
892 extern bool gimple_ior_addresses_taken (bitmap
, gimple
);
895 extern tree
create_tmp_var_raw (tree
, const char *);
896 extern tree
create_tmp_var_name (const char *);
897 extern tree
create_tmp_var (tree
, const char *);
898 extern tree
get_initialized_tmp_var (tree
, gimple_seq
*, gimple_seq
*);
899 extern tree
get_formal_tmp_var (tree
, gimple_seq
*);
900 extern void declare_vars (tree
, gimple
, bool);
901 extern void tree_annotate_all_with_location (tree
*, location_t
);
902 extern void annotate_all_with_location (gimple_seq
, location_t
);
904 /* Validation of GIMPLE expressions. Note that these predicates only check
905 the basic form of the expression, they don't recurse to make sure that
906 underlying nodes are also of the right form. */
907 typedef bool (*gimple_predicate
)(tree
);
910 /* FIXME we should deduce this from the predicate. */
912 fb_none
= 0, /* Do not generate a temporary. */
914 fb_rvalue
= 1, /* Generate an rvalue to hold the result of a
915 gimplified expression. */
917 fb_lvalue
= 2, /* Generate an lvalue to hold the result of a
918 gimplified expression. */
920 fb_mayfail
= 4, /* Gimplification may fail. Error issued
922 fb_either
= fb_rvalue
| fb_lvalue
925 typedef int fallback_t
;
927 enum gimplify_status
{
928 GS_ERROR
= -2, /* Something Bad Seen. */
929 GS_UNHANDLED
= -1, /* A langhook result for "I dunno". */
930 GS_OK
= 0, /* We did something, maybe more to do. */
931 GS_ALL_DONE
= 1 /* The expression is fully gimplified. */
936 struct gimplify_ctx
*prev_context
;
938 VEC(gimple
,heap
) *bind_expr_stack
;
940 gimple_seq conditional_cleanups
;
944 VEC(tree
,heap
) *case_labels
;
945 /* The formal temporary table. Should this be persistent? */
951 bool allow_rhs_cond_expr
;
954 extern enum gimplify_status
gimplify_expr (tree
*, gimple_seq
*, gimple_seq
*,
955 bool (*) (tree
), fallback_t
);
956 extern void gimplify_type_sizes (tree
, gimple_seq
*);
957 extern void gimplify_one_sizepos (tree
*, gimple_seq
*);
958 extern bool gimplify_stmt (tree
*, gimple_seq
*);
959 extern gimple
gimplify_body (tree
*, tree
, bool);
960 extern void push_gimplify_context (struct gimplify_ctx
*);
961 extern void pop_gimplify_context (gimple
);
962 extern void gimplify_and_add (tree
, gimple_seq
*);
964 /* Miscellaneous helpers. */
965 extern void gimple_add_tmp_var (tree
);
966 extern gimple
gimple_current_bind_expr (void);
967 extern VEC(gimple
, heap
) *gimple_bind_expr_stack (void);
968 extern tree
voidify_wrapper_expr (tree
, tree
);
969 extern tree
build_and_jump (tree
*);
970 extern tree
alloc_stmt_list (void);
971 extern void free_stmt_list (tree
);
972 extern tree
force_labels_r (tree
*, int *, void *);
973 extern enum gimplify_status
gimplify_va_arg_expr (tree
*, gimple_seq
*,
975 struct gimplify_omp_ctx
;
976 extern void omp_firstprivatize_variable (struct gimplify_omp_ctx
*, tree
);
977 extern tree
gimple_boolify (tree
);
978 extern gimple_predicate
rhs_predicate_for (tree
);
979 extern tree
canonicalize_cond_expr_cond (tree
);
982 extern void diagnose_omp_structured_block_errors (tree
);
983 extern tree
omp_reduction_init (tree
, tree
);
985 /* In tree-nested.c. */
986 extern void lower_nested_functions (tree
);
987 extern void insert_field_into_struct (tree
, tree
);
990 extern void gimplify_function_tree (tree
);
992 /* In cfgexpand.c. */
993 extern tree
gimple_assign_rhs_to_tree (gimple
);
996 extern bool validate_gimple_arglist (const_gimple
, ...);
999 extern bool tree_ssa_useless_type_conversion (tree
);
1000 extern tree
tree_ssa_strip_useless_type_conversions (tree
);
1001 extern bool useless_type_conversion_p (tree
, tree
);
1002 extern bool types_compatible_p (tree
, tree
);
1004 /* Return the code for GIMPLE statement G. */
1006 static inline enum gimple_code
1007 gimple_code (const_gimple g
)
1009 return g
->gsbase
.code
;
1013 /* Return true if statement G has sub-statements. This is only true for
1014 High GIMPLE statements. */
1017 gimple_has_substatements (gimple g
)
1019 switch (gimple_code (g
))
1023 case GIMPLE_EH_FILTER
:
1025 case GIMPLE_OMP_FOR
:
1026 case GIMPLE_OMP_MASTER
:
1027 case GIMPLE_OMP_ORDERED
:
1028 case GIMPLE_OMP_SECTION
:
1029 case GIMPLE_OMP_PARALLEL
:
1030 case GIMPLE_OMP_TASK
:
1031 case GIMPLE_OMP_SECTIONS
:
1032 case GIMPLE_OMP_SINGLE
:
1033 case GIMPLE_OMP_CRITICAL
:
1034 case GIMPLE_WITH_CLEANUP_EXPR
:
1043 /* Return the basic block holding statement G. */
1045 static inline struct basic_block_def
*
1046 gimple_bb (const_gimple g
)
1048 return g
->gsbase
.bb
;
1052 /* Return the lexical scope block holding statement G. */
1055 gimple_block (const_gimple g
)
1057 return g
->gsbase
.block
;
1061 /* Set BLOCK to be the lexical scope block holding statement G. */
1064 gimple_set_block (gimple g
, tree block
)
1066 g
->gsbase
.block
= block
;
1070 /* Return location information for statement G. */
1072 static inline location_t
1073 gimple_location (const_gimple g
)
1075 return g
->gsbase
.location
;
1078 /* Return pointer to location information for statement G. */
1080 static inline const location_t
*
1081 gimple_location_ptr (const_gimple g
)
1083 return &g
->gsbase
.location
;
1087 /* Set location information for statement G. */
1090 gimple_set_location (gimple g
, location_t location
)
1092 g
->gsbase
.location
= location
;
1096 /* Return true if G contains location information. */
1099 gimple_has_location (const_gimple g
)
1101 return gimple_location (g
) != UNKNOWN_LOCATION
;
1105 /* Return the file name of the location of STMT. */
1107 static inline const char *
1108 gimple_filename (const_gimple stmt
)
1110 return LOCATION_FILE (gimple_location (stmt
));
1114 /* Return the line number of the location of STMT. */
1117 gimple_lineno (const_gimple stmt
)
1119 return LOCATION_LINE (gimple_location (stmt
));
1123 /* Determine whether SEQ is a singleton. */
1126 gimple_seq_singleton_p (gimple_seq seq
)
1128 return ((gimple_seq_first (seq
) != NULL
)
1129 && (gimple_seq_first (seq
) == gimple_seq_last (seq
)));
1132 /* Return true if no warnings should be emitted for statement STMT. */
1135 gimple_no_warning_p (const_gimple stmt
)
1137 return stmt
->gsbase
.no_warning
;
1140 /* Set the no_warning flag of STMT to NO_WARNING. */
1143 gimple_set_no_warning (gimple stmt
, bool no_warning
)
1145 stmt
->gsbase
.no_warning
= (unsigned) no_warning
;
1148 /* Set the visited status on statement STMT to VISITED_P. */
1151 gimple_set_visited (gimple stmt
, bool visited_p
)
1153 stmt
->gsbase
.visited
= (unsigned) visited_p
;
1157 /* Return the visited status for statement STMT. */
1160 gimple_visited_p (gimple stmt
)
1162 return stmt
->gsbase
.visited
;
1166 /* Set pass local flag PLF on statement STMT to VAL_P. */
1169 gimple_set_plf (gimple stmt
, enum plf_mask plf
, bool val_p
)
1172 stmt
->gsbase
.plf
|= (unsigned int) plf
;
1174 stmt
->gsbase
.plf
&= ~((unsigned int) plf
);
1178 /* Return the value of pass local flag PLF on statement STMT. */
1180 static inline unsigned int
1181 gimple_plf (gimple stmt
, enum plf_mask plf
)
1183 return stmt
->gsbase
.plf
& ((unsigned int) plf
);
1187 /* Set the UID of statement. */
1190 gimple_set_uid (gimple g
, unsigned uid
)
1192 g
->gsbase
.uid
= uid
;
1196 /* Return the UID of statement. */
1198 static inline unsigned
1199 gimple_uid (const_gimple g
)
1201 return g
->gsbase
.uid
;
1205 /* Return true if GIMPLE statement G has register or memory operands. */
1208 gimple_has_ops (const_gimple g
)
1210 return gimple_code (g
) >= GIMPLE_COND
&& gimple_code (g
) <= GIMPLE_RETURN
;
1214 /* Return true if GIMPLE statement G has memory operands. */
1217 gimple_has_mem_ops (const_gimple g
)
1219 return gimple_code (g
) >= GIMPLE_ASSIGN
&& gimple_code (g
) <= GIMPLE_RETURN
;
1223 /* Return the set of DEF operands for statement G. */
1225 static inline struct def_optype_d
*
1226 gimple_def_ops (const_gimple g
)
1228 if (!gimple_has_ops (g
))
1230 return g
->gsops
.opbase
.def_ops
;
1234 /* Set DEF to be the set of DEF operands for statement G. */
1237 gimple_set_def_ops (gimple g
, struct def_optype_d
*def
)
1239 gcc_assert (gimple_has_ops (g
));
1240 g
->gsops
.opbase
.def_ops
= def
;
1244 /* Return the set of USE operands for statement G. */
1246 static inline struct use_optype_d
*
1247 gimple_use_ops (const_gimple g
)
1249 if (!gimple_has_ops (g
))
1251 return g
->gsops
.opbase
.use_ops
;
1255 /* Set USE to be the set of USE operands for statement G. */
1258 gimple_set_use_ops (gimple g
, struct use_optype_d
*use
)
1260 gcc_assert (gimple_has_ops (g
));
1261 g
->gsops
.opbase
.use_ops
= use
;
1265 /* Return the set of VUSE operand for statement G. */
1267 static inline use_operand_p
1268 gimple_vuse_op (const_gimple g
)
1270 struct use_optype_d
*ops
;
1271 if (!gimple_has_mem_ops (g
))
1272 return NULL_USE_OPERAND_P
;
1273 ops
= g
->gsops
.opbase
.use_ops
;
1275 && USE_OP_PTR (ops
)->use
== &g
->gsmem
.membase
.vuse
)
1276 return USE_OP_PTR (ops
);
1277 return NULL_USE_OPERAND_P
;
1280 /* Return the set of VDEF operand for statement G. */
1282 static inline def_operand_p
1283 gimple_vdef_op (const_gimple g
)
1285 struct def_optype_d
*ops
;
1286 if (!gimple_has_mem_ops (g
))
1287 return NULL_DEF_OPERAND_P
;
1288 ops
= g
->gsops
.opbase
.def_ops
;
1290 && DEF_OP_PTR (ops
) == &g
->gsmem
.membase
.vdef
)
1291 return DEF_OP_PTR (ops
);
1292 return NULL_DEF_OPERAND_P
;
1296 /* Return the single VUSE operand of the statement G. */
1299 gimple_vuse (const_gimple g
)
1301 if (!gimple_has_mem_ops (g
))
1303 return g
->gsmem
.membase
.vuse
;
1306 /* Return the single VDEF operand of the statement G. */
1309 gimple_vdef (const_gimple g
)
1311 if (!gimple_has_mem_ops (g
))
1313 return g
->gsmem
.membase
.vdef
;
1316 /* Return the single VUSE operand of the statement G. */
1318 static inline tree
*
1319 gimple_vuse_ptr (gimple g
)
1321 if (!gimple_has_mem_ops (g
))
1323 return &g
->gsmem
.membase
.vuse
;
1326 /* Return the single VDEF operand of the statement G. */
1328 static inline tree
*
1329 gimple_vdef_ptr (gimple g
)
1331 if (!gimple_has_mem_ops (g
))
1333 return &g
->gsmem
.membase
.vdef
;
1336 /* Set the single VUSE operand of the statement G. */
1339 gimple_set_vuse (gimple g
, tree vuse
)
1341 gcc_assert (gimple_has_mem_ops (g
));
1342 g
->gsmem
.membase
.vuse
= vuse
;
1345 /* Set the single VDEF operand of the statement G. */
1348 gimple_set_vdef (gimple g
, tree vdef
)
1350 gcc_assert (gimple_has_mem_ops (g
));
1351 g
->gsmem
.membase
.vdef
= vdef
;
1355 /* Return true if statement G has operands and the modified field has
1359 gimple_modified_p (const_gimple g
)
1361 return (gimple_has_ops (g
)) ? (bool) g
->gsbase
.modified
: false;
1365 /* Return the tree code for the expression computed by STMT. This is
1366 only valid for GIMPLE_COND, GIMPLE_CALL and GIMPLE_ASSIGN. For
1367 GIMPLE_CALL, return CALL_EXPR as the expression code for
1368 consistency. This is useful when the caller needs to deal with the
1369 three kinds of computation that GIMPLE supports. */
1371 static inline enum tree_code
1372 gimple_expr_code (const_gimple stmt
)
1374 enum gimple_code code
= gimple_code (stmt
);
1375 if (code
== GIMPLE_ASSIGN
|| code
== GIMPLE_COND
)
1376 return (enum tree_code
) stmt
->gsbase
.subcode
;
1377 else if (code
== GIMPLE_CALL
)
1384 /* Mark statement S as modified, and update it. */
1387 update_stmt (gimple s
)
1389 if (gimple_has_ops (s
))
1391 gimple_set_modified (s
, true);
1392 update_stmt_operands (s
);
1396 /* Update statement S if it has been optimized. */
1399 update_stmt_if_modified (gimple s
)
1401 if (gimple_modified_p (s
))
1402 update_stmt_operands (s
);
1405 /* Return true if statement STMT contains volatile operands. */
1408 gimple_has_volatile_ops (const_gimple stmt
)
1410 if (gimple_has_mem_ops (stmt
))
1411 return stmt
->gsbase
.has_volatile_ops
;
1417 /* Set the HAS_VOLATILE_OPS flag to VOLATILEP. */
1420 gimple_set_has_volatile_ops (gimple stmt
, bool volatilep
)
1422 if (gimple_has_mem_ops (stmt
))
1423 stmt
->gsbase
.has_volatile_ops
= (unsigned) volatilep
;
1427 /* Return true if statement STMT may access memory. */
1430 gimple_references_memory_p (gimple stmt
)
1432 return gimple_has_mem_ops (stmt
) && gimple_vuse (stmt
);
1436 /* Return the subcode for OMP statement S. */
1438 static inline unsigned
1439 gimple_omp_subcode (const_gimple s
)
1441 gcc_assert (gimple_code (s
) >= GIMPLE_OMP_ATOMIC_LOAD
1442 && gimple_code (s
) <= GIMPLE_OMP_SINGLE
);
1443 return s
->gsbase
.subcode
;
1446 /* Set the subcode for OMP statement S to SUBCODE. */
1449 gimple_omp_set_subcode (gimple s
, unsigned int subcode
)
1451 /* We only have 16 bits for the subcode. Assert that we are not
1453 gcc_assert (subcode
< (1 << 16));
1454 s
->gsbase
.subcode
= subcode
;
1457 /* Set the nowait flag on OMP_RETURN statement S. */
1460 gimple_omp_return_set_nowait (gimple s
)
1462 GIMPLE_CHECK (s
, GIMPLE_OMP_RETURN
);
1463 s
->gsbase
.subcode
|= GF_OMP_RETURN_NOWAIT
;
1467 /* Return true if OMP return statement G has the GF_OMP_RETURN_NOWAIT
1471 gimple_omp_return_nowait_p (const_gimple g
)
1473 GIMPLE_CHECK (g
, GIMPLE_OMP_RETURN
);
1474 return (gimple_omp_subcode (g
) & GF_OMP_RETURN_NOWAIT
) != 0;
1478 /* Return true if OMP section statement G has the GF_OMP_SECTION_LAST
1482 gimple_omp_section_last_p (const_gimple g
)
1484 GIMPLE_CHECK (g
, GIMPLE_OMP_SECTION
);
1485 return (gimple_omp_subcode (g
) & GF_OMP_SECTION_LAST
) != 0;
1489 /* Set the GF_OMP_SECTION_LAST flag on G. */
1492 gimple_omp_section_set_last (gimple g
)
1494 GIMPLE_CHECK (g
, GIMPLE_OMP_SECTION
);
1495 g
->gsbase
.subcode
|= GF_OMP_SECTION_LAST
;
1499 /* Return true if OMP parallel statement G has the
1500 GF_OMP_PARALLEL_COMBINED flag set. */
1503 gimple_omp_parallel_combined_p (const_gimple g
)
1505 GIMPLE_CHECK (g
, GIMPLE_OMP_PARALLEL
);
1506 return (gimple_omp_subcode (g
) & GF_OMP_PARALLEL_COMBINED
) != 0;
1510 /* Set the GF_OMP_PARALLEL_COMBINED field in G depending on the boolean
1511 value of COMBINED_P. */
1514 gimple_omp_parallel_set_combined_p (gimple g
, bool combined_p
)
1516 GIMPLE_CHECK (g
, GIMPLE_OMP_PARALLEL
);
1518 g
->gsbase
.subcode
|= GF_OMP_PARALLEL_COMBINED
;
1520 g
->gsbase
.subcode
&= ~GF_OMP_PARALLEL_COMBINED
;
1524 /* Return the number of operands for statement GS. */
1526 static inline unsigned
1527 gimple_num_ops (const_gimple gs
)
1529 return gs
->gsbase
.num_ops
;
1533 /* Set the number of operands for statement GS. */
1536 gimple_set_num_ops (gimple gs
, unsigned num_ops
)
1538 gs
->gsbase
.num_ops
= num_ops
;
1542 /* Return the array of operands for statement GS. */
1544 static inline tree
*
1545 gimple_ops (gimple gs
)
1547 /* Offset in bytes to the location of the operand vector in every
1548 tuple structure. Defined in gimple.c */
1549 extern size_t const gimple_ops_offset_
[];
1551 if (!gimple_has_ops (gs
))
1554 /* All the tuples have their operand vector at the very bottom
1555 of the structure. */
1556 return ((tree
*) ((char *) gs
+ gimple_ops_offset_
[gimple_code (gs
)]));
1560 /* Return operand I for statement GS. */
1563 gimple_op (const_gimple gs
, unsigned i
)
1565 if (gimple_has_ops (gs
))
1567 gcc_assert (i
< gimple_num_ops (gs
));
1568 return gimple_ops (CONST_CAST_GIMPLE (gs
))[i
];
1574 /* Return a pointer to operand I for statement GS. */
1576 static inline tree
*
1577 gimple_op_ptr (const_gimple gs
, unsigned i
)
1579 if (gimple_has_ops (gs
))
1581 gcc_assert (i
< gimple_num_ops (gs
));
1582 return gimple_ops (CONST_CAST_GIMPLE (gs
)) + i
;
1588 /* Set operand I of statement GS to OP. */
1591 gimple_set_op (gimple gs
, unsigned i
, tree op
)
1593 gcc_assert (gimple_has_ops (gs
) && i
< gimple_num_ops (gs
));
1595 /* Note. It may be tempting to assert that OP matches
1596 is_gimple_operand, but that would be wrong. Different tuples
1597 accept slightly different sets of tree operands. Each caller
1598 should perform its own validation. */
1599 gimple_ops (gs
)[i
] = op
;
1602 /* Return true if GS is a GIMPLE_ASSIGN. */
1605 is_gimple_assign (const_gimple gs
)
1607 return gimple_code (gs
) == GIMPLE_ASSIGN
;
1610 /* Determine if expression CODE is one of the valid expressions that can
1611 be used on the RHS of GIMPLE assignments. */
1613 static inline enum gimple_rhs_class
1614 get_gimple_rhs_class (enum tree_code code
)
1616 return (enum gimple_rhs_class
) gimple_rhs_class_table
[(int) code
];
1619 /* Return the LHS of assignment statement GS. */
1622 gimple_assign_lhs (const_gimple gs
)
1624 GIMPLE_CHECK (gs
, GIMPLE_ASSIGN
);
1625 return gimple_op (gs
, 0);
1629 /* Return a pointer to the LHS of assignment statement GS. */
1631 static inline tree
*
1632 gimple_assign_lhs_ptr (const_gimple gs
)
1634 GIMPLE_CHECK (gs
, GIMPLE_ASSIGN
);
1635 return gimple_op_ptr (gs
, 0);
1639 /* Set LHS to be the LHS operand of assignment statement GS. */
1642 gimple_assign_set_lhs (gimple gs
, tree lhs
)
1644 GIMPLE_CHECK (gs
, GIMPLE_ASSIGN
);
1645 gcc_assert (is_gimple_operand (lhs
));
1646 gimple_set_op (gs
, 0, lhs
);
1648 if (lhs
&& TREE_CODE (lhs
) == SSA_NAME
)
1649 SSA_NAME_DEF_STMT (lhs
) = gs
;
1653 /* Return the first operand on the RHS of assignment statement GS. */
1656 gimple_assign_rhs1 (const_gimple gs
)
1658 GIMPLE_CHECK (gs
, GIMPLE_ASSIGN
);
1659 return gimple_op (gs
, 1);
1663 /* Return a pointer to the first operand on the RHS of assignment
1666 static inline tree
*
1667 gimple_assign_rhs1_ptr (const_gimple gs
)
1669 GIMPLE_CHECK (gs
, GIMPLE_ASSIGN
);
1670 return gimple_op_ptr (gs
, 1);
1673 /* Set RHS to be the first operand on the RHS of assignment statement GS. */
1676 gimple_assign_set_rhs1 (gimple gs
, tree rhs
)
1678 GIMPLE_CHECK (gs
, GIMPLE_ASSIGN
);
1680 /* If there are 3 or more operands, the 2 operands on the RHS must be
1682 if (gimple_num_ops (gs
) >= 3)
1683 gcc_assert (is_gimple_val (rhs
));
1685 gcc_assert (is_gimple_operand (rhs
));
1687 gimple_set_op (gs
, 1, rhs
);
1691 /* Return the second operand on the RHS of assignment statement GS.
1692 If GS does not have two operands, NULL is returned instead. */
1695 gimple_assign_rhs2 (const_gimple gs
)
1697 GIMPLE_CHECK (gs
, GIMPLE_ASSIGN
);
1699 if (gimple_num_ops (gs
) >= 3)
1700 return gimple_op (gs
, 2);
1706 /* Return a pointer to the second operand on the RHS of assignment
1709 static inline tree
*
1710 gimple_assign_rhs2_ptr (const_gimple gs
)
1712 GIMPLE_CHECK (gs
, GIMPLE_ASSIGN
);
1713 return gimple_op_ptr (gs
, 2);
1717 /* Set RHS to be the second operand on the RHS of assignment statement GS. */
1720 gimple_assign_set_rhs2 (gimple gs
, tree rhs
)
1722 GIMPLE_CHECK (gs
, GIMPLE_ASSIGN
);
1724 /* The 2 operands on the RHS must be GIMPLE values. */
1725 gcc_assert (is_gimple_val (rhs
));
1727 gimple_set_op (gs
, 2, rhs
);
1730 /* Returns true if GS is a nontemporal move. */
1733 gimple_assign_nontemporal_move_p (const_gimple gs
)
1735 GIMPLE_CHECK (gs
, GIMPLE_ASSIGN
);
1736 return gs
->gsbase
.nontemporal_move
;
1739 /* Sets nontemporal move flag of GS to NONTEMPORAL. */
1742 gimple_assign_set_nontemporal_move (gimple gs
, bool nontemporal
)
1744 GIMPLE_CHECK (gs
, GIMPLE_ASSIGN
);
1745 gs
->gsbase
.nontemporal_move
= nontemporal
;
1749 /* Return the code of the expression computed on the rhs of assignment
1750 statement GS. In case that the RHS is a single object, returns the
1751 tree code of the object. */
1753 static inline enum tree_code
1754 gimple_assign_rhs_code (const_gimple gs
)
1756 enum tree_code code
;
1757 GIMPLE_CHECK (gs
, GIMPLE_ASSIGN
);
1759 code
= gimple_expr_code (gs
);
1760 if (get_gimple_rhs_class (code
) == GIMPLE_SINGLE_RHS
)
1761 code
= TREE_CODE (gimple_assign_rhs1 (gs
));
1767 /* Set CODE to be the code for the expression computed on the RHS of
1771 gimple_assign_set_rhs_code (gimple s
, enum tree_code code
)
1773 GIMPLE_CHECK (s
, GIMPLE_ASSIGN
);
1774 s
->gsbase
.subcode
= code
;
1778 /* Return the gimple rhs class of the code of the expression computed on
1779 the rhs of assignment statement GS.
1780 This will never return GIMPLE_INVALID_RHS. */
1782 static inline enum gimple_rhs_class
1783 gimple_assign_rhs_class (const_gimple gs
)
1785 return get_gimple_rhs_class (gimple_assign_rhs_code (gs
));
1789 /* Return true if S is a type-cast assignment. */
1792 gimple_assign_cast_p (gimple s
)
1794 if (is_gimple_assign (s
))
1796 enum tree_code sc
= gimple_assign_rhs_code (s
);
1797 return CONVERT_EXPR_CODE_P (sc
)
1798 || sc
== VIEW_CONVERT_EXPR
1799 || sc
== FIX_TRUNC_EXPR
;
1806 /* Return true if GS is a GIMPLE_CALL. */
1809 is_gimple_call (const_gimple gs
)
1811 return gimple_code (gs
) == GIMPLE_CALL
;
1814 /* Return the LHS of call statement GS. */
1817 gimple_call_lhs (const_gimple gs
)
1819 GIMPLE_CHECK (gs
, GIMPLE_CALL
);
1820 return gimple_op (gs
, 0);
1824 /* Return a pointer to the LHS of call statement GS. */
1826 static inline tree
*
1827 gimple_call_lhs_ptr (const_gimple gs
)
1829 GIMPLE_CHECK (gs
, GIMPLE_CALL
);
1830 return gimple_op_ptr (gs
, 0);
1834 /* Set LHS to be the LHS operand of call statement GS. */
1837 gimple_call_set_lhs (gimple gs
, tree lhs
)
1839 GIMPLE_CHECK (gs
, GIMPLE_CALL
);
1840 gcc_assert (!lhs
|| is_gimple_operand (lhs
));
1841 gimple_set_op (gs
, 0, lhs
);
1842 if (lhs
&& TREE_CODE (lhs
) == SSA_NAME
)
1843 SSA_NAME_DEF_STMT (lhs
) = gs
;
1847 /* Return the tree node representing the function called by call
1851 gimple_call_fn (const_gimple gs
)
1853 GIMPLE_CHECK (gs
, GIMPLE_CALL
);
1854 return gimple_op (gs
, 1);
1858 /* Return a pointer to the tree node representing the function called by call
1861 static inline tree
*
1862 gimple_call_fn_ptr (const_gimple gs
)
1864 GIMPLE_CHECK (gs
, GIMPLE_CALL
);
1865 return gimple_op_ptr (gs
, 1);
1869 /* Set FN to be the function called by call statement GS. */
1872 gimple_call_set_fn (gimple gs
, tree fn
)
1874 GIMPLE_CHECK (gs
, GIMPLE_CALL
);
1875 gcc_assert (is_gimple_operand (fn
));
1876 gimple_set_op (gs
, 1, fn
);
1880 /* Set FNDECL to be the function called by call statement GS. */
1883 gimple_call_set_fndecl (gimple gs
, tree decl
)
1885 GIMPLE_CHECK (gs
, GIMPLE_CALL
);
1886 gcc_assert (TREE_CODE (decl
) == FUNCTION_DECL
);
1887 gimple_set_op (gs
, 1, build_fold_addr_expr (decl
));
1891 /* If a given GIMPLE_CALL's callee is a FUNCTION_DECL, return it.
1892 Otherwise return NULL. This function is analogous to
1893 get_callee_fndecl in tree land. */
1896 gimple_call_fndecl (const_gimple gs
)
1898 tree addr
= gimple_call_fn (gs
);
1899 if (TREE_CODE (addr
) == ADDR_EXPR
)
1901 gcc_assert (TREE_CODE (TREE_OPERAND (addr
, 0)) == FUNCTION_DECL
);
1902 return TREE_OPERAND (addr
, 0);
1908 /* Return the type returned by call statement GS. */
1911 gimple_call_return_type (const_gimple gs
)
1913 tree fn
= gimple_call_fn (gs
);
1914 tree type
= TREE_TYPE (fn
);
1916 /* See through the pointer. */
1917 gcc_assert (POINTER_TYPE_P (type
));
1918 type
= TREE_TYPE (type
);
1920 gcc_assert (TREE_CODE (type
) == FUNCTION_TYPE
1921 || TREE_CODE (type
) == METHOD_TYPE
);
1923 /* The type returned by a FUNCTION_DECL is the type of its
1925 return TREE_TYPE (type
);
1929 /* Return the static chain for call statement GS. */
1932 gimple_call_chain (const_gimple gs
)
1934 GIMPLE_CHECK (gs
, GIMPLE_CALL
);
1935 return gimple_op (gs
, 2);
1939 /* Return a pointer to the static chain for call statement GS. */
1941 static inline tree
*
1942 gimple_call_chain_ptr (const_gimple gs
)
1944 GIMPLE_CHECK (gs
, GIMPLE_CALL
);
1945 return gimple_op_ptr (gs
, 2);
1948 /* Set CHAIN to be the static chain for call statement GS. */
1951 gimple_call_set_chain (gimple gs
, tree chain
)
1953 GIMPLE_CHECK (gs
, GIMPLE_CALL
);
1954 gcc_assert (chain
== NULL
1955 || TREE_CODE (chain
) == ADDR_EXPR
1956 || SSA_VAR_P (chain
));
1957 gimple_set_op (gs
, 2, chain
);
1961 /* Return the number of arguments used by call statement GS. */
1963 static inline unsigned
1964 gimple_call_num_args (const_gimple gs
)
1967 GIMPLE_CHECK (gs
, GIMPLE_CALL
);
1968 num_ops
= gimple_num_ops (gs
);
1969 gcc_assert (num_ops
>= 3);
1974 /* Return the argument at position INDEX for call statement GS. */
1977 gimple_call_arg (const_gimple gs
, unsigned index
)
1979 GIMPLE_CHECK (gs
, GIMPLE_CALL
);
1980 return gimple_op (gs
, index
+ 3);
1984 /* Return a pointer to the argument at position INDEX for call
1987 static inline tree
*
1988 gimple_call_arg_ptr (const_gimple gs
, unsigned index
)
1990 GIMPLE_CHECK (gs
, GIMPLE_CALL
);
1991 return gimple_op_ptr (gs
, index
+ 3);
1995 /* Set ARG to be the argument at position INDEX for call statement GS. */
1998 gimple_call_set_arg (gimple gs
, unsigned index
, tree arg
)
2000 GIMPLE_CHECK (gs
, GIMPLE_CALL
);
2001 gcc_assert (is_gimple_operand (arg
));
2002 gimple_set_op (gs
, index
+ 3, arg
);
2006 /* If TAIL_P is true, mark call statement S as being a tail call
2007 (i.e., a call just before the exit of a function). These calls are
2008 candidate for tail call optimization. */
2011 gimple_call_set_tail (gimple s
, bool tail_p
)
2013 GIMPLE_CHECK (s
, GIMPLE_CALL
);
2015 s
->gsbase
.subcode
|= GF_CALL_TAILCALL
;
2017 s
->gsbase
.subcode
&= ~GF_CALL_TAILCALL
;
2021 /* Return true if GIMPLE_CALL S is marked as a tail call. */
2024 gimple_call_tail_p (gimple s
)
2026 GIMPLE_CHECK (s
, GIMPLE_CALL
);
2027 return (s
->gsbase
.subcode
& GF_CALL_TAILCALL
) != 0;
2031 /* Set the inlinable status of GIMPLE_CALL S to INLINABLE_P. */
2034 gimple_call_set_cannot_inline (gimple s
, bool inlinable_p
)
2036 GIMPLE_CHECK (s
, GIMPLE_CALL
);
2038 s
->gsbase
.subcode
|= GF_CALL_CANNOT_INLINE
;
2040 s
->gsbase
.subcode
&= ~GF_CALL_CANNOT_INLINE
;
2044 /* Return true if GIMPLE_CALL S cannot be inlined. */
2047 gimple_call_cannot_inline_p (gimple s
)
2049 GIMPLE_CHECK (s
, GIMPLE_CALL
);
2050 return (s
->gsbase
.subcode
& GF_CALL_CANNOT_INLINE
) != 0;
2054 /* If RETURN_SLOT_OPT_P is true mark GIMPLE_CALL S as valid for return
2055 slot optimization. This transformation uses the target of the call
2056 expansion as the return slot for calls that return in memory. */
2059 gimple_call_set_return_slot_opt (gimple s
, bool return_slot_opt_p
)
2061 GIMPLE_CHECK (s
, GIMPLE_CALL
);
2062 if (return_slot_opt_p
)
2063 s
->gsbase
.subcode
|= GF_CALL_RETURN_SLOT_OPT
;
2065 s
->gsbase
.subcode
&= ~GF_CALL_RETURN_SLOT_OPT
;
2069 /* Return true if S is marked for return slot optimization. */
2072 gimple_call_return_slot_opt_p (gimple s
)
2074 GIMPLE_CHECK (s
, GIMPLE_CALL
);
2075 return (s
->gsbase
.subcode
& GF_CALL_RETURN_SLOT_OPT
) != 0;
2079 /* If FROM_THUNK_P is true, mark GIMPLE_CALL S as being the jump from a
2080 thunk to the thunked-to function. */
2083 gimple_call_set_from_thunk (gimple s
, bool from_thunk_p
)
2085 GIMPLE_CHECK (s
, GIMPLE_CALL
);
2087 s
->gsbase
.subcode
|= GF_CALL_FROM_THUNK
;
2089 s
->gsbase
.subcode
&= ~GF_CALL_FROM_THUNK
;
2093 /* Return true if GIMPLE_CALL S is a jump from a thunk. */
2096 gimple_call_from_thunk_p (gimple s
)
2098 GIMPLE_CHECK (s
, GIMPLE_CALL
);
2099 return (s
->gsbase
.subcode
& GF_CALL_FROM_THUNK
) != 0;
2103 /* If PASS_ARG_PACK_P is true, GIMPLE_CALL S is a stdarg call that needs the
2104 argument pack in its argument list. */
2107 gimple_call_set_va_arg_pack (gimple s
, bool pass_arg_pack_p
)
2109 GIMPLE_CHECK (s
, GIMPLE_CALL
);
2110 if (pass_arg_pack_p
)
2111 s
->gsbase
.subcode
|= GF_CALL_VA_ARG_PACK
;
2113 s
->gsbase
.subcode
&= ~GF_CALL_VA_ARG_PACK
;
2117 /* Return true if GIMPLE_CALL S is a stdarg call that needs the
2118 argument pack in its argument list. */
2121 gimple_call_va_arg_pack_p (gimple s
)
2123 GIMPLE_CHECK (s
, GIMPLE_CALL
);
2124 return (s
->gsbase
.subcode
& GF_CALL_VA_ARG_PACK
) != 0;
2128 /* Return true if S is a noreturn call. */
2131 gimple_call_noreturn_p (gimple s
)
2133 GIMPLE_CHECK (s
, GIMPLE_CALL
);
2134 return (gimple_call_flags (s
) & ECF_NORETURN
) != 0;
2138 /* Return true if S is a nothrow call. */
2141 gimple_call_nothrow_p (gimple s
)
2143 GIMPLE_CHECK (s
, GIMPLE_CALL
);
2144 return (gimple_call_flags (s
) & ECF_NOTHROW
) != 0;
2148 /* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL. */
2151 gimple_call_copy_flags (gimple dest_call
, gimple orig_call
)
2153 GIMPLE_CHECK (dest_call
, GIMPLE_CALL
);
2154 GIMPLE_CHECK (orig_call
, GIMPLE_CALL
);
2155 dest_call
->gsbase
.subcode
= orig_call
->gsbase
.subcode
;
2159 /* Returns true if this is a GIMPLE_ASSIGN or a GIMPLE_CALL with a
2163 gimple_has_lhs (gimple stmt
)
2165 return (is_gimple_assign (stmt
)
2166 || (is_gimple_call (stmt
)
2167 && gimple_call_lhs (stmt
) != NULL_TREE
));
2171 /* Return the code of the predicate computed by conditional statement GS. */
2173 static inline enum tree_code
2174 gimple_cond_code (const_gimple gs
)
2176 GIMPLE_CHECK (gs
, GIMPLE_COND
);
2177 return (enum tree_code
) gs
->gsbase
.subcode
;
2181 /* Set CODE to be the predicate code for the conditional statement GS. */
2184 gimple_cond_set_code (gimple gs
, enum tree_code code
)
2186 GIMPLE_CHECK (gs
, GIMPLE_COND
);
2187 gcc_assert (TREE_CODE_CLASS (code
) == tcc_comparison
);
2188 gs
->gsbase
.subcode
= code
;
2192 /* Return the LHS of the predicate computed by conditional statement GS. */
2195 gimple_cond_lhs (const_gimple gs
)
2197 GIMPLE_CHECK (gs
, GIMPLE_COND
);
2198 return gimple_op (gs
, 0);
2201 /* Return the pointer to the LHS of the predicate computed by conditional
2204 static inline tree
*
2205 gimple_cond_lhs_ptr (const_gimple gs
)
2207 GIMPLE_CHECK (gs
, GIMPLE_COND
);
2208 return gimple_op_ptr (gs
, 0);
2211 /* Set LHS to be the LHS operand of the predicate computed by
2212 conditional statement GS. */
2215 gimple_cond_set_lhs (gimple gs
, tree lhs
)
2217 GIMPLE_CHECK (gs
, GIMPLE_COND
);
2218 gcc_assert (is_gimple_operand (lhs
));
2219 gimple_set_op (gs
, 0, lhs
);
2223 /* Return the RHS operand of the predicate computed by conditional GS. */
2226 gimple_cond_rhs (const_gimple gs
)
2228 GIMPLE_CHECK (gs
, GIMPLE_COND
);
2229 return gimple_op (gs
, 1);
2232 /* Return the pointer to the RHS operand of the predicate computed by
2235 static inline tree
*
2236 gimple_cond_rhs_ptr (const_gimple gs
)
2238 GIMPLE_CHECK (gs
, GIMPLE_COND
);
2239 return gimple_op_ptr (gs
, 1);
2243 /* Set RHS to be the RHS operand of the predicate computed by
2244 conditional statement GS. */
2247 gimple_cond_set_rhs (gimple gs
, tree rhs
)
2249 GIMPLE_CHECK (gs
, GIMPLE_COND
);
2250 gcc_assert (is_gimple_operand (rhs
));
2251 gimple_set_op (gs
, 1, rhs
);
2255 /* Return the label used by conditional statement GS when its
2256 predicate evaluates to true. */
2259 gimple_cond_true_label (const_gimple gs
)
2261 GIMPLE_CHECK (gs
, GIMPLE_COND
);
2262 return gimple_op (gs
, 2);
2266 /* Set LABEL to be the label used by conditional statement GS when its
2267 predicate evaluates to true. */
2270 gimple_cond_set_true_label (gimple gs
, tree label
)
2272 GIMPLE_CHECK (gs
, GIMPLE_COND
);
2273 gcc_assert (!label
|| TREE_CODE (label
) == LABEL_DECL
);
2274 gimple_set_op (gs
, 2, label
);
2278 /* Set LABEL to be the label used by conditional statement GS when its
2279 predicate evaluates to false. */
2282 gimple_cond_set_false_label (gimple gs
, tree label
)
2284 GIMPLE_CHECK (gs
, GIMPLE_COND
);
2285 gcc_assert (!label
|| TREE_CODE (label
) == LABEL_DECL
);
2286 gimple_set_op (gs
, 3, label
);
2290 /* Return the label used by conditional statement GS when its
2291 predicate evaluates to false. */
2294 gimple_cond_false_label (const_gimple gs
)
2296 GIMPLE_CHECK (gs
, GIMPLE_COND
);
2297 return gimple_op (gs
, 3);
2301 /* Set the conditional COND_STMT to be of the form 'if (1 == 0)'. */
2304 gimple_cond_make_false (gimple gs
)
2306 gimple_cond_set_lhs (gs
, boolean_true_node
);
2307 gimple_cond_set_rhs (gs
, boolean_false_node
);
2308 gs
->gsbase
.subcode
= EQ_EXPR
;
2312 /* Set the conditional COND_STMT to be of the form 'if (1 == 1)'. */
2315 gimple_cond_make_true (gimple gs
)
2317 gimple_cond_set_lhs (gs
, boolean_true_node
);
2318 gimple_cond_set_rhs (gs
, boolean_true_node
);
2319 gs
->gsbase
.subcode
= EQ_EXPR
;
2322 /* Check if conditional statemente GS is of the form 'if (1 == 1)',
2323 'if (0 == 0)', 'if (1 != 0)' or 'if (0 != 1)' */
2326 gimple_cond_true_p (const_gimple gs
)
2328 tree lhs
= gimple_cond_lhs (gs
);
2329 tree rhs
= gimple_cond_rhs (gs
);
2330 enum tree_code code
= gimple_cond_code (gs
);
2332 if (lhs
!= boolean_true_node
&& lhs
!= boolean_false_node
)
2335 if (rhs
!= boolean_true_node
&& rhs
!= boolean_false_node
)
2338 if (code
== NE_EXPR
&& lhs
!= rhs
)
2341 if (code
== EQ_EXPR
&& lhs
== rhs
)
2347 /* Check if conditional statement GS is of the form 'if (1 != 1)',
2348 'if (0 != 0)', 'if (1 == 0)' or 'if (0 == 1)' */
2351 gimple_cond_false_p (const_gimple gs
)
2353 tree lhs
= gimple_cond_lhs (gs
);
2354 tree rhs
= gimple_cond_rhs (gs
);
2355 enum tree_code code
= gimple_cond_code (gs
);
2357 if (lhs
!= boolean_true_node
&& lhs
!= boolean_false_node
)
2360 if (rhs
!= boolean_true_node
&& rhs
!= boolean_false_node
)
2363 if (code
== NE_EXPR
&& lhs
== rhs
)
2366 if (code
== EQ_EXPR
&& lhs
!= rhs
)
2372 /* Check if conditional statement GS is of the form 'if (var != 0)' or
2376 gimple_cond_single_var_p (gimple gs
)
2378 if (gimple_cond_code (gs
) == NE_EXPR
2379 && gimple_cond_rhs (gs
) == boolean_false_node
)
2382 if (gimple_cond_code (gs
) == EQ_EXPR
2383 && gimple_cond_rhs (gs
) == boolean_true_node
)
2389 /* Set the code, LHS and RHS of GIMPLE_COND STMT from CODE, LHS and RHS. */
2392 gimple_cond_set_condition (gimple stmt
, enum tree_code code
, tree lhs
, tree rhs
)
2394 gimple_cond_set_code (stmt
, code
);
2395 gimple_cond_set_lhs (stmt
, lhs
);
2396 gimple_cond_set_rhs (stmt
, rhs
);
2399 /* Return the LABEL_DECL node used by GIMPLE_LABEL statement GS. */
2402 gimple_label_label (const_gimple gs
)
2404 GIMPLE_CHECK (gs
, GIMPLE_LABEL
);
2405 return gimple_op (gs
, 0);
2409 /* Set LABEL to be the LABEL_DECL node used by GIMPLE_LABEL statement
2413 gimple_label_set_label (gimple gs
, tree label
)
2415 GIMPLE_CHECK (gs
, GIMPLE_LABEL
);
2416 gcc_assert (TREE_CODE (label
) == LABEL_DECL
);
2417 gimple_set_op (gs
, 0, label
);
2421 /* Return the destination of the unconditional jump GS. */
2424 gimple_goto_dest (const_gimple gs
)
2426 GIMPLE_CHECK (gs
, GIMPLE_GOTO
);
2427 return gimple_op (gs
, 0);
2431 /* Set DEST to be the destination of the unconditonal jump GS. */
2434 gimple_goto_set_dest (gimple gs
, tree dest
)
2436 GIMPLE_CHECK (gs
, GIMPLE_GOTO
);
2437 gcc_assert (is_gimple_operand (dest
));
2438 gimple_set_op (gs
, 0, dest
);
2442 /* Return the variables declared in the GIMPLE_BIND statement GS. */
2445 gimple_bind_vars (const_gimple gs
)
2447 GIMPLE_CHECK (gs
, GIMPLE_BIND
);
2448 return gs
->gimple_bind
.vars
;
2452 /* Set VARS to be the set of variables declared in the GIMPLE_BIND
2456 gimple_bind_set_vars (gimple gs
, tree vars
)
2458 GIMPLE_CHECK (gs
, GIMPLE_BIND
);
2459 gs
->gimple_bind
.vars
= vars
;
2463 /* Append VARS to the set of variables declared in the GIMPLE_BIND
2467 gimple_bind_append_vars (gimple gs
, tree vars
)
2469 GIMPLE_CHECK (gs
, GIMPLE_BIND
);
2470 gs
->gimple_bind
.vars
= chainon (gs
->gimple_bind
.vars
, vars
);
2474 /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS. */
2476 static inline gimple_seq
2477 gimple_bind_body (gimple gs
)
2479 GIMPLE_CHECK (gs
, GIMPLE_BIND
);
2480 return gs
->gimple_bind
.body
;
2484 /* Set SEQ to be the GIMPLE sequence contained in the GIMPLE_BIND
2488 gimple_bind_set_body (gimple gs
, gimple_seq seq
)
2490 GIMPLE_CHECK (gs
, GIMPLE_BIND
);
2491 gs
->gimple_bind
.body
= seq
;
2495 /* Append a statement to the end of a GIMPLE_BIND's body. */
2498 gimple_bind_add_stmt (gimple gs
, gimple stmt
)
2500 GIMPLE_CHECK (gs
, GIMPLE_BIND
);
2501 gimple_seq_add_stmt (&gs
->gimple_bind
.body
, stmt
);
2505 /* Append a sequence of statements to the end of a GIMPLE_BIND's body. */
2508 gimple_bind_add_seq (gimple gs
, gimple_seq seq
)
2510 GIMPLE_CHECK (gs
, GIMPLE_BIND
);
2511 gimple_seq_add_seq (&gs
->gimple_bind
.body
, seq
);
2515 /* Return the TREE_BLOCK node associated with GIMPLE_BIND statement
2516 GS. This is analogous to the BIND_EXPR_BLOCK field in trees. */
2519 gimple_bind_block (const_gimple gs
)
2521 GIMPLE_CHECK (gs
, GIMPLE_BIND
);
2522 return gs
->gimple_bind
.block
;
2526 /* Set BLOCK to be the TREE_BLOCK node associated with GIMPLE_BIND
2530 gimple_bind_set_block (gimple gs
, tree block
)
2532 GIMPLE_CHECK (gs
, GIMPLE_BIND
);
2533 gcc_assert (block
== NULL_TREE
|| TREE_CODE (block
) == BLOCK
);
2534 gs
->gimple_bind
.block
= block
;
2538 /* Return the number of input operands for GIMPLE_ASM GS. */
2540 static inline unsigned
2541 gimple_asm_ninputs (const_gimple gs
)
2543 GIMPLE_CHECK (gs
, GIMPLE_ASM
);
2544 return gs
->gimple_asm
.ni
;
2548 /* Return the number of output operands for GIMPLE_ASM GS. */
2550 static inline unsigned
2551 gimple_asm_noutputs (const_gimple gs
)
2553 GIMPLE_CHECK (gs
, GIMPLE_ASM
);
2554 return gs
->gimple_asm
.no
;
2558 /* Return the number of clobber operands for GIMPLE_ASM GS. */
2560 static inline unsigned
2561 gimple_asm_nclobbers (const_gimple gs
)
2563 GIMPLE_CHECK (gs
, GIMPLE_ASM
);
2564 return gs
->gimple_asm
.nc
;
2568 /* Return input operand INDEX of GIMPLE_ASM GS. */
2571 gimple_asm_input_op (const_gimple gs
, unsigned index
)
2573 GIMPLE_CHECK (gs
, GIMPLE_ASM
);
2574 gcc_assert (index
<= gs
->gimple_asm
.ni
);
2575 return gimple_op (gs
, index
);
2578 /* Return a pointer to input operand INDEX of GIMPLE_ASM GS. */
2580 static inline tree
*
2581 gimple_asm_input_op_ptr (const_gimple gs
, unsigned index
)
2583 GIMPLE_CHECK (gs
, GIMPLE_ASM
);
2584 gcc_assert (index
<= gs
->gimple_asm
.ni
);
2585 return gimple_op_ptr (gs
, index
);
2589 /* Set IN_OP to be input operand INDEX in GIMPLE_ASM GS. */
2592 gimple_asm_set_input_op (gimple gs
, unsigned index
, tree in_op
)
2594 GIMPLE_CHECK (gs
, GIMPLE_ASM
);
2595 gcc_assert (index
<= gs
->gimple_asm
.ni
);
2596 gcc_assert (TREE_CODE (in_op
) == TREE_LIST
);
2597 gimple_set_op (gs
, index
, in_op
);
2601 /* Return output operand INDEX of GIMPLE_ASM GS. */
2604 gimple_asm_output_op (const_gimple gs
, unsigned index
)
2606 GIMPLE_CHECK (gs
, GIMPLE_ASM
);
2607 gcc_assert (index
<= gs
->gimple_asm
.no
);
2608 return gimple_op (gs
, index
+ gs
->gimple_asm
.ni
);
2611 /* Return a pointer to output operand INDEX of GIMPLE_ASM GS. */
2613 static inline tree
*
2614 gimple_asm_output_op_ptr (const_gimple gs
, unsigned index
)
2616 GIMPLE_CHECK (gs
, GIMPLE_ASM
);
2617 gcc_assert (index
<= gs
->gimple_asm
.no
);
2618 return gimple_op_ptr (gs
, index
+ gs
->gimple_asm
.ni
);
2622 /* Set OUT_OP to be output operand INDEX in GIMPLE_ASM GS. */
2625 gimple_asm_set_output_op (gimple gs
, unsigned index
, tree out_op
)
2627 GIMPLE_CHECK (gs
, GIMPLE_ASM
);
2628 gcc_assert (index
<= gs
->gimple_asm
.no
);
2629 gcc_assert (TREE_CODE (out_op
) == TREE_LIST
);
2630 gimple_set_op (gs
, index
+ gs
->gimple_asm
.ni
, out_op
);
2634 /* Return clobber operand INDEX of GIMPLE_ASM GS. */
2637 gimple_asm_clobber_op (const_gimple gs
, unsigned index
)
2639 GIMPLE_CHECK (gs
, GIMPLE_ASM
);
2640 gcc_assert (index
<= gs
->gimple_asm
.nc
);
2641 return gimple_op (gs
, index
+ gs
->gimple_asm
.ni
+ gs
->gimple_asm
.no
);
2645 /* Set CLOBBER_OP to be clobber operand INDEX in GIMPLE_ASM GS. */
2648 gimple_asm_set_clobber_op (gimple gs
, unsigned index
, tree clobber_op
)
2650 GIMPLE_CHECK (gs
, GIMPLE_ASM
);
2651 gcc_assert (index
<= gs
->gimple_asm
.nc
);
2652 gcc_assert (TREE_CODE (clobber_op
) == TREE_LIST
);
2653 gimple_set_op (gs
, index
+ gs
->gimple_asm
.ni
+ gs
->gimple_asm
.no
, clobber_op
);
2657 /* Return the string representing the assembly instruction in
2660 static inline const char *
2661 gimple_asm_string (const_gimple gs
)
2663 GIMPLE_CHECK (gs
, GIMPLE_ASM
);
2664 return gs
->gimple_asm
.string
;
2668 /* Return true if GS is an asm statement marked volatile. */
2671 gimple_asm_volatile_p (const_gimple gs
)
2673 GIMPLE_CHECK (gs
, GIMPLE_ASM
);
2674 return (gs
->gsbase
.subcode
& GF_ASM_VOLATILE
) != 0;
2678 /* If VOLATLE_P is true, mark asm statement GS as volatile. */
2681 gimple_asm_set_volatile (gimple gs
, bool volatile_p
)
2683 GIMPLE_CHECK (gs
, GIMPLE_ASM
);
2685 gs
->gsbase
.subcode
|= GF_ASM_VOLATILE
;
2687 gs
->gsbase
.subcode
&= ~GF_ASM_VOLATILE
;
2691 /* If INPUT_P is true, mark asm GS as an ASM_INPUT. */
2694 gimple_asm_set_input (gimple gs
, bool input_p
)
2696 GIMPLE_CHECK (gs
, GIMPLE_ASM
);
2698 gs
->gsbase
.subcode
|= GF_ASM_INPUT
;
2700 gs
->gsbase
.subcode
&= ~GF_ASM_INPUT
;
2704 /* Return true if asm GS is an ASM_INPUT. */
2707 gimple_asm_input_p (const_gimple gs
)
2709 GIMPLE_CHECK (gs
, GIMPLE_ASM
);
2710 return (gs
->gsbase
.subcode
& GF_ASM_INPUT
) != 0;
2714 /* Return the types handled by GIMPLE_CATCH statement GS. */
2717 gimple_catch_types (const_gimple gs
)
2719 GIMPLE_CHECK (gs
, GIMPLE_CATCH
);
2720 return gs
->gimple_catch
.types
;
2724 /* Return a pointer to the types handled by GIMPLE_CATCH statement GS. */
2726 static inline tree
*
2727 gimple_catch_types_ptr (gimple gs
)
2729 GIMPLE_CHECK (gs
, GIMPLE_CATCH
);
2730 return &gs
->gimple_catch
.types
;
2734 /* Return the GIMPLE sequence representing the body of the handler of
2735 GIMPLE_CATCH statement GS. */
2737 static inline gimple_seq
2738 gimple_catch_handler (gimple gs
)
2740 GIMPLE_CHECK (gs
, GIMPLE_CATCH
);
2741 return gs
->gimple_catch
.handler
;
2745 /* Return a pointer to the GIMPLE sequence representing the body of
2746 the handler of GIMPLE_CATCH statement GS. */
2748 static inline gimple_seq
*
2749 gimple_catch_handler_ptr (gimple gs
)
2751 GIMPLE_CHECK (gs
, GIMPLE_CATCH
);
2752 return &gs
->gimple_catch
.handler
;
2756 /* Set T to be the set of types handled by GIMPLE_CATCH GS. */
2759 gimple_catch_set_types (gimple gs
, tree t
)
2761 GIMPLE_CHECK (gs
, GIMPLE_CATCH
);
2762 gs
->gimple_catch
.types
= t
;
2766 /* Set HANDLER to be the body of GIMPLE_CATCH GS. */
2769 gimple_catch_set_handler (gimple gs
, gimple_seq handler
)
2771 GIMPLE_CHECK (gs
, GIMPLE_CATCH
);
2772 gs
->gimple_catch
.handler
= handler
;
2776 /* Return the types handled by GIMPLE_EH_FILTER statement GS. */
2779 gimple_eh_filter_types (const_gimple gs
)
2781 GIMPLE_CHECK (gs
, GIMPLE_EH_FILTER
);
2782 return gs
->gimple_eh_filter
.types
;
2786 /* Return a pointer to the types handled by GIMPLE_EH_FILTER statement
2789 static inline tree
*
2790 gimple_eh_filter_types_ptr (gimple gs
)
2792 GIMPLE_CHECK (gs
, GIMPLE_EH_FILTER
);
2793 return &gs
->gimple_eh_filter
.types
;
2797 /* Return the sequence of statement to execute when GIMPLE_EH_FILTER
2800 static inline gimple_seq
2801 gimple_eh_filter_failure (gimple gs
)
2803 GIMPLE_CHECK (gs
, GIMPLE_EH_FILTER
);
2804 return gs
->gimple_eh_filter
.failure
;
2808 /* Set TYPES to be the set of types handled by GIMPLE_EH_FILTER GS. */
2811 gimple_eh_filter_set_types (gimple gs
, tree types
)
2813 GIMPLE_CHECK (gs
, GIMPLE_EH_FILTER
);
2814 gs
->gimple_eh_filter
.types
= types
;
2818 /* Set FAILURE to be the sequence of statements to execute on failure
2819 for GIMPLE_EH_FILTER GS. */
2822 gimple_eh_filter_set_failure (gimple gs
, gimple_seq failure
)
2824 GIMPLE_CHECK (gs
, GIMPLE_EH_FILTER
);
2825 gs
->gimple_eh_filter
.failure
= failure
;
2828 /* Return the EH_FILTER_MUST_NOT_THROW flag. */
2832 gimple_eh_filter_must_not_throw (gimple gs
)
2834 GIMPLE_CHECK (gs
, GIMPLE_EH_FILTER
);
2835 return gs
->gsbase
.subcode
!= 0;
2838 /* Set the EH_FILTER_MUST_NOT_THROW flag to the value MNTP. */
2841 gimple_eh_filter_set_must_not_throw (gimple gs
, bool mntp
)
2843 GIMPLE_CHECK (gs
, GIMPLE_EH_FILTER
);
2844 gs
->gsbase
.subcode
= (unsigned int) mntp
;
2848 /* GIMPLE_TRY accessors. */
2850 /* Return the kind of try block represented by GIMPLE_TRY GS. This is
2851 either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY. */
2853 static inline enum gimple_try_flags
2854 gimple_try_kind (const_gimple gs
)
2856 GIMPLE_CHECK (gs
, GIMPLE_TRY
);
2857 return (enum gimple_try_flags
) (gs
->gsbase
.subcode
& GIMPLE_TRY_KIND
);
2861 /* Set the kind of try block represented by GIMPLE_TRY GS. */
2864 gimple_try_set_kind (gimple gs
, enum gimple_try_flags kind
)
2866 GIMPLE_CHECK (gs
, GIMPLE_TRY
);
2867 gcc_assert (kind
== GIMPLE_TRY_CATCH
|| kind
== GIMPLE_TRY_FINALLY
);
2868 if (gimple_try_kind (gs
) != kind
)
2869 gs
->gsbase
.subcode
= (unsigned int) kind
;
2873 /* Return the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2876 gimple_try_catch_is_cleanup (const_gimple gs
)
2878 gcc_assert (gimple_try_kind (gs
) == GIMPLE_TRY_CATCH
);
2879 return (gs
->gsbase
.subcode
& GIMPLE_TRY_CATCH_IS_CLEANUP
) != 0;
2883 /* Return the sequence of statements used as the body for GIMPLE_TRY GS. */
2885 static inline gimple_seq
2886 gimple_try_eval (gimple gs
)
2888 GIMPLE_CHECK (gs
, GIMPLE_TRY
);
2889 return gs
->gimple_try
.eval
;
2893 /* Return the sequence of statements used as the cleanup body for
2896 static inline gimple_seq
2897 gimple_try_cleanup (gimple gs
)
2899 GIMPLE_CHECK (gs
, GIMPLE_TRY
);
2900 return gs
->gimple_try
.cleanup
;
2904 /* Set the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2907 gimple_try_set_catch_is_cleanup (gimple g
, bool catch_is_cleanup
)
2909 gcc_assert (gimple_try_kind (g
) == GIMPLE_TRY_CATCH
);
2910 if (catch_is_cleanup
)
2911 g
->gsbase
.subcode
|= GIMPLE_TRY_CATCH_IS_CLEANUP
;
2913 g
->gsbase
.subcode
&= ~GIMPLE_TRY_CATCH_IS_CLEANUP
;
2917 /* Set EVAL to be the sequence of statements to use as the body for
2921 gimple_try_set_eval (gimple gs
, gimple_seq eval
)
2923 GIMPLE_CHECK (gs
, GIMPLE_TRY
);
2924 gs
->gimple_try
.eval
= eval
;
2928 /* Set CLEANUP to be the sequence of statements to use as the cleanup
2929 body for GIMPLE_TRY GS. */
2932 gimple_try_set_cleanup (gimple gs
, gimple_seq cleanup
)
2934 GIMPLE_CHECK (gs
, GIMPLE_TRY
);
2935 gs
->gimple_try
.cleanup
= cleanup
;
2939 /* Return the cleanup sequence for cleanup statement GS. */
2941 static inline gimple_seq
2942 gimple_wce_cleanup (gimple gs
)
2944 GIMPLE_CHECK (gs
, GIMPLE_WITH_CLEANUP_EXPR
);
2945 return gs
->gimple_wce
.cleanup
;
2949 /* Set CLEANUP to be the cleanup sequence for GS. */
2952 gimple_wce_set_cleanup (gimple gs
, gimple_seq cleanup
)
2954 GIMPLE_CHECK (gs
, GIMPLE_WITH_CLEANUP_EXPR
);
2955 gs
->gimple_wce
.cleanup
= cleanup
;
2959 /* Return the CLEANUP_EH_ONLY flag for a WCE tuple. */
2962 gimple_wce_cleanup_eh_only (const_gimple gs
)
2964 GIMPLE_CHECK (gs
, GIMPLE_WITH_CLEANUP_EXPR
);
2965 return gs
->gsbase
.subcode
!= 0;
2969 /* Set the CLEANUP_EH_ONLY flag for a WCE tuple. */
2972 gimple_wce_set_cleanup_eh_only (gimple gs
, bool eh_only_p
)
2974 GIMPLE_CHECK (gs
, GIMPLE_WITH_CLEANUP_EXPR
);
2975 gs
->gsbase
.subcode
= (unsigned int) eh_only_p
;
2979 /* Return the maximum number of arguments supported by GIMPLE_PHI GS. */
2981 static inline unsigned
2982 gimple_phi_capacity (const_gimple gs
)
2984 GIMPLE_CHECK (gs
, GIMPLE_PHI
);
2985 return gs
->gimple_phi
.capacity
;
2989 /* Return the number of arguments in GIMPLE_PHI GS. This must always
2990 be exactly the number of incoming edges for the basic block holding
2993 static inline unsigned
2994 gimple_phi_num_args (const_gimple gs
)
2996 GIMPLE_CHECK (gs
, GIMPLE_PHI
);
2997 return gs
->gimple_phi
.nargs
;
3001 /* Return the SSA name created by GIMPLE_PHI GS. */
3004 gimple_phi_result (const_gimple gs
)
3006 GIMPLE_CHECK (gs
, GIMPLE_PHI
);
3007 return gs
->gimple_phi
.result
;
3010 /* Return a pointer to the SSA name created by GIMPLE_PHI GS. */
3012 static inline tree
*
3013 gimple_phi_result_ptr (gimple gs
)
3015 GIMPLE_CHECK (gs
, GIMPLE_PHI
);
3016 return &gs
->gimple_phi
.result
;
3019 /* Set RESULT to be the SSA name created by GIMPLE_PHI GS. */
3022 gimple_phi_set_result (gimple gs
, tree result
)
3024 GIMPLE_CHECK (gs
, GIMPLE_PHI
);
3025 gs
->gimple_phi
.result
= result
;
3029 /* Return the PHI argument corresponding to incoming edge INDEX for
3032 static inline struct phi_arg_d
*
3033 gimple_phi_arg (gimple gs
, unsigned index
)
3035 GIMPLE_CHECK (gs
, GIMPLE_PHI
);
3036 gcc_assert (index
<= gs
->gimple_phi
.capacity
);
3037 return &(gs
->gimple_phi
.args
[index
]);
3040 /* Set PHIARG to be the argument corresponding to incoming edge INDEX
3041 for GIMPLE_PHI GS. */
3044 gimple_phi_set_arg (gimple gs
, unsigned index
, struct phi_arg_d
* phiarg
)
3046 GIMPLE_CHECK (gs
, GIMPLE_PHI
);
3047 gcc_assert (index
<= gs
->gimple_phi
.nargs
);
3048 memcpy (gs
->gimple_phi
.args
+ index
, phiarg
, sizeof (struct phi_arg_d
));
3051 /* Return the region number for GIMPLE_RESX GS. */
3054 gimple_resx_region (const_gimple gs
)
3056 GIMPLE_CHECK (gs
, GIMPLE_RESX
);
3057 return gs
->gimple_resx
.region
;
3060 /* Set REGION to be the region number for GIMPLE_RESX GS. */
3063 gimple_resx_set_region (gimple gs
, int region
)
3065 GIMPLE_CHECK (gs
, GIMPLE_RESX
);
3066 gs
->gimple_resx
.region
= region
;
3070 /* Return the number of labels associated with the switch statement GS. */
3072 static inline unsigned
3073 gimple_switch_num_labels (const_gimple gs
)
3076 GIMPLE_CHECK (gs
, GIMPLE_SWITCH
);
3077 num_ops
= gimple_num_ops (gs
);
3078 gcc_assert (num_ops
> 1);
3083 /* Set NLABELS to be the number of labels for the switch statement GS. */
3086 gimple_switch_set_num_labels (gimple g
, unsigned nlabels
)
3088 GIMPLE_CHECK (g
, GIMPLE_SWITCH
);
3089 gimple_set_num_ops (g
, nlabels
+ 1);
3093 /* Return the index variable used by the switch statement GS. */
3096 gimple_switch_index (const_gimple gs
)
3098 GIMPLE_CHECK (gs
, GIMPLE_SWITCH
);
3099 return gimple_op (gs
, 0);
3103 /* Return a pointer to the index variable for the switch statement GS. */
3105 static inline tree
*
3106 gimple_switch_index_ptr (const_gimple gs
)
3108 GIMPLE_CHECK (gs
, GIMPLE_SWITCH
);
3109 return gimple_op_ptr (gs
, 0);
3113 /* Set INDEX to be the index variable for switch statement GS. */
3116 gimple_switch_set_index (gimple gs
, tree index
)
3118 GIMPLE_CHECK (gs
, GIMPLE_SWITCH
);
3119 gcc_assert (SSA_VAR_P (index
) || CONSTANT_CLASS_P (index
));
3120 gimple_set_op (gs
, 0, index
);
3124 /* Return the label numbered INDEX. The default label is 0, followed by any
3125 labels in a switch statement. */
3128 gimple_switch_label (const_gimple gs
, unsigned index
)
3130 GIMPLE_CHECK (gs
, GIMPLE_SWITCH
);
3131 gcc_assert (gimple_num_ops (gs
) > index
+ 1);
3132 return gimple_op (gs
, index
+ 1);
3135 /* Set the label number INDEX to LABEL. 0 is always the default label. */
3138 gimple_switch_set_label (gimple gs
, unsigned index
, tree label
)
3140 GIMPLE_CHECK (gs
, GIMPLE_SWITCH
);
3141 gcc_assert (gimple_num_ops (gs
) > index
+ 1);
3142 gcc_assert (label
== NULL_TREE
|| TREE_CODE (label
) == CASE_LABEL_EXPR
);
3143 gimple_set_op (gs
, index
+ 1, label
);
3146 /* Return the default label for a switch statement. */
3149 gimple_switch_default_label (const_gimple gs
)
3151 return gimple_switch_label (gs
, 0);
3154 /* Set the default label for a switch statement. */
3157 gimple_switch_set_default_label (gimple gs
, tree label
)
3159 gimple_switch_set_label (gs
, 0, label
);
3163 /* Return the body for the OMP statement GS. */
3165 static inline gimple_seq
3166 gimple_omp_body (gimple gs
)
3168 return gs
->omp
.body
;
3171 /* Set BODY to be the body for the OMP statement GS. */
3174 gimple_omp_set_body (gimple gs
, gimple_seq body
)
3176 gs
->omp
.body
= body
;
3180 /* Return the name associated with OMP_CRITICAL statement GS. */
3183 gimple_omp_critical_name (const_gimple gs
)
3185 GIMPLE_CHECK (gs
, GIMPLE_OMP_CRITICAL
);
3186 return gs
->gimple_omp_critical
.name
;
3190 /* Return a pointer to the name associated with OMP critical statement GS. */
3192 static inline tree
*
3193 gimple_omp_critical_name_ptr (gimple gs
)
3195 GIMPLE_CHECK (gs
, GIMPLE_OMP_CRITICAL
);
3196 return &gs
->gimple_omp_critical
.name
;
3200 /* Set NAME to be the name associated with OMP critical statement GS. */
3203 gimple_omp_critical_set_name (gimple gs
, tree name
)
3205 GIMPLE_CHECK (gs
, GIMPLE_OMP_CRITICAL
);
3206 gs
->gimple_omp_critical
.name
= name
;
3210 /* Return the clauses associated with OMP_FOR GS. */
3213 gimple_omp_for_clauses (const_gimple gs
)
3215 GIMPLE_CHECK (gs
, GIMPLE_OMP_FOR
);
3216 return gs
->gimple_omp_for
.clauses
;
3220 /* Return a pointer to the OMP_FOR GS. */
3222 static inline tree
*
3223 gimple_omp_for_clauses_ptr (gimple gs
)
3225 GIMPLE_CHECK (gs
, GIMPLE_OMP_FOR
);
3226 return &gs
->gimple_omp_for
.clauses
;
3230 /* Set CLAUSES to be the list of clauses associated with OMP_FOR GS. */
3233 gimple_omp_for_set_clauses (gimple gs
, tree clauses
)
3235 GIMPLE_CHECK (gs
, GIMPLE_OMP_FOR
);
3236 gs
->gimple_omp_for
.clauses
= clauses
;
3240 /* Get the collapse count of OMP_FOR GS. */
3242 static inline size_t
3243 gimple_omp_for_collapse (gimple gs
)
3245 GIMPLE_CHECK (gs
, GIMPLE_OMP_FOR
);
3246 return gs
->gimple_omp_for
.collapse
;
3250 /* Return the index variable for OMP_FOR GS. */
3253 gimple_omp_for_index (const_gimple gs
, size_t i
)
3255 GIMPLE_CHECK (gs
, GIMPLE_OMP_FOR
);
3256 gcc_assert (i
< gs
->gimple_omp_for
.collapse
);
3257 return gs
->gimple_omp_for
.iter
[i
].index
;
3261 /* Return a pointer to the index variable for OMP_FOR GS. */
3263 static inline tree
*
3264 gimple_omp_for_index_ptr (gimple gs
, size_t i
)
3266 GIMPLE_CHECK (gs
, GIMPLE_OMP_FOR
);
3267 gcc_assert (i
< gs
->gimple_omp_for
.collapse
);
3268 return &gs
->gimple_omp_for
.iter
[i
].index
;
3272 /* Set INDEX to be the index variable for OMP_FOR GS. */
3275 gimple_omp_for_set_index (gimple gs
, size_t i
, tree index
)
3277 GIMPLE_CHECK (gs
, GIMPLE_OMP_FOR
);
3278 gcc_assert (i
< gs
->gimple_omp_for
.collapse
);
3279 gs
->gimple_omp_for
.iter
[i
].index
= index
;
3283 /* Return the initial value for OMP_FOR GS. */
3286 gimple_omp_for_initial (const_gimple gs
, size_t i
)
3288 GIMPLE_CHECK (gs
, GIMPLE_OMP_FOR
);
3289 gcc_assert (i
< gs
->gimple_omp_for
.collapse
);
3290 return gs
->gimple_omp_for
.iter
[i
].initial
;
3294 /* Return a pointer to the initial value for OMP_FOR GS. */
3296 static inline tree
*
3297 gimple_omp_for_initial_ptr (gimple gs
, size_t i
)
3299 GIMPLE_CHECK (gs
, GIMPLE_OMP_FOR
);
3300 gcc_assert (i
< gs
->gimple_omp_for
.collapse
);
3301 return &gs
->gimple_omp_for
.iter
[i
].initial
;
3305 /* Set INITIAL to be the initial value for OMP_FOR GS. */
3308 gimple_omp_for_set_initial (gimple gs
, size_t i
, tree initial
)
3310 GIMPLE_CHECK (gs
, GIMPLE_OMP_FOR
);
3311 gcc_assert (i
< gs
->gimple_omp_for
.collapse
);
3312 gs
->gimple_omp_for
.iter
[i
].initial
= initial
;
3316 /* Return the final value for OMP_FOR GS. */
3319 gimple_omp_for_final (const_gimple gs
, size_t i
)
3321 GIMPLE_CHECK (gs
, GIMPLE_OMP_FOR
);
3322 gcc_assert (i
< gs
->gimple_omp_for
.collapse
);
3323 return gs
->gimple_omp_for
.iter
[i
].final
;
3327 /* Return a pointer to the final value for OMP_FOR GS. */
3329 static inline tree
*
3330 gimple_omp_for_final_ptr (gimple gs
, size_t i
)
3332 GIMPLE_CHECK (gs
, GIMPLE_OMP_FOR
);
3333 gcc_assert (i
< gs
->gimple_omp_for
.collapse
);
3334 return &gs
->gimple_omp_for
.iter
[i
].final
;
3338 /* Set FINAL to be the final value for OMP_FOR GS. */
3341 gimple_omp_for_set_final (gimple gs
, size_t i
, tree final
)
3343 GIMPLE_CHECK (gs
, GIMPLE_OMP_FOR
);
3344 gcc_assert (i
< gs
->gimple_omp_for
.collapse
);
3345 gs
->gimple_omp_for
.iter
[i
].final
= final
;
3349 /* Return the increment value for OMP_FOR GS. */
3352 gimple_omp_for_incr (const_gimple gs
, size_t i
)
3354 GIMPLE_CHECK (gs
, GIMPLE_OMP_FOR
);
3355 gcc_assert (i
< gs
->gimple_omp_for
.collapse
);
3356 return gs
->gimple_omp_for
.iter
[i
].incr
;
3360 /* Return a pointer to the increment value for OMP_FOR GS. */
3362 static inline tree
*
3363 gimple_omp_for_incr_ptr (gimple gs
, size_t i
)
3365 GIMPLE_CHECK (gs
, GIMPLE_OMP_FOR
);
3366 gcc_assert (i
< gs
->gimple_omp_for
.collapse
);
3367 return &gs
->gimple_omp_for
.iter
[i
].incr
;
3371 /* Set INCR to be the increment value for OMP_FOR GS. */
3374 gimple_omp_for_set_incr (gimple gs
, size_t i
, tree incr
)
3376 GIMPLE_CHECK (gs
, GIMPLE_OMP_FOR
);
3377 gcc_assert (i
< gs
->gimple_omp_for
.collapse
);
3378 gs
->gimple_omp_for
.iter
[i
].incr
= incr
;
3382 /* Return the sequence of statements to execute before the OMP_FOR
3383 statement GS starts. */
3385 static inline gimple_seq
3386 gimple_omp_for_pre_body (gimple gs
)
3388 GIMPLE_CHECK (gs
, GIMPLE_OMP_FOR
);
3389 return gs
->gimple_omp_for
.pre_body
;
3393 /* Set PRE_BODY to be the sequence of statements to execute before the
3394 OMP_FOR statement GS starts. */
3397 gimple_omp_for_set_pre_body (gimple gs
, gimple_seq pre_body
)
3399 GIMPLE_CHECK (gs
, GIMPLE_OMP_FOR
);
3400 gs
->gimple_omp_for
.pre_body
= pre_body
;
3404 /* Return the clauses associated with OMP_PARALLEL GS. */
3407 gimple_omp_parallel_clauses (const_gimple gs
)
3409 GIMPLE_CHECK (gs
, GIMPLE_OMP_PARALLEL
);
3410 return gs
->gimple_omp_parallel
.clauses
;
3414 /* Return a pointer to the clauses associated with OMP_PARALLEL GS. */
3416 static inline tree
*
3417 gimple_omp_parallel_clauses_ptr (gimple gs
)
3419 GIMPLE_CHECK (gs
, GIMPLE_OMP_PARALLEL
);
3420 return &gs
->gimple_omp_parallel
.clauses
;
3424 /* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL
3428 gimple_omp_parallel_set_clauses (gimple gs
, tree clauses
)
3430 GIMPLE_CHECK (gs
, GIMPLE_OMP_PARALLEL
);
3431 gs
->gimple_omp_parallel
.clauses
= clauses
;
3435 /* Return the child function used to hold the body of OMP_PARALLEL GS. */
3438 gimple_omp_parallel_child_fn (const_gimple gs
)
3440 GIMPLE_CHECK (gs
, GIMPLE_OMP_PARALLEL
);
3441 return gs
->gimple_omp_parallel
.child_fn
;
3444 /* Return a pointer to the child function used to hold the body of
3447 static inline tree
*
3448 gimple_omp_parallel_child_fn_ptr (gimple gs
)
3450 GIMPLE_CHECK (gs
, GIMPLE_OMP_PARALLEL
);
3451 return &gs
->gimple_omp_parallel
.child_fn
;
3455 /* Set CHILD_FN to be the child function for OMP_PARALLEL GS. */
3458 gimple_omp_parallel_set_child_fn (gimple gs
, tree child_fn
)
3460 GIMPLE_CHECK (gs
, GIMPLE_OMP_PARALLEL
);
3461 gs
->gimple_omp_parallel
.child_fn
= child_fn
;
3465 /* Return the artificial argument used to send variables and values
3466 from the parent to the children threads in OMP_PARALLEL GS. */
3469 gimple_omp_parallel_data_arg (const_gimple gs
)
3471 GIMPLE_CHECK (gs
, GIMPLE_OMP_PARALLEL
);
3472 return gs
->gimple_omp_parallel
.data_arg
;
3476 /* Return a pointer to the data argument for OMP_PARALLEL GS. */
3478 static inline tree
*
3479 gimple_omp_parallel_data_arg_ptr (gimple gs
)
3481 GIMPLE_CHECK (gs
, GIMPLE_OMP_PARALLEL
);
3482 return &gs
->gimple_omp_parallel
.data_arg
;
3486 /* Set DATA_ARG to be the data argument for OMP_PARALLEL GS. */
3489 gimple_omp_parallel_set_data_arg (gimple gs
, tree data_arg
)
3491 GIMPLE_CHECK (gs
, GIMPLE_OMP_PARALLEL
);
3492 gs
->gimple_omp_parallel
.data_arg
= data_arg
;
3496 /* Return the clauses associated with OMP_TASK GS. */
3499 gimple_omp_task_clauses (const_gimple gs
)
3501 GIMPLE_CHECK (gs
, GIMPLE_OMP_TASK
);
3502 return gs
->gimple_omp_parallel
.clauses
;
3506 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3508 static inline tree
*
3509 gimple_omp_task_clauses_ptr (gimple gs
)
3511 GIMPLE_CHECK (gs
, GIMPLE_OMP_TASK
);
3512 return &gs
->gimple_omp_parallel
.clauses
;
3516 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3520 gimple_omp_task_set_clauses (gimple gs
, tree clauses
)
3522 GIMPLE_CHECK (gs
, GIMPLE_OMP_TASK
);
3523 gs
->gimple_omp_parallel
.clauses
= clauses
;
3527 /* Return the child function used to hold the body of OMP_TASK GS. */
3530 gimple_omp_task_child_fn (const_gimple gs
)
3532 GIMPLE_CHECK (gs
, GIMPLE_OMP_TASK
);
3533 return gs
->gimple_omp_parallel
.child_fn
;
3536 /* Return a pointer to the child function used to hold the body of
3539 static inline tree
*
3540 gimple_omp_task_child_fn_ptr (gimple gs
)
3542 GIMPLE_CHECK (gs
, GIMPLE_OMP_TASK
);
3543 return &gs
->gimple_omp_parallel
.child_fn
;
3547 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3550 gimple_omp_task_set_child_fn (gimple gs
, tree child_fn
)
3552 GIMPLE_CHECK (gs
, GIMPLE_OMP_TASK
);
3553 gs
->gimple_omp_parallel
.child_fn
= child_fn
;
3557 /* Return the artificial argument used to send variables and values
3558 from the parent to the children threads in OMP_TASK GS. */
3561 gimple_omp_task_data_arg (const_gimple gs
)
3563 GIMPLE_CHECK (gs
, GIMPLE_OMP_TASK
);
3564 return gs
->gimple_omp_parallel
.data_arg
;
3568 /* Return a pointer to the data argument for OMP_TASK GS. */
3570 static inline tree
*
3571 gimple_omp_task_data_arg_ptr (gimple gs
)
3573 GIMPLE_CHECK (gs
, GIMPLE_OMP_TASK
);
3574 return &gs
->gimple_omp_parallel
.data_arg
;
3578 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3581 gimple_omp_task_set_data_arg (gimple gs
, tree data_arg
)
3583 GIMPLE_CHECK (gs
, GIMPLE_OMP_TASK
);
3584 gs
->gimple_omp_parallel
.data_arg
= data_arg
;
3588 /* Return the clauses associated with OMP_TASK GS. */
3591 gimple_omp_taskreg_clauses (const_gimple gs
)
3593 if (gimple_code (gs
) != GIMPLE_OMP_PARALLEL
)
3594 GIMPLE_CHECK (gs
, GIMPLE_OMP_TASK
);
3595 return gs
->gimple_omp_parallel
.clauses
;
3599 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3601 static inline tree
*
3602 gimple_omp_taskreg_clauses_ptr (gimple gs
)
3604 if (gimple_code (gs
) != GIMPLE_OMP_PARALLEL
)
3605 GIMPLE_CHECK (gs
, GIMPLE_OMP_TASK
);
3606 return &gs
->gimple_omp_parallel
.clauses
;
3610 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3614 gimple_omp_taskreg_set_clauses (gimple gs
, tree clauses
)
3616 if (gimple_code (gs
) != GIMPLE_OMP_PARALLEL
)
3617 GIMPLE_CHECK (gs
, GIMPLE_OMP_TASK
);
3618 gs
->gimple_omp_parallel
.clauses
= clauses
;
3622 /* Return the child function used to hold the body of OMP_TASK GS. */
3625 gimple_omp_taskreg_child_fn (const_gimple gs
)
3627 if (gimple_code (gs
) != GIMPLE_OMP_PARALLEL
)
3628 GIMPLE_CHECK (gs
, GIMPLE_OMP_TASK
);
3629 return gs
->gimple_omp_parallel
.child_fn
;
3632 /* Return a pointer to the child function used to hold the body of
3635 static inline tree
*
3636 gimple_omp_taskreg_child_fn_ptr (gimple gs
)
3638 if (gimple_code (gs
) != GIMPLE_OMP_PARALLEL
)
3639 GIMPLE_CHECK (gs
, GIMPLE_OMP_TASK
);
3640 return &gs
->gimple_omp_parallel
.child_fn
;
3644 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3647 gimple_omp_taskreg_set_child_fn (gimple gs
, tree child_fn
)
3649 if (gimple_code (gs
) != GIMPLE_OMP_PARALLEL
)
3650 GIMPLE_CHECK (gs
, GIMPLE_OMP_TASK
);
3651 gs
->gimple_omp_parallel
.child_fn
= child_fn
;
3655 /* Return the artificial argument used to send variables and values
3656 from the parent to the children threads in OMP_TASK GS. */
3659 gimple_omp_taskreg_data_arg (const_gimple gs
)
3661 if (gimple_code (gs
) != GIMPLE_OMP_PARALLEL
)
3662 GIMPLE_CHECK (gs
, GIMPLE_OMP_TASK
);
3663 return gs
->gimple_omp_parallel
.data_arg
;
3667 /* Return a pointer to the data argument for OMP_TASK GS. */
3669 static inline tree
*
3670 gimple_omp_taskreg_data_arg_ptr (gimple gs
)
3672 if (gimple_code (gs
) != GIMPLE_OMP_PARALLEL
)
3673 GIMPLE_CHECK (gs
, GIMPLE_OMP_TASK
);
3674 return &gs
->gimple_omp_parallel
.data_arg
;
3678 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3681 gimple_omp_taskreg_set_data_arg (gimple gs
, tree data_arg
)
3683 if (gimple_code (gs
) != GIMPLE_OMP_PARALLEL
)
3684 GIMPLE_CHECK (gs
, GIMPLE_OMP_TASK
);
3685 gs
->gimple_omp_parallel
.data_arg
= data_arg
;
3689 /* Return the copy function used to hold the body of OMP_TASK GS. */
3692 gimple_omp_task_copy_fn (const_gimple gs
)
3694 GIMPLE_CHECK (gs
, GIMPLE_OMP_TASK
);
3695 return gs
->gimple_omp_task
.copy_fn
;
3698 /* Return a pointer to the copy function used to hold the body of
3701 static inline tree
*
3702 gimple_omp_task_copy_fn_ptr (gimple gs
)
3704 GIMPLE_CHECK (gs
, GIMPLE_OMP_TASK
);
3705 return &gs
->gimple_omp_task
.copy_fn
;
3709 /* Set CHILD_FN to be the copy function for OMP_TASK GS. */
3712 gimple_omp_task_set_copy_fn (gimple gs
, tree copy_fn
)
3714 GIMPLE_CHECK (gs
, GIMPLE_OMP_TASK
);
3715 gs
->gimple_omp_task
.copy_fn
= copy_fn
;
3719 /* Return size of the data block in bytes in OMP_TASK GS. */
3722 gimple_omp_task_arg_size (const_gimple gs
)
3724 GIMPLE_CHECK (gs
, GIMPLE_OMP_TASK
);
3725 return gs
->gimple_omp_task
.arg_size
;
3729 /* Return a pointer to the data block size for OMP_TASK GS. */
3731 static inline tree
*
3732 gimple_omp_task_arg_size_ptr (gimple gs
)
3734 GIMPLE_CHECK (gs
, GIMPLE_OMP_TASK
);
3735 return &gs
->gimple_omp_task
.arg_size
;
3739 /* Set ARG_SIZE to be the data block size for OMP_TASK GS. */
3742 gimple_omp_task_set_arg_size (gimple gs
, tree arg_size
)
3744 GIMPLE_CHECK (gs
, GIMPLE_OMP_TASK
);
3745 gs
->gimple_omp_task
.arg_size
= arg_size
;
3749 /* Return align of the data block in bytes in OMP_TASK GS. */
3752 gimple_omp_task_arg_align (const_gimple gs
)
3754 GIMPLE_CHECK (gs
, GIMPLE_OMP_TASK
);
3755 return gs
->gimple_omp_task
.arg_align
;
3759 /* Return a pointer to the data block align for OMP_TASK GS. */
3761 static inline tree
*
3762 gimple_omp_task_arg_align_ptr (gimple gs
)
3764 GIMPLE_CHECK (gs
, GIMPLE_OMP_TASK
);
3765 return &gs
->gimple_omp_task
.arg_align
;
3769 /* Set ARG_SIZE to be the data block align for OMP_TASK GS. */
3772 gimple_omp_task_set_arg_align (gimple gs
, tree arg_align
)
3774 GIMPLE_CHECK (gs
, GIMPLE_OMP_TASK
);
3775 gs
->gimple_omp_task
.arg_align
= arg_align
;
3779 /* Return the clauses associated with OMP_SINGLE GS. */
3782 gimple_omp_single_clauses (const_gimple gs
)
3784 GIMPLE_CHECK (gs
, GIMPLE_OMP_SINGLE
);
3785 return gs
->gimple_omp_single
.clauses
;
3789 /* Return a pointer to the clauses associated with OMP_SINGLE GS. */
3791 static inline tree
*
3792 gimple_omp_single_clauses_ptr (gimple gs
)
3794 GIMPLE_CHECK (gs
, GIMPLE_OMP_SINGLE
);
3795 return &gs
->gimple_omp_single
.clauses
;
3799 /* Set CLAUSES to be the clauses associated with OMP_SINGLE GS. */
3802 gimple_omp_single_set_clauses (gimple gs
, tree clauses
)
3804 GIMPLE_CHECK (gs
, GIMPLE_OMP_SINGLE
);
3805 gs
->gimple_omp_single
.clauses
= clauses
;
3809 /* Return the clauses associated with OMP_SECTIONS GS. */
3812 gimple_omp_sections_clauses (const_gimple gs
)
3814 GIMPLE_CHECK (gs
, GIMPLE_OMP_SECTIONS
);
3815 return gs
->gimple_omp_sections
.clauses
;
3819 /* Return a pointer to the clauses associated with OMP_SECTIONS GS. */
3821 static inline tree
*
3822 gimple_omp_sections_clauses_ptr (gimple gs
)
3824 GIMPLE_CHECK (gs
, GIMPLE_OMP_SECTIONS
);
3825 return &gs
->gimple_omp_sections
.clauses
;
3829 /* Set CLAUSES to be the set of clauses associated with OMP_SECTIONS
3833 gimple_omp_sections_set_clauses (gimple gs
, tree clauses
)
3835 GIMPLE_CHECK (gs
, GIMPLE_OMP_SECTIONS
);
3836 gs
->gimple_omp_sections
.clauses
= clauses
;
3840 /* Return the control variable associated with the GIMPLE_OMP_SECTIONS
3844 gimple_omp_sections_control (const_gimple gs
)
3846 GIMPLE_CHECK (gs
, GIMPLE_OMP_SECTIONS
);
3847 return gs
->gimple_omp_sections
.control
;
3851 /* Return a pointer to the clauses associated with the GIMPLE_OMP_SECTIONS
3854 static inline tree
*
3855 gimple_omp_sections_control_ptr (gimple gs
)
3857 GIMPLE_CHECK (gs
, GIMPLE_OMP_SECTIONS
);
3858 return &gs
->gimple_omp_sections
.control
;
3862 /* Set CONTROL to be the set of clauses associated with the
3863 GIMPLE_OMP_SECTIONS in GS. */
3866 gimple_omp_sections_set_control (gimple gs
, tree control
)
3868 GIMPLE_CHECK (gs
, GIMPLE_OMP_SECTIONS
);
3869 gs
->gimple_omp_sections
.control
= control
;
3873 /* Set COND to be the condition code for OMP_FOR GS. */
3876 gimple_omp_for_set_cond (gimple gs
, size_t i
, enum tree_code cond
)
3878 GIMPLE_CHECK (gs
, GIMPLE_OMP_FOR
);
3879 gcc_assert (TREE_CODE_CLASS (cond
) == tcc_comparison
);
3880 gcc_assert (i
< gs
->gimple_omp_for
.collapse
);
3881 gs
->gimple_omp_for
.iter
[i
].cond
= cond
;
3885 /* Return the condition code associated with OMP_FOR GS. */
3887 static inline enum tree_code
3888 gimple_omp_for_cond (const_gimple gs
, size_t i
)
3890 GIMPLE_CHECK (gs
, GIMPLE_OMP_FOR
);
3891 gcc_assert (i
< gs
->gimple_omp_for
.collapse
);
3892 return gs
->gimple_omp_for
.iter
[i
].cond
;
3896 /* Set the value being stored in an atomic store. */
3899 gimple_omp_atomic_store_set_val (gimple g
, tree val
)
3901 GIMPLE_CHECK (g
, GIMPLE_OMP_ATOMIC_STORE
);
3902 g
->gimple_omp_atomic_store
.val
= val
;
3906 /* Return the value being stored in an atomic store. */
3909 gimple_omp_atomic_store_val (const_gimple g
)
3911 GIMPLE_CHECK (g
, GIMPLE_OMP_ATOMIC_STORE
);
3912 return g
->gimple_omp_atomic_store
.val
;
3916 /* Return a pointer to the value being stored in an atomic store. */
3918 static inline tree
*
3919 gimple_omp_atomic_store_val_ptr (gimple g
)
3921 GIMPLE_CHECK (g
, GIMPLE_OMP_ATOMIC_STORE
);
3922 return &g
->gimple_omp_atomic_store
.val
;
3926 /* Set the LHS of an atomic load. */
3929 gimple_omp_atomic_load_set_lhs (gimple g
, tree lhs
)
3931 GIMPLE_CHECK (g
, GIMPLE_OMP_ATOMIC_LOAD
);
3932 g
->gimple_omp_atomic_load
.lhs
= lhs
;
3936 /* Get the LHS of an atomic load. */
3939 gimple_omp_atomic_load_lhs (const_gimple g
)
3941 GIMPLE_CHECK (g
, GIMPLE_OMP_ATOMIC_LOAD
);
3942 return g
->gimple_omp_atomic_load
.lhs
;
3946 /* Return a pointer to the LHS of an atomic load. */
3948 static inline tree
*
3949 gimple_omp_atomic_load_lhs_ptr (gimple g
)
3951 GIMPLE_CHECK (g
, GIMPLE_OMP_ATOMIC_LOAD
);
3952 return &g
->gimple_omp_atomic_load
.lhs
;
3956 /* Set the RHS of an atomic load. */
3959 gimple_omp_atomic_load_set_rhs (gimple g
, tree rhs
)
3961 GIMPLE_CHECK (g
, GIMPLE_OMP_ATOMIC_LOAD
);
3962 g
->gimple_omp_atomic_load
.rhs
= rhs
;
3966 /* Get the RHS of an atomic load. */
3969 gimple_omp_atomic_load_rhs (const_gimple g
)
3971 GIMPLE_CHECK (g
, GIMPLE_OMP_ATOMIC_LOAD
);
3972 return g
->gimple_omp_atomic_load
.rhs
;
3976 /* Return a pointer to the RHS of an atomic load. */
3978 static inline tree
*
3979 gimple_omp_atomic_load_rhs_ptr (gimple g
)
3981 GIMPLE_CHECK (g
, GIMPLE_OMP_ATOMIC_LOAD
);
3982 return &g
->gimple_omp_atomic_load
.rhs
;
3986 /* Get the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
3989 gimple_omp_continue_control_def (const_gimple g
)
3991 GIMPLE_CHECK (g
, GIMPLE_OMP_CONTINUE
);
3992 return g
->gimple_omp_continue
.control_def
;
3995 /* The same as above, but return the address. */
3997 static inline tree
*
3998 gimple_omp_continue_control_def_ptr (gimple g
)
4000 GIMPLE_CHECK (g
, GIMPLE_OMP_CONTINUE
);
4001 return &g
->gimple_omp_continue
.control_def
;
4004 /* Set the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4007 gimple_omp_continue_set_control_def (gimple g
, tree def
)
4009 GIMPLE_CHECK (g
, GIMPLE_OMP_CONTINUE
);
4010 g
->gimple_omp_continue
.control_def
= def
;
4014 /* Get the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4017 gimple_omp_continue_control_use (const_gimple g
)
4019 GIMPLE_CHECK (g
, GIMPLE_OMP_CONTINUE
);
4020 return g
->gimple_omp_continue
.control_use
;
4024 /* The same as above, but return the address. */
4026 static inline tree
*
4027 gimple_omp_continue_control_use_ptr (gimple g
)
4029 GIMPLE_CHECK (g
, GIMPLE_OMP_CONTINUE
);
4030 return &g
->gimple_omp_continue
.control_use
;
4034 /* Set the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4037 gimple_omp_continue_set_control_use (gimple g
, tree use
)
4039 GIMPLE_CHECK (g
, GIMPLE_OMP_CONTINUE
);
4040 g
->gimple_omp_continue
.control_use
= use
;
4044 /* Return a pointer to the return value for GIMPLE_RETURN GS. */
4046 static inline tree
*
4047 gimple_return_retval_ptr (const_gimple gs
)
4049 GIMPLE_CHECK (gs
, GIMPLE_RETURN
);
4050 gcc_assert (gimple_num_ops (gs
) == 1);
4051 return gimple_op_ptr (gs
, 0);
4054 /* Return the return value for GIMPLE_RETURN GS. */
4057 gimple_return_retval (const_gimple gs
)
4059 GIMPLE_CHECK (gs
, GIMPLE_RETURN
);
4060 gcc_assert (gimple_num_ops (gs
) == 1);
4061 return gimple_op (gs
, 0);
4065 /* Set RETVAL to be the return value for GIMPLE_RETURN GS. */
4068 gimple_return_set_retval (gimple gs
, tree retval
)
4070 GIMPLE_CHECK (gs
, GIMPLE_RETURN
);
4071 gcc_assert (gimple_num_ops (gs
) == 1);
4072 gcc_assert (retval
== NULL_TREE
4073 || TREE_CODE (retval
) == RESULT_DECL
4074 || is_gimple_val (retval
));
4075 gimple_set_op (gs
, 0, retval
);
4079 /* Returns true when the gimple statment STMT is any of the OpenMP types. */
4082 is_gimple_omp (const_gimple stmt
)
4084 return (gimple_code (stmt
) == GIMPLE_OMP_PARALLEL
4085 || gimple_code (stmt
) == GIMPLE_OMP_TASK
4086 || gimple_code (stmt
) == GIMPLE_OMP_FOR
4087 || gimple_code (stmt
) == GIMPLE_OMP_SECTIONS
4088 || gimple_code (stmt
) == GIMPLE_OMP_SECTIONS_SWITCH
4089 || gimple_code (stmt
) == GIMPLE_OMP_SINGLE
4090 || gimple_code (stmt
) == GIMPLE_OMP_SECTION
4091 || gimple_code (stmt
) == GIMPLE_OMP_MASTER
4092 || gimple_code (stmt
) == GIMPLE_OMP_ORDERED
4093 || gimple_code (stmt
) == GIMPLE_OMP_CRITICAL
4094 || gimple_code (stmt
) == GIMPLE_OMP_RETURN
4095 || gimple_code (stmt
) == GIMPLE_OMP_ATOMIC_LOAD
4096 || gimple_code (stmt
) == GIMPLE_OMP_ATOMIC_STORE
4097 || gimple_code (stmt
) == GIMPLE_OMP_CONTINUE
);
4101 /* Returns TRUE if statement G is a GIMPLE_NOP. */
4104 gimple_nop_p (const_gimple g
)
4106 return gimple_code (g
) == GIMPLE_NOP
;
4110 /* Return the predictor of GIMPLE_PREDICT statement GS. */
4112 static inline enum br_predictor
4113 gimple_predict_predictor (gimple gs
)
4115 GIMPLE_CHECK (gs
, GIMPLE_PREDICT
);
4116 return (enum br_predictor
) (gs
->gsbase
.subcode
& ~GF_PREDICT_TAKEN
);
4120 /* Set the predictor of GIMPLE_PREDICT statement GS to PREDICT. */
4123 gimple_predict_set_predictor (gimple gs
, enum br_predictor predictor
)
4125 GIMPLE_CHECK (gs
, GIMPLE_PREDICT
);
4126 gs
->gsbase
.subcode
= (gs
->gsbase
.subcode
& GF_PREDICT_TAKEN
)
4127 | (unsigned) predictor
;
4131 /* Return the outcome of GIMPLE_PREDICT statement GS. */
4133 static inline enum prediction
4134 gimple_predict_outcome (gimple gs
)
4136 GIMPLE_CHECK (gs
, GIMPLE_PREDICT
);
4137 return (gs
->gsbase
.subcode
& GF_PREDICT_TAKEN
) ? TAKEN
: NOT_TAKEN
;
4141 /* Set the outcome of GIMPLE_PREDICT statement GS to OUTCOME. */
4144 gimple_predict_set_outcome (gimple gs
, enum prediction outcome
)
4146 GIMPLE_CHECK (gs
, GIMPLE_PREDICT
);
4147 if (outcome
== TAKEN
)
4148 gs
->gsbase
.subcode
|= GF_PREDICT_TAKEN
;
4150 gs
->gsbase
.subcode
&= ~GF_PREDICT_TAKEN
;
4154 /* Return the type of the main expression computed by STMT. Return
4155 void_type_node if the statement computes nothing. */
4158 gimple_expr_type (const_gimple stmt
)
4160 enum gimple_code code
= gimple_code (stmt
);
4162 if (code
== GIMPLE_ASSIGN
|| code
== GIMPLE_CALL
)
4165 /* In general we want to pass out a type that can be substituted
4166 for both the RHS and the LHS types if there is a possibly
4167 useless conversion involved. That means returning the
4168 original RHS type as far as we can reconstruct it. */
4169 if (code
== GIMPLE_CALL
)
4170 type
= gimple_call_return_type (stmt
);
4172 switch (gimple_assign_rhs_code (stmt
))
4174 case POINTER_PLUS_EXPR
:
4175 type
= TREE_TYPE (gimple_assign_rhs1 (stmt
));
4179 /* As fallback use the type of the LHS. */
4180 type
= TREE_TYPE (gimple_get_lhs (stmt
));
4185 else if (code
== GIMPLE_COND
)
4186 return boolean_type_node
;
4188 return void_type_node
;
4192 /* Return a new iterator pointing to GIMPLE_SEQ's first statement. */
4194 static inline gimple_stmt_iterator
4195 gsi_start (gimple_seq seq
)
4197 gimple_stmt_iterator i
;
4199 i
.ptr
= gimple_seq_first (seq
);
4201 i
.bb
= (i
.ptr
&& i
.ptr
->stmt
) ? gimple_bb (i
.ptr
->stmt
) : NULL
;
4207 /* Return a new iterator pointing to the first statement in basic block BB. */
4209 static inline gimple_stmt_iterator
4210 gsi_start_bb (basic_block bb
)
4212 gimple_stmt_iterator i
;
4216 i
.ptr
= gimple_seq_first (seq
);
4224 /* Return a new iterator initially pointing to GIMPLE_SEQ's last statement. */
4226 static inline gimple_stmt_iterator
4227 gsi_last (gimple_seq seq
)
4229 gimple_stmt_iterator i
;
4231 i
.ptr
= gimple_seq_last (seq
);
4233 i
.bb
= (i
.ptr
&& i
.ptr
->stmt
) ? gimple_bb (i
.ptr
->stmt
) : NULL
;
4239 /* Return a new iterator pointing to the last statement in basic block BB. */
4241 static inline gimple_stmt_iterator
4242 gsi_last_bb (basic_block bb
)
4244 gimple_stmt_iterator i
;
4248 i
.ptr
= gimple_seq_last (seq
);
4256 /* Return true if I is at the end of its sequence. */
4259 gsi_end_p (gimple_stmt_iterator i
)
4261 return i
.ptr
== NULL
;
4265 /* Return true if I is one statement before the end of its sequence. */
4268 gsi_one_before_end_p (gimple_stmt_iterator i
)
4270 return i
.ptr
!= NULL
&& i
.ptr
->next
== NULL
;
4274 /* Advance the iterator to the next gimple statement. */
4277 gsi_next (gimple_stmt_iterator
*i
)
4279 i
->ptr
= i
->ptr
->next
;
4282 /* Advance the iterator to the previous gimple statement. */
4285 gsi_prev (gimple_stmt_iterator
*i
)
4287 i
->ptr
= i
->ptr
->prev
;
4290 /* Return the current stmt. */
4292 static inline gimple
4293 gsi_stmt (gimple_stmt_iterator i
)
4298 /* Return a block statement iterator that points to the first non-label
4299 statement in block BB. */
4301 static inline gimple_stmt_iterator
4302 gsi_after_labels (basic_block bb
)
4304 gimple_stmt_iterator gsi
= gsi_start_bb (bb
);
4306 while (!gsi_end_p (gsi
) && gimple_code (gsi_stmt (gsi
)) == GIMPLE_LABEL
)
4312 /* Return a pointer to the current stmt.
4314 NOTE: You may want to use gsi_replace on the iterator itself,
4315 as this performs additional bookkeeping that will not be done
4316 if you simply assign through a pointer returned by gsi_stmt_ptr. */
4318 static inline gimple
*
4319 gsi_stmt_ptr (gimple_stmt_iterator
*i
)
4321 return &i
->ptr
->stmt
;
4325 /* Return the basic block associated with this iterator. */
4327 static inline basic_block
4328 gsi_bb (gimple_stmt_iterator i
)
4334 /* Return the sequence associated with this iterator. */
4336 static inline gimple_seq
4337 gsi_seq (gimple_stmt_iterator i
)
4343 enum gsi_iterator_update
4345 GSI_NEW_STMT
, /* Only valid when single statement is added, move
4347 GSI_SAME_STMT
, /* Leave the iterator at the same statement. */
4348 GSI_CONTINUE_LINKING
/* Move iterator to whatever position is suitable
4349 for linking other statements in the same
4353 /* In gimple-iterator.c */
4354 gimple_stmt_iterator
gsi_start_phis (basic_block
);
4355 gimple_seq
gsi_split_seq_after (gimple_stmt_iterator
);
4356 gimple_seq
gsi_split_seq_before (gimple_stmt_iterator
*);
4357 void gsi_replace (gimple_stmt_iterator
*, gimple
, bool);
4358 void gsi_insert_before (gimple_stmt_iterator
*, gimple
,
4359 enum gsi_iterator_update
);
4360 void gsi_insert_before_without_update (gimple_stmt_iterator
*, gimple
,
4361 enum gsi_iterator_update
);
4362 void gsi_insert_seq_before (gimple_stmt_iterator
*, gimple_seq
,
4363 enum gsi_iterator_update
);
4364 void gsi_insert_seq_before_without_update (gimple_stmt_iterator
*, gimple_seq
,
4365 enum gsi_iterator_update
);
4366 void gsi_insert_after (gimple_stmt_iterator
*, gimple
,
4367 enum gsi_iterator_update
);
4368 void gsi_insert_after_without_update (gimple_stmt_iterator
*, gimple
,
4369 enum gsi_iterator_update
);
4370 void gsi_insert_seq_after (gimple_stmt_iterator
*, gimple_seq
,
4371 enum gsi_iterator_update
);
4372 void gsi_insert_seq_after_without_update (gimple_stmt_iterator
*, gimple_seq
,
4373 enum gsi_iterator_update
);
4374 void gsi_remove (gimple_stmt_iterator
*, bool);
4375 gimple_stmt_iterator
gsi_for_stmt (gimple
);
4376 void gsi_move_after (gimple_stmt_iterator
*, gimple_stmt_iterator
*);
4377 void gsi_move_before (gimple_stmt_iterator
*, gimple_stmt_iterator
*);
4378 void gsi_move_to_bb_end (gimple_stmt_iterator
*, struct basic_block_def
*);
4379 void gsi_insert_on_edge (edge
, gimple
);
4380 void gsi_insert_seq_on_edge (edge
, gimple_seq
);
4381 basic_block
gsi_insert_on_edge_immediate (edge
, gimple
);
4382 basic_block
gsi_insert_seq_on_edge_immediate (edge
, gimple_seq
);
4383 void gsi_commit_one_edge_insert (edge
, basic_block
*);
4384 void gsi_commit_edge_inserts (void);
4385 gimple
gimple_call_copy_skip_args (gimple
, bitmap
);
4388 /* Convenience routines to walk all statements of a gimple function.
4389 Note that this is useful exclusively before the code is converted
4390 into SSA form. Once the program is in SSA form, the standard
4391 operand interface should be used to analyze/modify statements. */
4392 struct walk_stmt_info
4394 /* Points to the current statement being walked. */
4395 gimple_stmt_iterator gsi
;
4397 /* Additional data that the callback functions may want to carry
4398 through the recursion. */
4401 /* Pointer map used to mark visited tree nodes when calling
4402 walk_tree on each operand. If set to NULL, duplicate tree nodes
4403 will be visited more than once. */
4404 struct pointer_set_t
*pset
;
4406 /* Indicates whether the operand being examined may be replaced
4407 with something that matches is_gimple_val (if true) or something
4408 slightly more complicated (if false). "Something" technically
4409 means the common subset of is_gimple_lvalue and is_gimple_rhs,
4410 but we never try to form anything more complicated than that, so
4411 we don't bother checking.
4413 Also note that CALLBACK should update this flag while walking the
4414 sub-expressions of a statement. For instance, when walking the
4415 statement 'foo (&var)', the flag VAL_ONLY will initially be set
4416 to true, however, when walking &var, the operand of that
4417 ADDR_EXPR does not need to be a GIMPLE value. */
4420 /* True if we are currently walking the LHS of an assignment. */
4423 /* Optional. Set to true by the callback functions if they made any
4427 /* True if we're interested in location information. */
4428 bool want_locations
;
4430 /* Operand returned by the callbacks. This is set when calling
4431 walk_gimple_seq. If the walk_stmt_fn or walk_tree_fn callback
4432 returns non-NULL, this field will contain the tree returned by
4433 the last callback. */
4434 tree callback_result
;
4437 /* Callback for walk_gimple_stmt. Called for every statement found
4438 during traversal. The first argument points to the statement to
4439 walk. The second argument is a flag that the callback sets to
4440 'true' if it the callback handled all the operands and
4441 sub-statements of the statement (the default value of this flag is
4442 'false'). The third argument is an anonymous pointer to data
4443 to be used by the callback. */
4444 typedef tree (*walk_stmt_fn
) (gimple_stmt_iterator
*, bool *,
4445 struct walk_stmt_info
*);
4447 gimple
walk_gimple_seq (gimple_seq
, walk_stmt_fn
, walk_tree_fn
,
4448 struct walk_stmt_info
*);
4449 tree
walk_gimple_stmt (gimple_stmt_iterator
*, walk_stmt_fn
, walk_tree_fn
,
4450 struct walk_stmt_info
*);
4451 tree
walk_gimple_op (gimple
, walk_tree_fn
, struct walk_stmt_info
*);
4453 #ifdef GATHER_STATISTICS
4454 /* Enum and arrays used for allocation stats. Keep in sync with
4455 gimple.c:gimple_alloc_kind_names. */
4456 enum gimple_alloc_kind
4458 gimple_alloc_kind_assign
, /* Assignments. */
4459 gimple_alloc_kind_phi
, /* PHI nodes. */
4460 gimple_alloc_kind_cond
, /* Conditionals. */
4461 gimple_alloc_kind_seq
, /* Sequences. */
4462 gimple_alloc_kind_rest
, /* Everything else. */
4463 gimple_alloc_kind_all
4466 extern int gimple_alloc_counts
[];
4467 extern int gimple_alloc_sizes
[];
4469 /* Return the allocation kind for a given stmt CODE. */
4470 static inline enum gimple_alloc_kind
4471 gimple_alloc_kind (enum gimple_code code
)
4476 return gimple_alloc_kind_assign
;
4478 return gimple_alloc_kind_phi
;
4480 return gimple_alloc_kind_cond
;
4482 return gimple_alloc_kind_rest
;
4485 #endif /* GATHER_STATISTICS */
4487 extern void dump_gimple_statistics (void);
4489 #endif /* GCC_GIMPLE_H */