1 /* Gimple IR definitions.
3 Copyright (C) 2007-2016 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 "tree-ssa-alias.h"
26 #include "gimple-expr.h"
28 typedef gimple *gimple_seq_node;
31 #define DEFGSCODE(SYM, STRING, STRUCT) SYM,
34 LAST_AND_UNUSED_GIMPLE_CODE
37 extern const char *const gimple_code_name[];
38 extern const unsigned char gimple_rhs_class_table[];
40 /* Strip the outermost pointer, from tr1/type_traits. */
41 template<typename T> struct remove_pointer { typedef T type; };
42 template<typename T> struct remove_pointer<T *> { typedef T type; };
44 /* Error out if a gimple tuple is addressed incorrectly. */
45 #if defined ENABLE_GIMPLE_CHECKING
46 #define gcc_gimple_checking_assert(EXPR) gcc_assert (EXPR)
47 extern void gimple_check_failed (const gimple *, const char *, int, \
48 const char *, enum gimple_code, \
49 enum tree_code) ATTRIBUTE_NORETURN;
51 #define GIMPLE_CHECK(GS, CODE) \
53 const gimple *__gs = (GS); \
54 if (gimple_code (__gs) != (CODE)) \
55 gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__, \
56 (CODE), ERROR_MARK); \
60 GIMPLE_CHECK2(const gimple *gs,
61 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
62 const char *file = __builtin_FILE (),
63 int line = __builtin_LINE (),
64 const char *fun = __builtin_FUNCTION ())
66 const char *file = __FILE__,
68 const char *fun = NULL)
71 T ret = dyn_cast <T> (gs);
73 gimple_check_failed (gs, file, line, fun,
74 remove_pointer<T>::type::code_, ERROR_MARK);
79 GIMPLE_CHECK2(gimple *gs,
80 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
81 const char *file = __builtin_FILE (),
82 int line = __builtin_LINE (),
83 const char *fun = __builtin_FUNCTION ())
85 const char *file = __FILE__,
87 const char *fun = NULL)
90 T ret = dyn_cast <T> (gs);
92 gimple_check_failed (gs, file, line, fun,
93 remove_pointer<T>::type::code_, ERROR_MARK);
96 #else /* not ENABLE_GIMPLE_CHECKING */
97 #define gcc_gimple_checking_assert(EXPR) ((void)(0 && (EXPR)))
98 #define GIMPLE_CHECK(GS, CODE) (void)0
101 GIMPLE_CHECK2(gimple *gs)
103 return as_a <T> (gs);
105 template <typename T>
107 GIMPLE_CHECK2(const gimple *gs)
109 return as_a <T> (gs);
113 /* Class of GIMPLE expressions suitable for the RHS of assignments. See
114 get_gimple_rhs_class. */
115 enum gimple_rhs_class
117 GIMPLE_INVALID_RHS, /* The expression cannot be used on the RHS. */
118 GIMPLE_TERNARY_RHS, /* The expression is a ternary operation. */
119 GIMPLE_BINARY_RHS, /* The expression is a binary operation. */
120 GIMPLE_UNARY_RHS, /* The expression is a unary operation. */
121 GIMPLE_SINGLE_RHS /* The expression is a single object (an SSA
122 name, a _DECL, a _REF, etc. */
125 /* Specific flags for individual GIMPLE statements. These flags are
126 always stored in gimple.subcode and they may only be
127 defined for statement codes that do not use subcodes.
129 Values for the masks can overlap as long as the overlapping values
130 are never used in the same statement class.
132 The maximum mask value that can be defined is 1 << 15 (i.e., each
133 statement code can hold up to 16 bitflags).
135 Keep this list sorted. */
137 GF_ASM_INPUT = 1 << 0,
138 GF_ASM_VOLATILE = 1 << 1,
139 GF_CALL_FROM_THUNK = 1 << 0,
140 GF_CALL_RETURN_SLOT_OPT = 1 << 1,
141 GF_CALL_TAILCALL = 1 << 2,
142 GF_CALL_VA_ARG_PACK = 1 << 3,
143 GF_CALL_NOTHROW = 1 << 4,
144 GF_CALL_ALLOCA_FOR_VAR = 1 << 5,
145 GF_CALL_INTERNAL = 1 << 6,
146 GF_CALL_CTRL_ALTERING = 1 << 7,
147 GF_CALL_WITH_BOUNDS = 1 << 8,
148 GF_OMP_PARALLEL_COMBINED = 1 << 0,
149 GF_OMP_PARALLEL_GRID_PHONY = 1 << 1,
150 GF_OMP_TASK_TASKLOOP = 1 << 0,
151 GF_OMP_FOR_KIND_MASK = (1 << 4) - 1,
152 GF_OMP_FOR_KIND_FOR = 0,
153 GF_OMP_FOR_KIND_DISTRIBUTE = 1,
154 GF_OMP_FOR_KIND_TASKLOOP = 2,
155 GF_OMP_FOR_KIND_CILKFOR = 3,
156 GF_OMP_FOR_KIND_OACC_LOOP = 4,
157 GF_OMP_FOR_KIND_GRID_LOOP = 5,
158 /* Flag for SIMD variants of OMP_FOR kinds. */
159 GF_OMP_FOR_SIMD = 1 << 3,
160 GF_OMP_FOR_KIND_SIMD = GF_OMP_FOR_SIMD | 0,
161 GF_OMP_FOR_KIND_CILKSIMD = GF_OMP_FOR_SIMD | 1,
162 GF_OMP_FOR_COMBINED = 1 << 4,
163 GF_OMP_FOR_COMBINED_INTO = 1 << 5,
164 GF_OMP_FOR_GRID_PHONY = 1 << 6,
165 GF_OMP_TARGET_KIND_MASK = (1 << 4) - 1,
166 GF_OMP_TARGET_KIND_REGION = 0,
167 GF_OMP_TARGET_KIND_DATA = 1,
168 GF_OMP_TARGET_KIND_UPDATE = 2,
169 GF_OMP_TARGET_KIND_ENTER_DATA = 3,
170 GF_OMP_TARGET_KIND_EXIT_DATA = 4,
171 GF_OMP_TARGET_KIND_OACC_PARALLEL = 5,
172 GF_OMP_TARGET_KIND_OACC_KERNELS = 6,
173 GF_OMP_TARGET_KIND_OACC_DATA = 7,
174 GF_OMP_TARGET_KIND_OACC_UPDATE = 8,
175 GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA = 9,
176 GF_OMP_TARGET_KIND_OACC_DECLARE = 10,
177 GF_OMP_TARGET_KIND_OACC_HOST_DATA = 11,
178 GF_OMP_TEAMS_GRID_PHONY = 1 << 0,
180 /* True on an GIMPLE_OMP_RETURN statement if the return does not require
181 a thread synchronization via some sort of barrier. The exact barrier
182 that would otherwise be emitted is dependent on the OMP statement with
183 which this return is associated. */
184 GF_OMP_RETURN_NOWAIT = 1 << 0,
186 GF_OMP_SECTION_LAST = 1 << 0,
187 GF_OMP_ATOMIC_NEED_VALUE = 1 << 0,
188 GF_OMP_ATOMIC_SEQ_CST = 1 << 1,
189 GF_PREDICT_TAKEN = 1 << 15
192 /* Currently, there are only two types of gimple debug stmt. Others are
193 envisioned, for example, to enable the generation of is_stmt notes
194 in line number information, to mark sequence points, etc. This
195 subcode is to be used to tell them apart. */
196 enum gimple_debug_subcode {
197 GIMPLE_DEBUG_BIND = 0,
198 GIMPLE_DEBUG_SOURCE_BIND = 1
201 /* Masks for selecting a pass local flag (PLF) to work on. These
202 masks are used by gimple_set_plf and gimple_plf. */
208 /* Data structure definitions for GIMPLE tuples. NOTE: word markers
209 are for 64 bit hosts. */
211 struct GTY((desc ("gimple_statement_structure (&%h)"), tag ("GSS_BASE"),
212 chain_next ("%h.next"), variable_size))
216 Main identifying code for a tuple. */
217 ENUM_BITFIELD(gimple_code) code : 8;
219 /* Nonzero if a warning should not be emitted on this tuple. */
220 unsigned int no_warning : 1;
222 /* Nonzero if this tuple has been visited. Passes are responsible
223 for clearing this bit before using it. */
224 unsigned int visited : 1;
226 /* Nonzero if this tuple represents a non-temporal move. */
227 unsigned int nontemporal_move : 1;
229 /* Pass local flags. These flags are free for any pass to use as
230 they see fit. Passes should not assume that these flags contain
231 any useful value when the pass starts. Any initial state that
232 the pass requires should be set on entry to the pass. See
233 gimple_set_plf and gimple_plf for usage. */
234 unsigned int plf : 2;
236 /* Nonzero if this statement has been modified and needs to have its
237 operands rescanned. */
238 unsigned modified : 1;
240 /* Nonzero if this statement contains volatile operands. */
241 unsigned has_volatile_ops : 1;
243 /* Padding to get subcode to 16 bit alignment. */
246 /* The SUBCODE field can be used for tuple-specific flags for tuples
247 that do not require subcodes. Note that SUBCODE should be at
248 least as wide as tree codes, as several tuples store tree codes
250 unsigned int subcode : 16;
252 /* UID of this statement. This is used by passes that want to
253 assign IDs to statements. It must be assigned and used by each
254 pass. By default it should be assumed to contain garbage. */
258 Locus information for debug info. */
261 /* Number of operands in this tuple. */
265 Basic block holding this statement. */
269 Linked lists of gimple statements. The next pointers form
270 a NULL terminated list, the prev pointers are a cyclic list.
271 A gimple statement is hence also a double-ended list of
272 statements, with the pointer itself being the first element,
273 and the prev pointer being the last. */
275 gimple *GTY((skip)) prev;
279 /* Base structure for tuples with operands. */
281 /* This gimple subclass has no tag value. */
283 gimple_statement_with_ops_base : public gimple
285 /* [ WORD 1-6 ] : base class */
288 SSA operand vectors. NOTE: It should be possible to
289 amalgamate these vectors with the operand vector OP. However,
290 the SSA operand vectors are organized differently and contain
291 more information (like immediate use chaining). */
292 struct use_optype_d GTY((skip (""))) *use_ops;
296 /* Statements that take register operands. */
298 struct GTY((tag("GSS_WITH_OPS")))
299 gimple_statement_with_ops : public gimple_statement_with_ops_base
301 /* [ WORD 1-7 ] : base class */
304 Operand vector. NOTE! This must always be the last field
305 of this structure. In particular, this means that this
306 structure cannot be embedded inside another one. */
307 tree GTY((length ("%h.num_ops"))) op[1];
311 /* Base for statements that take both memory and register operands. */
313 struct GTY((tag("GSS_WITH_MEM_OPS_BASE")))
314 gimple_statement_with_memory_ops_base : public gimple_statement_with_ops_base
316 /* [ WORD 1-7 ] : base class */
319 Virtual operands for this statement. The GC will pick them
320 up via the ssa_names array. */
321 tree GTY((skip (""))) vdef;
322 tree GTY((skip (""))) vuse;
326 /* Statements that take both memory and register operands. */
328 struct GTY((tag("GSS_WITH_MEM_OPS")))
329 gimple_statement_with_memory_ops :
330 public gimple_statement_with_memory_ops_base
332 /* [ WORD 1-9 ] : base class */
335 Operand vector. NOTE! This must always be the last field
336 of this structure. In particular, this means that this
337 structure cannot be embedded inside another one. */
338 tree GTY((length ("%h.num_ops"))) op[1];
342 /* Call statements that take both memory and register operands. */
344 struct GTY((tag("GSS_CALL")))
345 gcall : public gimple_statement_with_memory_ops_base
347 /* [ WORD 1-9 ] : base class */
350 struct pt_solution call_used;
351 struct pt_solution call_clobbered;
354 union GTY ((desc ("%1.subcode & GF_CALL_INTERNAL"))) {
355 tree GTY ((tag ("0"))) fntype;
356 enum internal_fn GTY ((tag ("GF_CALL_INTERNAL"))) internal_fn;
360 Operand vector. NOTE! This must always be the last field
361 of this structure. In particular, this means that this
362 structure cannot be embedded inside another one. */
363 tree GTY((length ("%h.num_ops"))) op[1];
365 static const enum gimple_code code_ = GIMPLE_CALL;
369 /* OMP statements. */
371 struct GTY((tag("GSS_OMP")))
372 gimple_statement_omp : public gimple
374 /* [ WORD 1-6 ] : base class */
383 struct GTY((tag("GSS_BIND")))
384 gbind : public gimple
386 /* [ WORD 1-6 ] : base class */
389 Variables declared in this scope. */
393 This is different than the BLOCK field in gimple,
394 which is analogous to TREE_BLOCK (i.e., the lexical block holding
395 this statement). This field is the equivalent of BIND_EXPR_BLOCK
396 in tree land (i.e., the lexical scope defined by this bind). See
407 struct GTY((tag("GSS_CATCH")))
408 gcatch : public gimple
410 /* [ WORD 1-6 ] : base class */
420 /* GIMPLE_EH_FILTER */
422 struct GTY((tag("GSS_EH_FILTER")))
423 geh_filter : public gimple
425 /* [ WORD 1-6 ] : base class */
438 struct GTY((tag("GSS_EH_ELSE")))
439 geh_else : public gimple
441 /* [ WORD 1-6 ] : base class */
444 gimple_seq n_body, e_body;
447 /* GIMPLE_EH_MUST_NOT_THROW */
449 struct GTY((tag("GSS_EH_MNT")))
450 geh_mnt : public gimple
452 /* [ WORD 1-6 ] : base class */
454 /* [ WORD 7 ] Abort function decl. */
460 struct GTY((tag("GSS_PHI")))
463 /* [ WORD 1-6 ] : base class */
473 struct phi_arg_d GTY ((length ("%h.nargs"))) args[1];
477 /* GIMPLE_RESX, GIMPLE_EH_DISPATCH */
479 struct GTY((tag("GSS_EH_CTRL")))
480 gimple_statement_eh_ctrl : public gimple
482 /* [ WORD 1-6 ] : base class */
485 Exception region number. */
489 struct GTY((tag("GSS_EH_CTRL")))
490 gresx : public gimple_statement_eh_ctrl
492 /* No extra fields; adds invariant:
493 stmt->code == GIMPLE_RESX. */
496 struct GTY((tag("GSS_EH_CTRL")))
497 geh_dispatch : public gimple_statement_eh_ctrl
499 /* No extra fields; adds invariant:
500 stmt->code == GIMPLE_EH_DISPATH. */
506 struct GTY((tag("GSS_TRY")))
509 /* [ WORD 1-6 ] : base class */
512 Expression to evaluate. */
516 Cleanup expression. */
520 /* Kind of GIMPLE_TRY statements. */
521 enum gimple_try_flags
524 GIMPLE_TRY_CATCH = 1 << 0,
527 GIMPLE_TRY_FINALLY = 1 << 1,
528 GIMPLE_TRY_KIND = GIMPLE_TRY_CATCH | GIMPLE_TRY_FINALLY,
530 /* Analogous to TRY_CATCH_IS_CLEANUP. */
531 GIMPLE_TRY_CATCH_IS_CLEANUP = 1 << 2
534 /* GIMPLE_WITH_CLEANUP_EXPR */
536 struct GTY((tag("GSS_WCE")))
537 gimple_statement_wce : public gimple
539 /* [ WORD 1-6 ] : base class */
541 /* Subcode: CLEANUP_EH_ONLY. True if the cleanup should only be
542 executed if an exception is thrown, not on normal exit of its
543 scope. This flag is analogous to the CLEANUP_EH_ONLY flag
547 Cleanup expression. */
554 struct GTY((tag("GSS_ASM")))
555 gasm : public gimple_statement_with_memory_ops_base
557 /* [ WORD 1-9 ] : base class */
560 __asm__ statement. */
564 Number of inputs, outputs, clobbers, labels. */
571 Operand vector. NOTE! This must always be the last field
572 of this structure. In particular, this means that this
573 structure cannot be embedded inside another one. */
574 tree GTY((length ("%h.num_ops"))) op[1];
577 /* GIMPLE_OMP_CRITICAL */
579 struct GTY((tag("GSS_OMP_CRITICAL")))
580 gomp_critical : public gimple_statement_omp
582 /* [ WORD 1-7 ] : base class */
588 Critical section name. */
593 struct GTY(()) gimple_omp_for_iter {
594 /* Condition code. */
597 /* Index variable. */
612 struct GTY((tag("GSS_OMP_FOR")))
613 gomp_for : public gimple_statement_omp
615 /* [ WORD 1-7 ] : base class */
621 Number of elements in iter array. */
625 struct gimple_omp_for_iter * GTY((length ("%h.collapse"))) iter;
628 Pre-body evaluated before the loop body begins. */
633 /* GIMPLE_OMP_PARALLEL, GIMPLE_OMP_TARGET, GIMPLE_OMP_TASK */
635 struct GTY((tag("GSS_OMP_PARALLEL_LAYOUT")))
636 gimple_statement_omp_parallel_layout : public gimple_statement_omp
638 /* [ WORD 1-7 ] : base class */
645 Child function holding the body of the parallel region. */
649 Shared data argument. */
653 /* GIMPLE_OMP_PARALLEL or GIMPLE_TASK */
654 struct GTY((tag("GSS_OMP_PARALLEL_LAYOUT")))
655 gimple_statement_omp_taskreg : public gimple_statement_omp_parallel_layout
657 /* No extra fields; adds invariant:
658 stmt->code == GIMPLE_OMP_PARALLEL
659 || stmt->code == GIMPLE_OMP_TASK. */
662 /* GIMPLE_OMP_PARALLEL */
663 struct GTY((tag("GSS_OMP_PARALLEL_LAYOUT")))
664 gomp_parallel : public gimple_statement_omp_taskreg
666 /* No extra fields; adds invariant:
667 stmt->code == GIMPLE_OMP_PARALLEL. */
670 /* GIMPLE_OMP_TARGET */
671 struct GTY((tag("GSS_OMP_PARALLEL_LAYOUT")))
672 gomp_target : public gimple_statement_omp_parallel_layout
674 /* No extra fields; adds invariant:
675 stmt->code == GIMPLE_OMP_TARGET. */
678 /* GIMPLE_OMP_TASK */
680 struct GTY((tag("GSS_OMP_TASK")))
681 gomp_task : public gimple_statement_omp_taskreg
683 /* [ WORD 1-10 ] : base class */
686 Child function holding firstprivate initialization if needed. */
690 Size and alignment in bytes of the argument data block. */
696 /* GIMPLE_OMP_SECTION */
697 /* Uses struct gimple_statement_omp. */
700 /* GIMPLE_OMP_SECTIONS */
702 struct GTY((tag("GSS_OMP_SECTIONS")))
703 gomp_sections : public gimple_statement_omp
705 /* [ WORD 1-7 ] : base class */
711 The control variable used for deciding which of the sections to
716 /* GIMPLE_OMP_CONTINUE.
718 Note: This does not inherit from gimple_statement_omp, because we
719 do not need the body field. */
721 struct GTY((tag("GSS_OMP_CONTINUE")))
722 gomp_continue : public gimple
724 /* [ WORD 1-6 ] : base class */
733 /* GIMPLE_OMP_SINGLE, GIMPLE_OMP_TEAMS, GIMPLE_OMP_ORDERED */
735 struct GTY((tag("GSS_OMP_SINGLE_LAYOUT")))
736 gimple_statement_omp_single_layout : public gimple_statement_omp
738 /* [ WORD 1-7 ] : base class */
744 struct GTY((tag("GSS_OMP_SINGLE_LAYOUT")))
745 gomp_single : public gimple_statement_omp_single_layout
747 /* No extra fields; adds invariant:
748 stmt->code == GIMPLE_OMP_SINGLE. */
751 struct GTY((tag("GSS_OMP_SINGLE_LAYOUT")))
752 gomp_teams : public gimple_statement_omp_single_layout
754 /* No extra fields; adds invariant:
755 stmt->code == GIMPLE_OMP_TEAMS. */
758 struct GTY((tag("GSS_OMP_SINGLE_LAYOUT")))
759 gomp_ordered : public gimple_statement_omp_single_layout
761 /* No extra fields; adds invariant:
762 stmt->code == GIMPLE_OMP_ORDERED. */
766 /* GIMPLE_OMP_ATOMIC_LOAD.
767 Note: This is based on gimple, not g_s_omp, because g_s_omp
768 contains a sequence, which we don't need here. */
770 struct GTY((tag("GSS_OMP_ATOMIC_LOAD")))
771 gomp_atomic_load : public gimple
773 /* [ WORD 1-6 ] : base class */
779 /* GIMPLE_OMP_ATOMIC_STORE.
780 See note on GIMPLE_OMP_ATOMIC_LOAD. */
782 struct GTY((tag("GSS_OMP_ATOMIC_STORE_LAYOUT")))
783 gimple_statement_omp_atomic_store_layout : public gimple
785 /* [ WORD 1-6 ] : base class */
791 struct GTY((tag("GSS_OMP_ATOMIC_STORE_LAYOUT")))
793 public gimple_statement_omp_atomic_store_layout
795 /* No extra fields; adds invariant:
796 stmt->code == GIMPLE_OMP_ATOMIC_STORE. */
799 struct GTY((tag("GSS_OMP_ATOMIC_STORE_LAYOUT")))
800 gimple_statement_omp_return :
801 public gimple_statement_omp_atomic_store_layout
803 /* No extra fields; adds invariant:
804 stmt->code == GIMPLE_OMP_RETURN. */
807 /* GIMPLE_TRANSACTION. */
809 /* Bits to be stored in the GIMPLE_TRANSACTION subcode. */
811 /* The __transaction_atomic was declared [[outer]] or it is
812 __transaction_relaxed. */
813 #define GTMA_IS_OUTER (1u << 0)
814 #define GTMA_IS_RELAXED (1u << 1)
815 #define GTMA_DECLARATION_MASK (GTMA_IS_OUTER | GTMA_IS_RELAXED)
817 /* The transaction is seen to not have an abort. */
818 #define GTMA_HAVE_ABORT (1u << 2)
819 /* The transaction is seen to have loads or stores. */
820 #define GTMA_HAVE_LOAD (1u << 3)
821 #define GTMA_HAVE_STORE (1u << 4)
822 /* The transaction MAY enter serial irrevocable mode in its dynamic scope. */
823 #define GTMA_MAY_ENTER_IRREVOCABLE (1u << 5)
824 /* The transaction WILL enter serial irrevocable mode.
825 An irrevocable block post-dominates the entire transaction, such
826 that all invocations of the transaction will go serial-irrevocable.
827 In such case, we don't bother instrumenting the transaction, and
828 tell the runtime that it should begin the transaction in
829 serial-irrevocable mode. */
830 #define GTMA_DOES_GO_IRREVOCABLE (1u << 6)
831 /* The transaction contains no instrumentation code whatsover, most
832 likely because it is guaranteed to go irrevocable upon entry. */
833 #define GTMA_HAS_NO_INSTRUMENTATION (1u << 7)
835 struct GTY((tag("GSS_TRANSACTION")))
836 gtransaction : public gimple_statement_with_memory_ops_base
838 /* [ WORD 1-9 ] : base class */
849 #define DEFGSSTRUCT(SYM, STRUCT, HAS_TREE_OP) SYM,
850 enum gimple_statement_structure_enum {
851 #include "gsstruct.def"
856 /* A statement with the invariant that
857 stmt->code == GIMPLE_COND
858 i.e. a conditional jump statement. */
860 struct GTY((tag("GSS_WITH_OPS")))
861 gcond : public gimple_statement_with_ops
863 /* no additional fields; this uses the layout for GSS_WITH_OPS. */
864 static const enum gimple_code code_ = GIMPLE_COND;
867 /* A statement with the invariant that
868 stmt->code == GIMPLE_DEBUG
869 i.e. a debug statement. */
871 struct GTY((tag("GSS_WITH_OPS")))
872 gdebug : public gimple_statement_with_ops
874 /* no additional fields; this uses the layout for GSS_WITH_OPS. */
877 /* A statement with the invariant that
878 stmt->code == GIMPLE_GOTO
879 i.e. a goto statement. */
881 struct GTY((tag("GSS_WITH_OPS")))
882 ggoto : public gimple_statement_with_ops
884 /* no additional fields; this uses the layout for GSS_WITH_OPS. */
887 /* A statement with the invariant that
888 stmt->code == GIMPLE_LABEL
889 i.e. a label statement. */
891 struct GTY((tag("GSS_WITH_OPS")))
892 glabel : public gimple_statement_with_ops
894 /* no additional fields; this uses the layout for GSS_WITH_OPS. */
897 /* A statement with the invariant that
898 stmt->code == GIMPLE_SWITCH
899 i.e. a switch statement. */
901 struct GTY((tag("GSS_WITH_OPS")))
902 gswitch : public gimple_statement_with_ops
904 /* no additional fields; this uses the layout for GSS_WITH_OPS. */
907 /* A statement with the invariant that
908 stmt->code == GIMPLE_ASSIGN
909 i.e. an assignment statement. */
911 struct GTY((tag("GSS_WITH_MEM_OPS")))
912 gassign : public gimple_statement_with_memory_ops
914 static const enum gimple_code code_ = GIMPLE_ASSIGN;
915 /* no additional fields; this uses the layout for GSS_WITH_MEM_OPS. */
918 /* A statement with the invariant that
919 stmt->code == GIMPLE_RETURN
920 i.e. a return statement. */
922 struct GTY((tag("GSS_WITH_MEM_OPS")))
923 greturn : public gimple_statement_with_memory_ops
925 /* no additional fields; this uses the layout for GSS_WITH_MEM_OPS. */
931 is_a_helper <gasm *>::test (gimple *gs)
933 return gs->code == GIMPLE_ASM;
939 is_a_helper <gassign *>::test (gimple *gs)
941 return gs->code == GIMPLE_ASSIGN;
947 is_a_helper <const gassign *>::test (const gimple *gs)
949 return gs->code == GIMPLE_ASSIGN;
955 is_a_helper <gbind *>::test (gimple *gs)
957 return gs->code == GIMPLE_BIND;
963 is_a_helper <gcall *>::test (gimple *gs)
965 return gs->code == GIMPLE_CALL;
971 is_a_helper <gcatch *>::test (gimple *gs)
973 return gs->code == GIMPLE_CATCH;
979 is_a_helper <gcond *>::test (gimple *gs)
981 return gs->code == GIMPLE_COND;
987 is_a_helper <const gcond *>::test (const gimple *gs)
989 return gs->code == GIMPLE_COND;
995 is_a_helper <gdebug *>::test (gimple *gs)
997 return gs->code == GIMPLE_DEBUG;
1003 is_a_helper <ggoto *>::test (gimple *gs)
1005 return gs->code == GIMPLE_GOTO;
1011 is_a_helper <glabel *>::test (gimple *gs)
1013 return gs->code == GIMPLE_LABEL;
1019 is_a_helper <gresx *>::test (gimple *gs)
1021 return gs->code == GIMPLE_RESX;
1027 is_a_helper <geh_dispatch *>::test (gimple *gs)
1029 return gs->code == GIMPLE_EH_DISPATCH;
1035 is_a_helper <geh_else *>::test (gimple *gs)
1037 return gs->code == GIMPLE_EH_ELSE;
1043 is_a_helper <geh_filter *>::test (gimple *gs)
1045 return gs->code == GIMPLE_EH_FILTER;
1051 is_a_helper <geh_mnt *>::test (gimple *gs)
1053 return gs->code == GIMPLE_EH_MUST_NOT_THROW;
1059 is_a_helper <gomp_atomic_load *>::test (gimple *gs)
1061 return gs->code == GIMPLE_OMP_ATOMIC_LOAD;
1067 is_a_helper <gomp_atomic_store *>::test (gimple *gs)
1069 return gs->code == GIMPLE_OMP_ATOMIC_STORE;
1075 is_a_helper <gimple_statement_omp_return *>::test (gimple *gs)
1077 return gs->code == GIMPLE_OMP_RETURN;
1083 is_a_helper <gomp_continue *>::test (gimple *gs)
1085 return gs->code == GIMPLE_OMP_CONTINUE;
1091 is_a_helper <gomp_critical *>::test (gimple *gs)
1093 return gs->code == GIMPLE_OMP_CRITICAL;
1099 is_a_helper <gomp_ordered *>::test (gimple *gs)
1101 return gs->code == GIMPLE_OMP_ORDERED;
1107 is_a_helper <gomp_for *>::test (gimple *gs)
1109 return gs->code == GIMPLE_OMP_FOR;
1115 is_a_helper <gimple_statement_omp_taskreg *>::test (gimple *gs)
1117 return gs->code == GIMPLE_OMP_PARALLEL || gs->code == GIMPLE_OMP_TASK;
1123 is_a_helper <gomp_parallel *>::test (gimple *gs)
1125 return gs->code == GIMPLE_OMP_PARALLEL;
1131 is_a_helper <gomp_target *>::test (gimple *gs)
1133 return gs->code == GIMPLE_OMP_TARGET;
1139 is_a_helper <gomp_sections *>::test (gimple *gs)
1141 return gs->code == GIMPLE_OMP_SECTIONS;
1147 is_a_helper <gomp_single *>::test (gimple *gs)
1149 return gs->code == GIMPLE_OMP_SINGLE;
1155 is_a_helper <gomp_teams *>::test (gimple *gs)
1157 return gs->code == GIMPLE_OMP_TEAMS;
1163 is_a_helper <gomp_task *>::test (gimple *gs)
1165 return gs->code == GIMPLE_OMP_TASK;
1171 is_a_helper <gphi *>::test (gimple *gs)
1173 return gs->code == GIMPLE_PHI;
1179 is_a_helper <greturn *>::test (gimple *gs)
1181 return gs->code == GIMPLE_RETURN;
1187 is_a_helper <gswitch *>::test (gimple *gs)
1189 return gs->code == GIMPLE_SWITCH;
1195 is_a_helper <gtransaction *>::test (gimple *gs)
1197 return gs->code == GIMPLE_TRANSACTION;
1203 is_a_helper <gtry *>::test (gimple *gs)
1205 return gs->code == GIMPLE_TRY;
1211 is_a_helper <gimple_statement_wce *>::test (gimple *gs)
1213 return gs->code == GIMPLE_WITH_CLEANUP_EXPR;
1219 is_a_helper <const gasm *>::test (const gimple *gs)
1221 return gs->code == GIMPLE_ASM;
1227 is_a_helper <const gbind *>::test (const gimple *gs)
1229 return gs->code == GIMPLE_BIND;
1235 is_a_helper <const gcall *>::test (const gimple *gs)
1237 return gs->code == GIMPLE_CALL;
1243 is_a_helper <const gcatch *>::test (const gimple *gs)
1245 return gs->code == GIMPLE_CATCH;
1251 is_a_helper <const gresx *>::test (const gimple *gs)
1253 return gs->code == GIMPLE_RESX;
1259 is_a_helper <const geh_dispatch *>::test (const gimple *gs)
1261 return gs->code == GIMPLE_EH_DISPATCH;
1267 is_a_helper <const geh_filter *>::test (const gimple *gs)
1269 return gs->code == GIMPLE_EH_FILTER;
1275 is_a_helper <const gomp_atomic_load *>::test (const gimple *gs)
1277 return gs->code == GIMPLE_OMP_ATOMIC_LOAD;
1283 is_a_helper <const gomp_atomic_store *>::test (const gimple *gs)
1285 return gs->code == GIMPLE_OMP_ATOMIC_STORE;
1291 is_a_helper <const gimple_statement_omp_return *>::test (const gimple *gs)
1293 return gs->code == GIMPLE_OMP_RETURN;
1299 is_a_helper <const gomp_continue *>::test (const gimple *gs)
1301 return gs->code == GIMPLE_OMP_CONTINUE;
1307 is_a_helper <const gomp_critical *>::test (const gimple *gs)
1309 return gs->code == GIMPLE_OMP_CRITICAL;
1315 is_a_helper <const gomp_ordered *>::test (const gimple *gs)
1317 return gs->code == GIMPLE_OMP_ORDERED;
1323 is_a_helper <const gomp_for *>::test (const gimple *gs)
1325 return gs->code == GIMPLE_OMP_FOR;
1331 is_a_helper <const gimple_statement_omp_taskreg *>::test (const gimple *gs)
1333 return gs->code == GIMPLE_OMP_PARALLEL || gs->code == GIMPLE_OMP_TASK;
1339 is_a_helper <const gomp_parallel *>::test (const gimple *gs)
1341 return gs->code == GIMPLE_OMP_PARALLEL;
1347 is_a_helper <const gomp_target *>::test (const gimple *gs)
1349 return gs->code == GIMPLE_OMP_TARGET;
1355 is_a_helper <const gomp_sections *>::test (const gimple *gs)
1357 return gs->code == GIMPLE_OMP_SECTIONS;
1363 is_a_helper <const gomp_single *>::test (const gimple *gs)
1365 return gs->code == GIMPLE_OMP_SINGLE;
1371 is_a_helper <const gomp_teams *>::test (const gimple *gs)
1373 return gs->code == GIMPLE_OMP_TEAMS;
1379 is_a_helper <const gomp_task *>::test (const gimple *gs)
1381 return gs->code == GIMPLE_OMP_TASK;
1387 is_a_helper <const gphi *>::test (const gimple *gs)
1389 return gs->code == GIMPLE_PHI;
1395 is_a_helper <const gtransaction *>::test (const gimple *gs)
1397 return gs->code == GIMPLE_TRANSACTION;
1400 /* Offset in bytes to the location of the operand vector.
1401 Zero if there is no operand vector for this tuple structure. */
1402 extern size_t const gimple_ops_offset_[];
1404 /* Map GIMPLE codes to GSS codes. */
1405 extern enum gimple_statement_structure_enum const gss_for_code_[];
1407 /* This variable holds the currently expanded gimple statement for purposes
1408 of comminucating the profile info to the builtin expanders. */
1409 extern gimple *currently_expanding_gimple_stmt;
1411 #define gimple_alloc(c, n) gimple_alloc_stat (c, n MEM_STAT_INFO)
1412 gimple *gimple_alloc_stat (enum gimple_code, unsigned MEM_STAT_DECL);
1413 greturn *gimple_build_return (tree);
1414 void gimple_call_reset_alias_info (gcall *);
1415 gcall *gimple_build_call_vec (tree, vec<tree> );
1416 gcall *gimple_build_call (tree, unsigned, ...);
1417 gcall *gimple_build_call_valist (tree, unsigned, va_list);
1418 gcall *gimple_build_call_internal (enum internal_fn, unsigned, ...);
1419 gcall *gimple_build_call_internal_vec (enum internal_fn, vec<tree> );
1420 gcall *gimple_build_call_from_tree (tree);
1421 gassign *gimple_build_assign (tree, tree CXX_MEM_STAT_INFO);
1422 gassign *gimple_build_assign (tree, enum tree_code,
1423 tree, tree, tree CXX_MEM_STAT_INFO);
1424 gassign *gimple_build_assign (tree, enum tree_code,
1425 tree, tree CXX_MEM_STAT_INFO);
1426 gassign *gimple_build_assign (tree, enum tree_code, tree CXX_MEM_STAT_INFO);
1427 gcond *gimple_build_cond (enum tree_code, tree, tree, tree, tree);
1428 gcond *gimple_build_cond_from_tree (tree, tree, tree);
1429 void gimple_cond_set_condition_from_tree (gcond *, tree);
1430 glabel *gimple_build_label (tree label);
1431 ggoto *gimple_build_goto (tree dest);
1432 gimple *gimple_build_nop (void);
1433 gbind *gimple_build_bind (tree, gimple_seq, tree);
1434 gasm *gimple_build_asm_vec (const char *, vec<tree, va_gc> *,
1435 vec<tree, va_gc> *, vec<tree, va_gc> *,
1436 vec<tree, va_gc> *);
1437 gcatch *gimple_build_catch (tree, gimple_seq);
1438 geh_filter *gimple_build_eh_filter (tree, gimple_seq);
1439 geh_mnt *gimple_build_eh_must_not_throw (tree);
1440 geh_else *gimple_build_eh_else (gimple_seq, gimple_seq);
1441 gtry *gimple_build_try (gimple_seq, gimple_seq,
1442 enum gimple_try_flags);
1443 gimple *gimple_build_wce (gimple_seq);
1444 gresx *gimple_build_resx (int);
1445 gswitch *gimple_build_switch_nlabels (unsigned, tree, tree);
1446 gswitch *gimple_build_switch (tree, tree, vec<tree> );
1447 geh_dispatch *gimple_build_eh_dispatch (int);
1448 gdebug *gimple_build_debug_bind_stat (tree, tree, gimple * MEM_STAT_DECL);
1449 #define gimple_build_debug_bind(var,val,stmt) \
1450 gimple_build_debug_bind_stat ((var), (val), (stmt) MEM_STAT_INFO)
1451 gdebug *gimple_build_debug_source_bind_stat (tree, tree, gimple * MEM_STAT_DECL);
1452 #define gimple_build_debug_source_bind(var,val,stmt) \
1453 gimple_build_debug_source_bind_stat ((var), (val), (stmt) MEM_STAT_INFO)
1454 gomp_critical *gimple_build_omp_critical (gimple_seq, tree, tree);
1455 gomp_for *gimple_build_omp_for (gimple_seq, int, tree, size_t, gimple_seq);
1456 gomp_parallel *gimple_build_omp_parallel (gimple_seq, tree, tree, tree);
1457 gomp_task *gimple_build_omp_task (gimple_seq, tree, tree, tree, tree,
1459 gimple *gimple_build_omp_section (gimple_seq);
1460 gimple *gimple_build_omp_master (gimple_seq);
1461 gimple *gimple_build_omp_grid_body (gimple_seq);
1462 gimple *gimple_build_omp_taskgroup (gimple_seq);
1463 gomp_continue *gimple_build_omp_continue (tree, tree);
1464 gomp_ordered *gimple_build_omp_ordered (gimple_seq, tree);
1465 gimple *gimple_build_omp_return (bool);
1466 gomp_sections *gimple_build_omp_sections (gimple_seq, tree);
1467 gimple *gimple_build_omp_sections_switch (void);
1468 gomp_single *gimple_build_omp_single (gimple_seq, tree);
1469 gomp_target *gimple_build_omp_target (gimple_seq, int, tree);
1470 gomp_teams *gimple_build_omp_teams (gimple_seq, tree);
1471 gomp_atomic_load *gimple_build_omp_atomic_load (tree, tree);
1472 gomp_atomic_store *gimple_build_omp_atomic_store (tree);
1473 gtransaction *gimple_build_transaction (gimple_seq);
1474 extern void gimple_seq_add_stmt (gimple_seq *, gimple *);
1475 extern void gimple_seq_add_stmt_without_update (gimple_seq *, gimple *);
1476 void gimple_seq_add_seq (gimple_seq *, gimple_seq);
1477 void gimple_seq_add_seq_without_update (gimple_seq *, gimple_seq);
1478 extern void annotate_all_with_location_after (gimple_seq, gimple_stmt_iterator,
1480 extern void annotate_all_with_location (gimple_seq, location_t);
1481 bool empty_body_p (gimple_seq);
1482 gimple_seq gimple_seq_copy (gimple_seq);
1483 bool gimple_call_same_target_p (const gimple *, const gimple *);
1484 int gimple_call_flags (const gimple *);
1485 int gimple_call_arg_flags (const gcall *, unsigned);
1486 int gimple_call_return_flags (const gcall *);
1487 bool gimple_assign_copy_p (gimple *);
1488 bool gimple_assign_ssa_name_copy_p (gimple *);
1489 bool gimple_assign_unary_nop_p (gimple *);
1490 void gimple_set_bb (gimple *, basic_block);
1491 void gimple_assign_set_rhs_from_tree (gimple_stmt_iterator *, tree);
1492 void gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *, enum tree_code,
1494 tree gimple_get_lhs (const gimple *);
1495 void gimple_set_lhs (gimple *, tree);
1496 gimple *gimple_copy (gimple *);
1497 bool gimple_has_side_effects (const gimple *);
1498 bool gimple_could_trap_p_1 (gimple *, bool, bool);
1499 bool gimple_could_trap_p (gimple *);
1500 bool gimple_assign_rhs_could_trap_p (gimple *);
1501 extern void dump_gimple_statistics (void);
1502 unsigned get_gimple_rhs_num_ops (enum tree_code);
1503 extern tree canonicalize_cond_expr_cond (tree);
1504 gcall *gimple_call_copy_skip_args (gcall *, bitmap);
1505 extern bool gimple_compare_field_offset (tree, tree);
1506 extern tree gimple_unsigned_type (tree);
1507 extern tree gimple_signed_type (tree);
1508 extern alias_set_type gimple_get_alias_set (tree);
1509 extern bool gimple_ior_addresses_taken (bitmap, gimple *);
1510 extern bool gimple_builtin_call_types_compatible_p (const gimple *, tree);
1511 extern combined_fn gimple_call_combined_fn (const gimple *);
1512 extern bool gimple_call_builtin_p (const gimple *);
1513 extern bool gimple_call_builtin_p (const gimple *, enum built_in_class);
1514 extern bool gimple_call_builtin_p (const gimple *, enum built_in_function);
1515 extern bool gimple_asm_clobbers_memory_p (const gasm *);
1516 extern void dump_decl_set (FILE *, bitmap);
1517 extern bool nonfreeing_call_p (gimple *);
1518 extern bool nonbarrier_call_p (gimple *);
1519 extern bool infer_nonnull_range (gimple *, tree);
1520 extern bool infer_nonnull_range_by_dereference (gimple *, tree);
1521 extern bool infer_nonnull_range_by_attribute (gimple *, tree);
1522 extern void sort_case_labels (vec<tree>);
1523 extern void preprocess_case_label_vec_for_gimple (vec<tree>, tree, tree *);
1524 extern void gimple_seq_set_location (gimple_seq, location_t);
1525 extern bool gimple_inexpensive_call_p (gimple *);
1526 extern void gimple_seq_discard (gimple_seq);
1527 extern void maybe_remove_unused_call_args (struct function *, gimple *);
1529 /* Formal (expression) temporary table handling: multiple occurrences of
1530 the same scalar expression are evaluated into the same temporary. */
1532 typedef struct gimple_temp_hash_elt
1535 tree temp; /* Value */
1538 /* Get the number of the next statement uid to be allocated. */
1539 static inline unsigned int
1540 gimple_stmt_max_uid (struct function *fn)
1542 return fn->last_stmt_uid;
1545 /* Set the number of the next statement uid to be allocated. */
1547 set_gimple_stmt_max_uid (struct function *fn, unsigned int maxid)
1549 fn->last_stmt_uid = maxid;
1552 /* Set the number of the next statement uid to be allocated. */
1553 static inline unsigned int
1554 inc_gimple_stmt_max_uid (struct function *fn)
1556 return fn->last_stmt_uid++;
1559 /* Return the first node in GIMPLE sequence S. */
1561 static inline gimple_seq_node
1562 gimple_seq_first (gimple_seq s)
1568 /* Return the first statement in GIMPLE sequence S. */
1570 static inline gimple *
1571 gimple_seq_first_stmt (gimple_seq s)
1573 gimple_seq_node n = gimple_seq_first (s);
1577 /* Return the first statement in GIMPLE sequence S as a gbind *,
1578 verifying that it has code GIMPLE_BIND in a checked build. */
1580 static inline gbind *
1581 gimple_seq_first_stmt_as_a_bind (gimple_seq s)
1583 gimple_seq_node n = gimple_seq_first (s);
1584 return as_a <gbind *> (n);
1588 /* Return the last node in GIMPLE sequence S. */
1590 static inline gimple_seq_node
1591 gimple_seq_last (gimple_seq s)
1593 return s ? s->prev : NULL;
1597 /* Return the last statement in GIMPLE sequence S. */
1599 static inline gimple *
1600 gimple_seq_last_stmt (gimple_seq s)
1602 gimple_seq_node n = gimple_seq_last (s);
1607 /* Set the last node in GIMPLE sequence *PS to LAST. */
1610 gimple_seq_set_last (gimple_seq *ps, gimple_seq_node last)
1616 /* Set the first node in GIMPLE sequence *PS to FIRST. */
1619 gimple_seq_set_first (gimple_seq *ps, gimple_seq_node first)
1625 /* Return true if GIMPLE sequence S is empty. */
1628 gimple_seq_empty_p (gimple_seq s)
1633 /* Allocate a new sequence and initialize its first element with STMT. */
1635 static inline gimple_seq
1636 gimple_seq_alloc_with_stmt (gimple *stmt)
1638 gimple_seq seq = NULL;
1639 gimple_seq_add_stmt (&seq, stmt);
1644 /* Returns the sequence of statements in BB. */
1646 static inline gimple_seq
1647 bb_seq (const_basic_block bb)
1649 return (!(bb->flags & BB_RTL)) ? bb->il.gimple.seq : NULL;
1652 static inline gimple_seq *
1653 bb_seq_addr (basic_block bb)
1655 return (!(bb->flags & BB_RTL)) ? &bb->il.gimple.seq : NULL;
1658 /* Sets the sequence of statements in BB to SEQ. */
1661 set_bb_seq (basic_block bb, gimple_seq seq)
1663 gcc_checking_assert (!(bb->flags & BB_RTL));
1664 bb->il.gimple.seq = seq;
1668 /* Return the code for GIMPLE statement G. */
1670 static inline enum gimple_code
1671 gimple_code (const gimple *g)
1677 /* Return the GSS code used by a GIMPLE code. */
1679 static inline enum gimple_statement_structure_enum
1680 gss_for_code (enum gimple_code code)
1682 gcc_gimple_checking_assert ((unsigned int)code < LAST_AND_UNUSED_GIMPLE_CODE);
1683 return gss_for_code_[code];
1687 /* Return which GSS code is used by GS. */
1689 static inline enum gimple_statement_structure_enum
1690 gimple_statement_structure (gimple *gs)
1692 return gss_for_code (gimple_code (gs));
1696 /* Return true if statement G has sub-statements. This is only true for
1697 High GIMPLE statements. */
1700 gimple_has_substatements (gimple *g)
1702 switch (gimple_code (g))
1706 case GIMPLE_EH_FILTER:
1707 case GIMPLE_EH_ELSE:
1709 case GIMPLE_OMP_FOR:
1710 case GIMPLE_OMP_MASTER:
1711 case GIMPLE_OMP_TASKGROUP:
1712 case GIMPLE_OMP_ORDERED:
1713 case GIMPLE_OMP_SECTION:
1714 case GIMPLE_OMP_PARALLEL:
1715 case GIMPLE_OMP_TASK:
1716 case GIMPLE_OMP_SECTIONS:
1717 case GIMPLE_OMP_SINGLE:
1718 case GIMPLE_OMP_TARGET:
1719 case GIMPLE_OMP_TEAMS:
1720 case GIMPLE_OMP_CRITICAL:
1721 case GIMPLE_WITH_CLEANUP_EXPR:
1722 case GIMPLE_TRANSACTION:
1723 case GIMPLE_OMP_GRID_BODY:
1732 /* Return the basic block holding statement G. */
1734 static inline basic_block
1735 gimple_bb (const gimple *g)
1741 /* Return the lexical scope block holding statement G. */
1744 gimple_block (const gimple *g)
1746 return LOCATION_BLOCK (g->location);
1750 /* Set BLOCK to be the lexical scope block holding statement G. */
1753 gimple_set_block (gimple *g, tree block)
1755 g->location = set_block (g->location, block);
1759 /* Return location information for statement G. */
1761 static inline location_t
1762 gimple_location (const gimple *g)
1767 /* Return location information for statement G if g is not NULL.
1768 Otherwise, UNKNOWN_LOCATION is returned. */
1770 static inline location_t
1771 gimple_location_safe (const gimple *g)
1773 return g ? gimple_location (g) : UNKNOWN_LOCATION;
1776 /* Set location information for statement G. */
1779 gimple_set_location (gimple *g, location_t location)
1781 g->location = location;
1785 /* Return true if G contains location information. */
1788 gimple_has_location (const gimple *g)
1790 return LOCATION_LOCUS (gimple_location (g)) != UNKNOWN_LOCATION;
1794 /* Return the file name of the location of STMT. */
1796 static inline const char *
1797 gimple_filename (const gimple *stmt)
1799 return LOCATION_FILE (gimple_location (stmt));
1803 /* Return the line number of the location of STMT. */
1806 gimple_lineno (const gimple *stmt)
1808 return LOCATION_LINE (gimple_location (stmt));
1812 /* Determine whether SEQ is a singleton. */
1815 gimple_seq_singleton_p (gimple_seq seq)
1817 return ((gimple_seq_first (seq) != NULL)
1818 && (gimple_seq_first (seq) == gimple_seq_last (seq)));
1821 /* Return true if no warnings should be emitted for statement STMT. */
1824 gimple_no_warning_p (const gimple *stmt)
1826 return stmt->no_warning;
1829 /* Set the no_warning flag of STMT to NO_WARNING. */
1832 gimple_set_no_warning (gimple *stmt, bool no_warning)
1834 stmt->no_warning = (unsigned) no_warning;
1837 /* Set the visited status on statement STMT to VISITED_P.
1839 Please note that this 'visited' property of the gimple statement is
1840 supposed to be undefined at pass boundaries. This means that a
1841 given pass should not assume it contains any useful value when the
1842 pass starts and thus can set it to any value it sees fit.
1844 You can learn more about the visited property of the gimple
1845 statement by reading the comments of the 'visited' data member of
1850 gimple_set_visited (gimple *stmt, bool visited_p)
1852 stmt->visited = (unsigned) visited_p;
1856 /* Return the visited status for statement STMT.
1858 Please note that this 'visited' property of the gimple statement is
1859 supposed to be undefined at pass boundaries. This means that a
1860 given pass should not assume it contains any useful value when the
1861 pass starts and thus can set it to any value it sees fit.
1863 You can learn more about the visited property of the gimple
1864 statement by reading the comments of the 'visited' data member of
1868 gimple_visited_p (gimple *stmt)
1870 return stmt->visited;
1874 /* Set pass local flag PLF on statement STMT to VAL_P.
1876 Please note that this PLF property of the gimple statement is
1877 supposed to be undefined at pass boundaries. This means that a
1878 given pass should not assume it contains any useful value when the
1879 pass starts and thus can set it to any value it sees fit.
1881 You can learn more about the PLF property by reading the comment of
1882 the 'plf' data member of struct gimple_statement_structure. */
1885 gimple_set_plf (gimple *stmt, enum plf_mask plf, bool val_p)
1888 stmt->plf |= (unsigned int) plf;
1890 stmt->plf &= ~((unsigned int) plf);
1894 /* Return the value of pass local flag PLF on statement STMT.
1896 Please note that this 'plf' property of the gimple statement is
1897 supposed to be undefined at pass boundaries. This means that a
1898 given pass should not assume it contains any useful value when the
1899 pass starts and thus can set it to any value it sees fit.
1901 You can learn more about the plf property by reading the comment of
1902 the 'plf' data member of struct gimple_statement_structure. */
1904 static inline unsigned int
1905 gimple_plf (gimple *stmt, enum plf_mask plf)
1907 return stmt->plf & ((unsigned int) plf);
1911 /* Set the UID of statement.
1913 Please note that this UID property is supposed to be undefined at
1914 pass boundaries. This means that a given pass should not assume it
1915 contains any useful value when the pass starts and thus can set it
1916 to any value it sees fit. */
1919 gimple_set_uid (gimple *g, unsigned uid)
1925 /* Return the UID of statement.
1927 Please note that this UID property is supposed to be undefined at
1928 pass boundaries. This means that a given pass should not assume it
1929 contains any useful value when the pass starts and thus can set it
1930 to any value it sees fit. */
1932 static inline unsigned
1933 gimple_uid (const gimple *g)
1939 /* Make statement G a singleton sequence. */
1942 gimple_init_singleton (gimple *g)
1949 /* Return true if GIMPLE statement G has register or memory operands. */
1952 gimple_has_ops (const gimple *g)
1954 return gimple_code (g) >= GIMPLE_COND && gimple_code (g) <= GIMPLE_RETURN;
1960 is_a_helper <const gimple_statement_with_ops *>::test (const gimple *gs)
1962 return gimple_has_ops (gs);
1968 is_a_helper <gimple_statement_with_ops *>::test (gimple *gs)
1970 return gimple_has_ops (gs);
1973 /* Return true if GIMPLE statement G has memory operands. */
1976 gimple_has_mem_ops (const gimple *g)
1978 return gimple_code (g) >= GIMPLE_ASSIGN && gimple_code (g) <= GIMPLE_RETURN;
1984 is_a_helper <const gimple_statement_with_memory_ops *>::test (const gimple *gs)
1986 return gimple_has_mem_ops (gs);
1992 is_a_helper <gimple_statement_with_memory_ops *>::test (gimple *gs)
1994 return gimple_has_mem_ops (gs);
1997 /* Return the set of USE operands for statement G. */
1999 static inline struct use_optype_d *
2000 gimple_use_ops (const gimple *g)
2002 const gimple_statement_with_ops *ops_stmt =
2003 dyn_cast <const gimple_statement_with_ops *> (g);
2006 return ops_stmt->use_ops;
2010 /* Set USE to be the set of USE operands for statement G. */
2013 gimple_set_use_ops (gimple *g, struct use_optype_d *use)
2015 gimple_statement_with_ops *ops_stmt =
2016 as_a <gimple_statement_with_ops *> (g);
2017 ops_stmt->use_ops = use;
2021 /* Return the single VUSE operand of the statement G. */
2024 gimple_vuse (const gimple *g)
2026 const gimple_statement_with_memory_ops *mem_ops_stmt =
2027 dyn_cast <const gimple_statement_with_memory_ops *> (g);
2030 return mem_ops_stmt->vuse;
2033 /* Return the single VDEF operand of the statement G. */
2036 gimple_vdef (const gimple *g)
2038 const gimple_statement_with_memory_ops *mem_ops_stmt =
2039 dyn_cast <const gimple_statement_with_memory_ops *> (g);
2042 return mem_ops_stmt->vdef;
2045 /* Return the single VUSE operand of the statement G. */
2047 static inline tree *
2048 gimple_vuse_ptr (gimple *g)
2050 gimple_statement_with_memory_ops *mem_ops_stmt =
2051 dyn_cast <gimple_statement_with_memory_ops *> (g);
2054 return &mem_ops_stmt->vuse;
2057 /* Return the single VDEF operand of the statement G. */
2059 static inline tree *
2060 gimple_vdef_ptr (gimple *g)
2062 gimple_statement_with_memory_ops *mem_ops_stmt =
2063 dyn_cast <gimple_statement_with_memory_ops *> (g);
2066 return &mem_ops_stmt->vdef;
2069 /* Set the single VUSE operand of the statement G. */
2072 gimple_set_vuse (gimple *g, tree vuse)
2074 gimple_statement_with_memory_ops *mem_ops_stmt =
2075 as_a <gimple_statement_with_memory_ops *> (g);
2076 mem_ops_stmt->vuse = vuse;
2079 /* Set the single VDEF operand of the statement G. */
2082 gimple_set_vdef (gimple *g, tree vdef)
2084 gimple_statement_with_memory_ops *mem_ops_stmt =
2085 as_a <gimple_statement_with_memory_ops *> (g);
2086 mem_ops_stmt->vdef = vdef;
2090 /* Return true if statement G has operands and the modified field has
2094 gimple_modified_p (const gimple *g)
2096 return (gimple_has_ops (g)) ? (bool) g->modified : false;
2100 /* Set the MODIFIED flag to MODIFIEDP, iff the gimple statement G has
2101 a MODIFIED field. */
2104 gimple_set_modified (gimple *s, bool modifiedp)
2106 if (gimple_has_ops (s))
2107 s->modified = (unsigned) modifiedp;
2111 /* Return the tree code for the expression computed by STMT. This is
2112 only valid for GIMPLE_COND, GIMPLE_CALL and GIMPLE_ASSIGN. For
2113 GIMPLE_CALL, return CALL_EXPR as the expression code for
2114 consistency. This is useful when the caller needs to deal with the
2115 three kinds of computation that GIMPLE supports. */
2117 static inline enum tree_code
2118 gimple_expr_code (const gimple *stmt)
2120 enum gimple_code code = gimple_code (stmt);
2121 if (code == GIMPLE_ASSIGN || code == GIMPLE_COND)
2122 return (enum tree_code) stmt->subcode;
2125 gcc_gimple_checking_assert (code == GIMPLE_CALL);
2131 /* Return true if statement STMT contains volatile operands. */
2134 gimple_has_volatile_ops (const gimple *stmt)
2136 if (gimple_has_mem_ops (stmt))
2137 return stmt->has_volatile_ops;
2143 /* Set the HAS_VOLATILE_OPS flag to VOLATILEP. */
2146 gimple_set_has_volatile_ops (gimple *stmt, bool volatilep)
2148 if (gimple_has_mem_ops (stmt))
2149 stmt->has_volatile_ops = (unsigned) volatilep;
2152 /* Return true if STMT is in a transaction. */
2155 gimple_in_transaction (const gimple *stmt)
2157 return bb_in_transaction (gimple_bb (stmt));
2160 /* Return true if statement STMT may access memory. */
2163 gimple_references_memory_p (gimple *stmt)
2165 return gimple_has_mem_ops (stmt) && gimple_vuse (stmt);
2169 /* Return the subcode for OMP statement S. */
2171 static inline unsigned
2172 gimple_omp_subcode (const gimple *s)
2174 gcc_gimple_checking_assert (gimple_code (s) >= GIMPLE_OMP_ATOMIC_LOAD
2175 && gimple_code (s) <= GIMPLE_OMP_TEAMS);
2179 /* Set the subcode for OMP statement S to SUBCODE. */
2182 gimple_omp_set_subcode (gimple *s, unsigned int subcode)
2184 /* We only have 16 bits for the subcode. Assert that we are not
2186 gcc_gimple_checking_assert (subcode < (1 << 16));
2187 s->subcode = subcode;
2190 /* Set the nowait flag on OMP_RETURN statement S. */
2193 gimple_omp_return_set_nowait (gimple *s)
2195 GIMPLE_CHECK (s, GIMPLE_OMP_RETURN);
2196 s->subcode |= GF_OMP_RETURN_NOWAIT;
2200 /* Return true if OMP return statement G has the GF_OMP_RETURN_NOWAIT
2204 gimple_omp_return_nowait_p (const gimple *g)
2206 GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
2207 return (gimple_omp_subcode (g) & GF_OMP_RETURN_NOWAIT) != 0;
2211 /* Set the LHS of OMP return. */
2214 gimple_omp_return_set_lhs (gimple *g, tree lhs)
2216 gimple_statement_omp_return *omp_return_stmt =
2217 as_a <gimple_statement_omp_return *> (g);
2218 omp_return_stmt->val = lhs;
2222 /* Get the LHS of OMP return. */
2225 gimple_omp_return_lhs (const gimple *g)
2227 const gimple_statement_omp_return *omp_return_stmt =
2228 as_a <const gimple_statement_omp_return *> (g);
2229 return omp_return_stmt->val;
2233 /* Return a pointer to the LHS of OMP return. */
2235 static inline tree *
2236 gimple_omp_return_lhs_ptr (gimple *g)
2238 gimple_statement_omp_return *omp_return_stmt =
2239 as_a <gimple_statement_omp_return *> (g);
2240 return &omp_return_stmt->val;
2244 /* Return true if OMP section statement G has the GF_OMP_SECTION_LAST
2248 gimple_omp_section_last_p (const gimple *g)
2250 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
2251 return (gimple_omp_subcode (g) & GF_OMP_SECTION_LAST) != 0;
2255 /* Set the GF_OMP_SECTION_LAST flag on G. */
2258 gimple_omp_section_set_last (gimple *g)
2260 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
2261 g->subcode |= GF_OMP_SECTION_LAST;
2265 /* Return true if OMP parallel statement G has the
2266 GF_OMP_PARALLEL_COMBINED flag set. */
2269 gimple_omp_parallel_combined_p (const gimple *g)
2271 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
2272 return (gimple_omp_subcode (g) & GF_OMP_PARALLEL_COMBINED) != 0;
2276 /* Set the GF_OMP_PARALLEL_COMBINED field in G depending on the boolean
2277 value of COMBINED_P. */
2280 gimple_omp_parallel_set_combined_p (gimple *g, bool combined_p)
2282 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
2284 g->subcode |= GF_OMP_PARALLEL_COMBINED;
2286 g->subcode &= ~GF_OMP_PARALLEL_COMBINED;
2290 /* Return true if OMP atomic load/store statement G has the
2291 GF_OMP_ATOMIC_NEED_VALUE flag set. */
2294 gimple_omp_atomic_need_value_p (const gimple *g)
2296 if (gimple_code (g) != GIMPLE_OMP_ATOMIC_LOAD)
2297 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
2298 return (gimple_omp_subcode (g) & GF_OMP_ATOMIC_NEED_VALUE) != 0;
2302 /* Set the GF_OMP_ATOMIC_NEED_VALUE flag on G. */
2305 gimple_omp_atomic_set_need_value (gimple *g)
2307 if (gimple_code (g) != GIMPLE_OMP_ATOMIC_LOAD)
2308 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
2309 g->subcode |= GF_OMP_ATOMIC_NEED_VALUE;
2313 /* Return true if OMP atomic load/store statement G has the
2314 GF_OMP_ATOMIC_SEQ_CST flag set. */
2317 gimple_omp_atomic_seq_cst_p (const gimple *g)
2319 if (gimple_code (g) != GIMPLE_OMP_ATOMIC_LOAD)
2320 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
2321 return (gimple_omp_subcode (g) & GF_OMP_ATOMIC_SEQ_CST) != 0;
2325 /* Set the GF_OMP_ATOMIC_SEQ_CST flag on G. */
2328 gimple_omp_atomic_set_seq_cst (gimple *g)
2330 if (gimple_code (g) != GIMPLE_OMP_ATOMIC_LOAD)
2331 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
2332 g->subcode |= GF_OMP_ATOMIC_SEQ_CST;
2336 /* Return the number of operands for statement GS. */
2338 static inline unsigned
2339 gimple_num_ops (const gimple *gs)
2345 /* Set the number of operands for statement GS. */
2348 gimple_set_num_ops (gimple *gs, unsigned num_ops)
2350 gs->num_ops = num_ops;
2354 /* Return the array of operands for statement GS. */
2356 static inline tree *
2357 gimple_ops (gimple *gs)
2361 /* All the tuples have their operand vector at the very bottom
2362 of the structure. Note that those structures that do not
2363 have an operand vector have a zero offset. */
2364 off = gimple_ops_offset_[gimple_statement_structure (gs)];
2365 gcc_gimple_checking_assert (off != 0);
2367 return (tree *) ((char *) gs + off);
2371 /* Return operand I for statement GS. */
2374 gimple_op (const gimple *gs, unsigned i)
2376 if (gimple_has_ops (gs))
2378 gcc_gimple_checking_assert (i < gimple_num_ops (gs));
2379 return gimple_ops (CONST_CAST_GIMPLE (gs))[i];
2385 /* Return a pointer to operand I for statement GS. */
2387 static inline tree *
2388 gimple_op_ptr (gimple *gs, unsigned i)
2390 if (gimple_has_ops (gs))
2392 gcc_gimple_checking_assert (i < gimple_num_ops (gs));
2393 return gimple_ops (gs) + i;
2399 /* Set operand I of statement GS to OP. */
2402 gimple_set_op (gimple *gs, unsigned i, tree op)
2404 gcc_gimple_checking_assert (gimple_has_ops (gs) && i < gimple_num_ops (gs));
2406 /* Note. It may be tempting to assert that OP matches
2407 is_gimple_operand, but that would be wrong. Different tuples
2408 accept slightly different sets of tree operands. Each caller
2409 should perform its own validation. */
2410 gimple_ops (gs)[i] = op;
2413 /* Return true if GS is a GIMPLE_ASSIGN. */
2416 is_gimple_assign (const gimple *gs)
2418 return gimple_code (gs) == GIMPLE_ASSIGN;
2421 /* Determine if expression CODE is one of the valid expressions that can
2422 be used on the RHS of GIMPLE assignments. */
2424 static inline enum gimple_rhs_class
2425 get_gimple_rhs_class (enum tree_code code)
2427 return (enum gimple_rhs_class) gimple_rhs_class_table[(int) code];
2430 /* Return the LHS of assignment statement GS. */
2433 gimple_assign_lhs (const gassign *gs)
2439 gimple_assign_lhs (const gimple *gs)
2441 const gassign *ass = GIMPLE_CHECK2<const gassign *> (gs);
2442 return gimple_assign_lhs (ass);
2446 /* Return a pointer to the LHS of assignment statement GS. */
2448 static inline tree *
2449 gimple_assign_lhs_ptr (gassign *gs)
2454 static inline tree *
2455 gimple_assign_lhs_ptr (gimple *gs)
2457 gassign *ass = GIMPLE_CHECK2<gassign *> (gs);
2458 return gimple_assign_lhs_ptr (ass);
2462 /* Set LHS to be the LHS operand of assignment statement GS. */
2465 gimple_assign_set_lhs (gassign *gs, tree lhs)
2469 if (lhs && TREE_CODE (lhs) == SSA_NAME)
2470 SSA_NAME_DEF_STMT (lhs) = gs;
2474 gimple_assign_set_lhs (gimple *gs, tree lhs)
2476 gassign *ass = GIMPLE_CHECK2<gassign *> (gs);
2477 gimple_assign_set_lhs (ass, lhs);
2481 /* Return the first operand on the RHS of assignment statement GS. */
2484 gimple_assign_rhs1 (const gassign *gs)
2490 gimple_assign_rhs1 (const gimple *gs)
2492 const gassign *ass = GIMPLE_CHECK2<const gassign *> (gs);
2493 return gimple_assign_rhs1 (ass);
2497 /* Return a pointer to the first operand on the RHS of assignment
2500 static inline tree *
2501 gimple_assign_rhs1_ptr (gassign *gs)
2506 static inline tree *
2507 gimple_assign_rhs1_ptr (gimple *gs)
2509 gassign *ass = GIMPLE_CHECK2<gassign *> (gs);
2510 return gimple_assign_rhs1_ptr (ass);
2513 /* Set RHS to be the first operand on the RHS of assignment statement GS. */
2516 gimple_assign_set_rhs1 (gassign *gs, tree rhs)
2522 gimple_assign_set_rhs1 (gimple *gs, tree rhs)
2524 gassign *ass = GIMPLE_CHECK2<gassign *> (gs);
2525 gimple_assign_set_rhs1 (ass, rhs);
2529 /* Return the second operand on the RHS of assignment statement GS.
2530 If GS does not have two operands, NULL is returned instead. */
2533 gimple_assign_rhs2 (const gassign *gs)
2535 if (gimple_num_ops (gs) >= 3)
2542 gimple_assign_rhs2 (const gimple *gs)
2544 const gassign *ass = GIMPLE_CHECK2<const gassign *> (gs);
2545 return gimple_assign_rhs2 (ass);
2549 /* Return a pointer to the second operand on the RHS of assignment
2552 static inline tree *
2553 gimple_assign_rhs2_ptr (gassign *gs)
2555 gcc_gimple_checking_assert (gimple_num_ops (gs) >= 3);
2559 static inline tree *
2560 gimple_assign_rhs2_ptr (gimple *gs)
2562 gassign *ass = GIMPLE_CHECK2<gassign *> (gs);
2563 return gimple_assign_rhs2_ptr (ass);
2567 /* Set RHS to be the second operand on the RHS of assignment statement GS. */
2570 gimple_assign_set_rhs2 (gassign *gs, tree rhs)
2572 gcc_gimple_checking_assert (gimple_num_ops (gs) >= 3);
2577 gimple_assign_set_rhs2 (gimple *gs, tree rhs)
2579 gassign *ass = GIMPLE_CHECK2<gassign *> (gs);
2580 return gimple_assign_set_rhs2 (ass, rhs);
2583 /* Return the third operand on the RHS of assignment statement GS.
2584 If GS does not have two operands, NULL is returned instead. */
2587 gimple_assign_rhs3 (const gassign *gs)
2589 if (gimple_num_ops (gs) >= 4)
2596 gimple_assign_rhs3 (const gimple *gs)
2598 const gassign *ass = GIMPLE_CHECK2<const gassign *> (gs);
2599 return gimple_assign_rhs3 (ass);
2602 /* Return a pointer to the third operand on the RHS of assignment
2605 static inline tree *
2606 gimple_assign_rhs3_ptr (gimple *gs)
2608 gassign *ass = GIMPLE_CHECK2<gassign *> (gs);
2609 gcc_gimple_checking_assert (gimple_num_ops (gs) >= 4);
2614 /* Set RHS to be the third operand on the RHS of assignment statement GS. */
2617 gimple_assign_set_rhs3 (gassign *gs, tree rhs)
2619 gcc_gimple_checking_assert (gimple_num_ops (gs) >= 4);
2624 gimple_assign_set_rhs3 (gimple *gs, tree rhs)
2626 gassign *ass = GIMPLE_CHECK2<gassign *> (gs);
2627 gimple_assign_set_rhs3 (ass, rhs);
2631 /* A wrapper around 3 operand gimple_assign_set_rhs_with_ops, for callers
2632 which expect to see only two operands. */
2635 gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *gsi, enum tree_code code,
2638 gimple_assign_set_rhs_with_ops (gsi, code, op1, op2, NULL);
2641 /* A wrapper around 3 operand gimple_assign_set_rhs_with_ops, for callers
2642 which expect to see only one operands. */
2645 gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *gsi, enum tree_code code,
2648 gimple_assign_set_rhs_with_ops (gsi, code, op1, NULL, NULL);
2651 /* Returns true if GS is a nontemporal move. */
2654 gimple_assign_nontemporal_move_p (const gassign *gs)
2656 return gs->nontemporal_move;
2659 /* Sets nontemporal move flag of GS to NONTEMPORAL. */
2662 gimple_assign_set_nontemporal_move (gimple *gs, bool nontemporal)
2664 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
2665 gs->nontemporal_move = nontemporal;
2669 /* Return the code of the expression computed on the rhs of assignment
2670 statement GS. In case that the RHS is a single object, returns the
2671 tree code of the object. */
2673 static inline enum tree_code
2674 gimple_assign_rhs_code (const gassign *gs)
2676 enum tree_code code = (enum tree_code) gs->subcode;
2677 /* While we initially set subcode to the TREE_CODE of the rhs for
2678 GIMPLE_SINGLE_RHS assigns we do not update that subcode to stay
2679 in sync when we rewrite stmts into SSA form or do SSA propagations. */
2680 if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS)
2681 code = TREE_CODE (gs->op[1]);
2686 static inline enum tree_code
2687 gimple_assign_rhs_code (const gimple *gs)
2689 const gassign *ass = GIMPLE_CHECK2<const gassign *> (gs);
2690 return gimple_assign_rhs_code (ass);
2694 /* Set CODE to be the code for the expression computed on the RHS of
2698 gimple_assign_set_rhs_code (gimple *s, enum tree_code code)
2700 GIMPLE_CHECK (s, GIMPLE_ASSIGN);
2705 /* Return the gimple rhs class of the code of the expression computed on
2706 the rhs of assignment statement GS.
2707 This will never return GIMPLE_INVALID_RHS. */
2709 static inline enum gimple_rhs_class
2710 gimple_assign_rhs_class (const gimple *gs)
2712 return get_gimple_rhs_class (gimple_assign_rhs_code (gs));
2715 /* Return true if GS is an assignment with a singleton RHS, i.e.,
2716 there is no operator associated with the assignment itself.
2717 Unlike gimple_assign_copy_p, this predicate returns true for
2718 any RHS operand, including those that perform an operation
2719 and do not have the semantics of a copy, such as COND_EXPR. */
2722 gimple_assign_single_p (const gimple *gs)
2724 return (is_gimple_assign (gs)
2725 && gimple_assign_rhs_class (gs) == GIMPLE_SINGLE_RHS);
2728 /* Return true if GS performs a store to its lhs. */
2731 gimple_store_p (const gimple *gs)
2733 tree lhs = gimple_get_lhs (gs);
2734 return lhs && !is_gimple_reg (lhs);
2737 /* Return true if GS is an assignment that loads from its rhs1. */
2740 gimple_assign_load_p (const gimple *gs)
2743 if (!gimple_assign_single_p (gs))
2745 rhs = gimple_assign_rhs1 (gs);
2746 if (TREE_CODE (rhs) == WITH_SIZE_EXPR)
2748 rhs = get_base_address (rhs);
2749 return (DECL_P (rhs)
2750 || TREE_CODE (rhs) == MEM_REF || TREE_CODE (rhs) == TARGET_MEM_REF);
2754 /* Return true if S is a type-cast assignment. */
2757 gimple_assign_cast_p (const gimple *s)
2759 if (is_gimple_assign (s))
2761 enum tree_code sc = gimple_assign_rhs_code (s);
2762 return CONVERT_EXPR_CODE_P (sc)
2763 || sc == VIEW_CONVERT_EXPR
2764 || sc == FIX_TRUNC_EXPR;
2770 /* Return true if S is a clobber statement. */
2773 gimple_clobber_p (const gimple *s)
2775 return gimple_assign_single_p (s)
2776 && TREE_CLOBBER_P (gimple_assign_rhs1 (s));
2779 /* Return true if GS is a GIMPLE_CALL. */
2782 is_gimple_call (const gimple *gs)
2784 return gimple_code (gs) == GIMPLE_CALL;
2787 /* Return the LHS of call statement GS. */
2790 gimple_call_lhs (const gcall *gs)
2796 gimple_call_lhs (const gimple *gs)
2798 const gcall *gc = GIMPLE_CHECK2<const gcall *> (gs);
2799 return gimple_call_lhs (gc);
2803 /* Return a pointer to the LHS of call statement GS. */
2805 static inline tree *
2806 gimple_call_lhs_ptr (gcall *gs)
2811 static inline tree *
2812 gimple_call_lhs_ptr (gimple *gs)
2814 gcall *gc = GIMPLE_CHECK2<gcall *> (gs);
2815 return gimple_call_lhs_ptr (gc);
2819 /* Set LHS to be the LHS operand of call statement GS. */
2822 gimple_call_set_lhs (gcall *gs, tree lhs)
2825 if (lhs && TREE_CODE (lhs) == SSA_NAME)
2826 SSA_NAME_DEF_STMT (lhs) = gs;
2830 gimple_call_set_lhs (gimple *gs, tree lhs)
2832 gcall *gc = GIMPLE_CHECK2<gcall *> (gs);
2833 gimple_call_set_lhs (gc, lhs);
2837 /* Return true if call GS calls an internal-only function, as enumerated
2841 gimple_call_internal_p (const gcall *gs)
2843 return (gs->subcode & GF_CALL_INTERNAL) != 0;
2847 gimple_call_internal_p (const gimple *gs)
2849 const gcall *gc = GIMPLE_CHECK2<const gcall *> (gs);
2850 return gimple_call_internal_p (gc);
2854 /* Return true if call GS is marked as instrumented by
2855 Pointer Bounds Checker. */
2858 gimple_call_with_bounds_p (const gcall *gs)
2860 return (gs->subcode & GF_CALL_WITH_BOUNDS) != 0;
2864 gimple_call_with_bounds_p (const gimple *gs)
2866 const gcall *gc = GIMPLE_CHECK2<const gcall *> (gs);
2867 return gimple_call_with_bounds_p (gc);
2871 /* If INSTRUMENTED_P is true, marm statement GS as instrumented by
2872 Pointer Bounds Checker. */
2875 gimple_call_set_with_bounds (gcall *gs, bool with_bounds)
2878 gs->subcode |= GF_CALL_WITH_BOUNDS;
2880 gs->subcode &= ~GF_CALL_WITH_BOUNDS;
2884 gimple_call_set_with_bounds (gimple *gs, bool with_bounds)
2886 gcall *gc = GIMPLE_CHECK2<gcall *> (gs);
2887 gimple_call_set_with_bounds (gc, with_bounds);
2891 /* Return the target of internal call GS. */
2893 static inline enum internal_fn
2894 gimple_call_internal_fn (const gcall *gs)
2896 gcc_gimple_checking_assert (gimple_call_internal_p (gs));
2897 return gs->u.internal_fn;
2900 static inline enum internal_fn
2901 gimple_call_internal_fn (const gimple *gs)
2903 const gcall *gc = GIMPLE_CHECK2<const gcall *> (gs);
2904 return gimple_call_internal_fn (gc);
2907 /* Return true, if this internal gimple call is unique. */
2910 gimple_call_internal_unique_p (const gcall *gs)
2912 return gimple_call_internal_fn (gs) == IFN_UNIQUE;
2916 gimple_call_internal_unique_p (const gimple *gs)
2918 const gcall *gc = GIMPLE_CHECK2<const gcall *> (gs);
2919 return gimple_call_internal_unique_p (gc);
2922 /* Return true if GS is an internal function FN. */
2925 gimple_call_internal_p (const gimple *gs, internal_fn fn)
2927 return (is_gimple_call (gs)
2928 && gimple_call_internal_p (gs)
2929 && gimple_call_internal_fn (gs) == fn);
2932 /* If CTRL_ALTERING_P is true, mark GIMPLE_CALL S to be a stmt
2933 that could alter control flow. */
2936 gimple_call_set_ctrl_altering (gcall *s, bool ctrl_altering_p)
2938 if (ctrl_altering_p)
2939 s->subcode |= GF_CALL_CTRL_ALTERING;
2941 s->subcode &= ~GF_CALL_CTRL_ALTERING;
2945 gimple_call_set_ctrl_altering (gimple *s, bool ctrl_altering_p)
2947 gcall *gc = GIMPLE_CHECK2<gcall *> (s);
2948 gimple_call_set_ctrl_altering (gc, ctrl_altering_p);
2951 /* Return true if call GS calls an func whose GF_CALL_CTRL_ALTERING
2952 flag is set. Such call could not be a stmt in the middle of a bb. */
2955 gimple_call_ctrl_altering_p (const gcall *gs)
2957 return (gs->subcode & GF_CALL_CTRL_ALTERING) != 0;
2961 gimple_call_ctrl_altering_p (const gimple *gs)
2963 const gcall *gc = GIMPLE_CHECK2<const gcall *> (gs);
2964 return gimple_call_ctrl_altering_p (gc);
2968 /* Return the function type of the function called by GS. */
2971 gimple_call_fntype (const gcall *gs)
2973 if (gimple_call_internal_p (gs))
2975 return gs->u.fntype;
2979 gimple_call_fntype (const gimple *gs)
2981 const gcall *call_stmt = GIMPLE_CHECK2<const gcall *> (gs);
2982 return gimple_call_fntype (call_stmt);
2985 /* Set the type of the function called by CALL_STMT to FNTYPE. */
2988 gimple_call_set_fntype (gcall *call_stmt, tree fntype)
2990 gcc_gimple_checking_assert (!gimple_call_internal_p (call_stmt));
2991 call_stmt->u.fntype = fntype;
2995 /* Return the tree node representing the function called by call
2999 gimple_call_fn (const gcall *gs)
3005 gimple_call_fn (const gimple *gs)
3007 const gcall *gc = GIMPLE_CHECK2<const gcall *> (gs);
3008 return gimple_call_fn (gc);
3011 /* Return a pointer to the tree node representing the function called by call
3014 static inline tree *
3015 gimple_call_fn_ptr (gcall *gs)
3020 static inline tree *
3021 gimple_call_fn_ptr (gimple *gs)
3023 gcall *gc = GIMPLE_CHECK2<gcall *> (gs);
3024 return gimple_call_fn_ptr (gc);
3028 /* Set FN to be the function called by call statement GS. */
3031 gimple_call_set_fn (gcall *gs, tree fn)
3033 gcc_gimple_checking_assert (!gimple_call_internal_p (gs));
3038 /* Set FNDECL to be the function called by call statement GS. */
3041 gimple_call_set_fndecl (gcall *gs, tree decl)
3043 gcc_gimple_checking_assert (!gimple_call_internal_p (gs));
3044 gs->op[1] = build1_loc (gimple_location (gs), ADDR_EXPR,
3045 build_pointer_type (TREE_TYPE (decl)), decl);
3049 gimple_call_set_fndecl (gimple *gs, tree decl)
3051 gcall *gc = GIMPLE_CHECK2<gcall *> (gs);
3052 gimple_call_set_fndecl (gc, decl);
3056 /* Set internal function FN to be the function called by call statement CALL_STMT. */
3059 gimple_call_set_internal_fn (gcall *call_stmt, enum internal_fn fn)
3061 gcc_gimple_checking_assert (gimple_call_internal_p (call_stmt));
3062 call_stmt->u.internal_fn = fn;
3066 /* If a given GIMPLE_CALL's callee is a FUNCTION_DECL, return it.
3067 Otherwise return NULL. This function is analogous to
3068 get_callee_fndecl in tree land. */
3071 gimple_call_fndecl (const gcall *gs)
3073 return gimple_call_addr_fndecl (gimple_call_fn (gs));
3077 gimple_call_fndecl (const gimple *gs)
3079 const gcall *gc = GIMPLE_CHECK2<const gcall *> (gs);
3080 return gimple_call_fndecl (gc);
3084 /* Return the type returned by call statement GS. */
3087 gimple_call_return_type (const gcall *gs)
3089 tree type = gimple_call_fntype (gs);
3091 if (type == NULL_TREE)
3092 return TREE_TYPE (gimple_call_lhs (gs));
3094 /* The type returned by a function is the type of its
3096 return TREE_TYPE (type);
3100 /* Return the static chain for call statement GS. */
3103 gimple_call_chain (const gcall *gs)
3109 gimple_call_chain (const gimple *gs)
3111 const gcall *gc = GIMPLE_CHECK2<const gcall *> (gs);
3112 return gimple_call_chain (gc);
3116 /* Return a pointer to the static chain for call statement CALL_STMT. */
3118 static inline tree *
3119 gimple_call_chain_ptr (gcall *call_stmt)
3121 return &call_stmt->op[2];
3124 /* Set CHAIN to be the static chain for call statement CALL_STMT. */
3127 gimple_call_set_chain (gcall *call_stmt, tree chain)
3129 call_stmt->op[2] = chain;
3133 /* Return the number of arguments used by call statement GS. */
3135 static inline unsigned
3136 gimple_call_num_args (const gcall *gs)
3138 return gimple_num_ops (gs) - 3;
3141 static inline unsigned
3142 gimple_call_num_args (const gimple *gs)
3144 const gcall *gc = GIMPLE_CHECK2<const gcall *> (gs);
3145 return gimple_call_num_args (gc);
3149 /* Return the argument at position INDEX for call statement GS. */
3152 gimple_call_arg (const gcall *gs, unsigned index)
3154 gcc_gimple_checking_assert (gimple_num_ops (gs) > index + 3);
3155 return gs->op[index + 3];
3159 gimple_call_arg (const gimple *gs, unsigned index)
3161 const gcall *gc = GIMPLE_CHECK2<const gcall *> (gs);
3162 return gimple_call_arg (gc, index);
3166 /* Return a pointer to the argument at position INDEX for call
3169 static inline tree *
3170 gimple_call_arg_ptr (gcall *gs, unsigned index)
3172 gcc_gimple_checking_assert (gimple_num_ops (gs) > index + 3);
3173 return &gs->op[index + 3];
3176 static inline tree *
3177 gimple_call_arg_ptr (gimple *gs, unsigned index)
3179 gcall *gc = GIMPLE_CHECK2<gcall *> (gs);
3180 return gimple_call_arg_ptr (gc, index);
3184 /* Set ARG to be the argument at position INDEX for call statement GS. */
3187 gimple_call_set_arg (gcall *gs, unsigned index, tree arg)
3189 gcc_gimple_checking_assert (gimple_num_ops (gs) > index + 3);
3190 gs->op[index + 3] = arg;
3194 gimple_call_set_arg (gimple *gs, unsigned index, tree arg)
3196 gcall *gc = GIMPLE_CHECK2<gcall *> (gs);
3197 gimple_call_set_arg (gc, index, arg);
3201 /* If TAIL_P is true, mark call statement S as being a tail call
3202 (i.e., a call just before the exit of a function). These calls are
3203 candidate for tail call optimization. */
3206 gimple_call_set_tail (gcall *s, bool tail_p)
3209 s->subcode |= GF_CALL_TAILCALL;
3211 s->subcode &= ~GF_CALL_TAILCALL;
3215 /* Return true if GIMPLE_CALL S is marked as a tail call. */
3218 gimple_call_tail_p (gcall *s)
3220 return (s->subcode & GF_CALL_TAILCALL) != 0;
3224 /* If RETURN_SLOT_OPT_P is true mark GIMPLE_CALL S as valid for return
3225 slot optimization. This transformation uses the target of the call
3226 expansion as the return slot for calls that return in memory. */
3229 gimple_call_set_return_slot_opt (gcall *s, bool return_slot_opt_p)
3231 if (return_slot_opt_p)
3232 s->subcode |= GF_CALL_RETURN_SLOT_OPT;
3234 s->subcode &= ~GF_CALL_RETURN_SLOT_OPT;
3238 /* Return true if S is marked for return slot optimization. */
3241 gimple_call_return_slot_opt_p (gcall *s)
3243 return (s->subcode & GF_CALL_RETURN_SLOT_OPT) != 0;
3247 /* If FROM_THUNK_P is true, mark GIMPLE_CALL S as being the jump from a
3248 thunk to the thunked-to function. */
3251 gimple_call_set_from_thunk (gcall *s, bool from_thunk_p)
3254 s->subcode |= GF_CALL_FROM_THUNK;
3256 s->subcode &= ~GF_CALL_FROM_THUNK;
3260 /* Return true if GIMPLE_CALL S is a jump from a thunk. */
3263 gimple_call_from_thunk_p (gcall *s)
3265 return (s->subcode & GF_CALL_FROM_THUNK) != 0;
3269 /* If PASS_ARG_PACK_P is true, GIMPLE_CALL S is a stdarg call that needs the
3270 argument pack in its argument list. */
3273 gimple_call_set_va_arg_pack (gcall *s, bool pass_arg_pack_p)
3275 if (pass_arg_pack_p)
3276 s->subcode |= GF_CALL_VA_ARG_PACK;
3278 s->subcode &= ~GF_CALL_VA_ARG_PACK;
3282 /* Return true if GIMPLE_CALL S is a stdarg call that needs the
3283 argument pack in its argument list. */
3286 gimple_call_va_arg_pack_p (gcall *s)
3288 return (s->subcode & GF_CALL_VA_ARG_PACK) != 0;
3292 /* Return true if S is a noreturn call. */
3295 gimple_call_noreturn_p (const gcall *s)
3297 return (gimple_call_flags (s) & ECF_NORETURN) != 0;
3301 gimple_call_noreturn_p (const gimple *s)
3303 const gcall *gc = GIMPLE_CHECK2<const gcall *> (s);
3304 return gimple_call_noreturn_p (gc);
3308 /* If NOTHROW_P is true, GIMPLE_CALL S is a call that is known to not throw
3309 even if the called function can throw in other cases. */
3312 gimple_call_set_nothrow (gcall *s, bool nothrow_p)
3315 s->subcode |= GF_CALL_NOTHROW;
3317 s->subcode &= ~GF_CALL_NOTHROW;
3320 /* Return true if S is a nothrow call. */
3323 gimple_call_nothrow_p (gcall *s)
3325 return (gimple_call_flags (s) & ECF_NOTHROW) != 0;
3328 /* If FOR_VAR is true, GIMPLE_CALL S is a call to builtin_alloca that
3329 is known to be emitted for VLA objects. Those are wrapped by
3330 stack_save/stack_restore calls and hence can't lead to unbounded
3331 stack growth even when they occur in loops. */
3334 gimple_call_set_alloca_for_var (gcall *s, bool for_var)
3337 s->subcode |= GF_CALL_ALLOCA_FOR_VAR;
3339 s->subcode &= ~GF_CALL_ALLOCA_FOR_VAR;
3342 /* Return true of S is a call to builtin_alloca emitted for VLA objects. */
3345 gimple_call_alloca_for_var_p (gcall *s)
3347 return (s->subcode & GF_CALL_ALLOCA_FOR_VAR) != 0;
3350 /* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL. */
3353 gimple_call_copy_flags (gcall *dest_call, gcall *orig_call)
3355 dest_call->subcode = orig_call->subcode;
3359 /* Return a pointer to the points-to solution for the set of call-used
3360 variables of the call CALL_STMT. */
3362 static inline struct pt_solution *
3363 gimple_call_use_set (gcall *call_stmt)
3365 return &call_stmt->call_used;
3369 /* Return a pointer to the points-to solution for the set of call-used
3370 variables of the call CALL_STMT. */
3372 static inline struct pt_solution *
3373 gimple_call_clobber_set (gcall *call_stmt)
3375 return &call_stmt->call_clobbered;
3379 /* Returns true if this is a GIMPLE_ASSIGN or a GIMPLE_CALL with a
3383 gimple_has_lhs (gimple *stmt)
3385 if (is_gimple_assign (stmt))
3387 if (gcall *call = dyn_cast <gcall *> (stmt))
3388 return gimple_call_lhs (call) != NULL_TREE;
3393 /* Return the code of the predicate computed by conditional statement GS. */
3395 static inline enum tree_code
3396 gimple_cond_code (const gcond *gs)
3398 return (enum tree_code) gs->subcode;
3401 static inline enum tree_code
3402 gimple_cond_code (const gimple *gs)
3404 const gcond *gc = GIMPLE_CHECK2<const gcond *> (gs);
3405 return gimple_cond_code (gc);
3409 /* Set CODE to be the predicate code for the conditional statement GS. */
3412 gimple_cond_set_code (gcond *gs, enum tree_code code)
3418 /* Return the LHS of the predicate computed by conditional statement GS. */
3421 gimple_cond_lhs (const gcond *gs)
3427 gimple_cond_lhs (const gimple *gs)
3429 const gcond *gc = GIMPLE_CHECK2<const gcond *> (gs);
3430 return gimple_cond_lhs (gc);
3433 /* Return the pointer to the LHS of the predicate computed by conditional
3436 static inline tree *
3437 gimple_cond_lhs_ptr (gcond *gs)
3442 /* Set LHS to be the LHS operand of the predicate computed by
3443 conditional statement GS. */
3446 gimple_cond_set_lhs (gcond *gs, tree lhs)
3452 /* Return the RHS operand of the predicate computed by conditional GS. */
3455 gimple_cond_rhs (const gcond *gs)
3461 gimple_cond_rhs (const gimple *gs)
3463 const gcond *gc = GIMPLE_CHECK2<const gcond *> (gs);
3464 return gimple_cond_rhs (gc);
3467 /* Return the pointer to the RHS operand of the predicate computed by
3470 static inline tree *
3471 gimple_cond_rhs_ptr (gcond *gs)
3477 /* Set RHS to be the RHS operand of the predicate computed by
3478 conditional statement GS. */
3481 gimple_cond_set_rhs (gcond *gs, tree rhs)
3487 /* Return the label used by conditional statement GS when its
3488 predicate evaluates to true. */
3491 gimple_cond_true_label (const gcond *gs)
3497 /* Set LABEL to be the label used by conditional statement GS when its
3498 predicate evaluates to true. */
3501 gimple_cond_set_true_label (gcond *gs, tree label)
3507 /* Set LABEL to be the label used by conditional statement GS when its
3508 predicate evaluates to false. */
3511 gimple_cond_set_false_label (gcond *gs, tree label)
3517 /* Return the label used by conditional statement GS when its
3518 predicate evaluates to false. */
3521 gimple_cond_false_label (const gcond *gs)
3527 /* Set the conditional COND_STMT to be of the form 'if (1 == 0)'. */
3530 gimple_cond_make_false (gcond *gs)
3532 gimple_cond_set_lhs (gs, boolean_false_node);
3533 gimple_cond_set_rhs (gs, boolean_false_node);
3534 gs->subcode = NE_EXPR;
3538 /* Set the conditional COND_STMT to be of the form 'if (1 == 1)'. */
3541 gimple_cond_make_true (gcond *gs)
3543 gimple_cond_set_lhs (gs, boolean_true_node);
3544 gimple_cond_set_rhs (gs, boolean_false_node);
3545 gs->subcode = NE_EXPR;
3548 /* Check if conditional statemente GS is of the form 'if (1 == 1)',
3549 'if (0 == 0)', 'if (1 != 0)' or 'if (0 != 1)' */
3552 gimple_cond_true_p (const gcond *gs)
3554 tree lhs = gimple_cond_lhs (gs);
3555 tree rhs = gimple_cond_rhs (gs);
3556 enum tree_code code = gimple_cond_code (gs);
3558 if (lhs != boolean_true_node && lhs != boolean_false_node)
3561 if (rhs != boolean_true_node && rhs != boolean_false_node)
3564 if (code == NE_EXPR && lhs != rhs)
3567 if (code == EQ_EXPR && lhs == rhs)
3573 /* Check if conditional statement GS is of the form 'if (1 != 1)',
3574 'if (0 != 0)', 'if (1 == 0)' or 'if (0 == 1)' */
3577 gimple_cond_false_p (const gcond *gs)
3579 tree lhs = gimple_cond_lhs (gs);
3580 tree rhs = gimple_cond_rhs (gs);
3581 enum tree_code code = gimple_cond_code (gs);
3583 if (lhs != boolean_true_node && lhs != boolean_false_node)
3586 if (rhs != boolean_true_node && rhs != boolean_false_node)
3589 if (code == NE_EXPR && lhs == rhs)
3592 if (code == EQ_EXPR && lhs != rhs)
3598 /* Set the code, LHS and RHS of GIMPLE_COND STMT from CODE, LHS and RHS. */
3601 gimple_cond_set_condition (gcond *stmt, enum tree_code code, tree lhs,
3604 gimple_cond_set_code (stmt, code);
3605 gimple_cond_set_lhs (stmt, lhs);
3606 gimple_cond_set_rhs (stmt, rhs);
3609 /* Return the LABEL_DECL node used by GIMPLE_LABEL statement GS. */
3612 gimple_label_label (const glabel *gs)
3618 /* Set LABEL to be the LABEL_DECL node used by GIMPLE_LABEL statement
3622 gimple_label_set_label (glabel *gs, tree label)
3628 /* Return the destination of the unconditional jump GS. */
3631 gimple_goto_dest (const gimple *gs)
3633 GIMPLE_CHECK (gs, GIMPLE_GOTO);
3634 return gimple_op (gs, 0);
3638 /* Set DEST to be the destination of the unconditonal jump GS. */
3641 gimple_goto_set_dest (ggoto *gs, tree dest)
3647 /* Return the variables declared in the GIMPLE_BIND statement GS. */
3650 gimple_bind_vars (const gbind *bind_stmt)
3652 return bind_stmt->vars;
3656 /* Set VARS to be the set of variables declared in the GIMPLE_BIND
3660 gimple_bind_set_vars (gbind *bind_stmt, tree vars)
3662 bind_stmt->vars = vars;
3666 /* Append VARS to the set of variables declared in the GIMPLE_BIND
3670 gimple_bind_append_vars (gbind *bind_stmt, tree vars)
3672 bind_stmt->vars = chainon (bind_stmt->vars, vars);
3676 static inline gimple_seq *
3677 gimple_bind_body_ptr (gbind *bind_stmt)
3679 return &bind_stmt->body;
3682 /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS. */
3684 static inline gimple_seq
3685 gimple_bind_body (gbind *gs)
3687 return *gimple_bind_body_ptr (gs);
3691 /* Set SEQ to be the GIMPLE sequence contained in the GIMPLE_BIND
3695 gimple_bind_set_body (gbind *bind_stmt, gimple_seq seq)
3697 bind_stmt->body = seq;
3701 /* Append a statement to the end of a GIMPLE_BIND's body. */
3704 gimple_bind_add_stmt (gbind *bind_stmt, gimple *stmt)
3706 gimple_seq_add_stmt (&bind_stmt->body, stmt);
3710 /* Append a sequence of statements to the end of a GIMPLE_BIND's body. */
3713 gimple_bind_add_seq (gbind *bind_stmt, gimple_seq seq)
3715 gimple_seq_add_seq (&bind_stmt->body, seq);
3719 /* Return the TREE_BLOCK node associated with GIMPLE_BIND statement
3720 GS. This is analogous to the BIND_EXPR_BLOCK field in trees. */
3723 gimple_bind_block (const gbind *bind_stmt)
3725 return bind_stmt->block;
3729 /* Set BLOCK to be the TREE_BLOCK node associated with GIMPLE_BIND
3733 gimple_bind_set_block (gbind *bind_stmt, tree block)
3735 gcc_gimple_checking_assert (block == NULL_TREE
3736 || TREE_CODE (block) == BLOCK);
3737 bind_stmt->block = block;
3741 /* Return the number of input operands for GIMPLE_ASM ASM_STMT. */
3743 static inline unsigned
3744 gimple_asm_ninputs (const gasm *asm_stmt)
3746 return asm_stmt->ni;
3750 /* Return the number of output operands for GIMPLE_ASM ASM_STMT. */
3752 static inline unsigned
3753 gimple_asm_noutputs (const gasm *asm_stmt)
3755 return asm_stmt->no;
3759 /* Return the number of clobber operands for GIMPLE_ASM ASM_STMT. */
3761 static inline unsigned
3762 gimple_asm_nclobbers (const gasm *asm_stmt)
3764 return asm_stmt->nc;
3767 /* Return the number of label operands for GIMPLE_ASM ASM_STMT. */
3769 static inline unsigned
3770 gimple_asm_nlabels (const gasm *asm_stmt)
3772 return asm_stmt->nl;
3775 /* Return input operand INDEX of GIMPLE_ASM ASM_STMT. */
3778 gimple_asm_input_op (const gasm *asm_stmt, unsigned index)
3780 gcc_gimple_checking_assert (index < asm_stmt->ni);
3781 return asm_stmt->op[index + asm_stmt->no];
3784 /* Set IN_OP to be input operand INDEX in GIMPLE_ASM ASM_STMT. */
3787 gimple_asm_set_input_op (gasm *asm_stmt, unsigned index, tree in_op)
3789 gcc_gimple_checking_assert (index < asm_stmt->ni
3790 && TREE_CODE (in_op) == TREE_LIST);
3791 asm_stmt->op[index + asm_stmt->no] = in_op;
3795 /* Return output operand INDEX of GIMPLE_ASM ASM_STMT. */
3798 gimple_asm_output_op (const gasm *asm_stmt, unsigned index)
3800 gcc_gimple_checking_assert (index < asm_stmt->no);
3801 return asm_stmt->op[index];
3804 /* Set OUT_OP to be output operand INDEX in GIMPLE_ASM ASM_STMT. */
3807 gimple_asm_set_output_op (gasm *asm_stmt, unsigned index, tree out_op)
3809 gcc_gimple_checking_assert (index < asm_stmt->no
3810 && TREE_CODE (out_op) == TREE_LIST);
3811 asm_stmt->op[index] = out_op;
3815 /* Return clobber operand INDEX of GIMPLE_ASM ASM_STMT. */
3818 gimple_asm_clobber_op (const gasm *asm_stmt, unsigned index)
3820 gcc_gimple_checking_assert (index < asm_stmt->nc);
3821 return asm_stmt->op[index + asm_stmt->ni + asm_stmt->no];
3825 /* Set CLOBBER_OP to be clobber operand INDEX in GIMPLE_ASM ASM_STMT. */
3828 gimple_asm_set_clobber_op (gasm *asm_stmt, unsigned index, tree clobber_op)
3830 gcc_gimple_checking_assert (index < asm_stmt->nc
3831 && TREE_CODE (clobber_op) == TREE_LIST);
3832 asm_stmt->op[index + asm_stmt->ni + asm_stmt->no] = clobber_op;
3835 /* Return label operand INDEX of GIMPLE_ASM ASM_STMT. */
3838 gimple_asm_label_op (const gasm *asm_stmt, unsigned index)
3840 gcc_gimple_checking_assert (index < asm_stmt->nl);
3841 return asm_stmt->op[index + asm_stmt->ni + asm_stmt->nc];
3844 /* Set LABEL_OP to be label operand INDEX in GIMPLE_ASM ASM_STMT. */
3847 gimple_asm_set_label_op (gasm *asm_stmt, unsigned index, tree label_op)
3849 gcc_gimple_checking_assert (index < asm_stmt->nl
3850 && TREE_CODE (label_op) == TREE_LIST);
3851 asm_stmt->op[index + asm_stmt->ni + asm_stmt->nc] = label_op;
3854 /* Return the string representing the assembly instruction in
3855 GIMPLE_ASM ASM_STMT. */
3857 static inline const char *
3858 gimple_asm_string (const gasm *asm_stmt)
3860 return asm_stmt->string;
3864 /* Return true ASM_STMT ASM_STMT is an asm statement marked volatile. */
3867 gimple_asm_volatile_p (const gasm *asm_stmt)
3869 return (asm_stmt->subcode & GF_ASM_VOLATILE) != 0;
3873 /* If VOLATLE_P is true, mark asm statement ASM_STMT as volatile. */
3876 gimple_asm_set_volatile (gasm *asm_stmt, bool volatile_p)
3879 asm_stmt->subcode |= GF_ASM_VOLATILE;
3881 asm_stmt->subcode &= ~GF_ASM_VOLATILE;
3885 /* If INPUT_P is true, mark asm ASM_STMT as an ASM_INPUT. */
3888 gimple_asm_set_input (gasm *asm_stmt, bool input_p)
3891 asm_stmt->subcode |= GF_ASM_INPUT;
3893 asm_stmt->subcode &= ~GF_ASM_INPUT;
3897 /* Return true if asm ASM_STMT is an ASM_INPUT. */
3900 gimple_asm_input_p (const gasm *asm_stmt)
3902 return (asm_stmt->subcode & GF_ASM_INPUT) != 0;
3906 /* Return the types handled by GIMPLE_CATCH statement CATCH_STMT. */
3909 gimple_catch_types (const gcatch *catch_stmt)
3911 return catch_stmt->types;
3915 /* Return a pointer to the types handled by GIMPLE_CATCH statement CATCH_STMT. */
3917 static inline tree *
3918 gimple_catch_types_ptr (gcatch *catch_stmt)
3920 return &catch_stmt->types;
3924 /* Return a pointer to the GIMPLE sequence representing the body of
3925 the handler of GIMPLE_CATCH statement CATCH_STMT. */
3927 static inline gimple_seq *
3928 gimple_catch_handler_ptr (gcatch *catch_stmt)
3930 return &catch_stmt->handler;
3934 /* Return the GIMPLE sequence representing the body of the handler of
3935 GIMPLE_CATCH statement CATCH_STMT. */
3937 static inline gimple_seq
3938 gimple_catch_handler (gcatch *catch_stmt)
3940 return *gimple_catch_handler_ptr (catch_stmt);
3944 /* Set T to be the set of types handled by GIMPLE_CATCH CATCH_STMT. */
3947 gimple_catch_set_types (gcatch *catch_stmt, tree t)
3949 catch_stmt->types = t;
3953 /* Set HANDLER to be the body of GIMPLE_CATCH CATCH_STMT. */
3956 gimple_catch_set_handler (gcatch *catch_stmt, gimple_seq handler)
3958 catch_stmt->handler = handler;
3962 /* Return the types handled by GIMPLE_EH_FILTER statement GS. */
3965 gimple_eh_filter_types (const gimple *gs)
3967 const geh_filter *eh_filter_stmt = as_a <const geh_filter *> (gs);
3968 return eh_filter_stmt->types;
3972 /* Return a pointer to the types handled by GIMPLE_EH_FILTER statement
3975 static inline tree *
3976 gimple_eh_filter_types_ptr (gimple *gs)
3978 geh_filter *eh_filter_stmt = as_a <geh_filter *> (gs);
3979 return &eh_filter_stmt->types;
3983 /* Return a pointer to the sequence of statement to execute when
3984 GIMPLE_EH_FILTER statement fails. */
3986 static inline gimple_seq *
3987 gimple_eh_filter_failure_ptr (gimple *gs)
3989 geh_filter *eh_filter_stmt = as_a <geh_filter *> (gs);
3990 return &eh_filter_stmt->failure;
3994 /* Return the sequence of statement to execute when GIMPLE_EH_FILTER
3997 static inline gimple_seq
3998 gimple_eh_filter_failure (gimple *gs)
4000 return *gimple_eh_filter_failure_ptr (gs);
4004 /* Set TYPES to be the set of types handled by GIMPLE_EH_FILTER
4008 gimple_eh_filter_set_types (geh_filter *eh_filter_stmt, tree types)
4010 eh_filter_stmt->types = types;
4014 /* Set FAILURE to be the sequence of statements to execute on failure
4015 for GIMPLE_EH_FILTER EH_FILTER_STMT. */
4018 gimple_eh_filter_set_failure (geh_filter *eh_filter_stmt,
4021 eh_filter_stmt->failure = failure;
4024 /* Get the function decl to be called by the MUST_NOT_THROW region. */
4027 gimple_eh_must_not_throw_fndecl (geh_mnt *eh_mnt_stmt)
4029 return eh_mnt_stmt->fndecl;
4032 /* Set the function decl to be called by GS to DECL. */
4035 gimple_eh_must_not_throw_set_fndecl (geh_mnt *eh_mnt_stmt,
4038 eh_mnt_stmt->fndecl = decl;
4041 /* GIMPLE_EH_ELSE accessors. */
4043 static inline gimple_seq *
4044 gimple_eh_else_n_body_ptr (geh_else *eh_else_stmt)
4046 return &eh_else_stmt->n_body;
4049 static inline gimple_seq
4050 gimple_eh_else_n_body (geh_else *eh_else_stmt)
4052 return *gimple_eh_else_n_body_ptr (eh_else_stmt);
4055 static inline gimple_seq *
4056 gimple_eh_else_e_body_ptr (geh_else *eh_else_stmt)
4058 return &eh_else_stmt->e_body;
4061 static inline gimple_seq
4062 gimple_eh_else_e_body (geh_else *eh_else_stmt)
4064 return *gimple_eh_else_e_body_ptr (eh_else_stmt);
4068 gimple_eh_else_set_n_body (geh_else *eh_else_stmt, gimple_seq seq)
4070 eh_else_stmt->n_body = seq;
4074 gimple_eh_else_set_e_body (geh_else *eh_else_stmt, gimple_seq seq)
4076 eh_else_stmt->e_body = seq;
4079 /* GIMPLE_TRY accessors. */
4081 /* Return the kind of try block represented by GIMPLE_TRY GS. This is
4082 either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY. */
4084 static inline enum gimple_try_flags
4085 gimple_try_kind (const gimple *gs)
4087 GIMPLE_CHECK (gs, GIMPLE_TRY);
4088 return (enum gimple_try_flags) (gs->subcode & GIMPLE_TRY_KIND);
4092 /* Set the kind of try block represented by GIMPLE_TRY GS. */
4095 gimple_try_set_kind (gtry *gs, enum gimple_try_flags kind)
4097 gcc_gimple_checking_assert (kind == GIMPLE_TRY_CATCH
4098 || kind == GIMPLE_TRY_FINALLY);
4099 if (gimple_try_kind (gs) != kind)
4100 gs->subcode = (unsigned int) kind;
4104 /* Return the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
4107 gimple_try_catch_is_cleanup (const gimple *gs)
4109 gcc_gimple_checking_assert (gimple_try_kind (gs) == GIMPLE_TRY_CATCH);
4110 return (gs->subcode & GIMPLE_TRY_CATCH_IS_CLEANUP) != 0;
4114 /* Return a pointer to the sequence of statements used as the
4115 body for GIMPLE_TRY GS. */
4117 static inline gimple_seq *
4118 gimple_try_eval_ptr (gimple *gs)
4120 gtry *try_stmt = as_a <gtry *> (gs);
4121 return &try_stmt->eval;
4125 /* Return the sequence of statements used as the body for GIMPLE_TRY GS. */
4127 static inline gimple_seq
4128 gimple_try_eval (gimple *gs)
4130 return *gimple_try_eval_ptr (gs);
4134 /* Return a pointer to the sequence of statements used as the cleanup body for
4137 static inline gimple_seq *
4138 gimple_try_cleanup_ptr (gimple *gs)
4140 gtry *try_stmt = as_a <gtry *> (gs);
4141 return &try_stmt->cleanup;
4145 /* Return the sequence of statements used as the cleanup body for
4148 static inline gimple_seq
4149 gimple_try_cleanup (gimple *gs)
4151 return *gimple_try_cleanup_ptr (gs);
4155 /* Set the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
4158 gimple_try_set_catch_is_cleanup (gtry *g, bool catch_is_cleanup)
4160 gcc_gimple_checking_assert (gimple_try_kind (g) == GIMPLE_TRY_CATCH);
4161 if (catch_is_cleanup)
4162 g->subcode |= GIMPLE_TRY_CATCH_IS_CLEANUP;
4164 g->subcode &= ~GIMPLE_TRY_CATCH_IS_CLEANUP;
4168 /* Set EVAL to be the sequence of statements to use as the body for
4169 GIMPLE_TRY TRY_STMT. */
4172 gimple_try_set_eval (gtry *try_stmt, gimple_seq eval)
4174 try_stmt->eval = eval;
4178 /* Set CLEANUP to be the sequence of statements to use as the cleanup
4179 body for GIMPLE_TRY TRY_STMT. */
4182 gimple_try_set_cleanup (gtry *try_stmt, gimple_seq cleanup)
4184 try_stmt->cleanup = cleanup;
4188 /* Return a pointer to the cleanup sequence for cleanup statement GS. */
4190 static inline gimple_seq *
4191 gimple_wce_cleanup_ptr (gimple *gs)
4193 gimple_statement_wce *wce_stmt = as_a <gimple_statement_wce *> (gs);
4194 return &wce_stmt->cleanup;
4198 /* Return the cleanup sequence for cleanup statement GS. */
4200 static inline gimple_seq
4201 gimple_wce_cleanup (gimple *gs)
4203 return *gimple_wce_cleanup_ptr (gs);
4207 /* Set CLEANUP to be the cleanup sequence for GS. */
4210 gimple_wce_set_cleanup (gimple *gs, gimple_seq cleanup)
4212 gimple_statement_wce *wce_stmt = as_a <gimple_statement_wce *> (gs);
4213 wce_stmt->cleanup = cleanup;
4217 /* Return the CLEANUP_EH_ONLY flag for a WCE tuple. */
4220 gimple_wce_cleanup_eh_only (const gimple *gs)
4222 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
4223 return gs->subcode != 0;
4227 /* Set the CLEANUP_EH_ONLY flag for a WCE tuple. */
4230 gimple_wce_set_cleanup_eh_only (gimple *gs, bool eh_only_p)
4232 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
4233 gs->subcode = (unsigned int) eh_only_p;
4237 /* Return the maximum number of arguments supported by GIMPLE_PHI GS. */
4239 static inline unsigned
4240 gimple_phi_capacity (const gimple *gs)
4242 const gphi *phi_stmt = as_a <const gphi *> (gs);
4243 return phi_stmt->capacity;
4247 /* Return the number of arguments in GIMPLE_PHI GS. This must always
4248 be exactly the number of incoming edges for the basic block holding
4251 static inline unsigned
4252 gimple_phi_num_args (const gimple *gs)
4254 const gphi *phi_stmt = as_a <const gphi *> (gs);
4255 return phi_stmt->nargs;
4259 /* Return the SSA name created by GIMPLE_PHI GS. */
4262 gimple_phi_result (const gimple *gs)
4264 const gphi *phi_stmt = as_a <const gphi *> (gs);
4265 return phi_stmt->result;
4268 /* Return a pointer to the SSA name created by GIMPLE_PHI GS. */
4270 static inline tree *
4271 gimple_phi_result_ptr (gimple *gs)
4273 gphi *phi_stmt = as_a <gphi *> (gs);
4274 return &phi_stmt->result;
4277 /* Set RESULT to be the SSA name created by GIMPLE_PHI PHI. */
4280 gimple_phi_set_result (gphi *phi, tree result)
4282 phi->result = result;
4283 if (result && TREE_CODE (result) == SSA_NAME)
4284 SSA_NAME_DEF_STMT (result) = phi;
4288 /* Return the PHI argument corresponding to incoming edge INDEX for
4291 static inline struct phi_arg_d *
4292 gimple_phi_arg (gimple *gs, unsigned index)
4294 gphi *phi_stmt = as_a <gphi *> (gs);
4295 gcc_gimple_checking_assert (index <= phi_stmt->capacity);
4296 return &(phi_stmt->args[index]);
4299 /* Set PHIARG to be the argument corresponding to incoming edge INDEX
4300 for GIMPLE_PHI PHI. */
4303 gimple_phi_set_arg (gphi *phi, unsigned index, struct phi_arg_d * phiarg)
4305 gcc_gimple_checking_assert (index <= phi->nargs);
4306 phi->args[index] = *phiarg;
4309 /* Return the PHI nodes for basic block BB, or NULL if there are no
4312 static inline gimple_seq
4313 phi_nodes (const_basic_block bb)
4315 gcc_checking_assert (!(bb->flags & BB_RTL));
4316 return bb->il.gimple.phi_nodes;
4319 /* Return a pointer to the PHI nodes for basic block BB. */
4321 static inline gimple_seq *
4322 phi_nodes_ptr (basic_block bb)
4324 gcc_checking_assert (!(bb->flags & BB_RTL));
4325 return &bb->il.gimple.phi_nodes;
4328 /* Return the tree operand for argument I of PHI node GS. */
4331 gimple_phi_arg_def (gimple *gs, size_t index)
4333 return gimple_phi_arg (gs, index)->def;
4337 /* Return a pointer to the tree operand for argument I of phi node PHI. */
4339 static inline tree *
4340 gimple_phi_arg_def_ptr (gphi *phi, size_t index)
4342 return &gimple_phi_arg (phi, index)->def;
4345 /* Return the edge associated with argument I of phi node PHI. */
4348 gimple_phi_arg_edge (gphi *phi, size_t i)
4350 return EDGE_PRED (gimple_bb (phi), i);
4353 /* Return the source location of gimple argument I of phi node PHI. */
4355 static inline source_location
4356 gimple_phi_arg_location (gphi *phi, size_t i)
4358 return gimple_phi_arg (phi, i)->locus;
4361 /* Return the source location of the argument on edge E of phi node PHI. */
4363 static inline source_location
4364 gimple_phi_arg_location_from_edge (gphi *phi, edge e)
4366 return gimple_phi_arg (phi, e->dest_idx)->locus;
4369 /* Set the source location of gimple argument I of phi node PHI to LOC. */
4372 gimple_phi_arg_set_location (gphi *phi, size_t i, source_location loc)
4374 gimple_phi_arg (phi, i)->locus = loc;
4377 /* Return TRUE if argument I of phi node PHI has a location record. */
4380 gimple_phi_arg_has_location (gphi *phi, size_t i)
4382 return gimple_phi_arg_location (phi, i) != UNKNOWN_LOCATION;
4386 /* Return the region number for GIMPLE_RESX RESX_STMT. */
4389 gimple_resx_region (const gresx *resx_stmt)
4391 return resx_stmt->region;
4394 /* Set REGION to be the region number for GIMPLE_RESX RESX_STMT. */
4397 gimple_resx_set_region (gresx *resx_stmt, int region)
4399 resx_stmt->region = region;
4402 /* Return the region number for GIMPLE_EH_DISPATCH EH_DISPATCH_STMT. */
4405 gimple_eh_dispatch_region (const geh_dispatch *eh_dispatch_stmt)
4407 return eh_dispatch_stmt->region;
4410 /* Set REGION to be the region number for GIMPLE_EH_DISPATCH
4411 EH_DISPATCH_STMT. */
4414 gimple_eh_dispatch_set_region (geh_dispatch *eh_dispatch_stmt, int region)
4416 eh_dispatch_stmt->region = region;
4419 /* Return the number of labels associated with the switch statement GS. */
4421 static inline unsigned
4422 gimple_switch_num_labels (const gswitch *gs)
4425 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
4426 num_ops = gimple_num_ops (gs);
4427 gcc_gimple_checking_assert (num_ops > 1);
4432 /* Set NLABELS to be the number of labels for the switch statement GS. */
4435 gimple_switch_set_num_labels (gswitch *g, unsigned nlabels)
4437 GIMPLE_CHECK (g, GIMPLE_SWITCH);
4438 gimple_set_num_ops (g, nlabels + 1);
4442 /* Return the index variable used by the switch statement GS. */
4445 gimple_switch_index (const gswitch *gs)
4451 /* Return a pointer to the index variable for the switch statement GS. */
4453 static inline tree *
4454 gimple_switch_index_ptr (gswitch *gs)
4460 /* Set INDEX to be the index variable for switch statement GS. */
4463 gimple_switch_set_index (gswitch *gs, tree index)
4465 gcc_gimple_checking_assert (SSA_VAR_P (index) || CONSTANT_CLASS_P (index));
4470 /* Return the label numbered INDEX. The default label is 0, followed by any
4471 labels in a switch statement. */
4474 gimple_switch_label (const gswitch *gs, unsigned index)
4476 gcc_gimple_checking_assert (gimple_num_ops (gs) > index + 1);
4477 return gs->op[index + 1];
4480 /* Set the label number INDEX to LABEL. 0 is always the default label. */
4483 gimple_switch_set_label (gswitch *gs, unsigned index, tree label)
4485 gcc_gimple_checking_assert (gimple_num_ops (gs) > index + 1
4486 && (label == NULL_TREE
4487 || TREE_CODE (label) == CASE_LABEL_EXPR));
4488 gs->op[index + 1] = label;
4491 /* Return the default label for a switch statement. */
4494 gimple_switch_default_label (const gswitch *gs)
4496 tree label = gimple_switch_label (gs, 0);
4497 gcc_checking_assert (!CASE_LOW (label) && !CASE_HIGH (label));
4501 /* Set the default label for a switch statement. */
4504 gimple_switch_set_default_label (gswitch *gs, tree label)
4506 gcc_checking_assert (!CASE_LOW (label) && !CASE_HIGH (label));
4507 gimple_switch_set_label (gs, 0, label);
4510 /* Return true if GS is a GIMPLE_DEBUG statement. */
4513 is_gimple_debug (const gimple *gs)
4515 return gimple_code (gs) == GIMPLE_DEBUG;
4518 /* Return true if S is a GIMPLE_DEBUG BIND statement. */
4521 gimple_debug_bind_p (const gimple *s)
4523 if (is_gimple_debug (s))
4524 return s->subcode == GIMPLE_DEBUG_BIND;
4529 /* Return the variable bound in a GIMPLE_DEBUG bind statement. */
4532 gimple_debug_bind_get_var (gimple *dbg)
4534 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
4535 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
4536 return gimple_op (dbg, 0);
4539 /* Return the value bound to the variable in a GIMPLE_DEBUG bind
4543 gimple_debug_bind_get_value (gimple *dbg)
4545 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
4546 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
4547 return gimple_op (dbg, 1);
4550 /* Return a pointer to the value bound to the variable in a
4551 GIMPLE_DEBUG bind statement. */
4553 static inline tree *
4554 gimple_debug_bind_get_value_ptr (gimple *dbg)
4556 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
4557 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
4558 return gimple_op_ptr (dbg, 1);
4561 /* Set the variable bound in a GIMPLE_DEBUG bind statement. */
4564 gimple_debug_bind_set_var (gimple *dbg, tree var)
4566 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
4567 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
4568 gimple_set_op (dbg, 0, var);
4571 /* Set the value bound to the variable in a GIMPLE_DEBUG bind
4575 gimple_debug_bind_set_value (gimple *dbg, tree value)
4577 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
4578 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
4579 gimple_set_op (dbg, 1, value);
4582 /* The second operand of a GIMPLE_DEBUG_BIND, when the value was
4584 #define GIMPLE_DEBUG_BIND_NOVALUE NULL_TREE /* error_mark_node */
4586 /* Remove the value bound to the variable in a GIMPLE_DEBUG bind
4590 gimple_debug_bind_reset_value (gimple *dbg)
4592 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
4593 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
4594 gimple_set_op (dbg, 1, GIMPLE_DEBUG_BIND_NOVALUE);
4597 /* Return true if the GIMPLE_DEBUG bind statement is bound to a
4601 gimple_debug_bind_has_value_p (gimple *dbg)
4603 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
4604 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
4605 return gimple_op (dbg, 1) != GIMPLE_DEBUG_BIND_NOVALUE;
4608 #undef GIMPLE_DEBUG_BIND_NOVALUE
4610 /* Return true if S is a GIMPLE_DEBUG SOURCE BIND statement. */
4613 gimple_debug_source_bind_p (const gimple *s)
4615 if (is_gimple_debug (s))
4616 return s->subcode == GIMPLE_DEBUG_SOURCE_BIND;
4621 /* Return the variable bound in a GIMPLE_DEBUG source bind statement. */
4624 gimple_debug_source_bind_get_var (gimple *dbg)
4626 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
4627 gcc_gimple_checking_assert (gimple_debug_source_bind_p (dbg));
4628 return gimple_op (dbg, 0);
4631 /* Return the value bound to the variable in a GIMPLE_DEBUG source bind
4635 gimple_debug_source_bind_get_value (gimple *dbg)
4637 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
4638 gcc_gimple_checking_assert (gimple_debug_source_bind_p (dbg));
4639 return gimple_op (dbg, 1);
4642 /* Return a pointer to the value bound to the variable in a
4643 GIMPLE_DEBUG source bind statement. */
4645 static inline tree *
4646 gimple_debug_source_bind_get_value_ptr (gimple *dbg)
4648 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
4649 gcc_gimple_checking_assert (gimple_debug_source_bind_p (dbg));
4650 return gimple_op_ptr (dbg, 1);
4653 /* Set the variable bound in a GIMPLE_DEBUG source bind statement. */
4656 gimple_debug_source_bind_set_var (gimple *dbg, tree var)
4658 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
4659 gcc_gimple_checking_assert (gimple_debug_source_bind_p (dbg));
4660 gimple_set_op (dbg, 0, var);
4663 /* Set the value bound to the variable in a GIMPLE_DEBUG source bind
4667 gimple_debug_source_bind_set_value (gimple *dbg, tree value)
4669 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
4670 gcc_gimple_checking_assert (gimple_debug_source_bind_p (dbg));
4671 gimple_set_op (dbg, 1, value);
4674 /* Return the line number for EXPR, or return -1 if we have no line
4675 number information for it. */
4677 get_lineno (const gimple *stmt)
4684 loc = gimple_location (stmt);
4685 if (loc == UNKNOWN_LOCATION)
4688 return LOCATION_LINE (loc);
4691 /* Return a pointer to the body for the OMP statement GS. */
4693 static inline gimple_seq *
4694 gimple_omp_body_ptr (gimple *gs)
4696 return &static_cast <gimple_statement_omp *> (gs)->body;
4699 /* Return the body for the OMP statement GS. */
4701 static inline gimple_seq
4702 gimple_omp_body (gimple *gs)
4704 return *gimple_omp_body_ptr (gs);
4707 /* Set BODY to be the body for the OMP statement GS. */
4710 gimple_omp_set_body (gimple *gs, gimple_seq body)
4712 static_cast <gimple_statement_omp *> (gs)->body = body;
4716 /* Return the name associated with OMP_CRITICAL statement CRIT_STMT. */
4719 gimple_omp_critical_name (const gomp_critical *crit_stmt)
4721 return crit_stmt->name;
4725 /* Return a pointer to the name associated with OMP critical statement
4728 static inline tree *
4729 gimple_omp_critical_name_ptr (gomp_critical *crit_stmt)
4731 return &crit_stmt->name;
4735 /* Set NAME to be the name associated with OMP critical statement
4739 gimple_omp_critical_set_name (gomp_critical *crit_stmt, tree name)
4741 crit_stmt->name = name;
4745 /* Return the clauses associated with OMP_CRITICAL statement CRIT_STMT. */
4748 gimple_omp_critical_clauses (const gomp_critical *crit_stmt)
4750 return crit_stmt->clauses;
4754 /* Return a pointer to the clauses associated with OMP critical statement
4757 static inline tree *
4758 gimple_omp_critical_clauses_ptr (gomp_critical *crit_stmt)
4760 return &crit_stmt->clauses;
4764 /* Set CLAUSES to be the clauses associated with OMP critical statement
4768 gimple_omp_critical_set_clauses (gomp_critical *crit_stmt, tree clauses)
4770 crit_stmt->clauses = clauses;
4774 /* Return the clauses associated with OMP_ORDERED statement ORD_STMT. */
4777 gimple_omp_ordered_clauses (const gomp_ordered *ord_stmt)
4779 return ord_stmt->clauses;
4783 /* Return a pointer to the clauses associated with OMP ordered statement
4786 static inline tree *
4787 gimple_omp_ordered_clauses_ptr (gomp_ordered *ord_stmt)
4789 return &ord_stmt->clauses;
4793 /* Set CLAUSES to be the clauses associated with OMP ordered statement
4797 gimple_omp_ordered_set_clauses (gomp_ordered *ord_stmt, tree clauses)
4799 ord_stmt->clauses = clauses;
4803 /* Return the kind of the OMP_FOR statemement G. */
4806 gimple_omp_for_kind (const gimple *g)
4808 GIMPLE_CHECK (g, GIMPLE_OMP_FOR);
4809 return (gimple_omp_subcode (g) & GF_OMP_FOR_KIND_MASK);
4813 /* Set the kind of the OMP_FOR statement G. */
4816 gimple_omp_for_set_kind (gomp_for *g, int kind)
4818 g->subcode = (g->subcode & ~GF_OMP_FOR_KIND_MASK)
4819 | (kind & GF_OMP_FOR_KIND_MASK);
4823 /* Return true if OMP_FOR statement G has the
4824 GF_OMP_FOR_COMBINED flag set. */
4827 gimple_omp_for_combined_p (const gimple *g)
4829 GIMPLE_CHECK (g, GIMPLE_OMP_FOR);
4830 return (gimple_omp_subcode (g) & GF_OMP_FOR_COMBINED) != 0;
4834 /* Set the GF_OMP_FOR_COMBINED field in the OMP_FOR statement G depending on
4835 the boolean value of COMBINED_P. */
4838 gimple_omp_for_set_combined_p (gomp_for *g, bool combined_p)
4841 g->subcode |= GF_OMP_FOR_COMBINED;
4843 g->subcode &= ~GF_OMP_FOR_COMBINED;
4847 /* Return true if the OMP_FOR statement G has the
4848 GF_OMP_FOR_COMBINED_INTO flag set. */
4851 gimple_omp_for_combined_into_p (const gimple *g)
4853 GIMPLE_CHECK (g, GIMPLE_OMP_FOR);
4854 return (gimple_omp_subcode (g) & GF_OMP_FOR_COMBINED_INTO) != 0;
4858 /* Set the GF_OMP_FOR_COMBINED_INTO field in the OMP_FOR statement G depending
4859 on the boolean value of COMBINED_P. */
4862 gimple_omp_for_set_combined_into_p (gomp_for *g, bool combined_p)
4865 g->subcode |= GF_OMP_FOR_COMBINED_INTO;
4867 g->subcode &= ~GF_OMP_FOR_COMBINED_INTO;
4871 /* Return the clauses associated with the OMP_FOR statement GS. */
4874 gimple_omp_for_clauses (const gimple *gs)
4876 const gomp_for *omp_for_stmt = as_a <const gomp_for *> (gs);
4877 return omp_for_stmt->clauses;
4881 /* Return a pointer to the clauses associated with the OMP_FOR statement
4884 static inline tree *
4885 gimple_omp_for_clauses_ptr (gimple *gs)
4887 gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
4888 return &omp_for_stmt->clauses;
4892 /* Set CLAUSES to be the list of clauses associated with the OMP_FOR statement
4896 gimple_omp_for_set_clauses (gimple *gs, tree clauses)
4898 gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
4899 omp_for_stmt->clauses = clauses;
4903 /* Get the collapse count of the OMP_FOR statement GS. */
4905 static inline size_t
4906 gimple_omp_for_collapse (gimple *gs)
4908 gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
4909 return omp_for_stmt->collapse;
4913 /* Return the condition code associated with the OMP_FOR statement GS. */
4915 static inline enum tree_code
4916 gimple_omp_for_cond (const gimple *gs, size_t i)
4918 const gomp_for *omp_for_stmt = as_a <const gomp_for *> (gs);
4919 gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
4920 return omp_for_stmt->iter[i].cond;
4924 /* Set COND to be the condition code for the OMP_FOR statement GS. */
4927 gimple_omp_for_set_cond (gimple *gs, size_t i, enum tree_code cond)
4929 gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
4930 gcc_gimple_checking_assert (TREE_CODE_CLASS (cond) == tcc_comparison
4931 && i < omp_for_stmt->collapse);
4932 omp_for_stmt->iter[i].cond = cond;
4936 /* Return the index variable for the OMP_FOR statement GS. */
4939 gimple_omp_for_index (const gimple *gs, size_t i)
4941 const gomp_for *omp_for_stmt = as_a <const gomp_for *> (gs);
4942 gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
4943 return omp_for_stmt->iter[i].index;
4947 /* Return a pointer to the index variable for the OMP_FOR statement GS. */
4949 static inline tree *
4950 gimple_omp_for_index_ptr (gimple *gs, size_t i)
4952 gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
4953 gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
4954 return &omp_for_stmt->iter[i].index;
4958 /* Set INDEX to be the index variable for the OMP_FOR statement GS. */
4961 gimple_omp_for_set_index (gimple *gs, size_t i, tree index)
4963 gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
4964 gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
4965 omp_for_stmt->iter[i].index = index;
4969 /* Return the initial value for the OMP_FOR statement GS. */
4972 gimple_omp_for_initial (const gimple *gs, size_t i)
4974 const gomp_for *omp_for_stmt = as_a <const gomp_for *> (gs);
4975 gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
4976 return omp_for_stmt->iter[i].initial;
4980 /* Return a pointer to the initial value for the OMP_FOR statement GS. */
4982 static inline tree *
4983 gimple_omp_for_initial_ptr (gimple *gs, size_t i)
4985 gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
4986 gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
4987 return &omp_for_stmt->iter[i].initial;
4991 /* Set INITIAL to be the initial value for the OMP_FOR statement GS. */
4994 gimple_omp_for_set_initial (gimple *gs, size_t i, tree initial)
4996 gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
4997 gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
4998 omp_for_stmt->iter[i].initial = initial;
5002 /* Return the final value for the OMP_FOR statement GS. */
5005 gimple_omp_for_final (const gimple *gs, size_t i)
5007 const gomp_for *omp_for_stmt = as_a <const gomp_for *> (gs);
5008 gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
5009 return omp_for_stmt->iter[i].final;
5013 /* Return a pointer to the final value for the OMP_FOR statement GS. */
5015 static inline tree *
5016 gimple_omp_for_final_ptr (gimple *gs, size_t i)
5018 gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
5019 gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
5020 return &omp_for_stmt->iter[i].final;
5024 /* Set FINAL to be the final value for the OMP_FOR statement GS. */
5027 gimple_omp_for_set_final (gimple *gs, size_t i, tree final)
5029 gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
5030 gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
5031 omp_for_stmt->iter[i].final = final;
5035 /* Return the increment value for the OMP_FOR statement GS. */
5038 gimple_omp_for_incr (const gimple *gs, size_t i)
5040 const gomp_for *omp_for_stmt = as_a <const gomp_for *> (gs);
5041 gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
5042 return omp_for_stmt->iter[i].incr;
5046 /* Return a pointer to the increment value for the OMP_FOR statement GS. */
5048 static inline tree *
5049 gimple_omp_for_incr_ptr (gimple *gs, size_t i)
5051 gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
5052 gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
5053 return &omp_for_stmt->iter[i].incr;
5057 /* Set INCR to be the increment value for the OMP_FOR statement GS. */
5060 gimple_omp_for_set_incr (gimple *gs, size_t i, tree incr)
5062 gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
5063 gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
5064 omp_for_stmt->iter[i].incr = incr;
5068 /* Return a pointer to the sequence of statements to execute before the OMP_FOR
5069 statement GS starts. */
5071 static inline gimple_seq *
5072 gimple_omp_for_pre_body_ptr (gimple *gs)
5074 gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
5075 return &omp_for_stmt->pre_body;
5079 /* Return the sequence of statements to execute before the OMP_FOR
5080 statement GS starts. */
5082 static inline gimple_seq
5083 gimple_omp_for_pre_body (gimple *gs)
5085 return *gimple_omp_for_pre_body_ptr (gs);
5089 /* Set PRE_BODY to be the sequence of statements to execute before the
5090 OMP_FOR statement GS starts. */
5093 gimple_omp_for_set_pre_body (gimple *gs, gimple_seq pre_body)
5095 gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
5096 omp_for_stmt->pre_body = pre_body;
5099 /* Return the kernel_phony of OMP_FOR statement. */
5102 gimple_omp_for_grid_phony (const gomp_for *omp_for)
5104 return (gimple_omp_subcode (omp_for) & GF_OMP_FOR_GRID_PHONY) != 0;
5107 /* Set kernel_phony flag of OMP_FOR to VALUE. */
5110 gimple_omp_for_set_grid_phony (gomp_for *omp_for, bool value)
5113 omp_for->subcode |= GF_OMP_FOR_GRID_PHONY;
5115 omp_for->subcode &= ~GF_OMP_FOR_GRID_PHONY;
5118 /* Return the clauses associated with OMP_PARALLEL GS. */
5121 gimple_omp_parallel_clauses (const gimple *gs)
5123 const gomp_parallel *omp_parallel_stmt = as_a <const gomp_parallel *> (gs);
5124 return omp_parallel_stmt->clauses;
5128 /* Return a pointer to the clauses associated with OMP_PARALLEL_STMT. */
5130 static inline tree *
5131 gimple_omp_parallel_clauses_ptr (gomp_parallel *omp_parallel_stmt)
5133 return &omp_parallel_stmt->clauses;
5137 /* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL_STMT. */
5140 gimple_omp_parallel_set_clauses (gomp_parallel *omp_parallel_stmt,
5143 omp_parallel_stmt->clauses = clauses;
5147 /* Return the child function used to hold the body of OMP_PARALLEL_STMT. */
5150 gimple_omp_parallel_child_fn (const gomp_parallel *omp_parallel_stmt)
5152 return omp_parallel_stmt->child_fn;
5155 /* Return a pointer to the child function used to hold the body of
5156 OMP_PARALLEL_STMT. */
5158 static inline tree *
5159 gimple_omp_parallel_child_fn_ptr (gomp_parallel *omp_parallel_stmt)
5161 return &omp_parallel_stmt->child_fn;
5165 /* Set CHILD_FN to be the child function for OMP_PARALLEL_STMT. */
5168 gimple_omp_parallel_set_child_fn (gomp_parallel *omp_parallel_stmt,
5171 omp_parallel_stmt->child_fn = child_fn;
5175 /* Return the artificial argument used to send variables and values
5176 from the parent to the children threads in OMP_PARALLEL_STMT. */
5179 gimple_omp_parallel_data_arg (const gomp_parallel *omp_parallel_stmt)
5181 return omp_parallel_stmt->data_arg;
5185 /* Return a pointer to the data argument for OMP_PARALLEL_STMT. */
5187 static inline tree *
5188 gimple_omp_parallel_data_arg_ptr (gomp_parallel *omp_parallel_stmt)
5190 return &omp_parallel_stmt->data_arg;
5194 /* Set DATA_ARG to be the data argument for OMP_PARALLEL_STMT. */
5197 gimple_omp_parallel_set_data_arg (gomp_parallel *omp_parallel_stmt,
5200 omp_parallel_stmt->data_arg = data_arg;
5203 /* Return the kernel_phony flag of OMP_PARALLEL_STMT. */
5206 gimple_omp_parallel_grid_phony (const gomp_parallel *stmt)
5208 return (gimple_omp_subcode (stmt) & GF_OMP_PARALLEL_GRID_PHONY) != 0;
5211 /* Set kernel_phony flag of OMP_PARALLEL_STMT to VALUE. */
5214 gimple_omp_parallel_set_grid_phony (gomp_parallel *stmt, bool value)
5217 stmt->subcode |= GF_OMP_PARALLEL_GRID_PHONY;
5219 stmt->subcode &= ~GF_OMP_PARALLEL_GRID_PHONY;
5222 /* Return the clauses associated with OMP_TASK GS. */
5225 gimple_omp_task_clauses (const gimple *gs)
5227 const gomp_task *omp_task_stmt = as_a <const gomp_task *> (gs);
5228 return omp_task_stmt->clauses;
5232 /* Return a pointer to the clauses associated with OMP_TASK GS. */
5234 static inline tree *
5235 gimple_omp_task_clauses_ptr (gimple *gs)
5237 gomp_task *omp_task_stmt = as_a <gomp_task *> (gs);
5238 return &omp_task_stmt->clauses;
5242 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
5246 gimple_omp_task_set_clauses (gimple *gs, tree clauses)
5248 gomp_task *omp_task_stmt = as_a <gomp_task *> (gs);
5249 omp_task_stmt->clauses = clauses;
5253 /* Return true if OMP task statement G has the
5254 GF_OMP_TASK_TASKLOOP flag set. */
5257 gimple_omp_task_taskloop_p (const gimple *g)
5259 GIMPLE_CHECK (g, GIMPLE_OMP_TASK);
5260 return (gimple_omp_subcode (g) & GF_OMP_TASK_TASKLOOP) != 0;
5264 /* Set the GF_OMP_TASK_TASKLOOP field in G depending on the boolean
5265 value of TASKLOOP_P. */
5268 gimple_omp_task_set_taskloop_p (gimple *g, bool taskloop_p)
5270 GIMPLE_CHECK (g, GIMPLE_OMP_TASK);
5272 g->subcode |= GF_OMP_TASK_TASKLOOP;
5274 g->subcode &= ~GF_OMP_TASK_TASKLOOP;
5278 /* Return the child function used to hold the body of OMP_TASK GS. */
5281 gimple_omp_task_child_fn (const gimple *gs)
5283 const gomp_task *omp_task_stmt = as_a <const gomp_task *> (gs);
5284 return omp_task_stmt->child_fn;
5287 /* Return a pointer to the child function used to hold the body of
5290 static inline tree *
5291 gimple_omp_task_child_fn_ptr (gimple *gs)
5293 gomp_task *omp_task_stmt = as_a <gomp_task *> (gs);
5294 return &omp_task_stmt->child_fn;
5298 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
5301 gimple_omp_task_set_child_fn (gimple *gs, tree child_fn)
5303 gomp_task *omp_task_stmt = as_a <gomp_task *> (gs);
5304 omp_task_stmt->child_fn = child_fn;
5308 /* Return the artificial argument used to send variables and values
5309 from the parent to the children threads in OMP_TASK GS. */
5312 gimple_omp_task_data_arg (const gimple *gs)
5314 const gomp_task *omp_task_stmt = as_a <const gomp_task *> (gs);
5315 return omp_task_stmt->data_arg;
5319 /* Return a pointer to the data argument for OMP_TASK GS. */
5321 static inline tree *
5322 gimple_omp_task_data_arg_ptr (gimple *gs)
5324 gomp_task *omp_task_stmt = as_a <gomp_task *> (gs);
5325 return &omp_task_stmt->data_arg;
5329 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
5332 gimple_omp_task_set_data_arg (gimple *gs, tree data_arg)
5334 gomp_task *omp_task_stmt = as_a <gomp_task *> (gs);
5335 omp_task_stmt->data_arg = data_arg;
5339 /* Return the clauses associated with OMP_TASK GS. */
5342 gimple_omp_taskreg_clauses (const gimple *gs)
5344 const gimple_statement_omp_taskreg *omp_taskreg_stmt
5345 = as_a <const gimple_statement_omp_taskreg *> (gs);
5346 return omp_taskreg_stmt->clauses;
5350 /* Return a pointer to the clauses associated with OMP_TASK GS. */
5352 static inline tree *
5353 gimple_omp_taskreg_clauses_ptr (gimple *gs)
5355 gimple_statement_omp_taskreg *omp_taskreg_stmt
5356 = as_a <gimple_statement_omp_taskreg *> (gs);
5357 return &omp_taskreg_stmt->clauses;
5361 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
5365 gimple_omp_taskreg_set_clauses (gimple *gs, tree clauses)
5367 gimple_statement_omp_taskreg *omp_taskreg_stmt
5368 = as_a <gimple_statement_omp_taskreg *> (gs);
5369 omp_taskreg_stmt->clauses = clauses;
5373 /* Return the child function used to hold the body of OMP_TASK GS. */
5376 gimple_omp_taskreg_child_fn (const gimple *gs)
5378 const gimple_statement_omp_taskreg *omp_taskreg_stmt
5379 = as_a <const gimple_statement_omp_taskreg *> (gs);
5380 return omp_taskreg_stmt->child_fn;
5383 /* Return a pointer to the child function used to hold the body of
5386 static inline tree *
5387 gimple_omp_taskreg_child_fn_ptr (gimple *gs)
5389 gimple_statement_omp_taskreg *omp_taskreg_stmt
5390 = as_a <gimple_statement_omp_taskreg *> (gs);
5391 return &omp_taskreg_stmt->child_fn;
5395 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
5398 gimple_omp_taskreg_set_child_fn (gimple *gs, tree child_fn)
5400 gimple_statement_omp_taskreg *omp_taskreg_stmt
5401 = as_a <gimple_statement_omp_taskreg *> (gs);
5402 omp_taskreg_stmt->child_fn = child_fn;
5406 /* Return the artificial argument used to send variables and values
5407 from the parent to the children threads in OMP_TASK GS. */
5410 gimple_omp_taskreg_data_arg (const gimple *gs)
5412 const gimple_statement_omp_taskreg *omp_taskreg_stmt
5413 = as_a <const gimple_statement_omp_taskreg *> (gs);
5414 return omp_taskreg_stmt->data_arg;
5418 /* Return a pointer to the data argument for OMP_TASK GS. */
5420 static inline tree *
5421 gimple_omp_taskreg_data_arg_ptr (gimple *gs)
5423 gimple_statement_omp_taskreg *omp_taskreg_stmt
5424 = as_a <gimple_statement_omp_taskreg *> (gs);
5425 return &omp_taskreg_stmt->data_arg;
5429 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
5432 gimple_omp_taskreg_set_data_arg (gimple *gs, tree data_arg)
5434 gimple_statement_omp_taskreg *omp_taskreg_stmt
5435 = as_a <gimple_statement_omp_taskreg *> (gs);
5436 omp_taskreg_stmt->data_arg = data_arg;
5440 /* Return the copy function used to hold the body of OMP_TASK GS. */
5443 gimple_omp_task_copy_fn (const gimple *gs)
5445 const gomp_task *omp_task_stmt = as_a <const gomp_task *> (gs);
5446 return omp_task_stmt->copy_fn;
5449 /* Return a pointer to the copy function used to hold the body of
5452 static inline tree *
5453 gimple_omp_task_copy_fn_ptr (gimple *gs)
5455 gomp_task *omp_task_stmt = as_a <gomp_task *> (gs);
5456 return &omp_task_stmt->copy_fn;
5460 /* Set CHILD_FN to be the copy function for OMP_TASK GS. */
5463 gimple_omp_task_set_copy_fn (gimple *gs, tree copy_fn)
5465 gomp_task *omp_task_stmt = as_a <gomp_task *> (gs);
5466 omp_task_stmt->copy_fn = copy_fn;
5470 /* Return size of the data block in bytes in OMP_TASK GS. */
5473 gimple_omp_task_arg_size (const gimple *gs)
5475 const gomp_task *omp_task_stmt = as_a <const gomp_task *> (gs);
5476 return omp_task_stmt->arg_size;
5480 /* Return a pointer to the data block size for OMP_TASK GS. */
5482 static inline tree *
5483 gimple_omp_task_arg_size_ptr (gimple *gs)
5485 gomp_task *omp_task_stmt = as_a <gomp_task *> (gs);
5486 return &omp_task_stmt->arg_size;
5490 /* Set ARG_SIZE to be the data block size for OMP_TASK GS. */
5493 gimple_omp_task_set_arg_size (gimple *gs, tree arg_size)
5495 gomp_task *omp_task_stmt = as_a <gomp_task *> (gs);
5496 omp_task_stmt->arg_size = arg_size;
5500 /* Return align of the data block in bytes in OMP_TASK GS. */
5503 gimple_omp_task_arg_align (const gimple *gs)
5505 const gomp_task *omp_task_stmt = as_a <const gomp_task *> (gs);
5506 return omp_task_stmt->arg_align;
5510 /* Return a pointer to the data block align for OMP_TASK GS. */
5512 static inline tree *
5513 gimple_omp_task_arg_align_ptr (gimple *gs)
5515 gomp_task *omp_task_stmt = as_a <gomp_task *> (gs);
5516 return &omp_task_stmt->arg_align;
5520 /* Set ARG_SIZE to be the data block align for OMP_TASK GS. */
5523 gimple_omp_task_set_arg_align (gimple *gs, tree arg_align)
5525 gomp_task *omp_task_stmt = as_a <gomp_task *> (gs);
5526 omp_task_stmt->arg_align = arg_align;
5530 /* Return the clauses associated with OMP_SINGLE GS. */
5533 gimple_omp_single_clauses (const gimple *gs)
5535 const gomp_single *omp_single_stmt = as_a <const gomp_single *> (gs);
5536 return omp_single_stmt->clauses;
5540 /* Return a pointer to the clauses associated with OMP_SINGLE GS. */
5542 static inline tree *
5543 gimple_omp_single_clauses_ptr (gimple *gs)
5545 gomp_single *omp_single_stmt = as_a <gomp_single *> (gs);
5546 return &omp_single_stmt->clauses;
5550 /* Set CLAUSES to be the clauses associated with OMP_SINGLE_STMT. */
5553 gimple_omp_single_set_clauses (gomp_single *omp_single_stmt, tree clauses)
5555 omp_single_stmt->clauses = clauses;
5559 /* Return the clauses associated with OMP_TARGET GS. */
5562 gimple_omp_target_clauses (const gimple *gs)
5564 const gomp_target *omp_target_stmt = as_a <const gomp_target *> (gs);
5565 return omp_target_stmt->clauses;
5569 /* Return a pointer to the clauses associated with OMP_TARGET GS. */
5571 static inline tree *
5572 gimple_omp_target_clauses_ptr (gimple *gs)
5574 gomp_target *omp_target_stmt = as_a <gomp_target *> (gs);
5575 return &omp_target_stmt->clauses;
5579 /* Set CLAUSES to be the clauses associated with OMP_TARGET_STMT. */
5582 gimple_omp_target_set_clauses (gomp_target *omp_target_stmt,
5585 omp_target_stmt->clauses = clauses;
5589 /* Return the kind of the OMP_TARGET G. */
5592 gimple_omp_target_kind (const gimple *g)
5594 GIMPLE_CHECK (g, GIMPLE_OMP_TARGET);
5595 return (gimple_omp_subcode (g) & GF_OMP_TARGET_KIND_MASK);
5599 /* Set the kind of the OMP_TARGET G. */
5602 gimple_omp_target_set_kind (gomp_target *g, int kind)
5604 g->subcode = (g->subcode & ~GF_OMP_TARGET_KIND_MASK)
5605 | (kind & GF_OMP_TARGET_KIND_MASK);
5609 /* Return the child function used to hold the body of OMP_TARGET_STMT. */
5612 gimple_omp_target_child_fn (const gomp_target *omp_target_stmt)
5614 return omp_target_stmt->child_fn;
5617 /* Return a pointer to the child function used to hold the body of
5620 static inline tree *
5621 gimple_omp_target_child_fn_ptr (gomp_target *omp_target_stmt)
5623 return &omp_target_stmt->child_fn;
5627 /* Set CHILD_FN to be the child function for OMP_TARGET_STMT. */
5630 gimple_omp_target_set_child_fn (gomp_target *omp_target_stmt,
5633 omp_target_stmt->child_fn = child_fn;
5637 /* Return the artificial argument used to send variables and values
5638 from the parent to the children threads in OMP_TARGET_STMT. */
5641 gimple_omp_target_data_arg (const gomp_target *omp_target_stmt)
5643 return omp_target_stmt->data_arg;
5647 /* Return a pointer to the data argument for OMP_TARGET GS. */
5649 static inline tree *
5650 gimple_omp_target_data_arg_ptr (gomp_target *omp_target_stmt)
5652 return &omp_target_stmt->data_arg;
5656 /* Set DATA_ARG to be the data argument for OMP_TARGET_STMT. */
5659 gimple_omp_target_set_data_arg (gomp_target *omp_target_stmt,
5662 omp_target_stmt->data_arg = data_arg;
5666 /* Return the clauses associated with OMP_TEAMS GS. */
5669 gimple_omp_teams_clauses (const gimple *gs)
5671 const gomp_teams *omp_teams_stmt = as_a <const gomp_teams *> (gs);
5672 return omp_teams_stmt->clauses;
5676 /* Return a pointer to the clauses associated with OMP_TEAMS GS. */
5678 static inline tree *
5679 gimple_omp_teams_clauses_ptr (gimple *gs)
5681 gomp_teams *omp_teams_stmt = as_a <gomp_teams *> (gs);
5682 return &omp_teams_stmt->clauses;
5686 /* Set CLAUSES to be the clauses associated with OMP_TEAMS_STMT. */
5689 gimple_omp_teams_set_clauses (gomp_teams *omp_teams_stmt, tree clauses)
5691 omp_teams_stmt->clauses = clauses;
5694 /* Return the kernel_phony flag of an OMP_TEAMS_STMT. */
5697 gimple_omp_teams_grid_phony (const gomp_teams *omp_teams_stmt)
5699 return (gimple_omp_subcode (omp_teams_stmt) & GF_OMP_TEAMS_GRID_PHONY) != 0;
5702 /* Set kernel_phony flag of an OMP_TEAMS_STMT to VALUE. */
5705 gimple_omp_teams_set_grid_phony (gomp_teams *omp_teams_stmt, bool value)
5708 omp_teams_stmt->subcode |= GF_OMP_TEAMS_GRID_PHONY;
5710 omp_teams_stmt->subcode &= ~GF_OMP_TEAMS_GRID_PHONY;
5713 /* Return the clauses associated with OMP_SECTIONS GS. */
5716 gimple_omp_sections_clauses (const gimple *gs)
5718 const gomp_sections *omp_sections_stmt = as_a <const gomp_sections *> (gs);
5719 return omp_sections_stmt->clauses;
5723 /* Return a pointer to the clauses associated with OMP_SECTIONS GS. */
5725 static inline tree *
5726 gimple_omp_sections_clauses_ptr (gimple *gs)
5728 gomp_sections *omp_sections_stmt = as_a <gomp_sections *> (gs);
5729 return &omp_sections_stmt->clauses;
5733 /* Set CLAUSES to be the set of clauses associated with OMP_SECTIONS
5737 gimple_omp_sections_set_clauses (gimple *gs, tree clauses)
5739 gomp_sections *omp_sections_stmt = as_a <gomp_sections *> (gs);
5740 omp_sections_stmt->clauses = clauses;
5744 /* Return the control variable associated with the GIMPLE_OMP_SECTIONS
5748 gimple_omp_sections_control (const gimple *gs)
5750 const gomp_sections *omp_sections_stmt = as_a <const gomp_sections *> (gs);
5751 return omp_sections_stmt->control;
5755 /* Return a pointer to the clauses associated with the GIMPLE_OMP_SECTIONS
5758 static inline tree *
5759 gimple_omp_sections_control_ptr (gimple *gs)
5761 gomp_sections *omp_sections_stmt = as_a <gomp_sections *> (gs);
5762 return &omp_sections_stmt->control;
5766 /* Set CONTROL to be the set of clauses associated with the
5767 GIMPLE_OMP_SECTIONS in GS. */
5770 gimple_omp_sections_set_control (gimple *gs, tree control)
5772 gomp_sections *omp_sections_stmt = as_a <gomp_sections *> (gs);
5773 omp_sections_stmt->control = control;
5777 /* Set the value being stored in an atomic store. */
5780 gimple_omp_atomic_store_set_val (gomp_atomic_store *store_stmt, tree val)
5782 store_stmt->val = val;
5786 /* Return the value being stored in an atomic store. */
5789 gimple_omp_atomic_store_val (const gomp_atomic_store *store_stmt)
5791 return store_stmt->val;
5795 /* Return a pointer to the value being stored in an atomic store. */
5797 static inline tree *
5798 gimple_omp_atomic_store_val_ptr (gomp_atomic_store *store_stmt)
5800 return &store_stmt->val;
5804 /* Set the LHS of an atomic load. */
5807 gimple_omp_atomic_load_set_lhs (gomp_atomic_load *load_stmt, tree lhs)
5809 load_stmt->lhs = lhs;
5813 /* Get the LHS of an atomic load. */
5816 gimple_omp_atomic_load_lhs (const gomp_atomic_load *load_stmt)
5818 return load_stmt->lhs;
5822 /* Return a pointer to the LHS of an atomic load. */
5824 static inline tree *
5825 gimple_omp_atomic_load_lhs_ptr (gomp_atomic_load *load_stmt)
5827 return &load_stmt->lhs;
5831 /* Set the RHS of an atomic load. */
5834 gimple_omp_atomic_load_set_rhs (gomp_atomic_load *load_stmt, tree rhs)
5836 load_stmt->rhs = rhs;
5840 /* Get the RHS of an atomic load. */
5843 gimple_omp_atomic_load_rhs (const gomp_atomic_load *load_stmt)
5845 return load_stmt->rhs;
5849 /* Return a pointer to the RHS of an atomic load. */
5851 static inline tree *
5852 gimple_omp_atomic_load_rhs_ptr (gomp_atomic_load *load_stmt)
5854 return &load_stmt->rhs;
5858 /* Get the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
5861 gimple_omp_continue_control_def (const gomp_continue *cont_stmt)
5863 return cont_stmt->control_def;
5866 /* The same as above, but return the address. */
5868 static inline tree *
5869 gimple_omp_continue_control_def_ptr (gomp_continue *cont_stmt)
5871 return &cont_stmt->control_def;
5874 /* Set the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
5877 gimple_omp_continue_set_control_def (gomp_continue *cont_stmt, tree def)
5879 cont_stmt->control_def = def;
5883 /* Get the use of the control variable in a GIMPLE_OMP_CONTINUE. */
5886 gimple_omp_continue_control_use (const gomp_continue *cont_stmt)
5888 return cont_stmt->control_use;
5892 /* The same as above, but return the address. */
5894 static inline tree *
5895 gimple_omp_continue_control_use_ptr (gomp_continue *cont_stmt)
5897 return &cont_stmt->control_use;
5901 /* Set the use of the control variable in a GIMPLE_OMP_CONTINUE. */
5904 gimple_omp_continue_set_control_use (gomp_continue *cont_stmt, tree use)
5906 cont_stmt->control_use = use;
5909 /* Return a pointer to the body for the GIMPLE_TRANSACTION statement
5910 TRANSACTION_STMT. */
5912 static inline gimple_seq *
5913 gimple_transaction_body_ptr (gtransaction *transaction_stmt)
5915 return &transaction_stmt->body;
5918 /* Return the body for the GIMPLE_TRANSACTION statement TRANSACTION_STMT. */
5920 static inline gimple_seq
5921 gimple_transaction_body (gtransaction *transaction_stmt)
5923 return transaction_stmt->body;
5926 /* Return the label associated with a GIMPLE_TRANSACTION. */
5929 gimple_transaction_label_norm (const gtransaction *transaction_stmt)
5931 return transaction_stmt->label_norm;
5934 static inline tree *
5935 gimple_transaction_label_norm_ptr (gtransaction *transaction_stmt)
5937 return &transaction_stmt->label_norm;
5941 gimple_transaction_label_uninst (const gtransaction *transaction_stmt)
5943 return transaction_stmt->label_uninst;
5946 static inline tree *
5947 gimple_transaction_label_uninst_ptr (gtransaction *transaction_stmt)
5949 return &transaction_stmt->label_uninst;
5953 gimple_transaction_label_over (const gtransaction *transaction_stmt)
5955 return transaction_stmt->label_over;
5958 static inline tree *
5959 gimple_transaction_label_over_ptr (gtransaction *transaction_stmt)
5961 return &transaction_stmt->label_over;
5964 /* Return the subcode associated with a GIMPLE_TRANSACTION. */
5966 static inline unsigned int
5967 gimple_transaction_subcode (const gtransaction *transaction_stmt)
5969 return transaction_stmt->subcode;
5972 /* Set BODY to be the body for the GIMPLE_TRANSACTION statement
5973 TRANSACTION_STMT. */
5976 gimple_transaction_set_body (gtransaction *transaction_stmt,
5979 transaction_stmt->body = body;
5982 /* Set the label associated with a GIMPLE_TRANSACTION. */
5985 gimple_transaction_set_label_norm (gtransaction *transaction_stmt, tree label)
5987 transaction_stmt->label_norm = label;
5991 gimple_transaction_set_label_uninst (gtransaction *transaction_stmt, tree label)
5993 transaction_stmt->label_uninst = label;
5997 gimple_transaction_set_label_over (gtransaction *transaction_stmt, tree label)
5999 transaction_stmt->label_over = label;
6002 /* Set the subcode associated with a GIMPLE_TRANSACTION. */
6005 gimple_transaction_set_subcode (gtransaction *transaction_stmt,
6006 unsigned int subcode)
6008 transaction_stmt->subcode = subcode;
6011 /* Return a pointer to the return value for GIMPLE_RETURN GS. */
6013 static inline tree *
6014 gimple_return_retval_ptr (greturn *gs)
6019 /* Return the return value for GIMPLE_RETURN GS. */
6022 gimple_return_retval (const greturn *gs)
6028 /* Set RETVAL to be the return value for GIMPLE_RETURN GS. */
6031 gimple_return_set_retval (greturn *gs, tree retval)
6037 /* Return the return bounds for GIMPLE_RETURN GS. */
6040 gimple_return_retbnd (const gimple *gs)
6042 GIMPLE_CHECK (gs, GIMPLE_RETURN);
6043 return gimple_op (gs, 1);
6047 /* Set RETVAL to be the return bounds for GIMPLE_RETURN GS. */
6050 gimple_return_set_retbnd (gimple *gs, tree retval)
6052 GIMPLE_CHECK (gs, GIMPLE_RETURN);
6053 gimple_set_op (gs, 1, retval);
6057 /* Returns true when the gimple statement STMT is any of the OMP types. */
6059 #define CASE_GIMPLE_OMP \
6060 case GIMPLE_OMP_PARALLEL: \
6061 case GIMPLE_OMP_TASK: \
6062 case GIMPLE_OMP_FOR: \
6063 case GIMPLE_OMP_SECTIONS: \
6064 case GIMPLE_OMP_SECTIONS_SWITCH: \
6065 case GIMPLE_OMP_SINGLE: \
6066 case GIMPLE_OMP_TARGET: \
6067 case GIMPLE_OMP_TEAMS: \
6068 case GIMPLE_OMP_SECTION: \
6069 case GIMPLE_OMP_MASTER: \
6070 case GIMPLE_OMP_TASKGROUP: \
6071 case GIMPLE_OMP_ORDERED: \
6072 case GIMPLE_OMP_CRITICAL: \
6073 case GIMPLE_OMP_RETURN: \
6074 case GIMPLE_OMP_ATOMIC_LOAD: \
6075 case GIMPLE_OMP_ATOMIC_STORE: \
6076 case GIMPLE_OMP_CONTINUE: \
6077 case GIMPLE_OMP_GRID_BODY
6080 is_gimple_omp (const gimple *stmt)
6082 switch (gimple_code (stmt))
6091 /* Return true if the OMP gimple statement STMT is any of the OpenACC types
6095 is_gimple_omp_oacc (const gimple *stmt)
6097 gcc_assert (is_gimple_omp (stmt));
6098 switch (gimple_code (stmt))
6100 case GIMPLE_OMP_FOR:
6101 switch (gimple_omp_for_kind (stmt))
6103 case GF_OMP_FOR_KIND_OACC_LOOP:
6108 case GIMPLE_OMP_TARGET:
6109 switch (gimple_omp_target_kind (stmt))
6111 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
6112 case GF_OMP_TARGET_KIND_OACC_KERNELS:
6113 case GF_OMP_TARGET_KIND_OACC_DATA:
6114 case GF_OMP_TARGET_KIND_OACC_UPDATE:
6115 case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
6116 case GF_OMP_TARGET_KIND_OACC_DECLARE:
6117 case GF_OMP_TARGET_KIND_OACC_HOST_DATA:
6128 /* Return true if the OMP gimple statement STMT is offloaded. */
6131 is_gimple_omp_offloaded (const gimple *stmt)
6133 gcc_assert (is_gimple_omp (stmt));
6134 switch (gimple_code (stmt))
6136 case GIMPLE_OMP_TARGET:
6137 switch (gimple_omp_target_kind (stmt))
6139 case GF_OMP_TARGET_KIND_REGION:
6140 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
6141 case GF_OMP_TARGET_KIND_OACC_KERNELS:
6152 /* Returns TRUE if statement G is a GIMPLE_NOP. */
6155 gimple_nop_p (const gimple *g)
6157 return gimple_code (g) == GIMPLE_NOP;
6161 /* Return true if GS is a GIMPLE_RESX. */
6164 is_gimple_resx (const gimple *gs)
6166 return gimple_code (gs) == GIMPLE_RESX;
6169 /* Return the type of the main expression computed by STMT. Return
6170 void_type_node if the statement computes nothing. */
6173 gimple_expr_type (const gimple *stmt)
6175 enum gimple_code code = gimple_code (stmt);
6176 /* In general we want to pass out a type that can be substituted
6177 for both the RHS and the LHS types if there is a possibly
6178 useless conversion involved. That means returning the
6179 original RHS type as far as we can reconstruct it. */
6180 if (code == GIMPLE_CALL)
6182 const gcall *call_stmt = as_a <const gcall *> (stmt);
6183 if (gimple_call_internal_p (call_stmt)
6184 && gimple_call_internal_fn (call_stmt) == IFN_MASK_STORE)
6185 return TREE_TYPE (gimple_call_arg (call_stmt, 3));
6187 return gimple_call_return_type (call_stmt);
6189 else if (code == GIMPLE_ASSIGN)
6191 if (gimple_assign_rhs_code (stmt) == POINTER_PLUS_EXPR)
6192 return TREE_TYPE (gimple_assign_rhs1 (stmt));
6194 /* As fallback use the type of the LHS. */
6195 return TREE_TYPE (gimple_get_lhs (stmt));
6197 else if (code == GIMPLE_COND)
6198 return boolean_type_node;
6200 return void_type_node;
6203 /* Enum and arrays used for allocation stats. Keep in sync with
6204 gimple.c:gimple_alloc_kind_names. */
6205 enum gimple_alloc_kind
6207 gimple_alloc_kind_assign, /* Assignments. */
6208 gimple_alloc_kind_phi, /* PHI nodes. */
6209 gimple_alloc_kind_cond, /* Conditionals. */
6210 gimple_alloc_kind_rest, /* Everything else. */
6211 gimple_alloc_kind_all
6214 extern int gimple_alloc_counts[];
6215 extern int gimple_alloc_sizes[];
6217 /* Return the allocation kind for a given stmt CODE. */
6218 static inline enum gimple_alloc_kind
6219 gimple_alloc_kind (enum gimple_code code)
6224 return gimple_alloc_kind_assign;
6226 return gimple_alloc_kind_phi;
6228 return gimple_alloc_kind_cond;
6230 return gimple_alloc_kind_rest;
6234 /* Return true if a location should not be emitted for this statement
6235 by annotate_all_with_location. */
6238 gimple_do_not_emit_location_p (gimple *g)
6240 return gimple_plf (g, GF_PLF_1);
6243 /* Mark statement G so a location will not be emitted by
6244 annotate_one_with_location. */
6247 gimple_set_do_not_emit_location (gimple *g)
6249 /* The PLF flags are initialized to 0 when a new tuple is created,
6250 so no need to initialize it anywhere. */
6251 gimple_set_plf (g, GF_PLF_1, true);
6255 /* Macros for showing usage statistics. */
6256 #define SCALE(x) ((unsigned long) ((x) < 1024*10 \
6258 : ((x) < 1024*1024*10 \
6260 : (x) / (1024*1024))))
6262 #define LABEL(x) ((x) < 1024*10 ? 'b' : ((x) < 1024*1024*10 ? 'k' : 'M'))
6264 #endif /* GCC_GIMPLE_H */