1 /* Gimple IR definitions.
3 Copyright (C) 2007-2015 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_FOR_KIND_MASK = (1 << 3) - 1,
150 GF_OMP_FOR_KIND_FOR = 0,
151 GF_OMP_FOR_KIND_DISTRIBUTE = 1,
152 GF_OMP_FOR_KIND_CILKFOR = 2,
153 GF_OMP_FOR_KIND_OACC_LOOP = 3,
154 /* Flag for SIMD variants of OMP_FOR kinds. */
155 GF_OMP_FOR_SIMD = 1 << 2,
156 GF_OMP_FOR_KIND_SIMD = GF_OMP_FOR_SIMD | 0,
157 GF_OMP_FOR_KIND_CILKSIMD = GF_OMP_FOR_SIMD | 1,
158 GF_OMP_FOR_COMBINED = 1 << 3,
159 GF_OMP_FOR_COMBINED_INTO = 1 << 4,
160 GF_OMP_TARGET_KIND_MASK = (1 << 3) - 1,
161 GF_OMP_TARGET_KIND_REGION = 0,
162 GF_OMP_TARGET_KIND_DATA = 1,
163 GF_OMP_TARGET_KIND_UPDATE = 2,
164 GF_OMP_TARGET_KIND_OACC_PARALLEL = 3,
165 GF_OMP_TARGET_KIND_OACC_KERNELS = 4,
166 GF_OMP_TARGET_KIND_OACC_DATA = 5,
167 GF_OMP_TARGET_KIND_OACC_UPDATE = 6,
168 GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA = 7,
170 /* True on an GIMPLE_OMP_RETURN statement if the return does not require
171 a thread synchronization via some sort of barrier. The exact barrier
172 that would otherwise be emitted is dependent on the OMP statement with
173 which this return is associated. */
174 GF_OMP_RETURN_NOWAIT = 1 << 0,
176 GF_OMP_SECTION_LAST = 1 << 0,
177 GF_OMP_ATOMIC_NEED_VALUE = 1 << 0,
178 GF_OMP_ATOMIC_SEQ_CST = 1 << 1,
179 GF_PREDICT_TAKEN = 1 << 15
182 /* Currently, there are only two types of gimple debug stmt. Others are
183 envisioned, for example, to enable the generation of is_stmt notes
184 in line number information, to mark sequence points, etc. This
185 subcode is to be used to tell them apart. */
186 enum gimple_debug_subcode {
187 GIMPLE_DEBUG_BIND = 0,
188 GIMPLE_DEBUG_SOURCE_BIND = 1
191 /* Masks for selecting a pass local flag (PLF) to work on. These
192 masks are used by gimple_set_plf and gimple_plf. */
198 /* Data structure definitions for GIMPLE tuples. NOTE: word markers
199 are for 64 bit hosts. */
201 struct GTY((desc ("gimple_statement_structure (&%h)"), tag ("GSS_BASE"),
202 chain_next ("%h.next"), variable_size))
206 Main identifying code for a tuple. */
207 ENUM_BITFIELD(gimple_code) code : 8;
209 /* Nonzero if a warning should not be emitted on this tuple. */
210 unsigned int no_warning : 1;
212 /* Nonzero if this tuple has been visited. Passes are responsible
213 for clearing this bit before using it. */
214 unsigned int visited : 1;
216 /* Nonzero if this tuple represents a non-temporal move. */
217 unsigned int nontemporal_move : 1;
219 /* Pass local flags. These flags are free for any pass to use as
220 they see fit. Passes should not assume that these flags contain
221 any useful value when the pass starts. Any initial state that
222 the pass requires should be set on entry to the pass. See
223 gimple_set_plf and gimple_plf for usage. */
224 unsigned int plf : 2;
226 /* Nonzero if this statement has been modified and needs to have its
227 operands rescanned. */
228 unsigned modified : 1;
230 /* Nonzero if this statement contains volatile operands. */
231 unsigned has_volatile_ops : 1;
233 /* Padding to get subcode to 16 bit alignment. */
236 /* The SUBCODE field can be used for tuple-specific flags for tuples
237 that do not require subcodes. Note that SUBCODE should be at
238 least as wide as tree codes, as several tuples store tree codes
240 unsigned int subcode : 16;
242 /* UID of this statement. This is used by passes that want to
243 assign IDs to statements. It must be assigned and used by each
244 pass. By default it should be assumed to contain garbage. */
248 Locus information for debug info. */
251 /* Number of operands in this tuple. */
255 Basic block holding this statement. */
259 Linked lists of gimple statements. The next pointers form
260 a NULL terminated list, the prev pointers are a cyclic list.
261 A gimple statement is hence also a double-ended list of
262 statements, with the pointer itself being the first element,
263 and the prev pointer being the last. */
265 gimple *GTY((skip)) prev;
269 /* Base structure for tuples with operands. */
271 /* This gimple subclass has no tag value. */
273 gimple_statement_with_ops_base : public gimple
275 /* [ WORD 1-6 ] : base class */
278 SSA operand vectors. NOTE: It should be possible to
279 amalgamate these vectors with the operand vector OP. However,
280 the SSA operand vectors are organized differently and contain
281 more information (like immediate use chaining). */
282 struct use_optype_d GTY((skip (""))) *use_ops;
286 /* Statements that take register operands. */
288 struct GTY((tag("GSS_WITH_OPS")))
289 gimple_statement_with_ops : public gimple_statement_with_ops_base
291 /* [ WORD 1-7 ] : base class */
294 Operand vector. NOTE! This must always be the last field
295 of this structure. In particular, this means that this
296 structure cannot be embedded inside another one. */
297 tree GTY((length ("%h.num_ops"))) op[1];
301 /* Base for statements that take both memory and register operands. */
303 struct GTY((tag("GSS_WITH_MEM_OPS_BASE")))
304 gimple_statement_with_memory_ops_base : public gimple_statement_with_ops_base
306 /* [ WORD 1-7 ] : base class */
309 Virtual operands for this statement. The GC will pick them
310 up via the ssa_names array. */
311 tree GTY((skip (""))) vdef;
312 tree GTY((skip (""))) vuse;
316 /* Statements that take both memory and register operands. */
318 struct GTY((tag("GSS_WITH_MEM_OPS")))
319 gimple_statement_with_memory_ops :
320 public gimple_statement_with_memory_ops_base
322 /* [ WORD 1-9 ] : base class */
325 Operand vector. NOTE! This must always be the last field
326 of this structure. In particular, this means that this
327 structure cannot be embedded inside another one. */
328 tree GTY((length ("%h.num_ops"))) op[1];
332 /* Call statements that take both memory and register operands. */
334 struct GTY((tag("GSS_CALL")))
335 gcall : public gimple_statement_with_memory_ops_base
337 /* [ WORD 1-9 ] : base class */
340 struct pt_solution call_used;
341 struct pt_solution call_clobbered;
344 union GTY ((desc ("%1.subcode & GF_CALL_INTERNAL"))) {
345 tree GTY ((tag ("0"))) fntype;
346 enum internal_fn GTY ((tag ("GF_CALL_INTERNAL"))) internal_fn;
350 Operand vector. NOTE! This must always be the last field
351 of this structure. In particular, this means that this
352 structure cannot be embedded inside another one. */
353 tree GTY((length ("%h.num_ops"))) op[1];
355 static const enum gimple_code code_ = GIMPLE_CALL;
359 /* OMP statements. */
361 struct GTY((tag("GSS_OMP")))
362 gimple_statement_omp : public gimple
364 /* [ WORD 1-6 ] : base class */
373 struct GTY((tag("GSS_BIND")))
374 gbind : public gimple
376 /* [ WORD 1-6 ] : base class */
379 Variables declared in this scope. */
383 This is different than the BLOCK field in gimple,
384 which is analogous to TREE_BLOCK (i.e., the lexical block holding
385 this statement). This field is the equivalent of BIND_EXPR_BLOCK
386 in tree land (i.e., the lexical scope defined by this bind). See
397 struct GTY((tag("GSS_CATCH")))
398 gcatch : public gimple
400 /* [ WORD 1-6 ] : base class */
410 /* GIMPLE_EH_FILTER */
412 struct GTY((tag("GSS_EH_FILTER")))
413 geh_filter : public gimple
415 /* [ WORD 1-6 ] : base class */
428 struct GTY((tag("GSS_EH_ELSE")))
429 geh_else : public gimple
431 /* [ WORD 1-6 ] : base class */
434 gimple_seq n_body, e_body;
437 /* GIMPLE_EH_MUST_NOT_THROW */
439 struct GTY((tag("GSS_EH_MNT")))
440 geh_mnt : public gimple
442 /* [ WORD 1-6 ] : base class */
444 /* [ WORD 7 ] Abort function decl. */
450 struct GTY((tag("GSS_PHI")))
453 /* [ WORD 1-6 ] : base class */
463 struct phi_arg_d GTY ((length ("%h.nargs"))) args[1];
467 /* GIMPLE_RESX, GIMPLE_EH_DISPATCH */
469 struct GTY((tag("GSS_EH_CTRL")))
470 gimple_statement_eh_ctrl : public gimple
472 /* [ WORD 1-6 ] : base class */
475 Exception region number. */
479 struct GTY((tag("GSS_EH_CTRL")))
480 gresx : public gimple_statement_eh_ctrl
482 /* No extra fields; adds invariant:
483 stmt->code == GIMPLE_RESX. */
486 struct GTY((tag("GSS_EH_CTRL")))
487 geh_dispatch : public gimple_statement_eh_ctrl
489 /* No extra fields; adds invariant:
490 stmt->code == GIMPLE_EH_DISPATH. */
496 struct GTY((tag("GSS_TRY")))
499 /* [ WORD 1-6 ] : base class */
502 Expression to evaluate. */
506 Cleanup expression. */
510 /* Kind of GIMPLE_TRY statements. */
511 enum gimple_try_flags
514 GIMPLE_TRY_CATCH = 1 << 0,
517 GIMPLE_TRY_FINALLY = 1 << 1,
518 GIMPLE_TRY_KIND = GIMPLE_TRY_CATCH | GIMPLE_TRY_FINALLY,
520 /* Analogous to TRY_CATCH_IS_CLEANUP. */
521 GIMPLE_TRY_CATCH_IS_CLEANUP = 1 << 2
524 /* GIMPLE_WITH_CLEANUP_EXPR */
526 struct GTY((tag("GSS_WCE")))
527 gimple_statement_wce : public gimple
529 /* [ WORD 1-6 ] : base class */
531 /* Subcode: CLEANUP_EH_ONLY. True if the cleanup should only be
532 executed if an exception is thrown, not on normal exit of its
533 scope. This flag is analogous to the CLEANUP_EH_ONLY flag
537 Cleanup expression. */
544 struct GTY((tag("GSS_ASM")))
545 gasm : public gimple_statement_with_memory_ops_base
547 /* [ WORD 1-9 ] : base class */
550 __asm__ statement. */
554 Number of inputs, outputs, clobbers, labels. */
561 Operand vector. NOTE! This must always be the last field
562 of this structure. In particular, this means that this
563 structure cannot be embedded inside another one. */
564 tree GTY((length ("%h.num_ops"))) op[1];
567 /* GIMPLE_OMP_CRITICAL */
569 struct GTY((tag("GSS_OMP_CRITICAL")))
570 gomp_critical : public gimple_statement_omp
572 /* [ WORD 1-7 ] : base class */
575 Critical section name. */
580 struct GTY(()) gimple_omp_for_iter {
581 /* Condition code. */
584 /* Index variable. */
599 struct GTY((tag("GSS_OMP_FOR")))
600 gomp_for : public gimple_statement_omp
602 /* [ WORD 1-7 ] : base class */
608 Number of elements in iter array. */
612 struct gimple_omp_for_iter * GTY((length ("%h.collapse"))) iter;
615 Pre-body evaluated before the loop body begins. */
620 /* GIMPLE_OMP_PARALLEL, GIMPLE_OMP_TARGET, GIMPLE_OMP_TASK */
622 struct GTY((tag("GSS_OMP_PARALLEL_LAYOUT")))
623 gimple_statement_omp_parallel_layout : public gimple_statement_omp
625 /* [ WORD 1-7 ] : base class */
632 Child function holding the body of the parallel region. */
636 Shared data argument. */
640 /* GIMPLE_OMP_PARALLEL or GIMPLE_TASK */
641 struct GTY((tag("GSS_OMP_PARALLEL_LAYOUT")))
642 gimple_statement_omp_taskreg : public gimple_statement_omp_parallel_layout
644 /* No extra fields; adds invariant:
645 stmt->code == GIMPLE_OMP_PARALLEL
646 || stmt->code == GIMPLE_OMP_TASK. */
649 /* GIMPLE_OMP_PARALLEL */
650 struct GTY((tag("GSS_OMP_PARALLEL_LAYOUT")))
651 gomp_parallel : public gimple_statement_omp_taskreg
653 /* No extra fields; adds invariant:
654 stmt->code == GIMPLE_OMP_PARALLEL. */
657 /* GIMPLE_OMP_TARGET */
658 struct GTY((tag("GSS_OMP_PARALLEL_LAYOUT")))
659 gomp_target : public gimple_statement_omp_parallel_layout
661 /* No extra fields; adds invariant:
662 stmt->code == GIMPLE_OMP_TARGET. */
665 /* GIMPLE_OMP_TASK */
667 struct GTY((tag("GSS_OMP_TASK")))
668 gomp_task : public gimple_statement_omp_taskreg
670 /* [ WORD 1-10 ] : base class */
673 Child function holding firstprivate initialization if needed. */
677 Size and alignment in bytes of the argument data block. */
683 /* GIMPLE_OMP_SECTION */
684 /* Uses struct gimple_statement_omp. */
687 /* GIMPLE_OMP_SECTIONS */
689 struct GTY((tag("GSS_OMP_SECTIONS")))
690 gomp_sections : public gimple_statement_omp
692 /* [ WORD 1-7 ] : base class */
698 The control variable used for deciding which of the sections to
703 /* GIMPLE_OMP_CONTINUE.
705 Note: This does not inherit from gimple_statement_omp, because we
706 do not need the body field. */
708 struct GTY((tag("GSS_OMP_CONTINUE")))
709 gomp_continue : public gimple
711 /* [ WORD 1-6 ] : base class */
720 /* GIMPLE_OMP_SINGLE, GIMPLE_OMP_TEAMS */
722 struct GTY((tag("GSS_OMP_SINGLE_LAYOUT")))
723 gimple_statement_omp_single_layout : public gimple_statement_omp
725 /* [ WORD 1-7 ] : base class */
731 struct GTY((tag("GSS_OMP_SINGLE_LAYOUT")))
732 gomp_single : public gimple_statement_omp_single_layout
734 /* No extra fields; adds invariant:
735 stmt->code == GIMPLE_OMP_SINGLE. */
738 struct GTY((tag("GSS_OMP_SINGLE_LAYOUT")))
739 gomp_teams : public gimple_statement_omp_single_layout
741 /* No extra fields; adds invariant:
742 stmt->code == GIMPLE_OMP_TEAMS. */
746 /* GIMPLE_OMP_ATOMIC_LOAD.
747 Note: This is based on gimple, not g_s_omp, because g_s_omp
748 contains a sequence, which we don't need here. */
750 struct GTY((tag("GSS_OMP_ATOMIC_LOAD")))
751 gomp_atomic_load : public gimple
753 /* [ WORD 1-6 ] : base class */
759 /* GIMPLE_OMP_ATOMIC_STORE.
760 See note on GIMPLE_OMP_ATOMIC_LOAD. */
762 struct GTY((tag("GSS_OMP_ATOMIC_STORE_LAYOUT")))
763 gimple_statement_omp_atomic_store_layout : public gimple
765 /* [ WORD 1-6 ] : base class */
771 struct GTY((tag("GSS_OMP_ATOMIC_STORE_LAYOUT")))
773 public gimple_statement_omp_atomic_store_layout
775 /* No extra fields; adds invariant:
776 stmt->code == GIMPLE_OMP_ATOMIC_STORE. */
779 struct GTY((tag("GSS_OMP_ATOMIC_STORE_LAYOUT")))
780 gimple_statement_omp_return :
781 public gimple_statement_omp_atomic_store_layout
783 /* No extra fields; adds invariant:
784 stmt->code == GIMPLE_OMP_RETURN. */
787 /* GIMPLE_TRANSACTION. */
789 /* Bits to be stored in the GIMPLE_TRANSACTION subcode. */
791 /* The __transaction_atomic was declared [[outer]] or it is
792 __transaction_relaxed. */
793 #define GTMA_IS_OUTER (1u << 0)
794 #define GTMA_IS_RELAXED (1u << 1)
795 #define GTMA_DECLARATION_MASK (GTMA_IS_OUTER | GTMA_IS_RELAXED)
797 /* The transaction is seen to not have an abort. */
798 #define GTMA_HAVE_ABORT (1u << 2)
799 /* The transaction is seen to have loads or stores. */
800 #define GTMA_HAVE_LOAD (1u << 3)
801 #define GTMA_HAVE_STORE (1u << 4)
802 /* The transaction MAY enter serial irrevocable mode in its dynamic scope. */
803 #define GTMA_MAY_ENTER_IRREVOCABLE (1u << 5)
804 /* The transaction WILL enter serial irrevocable mode.
805 An irrevocable block post-dominates the entire transaction, such
806 that all invocations of the transaction will go serial-irrevocable.
807 In such case, we don't bother instrumenting the transaction, and
808 tell the runtime that it should begin the transaction in
809 serial-irrevocable mode. */
810 #define GTMA_DOES_GO_IRREVOCABLE (1u << 6)
811 /* The transaction contains no instrumentation code whatsover, most
812 likely because it is guaranteed to go irrevocable upon entry. */
813 #define GTMA_HAS_NO_INSTRUMENTATION (1u << 7)
815 struct GTY((tag("GSS_TRANSACTION")))
816 gtransaction : public gimple_statement_with_memory_ops_base
818 /* [ WORD 1-9 ] : base class */
827 #define DEFGSSTRUCT(SYM, STRUCT, HAS_TREE_OP) SYM,
828 enum gimple_statement_structure_enum {
829 #include "gsstruct.def"
834 /* A statement with the invariant that
835 stmt->code == GIMPLE_COND
836 i.e. a conditional jump statement. */
838 struct GTY((tag("GSS_WITH_OPS")))
839 gcond : public gimple_statement_with_ops
841 /* no additional fields; this uses the layout for GSS_WITH_OPS. */
842 static const enum gimple_code code_ = GIMPLE_COND;
845 /* A statement with the invariant that
846 stmt->code == GIMPLE_DEBUG
847 i.e. a debug statement. */
849 struct GTY((tag("GSS_WITH_OPS")))
850 gdebug : public gimple_statement_with_ops
852 /* no additional fields; this uses the layout for GSS_WITH_OPS. */
855 /* A statement with the invariant that
856 stmt->code == GIMPLE_GOTO
857 i.e. a goto statement. */
859 struct GTY((tag("GSS_WITH_OPS")))
860 ggoto : public gimple_statement_with_ops
862 /* no additional fields; this uses the layout for GSS_WITH_OPS. */
865 /* A statement with the invariant that
866 stmt->code == GIMPLE_LABEL
867 i.e. a label statement. */
869 struct GTY((tag("GSS_WITH_OPS")))
870 glabel : public gimple_statement_with_ops
872 /* no additional fields; this uses the layout for GSS_WITH_OPS. */
875 /* A statement with the invariant that
876 stmt->code == GIMPLE_SWITCH
877 i.e. a switch statement. */
879 struct GTY((tag("GSS_WITH_OPS")))
880 gswitch : public gimple_statement_with_ops
882 /* no additional fields; this uses the layout for GSS_WITH_OPS. */
885 /* A statement with the invariant that
886 stmt->code == GIMPLE_ASSIGN
887 i.e. an assignment statement. */
889 struct GTY((tag("GSS_WITH_MEM_OPS")))
890 gassign : public gimple_statement_with_memory_ops
892 static const enum gimple_code code_ = GIMPLE_ASSIGN;
893 /* no additional fields; this uses the layout for GSS_WITH_MEM_OPS. */
896 /* A statement with the invariant that
897 stmt->code == GIMPLE_RETURN
898 i.e. a return statement. */
900 struct GTY((tag("GSS_WITH_MEM_OPS")))
901 greturn : public gimple_statement_with_memory_ops
903 /* no additional fields; this uses the layout for GSS_WITH_MEM_OPS. */
909 is_a_helper <gasm *>::test (gimple *gs)
911 return gs->code == GIMPLE_ASM;
917 is_a_helper <gassign *>::test (gimple *gs)
919 return gs->code == GIMPLE_ASSIGN;
925 is_a_helper <const gassign *>::test (const gimple *gs)
927 return gs->code == GIMPLE_ASSIGN;
933 is_a_helper <gbind *>::test (gimple *gs)
935 return gs->code == GIMPLE_BIND;
941 is_a_helper <gcall *>::test (gimple *gs)
943 return gs->code == GIMPLE_CALL;
949 is_a_helper <gcatch *>::test (gimple *gs)
951 return gs->code == GIMPLE_CATCH;
957 is_a_helper <gcond *>::test (gimple *gs)
959 return gs->code == GIMPLE_COND;
965 is_a_helper <const gcond *>::test (const gimple *gs)
967 return gs->code == GIMPLE_COND;
973 is_a_helper <gdebug *>::test (gimple *gs)
975 return gs->code == GIMPLE_DEBUG;
981 is_a_helper <ggoto *>::test (gimple *gs)
983 return gs->code == GIMPLE_GOTO;
989 is_a_helper <glabel *>::test (gimple *gs)
991 return gs->code == GIMPLE_LABEL;
997 is_a_helper <gresx *>::test (gimple *gs)
999 return gs->code == GIMPLE_RESX;
1005 is_a_helper <geh_dispatch *>::test (gimple *gs)
1007 return gs->code == GIMPLE_EH_DISPATCH;
1013 is_a_helper <geh_else *>::test (gimple *gs)
1015 return gs->code == GIMPLE_EH_ELSE;
1021 is_a_helper <geh_filter *>::test (gimple *gs)
1023 return gs->code == GIMPLE_EH_FILTER;
1029 is_a_helper <geh_mnt *>::test (gimple *gs)
1031 return gs->code == GIMPLE_EH_MUST_NOT_THROW;
1037 is_a_helper <gomp_atomic_load *>::test (gimple *gs)
1039 return gs->code == GIMPLE_OMP_ATOMIC_LOAD;
1045 is_a_helper <gomp_atomic_store *>::test (gimple *gs)
1047 return gs->code == GIMPLE_OMP_ATOMIC_STORE;
1053 is_a_helper <gimple_statement_omp_return *>::test (gimple *gs)
1055 return gs->code == GIMPLE_OMP_RETURN;
1061 is_a_helper <gomp_continue *>::test (gimple *gs)
1063 return gs->code == GIMPLE_OMP_CONTINUE;
1069 is_a_helper <gomp_critical *>::test (gimple *gs)
1071 return gs->code == GIMPLE_OMP_CRITICAL;
1077 is_a_helper <gomp_for *>::test (gimple *gs)
1079 return gs->code == GIMPLE_OMP_FOR;
1085 is_a_helper <gimple_statement_omp_taskreg *>::test (gimple *gs)
1087 return gs->code == GIMPLE_OMP_PARALLEL || gs->code == GIMPLE_OMP_TASK;
1093 is_a_helper <gomp_parallel *>::test (gimple *gs)
1095 return gs->code == GIMPLE_OMP_PARALLEL;
1101 is_a_helper <gomp_target *>::test (gimple *gs)
1103 return gs->code == GIMPLE_OMP_TARGET;
1109 is_a_helper <gomp_sections *>::test (gimple *gs)
1111 return gs->code == GIMPLE_OMP_SECTIONS;
1117 is_a_helper <gomp_single *>::test (gimple *gs)
1119 return gs->code == GIMPLE_OMP_SINGLE;
1125 is_a_helper <gomp_teams *>::test (gimple *gs)
1127 return gs->code == GIMPLE_OMP_TEAMS;
1133 is_a_helper <gomp_task *>::test (gimple *gs)
1135 return gs->code == GIMPLE_OMP_TASK;
1141 is_a_helper <gphi *>::test (gimple *gs)
1143 return gs->code == GIMPLE_PHI;
1149 is_a_helper <greturn *>::test (gimple *gs)
1151 return gs->code == GIMPLE_RETURN;
1157 is_a_helper <gswitch *>::test (gimple *gs)
1159 return gs->code == GIMPLE_SWITCH;
1165 is_a_helper <gtransaction *>::test (gimple *gs)
1167 return gs->code == GIMPLE_TRANSACTION;
1173 is_a_helper <gtry *>::test (gimple *gs)
1175 return gs->code == GIMPLE_TRY;
1181 is_a_helper <gimple_statement_wce *>::test (gimple *gs)
1183 return gs->code == GIMPLE_WITH_CLEANUP_EXPR;
1189 is_a_helper <const gasm *>::test (const gimple *gs)
1191 return gs->code == GIMPLE_ASM;
1197 is_a_helper <const gbind *>::test (const gimple *gs)
1199 return gs->code == GIMPLE_BIND;
1205 is_a_helper <const gcall *>::test (const gimple *gs)
1207 return gs->code == GIMPLE_CALL;
1213 is_a_helper <const gcatch *>::test (const gimple *gs)
1215 return gs->code == GIMPLE_CATCH;
1221 is_a_helper <const gresx *>::test (const gimple *gs)
1223 return gs->code == GIMPLE_RESX;
1229 is_a_helper <const geh_dispatch *>::test (const gimple *gs)
1231 return gs->code == GIMPLE_EH_DISPATCH;
1237 is_a_helper <const geh_filter *>::test (const gimple *gs)
1239 return gs->code == GIMPLE_EH_FILTER;
1245 is_a_helper <const gomp_atomic_load *>::test (const gimple *gs)
1247 return gs->code == GIMPLE_OMP_ATOMIC_LOAD;
1253 is_a_helper <const gomp_atomic_store *>::test (const gimple *gs)
1255 return gs->code == GIMPLE_OMP_ATOMIC_STORE;
1261 is_a_helper <const gimple_statement_omp_return *>::test (const gimple *gs)
1263 return gs->code == GIMPLE_OMP_RETURN;
1269 is_a_helper <const gomp_continue *>::test (const gimple *gs)
1271 return gs->code == GIMPLE_OMP_CONTINUE;
1277 is_a_helper <const gomp_critical *>::test (const gimple *gs)
1279 return gs->code == GIMPLE_OMP_CRITICAL;
1285 is_a_helper <const gomp_for *>::test (const gimple *gs)
1287 return gs->code == GIMPLE_OMP_FOR;
1293 is_a_helper <const gimple_statement_omp_taskreg *>::test (const gimple *gs)
1295 return gs->code == GIMPLE_OMP_PARALLEL || gs->code == GIMPLE_OMP_TASK;
1301 is_a_helper <const gomp_parallel *>::test (const gimple *gs)
1303 return gs->code == GIMPLE_OMP_PARALLEL;
1309 is_a_helper <const gomp_target *>::test (const gimple *gs)
1311 return gs->code == GIMPLE_OMP_TARGET;
1317 is_a_helper <const gomp_sections *>::test (const gimple *gs)
1319 return gs->code == GIMPLE_OMP_SECTIONS;
1325 is_a_helper <const gomp_single *>::test (const gimple *gs)
1327 return gs->code == GIMPLE_OMP_SINGLE;
1333 is_a_helper <const gomp_teams *>::test (const gimple *gs)
1335 return gs->code == GIMPLE_OMP_TEAMS;
1341 is_a_helper <const gomp_task *>::test (const gimple *gs)
1343 return gs->code == GIMPLE_OMP_TASK;
1349 is_a_helper <const gphi *>::test (const gimple *gs)
1351 return gs->code == GIMPLE_PHI;
1357 is_a_helper <const gtransaction *>::test (const gimple *gs)
1359 return gs->code == GIMPLE_TRANSACTION;
1362 /* Offset in bytes to the location of the operand vector.
1363 Zero if there is no operand vector for this tuple structure. */
1364 extern size_t const gimple_ops_offset_[];
1366 /* Map GIMPLE codes to GSS codes. */
1367 extern enum gimple_statement_structure_enum const gss_for_code_[];
1369 /* This variable holds the currently expanded gimple statement for purposes
1370 of comminucating the profile info to the builtin expanders. */
1371 extern gimple *currently_expanding_gimple_stmt;
1373 #define gimple_alloc(c, n) gimple_alloc_stat (c, n MEM_STAT_INFO)
1374 gimple *gimple_alloc_stat (enum gimple_code, unsigned MEM_STAT_DECL);
1375 greturn *gimple_build_return (tree);
1376 void gimple_call_reset_alias_info (gcall *);
1377 gcall *gimple_build_call_vec (tree, vec<tree> );
1378 gcall *gimple_build_call (tree, unsigned, ...);
1379 gcall *gimple_build_call_valist (tree, unsigned, va_list);
1380 gcall *gimple_build_call_internal (enum internal_fn, unsigned, ...);
1381 gcall *gimple_build_call_internal_vec (enum internal_fn, vec<tree> );
1382 gcall *gimple_build_call_from_tree (tree);
1383 gassign *gimple_build_assign (tree, tree CXX_MEM_STAT_INFO);
1384 gassign *gimple_build_assign (tree, enum tree_code,
1385 tree, tree, tree CXX_MEM_STAT_INFO);
1386 gassign *gimple_build_assign (tree, enum tree_code,
1387 tree, tree CXX_MEM_STAT_INFO);
1388 gassign *gimple_build_assign (tree, enum tree_code, tree CXX_MEM_STAT_INFO);
1389 gcond *gimple_build_cond (enum tree_code, tree, tree, tree, tree);
1390 gcond *gimple_build_cond_from_tree (tree, tree, tree);
1391 void gimple_cond_set_condition_from_tree (gcond *, tree);
1392 glabel *gimple_build_label (tree label);
1393 ggoto *gimple_build_goto (tree dest);
1394 gimple *gimple_build_nop (void);
1395 gbind *gimple_build_bind (tree, gimple_seq, tree);
1396 gasm *gimple_build_asm_vec (const char *, vec<tree, va_gc> *,
1397 vec<tree, va_gc> *, vec<tree, va_gc> *,
1398 vec<tree, va_gc> *);
1399 gcatch *gimple_build_catch (tree, gimple_seq);
1400 geh_filter *gimple_build_eh_filter (tree, gimple_seq);
1401 geh_mnt *gimple_build_eh_must_not_throw (tree);
1402 geh_else *gimple_build_eh_else (gimple_seq, gimple_seq);
1403 gtry *gimple_build_try (gimple_seq, gimple_seq,
1404 enum gimple_try_flags);
1405 gimple *gimple_build_wce (gimple_seq);
1406 gresx *gimple_build_resx (int);
1407 gswitch *gimple_build_switch_nlabels (unsigned, tree, tree);
1408 gswitch *gimple_build_switch (tree, tree, vec<tree> );
1409 geh_dispatch *gimple_build_eh_dispatch (int);
1410 gdebug *gimple_build_debug_bind_stat (tree, tree, gimple * MEM_STAT_DECL);
1411 #define gimple_build_debug_bind(var,val,stmt) \
1412 gimple_build_debug_bind_stat ((var), (val), (stmt) MEM_STAT_INFO)
1413 gdebug *gimple_build_debug_source_bind_stat (tree, tree, gimple * MEM_STAT_DECL);
1414 #define gimple_build_debug_source_bind(var,val,stmt) \
1415 gimple_build_debug_source_bind_stat ((var), (val), (stmt) MEM_STAT_INFO)
1416 gomp_critical *gimple_build_omp_critical (gimple_seq, tree);
1417 gomp_for *gimple_build_omp_for (gimple_seq, int, tree, size_t, gimple_seq);
1418 gomp_parallel *gimple_build_omp_parallel (gimple_seq, tree, tree, tree);
1419 gomp_task *gimple_build_omp_task (gimple_seq, tree, tree, tree, tree,
1421 gimple *gimple_build_omp_section (gimple_seq);
1422 gimple *gimple_build_omp_master (gimple_seq);
1423 gimple *gimple_build_omp_taskgroup (gimple_seq);
1424 gomp_continue *gimple_build_omp_continue (tree, tree);
1425 gimple *gimple_build_omp_ordered (gimple_seq);
1426 gimple *gimple_build_omp_return (bool);
1427 gomp_sections *gimple_build_omp_sections (gimple_seq, tree);
1428 gimple *gimple_build_omp_sections_switch (void);
1429 gomp_single *gimple_build_omp_single (gimple_seq, tree);
1430 gomp_target *gimple_build_omp_target (gimple_seq, int, tree);
1431 gomp_teams *gimple_build_omp_teams (gimple_seq, tree);
1432 gomp_atomic_load *gimple_build_omp_atomic_load (tree, tree);
1433 gomp_atomic_store *gimple_build_omp_atomic_store (tree);
1434 gtransaction *gimple_build_transaction (gimple_seq, tree);
1435 extern void gimple_seq_add_stmt (gimple_seq *, gimple *);
1436 extern void gimple_seq_add_stmt_without_update (gimple_seq *, gimple *);
1437 void gimple_seq_add_seq (gimple_seq *, gimple_seq);
1438 void gimple_seq_add_seq_without_update (gimple_seq *, gimple_seq);
1439 extern void annotate_all_with_location_after (gimple_seq, gimple_stmt_iterator,
1441 extern void annotate_all_with_location (gimple_seq, location_t);
1442 bool empty_body_p (gimple_seq);
1443 gimple_seq gimple_seq_copy (gimple_seq);
1444 bool gimple_call_same_target_p (const gimple *, const gimple *);
1445 int gimple_call_flags (const gimple *);
1446 int gimple_call_arg_flags (const gcall *, unsigned);
1447 int gimple_call_return_flags (const gcall *);
1448 bool gimple_assign_copy_p (gimple *);
1449 bool gimple_assign_ssa_name_copy_p (gimple *);
1450 bool gimple_assign_unary_nop_p (gimple *);
1451 void gimple_set_bb (gimple *, basic_block);
1452 void gimple_assign_set_rhs_from_tree (gimple_stmt_iterator *, tree);
1453 void gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *, enum tree_code,
1455 tree gimple_get_lhs (const gimple *);
1456 void gimple_set_lhs (gimple *, tree);
1457 gimple *gimple_copy (gimple *);
1458 bool gimple_has_side_effects (const gimple *);
1459 bool gimple_could_trap_p_1 (gimple *, bool, bool);
1460 bool gimple_could_trap_p (gimple *);
1461 bool gimple_assign_rhs_could_trap_p (gimple *);
1462 extern void dump_gimple_statistics (void);
1463 unsigned get_gimple_rhs_num_ops (enum tree_code);
1464 extern tree canonicalize_cond_expr_cond (tree);
1465 gcall *gimple_call_copy_skip_args (gcall *, bitmap);
1466 extern bool gimple_compare_field_offset (tree, tree);
1467 extern tree gimple_unsigned_type (tree);
1468 extern tree gimple_signed_type (tree);
1469 extern alias_set_type gimple_get_alias_set (tree);
1470 extern bool gimple_ior_addresses_taken (bitmap, gimple *);
1471 extern bool gimple_builtin_call_types_compatible_p (const gimple *, tree);
1472 extern bool gimple_call_builtin_p (const gimple *);
1473 extern bool gimple_call_builtin_p (const gimple *, enum built_in_class);
1474 extern bool gimple_call_builtin_p (const gimple *, enum built_in_function);
1475 extern bool gimple_asm_clobbers_memory_p (const gasm *);
1476 extern void dump_decl_set (FILE *, bitmap);
1477 extern bool nonfreeing_call_p (gimple *);
1478 extern bool infer_nonnull_range (gimple *, tree);
1479 extern bool infer_nonnull_range_by_dereference (gimple *, tree);
1480 extern bool infer_nonnull_range_by_attribute (gimple *, tree);
1481 extern void sort_case_labels (vec<tree>);
1482 extern void preprocess_case_label_vec_for_gimple (vec<tree>, tree, tree *);
1483 extern void gimple_seq_set_location (gimple_seq, location_t);
1484 extern void gimple_seq_discard (gimple_seq);
1485 extern void maybe_remove_unused_call_args (struct function *, gimple *);
1487 /* Formal (expression) temporary table handling: multiple occurrences of
1488 the same scalar expression are evaluated into the same temporary. */
1490 typedef struct gimple_temp_hash_elt
1493 tree temp; /* Value */
1496 /* Get the number of the next statement uid to be allocated. */
1497 static inline unsigned int
1498 gimple_stmt_max_uid (struct function *fn)
1500 return fn->last_stmt_uid;
1503 /* Set the number of the next statement uid to be allocated. */
1505 set_gimple_stmt_max_uid (struct function *fn, unsigned int maxid)
1507 fn->last_stmt_uid = maxid;
1510 /* Set the number of the next statement uid to be allocated. */
1511 static inline unsigned int
1512 inc_gimple_stmt_max_uid (struct function *fn)
1514 return fn->last_stmt_uid++;
1517 /* Return the first node in GIMPLE sequence S. */
1519 static inline gimple_seq_node
1520 gimple_seq_first (gimple_seq s)
1526 /* Return the first statement in GIMPLE sequence S. */
1528 static inline gimple *
1529 gimple_seq_first_stmt (gimple_seq s)
1531 gimple_seq_node n = gimple_seq_first (s);
1535 /* Return the first statement in GIMPLE sequence S as a gbind *,
1536 verifying that it has code GIMPLE_BIND in a checked build. */
1538 static inline gbind *
1539 gimple_seq_first_stmt_as_a_bind (gimple_seq s)
1541 gimple_seq_node n = gimple_seq_first (s);
1542 return as_a <gbind *> (n);
1546 /* Return the last node in GIMPLE sequence S. */
1548 static inline gimple_seq_node
1549 gimple_seq_last (gimple_seq s)
1551 return s ? s->prev : NULL;
1555 /* Return the last statement in GIMPLE sequence S. */
1557 static inline gimple *
1558 gimple_seq_last_stmt (gimple_seq s)
1560 gimple_seq_node n = gimple_seq_last (s);
1565 /* Set the last node in GIMPLE sequence *PS to LAST. */
1568 gimple_seq_set_last (gimple_seq *ps, gimple_seq_node last)
1574 /* Set the first node in GIMPLE sequence *PS to FIRST. */
1577 gimple_seq_set_first (gimple_seq *ps, gimple_seq_node first)
1583 /* Return true if GIMPLE sequence S is empty. */
1586 gimple_seq_empty_p (gimple_seq s)
1591 /* Allocate a new sequence and initialize its first element with STMT. */
1593 static inline gimple_seq
1594 gimple_seq_alloc_with_stmt (gimple *stmt)
1596 gimple_seq seq = NULL;
1597 gimple_seq_add_stmt (&seq, stmt);
1602 /* Returns the sequence of statements in BB. */
1604 static inline gimple_seq
1605 bb_seq (const_basic_block bb)
1607 return (!(bb->flags & BB_RTL)) ? bb->il.gimple.seq : NULL;
1610 static inline gimple_seq *
1611 bb_seq_addr (basic_block bb)
1613 return (!(bb->flags & BB_RTL)) ? &bb->il.gimple.seq : NULL;
1616 /* Sets the sequence of statements in BB to SEQ. */
1619 set_bb_seq (basic_block bb, gimple_seq seq)
1621 gcc_checking_assert (!(bb->flags & BB_RTL));
1622 bb->il.gimple.seq = seq;
1626 /* Return the code for GIMPLE statement G. */
1628 static inline enum gimple_code
1629 gimple_code (const gimple *g)
1635 /* Return the GSS code used by a GIMPLE code. */
1637 static inline enum gimple_statement_structure_enum
1638 gss_for_code (enum gimple_code code)
1640 gcc_gimple_checking_assert ((unsigned int)code < LAST_AND_UNUSED_GIMPLE_CODE);
1641 return gss_for_code_[code];
1645 /* Return which GSS code is used by GS. */
1647 static inline enum gimple_statement_structure_enum
1648 gimple_statement_structure (gimple *gs)
1650 return gss_for_code (gimple_code (gs));
1654 /* Return true if statement G has sub-statements. This is only true for
1655 High GIMPLE statements. */
1658 gimple_has_substatements (gimple *g)
1660 switch (gimple_code (g))
1664 case GIMPLE_EH_FILTER:
1665 case GIMPLE_EH_ELSE:
1667 case GIMPLE_OMP_FOR:
1668 case GIMPLE_OMP_MASTER:
1669 case GIMPLE_OMP_TASKGROUP:
1670 case GIMPLE_OMP_ORDERED:
1671 case GIMPLE_OMP_SECTION:
1672 case GIMPLE_OMP_PARALLEL:
1673 case GIMPLE_OMP_TASK:
1674 case GIMPLE_OMP_SECTIONS:
1675 case GIMPLE_OMP_SINGLE:
1676 case GIMPLE_OMP_TARGET:
1677 case GIMPLE_OMP_TEAMS:
1678 case GIMPLE_OMP_CRITICAL:
1679 case GIMPLE_WITH_CLEANUP_EXPR:
1680 case GIMPLE_TRANSACTION:
1689 /* Return the basic block holding statement G. */
1691 static inline basic_block
1692 gimple_bb (const gimple *g)
1698 /* Return the lexical scope block holding statement G. */
1701 gimple_block (const gimple *g)
1703 return LOCATION_BLOCK (g->location);
1707 /* Set BLOCK to be the lexical scope block holding statement G. */
1710 gimple_set_block (gimple *g, tree block)
1714 COMBINE_LOCATION_DATA (line_table, g->location, block);
1716 g->location = LOCATION_LOCUS (g->location);
1720 /* Return location information for statement G. */
1722 static inline location_t
1723 gimple_location (const gimple *g)
1728 /* Return location information for statement G if g is not NULL.
1729 Otherwise, UNKNOWN_LOCATION is returned. */
1731 static inline location_t
1732 gimple_location_safe (const gimple *g)
1734 return g ? gimple_location (g) : UNKNOWN_LOCATION;
1737 /* Set location information for statement G. */
1740 gimple_set_location (gimple *g, location_t location)
1742 g->location = location;
1746 /* Return true if G contains location information. */
1749 gimple_has_location (const gimple *g)
1751 return LOCATION_LOCUS (gimple_location (g)) != UNKNOWN_LOCATION;
1755 /* Return the file name of the location of STMT. */
1757 static inline const char *
1758 gimple_filename (const gimple *stmt)
1760 return LOCATION_FILE (gimple_location (stmt));
1764 /* Return the line number of the location of STMT. */
1767 gimple_lineno (const gimple *stmt)
1769 return LOCATION_LINE (gimple_location (stmt));
1773 /* Determine whether SEQ is a singleton. */
1776 gimple_seq_singleton_p (gimple_seq seq)
1778 return ((gimple_seq_first (seq) != NULL)
1779 && (gimple_seq_first (seq) == gimple_seq_last (seq)));
1782 /* Return true if no warnings should be emitted for statement STMT. */
1785 gimple_no_warning_p (const gimple *stmt)
1787 return stmt->no_warning;
1790 /* Set the no_warning flag of STMT to NO_WARNING. */
1793 gimple_set_no_warning (gimple *stmt, bool no_warning)
1795 stmt->no_warning = (unsigned) no_warning;
1798 /* Set the visited status on statement STMT to VISITED_P.
1800 Please note that this 'visited' property of the gimple statement is
1801 supposed to be undefined at pass boundaries. This means that a
1802 given pass should not assume it contains any useful value when the
1803 pass starts and thus can set it to any value it sees fit.
1805 You can learn more about the visited property of the gimple
1806 statement by reading the comments of the 'visited' data member of
1811 gimple_set_visited (gimple *stmt, bool visited_p)
1813 stmt->visited = (unsigned) visited_p;
1817 /* Return the visited status for statement STMT.
1819 Please note that this 'visited' property of the gimple statement is
1820 supposed to be undefined at pass boundaries. This means that a
1821 given pass should not assume it contains any useful value when the
1822 pass starts and thus can set it to any value it sees fit.
1824 You can learn more about the visited property of the gimple
1825 statement by reading the comments of the 'visited' data member of
1829 gimple_visited_p (gimple *stmt)
1831 return stmt->visited;
1835 /* Set pass local flag PLF on statement STMT to VAL_P.
1837 Please note that this PLF property of the gimple statement is
1838 supposed to be undefined at pass boundaries. This means that a
1839 given pass should not assume it contains any useful value when the
1840 pass starts and thus can set it to any value it sees fit.
1842 You can learn more about the PLF property by reading the comment of
1843 the 'plf' data member of struct gimple_statement_structure. */
1846 gimple_set_plf (gimple *stmt, enum plf_mask plf, bool val_p)
1849 stmt->plf |= (unsigned int) plf;
1851 stmt->plf &= ~((unsigned int) plf);
1855 /* Return the value of pass local flag PLF on statement STMT.
1857 Please note that this 'plf' property of the gimple statement is
1858 supposed to be undefined at pass boundaries. This means that a
1859 given pass should not assume it contains any useful value when the
1860 pass starts and thus can set it to any value it sees fit.
1862 You can learn more about the plf property by reading the comment of
1863 the 'plf' data member of struct gimple_statement_structure. */
1865 static inline unsigned int
1866 gimple_plf (gimple *stmt, enum plf_mask plf)
1868 return stmt->plf & ((unsigned int) plf);
1872 /* Set the UID of statement.
1874 Please note that this UID property is supposed to be undefined at
1875 pass boundaries. This means that a given pass should not assume it
1876 contains any useful value when the pass starts and thus can set it
1877 to any value it sees fit. */
1880 gimple_set_uid (gimple *g, unsigned uid)
1886 /* Return the UID of statement.
1888 Please note that this UID property is supposed to be undefined at
1889 pass boundaries. This means that a given pass should not assume it
1890 contains any useful value when the pass starts and thus can set it
1891 to any value it sees fit. */
1893 static inline unsigned
1894 gimple_uid (const gimple *g)
1900 /* Make statement G a singleton sequence. */
1903 gimple_init_singleton (gimple *g)
1910 /* Return true if GIMPLE statement G has register or memory operands. */
1913 gimple_has_ops (const gimple *g)
1915 return gimple_code (g) >= GIMPLE_COND && gimple_code (g) <= GIMPLE_RETURN;
1921 is_a_helper <const gimple_statement_with_ops *>::test (const gimple *gs)
1923 return gimple_has_ops (gs);
1929 is_a_helper <gimple_statement_with_ops *>::test (gimple *gs)
1931 return gimple_has_ops (gs);
1934 /* Return true if GIMPLE statement G has memory operands. */
1937 gimple_has_mem_ops (const gimple *g)
1939 return gimple_code (g) >= GIMPLE_ASSIGN && gimple_code (g) <= GIMPLE_RETURN;
1945 is_a_helper <const gimple_statement_with_memory_ops *>::test (const gimple *gs)
1947 return gimple_has_mem_ops (gs);
1953 is_a_helper <gimple_statement_with_memory_ops *>::test (gimple *gs)
1955 return gimple_has_mem_ops (gs);
1958 /* Return the set of USE operands for statement G. */
1960 static inline struct use_optype_d *
1961 gimple_use_ops (const gimple *g)
1963 const gimple_statement_with_ops *ops_stmt =
1964 dyn_cast <const gimple_statement_with_ops *> (g);
1967 return ops_stmt->use_ops;
1971 /* Set USE to be the set of USE operands for statement G. */
1974 gimple_set_use_ops (gimple *g, struct use_optype_d *use)
1976 gimple_statement_with_ops *ops_stmt =
1977 as_a <gimple_statement_with_ops *> (g);
1978 ops_stmt->use_ops = use;
1982 /* Return the single VUSE operand of the statement G. */
1985 gimple_vuse (const gimple *g)
1987 const gimple_statement_with_memory_ops *mem_ops_stmt =
1988 dyn_cast <const gimple_statement_with_memory_ops *> (g);
1991 return mem_ops_stmt->vuse;
1994 /* Return the single VDEF operand of the statement G. */
1997 gimple_vdef (const gimple *g)
1999 const gimple_statement_with_memory_ops *mem_ops_stmt =
2000 dyn_cast <const gimple_statement_with_memory_ops *> (g);
2003 return mem_ops_stmt->vdef;
2006 /* Return the single VUSE operand of the statement G. */
2008 static inline tree *
2009 gimple_vuse_ptr (gimple *g)
2011 gimple_statement_with_memory_ops *mem_ops_stmt =
2012 dyn_cast <gimple_statement_with_memory_ops *> (g);
2015 return &mem_ops_stmt->vuse;
2018 /* Return the single VDEF operand of the statement G. */
2020 static inline tree *
2021 gimple_vdef_ptr (gimple *g)
2023 gimple_statement_with_memory_ops *mem_ops_stmt =
2024 dyn_cast <gimple_statement_with_memory_ops *> (g);
2027 return &mem_ops_stmt->vdef;
2030 /* Set the single VUSE operand of the statement G. */
2033 gimple_set_vuse (gimple *g, tree vuse)
2035 gimple_statement_with_memory_ops *mem_ops_stmt =
2036 as_a <gimple_statement_with_memory_ops *> (g);
2037 mem_ops_stmt->vuse = vuse;
2040 /* Set the single VDEF operand of the statement G. */
2043 gimple_set_vdef (gimple *g, tree vdef)
2045 gimple_statement_with_memory_ops *mem_ops_stmt =
2046 as_a <gimple_statement_with_memory_ops *> (g);
2047 mem_ops_stmt->vdef = vdef;
2051 /* Return true if statement G has operands and the modified field has
2055 gimple_modified_p (const gimple *g)
2057 return (gimple_has_ops (g)) ? (bool) g->modified : false;
2061 /* Set the MODIFIED flag to MODIFIEDP, iff the gimple statement G has
2062 a MODIFIED field. */
2065 gimple_set_modified (gimple *s, bool modifiedp)
2067 if (gimple_has_ops (s))
2068 s->modified = (unsigned) modifiedp;
2072 /* Return the tree code for the expression computed by STMT. This is
2073 only valid for GIMPLE_COND, GIMPLE_CALL and GIMPLE_ASSIGN. For
2074 GIMPLE_CALL, return CALL_EXPR as the expression code for
2075 consistency. This is useful when the caller needs to deal with the
2076 three kinds of computation that GIMPLE supports. */
2078 static inline enum tree_code
2079 gimple_expr_code (const gimple *stmt)
2081 enum gimple_code code = gimple_code (stmt);
2082 if (code == GIMPLE_ASSIGN || code == GIMPLE_COND)
2083 return (enum tree_code) stmt->subcode;
2086 gcc_gimple_checking_assert (code == GIMPLE_CALL);
2092 /* Return true if statement STMT contains volatile operands. */
2095 gimple_has_volatile_ops (const gimple *stmt)
2097 if (gimple_has_mem_ops (stmt))
2098 return stmt->has_volatile_ops;
2104 /* Set the HAS_VOLATILE_OPS flag to VOLATILEP. */
2107 gimple_set_has_volatile_ops (gimple *stmt, bool volatilep)
2109 if (gimple_has_mem_ops (stmt))
2110 stmt->has_volatile_ops = (unsigned) volatilep;
2113 /* Return true if STMT is in a transaction. */
2116 gimple_in_transaction (const gimple *stmt)
2118 return bb_in_transaction (gimple_bb (stmt));
2121 /* Return true if statement STMT may access memory. */
2124 gimple_references_memory_p (gimple *stmt)
2126 return gimple_has_mem_ops (stmt) && gimple_vuse (stmt);
2130 /* Return the subcode for OMP statement S. */
2132 static inline unsigned
2133 gimple_omp_subcode (const gimple *s)
2135 gcc_gimple_checking_assert (gimple_code (s) >= GIMPLE_OMP_ATOMIC_LOAD
2136 && gimple_code (s) <= GIMPLE_OMP_TEAMS);
2140 /* Set the subcode for OMP statement S to SUBCODE. */
2143 gimple_omp_set_subcode (gimple *s, unsigned int subcode)
2145 /* We only have 16 bits for the subcode. Assert that we are not
2147 gcc_gimple_checking_assert (subcode < (1 << 16));
2148 s->subcode = subcode;
2151 /* Set the nowait flag on OMP_RETURN statement S. */
2154 gimple_omp_return_set_nowait (gimple *s)
2156 GIMPLE_CHECK (s, GIMPLE_OMP_RETURN);
2157 s->subcode |= GF_OMP_RETURN_NOWAIT;
2161 /* Return true if OMP return statement G has the GF_OMP_RETURN_NOWAIT
2165 gimple_omp_return_nowait_p (const gimple *g)
2167 GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
2168 return (gimple_omp_subcode (g) & GF_OMP_RETURN_NOWAIT) != 0;
2172 /* Set the LHS of OMP return. */
2175 gimple_omp_return_set_lhs (gimple *g, tree lhs)
2177 gimple_statement_omp_return *omp_return_stmt =
2178 as_a <gimple_statement_omp_return *> (g);
2179 omp_return_stmt->val = lhs;
2183 /* Get the LHS of OMP return. */
2186 gimple_omp_return_lhs (const gimple *g)
2188 const gimple_statement_omp_return *omp_return_stmt =
2189 as_a <const gimple_statement_omp_return *> (g);
2190 return omp_return_stmt->val;
2194 /* Return a pointer to the LHS of OMP return. */
2196 static inline tree *
2197 gimple_omp_return_lhs_ptr (gimple *g)
2199 gimple_statement_omp_return *omp_return_stmt =
2200 as_a <gimple_statement_omp_return *> (g);
2201 return &omp_return_stmt->val;
2205 /* Return true if OMP section statement G has the GF_OMP_SECTION_LAST
2209 gimple_omp_section_last_p (const gimple *g)
2211 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
2212 return (gimple_omp_subcode (g) & GF_OMP_SECTION_LAST) != 0;
2216 /* Set the GF_OMP_SECTION_LAST flag on G. */
2219 gimple_omp_section_set_last (gimple *g)
2221 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
2222 g->subcode |= GF_OMP_SECTION_LAST;
2226 /* Return true if OMP parallel statement G has the
2227 GF_OMP_PARALLEL_COMBINED flag set. */
2230 gimple_omp_parallel_combined_p (const gimple *g)
2232 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
2233 return (gimple_omp_subcode (g) & GF_OMP_PARALLEL_COMBINED) != 0;
2237 /* Set the GF_OMP_PARALLEL_COMBINED field in G depending on the boolean
2238 value of COMBINED_P. */
2241 gimple_omp_parallel_set_combined_p (gimple *g, bool combined_p)
2243 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
2245 g->subcode |= GF_OMP_PARALLEL_COMBINED;
2247 g->subcode &= ~GF_OMP_PARALLEL_COMBINED;
2251 /* Return true if OMP atomic load/store statement G has the
2252 GF_OMP_ATOMIC_NEED_VALUE flag set. */
2255 gimple_omp_atomic_need_value_p (const gimple *g)
2257 if (gimple_code (g) != GIMPLE_OMP_ATOMIC_LOAD)
2258 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
2259 return (gimple_omp_subcode (g) & GF_OMP_ATOMIC_NEED_VALUE) != 0;
2263 /* Set the GF_OMP_ATOMIC_NEED_VALUE flag on G. */
2266 gimple_omp_atomic_set_need_value (gimple *g)
2268 if (gimple_code (g) != GIMPLE_OMP_ATOMIC_LOAD)
2269 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
2270 g->subcode |= GF_OMP_ATOMIC_NEED_VALUE;
2274 /* Return true if OMP atomic load/store statement G has the
2275 GF_OMP_ATOMIC_SEQ_CST flag set. */
2278 gimple_omp_atomic_seq_cst_p (const gimple *g)
2280 if (gimple_code (g) != GIMPLE_OMP_ATOMIC_LOAD)
2281 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
2282 return (gimple_omp_subcode (g) & GF_OMP_ATOMIC_SEQ_CST) != 0;
2286 /* Set the GF_OMP_ATOMIC_SEQ_CST flag on G. */
2289 gimple_omp_atomic_set_seq_cst (gimple *g)
2291 if (gimple_code (g) != GIMPLE_OMP_ATOMIC_LOAD)
2292 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
2293 g->subcode |= GF_OMP_ATOMIC_SEQ_CST;
2297 /* Return the number of operands for statement GS. */
2299 static inline unsigned
2300 gimple_num_ops (const gimple *gs)
2306 /* Set the number of operands for statement GS. */
2309 gimple_set_num_ops (gimple *gs, unsigned num_ops)
2311 gs->num_ops = num_ops;
2315 /* Return the array of operands for statement GS. */
2317 static inline tree *
2318 gimple_ops (gimple *gs)
2322 /* All the tuples have their operand vector at the very bottom
2323 of the structure. Note that those structures that do not
2324 have an operand vector have a zero offset. */
2325 off = gimple_ops_offset_[gimple_statement_structure (gs)];
2326 gcc_gimple_checking_assert (off != 0);
2328 return (tree *) ((char *) gs + off);
2332 /* Return operand I for statement GS. */
2335 gimple_op (const gimple *gs, unsigned i)
2337 if (gimple_has_ops (gs))
2339 gcc_gimple_checking_assert (i < gimple_num_ops (gs));
2340 return gimple_ops (CONST_CAST_GIMPLE (gs))[i];
2346 /* Return a pointer to operand I for statement GS. */
2348 static inline tree *
2349 gimple_op_ptr (const gimple *gs, unsigned i)
2351 if (gimple_has_ops (gs))
2353 gcc_gimple_checking_assert (i < gimple_num_ops (gs));
2354 return gimple_ops (CONST_CAST_GIMPLE (gs)) + i;
2360 /* Set operand I of statement GS to OP. */
2363 gimple_set_op (gimple *gs, unsigned i, tree op)
2365 gcc_gimple_checking_assert (gimple_has_ops (gs) && i < gimple_num_ops (gs));
2367 /* Note. It may be tempting to assert that OP matches
2368 is_gimple_operand, but that would be wrong. Different tuples
2369 accept slightly different sets of tree operands. Each caller
2370 should perform its own validation. */
2371 gimple_ops (gs)[i] = op;
2374 /* Return true if GS is a GIMPLE_ASSIGN. */
2377 is_gimple_assign (const gimple *gs)
2379 return gimple_code (gs) == GIMPLE_ASSIGN;
2382 /* Determine if expression CODE is one of the valid expressions that can
2383 be used on the RHS of GIMPLE assignments. */
2385 static inline enum gimple_rhs_class
2386 get_gimple_rhs_class (enum tree_code code)
2388 return (enum gimple_rhs_class) gimple_rhs_class_table[(int) code];
2391 /* Return the LHS of assignment statement GS. */
2394 gimple_assign_lhs (const gassign *gs)
2400 gimple_assign_lhs (const gimple *gs)
2402 const gassign *ass = GIMPLE_CHECK2<const gassign *> (gs);
2403 return gimple_assign_lhs (ass);
2407 /* Return a pointer to the LHS of assignment statement GS. */
2409 static inline tree *
2410 gimple_assign_lhs_ptr (const gassign *gs)
2412 return const_cast<tree *> (&gs->op[0]);
2415 static inline tree *
2416 gimple_assign_lhs_ptr (const gimple *gs)
2418 const gassign *ass = GIMPLE_CHECK2<const gassign *> (gs);
2419 return gimple_assign_lhs_ptr (ass);
2423 /* Set LHS to be the LHS operand of assignment statement GS. */
2426 gimple_assign_set_lhs (gassign *gs, tree lhs)
2430 if (lhs && TREE_CODE (lhs) == SSA_NAME)
2431 SSA_NAME_DEF_STMT (lhs) = gs;
2435 gimple_assign_set_lhs (gimple *gs, tree lhs)
2437 gassign *ass = GIMPLE_CHECK2<gassign *> (gs);
2438 gimple_assign_set_lhs (ass, lhs);
2442 /* Return the first operand on the RHS of assignment statement GS. */
2445 gimple_assign_rhs1 (const gassign *gs)
2451 gimple_assign_rhs1 (const gimple *gs)
2453 const gassign *ass = GIMPLE_CHECK2<const gassign *> (gs);
2454 return gimple_assign_rhs1 (ass);
2458 /* Return a pointer to the first operand on the RHS of assignment
2461 static inline tree *
2462 gimple_assign_rhs1_ptr (const gassign *gs)
2464 return const_cast<tree *> (&gs->op[1]);
2467 static inline tree *
2468 gimple_assign_rhs1_ptr (const gimple *gs)
2470 const gassign *ass = GIMPLE_CHECK2<const gassign *> (gs);
2471 return gimple_assign_rhs1_ptr (ass);
2474 /* Set RHS to be the first operand on the RHS of assignment statement GS. */
2477 gimple_assign_set_rhs1 (gassign *gs, tree rhs)
2483 gimple_assign_set_rhs1 (gimple *gs, tree rhs)
2485 gassign *ass = GIMPLE_CHECK2<gassign *> (gs);
2486 gimple_assign_set_rhs1 (ass, rhs);
2490 /* Return the second operand on the RHS of assignment statement GS.
2491 If GS does not have two operands, NULL is returned instead. */
2494 gimple_assign_rhs2 (const gassign *gs)
2496 if (gimple_num_ops (gs) >= 3)
2503 gimple_assign_rhs2 (const gimple *gs)
2505 const gassign *ass = GIMPLE_CHECK2<const gassign *> (gs);
2506 return gimple_assign_rhs2 (ass);
2510 /* Return a pointer to the second operand on the RHS of assignment
2513 static inline tree *
2514 gimple_assign_rhs2_ptr (const gassign *gs)
2516 gcc_gimple_checking_assert (gimple_num_ops (gs) >= 3);
2517 return const_cast<tree *> (&gs->op[2]);
2520 static inline tree *
2521 gimple_assign_rhs2_ptr (const gimple *gs)
2523 const gassign *ass = GIMPLE_CHECK2<const gassign *> (gs);
2524 return gimple_assign_rhs2_ptr (ass);
2528 /* Set RHS to be the second operand on the RHS of assignment statement GS. */
2531 gimple_assign_set_rhs2 (gassign *gs, tree rhs)
2533 gcc_gimple_checking_assert (gimple_num_ops (gs) >= 3);
2538 gimple_assign_set_rhs2 (gimple *gs, tree rhs)
2540 gassign *ass = GIMPLE_CHECK2<gassign *> (gs);
2541 return gimple_assign_set_rhs2 (ass, rhs);
2544 /* Return the third operand on the RHS of assignment statement GS.
2545 If GS does not have two operands, NULL is returned instead. */
2548 gimple_assign_rhs3 (const gassign *gs)
2550 if (gimple_num_ops (gs) >= 4)
2557 gimple_assign_rhs3 (const gimple *gs)
2559 const gassign *ass = GIMPLE_CHECK2<const gassign *> (gs);
2560 return gimple_assign_rhs3 (ass);
2563 /* Return a pointer to the third operand on the RHS of assignment
2566 static inline tree *
2567 gimple_assign_rhs3_ptr (const gimple *gs)
2569 const gassign *ass = GIMPLE_CHECK2<const gassign *> (gs);
2570 gcc_gimple_checking_assert (gimple_num_ops (gs) >= 4);
2571 return const_cast<tree *> (&ass->op[3]);
2575 /* Set RHS to be the third operand on the RHS of assignment statement GS. */
2578 gimple_assign_set_rhs3 (gassign *gs, tree rhs)
2580 gcc_gimple_checking_assert (gimple_num_ops (gs) >= 4);
2585 gimple_assign_set_rhs3 (gimple *gs, tree rhs)
2587 gassign *ass = GIMPLE_CHECK2<gassign *> (gs);
2588 gimple_assign_set_rhs3 (ass, rhs);
2592 /* A wrapper around 3 operand gimple_assign_set_rhs_with_ops, for callers
2593 which expect to see only two operands. */
2596 gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *gsi, enum tree_code code,
2599 gimple_assign_set_rhs_with_ops (gsi, code, op1, op2, NULL);
2602 /* A wrapper around 3 operand gimple_assign_set_rhs_with_ops, for callers
2603 which expect to see only one operands. */
2606 gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *gsi, enum tree_code code,
2609 gimple_assign_set_rhs_with_ops (gsi, code, op1, NULL, NULL);
2612 /* Returns true if GS is a nontemporal move. */
2615 gimple_assign_nontemporal_move_p (const gassign *gs)
2617 return gs->nontemporal_move;
2620 /* Sets nontemporal move flag of GS to NONTEMPORAL. */
2623 gimple_assign_set_nontemporal_move (gimple *gs, bool nontemporal)
2625 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
2626 gs->nontemporal_move = nontemporal;
2630 /* Return the code of the expression computed on the rhs of assignment
2631 statement GS. In case that the RHS is a single object, returns the
2632 tree code of the object. */
2634 static inline enum tree_code
2635 gimple_assign_rhs_code (const gassign *gs)
2637 enum tree_code code = (enum tree_code) gs->subcode;
2638 /* While we initially set subcode to the TREE_CODE of the rhs for
2639 GIMPLE_SINGLE_RHS assigns we do not update that subcode to stay
2640 in sync when we rewrite stmts into SSA form or do SSA propagations. */
2641 if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS)
2642 code = TREE_CODE (gs->op[1]);
2647 static inline enum tree_code
2648 gimple_assign_rhs_code (const gimple *gs)
2650 const gassign *ass = GIMPLE_CHECK2<const gassign *> (gs);
2651 return gimple_assign_rhs_code (ass);
2655 /* Set CODE to be the code for the expression computed on the RHS of
2659 gimple_assign_set_rhs_code (gimple *s, enum tree_code code)
2661 GIMPLE_CHECK (s, GIMPLE_ASSIGN);
2666 /* Return the gimple rhs class of the code of the expression computed on
2667 the rhs of assignment statement GS.
2668 This will never return GIMPLE_INVALID_RHS. */
2670 static inline enum gimple_rhs_class
2671 gimple_assign_rhs_class (const gimple *gs)
2673 return get_gimple_rhs_class (gimple_assign_rhs_code (gs));
2676 /* Return true if GS is an assignment with a singleton RHS, i.e.,
2677 there is no operator associated with the assignment itself.
2678 Unlike gimple_assign_copy_p, this predicate returns true for
2679 any RHS operand, including those that perform an operation
2680 and do not have the semantics of a copy, such as COND_EXPR. */
2683 gimple_assign_single_p (const gimple *gs)
2685 return (is_gimple_assign (gs)
2686 && gimple_assign_rhs_class (gs) == GIMPLE_SINGLE_RHS);
2689 /* Return true if GS performs a store to its lhs. */
2692 gimple_store_p (const gimple *gs)
2694 tree lhs = gimple_get_lhs (gs);
2695 return lhs && !is_gimple_reg (lhs);
2698 /* Return true if GS is an assignment that loads from its rhs1. */
2701 gimple_assign_load_p (const gimple *gs)
2704 if (!gimple_assign_single_p (gs))
2706 rhs = gimple_assign_rhs1 (gs);
2707 if (TREE_CODE (rhs) == WITH_SIZE_EXPR)
2709 rhs = get_base_address (rhs);
2710 return (DECL_P (rhs)
2711 || TREE_CODE (rhs) == MEM_REF || TREE_CODE (rhs) == TARGET_MEM_REF);
2715 /* Return true if S is a type-cast assignment. */
2718 gimple_assign_cast_p (const gimple *s)
2720 if (is_gimple_assign (s))
2722 enum tree_code sc = gimple_assign_rhs_code (s);
2723 return CONVERT_EXPR_CODE_P (sc)
2724 || sc == VIEW_CONVERT_EXPR
2725 || sc == FIX_TRUNC_EXPR;
2731 /* Return true if S is a clobber statement. */
2734 gimple_clobber_p (const gimple *s)
2736 return gimple_assign_single_p (s)
2737 && TREE_CLOBBER_P (gimple_assign_rhs1 (s));
2740 /* Return true if GS is a GIMPLE_CALL. */
2743 is_gimple_call (const gimple *gs)
2745 return gimple_code (gs) == GIMPLE_CALL;
2748 /* Return the LHS of call statement GS. */
2751 gimple_call_lhs (const gcall *gs)
2757 gimple_call_lhs (const gimple *gs)
2759 const gcall *gc = GIMPLE_CHECK2<const gcall *> (gs);
2760 return gimple_call_lhs (gc);
2764 /* Return a pointer to the LHS of call statement GS. */
2766 static inline tree *
2767 gimple_call_lhs_ptr (const gcall *gs)
2769 return const_cast<tree *> (&gs->op[0]);
2772 static inline tree *
2773 gimple_call_lhs_ptr (const gimple *gs)
2775 const gcall *gc = GIMPLE_CHECK2<const gcall *> (gs);
2776 return gimple_call_lhs_ptr (gc);
2780 /* Set LHS to be the LHS operand of call statement GS. */
2783 gimple_call_set_lhs (gcall *gs, tree lhs)
2786 if (lhs && TREE_CODE (lhs) == SSA_NAME)
2787 SSA_NAME_DEF_STMT (lhs) = gs;
2791 gimple_call_set_lhs (gimple *gs, tree lhs)
2793 gcall *gc = GIMPLE_CHECK2<gcall *> (gs);
2794 gimple_call_set_lhs (gc, lhs);
2798 /* Return true if call GS calls an internal-only function, as enumerated
2802 gimple_call_internal_p (const gcall *gs)
2804 return (gs->subcode & GF_CALL_INTERNAL) != 0;
2808 gimple_call_internal_p (const gimple *gs)
2810 const gcall *gc = GIMPLE_CHECK2<const gcall *> (gs);
2811 return gimple_call_internal_p (gc);
2815 /* Return true if call GS is marked as instrumented by
2816 Pointer Bounds Checker. */
2819 gimple_call_with_bounds_p (const gcall *gs)
2821 return (gs->subcode & GF_CALL_WITH_BOUNDS) != 0;
2825 gimple_call_with_bounds_p (const gimple *gs)
2827 const gcall *gc = GIMPLE_CHECK2<const gcall *> (gs);
2828 return gimple_call_with_bounds_p (gc);
2832 /* If INSTRUMENTED_P is true, marm statement GS as instrumented by
2833 Pointer Bounds Checker. */
2836 gimple_call_set_with_bounds (gcall *gs, bool with_bounds)
2839 gs->subcode |= GF_CALL_WITH_BOUNDS;
2841 gs->subcode &= ~GF_CALL_WITH_BOUNDS;
2845 gimple_call_set_with_bounds (gimple *gs, bool with_bounds)
2847 gcall *gc = GIMPLE_CHECK2<gcall *> (gs);
2848 gimple_call_set_with_bounds (gc, with_bounds);
2852 /* Return the target of internal call GS. */
2854 static inline enum internal_fn
2855 gimple_call_internal_fn (const gcall *gs)
2857 gcc_gimple_checking_assert (gimple_call_internal_p (gs));
2858 return gs->u.internal_fn;
2861 static inline enum internal_fn
2862 gimple_call_internal_fn (const gimple *gs)
2864 const gcall *gc = GIMPLE_CHECK2<const gcall *> (gs);
2865 return gimple_call_internal_fn (gc);
2868 /* If CTRL_ALTERING_P is true, mark GIMPLE_CALL S to be a stmt
2869 that could alter control flow. */
2872 gimple_call_set_ctrl_altering (gcall *s, bool ctrl_altering_p)
2874 if (ctrl_altering_p)
2875 s->subcode |= GF_CALL_CTRL_ALTERING;
2877 s->subcode &= ~GF_CALL_CTRL_ALTERING;
2881 gimple_call_set_ctrl_altering (gimple *s, bool ctrl_altering_p)
2883 gcall *gc = GIMPLE_CHECK2<gcall *> (s);
2884 gimple_call_set_ctrl_altering (gc, ctrl_altering_p);
2887 /* Return true if call GS calls an func whose GF_CALL_CTRL_ALTERING
2888 flag is set. Such call could not be a stmt in the middle of a bb. */
2891 gimple_call_ctrl_altering_p (const gcall *gs)
2893 return (gs->subcode & GF_CALL_CTRL_ALTERING) != 0;
2897 gimple_call_ctrl_altering_p (const gimple *gs)
2899 const gcall *gc = GIMPLE_CHECK2<const gcall *> (gs);
2900 return gimple_call_ctrl_altering_p (gc);
2904 /* Return the function type of the function called by GS. */
2907 gimple_call_fntype (const gcall *gs)
2909 if (gimple_call_internal_p (gs))
2911 return gs->u.fntype;
2915 gimple_call_fntype (const gimple *gs)
2917 const gcall *call_stmt = GIMPLE_CHECK2<const gcall *> (gs);
2918 return gimple_call_fntype (call_stmt);
2921 /* Set the type of the function called by CALL_STMT to FNTYPE. */
2924 gimple_call_set_fntype (gcall *call_stmt, tree fntype)
2926 gcc_gimple_checking_assert (!gimple_call_internal_p (call_stmt));
2927 call_stmt->u.fntype = fntype;
2931 /* Return the tree node representing the function called by call
2935 gimple_call_fn (const gcall *gs)
2941 gimple_call_fn (const gimple *gs)
2943 const gcall *gc = GIMPLE_CHECK2<const gcall *> (gs);
2944 return gimple_call_fn (gc);
2947 /* Return a pointer to the tree node representing the function called by call
2950 static inline tree *
2951 gimple_call_fn_ptr (const gcall *gs)
2953 return const_cast<tree *> (&gs->op[1]);
2956 static inline tree *
2957 gimple_call_fn_ptr (const gimple *gs)
2959 const gcall *gc = GIMPLE_CHECK2<const gcall *> (gs);
2960 return gimple_call_fn_ptr (gc);
2964 /* Set FN to be the function called by call statement GS. */
2967 gimple_call_set_fn (gcall *gs, tree fn)
2969 gcc_gimple_checking_assert (!gimple_call_internal_p (gs));
2974 /* Set FNDECL to be the function called by call statement GS. */
2977 gimple_call_set_fndecl (gcall *gs, tree decl)
2979 gcc_gimple_checking_assert (!gimple_call_internal_p (gs));
2980 gs->op[1] = build1_loc (gimple_location (gs), ADDR_EXPR,
2981 build_pointer_type (TREE_TYPE (decl)), decl);
2985 gimple_call_set_fndecl (gimple *gs, tree decl)
2987 gcall *gc = GIMPLE_CHECK2<gcall *> (gs);
2988 gimple_call_set_fndecl (gc, decl);
2992 /* Set internal function FN to be the function called by call statement CALL_STMT. */
2995 gimple_call_set_internal_fn (gcall *call_stmt, enum internal_fn fn)
2997 gcc_gimple_checking_assert (gimple_call_internal_p (call_stmt));
2998 call_stmt->u.internal_fn = fn;
3002 /* If a given GIMPLE_CALL's callee is a FUNCTION_DECL, return it.
3003 Otherwise return NULL. This function is analogous to
3004 get_callee_fndecl in tree land. */
3007 gimple_call_fndecl (const gcall *gs)
3009 return gimple_call_addr_fndecl (gimple_call_fn (gs));
3013 gimple_call_fndecl (const gimple *gs)
3015 const gcall *gc = GIMPLE_CHECK2<const gcall *> (gs);
3016 return gimple_call_fndecl (gc);
3020 /* Return the type returned by call statement GS. */
3023 gimple_call_return_type (const gcall *gs)
3025 tree type = gimple_call_fntype (gs);
3027 if (type == NULL_TREE)
3028 return TREE_TYPE (gimple_call_lhs (gs));
3030 /* The type returned by a function is the type of its
3032 return TREE_TYPE (type);
3036 /* Return the static chain for call statement GS. */
3039 gimple_call_chain (const gcall *gs)
3045 gimple_call_chain (const gimple *gs)
3047 const gcall *gc = GIMPLE_CHECK2<const gcall *> (gs);
3048 return gimple_call_chain (gc);
3052 /* Return a pointer to the static chain for call statement CALL_STMT. */
3054 static inline tree *
3055 gimple_call_chain_ptr (const gcall *call_stmt)
3057 return const_cast<tree *> (&call_stmt->op[2]);
3060 /* Set CHAIN to be the static chain for call statement CALL_STMT. */
3063 gimple_call_set_chain (gcall *call_stmt, tree chain)
3065 call_stmt->op[2] = chain;
3069 /* Return the number of arguments used by call statement GS. */
3071 static inline unsigned
3072 gimple_call_num_args (const gcall *gs)
3074 return gimple_num_ops (gs) - 3;
3077 static inline unsigned
3078 gimple_call_num_args (const gimple *gs)
3080 const gcall *gc = GIMPLE_CHECK2<const gcall *> (gs);
3081 return gimple_call_num_args (gc);
3085 /* Return the argument at position INDEX for call statement GS. */
3088 gimple_call_arg (const gcall *gs, unsigned index)
3090 gcc_gimple_checking_assert (gimple_num_ops (gs) > index + 3);
3091 return gs->op[index + 3];
3095 gimple_call_arg (const gimple *gs, unsigned index)
3097 const gcall *gc = GIMPLE_CHECK2<const gcall *> (gs);
3098 return gimple_call_arg (gc, index);
3102 /* Return a pointer to the argument at position INDEX for call
3105 static inline tree *
3106 gimple_call_arg_ptr (const gcall *gs, unsigned index)
3108 gcc_gimple_checking_assert (gimple_num_ops (gs) > index + 3);
3109 return const_cast<tree *> (&gs->op[index + 3]);
3112 static inline tree *
3113 gimple_call_arg_ptr (const gimple *gs, unsigned index)
3115 const gcall *gc = GIMPLE_CHECK2<const gcall *> (gs);
3116 return gimple_call_arg_ptr (gc, index);
3120 /* Set ARG to be the argument at position INDEX for call statement GS. */
3123 gimple_call_set_arg (gcall *gs, unsigned index, tree arg)
3125 gcc_gimple_checking_assert (gimple_num_ops (gs) > index + 3);
3126 gs->op[index + 3] = arg;
3130 gimple_call_set_arg (gimple *gs, unsigned index, tree arg)
3132 gcall *gc = GIMPLE_CHECK2<gcall *> (gs);
3133 gimple_call_set_arg (gc, index, arg);
3137 /* If TAIL_P is true, mark call statement S as being a tail call
3138 (i.e., a call just before the exit of a function). These calls are
3139 candidate for tail call optimization. */
3142 gimple_call_set_tail (gcall *s, bool tail_p)
3145 s->subcode |= GF_CALL_TAILCALL;
3147 s->subcode &= ~GF_CALL_TAILCALL;
3151 /* Return true if GIMPLE_CALL S is marked as a tail call. */
3154 gimple_call_tail_p (gcall *s)
3156 return (s->subcode & GF_CALL_TAILCALL) != 0;
3160 /* If RETURN_SLOT_OPT_P is true mark GIMPLE_CALL S as valid for return
3161 slot optimization. This transformation uses the target of the call
3162 expansion as the return slot for calls that return in memory. */
3165 gimple_call_set_return_slot_opt (gcall *s, bool return_slot_opt_p)
3167 if (return_slot_opt_p)
3168 s->subcode |= GF_CALL_RETURN_SLOT_OPT;
3170 s->subcode &= ~GF_CALL_RETURN_SLOT_OPT;
3174 /* Return true if S is marked for return slot optimization. */
3177 gimple_call_return_slot_opt_p (gcall *s)
3179 return (s->subcode & GF_CALL_RETURN_SLOT_OPT) != 0;
3183 /* If FROM_THUNK_P is true, mark GIMPLE_CALL S as being the jump from a
3184 thunk to the thunked-to function. */
3187 gimple_call_set_from_thunk (gcall *s, bool from_thunk_p)
3190 s->subcode |= GF_CALL_FROM_THUNK;
3192 s->subcode &= ~GF_CALL_FROM_THUNK;
3196 /* Return true if GIMPLE_CALL S is a jump from a thunk. */
3199 gimple_call_from_thunk_p (gcall *s)
3201 return (s->subcode & GF_CALL_FROM_THUNK) != 0;
3205 /* If PASS_ARG_PACK_P is true, GIMPLE_CALL S is a stdarg call that needs the
3206 argument pack in its argument list. */
3209 gimple_call_set_va_arg_pack (gcall *s, bool pass_arg_pack_p)
3211 if (pass_arg_pack_p)
3212 s->subcode |= GF_CALL_VA_ARG_PACK;
3214 s->subcode &= ~GF_CALL_VA_ARG_PACK;
3218 /* Return true if GIMPLE_CALL S is a stdarg call that needs the
3219 argument pack in its argument list. */
3222 gimple_call_va_arg_pack_p (gcall *s)
3224 return (s->subcode & GF_CALL_VA_ARG_PACK) != 0;
3228 /* Return true if S is a noreturn call. */
3231 gimple_call_noreturn_p (const gcall *s)
3233 return (gimple_call_flags (s) & ECF_NORETURN) != 0;
3237 gimple_call_noreturn_p (const gimple *s)
3239 const gcall *gc = GIMPLE_CHECK2<const gcall *> (s);
3240 return gimple_call_noreturn_p (gc);
3244 /* If NOTHROW_P is true, GIMPLE_CALL S is a call that is known to not throw
3245 even if the called function can throw in other cases. */
3248 gimple_call_set_nothrow (gcall *s, bool nothrow_p)
3251 s->subcode |= GF_CALL_NOTHROW;
3253 s->subcode &= ~GF_CALL_NOTHROW;
3256 /* Return true if S is a nothrow call. */
3259 gimple_call_nothrow_p (gcall *s)
3261 return (gimple_call_flags (s) & ECF_NOTHROW) != 0;
3264 /* If FOR_VAR is true, GIMPLE_CALL S is a call to builtin_alloca that
3265 is known to be emitted for VLA objects. Those are wrapped by
3266 stack_save/stack_restore calls and hence can't lead to unbounded
3267 stack growth even when they occur in loops. */
3270 gimple_call_set_alloca_for_var (gcall *s, bool for_var)
3273 s->subcode |= GF_CALL_ALLOCA_FOR_VAR;
3275 s->subcode &= ~GF_CALL_ALLOCA_FOR_VAR;
3278 /* Return true of S is a call to builtin_alloca emitted for VLA objects. */
3281 gimple_call_alloca_for_var_p (gcall *s)
3283 return (s->subcode & GF_CALL_ALLOCA_FOR_VAR) != 0;
3286 /* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL. */
3289 gimple_call_copy_flags (gcall *dest_call, gcall *orig_call)
3291 dest_call->subcode = orig_call->subcode;
3295 /* Return a pointer to the points-to solution for the set of call-used
3296 variables of the call CALL_STMT. */
3298 static inline struct pt_solution *
3299 gimple_call_use_set (gcall *call_stmt)
3301 return &call_stmt->call_used;
3305 /* Return a pointer to the points-to solution for the set of call-used
3306 variables of the call CALL_STMT. */
3308 static inline struct pt_solution *
3309 gimple_call_clobber_set (gcall *call_stmt)
3311 return &call_stmt->call_clobbered;
3315 /* Returns true if this is a GIMPLE_ASSIGN or a GIMPLE_CALL with a
3319 gimple_has_lhs (gimple *stmt)
3321 if (is_gimple_assign (stmt))
3323 if (gcall *call = dyn_cast <gcall *> (stmt))
3324 return gimple_call_lhs (call) != NULL_TREE;
3329 /* Return the code of the predicate computed by conditional statement GS. */
3331 static inline enum tree_code
3332 gimple_cond_code (const gcond *gs)
3334 return (enum tree_code) gs->subcode;
3337 static inline enum tree_code
3338 gimple_cond_code (const gimple *gs)
3340 const gcond *gc = GIMPLE_CHECK2<const gcond *> (gs);
3341 return gimple_cond_code (gc);
3345 /* Set CODE to be the predicate code for the conditional statement GS. */
3348 gimple_cond_set_code (gcond *gs, enum tree_code code)
3354 /* Return the LHS of the predicate computed by conditional statement GS. */
3357 gimple_cond_lhs (const gcond *gs)
3363 gimple_cond_lhs (const gimple *gs)
3365 const gcond *gc = GIMPLE_CHECK2<const gcond *> (gs);
3366 return gimple_cond_lhs (gc);
3369 /* Return the pointer to the LHS of the predicate computed by conditional
3372 static inline tree *
3373 gimple_cond_lhs_ptr (const gcond *gs)
3375 return const_cast<tree *> (&gs->op[0]);
3378 /* Set LHS to be the LHS operand of the predicate computed by
3379 conditional statement GS. */
3382 gimple_cond_set_lhs (gcond *gs, tree lhs)
3388 /* Return the RHS operand of the predicate computed by conditional GS. */
3391 gimple_cond_rhs (const gcond *gs)
3397 gimple_cond_rhs (const gimple *gs)
3399 const gcond *gc = GIMPLE_CHECK2<const gcond *> (gs);
3400 return gimple_cond_rhs (gc);
3403 /* Return the pointer to the RHS operand of the predicate computed by
3406 static inline tree *
3407 gimple_cond_rhs_ptr (const gcond *gs)
3409 return const_cast<tree *> (&gs->op[1]);
3413 /* Set RHS to be the RHS operand of the predicate computed by
3414 conditional statement GS. */
3417 gimple_cond_set_rhs (gcond *gs, tree rhs)
3423 /* Return the label used by conditional statement GS when its
3424 predicate evaluates to true. */
3427 gimple_cond_true_label (const gcond *gs)
3433 /* Set LABEL to be the label used by conditional statement GS when its
3434 predicate evaluates to true. */
3437 gimple_cond_set_true_label (gcond *gs, tree label)
3443 /* Set LABEL to be the label used by conditional statement GS when its
3444 predicate evaluates to false. */
3447 gimple_cond_set_false_label (gcond *gs, tree label)
3453 /* Return the label used by conditional statement GS when its
3454 predicate evaluates to false. */
3457 gimple_cond_false_label (const gcond *gs)
3463 /* Set the conditional COND_STMT to be of the form 'if (1 == 0)'. */
3466 gimple_cond_make_false (gcond *gs)
3468 gimple_cond_set_lhs (gs, boolean_false_node);
3469 gimple_cond_set_rhs (gs, boolean_false_node);
3470 gs->subcode = NE_EXPR;
3474 /* Set the conditional COND_STMT to be of the form 'if (1 == 1)'. */
3477 gimple_cond_make_true (gcond *gs)
3479 gimple_cond_set_lhs (gs, boolean_true_node);
3480 gimple_cond_set_rhs (gs, boolean_false_node);
3481 gs->subcode = NE_EXPR;
3484 /* Check if conditional statemente GS is of the form 'if (1 == 1)',
3485 'if (0 == 0)', 'if (1 != 0)' or 'if (0 != 1)' */
3488 gimple_cond_true_p (const gcond *gs)
3490 tree lhs = gimple_cond_lhs (gs);
3491 tree rhs = gimple_cond_rhs (gs);
3492 enum tree_code code = gimple_cond_code (gs);
3494 if (lhs != boolean_true_node && lhs != boolean_false_node)
3497 if (rhs != boolean_true_node && rhs != boolean_false_node)
3500 if (code == NE_EXPR && lhs != rhs)
3503 if (code == EQ_EXPR && lhs == rhs)
3509 /* Check if conditional statement GS is of the form 'if (1 != 1)',
3510 'if (0 != 0)', 'if (1 == 0)' or 'if (0 == 1)' */
3513 gimple_cond_false_p (const gcond *gs)
3515 tree lhs = gimple_cond_lhs (gs);
3516 tree rhs = gimple_cond_rhs (gs);
3517 enum tree_code code = gimple_cond_code (gs);
3519 if (lhs != boolean_true_node && lhs != boolean_false_node)
3522 if (rhs != boolean_true_node && rhs != boolean_false_node)
3525 if (code == NE_EXPR && lhs == rhs)
3528 if (code == EQ_EXPR && lhs != rhs)
3534 /* Set the code, LHS and RHS of GIMPLE_COND STMT from CODE, LHS and RHS. */
3537 gimple_cond_set_condition (gcond *stmt, enum tree_code code, tree lhs,
3540 gimple_cond_set_code (stmt, code);
3541 gimple_cond_set_lhs (stmt, lhs);
3542 gimple_cond_set_rhs (stmt, rhs);
3545 /* Return the LABEL_DECL node used by GIMPLE_LABEL statement GS. */
3548 gimple_label_label (const glabel *gs)
3554 /* Set LABEL to be the LABEL_DECL node used by GIMPLE_LABEL statement
3558 gimple_label_set_label (glabel *gs, tree label)
3564 /* Return the destination of the unconditional jump GS. */
3567 gimple_goto_dest (const gimple *gs)
3569 GIMPLE_CHECK (gs, GIMPLE_GOTO);
3570 return gimple_op (gs, 0);
3574 /* Set DEST to be the destination of the unconditonal jump GS. */
3577 gimple_goto_set_dest (ggoto *gs, tree dest)
3583 /* Return the variables declared in the GIMPLE_BIND statement GS. */
3586 gimple_bind_vars (const gbind *bind_stmt)
3588 return bind_stmt->vars;
3592 /* Set VARS to be the set of variables declared in the GIMPLE_BIND
3596 gimple_bind_set_vars (gbind *bind_stmt, tree vars)
3598 bind_stmt->vars = vars;
3602 /* Append VARS to the set of variables declared in the GIMPLE_BIND
3606 gimple_bind_append_vars (gbind *bind_stmt, tree vars)
3608 bind_stmt->vars = chainon (bind_stmt->vars, vars);
3612 static inline gimple_seq *
3613 gimple_bind_body_ptr (gbind *bind_stmt)
3615 return &bind_stmt->body;
3618 /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS. */
3620 static inline gimple_seq
3621 gimple_bind_body (gbind *gs)
3623 return *gimple_bind_body_ptr (gs);
3627 /* Set SEQ to be the GIMPLE sequence contained in the GIMPLE_BIND
3631 gimple_bind_set_body (gbind *bind_stmt, gimple_seq seq)
3633 bind_stmt->body = seq;
3637 /* Append a statement to the end of a GIMPLE_BIND's body. */
3640 gimple_bind_add_stmt (gbind *bind_stmt, gimple *stmt)
3642 gimple_seq_add_stmt (&bind_stmt->body, stmt);
3646 /* Append a sequence of statements to the end of a GIMPLE_BIND's body. */
3649 gimple_bind_add_seq (gbind *bind_stmt, gimple_seq seq)
3651 gimple_seq_add_seq (&bind_stmt->body, seq);
3655 /* Return the TREE_BLOCK node associated with GIMPLE_BIND statement
3656 GS. This is analogous to the BIND_EXPR_BLOCK field in trees. */
3659 gimple_bind_block (const gbind *bind_stmt)
3661 return bind_stmt->block;
3665 /* Set BLOCK to be the TREE_BLOCK node associated with GIMPLE_BIND
3669 gimple_bind_set_block (gbind *bind_stmt, tree block)
3671 gcc_gimple_checking_assert (block == NULL_TREE
3672 || TREE_CODE (block) == BLOCK);
3673 bind_stmt->block = block;
3677 /* Return the number of input operands for GIMPLE_ASM ASM_STMT. */
3679 static inline unsigned
3680 gimple_asm_ninputs (const gasm *asm_stmt)
3682 return asm_stmt->ni;
3686 /* Return the number of output operands for GIMPLE_ASM ASM_STMT. */
3688 static inline unsigned
3689 gimple_asm_noutputs (const gasm *asm_stmt)
3691 return asm_stmt->no;
3695 /* Return the number of clobber operands for GIMPLE_ASM ASM_STMT. */
3697 static inline unsigned
3698 gimple_asm_nclobbers (const gasm *asm_stmt)
3700 return asm_stmt->nc;
3703 /* Return the number of label operands for GIMPLE_ASM ASM_STMT. */
3705 static inline unsigned
3706 gimple_asm_nlabels (const gasm *asm_stmt)
3708 return asm_stmt->nl;
3711 /* Return input operand INDEX of GIMPLE_ASM ASM_STMT. */
3714 gimple_asm_input_op (const gasm *asm_stmt, unsigned index)
3716 gcc_gimple_checking_assert (index < asm_stmt->ni);
3717 return asm_stmt->op[index + asm_stmt->no];
3720 /* Return a pointer to input operand INDEX of GIMPLE_ASM ASM_STMT. */
3722 static inline tree *
3723 gimple_asm_input_op_ptr (const gasm *asm_stmt, unsigned index)
3725 gcc_gimple_checking_assert (index < asm_stmt->ni);
3726 return const_cast<tree *> (&asm_stmt->op[index + asm_stmt->no]);
3730 /* Set IN_OP to be input operand INDEX in GIMPLE_ASM ASM_STMT. */
3733 gimple_asm_set_input_op (gasm *asm_stmt, unsigned index, tree in_op)
3735 gcc_gimple_checking_assert (index < asm_stmt->ni
3736 && TREE_CODE (in_op) == TREE_LIST);
3737 asm_stmt->op[index + asm_stmt->no] = in_op;
3741 /* Return output operand INDEX of GIMPLE_ASM ASM_STMT. */
3744 gimple_asm_output_op (const gasm *asm_stmt, unsigned index)
3746 gcc_gimple_checking_assert (index < asm_stmt->no);
3747 return asm_stmt->op[index];
3750 /* Return a pointer to output operand INDEX of GIMPLE_ASM ASM_STMT. */
3752 static inline tree *
3753 gimple_asm_output_op_ptr (const gasm *asm_stmt, unsigned index)
3755 gcc_gimple_checking_assert (index < asm_stmt->no);
3756 return const_cast<tree *> (&asm_stmt->op[index]);
3760 /* Set OUT_OP to be output operand INDEX in GIMPLE_ASM ASM_STMT. */
3763 gimple_asm_set_output_op (gasm *asm_stmt, unsigned index, tree out_op)
3765 gcc_gimple_checking_assert (index < asm_stmt->no
3766 && TREE_CODE (out_op) == TREE_LIST);
3767 asm_stmt->op[index] = out_op;
3771 /* Return clobber operand INDEX of GIMPLE_ASM ASM_STMT. */
3774 gimple_asm_clobber_op (const gasm *asm_stmt, unsigned index)
3776 gcc_gimple_checking_assert (index < asm_stmt->nc);
3777 return asm_stmt->op[index + asm_stmt->ni + asm_stmt->no];
3781 /* Set CLOBBER_OP to be clobber operand INDEX in GIMPLE_ASM ASM_STMT. */
3784 gimple_asm_set_clobber_op (gasm *asm_stmt, unsigned index, tree clobber_op)
3786 gcc_gimple_checking_assert (index < asm_stmt->nc
3787 && TREE_CODE (clobber_op) == TREE_LIST);
3788 asm_stmt->op[index + asm_stmt->ni + asm_stmt->no] = clobber_op;
3791 /* Return label operand INDEX of GIMPLE_ASM ASM_STMT. */
3794 gimple_asm_label_op (const gasm *asm_stmt, unsigned index)
3796 gcc_gimple_checking_assert (index < asm_stmt->nl);
3797 return asm_stmt->op[index + asm_stmt->ni + asm_stmt->nc];
3800 /* Set LABEL_OP to be label operand INDEX in GIMPLE_ASM ASM_STMT. */
3803 gimple_asm_set_label_op (gasm *asm_stmt, unsigned index, tree label_op)
3805 gcc_gimple_checking_assert (index < asm_stmt->nl
3806 && TREE_CODE (label_op) == TREE_LIST);
3807 asm_stmt->op[index + asm_stmt->ni + asm_stmt->nc] = label_op;
3810 /* Return the string representing the assembly instruction in
3811 GIMPLE_ASM ASM_STMT. */
3813 static inline const char *
3814 gimple_asm_string (const gasm *asm_stmt)
3816 return asm_stmt->string;
3820 /* Return true ASM_STMT ASM_STMT is an asm statement marked volatile. */
3823 gimple_asm_volatile_p (const gasm *asm_stmt)
3825 return (asm_stmt->subcode & GF_ASM_VOLATILE) != 0;
3829 /* If VOLATLE_P is true, mark asm statement ASM_STMT as volatile. */
3832 gimple_asm_set_volatile (gasm *asm_stmt, bool volatile_p)
3835 asm_stmt->subcode |= GF_ASM_VOLATILE;
3837 asm_stmt->subcode &= ~GF_ASM_VOLATILE;
3841 /* If INPUT_P is true, mark asm ASM_STMT as an ASM_INPUT. */
3844 gimple_asm_set_input (gasm *asm_stmt, bool input_p)
3847 asm_stmt->subcode |= GF_ASM_INPUT;
3849 asm_stmt->subcode &= ~GF_ASM_INPUT;
3853 /* Return true if asm ASM_STMT is an ASM_INPUT. */
3856 gimple_asm_input_p (const gasm *asm_stmt)
3858 return (asm_stmt->subcode & GF_ASM_INPUT) != 0;
3862 /* Return the types handled by GIMPLE_CATCH statement CATCH_STMT. */
3865 gimple_catch_types (const gcatch *catch_stmt)
3867 return catch_stmt->types;
3871 /* Return a pointer to the types handled by GIMPLE_CATCH statement CATCH_STMT. */
3873 static inline tree *
3874 gimple_catch_types_ptr (gcatch *catch_stmt)
3876 return &catch_stmt->types;
3880 /* Return a pointer to the GIMPLE sequence representing the body of
3881 the handler of GIMPLE_CATCH statement CATCH_STMT. */
3883 static inline gimple_seq *
3884 gimple_catch_handler_ptr (gcatch *catch_stmt)
3886 return &catch_stmt->handler;
3890 /* Return the GIMPLE sequence representing the body of the handler of
3891 GIMPLE_CATCH statement CATCH_STMT. */
3893 static inline gimple_seq
3894 gimple_catch_handler (gcatch *catch_stmt)
3896 return *gimple_catch_handler_ptr (catch_stmt);
3900 /* Set T to be the set of types handled by GIMPLE_CATCH CATCH_STMT. */
3903 gimple_catch_set_types (gcatch *catch_stmt, tree t)
3905 catch_stmt->types = t;
3909 /* Set HANDLER to be the body of GIMPLE_CATCH CATCH_STMT. */
3912 gimple_catch_set_handler (gcatch *catch_stmt, gimple_seq handler)
3914 catch_stmt->handler = handler;
3918 /* Return the types handled by GIMPLE_EH_FILTER statement GS. */
3921 gimple_eh_filter_types (const gimple *gs)
3923 const geh_filter *eh_filter_stmt = as_a <const geh_filter *> (gs);
3924 return eh_filter_stmt->types;
3928 /* Return a pointer to the types handled by GIMPLE_EH_FILTER statement
3931 static inline tree *
3932 gimple_eh_filter_types_ptr (gimple *gs)
3934 geh_filter *eh_filter_stmt = as_a <geh_filter *> (gs);
3935 return &eh_filter_stmt->types;
3939 /* Return a pointer to the sequence of statement to execute when
3940 GIMPLE_EH_FILTER statement fails. */
3942 static inline gimple_seq *
3943 gimple_eh_filter_failure_ptr (gimple *gs)
3945 geh_filter *eh_filter_stmt = as_a <geh_filter *> (gs);
3946 return &eh_filter_stmt->failure;
3950 /* Return the sequence of statement to execute when GIMPLE_EH_FILTER
3953 static inline gimple_seq
3954 gimple_eh_filter_failure (gimple *gs)
3956 return *gimple_eh_filter_failure_ptr (gs);
3960 /* Set TYPES to be the set of types handled by GIMPLE_EH_FILTER
3964 gimple_eh_filter_set_types (geh_filter *eh_filter_stmt, tree types)
3966 eh_filter_stmt->types = types;
3970 /* Set FAILURE to be the sequence of statements to execute on failure
3971 for GIMPLE_EH_FILTER EH_FILTER_STMT. */
3974 gimple_eh_filter_set_failure (geh_filter *eh_filter_stmt,
3977 eh_filter_stmt->failure = failure;
3980 /* Get the function decl to be called by the MUST_NOT_THROW region. */
3983 gimple_eh_must_not_throw_fndecl (geh_mnt *eh_mnt_stmt)
3985 return eh_mnt_stmt->fndecl;
3988 /* Set the function decl to be called by GS to DECL. */
3991 gimple_eh_must_not_throw_set_fndecl (geh_mnt *eh_mnt_stmt,
3994 eh_mnt_stmt->fndecl = decl;
3997 /* GIMPLE_EH_ELSE accessors. */
3999 static inline gimple_seq *
4000 gimple_eh_else_n_body_ptr (geh_else *eh_else_stmt)
4002 return &eh_else_stmt->n_body;
4005 static inline gimple_seq
4006 gimple_eh_else_n_body (geh_else *eh_else_stmt)
4008 return *gimple_eh_else_n_body_ptr (eh_else_stmt);
4011 static inline gimple_seq *
4012 gimple_eh_else_e_body_ptr (geh_else *eh_else_stmt)
4014 return &eh_else_stmt->e_body;
4017 static inline gimple_seq
4018 gimple_eh_else_e_body (geh_else *eh_else_stmt)
4020 return *gimple_eh_else_e_body_ptr (eh_else_stmt);
4024 gimple_eh_else_set_n_body (geh_else *eh_else_stmt, gimple_seq seq)
4026 eh_else_stmt->n_body = seq;
4030 gimple_eh_else_set_e_body (geh_else *eh_else_stmt, gimple_seq seq)
4032 eh_else_stmt->e_body = seq;
4035 /* GIMPLE_TRY accessors. */
4037 /* Return the kind of try block represented by GIMPLE_TRY GS. This is
4038 either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY. */
4040 static inline enum gimple_try_flags
4041 gimple_try_kind (const gimple *gs)
4043 GIMPLE_CHECK (gs, GIMPLE_TRY);
4044 return (enum gimple_try_flags) (gs->subcode & GIMPLE_TRY_KIND);
4048 /* Set the kind of try block represented by GIMPLE_TRY GS. */
4051 gimple_try_set_kind (gtry *gs, enum gimple_try_flags kind)
4053 gcc_gimple_checking_assert (kind == GIMPLE_TRY_CATCH
4054 || kind == GIMPLE_TRY_FINALLY);
4055 if (gimple_try_kind (gs) != kind)
4056 gs->subcode = (unsigned int) kind;
4060 /* Return the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
4063 gimple_try_catch_is_cleanup (const gimple *gs)
4065 gcc_gimple_checking_assert (gimple_try_kind (gs) == GIMPLE_TRY_CATCH);
4066 return (gs->subcode & GIMPLE_TRY_CATCH_IS_CLEANUP) != 0;
4070 /* Return a pointer to the sequence of statements used as the
4071 body for GIMPLE_TRY GS. */
4073 static inline gimple_seq *
4074 gimple_try_eval_ptr (gimple *gs)
4076 gtry *try_stmt = as_a <gtry *> (gs);
4077 return &try_stmt->eval;
4081 /* Return the sequence of statements used as the body for GIMPLE_TRY GS. */
4083 static inline gimple_seq
4084 gimple_try_eval (gimple *gs)
4086 return *gimple_try_eval_ptr (gs);
4090 /* Return a pointer to the sequence of statements used as the cleanup body for
4093 static inline gimple_seq *
4094 gimple_try_cleanup_ptr (gimple *gs)
4096 gtry *try_stmt = as_a <gtry *> (gs);
4097 return &try_stmt->cleanup;
4101 /* Return the sequence of statements used as the cleanup body for
4104 static inline gimple_seq
4105 gimple_try_cleanup (gimple *gs)
4107 return *gimple_try_cleanup_ptr (gs);
4111 /* Set the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
4114 gimple_try_set_catch_is_cleanup (gtry *g, bool catch_is_cleanup)
4116 gcc_gimple_checking_assert (gimple_try_kind (g) == GIMPLE_TRY_CATCH);
4117 if (catch_is_cleanup)
4118 g->subcode |= GIMPLE_TRY_CATCH_IS_CLEANUP;
4120 g->subcode &= ~GIMPLE_TRY_CATCH_IS_CLEANUP;
4124 /* Set EVAL to be the sequence of statements to use as the body for
4125 GIMPLE_TRY TRY_STMT. */
4128 gimple_try_set_eval (gtry *try_stmt, gimple_seq eval)
4130 try_stmt->eval = eval;
4134 /* Set CLEANUP to be the sequence of statements to use as the cleanup
4135 body for GIMPLE_TRY TRY_STMT. */
4138 gimple_try_set_cleanup (gtry *try_stmt, gimple_seq cleanup)
4140 try_stmt->cleanup = cleanup;
4144 /* Return a pointer to the cleanup sequence for cleanup statement GS. */
4146 static inline gimple_seq *
4147 gimple_wce_cleanup_ptr (gimple *gs)
4149 gimple_statement_wce *wce_stmt = as_a <gimple_statement_wce *> (gs);
4150 return &wce_stmt->cleanup;
4154 /* Return the cleanup sequence for cleanup statement GS. */
4156 static inline gimple_seq
4157 gimple_wce_cleanup (gimple *gs)
4159 return *gimple_wce_cleanup_ptr (gs);
4163 /* Set CLEANUP to be the cleanup sequence for GS. */
4166 gimple_wce_set_cleanup (gimple *gs, gimple_seq cleanup)
4168 gimple_statement_wce *wce_stmt = as_a <gimple_statement_wce *> (gs);
4169 wce_stmt->cleanup = cleanup;
4173 /* Return the CLEANUP_EH_ONLY flag for a WCE tuple. */
4176 gimple_wce_cleanup_eh_only (const gimple *gs)
4178 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
4179 return gs->subcode != 0;
4183 /* Set the CLEANUP_EH_ONLY flag for a WCE tuple. */
4186 gimple_wce_set_cleanup_eh_only (gimple *gs, bool eh_only_p)
4188 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
4189 gs->subcode = (unsigned int) eh_only_p;
4193 /* Return the maximum number of arguments supported by GIMPLE_PHI GS. */
4195 static inline unsigned
4196 gimple_phi_capacity (const gimple *gs)
4198 const gphi *phi_stmt = as_a <const gphi *> (gs);
4199 return phi_stmt->capacity;
4203 /* Return the number of arguments in GIMPLE_PHI GS. This must always
4204 be exactly the number of incoming edges for the basic block holding
4207 static inline unsigned
4208 gimple_phi_num_args (const gimple *gs)
4210 const gphi *phi_stmt = as_a <const gphi *> (gs);
4211 return phi_stmt->nargs;
4215 /* Return the SSA name created by GIMPLE_PHI GS. */
4218 gimple_phi_result (const gimple *gs)
4220 const gphi *phi_stmt = as_a <const gphi *> (gs);
4221 return phi_stmt->result;
4224 /* Return a pointer to the SSA name created by GIMPLE_PHI GS. */
4226 static inline tree *
4227 gimple_phi_result_ptr (gimple *gs)
4229 gphi *phi_stmt = as_a <gphi *> (gs);
4230 return &phi_stmt->result;
4233 /* Set RESULT to be the SSA name created by GIMPLE_PHI PHI. */
4236 gimple_phi_set_result (gphi *phi, tree result)
4238 phi->result = result;
4239 if (result && TREE_CODE (result) == SSA_NAME)
4240 SSA_NAME_DEF_STMT (result) = phi;
4244 /* Return the PHI argument corresponding to incoming edge INDEX for
4247 static inline struct phi_arg_d *
4248 gimple_phi_arg (gimple *gs, unsigned index)
4250 gphi *phi_stmt = as_a <gphi *> (gs);
4251 gcc_gimple_checking_assert (index <= phi_stmt->capacity);
4252 return &(phi_stmt->args[index]);
4255 /* Set PHIARG to be the argument corresponding to incoming edge INDEX
4256 for GIMPLE_PHI PHI. */
4259 gimple_phi_set_arg (gphi *phi, unsigned index, struct phi_arg_d * phiarg)
4261 gcc_gimple_checking_assert (index <= phi->nargs);
4262 phi->args[index] = *phiarg;
4265 /* Return the PHI nodes for basic block BB, or NULL if there are no
4268 static inline gimple_seq
4269 phi_nodes (const_basic_block bb)
4271 gcc_checking_assert (!(bb->flags & BB_RTL));
4272 return bb->il.gimple.phi_nodes;
4275 /* Return a pointer to the PHI nodes for basic block BB. */
4277 static inline gimple_seq *
4278 phi_nodes_ptr (basic_block bb)
4280 gcc_checking_assert (!(bb->flags & BB_RTL));
4281 return &bb->il.gimple.phi_nodes;
4284 /* Return the tree operand for argument I of PHI node GS. */
4287 gimple_phi_arg_def (gimple *gs, size_t index)
4289 return gimple_phi_arg (gs, index)->def;
4293 /* Return a pointer to the tree operand for argument I of phi node PHI. */
4295 static inline tree *
4296 gimple_phi_arg_def_ptr (gphi *phi, size_t index)
4298 return &gimple_phi_arg (phi, index)->def;
4301 /* Return the edge associated with argument I of phi node PHI. */
4304 gimple_phi_arg_edge (gphi *phi, size_t i)
4306 return EDGE_PRED (gimple_bb (phi), i);
4309 /* Return the source location of gimple argument I of phi node PHI. */
4311 static inline source_location
4312 gimple_phi_arg_location (gphi *phi, size_t i)
4314 return gimple_phi_arg (phi, i)->locus;
4317 /* Return the source location of the argument on edge E of phi node PHI. */
4319 static inline source_location
4320 gimple_phi_arg_location_from_edge (gphi *phi, edge e)
4322 return gimple_phi_arg (phi, e->dest_idx)->locus;
4325 /* Set the source location of gimple argument I of phi node PHI to LOC. */
4328 gimple_phi_arg_set_location (gphi *phi, size_t i, source_location loc)
4330 gimple_phi_arg (phi, i)->locus = loc;
4333 /* Return TRUE if argument I of phi node PHI has a location record. */
4336 gimple_phi_arg_has_location (gphi *phi, size_t i)
4338 return gimple_phi_arg_location (phi, i) != UNKNOWN_LOCATION;
4342 /* Return the region number for GIMPLE_RESX RESX_STMT. */
4345 gimple_resx_region (const gresx *resx_stmt)
4347 return resx_stmt->region;
4350 /* Set REGION to be the region number for GIMPLE_RESX RESX_STMT. */
4353 gimple_resx_set_region (gresx *resx_stmt, int region)
4355 resx_stmt->region = region;
4358 /* Return the region number for GIMPLE_EH_DISPATCH EH_DISPATCH_STMT. */
4361 gimple_eh_dispatch_region (const geh_dispatch *eh_dispatch_stmt)
4363 return eh_dispatch_stmt->region;
4366 /* Set REGION to be the region number for GIMPLE_EH_DISPATCH
4367 EH_DISPATCH_STMT. */
4370 gimple_eh_dispatch_set_region (geh_dispatch *eh_dispatch_stmt, int region)
4372 eh_dispatch_stmt->region = region;
4375 /* Return the number of labels associated with the switch statement GS. */
4377 static inline unsigned
4378 gimple_switch_num_labels (const gswitch *gs)
4381 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
4382 num_ops = gimple_num_ops (gs);
4383 gcc_gimple_checking_assert (num_ops > 1);
4388 /* Set NLABELS to be the number of labels for the switch statement GS. */
4391 gimple_switch_set_num_labels (gswitch *g, unsigned nlabels)
4393 GIMPLE_CHECK (g, GIMPLE_SWITCH);
4394 gimple_set_num_ops (g, nlabels + 1);
4398 /* Return the index variable used by the switch statement GS. */
4401 gimple_switch_index (const gswitch *gs)
4407 /* Return a pointer to the index variable for the switch statement GS. */
4409 static inline tree *
4410 gimple_switch_index_ptr (const gswitch *gs)
4412 return const_cast<tree *> (&gs->op[0]);
4416 /* Set INDEX to be the index variable for switch statement GS. */
4419 gimple_switch_set_index (gswitch *gs, tree index)
4421 gcc_gimple_checking_assert (SSA_VAR_P (index) || CONSTANT_CLASS_P (index));
4426 /* Return the label numbered INDEX. The default label is 0, followed by any
4427 labels in a switch statement. */
4430 gimple_switch_label (const gswitch *gs, unsigned index)
4432 gcc_gimple_checking_assert (gimple_num_ops (gs) > index + 1);
4433 return gs->op[index + 1];
4436 /* Set the label number INDEX to LABEL. 0 is always the default label. */
4439 gimple_switch_set_label (gswitch *gs, unsigned index, tree label)
4441 gcc_gimple_checking_assert (gimple_num_ops (gs) > index + 1
4442 && (label == NULL_TREE
4443 || TREE_CODE (label) == CASE_LABEL_EXPR));
4444 gs->op[index + 1] = label;
4447 /* Return the default label for a switch statement. */
4450 gimple_switch_default_label (const gswitch *gs)
4452 tree label = gimple_switch_label (gs, 0);
4453 gcc_checking_assert (!CASE_LOW (label) && !CASE_HIGH (label));
4457 /* Set the default label for a switch statement. */
4460 gimple_switch_set_default_label (gswitch *gs, tree label)
4462 gcc_checking_assert (!CASE_LOW (label) && !CASE_HIGH (label));
4463 gimple_switch_set_label (gs, 0, label);
4466 /* Return true if GS is a GIMPLE_DEBUG statement. */
4469 is_gimple_debug (const gimple *gs)
4471 return gimple_code (gs) == GIMPLE_DEBUG;
4474 /* Return true if S is a GIMPLE_DEBUG BIND statement. */
4477 gimple_debug_bind_p (const gimple *s)
4479 if (is_gimple_debug (s))
4480 return s->subcode == GIMPLE_DEBUG_BIND;
4485 /* Return the variable bound in a GIMPLE_DEBUG bind statement. */
4488 gimple_debug_bind_get_var (gimple *dbg)
4490 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
4491 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
4492 return gimple_op (dbg, 0);
4495 /* Return the value bound to the variable in a GIMPLE_DEBUG bind
4499 gimple_debug_bind_get_value (gimple *dbg)
4501 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
4502 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
4503 return gimple_op (dbg, 1);
4506 /* Return a pointer to the value bound to the variable in a
4507 GIMPLE_DEBUG bind statement. */
4509 static inline tree *
4510 gimple_debug_bind_get_value_ptr (gimple *dbg)
4512 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
4513 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
4514 return gimple_op_ptr (dbg, 1);
4517 /* Set the variable bound in a GIMPLE_DEBUG bind statement. */
4520 gimple_debug_bind_set_var (gimple *dbg, tree var)
4522 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
4523 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
4524 gimple_set_op (dbg, 0, var);
4527 /* Set the value bound to the variable in a GIMPLE_DEBUG bind
4531 gimple_debug_bind_set_value (gimple *dbg, tree value)
4533 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
4534 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
4535 gimple_set_op (dbg, 1, value);
4538 /* The second operand of a GIMPLE_DEBUG_BIND, when the value was
4540 #define GIMPLE_DEBUG_BIND_NOVALUE NULL_TREE /* error_mark_node */
4542 /* Remove the value bound to the variable in a GIMPLE_DEBUG bind
4546 gimple_debug_bind_reset_value (gimple *dbg)
4548 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
4549 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
4550 gimple_set_op (dbg, 1, GIMPLE_DEBUG_BIND_NOVALUE);
4553 /* Return true if the GIMPLE_DEBUG bind statement is bound to a
4557 gimple_debug_bind_has_value_p (gimple *dbg)
4559 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
4560 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
4561 return gimple_op (dbg, 1) != GIMPLE_DEBUG_BIND_NOVALUE;
4564 #undef GIMPLE_DEBUG_BIND_NOVALUE
4566 /* Return true if S is a GIMPLE_DEBUG SOURCE BIND statement. */
4569 gimple_debug_source_bind_p (const gimple *s)
4571 if (is_gimple_debug (s))
4572 return s->subcode == GIMPLE_DEBUG_SOURCE_BIND;
4577 /* Return the variable bound in a GIMPLE_DEBUG source bind statement. */
4580 gimple_debug_source_bind_get_var (gimple *dbg)
4582 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
4583 gcc_gimple_checking_assert (gimple_debug_source_bind_p (dbg));
4584 return gimple_op (dbg, 0);
4587 /* Return the value bound to the variable in a GIMPLE_DEBUG source bind
4591 gimple_debug_source_bind_get_value (gimple *dbg)
4593 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
4594 gcc_gimple_checking_assert (gimple_debug_source_bind_p (dbg));
4595 return gimple_op (dbg, 1);
4598 /* Return a pointer to the value bound to the variable in a
4599 GIMPLE_DEBUG source bind statement. */
4601 static inline tree *
4602 gimple_debug_source_bind_get_value_ptr (gimple *dbg)
4604 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
4605 gcc_gimple_checking_assert (gimple_debug_source_bind_p (dbg));
4606 return gimple_op_ptr (dbg, 1);
4609 /* Set the variable bound in a GIMPLE_DEBUG source bind statement. */
4612 gimple_debug_source_bind_set_var (gimple *dbg, tree var)
4614 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
4615 gcc_gimple_checking_assert (gimple_debug_source_bind_p (dbg));
4616 gimple_set_op (dbg, 0, var);
4619 /* Set the value bound to the variable in a GIMPLE_DEBUG source bind
4623 gimple_debug_source_bind_set_value (gimple *dbg, tree value)
4625 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
4626 gcc_gimple_checking_assert (gimple_debug_source_bind_p (dbg));
4627 gimple_set_op (dbg, 1, value);
4630 /* Return the line number for EXPR, or return -1 if we have no line
4631 number information for it. */
4633 get_lineno (const gimple *stmt)
4640 loc = gimple_location (stmt);
4641 if (loc == UNKNOWN_LOCATION)
4644 return LOCATION_LINE (loc);
4647 /* Return a pointer to the body for the OMP statement GS. */
4649 static inline gimple_seq *
4650 gimple_omp_body_ptr (gimple *gs)
4652 return &static_cast <gimple_statement_omp *> (gs)->body;
4655 /* Return the body for the OMP statement GS. */
4657 static inline gimple_seq
4658 gimple_omp_body (gimple *gs)
4660 return *gimple_omp_body_ptr (gs);
4663 /* Set BODY to be the body for the OMP statement GS. */
4666 gimple_omp_set_body (gimple *gs, gimple_seq body)
4668 static_cast <gimple_statement_omp *> (gs)->body = body;
4672 /* Return the name associated with OMP_CRITICAL statement CRIT_STMT. */
4675 gimple_omp_critical_name (const gomp_critical *crit_stmt)
4677 return crit_stmt->name;
4681 /* Return a pointer to the name associated with OMP critical statement GS. */
4683 static inline tree *
4684 gimple_omp_critical_name_ptr (gomp_critical *crit_stmt)
4686 return &crit_stmt->name;
4690 /* Set NAME to be the name associated with OMP critical statement GS. */
4693 gimple_omp_critical_set_name (gomp_critical *crit_stmt, tree name)
4695 crit_stmt->name = name;
4699 /* Return the kind of the OMP_FOR statemement G. */
4702 gimple_omp_for_kind (const gimple *g)
4704 GIMPLE_CHECK (g, GIMPLE_OMP_FOR);
4705 return (gimple_omp_subcode (g) & GF_OMP_FOR_KIND_MASK);
4709 /* Set the kind of the OMP_FOR statement G. */
4712 gimple_omp_for_set_kind (gomp_for *g, int kind)
4714 g->subcode = (g->subcode & ~GF_OMP_FOR_KIND_MASK)
4715 | (kind & GF_OMP_FOR_KIND_MASK);
4719 /* Return true if OMP_FOR statement G has the
4720 GF_OMP_FOR_COMBINED flag set. */
4723 gimple_omp_for_combined_p (const gimple *g)
4725 GIMPLE_CHECK (g, GIMPLE_OMP_FOR);
4726 return (gimple_omp_subcode (g) & GF_OMP_FOR_COMBINED) != 0;
4730 /* Set the GF_OMP_FOR_COMBINED field in the OMP_FOR statement G depending on
4731 the boolean value of COMBINED_P. */
4734 gimple_omp_for_set_combined_p (gomp_for *g, bool combined_p)
4737 g->subcode |= GF_OMP_FOR_COMBINED;
4739 g->subcode &= ~GF_OMP_FOR_COMBINED;
4743 /* Return true if the OMP_FOR statement G has the
4744 GF_OMP_FOR_COMBINED_INTO flag set. */
4747 gimple_omp_for_combined_into_p (const gimple *g)
4749 GIMPLE_CHECK (g, GIMPLE_OMP_FOR);
4750 return (gimple_omp_subcode (g) & GF_OMP_FOR_COMBINED_INTO) != 0;
4754 /* Set the GF_OMP_FOR_COMBINED_INTO field in the OMP_FOR statement G depending
4755 on the boolean value of COMBINED_P. */
4758 gimple_omp_for_set_combined_into_p (gomp_for *g, bool combined_p)
4761 g->subcode |= GF_OMP_FOR_COMBINED_INTO;
4763 g->subcode &= ~GF_OMP_FOR_COMBINED_INTO;
4767 /* Return the clauses associated with the OMP_FOR statement GS. */
4770 gimple_omp_for_clauses (const gimple *gs)
4772 const gomp_for *omp_for_stmt = as_a <const gomp_for *> (gs);
4773 return omp_for_stmt->clauses;
4777 /* Return a pointer to the clauses associated with the OMP_FOR statement
4780 static inline tree *
4781 gimple_omp_for_clauses_ptr (gimple *gs)
4783 gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
4784 return &omp_for_stmt->clauses;
4788 /* Set CLAUSES to be the list of clauses associated with the OMP_FOR statement
4792 gimple_omp_for_set_clauses (gimple *gs, tree clauses)
4794 gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
4795 omp_for_stmt->clauses = clauses;
4799 /* Get the collapse count of the OMP_FOR statement GS. */
4801 static inline size_t
4802 gimple_omp_for_collapse (gimple *gs)
4804 gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
4805 return omp_for_stmt->collapse;
4809 /* Return the condition code associated with the OMP_FOR statement GS. */
4811 static inline enum tree_code
4812 gimple_omp_for_cond (const gimple *gs, size_t i)
4814 const gomp_for *omp_for_stmt = as_a <const gomp_for *> (gs);
4815 gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
4816 return omp_for_stmt->iter[i].cond;
4820 /* Set COND to be the condition code for the OMP_FOR statement GS. */
4823 gimple_omp_for_set_cond (gimple *gs, size_t i, enum tree_code cond)
4825 gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
4826 gcc_gimple_checking_assert (TREE_CODE_CLASS (cond) == tcc_comparison
4827 && i < omp_for_stmt->collapse);
4828 omp_for_stmt->iter[i].cond = cond;
4832 /* Return the index variable for the OMP_FOR statement GS. */
4835 gimple_omp_for_index (const gimple *gs, size_t i)
4837 const gomp_for *omp_for_stmt = as_a <const gomp_for *> (gs);
4838 gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
4839 return omp_for_stmt->iter[i].index;
4843 /* Return a pointer to the index variable for the OMP_FOR statement GS. */
4845 static inline tree *
4846 gimple_omp_for_index_ptr (gimple *gs, size_t i)
4848 gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
4849 gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
4850 return &omp_for_stmt->iter[i].index;
4854 /* Set INDEX to be the index variable for the OMP_FOR statement GS. */
4857 gimple_omp_for_set_index (gimple *gs, size_t i, tree index)
4859 gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
4860 gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
4861 omp_for_stmt->iter[i].index = index;
4865 /* Return the initial value for the OMP_FOR statement GS. */
4868 gimple_omp_for_initial (const gimple *gs, size_t i)
4870 const gomp_for *omp_for_stmt = as_a <const gomp_for *> (gs);
4871 gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
4872 return omp_for_stmt->iter[i].initial;
4876 /* Return a pointer to the initial value for the OMP_FOR statement GS. */
4878 static inline tree *
4879 gimple_omp_for_initial_ptr (gimple *gs, size_t i)
4881 gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
4882 gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
4883 return &omp_for_stmt->iter[i].initial;
4887 /* Set INITIAL to be the initial value for the OMP_FOR statement GS. */
4890 gimple_omp_for_set_initial (gimple *gs, size_t i, tree initial)
4892 gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
4893 gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
4894 omp_for_stmt->iter[i].initial = initial;
4898 /* Return the final value for the OMP_FOR statement GS. */
4901 gimple_omp_for_final (const gimple *gs, size_t i)
4903 const gomp_for *omp_for_stmt = as_a <const gomp_for *> (gs);
4904 gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
4905 return omp_for_stmt->iter[i].final;
4909 /* Return a pointer to the final value for the OMP_FOR statement GS. */
4911 static inline tree *
4912 gimple_omp_for_final_ptr (gimple *gs, size_t i)
4914 gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
4915 gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
4916 return &omp_for_stmt->iter[i].final;
4920 /* Set FINAL to be the final value for the OMP_FOR statement GS. */
4923 gimple_omp_for_set_final (gimple *gs, size_t i, tree final)
4925 gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
4926 gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
4927 omp_for_stmt->iter[i].final = final;
4931 /* Return the increment value for the OMP_FOR statement GS. */
4934 gimple_omp_for_incr (const gimple *gs, size_t i)
4936 const gomp_for *omp_for_stmt = as_a <const gomp_for *> (gs);
4937 gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
4938 return omp_for_stmt->iter[i].incr;
4942 /* Return a pointer to the increment value for the OMP_FOR statement GS. */
4944 static inline tree *
4945 gimple_omp_for_incr_ptr (gimple *gs, size_t i)
4947 gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
4948 gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
4949 return &omp_for_stmt->iter[i].incr;
4953 /* Set INCR to be the increment value for the OMP_FOR statement GS. */
4956 gimple_omp_for_set_incr (gimple *gs, size_t i, tree incr)
4958 gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
4959 gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
4960 omp_for_stmt->iter[i].incr = incr;
4964 /* Return a pointer to the sequence of statements to execute before the OMP_FOR
4965 statement GS starts. */
4967 static inline gimple_seq *
4968 gimple_omp_for_pre_body_ptr (gimple *gs)
4970 gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
4971 return &omp_for_stmt->pre_body;
4975 /* Return the sequence of statements to execute before the OMP_FOR
4976 statement GS starts. */
4978 static inline gimple_seq
4979 gimple_omp_for_pre_body (gimple *gs)
4981 return *gimple_omp_for_pre_body_ptr (gs);
4985 /* Set PRE_BODY to be the sequence of statements to execute before the
4986 OMP_FOR statement GS starts. */
4989 gimple_omp_for_set_pre_body (gimple *gs, gimple_seq pre_body)
4991 gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
4992 omp_for_stmt->pre_body = pre_body;
4996 /* Return the clauses associated with OMP_PARALLEL GS. */
4999 gimple_omp_parallel_clauses (const gimple *gs)
5001 const gomp_parallel *omp_parallel_stmt = as_a <const gomp_parallel *> (gs);
5002 return omp_parallel_stmt->clauses;
5006 /* Return a pointer to the clauses associated with OMP_PARALLEL_STMT. */
5008 static inline tree *
5009 gimple_omp_parallel_clauses_ptr (gomp_parallel *omp_parallel_stmt)
5011 return &omp_parallel_stmt->clauses;
5015 /* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL_STMT. */
5018 gimple_omp_parallel_set_clauses (gomp_parallel *omp_parallel_stmt,
5021 omp_parallel_stmt->clauses = clauses;
5025 /* Return the child function used to hold the body of OMP_PARALLEL_STMT. */
5028 gimple_omp_parallel_child_fn (const gomp_parallel *omp_parallel_stmt)
5030 return omp_parallel_stmt->child_fn;
5033 /* Return a pointer to the child function used to hold the body of
5034 OMP_PARALLEL_STMT. */
5036 static inline tree *
5037 gimple_omp_parallel_child_fn_ptr (gomp_parallel *omp_parallel_stmt)
5039 return &omp_parallel_stmt->child_fn;
5043 /* Set CHILD_FN to be the child function for OMP_PARALLEL_STMT. */
5046 gimple_omp_parallel_set_child_fn (gomp_parallel *omp_parallel_stmt,
5049 omp_parallel_stmt->child_fn = child_fn;
5053 /* Return the artificial argument used to send variables and values
5054 from the parent to the children threads in OMP_PARALLEL_STMT. */
5057 gimple_omp_parallel_data_arg (const gomp_parallel *omp_parallel_stmt)
5059 return omp_parallel_stmt->data_arg;
5063 /* Return a pointer to the data argument for OMP_PARALLEL_STMT. */
5065 static inline tree *
5066 gimple_omp_parallel_data_arg_ptr (gomp_parallel *omp_parallel_stmt)
5068 return &omp_parallel_stmt->data_arg;
5072 /* Set DATA_ARG to be the data argument for OMP_PARALLEL_STMT. */
5075 gimple_omp_parallel_set_data_arg (gomp_parallel *omp_parallel_stmt,
5078 omp_parallel_stmt->data_arg = data_arg;
5082 /* Return the clauses associated with OMP_TASK GS. */
5085 gimple_omp_task_clauses (const gimple *gs)
5087 const gomp_task *omp_task_stmt = as_a <const gomp_task *> (gs);
5088 return omp_task_stmt->clauses;
5092 /* Return a pointer to the clauses associated with OMP_TASK GS. */
5094 static inline tree *
5095 gimple_omp_task_clauses_ptr (gimple *gs)
5097 gomp_task *omp_task_stmt = as_a <gomp_task *> (gs);
5098 return &omp_task_stmt->clauses;
5102 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
5106 gimple_omp_task_set_clauses (gimple *gs, tree clauses)
5108 gomp_task *omp_task_stmt = as_a <gomp_task *> (gs);
5109 omp_task_stmt->clauses = clauses;
5113 /* Return the child function used to hold the body of OMP_TASK GS. */
5116 gimple_omp_task_child_fn (const gimple *gs)
5118 const gomp_task *omp_task_stmt = as_a <const gomp_task *> (gs);
5119 return omp_task_stmt->child_fn;
5122 /* Return a pointer to the child function used to hold the body of
5125 static inline tree *
5126 gimple_omp_task_child_fn_ptr (gimple *gs)
5128 gomp_task *omp_task_stmt = as_a <gomp_task *> (gs);
5129 return &omp_task_stmt->child_fn;
5133 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
5136 gimple_omp_task_set_child_fn (gimple *gs, tree child_fn)
5138 gomp_task *omp_task_stmt = as_a <gomp_task *> (gs);
5139 omp_task_stmt->child_fn = child_fn;
5143 /* Return the artificial argument used to send variables and values
5144 from the parent to the children threads in OMP_TASK GS. */
5147 gimple_omp_task_data_arg (const gimple *gs)
5149 const gomp_task *omp_task_stmt = as_a <const gomp_task *> (gs);
5150 return omp_task_stmt->data_arg;
5154 /* Return a pointer to the data argument for OMP_TASK GS. */
5156 static inline tree *
5157 gimple_omp_task_data_arg_ptr (gimple *gs)
5159 gomp_task *omp_task_stmt = as_a <gomp_task *> (gs);
5160 return &omp_task_stmt->data_arg;
5164 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
5167 gimple_omp_task_set_data_arg (gimple *gs, tree data_arg)
5169 gomp_task *omp_task_stmt = as_a <gomp_task *> (gs);
5170 omp_task_stmt->data_arg = data_arg;
5174 /* Return the clauses associated with OMP_TASK GS. */
5177 gimple_omp_taskreg_clauses (const gimple *gs)
5179 const gimple_statement_omp_taskreg *omp_taskreg_stmt
5180 = as_a <const gimple_statement_omp_taskreg *> (gs);
5181 return omp_taskreg_stmt->clauses;
5185 /* Return a pointer to the clauses associated with OMP_TASK GS. */
5187 static inline tree *
5188 gimple_omp_taskreg_clauses_ptr (gimple *gs)
5190 gimple_statement_omp_taskreg *omp_taskreg_stmt
5191 = as_a <gimple_statement_omp_taskreg *> (gs);
5192 return &omp_taskreg_stmt->clauses;
5196 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
5200 gimple_omp_taskreg_set_clauses (gimple *gs, tree clauses)
5202 gimple_statement_omp_taskreg *omp_taskreg_stmt
5203 = as_a <gimple_statement_omp_taskreg *> (gs);
5204 omp_taskreg_stmt->clauses = clauses;
5208 /* Return the child function used to hold the body of OMP_TASK GS. */
5211 gimple_omp_taskreg_child_fn (const gimple *gs)
5213 const gimple_statement_omp_taskreg *omp_taskreg_stmt
5214 = as_a <const gimple_statement_omp_taskreg *> (gs);
5215 return omp_taskreg_stmt->child_fn;
5218 /* Return a pointer to the child function used to hold the body of
5221 static inline tree *
5222 gimple_omp_taskreg_child_fn_ptr (gimple *gs)
5224 gimple_statement_omp_taskreg *omp_taskreg_stmt
5225 = as_a <gimple_statement_omp_taskreg *> (gs);
5226 return &omp_taskreg_stmt->child_fn;
5230 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
5233 gimple_omp_taskreg_set_child_fn (gimple *gs, tree child_fn)
5235 gimple_statement_omp_taskreg *omp_taskreg_stmt
5236 = as_a <gimple_statement_omp_taskreg *> (gs);
5237 omp_taskreg_stmt->child_fn = child_fn;
5241 /* Return the artificial argument used to send variables and values
5242 from the parent to the children threads in OMP_TASK GS. */
5245 gimple_omp_taskreg_data_arg (const gimple *gs)
5247 const gimple_statement_omp_taskreg *omp_taskreg_stmt
5248 = as_a <const gimple_statement_omp_taskreg *> (gs);
5249 return omp_taskreg_stmt->data_arg;
5253 /* Return a pointer to the data argument for OMP_TASK GS. */
5255 static inline tree *
5256 gimple_omp_taskreg_data_arg_ptr (gimple *gs)
5258 gimple_statement_omp_taskreg *omp_taskreg_stmt
5259 = as_a <gimple_statement_omp_taskreg *> (gs);
5260 return &omp_taskreg_stmt->data_arg;
5264 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
5267 gimple_omp_taskreg_set_data_arg (gimple *gs, tree data_arg)
5269 gimple_statement_omp_taskreg *omp_taskreg_stmt
5270 = as_a <gimple_statement_omp_taskreg *> (gs);
5271 omp_taskreg_stmt->data_arg = data_arg;
5275 /* Return the copy function used to hold the body of OMP_TASK GS. */
5278 gimple_omp_task_copy_fn (const gimple *gs)
5280 const gomp_task *omp_task_stmt = as_a <const gomp_task *> (gs);
5281 return omp_task_stmt->copy_fn;
5284 /* Return a pointer to the copy function used to hold the body of
5287 static inline tree *
5288 gimple_omp_task_copy_fn_ptr (gimple *gs)
5290 gomp_task *omp_task_stmt = as_a <gomp_task *> (gs);
5291 return &omp_task_stmt->copy_fn;
5295 /* Set CHILD_FN to be the copy function for OMP_TASK GS. */
5298 gimple_omp_task_set_copy_fn (gimple *gs, tree copy_fn)
5300 gomp_task *omp_task_stmt = as_a <gomp_task *> (gs);
5301 omp_task_stmt->copy_fn = copy_fn;
5305 /* Return size of the data block in bytes in OMP_TASK GS. */
5308 gimple_omp_task_arg_size (const gimple *gs)
5310 const gomp_task *omp_task_stmt = as_a <const gomp_task *> (gs);
5311 return omp_task_stmt->arg_size;
5315 /* Return a pointer to the data block size for OMP_TASK GS. */
5317 static inline tree *
5318 gimple_omp_task_arg_size_ptr (gimple *gs)
5320 gomp_task *omp_task_stmt = as_a <gomp_task *> (gs);
5321 return &omp_task_stmt->arg_size;
5325 /* Set ARG_SIZE to be the data block size for OMP_TASK GS. */
5328 gimple_omp_task_set_arg_size (gimple *gs, tree arg_size)
5330 gomp_task *omp_task_stmt = as_a <gomp_task *> (gs);
5331 omp_task_stmt->arg_size = arg_size;
5335 /* Return align of the data block in bytes in OMP_TASK GS. */
5338 gimple_omp_task_arg_align (const gimple *gs)
5340 const gomp_task *omp_task_stmt = as_a <const gomp_task *> (gs);
5341 return omp_task_stmt->arg_align;
5345 /* Return a pointer to the data block align for OMP_TASK GS. */
5347 static inline tree *
5348 gimple_omp_task_arg_align_ptr (gimple *gs)
5350 gomp_task *omp_task_stmt = as_a <gomp_task *> (gs);
5351 return &omp_task_stmt->arg_align;
5355 /* Set ARG_SIZE to be the data block align for OMP_TASK GS. */
5358 gimple_omp_task_set_arg_align (gimple *gs, tree arg_align)
5360 gomp_task *omp_task_stmt = as_a <gomp_task *> (gs);
5361 omp_task_stmt->arg_align = arg_align;
5365 /* Return the clauses associated with OMP_SINGLE GS. */
5368 gimple_omp_single_clauses (const gimple *gs)
5370 const gomp_single *omp_single_stmt = as_a <const gomp_single *> (gs);
5371 return omp_single_stmt->clauses;
5375 /* Return a pointer to the clauses associated with OMP_SINGLE GS. */
5377 static inline tree *
5378 gimple_omp_single_clauses_ptr (gimple *gs)
5380 gomp_single *omp_single_stmt = as_a <gomp_single *> (gs);
5381 return &omp_single_stmt->clauses;
5385 /* Set CLAUSES to be the clauses associated with OMP_SINGLE_STMT. */
5388 gimple_omp_single_set_clauses (gomp_single *omp_single_stmt, tree clauses)
5390 omp_single_stmt->clauses = clauses;
5394 /* Return the clauses associated with OMP_TARGET GS. */
5397 gimple_omp_target_clauses (const gimple *gs)
5399 const gomp_target *omp_target_stmt = as_a <const gomp_target *> (gs);
5400 return omp_target_stmt->clauses;
5404 /* Return a pointer to the clauses associated with OMP_TARGET GS. */
5406 static inline tree *
5407 gimple_omp_target_clauses_ptr (gimple *gs)
5409 gomp_target *omp_target_stmt = as_a <gomp_target *> (gs);
5410 return &omp_target_stmt->clauses;
5414 /* Set CLAUSES to be the clauses associated with OMP_TARGET_STMT. */
5417 gimple_omp_target_set_clauses (gomp_target *omp_target_stmt,
5420 omp_target_stmt->clauses = clauses;
5424 /* Return the kind of the OMP_TARGET G. */
5427 gimple_omp_target_kind (const gimple *g)
5429 GIMPLE_CHECK (g, GIMPLE_OMP_TARGET);
5430 return (gimple_omp_subcode (g) & GF_OMP_TARGET_KIND_MASK);
5434 /* Set the kind of the OMP_TARGET G. */
5437 gimple_omp_target_set_kind (gomp_target *g, int kind)
5439 g->subcode = (g->subcode & ~GF_OMP_TARGET_KIND_MASK)
5440 | (kind & GF_OMP_TARGET_KIND_MASK);
5444 /* Return the child function used to hold the body of OMP_TARGET_STMT. */
5447 gimple_omp_target_child_fn (const gomp_target *omp_target_stmt)
5449 return omp_target_stmt->child_fn;
5452 /* Return a pointer to the child function used to hold the body of
5455 static inline tree *
5456 gimple_omp_target_child_fn_ptr (gomp_target *omp_target_stmt)
5458 return &omp_target_stmt->child_fn;
5462 /* Set CHILD_FN to be the child function for OMP_TARGET_STMT. */
5465 gimple_omp_target_set_child_fn (gomp_target *omp_target_stmt,
5468 omp_target_stmt->child_fn = child_fn;
5472 /* Return the artificial argument used to send variables and values
5473 from the parent to the children threads in OMP_TARGET_STMT. */
5476 gimple_omp_target_data_arg (const gomp_target *omp_target_stmt)
5478 return omp_target_stmt->data_arg;
5482 /* Return a pointer to the data argument for OMP_TARGET GS. */
5484 static inline tree *
5485 gimple_omp_target_data_arg_ptr (gomp_target *omp_target_stmt)
5487 return &omp_target_stmt->data_arg;
5491 /* Set DATA_ARG to be the data argument for OMP_TARGET_STMT. */
5494 gimple_omp_target_set_data_arg (gomp_target *omp_target_stmt,
5497 omp_target_stmt->data_arg = data_arg;
5501 /* Return the clauses associated with OMP_TEAMS GS. */
5504 gimple_omp_teams_clauses (const gimple *gs)
5506 const gomp_teams *omp_teams_stmt = as_a <const gomp_teams *> (gs);
5507 return omp_teams_stmt->clauses;
5511 /* Return a pointer to the clauses associated with OMP_TEAMS GS. */
5513 static inline tree *
5514 gimple_omp_teams_clauses_ptr (gimple *gs)
5516 gomp_teams *omp_teams_stmt = as_a <gomp_teams *> (gs);
5517 return &omp_teams_stmt->clauses;
5521 /* Set CLAUSES to be the clauses associated with OMP_TEAMS_STMT. */
5524 gimple_omp_teams_set_clauses (gomp_teams *omp_teams_stmt, tree clauses)
5526 omp_teams_stmt->clauses = clauses;
5530 /* Return the clauses associated with OMP_SECTIONS GS. */
5533 gimple_omp_sections_clauses (const gimple *gs)
5535 const gomp_sections *omp_sections_stmt = as_a <const gomp_sections *> (gs);
5536 return omp_sections_stmt->clauses;
5540 /* Return a pointer to the clauses associated with OMP_SECTIONS GS. */
5542 static inline tree *
5543 gimple_omp_sections_clauses_ptr (gimple *gs)
5545 gomp_sections *omp_sections_stmt = as_a <gomp_sections *> (gs);
5546 return &omp_sections_stmt->clauses;
5550 /* Set CLAUSES to be the set of clauses associated with OMP_SECTIONS
5554 gimple_omp_sections_set_clauses (gimple *gs, tree clauses)
5556 gomp_sections *omp_sections_stmt = as_a <gomp_sections *> (gs);
5557 omp_sections_stmt->clauses = clauses;
5561 /* Return the control variable associated with the GIMPLE_OMP_SECTIONS
5565 gimple_omp_sections_control (const gimple *gs)
5567 const gomp_sections *omp_sections_stmt = as_a <const gomp_sections *> (gs);
5568 return omp_sections_stmt->control;
5572 /* Return a pointer to the clauses associated with the GIMPLE_OMP_SECTIONS
5575 static inline tree *
5576 gimple_omp_sections_control_ptr (gimple *gs)
5578 gomp_sections *omp_sections_stmt = as_a <gomp_sections *> (gs);
5579 return &omp_sections_stmt->control;
5583 /* Set CONTROL to be the set of clauses associated with the
5584 GIMPLE_OMP_SECTIONS in GS. */
5587 gimple_omp_sections_set_control (gimple *gs, tree control)
5589 gomp_sections *omp_sections_stmt = as_a <gomp_sections *> (gs);
5590 omp_sections_stmt->control = control;
5594 /* Set the value being stored in an atomic store. */
5597 gimple_omp_atomic_store_set_val (gomp_atomic_store *store_stmt, tree val)
5599 store_stmt->val = val;
5603 /* Return the value being stored in an atomic store. */
5606 gimple_omp_atomic_store_val (const gomp_atomic_store *store_stmt)
5608 return store_stmt->val;
5612 /* Return a pointer to the value being stored in an atomic store. */
5614 static inline tree *
5615 gimple_omp_atomic_store_val_ptr (gomp_atomic_store *store_stmt)
5617 return &store_stmt->val;
5621 /* Set the LHS of an atomic load. */
5624 gimple_omp_atomic_load_set_lhs (gomp_atomic_load *load_stmt, tree lhs)
5626 load_stmt->lhs = lhs;
5630 /* Get the LHS of an atomic load. */
5633 gimple_omp_atomic_load_lhs (const gomp_atomic_load *load_stmt)
5635 return load_stmt->lhs;
5639 /* Return a pointer to the LHS of an atomic load. */
5641 static inline tree *
5642 gimple_omp_atomic_load_lhs_ptr (gomp_atomic_load *load_stmt)
5644 return &load_stmt->lhs;
5648 /* Set the RHS of an atomic load. */
5651 gimple_omp_atomic_load_set_rhs (gomp_atomic_load *load_stmt, tree rhs)
5653 load_stmt->rhs = rhs;
5657 /* Get the RHS of an atomic load. */
5660 gimple_omp_atomic_load_rhs (const gomp_atomic_load *load_stmt)
5662 return load_stmt->rhs;
5666 /* Return a pointer to the RHS of an atomic load. */
5668 static inline tree *
5669 gimple_omp_atomic_load_rhs_ptr (gomp_atomic_load *load_stmt)
5671 return &load_stmt->rhs;
5675 /* Get the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
5678 gimple_omp_continue_control_def (const gomp_continue *cont_stmt)
5680 return cont_stmt->control_def;
5683 /* The same as above, but return the address. */
5685 static inline tree *
5686 gimple_omp_continue_control_def_ptr (gomp_continue *cont_stmt)
5688 return &cont_stmt->control_def;
5691 /* Set the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
5694 gimple_omp_continue_set_control_def (gomp_continue *cont_stmt, tree def)
5696 cont_stmt->control_def = def;
5700 /* Get the use of the control variable in a GIMPLE_OMP_CONTINUE. */
5703 gimple_omp_continue_control_use (const gomp_continue *cont_stmt)
5705 return cont_stmt->control_use;
5709 /* The same as above, but return the address. */
5711 static inline tree *
5712 gimple_omp_continue_control_use_ptr (gomp_continue *cont_stmt)
5714 return &cont_stmt->control_use;
5718 /* Set the use of the control variable in a GIMPLE_OMP_CONTINUE. */
5721 gimple_omp_continue_set_control_use (gomp_continue *cont_stmt, tree use)
5723 cont_stmt->control_use = use;
5726 /* Return a pointer to the body for the GIMPLE_TRANSACTION statement
5727 TRANSACTION_STMT. */
5729 static inline gimple_seq *
5730 gimple_transaction_body_ptr (gtransaction *transaction_stmt)
5732 return &transaction_stmt->body;
5735 /* Return the body for the GIMPLE_TRANSACTION statement TRANSACTION_STMT. */
5737 static inline gimple_seq
5738 gimple_transaction_body (gtransaction *transaction_stmt)
5740 return *gimple_transaction_body_ptr (transaction_stmt);
5743 /* Return the label associated with a GIMPLE_TRANSACTION. */
5746 gimple_transaction_label (const gtransaction *transaction_stmt)
5748 return transaction_stmt->label;
5751 static inline tree *
5752 gimple_transaction_label_ptr (gtransaction *transaction_stmt)
5754 return &transaction_stmt->label;
5757 /* Return the subcode associated with a GIMPLE_TRANSACTION. */
5759 static inline unsigned int
5760 gimple_transaction_subcode (const gtransaction *transaction_stmt)
5762 return transaction_stmt->subcode;
5765 /* Set BODY to be the body for the GIMPLE_TRANSACTION statement
5766 TRANSACTION_STMT. */
5769 gimple_transaction_set_body (gtransaction *transaction_stmt,
5772 transaction_stmt->body = body;
5775 /* Set the label associated with a GIMPLE_TRANSACTION. */
5778 gimple_transaction_set_label (gtransaction *transaction_stmt, tree label)
5780 transaction_stmt->label = label;
5783 /* Set the subcode associated with a GIMPLE_TRANSACTION. */
5786 gimple_transaction_set_subcode (gtransaction *transaction_stmt,
5787 unsigned int subcode)
5789 transaction_stmt->subcode = subcode;
5793 /* Return a pointer to the return value for GIMPLE_RETURN GS. */
5795 static inline tree *
5796 gimple_return_retval_ptr (const greturn *gs)
5798 return const_cast<tree *> (&gs->op[0]);
5801 /* Return the return value for GIMPLE_RETURN GS. */
5804 gimple_return_retval (const greturn *gs)
5810 /* Set RETVAL to be the return value for GIMPLE_RETURN GS. */
5813 gimple_return_set_retval (greturn *gs, tree retval)
5819 /* Return the return bounds for GIMPLE_RETURN GS. */
5822 gimple_return_retbnd (const gimple *gs)
5824 GIMPLE_CHECK (gs, GIMPLE_RETURN);
5825 return gimple_op (gs, 1);
5829 /* Set RETVAL to be the return bounds for GIMPLE_RETURN GS. */
5832 gimple_return_set_retbnd (gimple *gs, tree retval)
5834 GIMPLE_CHECK (gs, GIMPLE_RETURN);
5835 gimple_set_op (gs, 1, retval);
5839 /* Returns true when the gimple statement STMT is any of the OMP types. */
5841 #define CASE_GIMPLE_OMP \
5842 case GIMPLE_OMP_PARALLEL: \
5843 case GIMPLE_OMP_TASK: \
5844 case GIMPLE_OMP_FOR: \
5845 case GIMPLE_OMP_SECTIONS: \
5846 case GIMPLE_OMP_SECTIONS_SWITCH: \
5847 case GIMPLE_OMP_SINGLE: \
5848 case GIMPLE_OMP_TARGET: \
5849 case GIMPLE_OMP_TEAMS: \
5850 case GIMPLE_OMP_SECTION: \
5851 case GIMPLE_OMP_MASTER: \
5852 case GIMPLE_OMP_TASKGROUP: \
5853 case GIMPLE_OMP_ORDERED: \
5854 case GIMPLE_OMP_CRITICAL: \
5855 case GIMPLE_OMP_RETURN: \
5856 case GIMPLE_OMP_ATOMIC_LOAD: \
5857 case GIMPLE_OMP_ATOMIC_STORE: \
5858 case GIMPLE_OMP_CONTINUE
5861 is_gimple_omp (const gimple *stmt)
5863 switch (gimple_code (stmt))
5872 /* Return true if the OMP gimple statement STMT is any of the OpenACC types
5876 is_gimple_omp_oacc (const gimple *stmt)
5878 gcc_assert (is_gimple_omp (stmt));
5879 switch (gimple_code (stmt))
5881 case GIMPLE_OMP_FOR:
5882 switch (gimple_omp_for_kind (stmt))
5884 case GF_OMP_FOR_KIND_OACC_LOOP:
5889 case GIMPLE_OMP_TARGET:
5890 switch (gimple_omp_target_kind (stmt))
5892 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
5893 case GF_OMP_TARGET_KIND_OACC_KERNELS:
5894 case GF_OMP_TARGET_KIND_OACC_DATA:
5895 case GF_OMP_TARGET_KIND_OACC_UPDATE:
5896 case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
5907 /* Return true if the OMP gimple statement STMT is offloaded. */
5910 is_gimple_omp_offloaded (const gimple *stmt)
5912 gcc_assert (is_gimple_omp (stmt));
5913 switch (gimple_code (stmt))
5915 case GIMPLE_OMP_TARGET:
5916 switch (gimple_omp_target_kind (stmt))
5918 case GF_OMP_TARGET_KIND_REGION:
5919 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
5920 case GF_OMP_TARGET_KIND_OACC_KERNELS:
5931 /* Returns TRUE if statement G is a GIMPLE_NOP. */
5934 gimple_nop_p (const gimple *g)
5936 return gimple_code (g) == GIMPLE_NOP;
5940 /* Return true if GS is a GIMPLE_RESX. */
5943 is_gimple_resx (const gimple *gs)
5945 return gimple_code (gs) == GIMPLE_RESX;
5948 /* Return the type of the main expression computed by STMT. Return
5949 void_type_node if the statement computes nothing. */
5952 gimple_expr_type (const gimple *stmt)
5954 enum gimple_code code = gimple_code (stmt);
5955 /* In general we want to pass out a type that can be substituted
5956 for both the RHS and the LHS types if there is a possibly
5957 useless conversion involved. That means returning the
5958 original RHS type as far as we can reconstruct it. */
5959 if (code == GIMPLE_CALL)
5961 const gcall *call_stmt = as_a <const gcall *> (stmt);
5962 if (gimple_call_internal_p (call_stmt)
5963 && gimple_call_internal_fn (call_stmt) == IFN_MASK_STORE)
5964 return TREE_TYPE (gimple_call_arg (call_stmt, 3));
5966 return gimple_call_return_type (call_stmt);
5968 else if (code == GIMPLE_ASSIGN)
5970 if (gimple_assign_rhs_code (stmt) == POINTER_PLUS_EXPR)
5971 return TREE_TYPE (gimple_assign_rhs1 (stmt));
5973 /* As fallback use the type of the LHS. */
5974 return TREE_TYPE (gimple_get_lhs (stmt));
5976 else if (code == GIMPLE_COND)
5977 return boolean_type_node;
5979 return void_type_node;
5982 /* Enum and arrays used for allocation stats. Keep in sync with
5983 gimple.c:gimple_alloc_kind_names. */
5984 enum gimple_alloc_kind
5986 gimple_alloc_kind_assign, /* Assignments. */
5987 gimple_alloc_kind_phi, /* PHI nodes. */
5988 gimple_alloc_kind_cond, /* Conditionals. */
5989 gimple_alloc_kind_rest, /* Everything else. */
5990 gimple_alloc_kind_all
5993 extern int gimple_alloc_counts[];
5994 extern int gimple_alloc_sizes[];
5996 /* Return the allocation kind for a given stmt CODE. */
5997 static inline enum gimple_alloc_kind
5998 gimple_alloc_kind (enum gimple_code code)
6003 return gimple_alloc_kind_assign;
6005 return gimple_alloc_kind_phi;
6007 return gimple_alloc_kind_cond;
6009 return gimple_alloc_kind_rest;
6013 /* Return true if a location should not be emitted for this statement
6014 by annotate_all_with_location. */
6017 gimple_do_not_emit_location_p (gimple *g)
6019 return gimple_plf (g, GF_PLF_1);
6022 /* Mark statement G so a location will not be emitted by
6023 annotate_one_with_location. */
6026 gimple_set_do_not_emit_location (gimple *g)
6028 /* The PLF flags are initialized to 0 when a new tuple is created,
6029 so no need to initialize it anywhere. */
6030 gimple_set_plf (g, GF_PLF_1, true);
6034 /* Macros for showing usage statistics. */
6035 #define SCALE(x) ((unsigned long) ((x) < 1024*10 \
6037 : ((x) < 1024*1024*10 \
6039 : (x) / (1024*1024))))
6041 #define LABEL(x) ((x) < 1024*10 ? 'b' : ((x) < 1024*1024*10 ? 'k' : 'M'))
6043 #endif /* GCC_GIMPLE_H */