Released GUPC 4.9.0.1 based on version 203902.
[official-gcc.git] / gcc / gimple.h
blobf5ccdd83a39eef89aa31e38bc4c644258af9db99
1 /* Gimple IR definitions.
3 Copyright (C) 2007-2013 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
11 version.
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
16 for more details.
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/>. */
22 #ifndef GCC_GIMPLE_H
23 #define GCC_GIMPLE_H
25 #include "pointer-set.h"
26 #include "hash-table.h"
27 #include "vec.h"
28 #include "ggc.h"
29 #include "basic-block.h"
30 #include "tree-core.h"
31 #include "tree-ssa-alias.h"
32 #include "internal-fn.h"
33 #include "gimple-fold.h"
34 #include "tree-eh.h"
36 typedef gimple gimple_seq_node;
38 /* For each block, the PHI nodes that need to be rewritten are stored into
39 these vectors. */
40 typedef vec<gimple> gimple_vec;
42 enum gimple_code {
43 #define DEFGSCODE(SYM, STRING, STRUCT) SYM,
44 #include "gimple.def"
45 #undef DEFGSCODE
46 LAST_AND_UNUSED_GIMPLE_CODE
49 extern const char *const gimple_code_name[];
50 extern const unsigned char gimple_rhs_class_table[];
52 /* Error out if a gimple tuple is addressed incorrectly. */
53 #if defined ENABLE_GIMPLE_CHECKING
54 #define gcc_gimple_checking_assert(EXPR) gcc_assert (EXPR)
55 extern void gimple_check_failed (const_gimple, const char *, int, \
56 const char *, enum gimple_code, \
57 enum tree_code) ATTRIBUTE_NORETURN;
59 #define GIMPLE_CHECK(GS, CODE) \
60 do { \
61 const_gimple __gs = (GS); \
62 if (gimple_code (__gs) != (CODE)) \
63 gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__, \
64 (CODE), ERROR_MARK); \
65 } while (0)
66 #else /* not ENABLE_GIMPLE_CHECKING */
67 #define gcc_gimple_checking_assert(EXPR) ((void)(0 && (EXPR)))
68 #define GIMPLE_CHECK(GS, CODE) (void)0
69 #endif
71 /* Class of GIMPLE expressions suitable for the RHS of assignments. See
72 get_gimple_rhs_class. */
73 enum gimple_rhs_class
75 GIMPLE_INVALID_RHS, /* The expression cannot be used on the RHS. */
76 GIMPLE_TERNARY_RHS, /* The expression is a ternary operation. */
77 GIMPLE_BINARY_RHS, /* The expression is a binary operation. */
78 GIMPLE_UNARY_RHS, /* The expression is a unary operation. */
79 GIMPLE_SINGLE_RHS /* The expression is a single object (an SSA
80 name, a _DECL, a _REF, etc. */
83 /* Specific flags for individual GIMPLE statements. These flags are
84 always stored in gimple_statement_base.subcode and they may only be
85 defined for statement codes that do not use subcodes.
87 Values for the masks can overlap as long as the overlapping values
88 are never used in the same statement class.
90 The maximum mask value that can be defined is 1 << 15 (i.e., each
91 statement code can hold up to 16 bitflags).
93 Keep this list sorted. */
94 enum gf_mask {
95 GF_ASM_INPUT = 1 << 0,
96 GF_ASM_VOLATILE = 1 << 1,
97 GF_CALL_FROM_THUNK = 1 << 0,
98 GF_CALL_RETURN_SLOT_OPT = 1 << 1,
99 GF_CALL_TAILCALL = 1 << 2,
100 GF_CALL_VA_ARG_PACK = 1 << 3,
101 GF_CALL_NOTHROW = 1 << 4,
102 GF_CALL_ALLOCA_FOR_VAR = 1 << 5,
103 GF_CALL_INTERNAL = 1 << 6,
104 GF_OMP_PARALLEL_COMBINED = 1 << 0,
105 GF_OMP_FOR_KIND_MASK = 3 << 0,
106 GF_OMP_FOR_KIND_FOR = 0 << 0,
107 GF_OMP_FOR_KIND_SIMD = 1 << 0,
108 GF_OMP_FOR_KIND_DISTRIBUTE = 2 << 0,
109 GF_OMP_FOR_COMBINED = 1 << 2,
110 GF_OMP_FOR_COMBINED_INTO = 1 << 3,
111 GF_OMP_TARGET_KIND_MASK = 3 << 0,
112 GF_OMP_TARGET_KIND_REGION = 0 << 0,
113 GF_OMP_TARGET_KIND_DATA = 1 << 0,
114 GF_OMP_TARGET_KIND_UPDATE = 2 << 0,
116 /* True on an GIMPLE_OMP_RETURN statement if the return does not require
117 a thread synchronization via some sort of barrier. The exact barrier
118 that would otherwise be emitted is dependent on the OMP statement with
119 which this return is associated. */
120 GF_OMP_RETURN_NOWAIT = 1 << 0,
122 GF_OMP_SECTION_LAST = 1 << 0,
123 GF_OMP_ATOMIC_NEED_VALUE = 1 << 0,
124 GF_OMP_ATOMIC_SEQ_CST = 1 << 1,
125 GF_PREDICT_TAKEN = 1 << 15
128 /* Currently, there are only two types of gimple debug stmt. Others are
129 envisioned, for example, to enable the generation of is_stmt notes
130 in line number information, to mark sequence points, etc. This
131 subcode is to be used to tell them apart. */
132 enum gimple_debug_subcode {
133 GIMPLE_DEBUG_BIND = 0,
134 GIMPLE_DEBUG_SOURCE_BIND = 1
137 /* Masks for selecting a pass local flag (PLF) to work on. These
138 masks are used by gimple_set_plf and gimple_plf. */
139 enum plf_mask {
140 GF_PLF_1 = 1 << 0,
141 GF_PLF_2 = 1 << 1
144 /* Iterator object for GIMPLE statement sequences. */
146 struct gimple_stmt_iterator_d
148 /* Sequence node holding the current statement. */
149 gimple_seq_node ptr;
151 /* Sequence and basic block holding the statement. These fields
152 are necessary to handle edge cases such as when statement is
153 added to an empty basic block or when the last statement of a
154 block/sequence is removed. */
155 gimple_seq *seq;
156 basic_block bb;
159 /* Data structure definitions for GIMPLE tuples. NOTE: word markers
160 are for 64 bit hosts. */
162 struct GTY((chain_next ("%h.next"))) gimple_statement_base {
163 /* [ WORD 1 ]
164 Main identifying code for a tuple. */
165 ENUM_BITFIELD(gimple_code) code : 8;
167 /* Nonzero if a warning should not be emitted on this tuple. */
168 unsigned int no_warning : 1;
170 /* Nonzero if this tuple has been visited. Passes are responsible
171 for clearing this bit before using it. */
172 unsigned int visited : 1;
174 /* Nonzero if this tuple represents a non-temporal move. */
175 unsigned int nontemporal_move : 1;
177 /* Pass local flags. These flags are free for any pass to use as
178 they see fit. Passes should not assume that these flags contain
179 any useful value when the pass starts. Any initial state that
180 the pass requires should be set on entry to the pass. See
181 gimple_set_plf and gimple_plf for usage. */
182 unsigned int plf : 2;
184 /* Nonzero if this statement has been modified and needs to have its
185 operands rescanned. */
186 unsigned modified : 1;
188 /* Nonzero if this statement contains volatile operands. */
189 unsigned has_volatile_ops : 1;
191 /* The SUBCODE field can be used for tuple-specific flags for tuples
192 that do not require subcodes. Note that SUBCODE should be at
193 least as wide as tree codes, as several tuples store tree codes
194 in there. */
195 unsigned int subcode : 16;
197 /* UID of this statement. This is used by passes that want to
198 assign IDs to statements. It must be assigned and used by each
199 pass. By default it should be assumed to contain garbage. */
200 unsigned uid;
202 /* [ WORD 2 ]
203 Locus information for debug info. */
204 location_t location;
206 /* Number of operands in this tuple. */
207 unsigned num_ops;
209 /* [ WORD 3 ]
210 Basic block holding this statement. */
211 basic_block bb;
213 /* [ WORD 4-5 ]
214 Linked lists of gimple statements. The next pointers form
215 a NULL terminated list, the prev pointers are a cyclic list.
216 A gimple statement is hence also a double-ended list of
217 statements, with the pointer itself being the first element,
218 and the prev pointer being the last. */
219 gimple next;
220 gimple GTY((skip)) prev;
224 /* Base structure for tuples with operands. */
226 struct GTY(()) gimple_statement_with_ops_base
228 /* [ WORD 1-6 ] */
229 struct gimple_statement_base gsbase;
231 /* [ WORD 7 ]
232 SSA operand vectors. NOTE: It should be possible to
233 amalgamate these vectors with the operand vector OP. However,
234 the SSA operand vectors are organized differently and contain
235 more information (like immediate use chaining). */
236 struct use_optype_d GTY((skip (""))) *use_ops;
240 /* Statements that take register operands. */
242 struct GTY(()) gimple_statement_with_ops
244 /* [ WORD 1-7 ] */
245 struct gimple_statement_with_ops_base opbase;
247 /* [ WORD 8 ]
248 Operand vector. NOTE! This must always be the last field
249 of this structure. In particular, this means that this
250 structure cannot be embedded inside another one. */
251 tree GTY((length ("%h.opbase.gsbase.num_ops"))) op[1];
255 /* Base for statements that take both memory and register operands. */
257 struct GTY(()) gimple_statement_with_memory_ops_base
259 /* [ WORD 1-7 ] */
260 struct gimple_statement_with_ops_base opbase;
262 /* [ WORD 8-9 ]
263 Virtual operands for this statement. The GC will pick them
264 up via the ssa_names array. */
265 tree GTY((skip (""))) vdef;
266 tree GTY((skip (""))) vuse;
270 /* Statements that take both memory and register operands. */
272 struct GTY(()) gimple_statement_with_memory_ops
274 /* [ WORD 1-9 ] */
275 struct gimple_statement_with_memory_ops_base membase;
277 /* [ WORD 10 ]
278 Operand vector. NOTE! This must always be the last field
279 of this structure. In particular, this means that this
280 structure cannot be embedded inside another one. */
281 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
285 /* Call statements that take both memory and register operands. */
287 struct GTY(()) gimple_statement_call
289 /* [ WORD 1-9 ] */
290 struct gimple_statement_with_memory_ops_base membase;
292 /* [ WORD 10-13 ] */
293 struct pt_solution call_used;
294 struct pt_solution call_clobbered;
296 /* [ WORD 14 ] */
297 union GTY ((desc ("%1.membase.opbase.gsbase.subcode & GF_CALL_INTERNAL"))) {
298 tree GTY ((tag ("0"))) fntype;
299 enum internal_fn GTY ((tag ("GF_CALL_INTERNAL"))) internal_fn;
300 } u;
302 /* [ WORD 15 ]
303 Operand vector. NOTE! This must always be the last field
304 of this structure. In particular, this means that this
305 structure cannot be embedded inside another one. */
306 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
310 /* OpenMP statements (#pragma omp). */
312 struct GTY(()) gimple_statement_omp {
313 /* [ WORD 1-6 ] */
314 struct gimple_statement_base gsbase;
316 /* [ WORD 7 ] */
317 gimple_seq body;
321 /* GIMPLE_BIND */
323 struct GTY(()) gimple_statement_bind {
324 /* [ WORD 1-6 ] */
325 struct gimple_statement_base gsbase;
327 /* [ WORD 7 ]
328 Variables declared in this scope. */
329 tree vars;
331 /* [ WORD 8 ]
332 This is different than the BLOCK field in gimple_statement_base,
333 which is analogous to TREE_BLOCK (i.e., the lexical block holding
334 this statement). This field is the equivalent of BIND_EXPR_BLOCK
335 in tree land (i.e., the lexical scope defined by this bind). See
336 gimple-low.c. */
337 tree block;
339 /* [ WORD 9 ] */
340 gimple_seq body;
344 /* GIMPLE_CATCH */
346 struct GTY(()) gimple_statement_catch {
347 /* [ WORD 1-6 ] */
348 struct gimple_statement_base gsbase;
350 /* [ WORD 7 ] */
351 tree types;
353 /* [ WORD 8 ] */
354 gimple_seq handler;
358 /* GIMPLE_EH_FILTER */
360 struct GTY(()) gimple_statement_eh_filter {
361 /* [ WORD 1-6 ] */
362 struct gimple_statement_base gsbase;
364 /* [ WORD 7 ]
365 Filter types. */
366 tree types;
368 /* [ WORD 8 ]
369 Failure actions. */
370 gimple_seq failure;
373 /* GIMPLE_EH_ELSE */
375 struct GTY(()) gimple_statement_eh_else {
376 /* [ WORD 1-6 ] */
377 struct gimple_statement_base gsbase;
379 /* [ WORD 7,8 ] */
380 gimple_seq n_body, e_body;
383 /* GIMPLE_EH_MUST_NOT_THROW */
385 struct GTY(()) gimple_statement_eh_mnt {
386 /* [ WORD 1-6 ] */
387 struct gimple_statement_base gsbase;
389 /* [ WORD 7 ] Abort function decl. */
390 tree fndecl;
393 /* GIMPLE_PHI */
395 struct GTY(()) gimple_statement_phi {
396 /* [ WORD 1-6 ] */
397 struct gimple_statement_base gsbase;
399 /* [ WORD 7 ] */
400 unsigned capacity;
401 unsigned nargs;
403 /* [ WORD 8 ] */
404 tree result;
406 /* [ WORD 9 ] */
407 struct phi_arg_d GTY ((length ("%h.nargs"))) args[1];
411 /* GIMPLE_RESX, GIMPLE_EH_DISPATCH */
413 struct GTY(()) gimple_statement_eh_ctrl
415 /* [ WORD 1-6 ] */
416 struct gimple_statement_base gsbase;
418 /* [ WORD 7 ]
419 Exception region number. */
420 int region;
424 /* GIMPLE_TRY */
426 struct GTY(()) gimple_statement_try {
427 /* [ WORD 1-6 ] */
428 struct gimple_statement_base gsbase;
430 /* [ WORD 7 ]
431 Expression to evaluate. */
432 gimple_seq eval;
434 /* [ WORD 8 ]
435 Cleanup expression. */
436 gimple_seq cleanup;
439 /* Kind of GIMPLE_TRY statements. */
440 enum gimple_try_flags
442 /* A try/catch. */
443 GIMPLE_TRY_CATCH = 1 << 0,
445 /* A try/finally. */
446 GIMPLE_TRY_FINALLY = 1 << 1,
447 GIMPLE_TRY_KIND = GIMPLE_TRY_CATCH | GIMPLE_TRY_FINALLY,
449 /* Analogous to TRY_CATCH_IS_CLEANUP. */
450 GIMPLE_TRY_CATCH_IS_CLEANUP = 1 << 2
453 /* GIMPLE_WITH_CLEANUP_EXPR */
455 struct GTY(()) gimple_statement_wce {
456 /* [ WORD 1-6 ] */
457 struct gimple_statement_base gsbase;
459 /* Subcode: CLEANUP_EH_ONLY. True if the cleanup should only be
460 executed if an exception is thrown, not on normal exit of its
461 scope. This flag is analogous to the CLEANUP_EH_ONLY flag
462 in TARGET_EXPRs. */
464 /* [ WORD 7 ]
465 Cleanup expression. */
466 gimple_seq cleanup;
470 /* GIMPLE_ASM */
472 struct GTY(()) gimple_statement_asm
474 /* [ WORD 1-9 ] */
475 struct gimple_statement_with_memory_ops_base membase;
477 /* [ WORD 10 ]
478 __asm__ statement. */
479 const char *string;
481 /* [ WORD 11 ]
482 Number of inputs, outputs, clobbers, labels. */
483 unsigned char ni;
484 unsigned char no;
485 unsigned char nc;
486 unsigned char nl;
488 /* [ WORD 12 ]
489 Operand vector. NOTE! This must always be the last field
490 of this structure. In particular, this means that this
491 structure cannot be embedded inside another one. */
492 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
495 /* GIMPLE_OMP_CRITICAL */
497 struct GTY(()) gimple_statement_omp_critical {
498 /* [ WORD 1-7 ] */
499 struct gimple_statement_omp omp;
501 /* [ WORD 8 ]
502 Critical section name. */
503 tree name;
507 struct GTY(()) gimple_omp_for_iter {
508 /* Condition code. */
509 enum tree_code cond;
511 /* Index variable. */
512 tree index;
514 /* Initial value. */
515 tree initial;
517 /* Final value. */
518 tree final;
520 /* Increment. */
521 tree incr;
524 /* GIMPLE_OMP_FOR */
526 struct GTY(()) gimple_statement_omp_for {
527 /* [ WORD 1-7 ] */
528 struct gimple_statement_omp omp;
530 /* [ WORD 8 ] */
531 tree clauses;
533 /* [ WORD 9 ]
534 Number of elements in iter array. */
535 size_t collapse;
537 /* [ WORD 10 ] */
538 struct gimple_omp_for_iter * GTY((length ("%h.collapse"))) iter;
540 /* [ WORD 11 ]
541 Pre-body evaluated before the loop body begins. */
542 gimple_seq pre_body;
546 /* GIMPLE_OMP_PARALLEL */
548 struct GTY(()) gimple_statement_omp_parallel {
549 /* [ WORD 1-7 ] */
550 struct gimple_statement_omp omp;
552 /* [ WORD 8 ]
553 Clauses. */
554 tree clauses;
556 /* [ WORD 9 ]
557 Child function holding the body of the parallel region. */
558 tree child_fn;
560 /* [ WORD 10 ]
561 Shared data argument. */
562 tree data_arg;
566 /* GIMPLE_OMP_TASK */
568 struct GTY(()) gimple_statement_omp_task {
569 /* [ WORD 1-10 ] */
570 struct gimple_statement_omp_parallel par;
572 /* [ WORD 11 ]
573 Child function holding firstprivate initialization if needed. */
574 tree copy_fn;
576 /* [ WORD 12-13 ]
577 Size and alignment in bytes of the argument data block. */
578 tree arg_size;
579 tree arg_align;
583 /* GIMPLE_OMP_SECTION */
584 /* Uses struct gimple_statement_omp. */
587 /* GIMPLE_OMP_SECTIONS */
589 struct GTY(()) gimple_statement_omp_sections {
590 /* [ WORD 1-7 ] */
591 struct gimple_statement_omp omp;
593 /* [ WORD 8 ] */
594 tree clauses;
596 /* [ WORD 9 ]
597 The control variable used for deciding which of the sections to
598 execute. */
599 tree control;
602 /* GIMPLE_OMP_CONTINUE.
604 Note: This does not inherit from gimple_statement_omp, because we
605 do not need the body field. */
607 struct GTY(()) gimple_statement_omp_continue {
608 /* [ WORD 1-6 ] */
609 struct gimple_statement_base gsbase;
611 /* [ WORD 7 ] */
612 tree control_def;
614 /* [ WORD 8 ] */
615 tree control_use;
618 /* GIMPLE_OMP_SINGLE, GIMPLE_OMP_TARGET, GIMPLE_OMP_TEAMS */
620 struct GTY(()) gimple_statement_omp_single {
621 /* [ WORD 1-7 ] */
622 struct gimple_statement_omp omp;
624 /* [ WORD 7 ] */
625 tree clauses;
629 /* GIMPLE_OMP_ATOMIC_LOAD.
630 Note: This is based on gimple_statement_base, not g_s_omp, because g_s_omp
631 contains a sequence, which we don't need here. */
633 struct GTY(()) gimple_statement_omp_atomic_load {
634 /* [ WORD 1-6 ] */
635 struct gimple_statement_base gsbase;
637 /* [ WORD 7-8 ] */
638 tree rhs, lhs;
641 /* GIMPLE_OMP_ATOMIC_STORE.
642 See note on GIMPLE_OMP_ATOMIC_LOAD. */
644 struct GTY(()) gimple_statement_omp_atomic_store {
645 /* [ WORD 1-6 ] */
646 struct gimple_statement_base gsbase;
648 /* [ WORD 7 ] */
649 tree val;
652 /* GIMPLE_TRANSACTION. */
654 /* Bits to be stored in the GIMPLE_TRANSACTION subcode. */
656 /* The __transaction_atomic was declared [[outer]] or it is
657 __transaction_relaxed. */
658 #define GTMA_IS_OUTER (1u << 0)
659 #define GTMA_IS_RELAXED (1u << 1)
660 #define GTMA_DECLARATION_MASK (GTMA_IS_OUTER | GTMA_IS_RELAXED)
662 /* The transaction is seen to not have an abort. */
663 #define GTMA_HAVE_ABORT (1u << 2)
664 /* The transaction is seen to have loads or stores. */
665 #define GTMA_HAVE_LOAD (1u << 3)
666 #define GTMA_HAVE_STORE (1u << 4)
667 /* The transaction MAY enter serial irrevocable mode in its dynamic scope. */
668 #define GTMA_MAY_ENTER_IRREVOCABLE (1u << 5)
669 /* The transaction WILL enter serial irrevocable mode.
670 An irrevocable block post-dominates the entire transaction, such
671 that all invocations of the transaction will go serial-irrevocable.
672 In such case, we don't bother instrumenting the transaction, and
673 tell the runtime that it should begin the transaction in
674 serial-irrevocable mode. */
675 #define GTMA_DOES_GO_IRREVOCABLE (1u << 6)
676 /* The transaction contains no instrumentation code whatsover, most
677 likely because it is guaranteed to go irrevocable upon entry. */
678 #define GTMA_HAS_NO_INSTRUMENTATION (1u << 7)
680 struct GTY(()) gimple_statement_transaction
682 /* [ WORD 1-9 ] */
683 struct gimple_statement_with_memory_ops_base gsbase;
685 /* [ WORD 10 ] */
686 gimple_seq body;
688 /* [ WORD 11 ] */
689 tree label;
692 #define DEFGSSTRUCT(SYM, STRUCT, HAS_TREE_OP) SYM,
693 enum gimple_statement_structure_enum {
694 #include "gsstruct.def"
695 LAST_GSS_ENUM
697 #undef DEFGSSTRUCT
700 /* Define the overall contents of a gimple tuple. It may be any of the
701 structures declared above for various types of tuples. */
703 union GTY ((desc ("gimple_statement_structure (&%h)"),
704 chain_next ("%h.gsbase.next"), variable_size)) gimple_statement_d {
705 struct gimple_statement_base GTY ((tag ("GSS_BASE"))) gsbase;
706 struct gimple_statement_with_ops GTY ((tag ("GSS_WITH_OPS"))) gsops;
707 struct gimple_statement_with_memory_ops_base GTY ((tag ("GSS_WITH_MEM_OPS_BASE"))) gsmembase;
708 struct gimple_statement_with_memory_ops GTY ((tag ("GSS_WITH_MEM_OPS"))) gsmem;
709 struct gimple_statement_call GTY ((tag ("GSS_CALL"))) gimple_call;
710 struct gimple_statement_omp GTY ((tag ("GSS_OMP"))) omp;
711 struct gimple_statement_bind GTY ((tag ("GSS_BIND"))) gimple_bind;
712 struct gimple_statement_catch GTY ((tag ("GSS_CATCH"))) gimple_catch;
713 struct gimple_statement_eh_filter GTY ((tag ("GSS_EH_FILTER"))) gimple_eh_filter;
714 struct gimple_statement_eh_mnt GTY ((tag ("GSS_EH_MNT"))) gimple_eh_mnt;
715 struct gimple_statement_eh_else GTY ((tag ("GSS_EH_ELSE"))) gimple_eh_else;
716 struct gimple_statement_phi GTY ((tag ("GSS_PHI"))) gimple_phi;
717 struct gimple_statement_eh_ctrl GTY ((tag ("GSS_EH_CTRL"))) gimple_eh_ctrl;
718 struct gimple_statement_try GTY ((tag ("GSS_TRY"))) gimple_try;
719 struct gimple_statement_wce GTY ((tag ("GSS_WCE"))) gimple_wce;
720 struct gimple_statement_asm GTY ((tag ("GSS_ASM"))) gimple_asm;
721 struct gimple_statement_omp_critical GTY ((tag ("GSS_OMP_CRITICAL"))) gimple_omp_critical;
722 struct gimple_statement_omp_for GTY ((tag ("GSS_OMP_FOR"))) gimple_omp_for;
723 struct gimple_statement_omp_parallel GTY ((tag ("GSS_OMP_PARALLEL"))) gimple_omp_parallel;
724 struct gimple_statement_omp_task GTY ((tag ("GSS_OMP_TASK"))) gimple_omp_task;
725 struct gimple_statement_omp_sections GTY ((tag ("GSS_OMP_SECTIONS"))) gimple_omp_sections;
726 struct gimple_statement_omp_single GTY ((tag ("GSS_OMP_SINGLE"))) gimple_omp_single;
727 struct gimple_statement_omp_continue GTY ((tag ("GSS_OMP_CONTINUE"))) gimple_omp_continue;
728 struct gimple_statement_omp_atomic_load GTY ((tag ("GSS_OMP_ATOMIC_LOAD"))) gimple_omp_atomic_load;
729 struct gimple_statement_omp_atomic_store GTY ((tag ("GSS_OMP_ATOMIC_STORE"))) gimple_omp_atomic_store;
730 struct gimple_statement_transaction GTY((tag ("GSS_TRANSACTION"))) gimple_transaction;
733 /* Offset in bytes to the location of the operand vector.
734 Zero if there is no operand vector for this tuple structure. */
735 extern size_t const gimple_ops_offset_[];
737 /* Map GIMPLE codes to GSS codes. */
738 extern enum gimple_statement_structure_enum const gss_for_code_[];
740 /* This variable holds the currently expanded gimple statement for purposes
741 of comminucating the profile info to the builtin expanders. */
742 extern gimple currently_expanding_gimple_stmt;
744 gimple gimple_build_return (tree);
746 gimple gimple_build_assign_stat (tree, tree MEM_STAT_DECL);
747 #define gimple_build_assign(l,r) gimple_build_assign_stat (l, r MEM_STAT_INFO)
749 void extract_ops_from_tree_1 (tree, enum tree_code *, tree *, tree *, tree *);
751 gimple
752 gimple_build_assign_with_ops (enum tree_code, tree,
753 tree, tree CXX_MEM_STAT_INFO);
754 gimple
755 gimple_build_assign_with_ops (enum tree_code, tree,
756 tree, tree, tree CXX_MEM_STAT_INFO);
758 gimple gimple_build_debug_bind_stat (tree, tree, gimple MEM_STAT_DECL);
759 #define gimple_build_debug_bind(var,val,stmt) \
760 gimple_build_debug_bind_stat ((var), (val), (stmt) MEM_STAT_INFO)
761 gimple gimple_build_debug_source_bind_stat (tree, tree, gimple MEM_STAT_DECL);
762 #define gimple_build_debug_source_bind(var,val,stmt) \
763 gimple_build_debug_source_bind_stat ((var), (val), (stmt) MEM_STAT_INFO)
765 gimple gimple_build_call_vec (tree, vec<tree> );
766 gimple gimple_build_call (tree, unsigned, ...);
767 gimple gimple_build_call_valist (tree, unsigned, va_list);
768 gimple gimple_build_call_internal (enum internal_fn, unsigned, ...);
769 gimple gimple_build_call_internal_vec (enum internal_fn, vec<tree> );
770 gimple gimple_build_call_from_tree (tree);
771 gimple gimplify_assign (tree, tree, gimple_seq *);
772 gimple gimple_build_cond (enum tree_code, tree, tree, tree, tree);
773 gimple gimple_build_label (tree label);
774 gimple gimple_build_goto (tree dest);
775 gimple gimple_build_nop (void);
776 gimple gimple_build_bind (tree, gimple_seq, tree);
777 gimple gimple_build_asm_vec (const char *, vec<tree, va_gc> *,
778 vec<tree, va_gc> *, vec<tree, va_gc> *,
779 vec<tree, va_gc> *);
780 gimple gimple_build_catch (tree, gimple_seq);
781 gimple gimple_build_eh_filter (tree, gimple_seq);
782 gimple gimple_build_eh_must_not_throw (tree);
783 gimple gimple_build_eh_else (gimple_seq, gimple_seq);
784 gimple gimple_build_try (gimple_seq, gimple_seq, enum gimple_try_flags);
785 gimple gimple_build_wce (gimple_seq);
786 gimple gimple_build_resx (int);
787 gimple gimple_build_eh_dispatch (int);
788 gimple gimple_build_switch_nlabels (unsigned, tree, tree);
789 gimple gimple_build_switch (tree, tree, vec<tree> );
790 gimple gimple_build_omp_parallel (gimple_seq, tree, tree, tree);
791 gimple gimple_build_omp_task (gimple_seq, tree, tree, tree, tree, tree, tree);
792 gimple gimple_build_omp_for (gimple_seq, int, tree, size_t, gimple_seq);
793 gimple gimple_build_omp_critical (gimple_seq, tree);
794 gimple gimple_build_omp_section (gimple_seq);
795 gimple gimple_build_omp_continue (tree, tree);
796 gimple gimple_build_omp_master (gimple_seq);
797 gimple gimple_build_omp_taskgroup (gimple_seq);
798 gimple gimple_build_omp_return (bool);
799 gimple gimple_build_omp_ordered (gimple_seq);
800 gimple gimple_build_omp_sections (gimple_seq, tree);
801 gimple gimple_build_omp_sections_switch (void);
802 gimple gimple_build_omp_single (gimple_seq, tree);
803 gimple gimple_build_omp_target (gimple_seq, int, tree);
804 gimple gimple_build_omp_teams (gimple_seq, tree);
805 gimple gimple_build_cdt (tree, tree);
806 gimple gimple_build_omp_atomic_load (tree, tree);
807 gimple gimple_build_omp_atomic_store (tree);
808 gimple gimple_build_transaction (gimple_seq, tree);
809 gimple gimple_build_predict (enum br_predictor, enum prediction);
810 enum gimple_statement_structure_enum gss_for_assign (enum tree_code);
811 void sort_case_labels (vec<tree> );
812 void preprocess_case_label_vec_for_gimple (vec<tree> , tree, tree *);
813 void gimple_set_body (tree, gimple_seq);
814 gimple_seq gimple_body (tree);
815 bool gimple_has_body_p (tree);
816 gimple_seq gimple_seq_alloc (void);
817 void gimple_seq_free (gimple_seq);
818 void gimple_seq_add_seq (gimple_seq *, gimple_seq);
819 gimple_seq gimple_seq_copy (gimple_seq);
820 bool gimple_call_same_target_p (const_gimple, const_gimple);
821 int gimple_call_flags (const_gimple);
822 int gimple_call_return_flags (const_gimple);
823 int gimple_call_arg_flags (const_gimple, unsigned);
824 void gimple_call_reset_alias_info (gimple);
825 bool gimple_assign_copy_p (gimple);
826 bool gimple_assign_ssa_name_copy_p (gimple);
827 bool gimple_assign_unary_nop_p (gimple);
828 void gimple_set_bb (gimple, basic_block);
829 void gimple_assign_set_rhs_from_tree (gimple_stmt_iterator *, tree);
830 void gimple_assign_set_rhs_with_ops_1 (gimple_stmt_iterator *, enum tree_code,
831 tree, tree, tree);
832 tree gimple_get_lhs (const_gimple);
833 void gimple_set_lhs (gimple, tree);
834 void gimple_replace_lhs (gimple, tree);
835 gimple gimple_copy (gimple);
836 void gimple_cond_get_ops_from_tree (tree, enum tree_code *, tree *, tree *);
837 gimple gimple_build_cond_from_tree (tree, tree, tree);
838 void gimple_cond_set_condition_from_tree (gimple, tree);
839 bool gimple_has_side_effects (const_gimple);
840 bool gimple_could_trap_p (gimple);
841 bool gimple_could_trap_p_1 (gimple, bool, bool);
842 bool gimple_assign_rhs_could_trap_p (gimple);
843 void gimple_regimplify_operands (gimple, gimple_stmt_iterator *);
844 bool empty_body_p (gimple_seq);
845 unsigned get_gimple_rhs_num_ops (enum tree_code);
846 #define gimple_alloc(c, n) gimple_alloc_stat (c, n MEM_STAT_INFO)
847 gimple gimple_alloc_stat (enum gimple_code, unsigned MEM_STAT_DECL);
848 const char *gimple_decl_printable_name (tree, int);
850 /* Returns true iff T is a virtual ssa name decl. */
851 extern bool virtual_operand_p (tree);
852 /* Returns true iff T is a scalar register variable. */
853 extern bool is_gimple_reg (tree);
854 /* Returns true iff T is any sort of variable. */
855 extern bool is_gimple_variable (tree);
856 /* Returns true iff T is any sort of symbol. */
857 extern bool is_gimple_id (tree);
858 /* Returns true iff T is a variable or an INDIRECT_REF (of a variable). */
859 extern bool is_gimple_min_lval (tree);
860 /* Returns true iff T is something whose address can be taken. */
861 extern bool is_gimple_addressable (tree);
862 /* Returns true iff T is any valid GIMPLE lvalue. */
863 extern bool is_gimple_lvalue (tree);
865 /* Returns true iff T is a GIMPLE address. */
866 bool is_gimple_address (const_tree);
867 /* Returns true iff T is a GIMPLE invariant address. */
868 bool is_gimple_invariant_address (const_tree);
869 /* Returns true iff T is a GIMPLE invariant address at interprocedural
870 level. */
871 bool is_gimple_ip_invariant_address (const_tree);
872 /* Returns true iff T is a valid GIMPLE constant. */
873 bool is_gimple_constant (const_tree);
874 /* Returns true iff T is a GIMPLE restricted function invariant. */
875 extern bool is_gimple_min_invariant (const_tree);
876 /* Returns true iff T is a GIMPLE restricted interprecodural invariant. */
877 extern bool is_gimple_ip_invariant (const_tree);
878 /* Returns true iff T is a GIMPLE rvalue. */
879 extern bool is_gimple_val (tree);
880 /* Returns true iff T is a GIMPLE asm statement input. */
881 extern bool is_gimple_asm_val (tree);
882 /* Returns true iff T is a valid address operand of a MEM_REF. */
883 bool is_gimple_mem_ref_addr (tree);
885 /* Returns true iff T is a valid if-statement condition. */
886 extern bool is_gimple_condexpr (tree);
888 /* Returns true iff T is a valid call address expression. */
889 extern bool is_gimple_call_addr (tree);
891 /* Return TRUE iff stmt is a call to a built-in function. */
892 extern bool is_gimple_builtin_call (gimple stmt);
894 extern void recalculate_side_effects (tree);
895 extern bool gimple_compare_field_offset (tree, tree);
896 extern tree gimple_unsigned_type (tree);
897 extern tree gimple_signed_type (tree);
898 extern alias_set_type gimple_get_alias_set (tree);
899 extern bool walk_stmt_load_store_addr_ops (gimple, void *,
900 bool (*)(gimple, tree, void *),
901 bool (*)(gimple, tree, void *),
902 bool (*)(gimple, tree, void *));
903 extern bool walk_stmt_load_store_ops (gimple, void *,
904 bool (*)(gimple, tree, void *),
905 bool (*)(gimple, tree, void *));
906 extern bool gimple_ior_addresses_taken (bitmap, gimple);
907 extern bool gimple_call_builtin_p (gimple, enum built_in_class);
908 extern bool gimple_call_builtin_p (gimple, enum built_in_function);
909 extern bool gimple_asm_clobbers_memory_p (const_gimple);
910 extern bool useless_type_conversion_p (tree, tree);
911 extern bool types_compatible_p (tree, tree);
913 /* In gimplify.c */
914 extern tree create_tmp_var_raw (tree, const char *);
915 extern tree create_tmp_var_name (const char *);
916 extern tree create_tmp_var (tree, const char *);
917 extern tree create_tmp_reg (tree, const char *);
918 extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq *);
919 extern tree get_formal_tmp_var (tree, gimple_seq *);
920 extern void declare_vars (tree, gimple, bool);
921 extern void annotate_all_with_location (gimple_seq, location_t);
923 /* Validation of GIMPLE expressions. Note that these predicates only check
924 the basic form of the expression, they don't recurse to make sure that
925 underlying nodes are also of the right form. */
926 typedef bool (*gimple_predicate)(tree);
929 /* FIXME we should deduce this from the predicate. */
930 enum fallback {
931 fb_none = 0, /* Do not generate a temporary. */
933 fb_rvalue = 1, /* Generate an rvalue to hold the result of a
934 gimplified expression. */
936 fb_lvalue = 2, /* Generate an lvalue to hold the result of a
937 gimplified expression. */
939 fb_mayfail = 4, /* Gimplification may fail. Error issued
940 afterwards. */
941 fb_either= fb_rvalue | fb_lvalue
944 typedef int fallback_t;
946 enum gimplify_status {
947 GS_ERROR = -2, /* Something Bad Seen. */
948 GS_UNHANDLED = -1, /* A langhook result for "I dunno". */
949 GS_OK = 0, /* We did something, maybe more to do. */
950 GS_ALL_DONE = 1 /* The expression is fully gimplified. */
953 /* Formal (expression) temporary table handling: multiple occurrences of
954 the same scalar expression are evaluated into the same temporary. */
956 typedef struct gimple_temp_hash_elt
958 tree val; /* Key */
959 tree temp; /* Value */
960 } elt_t;
962 /* Gimplify hashtable helper. */
964 struct gimplify_hasher : typed_free_remove <elt_t>
966 typedef elt_t value_type;
967 typedef elt_t compare_type;
968 static inline hashval_t hash (const value_type *);
969 static inline bool equal (const value_type *, const compare_type *);
972 inline hashval_t
973 gimplify_hasher::hash (const value_type *p)
975 tree t = p->val;
976 return iterative_hash_expr (t, 0);
979 inline bool
980 gimplify_hasher::equal (const value_type *p1, const compare_type *p2)
982 tree t1 = p1->val;
983 tree t2 = p2->val;
984 enum tree_code code = TREE_CODE (t1);
986 if (TREE_CODE (t2) != code
987 || TREE_TYPE (t1) != TREE_TYPE (t2))
988 return false;
990 if (!operand_equal_p (t1, t2, 0))
991 return false;
993 #ifdef ENABLE_CHECKING
994 /* Only allow them to compare equal if they also hash equal; otherwise
995 results are nondeterminate, and we fail bootstrap comparison. */
996 gcc_assert (hash (p1) == hash (p2));
997 #endif
999 return true;
1002 struct gimplify_ctx
1004 struct gimplify_ctx *prev_context;
1006 vec<gimple> bind_expr_stack;
1007 tree temps;
1008 gimple_seq conditional_cleanups;
1009 tree exit_label;
1010 tree return_temp;
1012 vec<tree> case_labels;
1013 /* The formal temporary table. Should this be persistent? */
1014 hash_table <gimplify_hasher> temp_htab;
1016 int conditions;
1017 bool save_stack;
1018 bool into_ssa;
1019 bool allow_rhs_cond_expr;
1020 bool in_cleanup_point_expr;
1023 /* Return true if gimplify_one_sizepos doesn't need to gimplify
1024 expr (when in TYPE_SIZE{,_UNIT} and similar type/decl size/bitsize
1025 fields). */
1026 static inline bool
1027 is_gimple_sizepos (tree expr)
1029 /* gimplify_one_sizepos doesn't need to do anything if the value isn't there,
1030 is constant, or contains A PLACEHOLDER_EXPR. We also don't want to do
1031 anything if it's already a VAR_DECL. If it's a VAR_DECL from another
1032 function, the gimplifier will want to replace it with a new variable,
1033 but that will cause problems if this type is from outside the function.
1034 It's OK to have that here. */
1035 return (expr == NULL_TREE
1036 || TREE_CONSTANT (expr)
1037 || TREE_CODE (expr) == VAR_DECL
1038 || CONTAINS_PLACEHOLDER_P (expr));
1041 /* Get the number of the next statement uid to be allocated. */
1042 static inline unsigned int
1043 gimple_stmt_max_uid (struct function *fn)
1045 return fn->last_stmt_uid;
1048 /* Set the number of the next statement uid to be allocated. */
1049 static inline void
1050 set_gimple_stmt_max_uid (struct function *fn, unsigned int maxid)
1052 fn->last_stmt_uid = maxid;
1055 /* Set the number of the next statement uid to be allocated. */
1056 static inline unsigned int
1057 inc_gimple_stmt_max_uid (struct function *fn)
1059 return fn->last_stmt_uid++;
1062 extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *,
1063 bool (*) (tree), fallback_t);
1064 extern void gimplify_type_sizes (tree, gimple_seq *);
1065 extern void gimplify_one_sizepos (tree *, gimple_seq *);
1066 enum gimplify_status gimplify_self_mod_expr (tree *, gimple_seq *, gimple_seq *,
1067 bool, tree);
1068 extern bool gimplify_stmt (tree *, gimple_seq *);
1069 extern gimple gimplify_body (tree, bool);
1070 extern void push_gimplify_context (struct gimplify_ctx *);
1071 extern void pop_gimplify_context (gimple);
1072 extern void gimplify_and_add (tree, gimple_seq *);
1074 /* Miscellaneous helpers. */
1075 extern void gimple_add_tmp_var (tree);
1076 extern bool flag_instrument_functions_exclude_p (tree);
1077 extern gimple gimple_current_bind_expr (void);
1078 extern vec<gimple> gimple_bind_expr_stack (void);
1079 extern tree voidify_wrapper_expr (tree, tree);
1080 extern tree build_and_jump (tree *);
1081 extern tree force_labels_r (tree *, int *, void *);
1082 extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *,
1083 gimple_seq *);
1084 struct gimplify_omp_ctx;
1085 extern void omp_firstprivatize_variable (struct gimplify_omp_ctx *, tree);
1086 extern tree gimple_boolify (tree);
1087 extern gimple_predicate rhs_predicate_for (tree);
1088 extern tree canonicalize_cond_expr_cond (tree);
1089 extern void dump_decl_set (FILE *, bitmap);
1090 extern bool gimple_can_coalesce_p (tree, tree);
1091 extern bool nonfreeing_call_p (gimple);
1092 extern tree copy_var_decl (tree, tree, tree);
1094 /* In trans-mem.c. */
1095 extern void diagnose_tm_safe_errors (tree);
1096 extern void compute_transaction_bits (void);
1098 /* In tree-nested.c. */
1099 extern void lower_nested_functions (tree);
1100 extern void insert_field_into_struct (tree, tree);
1102 /* In gimplify.c. */
1103 extern void gimplify_function_tree (tree);
1105 /* In cfgexpand.c. */
1106 extern tree gimple_assign_rhs_to_tree (gimple);
1108 /* In builtins.c */
1109 extern bool validate_gimple_arglist (const_gimple, ...);
1111 /* Return the first node in GIMPLE sequence S. */
1113 static inline gimple_seq_node
1114 gimple_seq_first (gimple_seq s)
1116 return s;
1120 /* Return the first statement in GIMPLE sequence S. */
1122 static inline gimple
1123 gimple_seq_first_stmt (gimple_seq s)
1125 gimple_seq_node n = gimple_seq_first (s);
1126 return n;
1130 /* Return the last node in GIMPLE sequence S. */
1132 static inline gimple_seq_node
1133 gimple_seq_last (gimple_seq s)
1135 return s ? s->gsbase.prev : NULL;
1139 /* Return the last statement in GIMPLE sequence S. */
1141 static inline gimple
1142 gimple_seq_last_stmt (gimple_seq s)
1144 gimple_seq_node n = gimple_seq_last (s);
1145 return n;
1149 /* Set the last node in GIMPLE sequence *PS to LAST. */
1151 static inline void
1152 gimple_seq_set_last (gimple_seq *ps, gimple_seq_node last)
1154 (*ps)->gsbase.prev = last;
1158 /* Set the first node in GIMPLE sequence *PS to FIRST. */
1160 static inline void
1161 gimple_seq_set_first (gimple_seq *ps, gimple_seq_node first)
1163 *ps = first;
1167 /* Return true if GIMPLE sequence S is empty. */
1169 static inline bool
1170 gimple_seq_empty_p (gimple_seq s)
1172 return s == NULL;
1175 void gimple_seq_add_stmt (gimple_seq *, gimple);
1177 /* Link gimple statement GS to the end of the sequence *SEQ_P. If
1178 *SEQ_P is NULL, a new sequence is allocated. This function is
1179 similar to gimple_seq_add_stmt, but does not scan the operands.
1180 During gimplification, we need to manipulate statement sequences
1181 before the def/use vectors have been constructed. */
1182 void gimple_seq_add_stmt_without_update (gimple_seq *, gimple);
1184 /* Allocate a new sequence and initialize its first element with STMT. */
1186 static inline gimple_seq
1187 gimple_seq_alloc_with_stmt (gimple stmt)
1189 gimple_seq seq = NULL;
1190 gimple_seq_add_stmt (&seq, stmt);
1191 return seq;
1195 /* Returns the sequence of statements in BB. */
1197 static inline gimple_seq
1198 bb_seq (const_basic_block bb)
1200 return (!(bb->flags & BB_RTL)) ? bb->il.gimple.seq : NULL;
1203 static inline gimple_seq *
1204 bb_seq_addr (basic_block bb)
1206 return (!(bb->flags & BB_RTL)) ? &bb->il.gimple.seq : NULL;
1209 /* Sets the sequence of statements in BB to SEQ. */
1211 static inline void
1212 set_bb_seq (basic_block bb, gimple_seq seq)
1214 gcc_checking_assert (!(bb->flags & BB_RTL));
1215 bb->il.gimple.seq = seq;
1219 /* Return the code for GIMPLE statement G. */
1221 static inline enum gimple_code
1222 gimple_code (const_gimple g)
1224 return g->gsbase.code;
1228 /* Return the GSS code used by a GIMPLE code. */
1230 static inline enum gimple_statement_structure_enum
1231 gss_for_code (enum gimple_code code)
1233 gcc_gimple_checking_assert ((unsigned int)code < LAST_AND_UNUSED_GIMPLE_CODE);
1234 return gss_for_code_[code];
1238 /* Return which GSS code is used by GS. */
1240 static inline enum gimple_statement_structure_enum
1241 gimple_statement_structure (gimple gs)
1243 return gss_for_code (gimple_code (gs));
1247 /* Return true if statement G has sub-statements. This is only true for
1248 High GIMPLE statements. */
1250 static inline bool
1251 gimple_has_substatements (gimple g)
1253 switch (gimple_code (g))
1255 case GIMPLE_BIND:
1256 case GIMPLE_CATCH:
1257 case GIMPLE_EH_FILTER:
1258 case GIMPLE_EH_ELSE:
1259 case GIMPLE_TRY:
1260 case GIMPLE_OMP_FOR:
1261 case GIMPLE_OMP_MASTER:
1262 case GIMPLE_OMP_TASKGROUP:
1263 case GIMPLE_OMP_ORDERED:
1264 case GIMPLE_OMP_SECTION:
1265 case GIMPLE_OMP_PARALLEL:
1266 case GIMPLE_OMP_TASK:
1267 case GIMPLE_OMP_SECTIONS:
1268 case GIMPLE_OMP_SINGLE:
1269 case GIMPLE_OMP_TARGET:
1270 case GIMPLE_OMP_TEAMS:
1271 case GIMPLE_OMP_CRITICAL:
1272 case GIMPLE_WITH_CLEANUP_EXPR:
1273 case GIMPLE_TRANSACTION:
1274 return true;
1276 default:
1277 return false;
1282 /* Return the basic block holding statement G. */
1284 static inline basic_block
1285 gimple_bb (const_gimple g)
1287 return g->gsbase.bb;
1291 /* Return the lexical scope block holding statement G. */
1293 static inline tree
1294 gimple_block (const_gimple g)
1296 return LOCATION_BLOCK (g->gsbase.location);
1300 /* Set BLOCK to be the lexical scope block holding statement G. */
1302 static inline void
1303 gimple_set_block (gimple g, tree block)
1305 if (block)
1306 g->gsbase.location =
1307 COMBINE_LOCATION_DATA (line_table, g->gsbase.location, block);
1308 else
1309 g->gsbase.location = LOCATION_LOCUS (g->gsbase.location);
1313 /* Return location information for statement G. */
1315 static inline location_t
1316 gimple_location (const_gimple g)
1318 return g->gsbase.location;
1321 /* Return pointer to location information for statement G. */
1323 static inline const location_t *
1324 gimple_location_ptr (const_gimple g)
1326 return &g->gsbase.location;
1330 /* Set location information for statement G. */
1332 static inline void
1333 gimple_set_location (gimple g, location_t location)
1335 g->gsbase.location = location;
1339 /* Return true if G contains location information. */
1341 static inline bool
1342 gimple_has_location (const_gimple g)
1344 return LOCATION_LOCUS (gimple_location (g)) != UNKNOWN_LOCATION;
1348 /* Return the file name of the location of STMT. */
1350 static inline const char *
1351 gimple_filename (const_gimple stmt)
1353 return LOCATION_FILE (gimple_location (stmt));
1357 /* Return the line number of the location of STMT. */
1359 static inline int
1360 gimple_lineno (const_gimple stmt)
1362 return LOCATION_LINE (gimple_location (stmt));
1366 /* Determine whether SEQ is a singleton. */
1368 static inline bool
1369 gimple_seq_singleton_p (gimple_seq seq)
1371 return ((gimple_seq_first (seq) != NULL)
1372 && (gimple_seq_first (seq) == gimple_seq_last (seq)));
1375 /* Return true if no warnings should be emitted for statement STMT. */
1377 static inline bool
1378 gimple_no_warning_p (const_gimple stmt)
1380 return stmt->gsbase.no_warning;
1383 /* Set the no_warning flag of STMT to NO_WARNING. */
1385 static inline void
1386 gimple_set_no_warning (gimple stmt, bool no_warning)
1388 stmt->gsbase.no_warning = (unsigned) no_warning;
1391 /* Set the visited status on statement STMT to VISITED_P. */
1393 static inline void
1394 gimple_set_visited (gimple stmt, bool visited_p)
1396 stmt->gsbase.visited = (unsigned) visited_p;
1400 /* Return the visited status for statement STMT. */
1402 static inline bool
1403 gimple_visited_p (gimple stmt)
1405 return stmt->gsbase.visited;
1409 /* Set pass local flag PLF on statement STMT to VAL_P. */
1411 static inline void
1412 gimple_set_plf (gimple stmt, enum plf_mask plf, bool val_p)
1414 if (val_p)
1415 stmt->gsbase.plf |= (unsigned int) plf;
1416 else
1417 stmt->gsbase.plf &= ~((unsigned int) plf);
1421 /* Return the value of pass local flag PLF on statement STMT. */
1423 static inline unsigned int
1424 gimple_plf (gimple stmt, enum plf_mask plf)
1426 return stmt->gsbase.plf & ((unsigned int) plf);
1430 /* Set the UID of statement. */
1432 static inline void
1433 gimple_set_uid (gimple g, unsigned uid)
1435 g->gsbase.uid = uid;
1439 /* Return the UID of statement. */
1441 static inline unsigned
1442 gimple_uid (const_gimple g)
1444 return g->gsbase.uid;
1448 /* Make statement G a singleton sequence. */
1450 static inline void
1451 gimple_init_singleton (gimple g)
1453 g->gsbase.next = NULL;
1454 g->gsbase.prev = g;
1458 /* Return true if GIMPLE statement G has register or memory operands. */
1460 static inline bool
1461 gimple_has_ops (const_gimple g)
1463 return gimple_code (g) >= GIMPLE_COND && gimple_code (g) <= GIMPLE_RETURN;
1467 /* Return true if GIMPLE statement G has memory operands. */
1469 static inline bool
1470 gimple_has_mem_ops (const_gimple g)
1472 return gimple_code (g) >= GIMPLE_ASSIGN && gimple_code (g) <= GIMPLE_RETURN;
1476 /* Return the set of USE operands for statement G. */
1478 static inline struct use_optype_d *
1479 gimple_use_ops (const_gimple g)
1481 if (!gimple_has_ops (g))
1482 return NULL;
1483 return g->gsops.opbase.use_ops;
1487 /* Set USE to be the set of USE operands for statement G. */
1489 static inline void
1490 gimple_set_use_ops (gimple g, struct use_optype_d *use)
1492 gcc_gimple_checking_assert (gimple_has_ops (g));
1493 g->gsops.opbase.use_ops = use;
1497 /* Return the single VUSE operand of the statement G. */
1499 static inline tree
1500 gimple_vuse (const_gimple g)
1502 if (!gimple_has_mem_ops (g))
1503 return NULL_TREE;
1504 return g->gsmembase.vuse;
1507 /* Return the single VDEF operand of the statement G. */
1509 static inline tree
1510 gimple_vdef (const_gimple g)
1512 if (!gimple_has_mem_ops (g))
1513 return NULL_TREE;
1514 return g->gsmembase.vdef;
1517 /* Return the single VUSE operand of the statement G. */
1519 static inline tree *
1520 gimple_vuse_ptr (gimple g)
1522 if (!gimple_has_mem_ops (g))
1523 return NULL;
1524 return &g->gsmembase.vuse;
1527 /* Return the single VDEF operand of the statement G. */
1529 static inline tree *
1530 gimple_vdef_ptr (gimple g)
1532 if (!gimple_has_mem_ops (g))
1533 return NULL;
1534 return &g->gsmembase.vdef;
1537 /* Set the single VUSE operand of the statement G. */
1539 static inline void
1540 gimple_set_vuse (gimple g, tree vuse)
1542 gcc_gimple_checking_assert (gimple_has_mem_ops (g));
1543 g->gsmembase.vuse = vuse;
1546 /* Set the single VDEF operand of the statement G. */
1548 static inline void
1549 gimple_set_vdef (gimple g, tree vdef)
1551 gcc_gimple_checking_assert (gimple_has_mem_ops (g));
1552 g->gsmembase.vdef = vdef;
1556 /* Return true if statement G has operands and the modified field has
1557 been set. */
1559 static inline bool
1560 gimple_modified_p (const_gimple g)
1562 return (gimple_has_ops (g)) ? (bool) g->gsbase.modified : false;
1566 /* Set the MODIFIED flag to MODIFIEDP, iff the gimple statement G has
1567 a MODIFIED field. */
1569 static inline void
1570 gimple_set_modified (gimple s, bool modifiedp)
1572 if (gimple_has_ops (s))
1573 s->gsbase.modified = (unsigned) modifiedp;
1577 /* Return the tree code for the expression computed by STMT. This is
1578 only valid for GIMPLE_COND, GIMPLE_CALL and GIMPLE_ASSIGN. For
1579 GIMPLE_CALL, return CALL_EXPR as the expression code for
1580 consistency. This is useful when the caller needs to deal with the
1581 three kinds of computation that GIMPLE supports. */
1583 static inline enum tree_code
1584 gimple_expr_code (const_gimple stmt)
1586 enum gimple_code code = gimple_code (stmt);
1587 if (code == GIMPLE_ASSIGN || code == GIMPLE_COND)
1588 return (enum tree_code) stmt->gsbase.subcode;
1589 else
1591 gcc_gimple_checking_assert (code == GIMPLE_CALL);
1592 return CALL_EXPR;
1597 /* Return true if statement STMT contains volatile operands. */
1599 static inline bool
1600 gimple_has_volatile_ops (const_gimple stmt)
1602 if (gimple_has_mem_ops (stmt))
1603 return stmt->gsbase.has_volatile_ops;
1604 else
1605 return false;
1609 /* Set the HAS_VOLATILE_OPS flag to VOLATILEP. */
1611 static inline void
1612 gimple_set_has_volatile_ops (gimple stmt, bool volatilep)
1614 if (gimple_has_mem_ops (stmt))
1615 stmt->gsbase.has_volatile_ops = (unsigned) volatilep;
1618 /* Return true if BB is in a transaction. */
1620 static inline bool
1621 block_in_transaction (basic_block bb)
1623 return flag_tm && bb->flags & BB_IN_TRANSACTION;
1626 /* Return true if STMT is in a transaction. */
1628 static inline bool
1629 gimple_in_transaction (gimple stmt)
1631 return block_in_transaction (gimple_bb (stmt));
1634 /* Return true if statement STMT may access memory. */
1636 static inline bool
1637 gimple_references_memory_p (gimple stmt)
1639 return gimple_has_mem_ops (stmt) && gimple_vuse (stmt);
1643 /* Return the subcode for OMP statement S. */
1645 static inline unsigned
1646 gimple_omp_subcode (const_gimple s)
1648 gcc_gimple_checking_assert (gimple_code (s) >= GIMPLE_OMP_ATOMIC_LOAD
1649 && gimple_code (s) <= GIMPLE_OMP_TEAMS);
1650 return s->gsbase.subcode;
1653 /* Set the subcode for OMP statement S to SUBCODE. */
1655 static inline void
1656 gimple_omp_set_subcode (gimple s, unsigned int subcode)
1658 /* We only have 16 bits for the subcode. Assert that we are not
1659 overflowing it. */
1660 gcc_gimple_checking_assert (subcode < (1 << 16));
1661 s->gsbase.subcode = subcode;
1664 /* Set the nowait flag on OMP_RETURN statement S. */
1666 static inline void
1667 gimple_omp_return_set_nowait (gimple s)
1669 GIMPLE_CHECK (s, GIMPLE_OMP_RETURN);
1670 s->gsbase.subcode |= GF_OMP_RETURN_NOWAIT;
1674 /* Return true if OMP return statement G has the GF_OMP_RETURN_NOWAIT
1675 flag set. */
1677 static inline bool
1678 gimple_omp_return_nowait_p (const_gimple g)
1680 GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
1681 return (gimple_omp_subcode (g) & GF_OMP_RETURN_NOWAIT) != 0;
1685 /* Set the LHS of OMP return. */
1687 static inline void
1688 gimple_omp_return_set_lhs (gimple g, tree lhs)
1690 GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
1691 g->gimple_omp_atomic_store.val = lhs;
1695 /* Get the LHS of OMP return. */
1697 static inline tree
1698 gimple_omp_return_lhs (const_gimple g)
1700 GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
1701 return g->gimple_omp_atomic_store.val;
1705 /* Return a pointer to the LHS of OMP return. */
1707 static inline tree *
1708 gimple_omp_return_lhs_ptr (gimple g)
1710 GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
1711 return &g->gimple_omp_atomic_store.val;
1715 /* Return true if OMP section statement G has the GF_OMP_SECTION_LAST
1716 flag set. */
1718 static inline bool
1719 gimple_omp_section_last_p (const_gimple g)
1721 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1722 return (gimple_omp_subcode (g) & GF_OMP_SECTION_LAST) != 0;
1726 /* Set the GF_OMP_SECTION_LAST flag on G. */
1728 static inline void
1729 gimple_omp_section_set_last (gimple g)
1731 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1732 g->gsbase.subcode |= GF_OMP_SECTION_LAST;
1736 /* Return true if OMP parallel statement G has the
1737 GF_OMP_PARALLEL_COMBINED flag set. */
1739 static inline bool
1740 gimple_omp_parallel_combined_p (const_gimple g)
1742 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1743 return (gimple_omp_subcode (g) & GF_OMP_PARALLEL_COMBINED) != 0;
1747 /* Set the GF_OMP_PARALLEL_COMBINED field in G depending on the boolean
1748 value of COMBINED_P. */
1750 static inline void
1751 gimple_omp_parallel_set_combined_p (gimple g, bool combined_p)
1753 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1754 if (combined_p)
1755 g->gsbase.subcode |= GF_OMP_PARALLEL_COMBINED;
1756 else
1757 g->gsbase.subcode &= ~GF_OMP_PARALLEL_COMBINED;
1761 /* Return true if OMP atomic load/store statement G has the
1762 GF_OMP_ATOMIC_NEED_VALUE flag set. */
1764 static inline bool
1765 gimple_omp_atomic_need_value_p (const_gimple g)
1767 if (gimple_code (g) != GIMPLE_OMP_ATOMIC_LOAD)
1768 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
1769 return (gimple_omp_subcode (g) & GF_OMP_ATOMIC_NEED_VALUE) != 0;
1773 /* Set the GF_OMP_ATOMIC_NEED_VALUE flag on G. */
1775 static inline void
1776 gimple_omp_atomic_set_need_value (gimple g)
1778 if (gimple_code (g) != GIMPLE_OMP_ATOMIC_LOAD)
1779 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
1780 g->gsbase.subcode |= GF_OMP_ATOMIC_NEED_VALUE;
1784 /* Return true if OMP atomic load/store statement G has the
1785 GF_OMP_ATOMIC_SEQ_CST flag set. */
1787 static inline bool
1788 gimple_omp_atomic_seq_cst_p (const_gimple g)
1790 if (gimple_code (g) != GIMPLE_OMP_ATOMIC_LOAD)
1791 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
1792 return (gimple_omp_subcode (g) & GF_OMP_ATOMIC_SEQ_CST) != 0;
1796 /* Set the GF_OMP_ATOMIC_SEQ_CST flag on G. */
1798 static inline void
1799 gimple_omp_atomic_set_seq_cst (gimple g)
1801 if (gimple_code (g) != GIMPLE_OMP_ATOMIC_LOAD)
1802 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
1803 g->gsbase.subcode |= GF_OMP_ATOMIC_SEQ_CST;
1807 /* Return the number of operands for statement GS. */
1809 static inline unsigned
1810 gimple_num_ops (const_gimple gs)
1812 return gs->gsbase.num_ops;
1816 /* Set the number of operands for statement GS. */
1818 static inline void
1819 gimple_set_num_ops (gimple gs, unsigned num_ops)
1821 gs->gsbase.num_ops = num_ops;
1825 /* Return the array of operands for statement GS. */
1827 static inline tree *
1828 gimple_ops (gimple gs)
1830 size_t off;
1832 /* All the tuples have their operand vector at the very bottom
1833 of the structure. Note that those structures that do not
1834 have an operand vector have a zero offset. */
1835 off = gimple_ops_offset_[gimple_statement_structure (gs)];
1836 gcc_gimple_checking_assert (off != 0);
1838 return (tree *) ((char *) gs + off);
1842 /* Return operand I for statement GS. */
1844 static inline tree
1845 gimple_op (const_gimple gs, unsigned i)
1847 if (gimple_has_ops (gs))
1849 gcc_gimple_checking_assert (i < gimple_num_ops (gs));
1850 return gimple_ops (CONST_CAST_GIMPLE (gs))[i];
1852 else
1853 return NULL_TREE;
1856 /* Return a pointer to operand I for statement GS. */
1858 static inline tree *
1859 gimple_op_ptr (const_gimple gs, unsigned i)
1861 if (gimple_has_ops (gs))
1863 gcc_gimple_checking_assert (i < gimple_num_ops (gs));
1864 return gimple_ops (CONST_CAST_GIMPLE (gs)) + i;
1866 else
1867 return NULL;
1870 /* Set operand I of statement GS to OP. */
1872 static inline void
1873 gimple_set_op (gimple gs, unsigned i, tree op)
1875 gcc_gimple_checking_assert (gimple_has_ops (gs) && i < gimple_num_ops (gs));
1877 /* Note. It may be tempting to assert that OP matches
1878 is_gimple_operand, but that would be wrong. Different tuples
1879 accept slightly different sets of tree operands. Each caller
1880 should perform its own validation. */
1881 gimple_ops (gs)[i] = op;
1884 /* Return true if GS is a GIMPLE_ASSIGN. */
1886 static inline bool
1887 is_gimple_assign (const_gimple gs)
1889 return gimple_code (gs) == GIMPLE_ASSIGN;
1892 /* Determine if expression CODE is one of the valid expressions that can
1893 be used on the RHS of GIMPLE assignments. */
1895 static inline enum gimple_rhs_class
1896 get_gimple_rhs_class (enum tree_code code)
1898 return (enum gimple_rhs_class) gimple_rhs_class_table[(int) code];
1901 /* Return the LHS of assignment statement GS. */
1903 static inline tree
1904 gimple_assign_lhs (const_gimple gs)
1906 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1907 return gimple_op (gs, 0);
1911 /* Return a pointer to the LHS of assignment statement GS. */
1913 static inline tree *
1914 gimple_assign_lhs_ptr (const_gimple gs)
1916 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1917 return gimple_op_ptr (gs, 0);
1921 /* Set LHS to be the LHS operand of assignment statement GS. */
1923 static inline void
1924 gimple_assign_set_lhs (gimple gs, tree lhs)
1926 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1927 gimple_set_op (gs, 0, lhs);
1929 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1930 SSA_NAME_DEF_STMT (lhs) = gs;
1934 /* Return the first operand on the RHS of assignment statement GS. */
1936 static inline tree
1937 gimple_assign_rhs1 (const_gimple gs)
1939 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1940 return gimple_op (gs, 1);
1944 /* Return a pointer to the first operand on the RHS of assignment
1945 statement GS. */
1947 static inline tree *
1948 gimple_assign_rhs1_ptr (const_gimple gs)
1950 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1951 return gimple_op_ptr (gs, 1);
1954 /* Set RHS to be the first operand on the RHS of assignment statement GS. */
1956 static inline void
1957 gimple_assign_set_rhs1 (gimple gs, tree rhs)
1959 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1961 gimple_set_op (gs, 1, rhs);
1965 /* Return the second operand on the RHS of assignment statement GS.
1966 If GS does not have two operands, NULL is returned instead. */
1968 static inline tree
1969 gimple_assign_rhs2 (const_gimple gs)
1971 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1973 if (gimple_num_ops (gs) >= 3)
1974 return gimple_op (gs, 2);
1975 else
1976 return NULL_TREE;
1980 /* Return a pointer to the second operand on the RHS of assignment
1981 statement GS. */
1983 static inline tree *
1984 gimple_assign_rhs2_ptr (const_gimple gs)
1986 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1987 return gimple_op_ptr (gs, 2);
1991 /* Set RHS to be the second operand on the RHS of assignment statement GS. */
1993 static inline void
1994 gimple_assign_set_rhs2 (gimple gs, tree rhs)
1996 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1998 gimple_set_op (gs, 2, rhs);
2001 /* Return the third operand on the RHS of assignment statement GS.
2002 If GS does not have two operands, NULL is returned instead. */
2004 static inline tree
2005 gimple_assign_rhs3 (const_gimple gs)
2007 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
2009 if (gimple_num_ops (gs) >= 4)
2010 return gimple_op (gs, 3);
2011 else
2012 return NULL_TREE;
2015 /* Return a pointer to the third operand on the RHS of assignment
2016 statement GS. */
2018 static inline tree *
2019 gimple_assign_rhs3_ptr (const_gimple gs)
2021 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
2022 return gimple_op_ptr (gs, 3);
2026 /* Set RHS to be the third operand on the RHS of assignment statement GS. */
2028 static inline void
2029 gimple_assign_set_rhs3 (gimple gs, tree rhs)
2031 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
2033 gimple_set_op (gs, 3, rhs);
2036 /* A wrapper around gimple_assign_set_rhs_with_ops_1, for callers which expect
2037 to see only a maximum of two operands. */
2039 static inline void
2040 gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *gsi, enum tree_code code,
2041 tree op1, tree op2)
2043 gimple_assign_set_rhs_with_ops_1 (gsi, code, op1, op2, NULL);
2046 /* A wrapper around extract_ops_from_tree_1, for callers which expect
2047 to see only a maximum of two operands. */
2049 static inline void
2050 extract_ops_from_tree (tree expr, enum tree_code *code, tree *op0,
2051 tree *op1)
2053 tree op2;
2054 extract_ops_from_tree_1 (expr, code, op0, op1, &op2);
2055 gcc_assert (op2 == NULL_TREE);
2058 /* Returns true if GS is a nontemporal move. */
2060 static inline bool
2061 gimple_assign_nontemporal_move_p (const_gimple gs)
2063 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
2064 return gs->gsbase.nontemporal_move;
2067 /* Sets nontemporal move flag of GS to NONTEMPORAL. */
2069 static inline void
2070 gimple_assign_set_nontemporal_move (gimple gs, bool nontemporal)
2072 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
2073 gs->gsbase.nontemporal_move = nontemporal;
2077 /* Return the code of the expression computed on the rhs of assignment
2078 statement GS. In case that the RHS is a single object, returns the
2079 tree code of the object. */
2081 static inline enum tree_code
2082 gimple_assign_rhs_code (const_gimple gs)
2084 enum tree_code code;
2085 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
2087 code = (enum tree_code) gs->gsbase.subcode;
2088 /* While we initially set subcode to the TREE_CODE of the rhs for
2089 GIMPLE_SINGLE_RHS assigns we do not update that subcode to stay
2090 in sync when we rewrite stmts into SSA form or do SSA propagations. */
2091 if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS)
2092 code = TREE_CODE (gimple_assign_rhs1 (gs));
2094 return code;
2098 /* Set CODE to be the code for the expression computed on the RHS of
2099 assignment S. */
2101 static inline void
2102 gimple_assign_set_rhs_code (gimple s, enum tree_code code)
2104 GIMPLE_CHECK (s, GIMPLE_ASSIGN);
2105 s->gsbase.subcode = code;
2109 /* Return the gimple rhs class of the code of the expression computed on
2110 the rhs of assignment statement GS.
2111 This will never return GIMPLE_INVALID_RHS. */
2113 static inline enum gimple_rhs_class
2114 gimple_assign_rhs_class (const_gimple gs)
2116 return get_gimple_rhs_class (gimple_assign_rhs_code (gs));
2119 /* Return true if GS is an assignment with a singleton RHS, i.e.,
2120 there is no operator associated with the assignment itself.
2121 Unlike gimple_assign_copy_p, this predicate returns true for
2122 any RHS operand, including those that perform an operation
2123 and do not have the semantics of a copy, such as COND_EXPR. */
2125 static inline bool
2126 gimple_assign_single_p (gimple gs)
2128 return (is_gimple_assign (gs)
2129 && gimple_assign_rhs_class (gs) == GIMPLE_SINGLE_RHS);
2132 /* Return true if GS performs a store to its lhs. */
2134 static inline bool
2135 gimple_store_p (gimple gs)
2137 tree lhs = gimple_get_lhs (gs);
2138 return lhs && !is_gimple_reg (lhs);
2141 /* Return true if GS is an assignment that loads from its rhs1. */
2143 static inline bool
2144 gimple_assign_load_p (gimple gs)
2146 tree rhs;
2147 if (!gimple_assign_single_p (gs))
2148 return false;
2149 rhs = gimple_assign_rhs1 (gs);
2150 if (TREE_CODE (rhs) == WITH_SIZE_EXPR)
2151 return true;
2152 rhs = get_base_address (rhs);
2153 return (DECL_P (rhs)
2154 || TREE_CODE (rhs) == MEM_REF || TREE_CODE (rhs) == TARGET_MEM_REF);
2158 /* Return true if S is a type-cast assignment. */
2160 static inline bool
2161 gimple_assign_cast_p (gimple s)
2163 if (is_gimple_assign (s))
2165 enum tree_code sc = gimple_assign_rhs_code (s);
2166 return CONVERT_EXPR_CODE_P (sc)
2167 || sc == VIEW_CONVERT_EXPR
2168 || sc == FIX_TRUNC_EXPR;
2171 return false;
2174 /* Return true if S is a clobber statement. */
2176 static inline bool
2177 gimple_clobber_p (gimple s)
2179 return gimple_assign_single_p (s)
2180 && TREE_CLOBBER_P (gimple_assign_rhs1 (s));
2183 /* Return true if GS is a GIMPLE_CALL. */
2185 static inline bool
2186 is_gimple_call (const_gimple gs)
2188 return gimple_code (gs) == GIMPLE_CALL;
2191 /* Return the LHS of call statement GS. */
2193 static inline tree
2194 gimple_call_lhs (const_gimple gs)
2196 GIMPLE_CHECK (gs, GIMPLE_CALL);
2197 return gimple_op (gs, 0);
2201 /* Return a pointer to the LHS of call statement GS. */
2203 static inline tree *
2204 gimple_call_lhs_ptr (const_gimple gs)
2206 GIMPLE_CHECK (gs, GIMPLE_CALL);
2207 return gimple_op_ptr (gs, 0);
2211 /* Set LHS to be the LHS operand of call statement GS. */
2213 static inline void
2214 gimple_call_set_lhs (gimple gs, tree lhs)
2216 GIMPLE_CHECK (gs, GIMPLE_CALL);
2217 gimple_set_op (gs, 0, lhs);
2218 if (lhs && TREE_CODE (lhs) == SSA_NAME)
2219 SSA_NAME_DEF_STMT (lhs) = gs;
2223 /* Return true if call GS calls an internal-only function, as enumerated
2224 by internal_fn. */
2226 static inline bool
2227 gimple_call_internal_p (const_gimple gs)
2229 GIMPLE_CHECK (gs, GIMPLE_CALL);
2230 return (gs->gsbase.subcode & GF_CALL_INTERNAL) != 0;
2234 /* Return the target of internal call GS. */
2236 static inline enum internal_fn
2237 gimple_call_internal_fn (const_gimple gs)
2239 gcc_gimple_checking_assert (gimple_call_internal_p (gs));
2240 return gs->gimple_call.u.internal_fn;
2244 /* Return the function type of the function called by GS. */
2246 static inline tree
2247 gimple_call_fntype (const_gimple gs)
2249 GIMPLE_CHECK (gs, GIMPLE_CALL);
2250 if (gimple_call_internal_p (gs))
2251 return NULL_TREE;
2252 return gs->gimple_call.u.fntype;
2255 /* Set the type of the function called by GS to FNTYPE. */
2257 static inline void
2258 gimple_call_set_fntype (gimple gs, tree fntype)
2260 GIMPLE_CHECK (gs, GIMPLE_CALL);
2261 gcc_gimple_checking_assert (!gimple_call_internal_p (gs));
2262 gs->gimple_call.u.fntype = fntype;
2266 /* Return the tree node representing the function called by call
2267 statement GS. */
2269 static inline tree
2270 gimple_call_fn (const_gimple gs)
2272 GIMPLE_CHECK (gs, GIMPLE_CALL);
2273 return gimple_op (gs, 1);
2276 /* Return a pointer to the tree node representing the function called by call
2277 statement GS. */
2279 static inline tree *
2280 gimple_call_fn_ptr (const_gimple gs)
2282 GIMPLE_CHECK (gs, GIMPLE_CALL);
2283 return gimple_op_ptr (gs, 1);
2287 /* Set FN to be the function called by call statement GS. */
2289 static inline void
2290 gimple_call_set_fn (gimple gs, tree fn)
2292 GIMPLE_CHECK (gs, GIMPLE_CALL);
2293 gcc_gimple_checking_assert (!gimple_call_internal_p (gs));
2294 gimple_set_op (gs, 1, fn);
2298 /* Set FNDECL to be the function called by call statement GS. */
2300 static inline void
2301 gimple_call_set_fndecl (gimple gs, tree decl)
2303 GIMPLE_CHECK (gs, GIMPLE_CALL);
2304 gcc_gimple_checking_assert (!gimple_call_internal_p (gs));
2305 gimple_set_op (gs, 1, build_fold_addr_expr_loc (gimple_location (gs), decl));
2309 /* Set internal function FN to be the function called by call statement GS. */
2311 static inline void
2312 gimple_call_set_internal_fn (gimple gs, enum internal_fn fn)
2314 GIMPLE_CHECK (gs, GIMPLE_CALL);
2315 gcc_gimple_checking_assert (gimple_call_internal_p (gs));
2316 gs->gimple_call.u.internal_fn = fn;
2320 /* Given a valid GIMPLE_CALL function address return the FUNCTION_DECL
2321 associated with the callee if known. Otherwise return NULL_TREE. */
2323 static inline tree
2324 gimple_call_addr_fndecl (const_tree fn)
2326 if (fn && TREE_CODE (fn) == ADDR_EXPR)
2328 tree fndecl = TREE_OPERAND (fn, 0);
2329 if (TREE_CODE (fndecl) == MEM_REF
2330 && TREE_CODE (TREE_OPERAND (fndecl, 0)) == ADDR_EXPR
2331 && integer_zerop (TREE_OPERAND (fndecl, 1)))
2332 fndecl = TREE_OPERAND (TREE_OPERAND (fndecl, 0), 0);
2333 if (TREE_CODE (fndecl) == FUNCTION_DECL)
2334 return fndecl;
2336 return NULL_TREE;
2339 /* If a given GIMPLE_CALL's callee is a FUNCTION_DECL, return it.
2340 Otherwise return NULL. This function is analogous to
2341 get_callee_fndecl in tree land. */
2343 static inline tree
2344 gimple_call_fndecl (const_gimple gs)
2346 return gimple_call_addr_fndecl (gimple_call_fn (gs));
2350 /* Return the type returned by call statement GS. */
2352 static inline tree
2353 gimple_call_return_type (const_gimple gs)
2355 tree type = gimple_call_fntype (gs);
2357 if (type == NULL_TREE)
2358 return TREE_TYPE (gimple_call_lhs (gs));
2360 /* The type returned by a function is the type of its
2361 function type. */
2362 return TREE_TYPE (type);
2366 /* Return the static chain for call statement GS. */
2368 static inline tree
2369 gimple_call_chain (const_gimple gs)
2371 GIMPLE_CHECK (gs, GIMPLE_CALL);
2372 return gimple_op (gs, 2);
2376 /* Return a pointer to the static chain for call statement GS. */
2378 static inline tree *
2379 gimple_call_chain_ptr (const_gimple gs)
2381 GIMPLE_CHECK (gs, GIMPLE_CALL);
2382 return gimple_op_ptr (gs, 2);
2385 /* Set CHAIN to be the static chain for call statement GS. */
2387 static inline void
2388 gimple_call_set_chain (gimple gs, tree chain)
2390 GIMPLE_CHECK (gs, GIMPLE_CALL);
2392 gimple_set_op (gs, 2, chain);
2396 /* Return the number of arguments used by call statement GS. */
2398 static inline unsigned
2399 gimple_call_num_args (const_gimple gs)
2401 unsigned num_ops;
2402 GIMPLE_CHECK (gs, GIMPLE_CALL);
2403 num_ops = gimple_num_ops (gs);
2404 return num_ops - 3;
2408 /* Return the argument at position INDEX for call statement GS. */
2410 static inline tree
2411 gimple_call_arg (const_gimple gs, unsigned index)
2413 GIMPLE_CHECK (gs, GIMPLE_CALL);
2414 return gimple_op (gs, index + 3);
2418 /* Return a pointer to the argument at position INDEX for call
2419 statement GS. */
2421 static inline tree *
2422 gimple_call_arg_ptr (const_gimple gs, unsigned index)
2424 GIMPLE_CHECK (gs, GIMPLE_CALL);
2425 return gimple_op_ptr (gs, index + 3);
2429 /* Set ARG to be the argument at position INDEX for call statement GS. */
2431 static inline void
2432 gimple_call_set_arg (gimple gs, unsigned index, tree arg)
2434 GIMPLE_CHECK (gs, GIMPLE_CALL);
2435 gimple_set_op (gs, index + 3, arg);
2439 /* If TAIL_P is true, mark call statement S as being a tail call
2440 (i.e., a call just before the exit of a function). These calls are
2441 candidate for tail call optimization. */
2443 static inline void
2444 gimple_call_set_tail (gimple s, bool tail_p)
2446 GIMPLE_CHECK (s, GIMPLE_CALL);
2447 if (tail_p)
2448 s->gsbase.subcode |= GF_CALL_TAILCALL;
2449 else
2450 s->gsbase.subcode &= ~GF_CALL_TAILCALL;
2454 /* Return true if GIMPLE_CALL S is marked as a tail call. */
2456 static inline bool
2457 gimple_call_tail_p (gimple s)
2459 GIMPLE_CHECK (s, GIMPLE_CALL);
2460 return (s->gsbase.subcode & GF_CALL_TAILCALL) != 0;
2464 /* If RETURN_SLOT_OPT_P is true mark GIMPLE_CALL S as valid for return
2465 slot optimization. This transformation uses the target of the call
2466 expansion as the return slot for calls that return in memory. */
2468 static inline void
2469 gimple_call_set_return_slot_opt (gimple s, bool return_slot_opt_p)
2471 GIMPLE_CHECK (s, GIMPLE_CALL);
2472 if (return_slot_opt_p)
2473 s->gsbase.subcode |= GF_CALL_RETURN_SLOT_OPT;
2474 else
2475 s->gsbase.subcode &= ~GF_CALL_RETURN_SLOT_OPT;
2479 /* Return true if S is marked for return slot optimization. */
2481 static inline bool
2482 gimple_call_return_slot_opt_p (gimple s)
2484 GIMPLE_CHECK (s, GIMPLE_CALL);
2485 return (s->gsbase.subcode & GF_CALL_RETURN_SLOT_OPT) != 0;
2489 /* If FROM_THUNK_P is true, mark GIMPLE_CALL S as being the jump from a
2490 thunk to the thunked-to function. */
2492 static inline void
2493 gimple_call_set_from_thunk (gimple s, bool from_thunk_p)
2495 GIMPLE_CHECK (s, GIMPLE_CALL);
2496 if (from_thunk_p)
2497 s->gsbase.subcode |= GF_CALL_FROM_THUNK;
2498 else
2499 s->gsbase.subcode &= ~GF_CALL_FROM_THUNK;
2503 /* Return true if GIMPLE_CALL S is a jump from a thunk. */
2505 static inline bool
2506 gimple_call_from_thunk_p (gimple s)
2508 GIMPLE_CHECK (s, GIMPLE_CALL);
2509 return (s->gsbase.subcode & GF_CALL_FROM_THUNK) != 0;
2513 /* If PASS_ARG_PACK_P is true, GIMPLE_CALL S is a stdarg call that needs the
2514 argument pack in its argument list. */
2516 static inline void
2517 gimple_call_set_va_arg_pack (gimple s, bool pass_arg_pack_p)
2519 GIMPLE_CHECK (s, GIMPLE_CALL);
2520 if (pass_arg_pack_p)
2521 s->gsbase.subcode |= GF_CALL_VA_ARG_PACK;
2522 else
2523 s->gsbase.subcode &= ~GF_CALL_VA_ARG_PACK;
2527 /* Return true if GIMPLE_CALL S is a stdarg call that needs the
2528 argument pack in its argument list. */
2530 static inline bool
2531 gimple_call_va_arg_pack_p (gimple s)
2533 GIMPLE_CHECK (s, GIMPLE_CALL);
2534 return (s->gsbase.subcode & GF_CALL_VA_ARG_PACK) != 0;
2538 /* Return true if S is a noreturn call. */
2540 static inline bool
2541 gimple_call_noreturn_p (gimple s)
2543 GIMPLE_CHECK (s, GIMPLE_CALL);
2544 return (gimple_call_flags (s) & ECF_NORETURN) != 0;
2548 /* If NOTHROW_P is true, GIMPLE_CALL S is a call that is known to not throw
2549 even if the called function can throw in other cases. */
2551 static inline void
2552 gimple_call_set_nothrow (gimple s, bool nothrow_p)
2554 GIMPLE_CHECK (s, GIMPLE_CALL);
2555 if (nothrow_p)
2556 s->gsbase.subcode |= GF_CALL_NOTHROW;
2557 else
2558 s->gsbase.subcode &= ~GF_CALL_NOTHROW;
2561 /* Return true if S is a nothrow call. */
2563 static inline bool
2564 gimple_call_nothrow_p (gimple s)
2566 GIMPLE_CHECK (s, GIMPLE_CALL);
2567 return (gimple_call_flags (s) & ECF_NOTHROW) != 0;
2570 /* If FOR_VAR is true, GIMPLE_CALL S is a call to builtin_alloca that
2571 is known to be emitted for VLA objects. Those are wrapped by
2572 stack_save/stack_restore calls and hence can't lead to unbounded
2573 stack growth even when they occur in loops. */
2575 static inline void
2576 gimple_call_set_alloca_for_var (gimple s, bool for_var)
2578 GIMPLE_CHECK (s, GIMPLE_CALL);
2579 if (for_var)
2580 s->gsbase.subcode |= GF_CALL_ALLOCA_FOR_VAR;
2581 else
2582 s->gsbase.subcode &= ~GF_CALL_ALLOCA_FOR_VAR;
2585 /* Return true of S is a call to builtin_alloca emitted for VLA objects. */
2587 static inline bool
2588 gimple_call_alloca_for_var_p (gimple s)
2590 GIMPLE_CHECK (s, GIMPLE_CALL);
2591 return (s->gsbase.subcode & GF_CALL_ALLOCA_FOR_VAR) != 0;
2594 /* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL. */
2596 static inline void
2597 gimple_call_copy_flags (gimple dest_call, gimple orig_call)
2599 GIMPLE_CHECK (dest_call, GIMPLE_CALL);
2600 GIMPLE_CHECK (orig_call, GIMPLE_CALL);
2601 dest_call->gsbase.subcode = orig_call->gsbase.subcode;
2605 /* Return a pointer to the points-to solution for the set of call-used
2606 variables of the call CALL. */
2608 static inline struct pt_solution *
2609 gimple_call_use_set (gimple call)
2611 GIMPLE_CHECK (call, GIMPLE_CALL);
2612 return &call->gimple_call.call_used;
2616 /* Return a pointer to the points-to solution for the set of call-used
2617 variables of the call CALL. */
2619 static inline struct pt_solution *
2620 gimple_call_clobber_set (gimple call)
2622 GIMPLE_CHECK (call, GIMPLE_CALL);
2623 return &call->gimple_call.call_clobbered;
2627 /* Returns true if this is a GIMPLE_ASSIGN or a GIMPLE_CALL with a
2628 non-NULL lhs. */
2630 static inline bool
2631 gimple_has_lhs (gimple stmt)
2633 return (is_gimple_assign (stmt)
2634 || (is_gimple_call (stmt)
2635 && gimple_call_lhs (stmt) != NULL_TREE));
2639 /* Return the code of the predicate computed by conditional statement GS. */
2641 static inline enum tree_code
2642 gimple_cond_code (const_gimple gs)
2644 GIMPLE_CHECK (gs, GIMPLE_COND);
2645 return (enum tree_code) gs->gsbase.subcode;
2649 /* Set CODE to be the predicate code for the conditional statement GS. */
2651 static inline void
2652 gimple_cond_set_code (gimple gs, enum tree_code code)
2654 GIMPLE_CHECK (gs, GIMPLE_COND);
2655 gs->gsbase.subcode = code;
2659 /* Return the LHS of the predicate computed by conditional statement GS. */
2661 static inline tree
2662 gimple_cond_lhs (const_gimple gs)
2664 GIMPLE_CHECK (gs, GIMPLE_COND);
2665 return gimple_op (gs, 0);
2668 /* Return the pointer to the LHS of the predicate computed by conditional
2669 statement GS. */
2671 static inline tree *
2672 gimple_cond_lhs_ptr (const_gimple gs)
2674 GIMPLE_CHECK (gs, GIMPLE_COND);
2675 return gimple_op_ptr (gs, 0);
2678 /* Set LHS to be the LHS operand of the predicate computed by
2679 conditional statement GS. */
2681 static inline void
2682 gimple_cond_set_lhs (gimple gs, tree lhs)
2684 GIMPLE_CHECK (gs, GIMPLE_COND);
2685 gimple_set_op (gs, 0, lhs);
2689 /* Return the RHS operand of the predicate computed by conditional GS. */
2691 static inline tree
2692 gimple_cond_rhs (const_gimple gs)
2694 GIMPLE_CHECK (gs, GIMPLE_COND);
2695 return gimple_op (gs, 1);
2698 /* Return the pointer to the RHS operand of the predicate computed by
2699 conditional GS. */
2701 static inline tree *
2702 gimple_cond_rhs_ptr (const_gimple gs)
2704 GIMPLE_CHECK (gs, GIMPLE_COND);
2705 return gimple_op_ptr (gs, 1);
2709 /* Set RHS to be the RHS operand of the predicate computed by
2710 conditional statement GS. */
2712 static inline void
2713 gimple_cond_set_rhs (gimple gs, tree rhs)
2715 GIMPLE_CHECK (gs, GIMPLE_COND);
2716 gimple_set_op (gs, 1, rhs);
2720 /* Return the label used by conditional statement GS when its
2721 predicate evaluates to true. */
2723 static inline tree
2724 gimple_cond_true_label (const_gimple gs)
2726 GIMPLE_CHECK (gs, GIMPLE_COND);
2727 return gimple_op (gs, 2);
2731 /* Set LABEL to be the label used by conditional statement GS when its
2732 predicate evaluates to true. */
2734 static inline void
2735 gimple_cond_set_true_label (gimple gs, tree label)
2737 GIMPLE_CHECK (gs, GIMPLE_COND);
2738 gimple_set_op (gs, 2, label);
2742 /* Set LABEL to be the label used by conditional statement GS when its
2743 predicate evaluates to false. */
2745 static inline void
2746 gimple_cond_set_false_label (gimple gs, tree label)
2748 GIMPLE_CHECK (gs, GIMPLE_COND);
2749 gimple_set_op (gs, 3, label);
2753 /* Return the label used by conditional statement GS when its
2754 predicate evaluates to false. */
2756 static inline tree
2757 gimple_cond_false_label (const_gimple gs)
2759 GIMPLE_CHECK (gs, GIMPLE_COND);
2760 return gimple_op (gs, 3);
2764 /* Set the conditional COND_STMT to be of the form 'if (1 == 0)'. */
2766 static inline void
2767 gimple_cond_make_false (gimple gs)
2769 gimple_cond_set_lhs (gs, boolean_true_node);
2770 gimple_cond_set_rhs (gs, boolean_false_node);
2771 gs->gsbase.subcode = EQ_EXPR;
2775 /* Set the conditional COND_STMT to be of the form 'if (1 == 1)'. */
2777 static inline void
2778 gimple_cond_make_true (gimple gs)
2780 gimple_cond_set_lhs (gs, boolean_true_node);
2781 gimple_cond_set_rhs (gs, boolean_true_node);
2782 gs->gsbase.subcode = EQ_EXPR;
2785 /* Check if conditional statemente GS is of the form 'if (1 == 1)',
2786 'if (0 == 0)', 'if (1 != 0)' or 'if (0 != 1)' */
2788 static inline bool
2789 gimple_cond_true_p (const_gimple gs)
2791 tree lhs = gimple_cond_lhs (gs);
2792 tree rhs = gimple_cond_rhs (gs);
2793 enum tree_code code = gimple_cond_code (gs);
2795 if (lhs != boolean_true_node && lhs != boolean_false_node)
2796 return false;
2798 if (rhs != boolean_true_node && rhs != boolean_false_node)
2799 return false;
2801 if (code == NE_EXPR && lhs != rhs)
2802 return true;
2804 if (code == EQ_EXPR && lhs == rhs)
2805 return true;
2807 return false;
2810 /* Check if conditional statement GS is of the form 'if (1 != 1)',
2811 'if (0 != 0)', 'if (1 == 0)' or 'if (0 == 1)' */
2813 static inline bool
2814 gimple_cond_false_p (const_gimple gs)
2816 tree lhs = gimple_cond_lhs (gs);
2817 tree rhs = gimple_cond_rhs (gs);
2818 enum tree_code code = gimple_cond_code (gs);
2820 if (lhs != boolean_true_node && lhs != boolean_false_node)
2821 return false;
2823 if (rhs != boolean_true_node && rhs != boolean_false_node)
2824 return false;
2826 if (code == NE_EXPR && lhs == rhs)
2827 return true;
2829 if (code == EQ_EXPR && lhs != rhs)
2830 return true;
2832 return false;
2835 /* Set the code, LHS and RHS of GIMPLE_COND STMT from CODE, LHS and RHS. */
2837 static inline void
2838 gimple_cond_set_condition (gimple stmt, enum tree_code code, tree lhs, tree rhs)
2840 gimple_cond_set_code (stmt, code);
2841 gimple_cond_set_lhs (stmt, lhs);
2842 gimple_cond_set_rhs (stmt, rhs);
2845 /* Return the LABEL_DECL node used by GIMPLE_LABEL statement GS. */
2847 static inline tree
2848 gimple_label_label (const_gimple gs)
2850 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2851 return gimple_op (gs, 0);
2855 /* Set LABEL to be the LABEL_DECL node used by GIMPLE_LABEL statement
2856 GS. */
2858 static inline void
2859 gimple_label_set_label (gimple gs, tree label)
2861 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2862 gimple_set_op (gs, 0, label);
2866 /* Return the destination of the unconditional jump GS. */
2868 static inline tree
2869 gimple_goto_dest (const_gimple gs)
2871 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2872 return gimple_op (gs, 0);
2876 /* Set DEST to be the destination of the unconditonal jump GS. */
2878 static inline void
2879 gimple_goto_set_dest (gimple gs, tree dest)
2881 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2882 gimple_set_op (gs, 0, dest);
2886 /* Return the variables declared in the GIMPLE_BIND statement GS. */
2888 static inline tree
2889 gimple_bind_vars (const_gimple gs)
2891 GIMPLE_CHECK (gs, GIMPLE_BIND);
2892 return gs->gimple_bind.vars;
2896 /* Set VARS to be the set of variables declared in the GIMPLE_BIND
2897 statement GS. */
2899 static inline void
2900 gimple_bind_set_vars (gimple gs, tree vars)
2902 GIMPLE_CHECK (gs, GIMPLE_BIND);
2903 gs->gimple_bind.vars = vars;
2907 /* Append VARS to the set of variables declared in the GIMPLE_BIND
2908 statement GS. */
2910 static inline void
2911 gimple_bind_append_vars (gimple gs, tree vars)
2913 GIMPLE_CHECK (gs, GIMPLE_BIND);
2914 gs->gimple_bind.vars = chainon (gs->gimple_bind.vars, vars);
2918 static inline gimple_seq *
2919 gimple_bind_body_ptr (gimple gs)
2921 GIMPLE_CHECK (gs, GIMPLE_BIND);
2922 return &gs->gimple_bind.body;
2925 /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS. */
2927 static inline gimple_seq
2928 gimple_bind_body (gimple gs)
2930 return *gimple_bind_body_ptr (gs);
2934 /* Set SEQ to be the GIMPLE sequence contained in the GIMPLE_BIND
2935 statement GS. */
2937 static inline void
2938 gimple_bind_set_body (gimple gs, gimple_seq seq)
2940 GIMPLE_CHECK (gs, GIMPLE_BIND);
2941 gs->gimple_bind.body = seq;
2945 /* Append a statement to the end of a GIMPLE_BIND's body. */
2947 static inline void
2948 gimple_bind_add_stmt (gimple gs, gimple stmt)
2950 GIMPLE_CHECK (gs, GIMPLE_BIND);
2951 gimple_seq_add_stmt (&gs->gimple_bind.body, stmt);
2955 /* Append a sequence of statements to the end of a GIMPLE_BIND's body. */
2957 static inline void
2958 gimple_bind_add_seq (gimple gs, gimple_seq seq)
2960 GIMPLE_CHECK (gs, GIMPLE_BIND);
2961 gimple_seq_add_seq (&gs->gimple_bind.body, seq);
2965 /* Return the TREE_BLOCK node associated with GIMPLE_BIND statement
2966 GS. This is analogous to the BIND_EXPR_BLOCK field in trees. */
2968 static inline tree
2969 gimple_bind_block (const_gimple gs)
2971 GIMPLE_CHECK (gs, GIMPLE_BIND);
2972 return gs->gimple_bind.block;
2976 /* Set BLOCK to be the TREE_BLOCK node associated with GIMPLE_BIND
2977 statement GS. */
2979 static inline void
2980 gimple_bind_set_block (gimple gs, tree block)
2982 GIMPLE_CHECK (gs, GIMPLE_BIND);
2983 gcc_gimple_checking_assert (block == NULL_TREE
2984 || TREE_CODE (block) == BLOCK);
2985 gs->gimple_bind.block = block;
2989 /* Return the number of input operands for GIMPLE_ASM GS. */
2991 static inline unsigned
2992 gimple_asm_ninputs (const_gimple gs)
2994 GIMPLE_CHECK (gs, GIMPLE_ASM);
2995 return gs->gimple_asm.ni;
2999 /* Return the number of output operands for GIMPLE_ASM GS. */
3001 static inline unsigned
3002 gimple_asm_noutputs (const_gimple gs)
3004 GIMPLE_CHECK (gs, GIMPLE_ASM);
3005 return gs->gimple_asm.no;
3009 /* Return the number of clobber operands for GIMPLE_ASM GS. */
3011 static inline unsigned
3012 gimple_asm_nclobbers (const_gimple gs)
3014 GIMPLE_CHECK (gs, GIMPLE_ASM);
3015 return gs->gimple_asm.nc;
3018 /* Return the number of label operands for GIMPLE_ASM GS. */
3020 static inline unsigned
3021 gimple_asm_nlabels (const_gimple gs)
3023 GIMPLE_CHECK (gs, GIMPLE_ASM);
3024 return gs->gimple_asm.nl;
3027 /* Return input operand INDEX of GIMPLE_ASM GS. */
3029 static inline tree
3030 gimple_asm_input_op (const_gimple gs, unsigned index)
3032 GIMPLE_CHECK (gs, GIMPLE_ASM);
3033 gcc_gimple_checking_assert (index < gs->gimple_asm.ni);
3034 return gimple_op (gs, index + gs->gimple_asm.no);
3037 /* Return a pointer to input operand INDEX of GIMPLE_ASM GS. */
3039 static inline tree *
3040 gimple_asm_input_op_ptr (const_gimple gs, unsigned index)
3042 GIMPLE_CHECK (gs, GIMPLE_ASM);
3043 gcc_gimple_checking_assert (index < gs->gimple_asm.ni);
3044 return gimple_op_ptr (gs, index + gs->gimple_asm.no);
3048 /* Set IN_OP to be input operand INDEX in GIMPLE_ASM GS. */
3050 static inline void
3051 gimple_asm_set_input_op (gimple gs, unsigned index, tree in_op)
3053 GIMPLE_CHECK (gs, GIMPLE_ASM);
3054 gcc_gimple_checking_assert (index < gs->gimple_asm.ni
3055 && TREE_CODE (in_op) == TREE_LIST);
3056 gimple_set_op (gs, index + gs->gimple_asm.no, in_op);
3060 /* Return output operand INDEX of GIMPLE_ASM GS. */
3062 static inline tree
3063 gimple_asm_output_op (const_gimple gs, unsigned index)
3065 GIMPLE_CHECK (gs, GIMPLE_ASM);
3066 gcc_gimple_checking_assert (index < gs->gimple_asm.no);
3067 return gimple_op (gs, index);
3070 /* Return a pointer to output operand INDEX of GIMPLE_ASM GS. */
3072 static inline tree *
3073 gimple_asm_output_op_ptr (const_gimple gs, unsigned index)
3075 GIMPLE_CHECK (gs, GIMPLE_ASM);
3076 gcc_gimple_checking_assert (index < gs->gimple_asm.no);
3077 return gimple_op_ptr (gs, index);
3081 /* Set OUT_OP to be output operand INDEX in GIMPLE_ASM GS. */
3083 static inline void
3084 gimple_asm_set_output_op (gimple gs, unsigned index, tree out_op)
3086 GIMPLE_CHECK (gs, GIMPLE_ASM);
3087 gcc_gimple_checking_assert (index < gs->gimple_asm.no
3088 && TREE_CODE (out_op) == TREE_LIST);
3089 gimple_set_op (gs, index, out_op);
3093 /* Return clobber operand INDEX of GIMPLE_ASM GS. */
3095 static inline tree
3096 gimple_asm_clobber_op (const_gimple gs, unsigned index)
3098 GIMPLE_CHECK (gs, GIMPLE_ASM);
3099 gcc_gimple_checking_assert (index < gs->gimple_asm.nc);
3100 return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no);
3104 /* Set CLOBBER_OP to be clobber operand INDEX in GIMPLE_ASM GS. */
3106 static inline void
3107 gimple_asm_set_clobber_op (gimple gs, unsigned index, tree clobber_op)
3109 GIMPLE_CHECK (gs, GIMPLE_ASM);
3110 gcc_gimple_checking_assert (index < gs->gimple_asm.nc
3111 && TREE_CODE (clobber_op) == TREE_LIST);
3112 gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no, clobber_op);
3115 /* Return label operand INDEX of GIMPLE_ASM GS. */
3117 static inline tree
3118 gimple_asm_label_op (const_gimple gs, unsigned index)
3120 GIMPLE_CHECK (gs, GIMPLE_ASM);
3121 gcc_gimple_checking_assert (index < gs->gimple_asm.nl);
3122 return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.nc);
3125 /* Set LABEL_OP to be label operand INDEX in GIMPLE_ASM GS. */
3127 static inline void
3128 gimple_asm_set_label_op (gimple gs, unsigned index, tree label_op)
3130 GIMPLE_CHECK (gs, GIMPLE_ASM);
3131 gcc_gimple_checking_assert (index < gs->gimple_asm.nl
3132 && TREE_CODE (label_op) == TREE_LIST);
3133 gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.nc, label_op);
3136 /* Return the string representing the assembly instruction in
3137 GIMPLE_ASM GS. */
3139 static inline const char *
3140 gimple_asm_string (const_gimple gs)
3142 GIMPLE_CHECK (gs, GIMPLE_ASM);
3143 return gs->gimple_asm.string;
3147 /* Return true if GS is an asm statement marked volatile. */
3149 static inline bool
3150 gimple_asm_volatile_p (const_gimple gs)
3152 GIMPLE_CHECK (gs, GIMPLE_ASM);
3153 return (gs->gsbase.subcode & GF_ASM_VOLATILE) != 0;
3157 /* If VOLATLE_P is true, mark asm statement GS as volatile. */
3159 static inline void
3160 gimple_asm_set_volatile (gimple gs, bool volatile_p)
3162 GIMPLE_CHECK (gs, GIMPLE_ASM);
3163 if (volatile_p)
3164 gs->gsbase.subcode |= GF_ASM_VOLATILE;
3165 else
3166 gs->gsbase.subcode &= ~GF_ASM_VOLATILE;
3170 /* If INPUT_P is true, mark asm GS as an ASM_INPUT. */
3172 static inline void
3173 gimple_asm_set_input (gimple gs, bool input_p)
3175 GIMPLE_CHECK (gs, GIMPLE_ASM);
3176 if (input_p)
3177 gs->gsbase.subcode |= GF_ASM_INPUT;
3178 else
3179 gs->gsbase.subcode &= ~GF_ASM_INPUT;
3183 /* Return true if asm GS is an ASM_INPUT. */
3185 static inline bool
3186 gimple_asm_input_p (const_gimple gs)
3188 GIMPLE_CHECK (gs, GIMPLE_ASM);
3189 return (gs->gsbase.subcode & GF_ASM_INPUT) != 0;
3193 /* Return the types handled by GIMPLE_CATCH statement GS. */
3195 static inline tree
3196 gimple_catch_types (const_gimple gs)
3198 GIMPLE_CHECK (gs, GIMPLE_CATCH);
3199 return gs->gimple_catch.types;
3203 /* Return a pointer to the types handled by GIMPLE_CATCH statement GS. */
3205 static inline tree *
3206 gimple_catch_types_ptr (gimple gs)
3208 GIMPLE_CHECK (gs, GIMPLE_CATCH);
3209 return &gs->gimple_catch.types;
3213 /* Return a pointer to the GIMPLE sequence representing the body of
3214 the handler of GIMPLE_CATCH statement GS. */
3216 static inline gimple_seq *
3217 gimple_catch_handler_ptr (gimple gs)
3219 GIMPLE_CHECK (gs, GIMPLE_CATCH);
3220 return &gs->gimple_catch.handler;
3224 /* Return the GIMPLE sequence representing the body of the handler of
3225 GIMPLE_CATCH statement GS. */
3227 static inline gimple_seq
3228 gimple_catch_handler (gimple gs)
3230 return *gimple_catch_handler_ptr (gs);
3234 /* Set T to be the set of types handled by GIMPLE_CATCH GS. */
3236 static inline void
3237 gimple_catch_set_types (gimple gs, tree t)
3239 GIMPLE_CHECK (gs, GIMPLE_CATCH);
3240 gs->gimple_catch.types = t;
3244 /* Set HANDLER to be the body of GIMPLE_CATCH GS. */
3246 static inline void
3247 gimple_catch_set_handler (gimple gs, gimple_seq handler)
3249 GIMPLE_CHECK (gs, GIMPLE_CATCH);
3250 gs->gimple_catch.handler = handler;
3254 /* Return the types handled by GIMPLE_EH_FILTER statement GS. */
3256 static inline tree
3257 gimple_eh_filter_types (const_gimple gs)
3259 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
3260 return gs->gimple_eh_filter.types;
3264 /* Return a pointer to the types handled by GIMPLE_EH_FILTER statement
3265 GS. */
3267 static inline tree *
3268 gimple_eh_filter_types_ptr (gimple gs)
3270 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
3271 return &gs->gimple_eh_filter.types;
3275 /* Return a pointer to the sequence of statement to execute when
3276 GIMPLE_EH_FILTER statement fails. */
3278 static inline gimple_seq *
3279 gimple_eh_filter_failure_ptr (gimple gs)
3281 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
3282 return &gs->gimple_eh_filter.failure;
3286 /* Return the sequence of statement to execute when GIMPLE_EH_FILTER
3287 statement fails. */
3289 static inline gimple_seq
3290 gimple_eh_filter_failure (gimple gs)
3292 return *gimple_eh_filter_failure_ptr (gs);
3296 /* Set TYPES to be the set of types handled by GIMPLE_EH_FILTER GS. */
3298 static inline void
3299 gimple_eh_filter_set_types (gimple gs, tree types)
3301 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
3302 gs->gimple_eh_filter.types = types;
3306 /* Set FAILURE to be the sequence of statements to execute on failure
3307 for GIMPLE_EH_FILTER GS. */
3309 static inline void
3310 gimple_eh_filter_set_failure (gimple gs, gimple_seq failure)
3312 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
3313 gs->gimple_eh_filter.failure = failure;
3316 /* Get the function decl to be called by the MUST_NOT_THROW region. */
3318 static inline tree
3319 gimple_eh_must_not_throw_fndecl (gimple gs)
3321 GIMPLE_CHECK (gs, GIMPLE_EH_MUST_NOT_THROW);
3322 return gs->gimple_eh_mnt.fndecl;
3325 /* Set the function decl to be called by GS to DECL. */
3327 static inline void
3328 gimple_eh_must_not_throw_set_fndecl (gimple gs, tree decl)
3330 GIMPLE_CHECK (gs, GIMPLE_EH_MUST_NOT_THROW);
3331 gs->gimple_eh_mnt.fndecl = decl;
3334 /* GIMPLE_EH_ELSE accessors. */
3336 static inline gimple_seq *
3337 gimple_eh_else_n_body_ptr (gimple gs)
3339 GIMPLE_CHECK (gs, GIMPLE_EH_ELSE);
3340 return &gs->gimple_eh_else.n_body;
3343 static inline gimple_seq
3344 gimple_eh_else_n_body (gimple gs)
3346 return *gimple_eh_else_n_body_ptr (gs);
3349 static inline gimple_seq *
3350 gimple_eh_else_e_body_ptr (gimple gs)
3352 GIMPLE_CHECK (gs, GIMPLE_EH_ELSE);
3353 return &gs->gimple_eh_else.e_body;
3356 static inline gimple_seq
3357 gimple_eh_else_e_body (gimple gs)
3359 return *gimple_eh_else_e_body_ptr (gs);
3362 static inline void
3363 gimple_eh_else_set_n_body (gimple gs, gimple_seq seq)
3365 GIMPLE_CHECK (gs, GIMPLE_EH_ELSE);
3366 gs->gimple_eh_else.n_body = seq;
3369 static inline void
3370 gimple_eh_else_set_e_body (gimple gs, gimple_seq seq)
3372 GIMPLE_CHECK (gs, GIMPLE_EH_ELSE);
3373 gs->gimple_eh_else.e_body = seq;
3376 /* GIMPLE_TRY accessors. */
3378 /* Return the kind of try block represented by GIMPLE_TRY GS. This is
3379 either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY. */
3381 static inline enum gimple_try_flags
3382 gimple_try_kind (const_gimple gs)
3384 GIMPLE_CHECK (gs, GIMPLE_TRY);
3385 return (enum gimple_try_flags) (gs->gsbase.subcode & GIMPLE_TRY_KIND);
3389 /* Set the kind of try block represented by GIMPLE_TRY GS. */
3391 static inline void
3392 gimple_try_set_kind (gimple gs, enum gimple_try_flags kind)
3394 GIMPLE_CHECK (gs, GIMPLE_TRY);
3395 gcc_gimple_checking_assert (kind == GIMPLE_TRY_CATCH
3396 || kind == GIMPLE_TRY_FINALLY);
3397 if (gimple_try_kind (gs) != kind)
3398 gs->gsbase.subcode = (unsigned int) kind;
3402 /* Return the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
3404 static inline bool
3405 gimple_try_catch_is_cleanup (const_gimple gs)
3407 gcc_gimple_checking_assert (gimple_try_kind (gs) == GIMPLE_TRY_CATCH);
3408 return (gs->gsbase.subcode & GIMPLE_TRY_CATCH_IS_CLEANUP) != 0;
3412 /* Return a pointer to the sequence of statements used as the
3413 body for GIMPLE_TRY GS. */
3415 static inline gimple_seq *
3416 gimple_try_eval_ptr (gimple gs)
3418 GIMPLE_CHECK (gs, GIMPLE_TRY);
3419 return &gs->gimple_try.eval;
3423 /* Return the sequence of statements used as the body for GIMPLE_TRY GS. */
3425 static inline gimple_seq
3426 gimple_try_eval (gimple gs)
3428 return *gimple_try_eval_ptr (gs);
3432 /* Return a pointer to the sequence of statements used as the cleanup body for
3433 GIMPLE_TRY GS. */
3435 static inline gimple_seq *
3436 gimple_try_cleanup_ptr (gimple gs)
3438 GIMPLE_CHECK (gs, GIMPLE_TRY);
3439 return &gs->gimple_try.cleanup;
3443 /* Return the sequence of statements used as the cleanup body for
3444 GIMPLE_TRY GS. */
3446 static inline gimple_seq
3447 gimple_try_cleanup (gimple gs)
3449 return *gimple_try_cleanup_ptr (gs);
3453 /* Set the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
3455 static inline void
3456 gimple_try_set_catch_is_cleanup (gimple g, bool catch_is_cleanup)
3458 gcc_gimple_checking_assert (gimple_try_kind (g) == GIMPLE_TRY_CATCH);
3459 if (catch_is_cleanup)
3460 g->gsbase.subcode |= GIMPLE_TRY_CATCH_IS_CLEANUP;
3461 else
3462 g->gsbase.subcode &= ~GIMPLE_TRY_CATCH_IS_CLEANUP;
3466 /* Set EVAL to be the sequence of statements to use as the body for
3467 GIMPLE_TRY GS. */
3469 static inline void
3470 gimple_try_set_eval (gimple gs, gimple_seq eval)
3472 GIMPLE_CHECK (gs, GIMPLE_TRY);
3473 gs->gimple_try.eval = eval;
3477 /* Set CLEANUP to be the sequence of statements to use as the cleanup
3478 body for GIMPLE_TRY GS. */
3480 static inline void
3481 gimple_try_set_cleanup (gimple gs, gimple_seq cleanup)
3483 GIMPLE_CHECK (gs, GIMPLE_TRY);
3484 gs->gimple_try.cleanup = cleanup;
3488 /* Return a pointer to the cleanup sequence for cleanup statement GS. */
3490 static inline gimple_seq *
3491 gimple_wce_cleanup_ptr (gimple gs)
3493 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3494 return &gs->gimple_wce.cleanup;
3498 /* Return the cleanup sequence for cleanup statement GS. */
3500 static inline gimple_seq
3501 gimple_wce_cleanup (gimple gs)
3503 return *gimple_wce_cleanup_ptr (gs);
3507 /* Set CLEANUP to be the cleanup sequence for GS. */
3509 static inline void
3510 gimple_wce_set_cleanup (gimple gs, gimple_seq cleanup)
3512 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3513 gs->gimple_wce.cleanup = cleanup;
3517 /* Return the CLEANUP_EH_ONLY flag for a WCE tuple. */
3519 static inline bool
3520 gimple_wce_cleanup_eh_only (const_gimple gs)
3522 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3523 return gs->gsbase.subcode != 0;
3527 /* Set the CLEANUP_EH_ONLY flag for a WCE tuple. */
3529 static inline void
3530 gimple_wce_set_cleanup_eh_only (gimple gs, bool eh_only_p)
3532 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3533 gs->gsbase.subcode = (unsigned int) eh_only_p;
3537 /* Return the maximum number of arguments supported by GIMPLE_PHI GS. */
3539 static inline unsigned
3540 gimple_phi_capacity (const_gimple gs)
3542 GIMPLE_CHECK (gs, GIMPLE_PHI);
3543 return gs->gimple_phi.capacity;
3547 /* Return the number of arguments in GIMPLE_PHI GS. This must always
3548 be exactly the number of incoming edges for the basic block holding
3549 GS. */
3551 static inline unsigned
3552 gimple_phi_num_args (const_gimple gs)
3554 GIMPLE_CHECK (gs, GIMPLE_PHI);
3555 return gs->gimple_phi.nargs;
3559 /* Return the SSA name created by GIMPLE_PHI GS. */
3561 static inline tree
3562 gimple_phi_result (const_gimple gs)
3564 GIMPLE_CHECK (gs, GIMPLE_PHI);
3565 return gs->gimple_phi.result;
3568 /* Return a pointer to the SSA name created by GIMPLE_PHI GS. */
3570 static inline tree *
3571 gimple_phi_result_ptr (gimple gs)
3573 GIMPLE_CHECK (gs, GIMPLE_PHI);
3574 return &gs->gimple_phi.result;
3577 /* Set RESULT to be the SSA name created by GIMPLE_PHI GS. */
3579 static inline void
3580 gimple_phi_set_result (gimple gs, tree result)
3582 GIMPLE_CHECK (gs, GIMPLE_PHI);
3583 gs->gimple_phi.result = result;
3584 if (result && TREE_CODE (result) == SSA_NAME)
3585 SSA_NAME_DEF_STMT (result) = gs;
3589 /* Return the PHI argument corresponding to incoming edge INDEX for
3590 GIMPLE_PHI GS. */
3592 static inline struct phi_arg_d *
3593 gimple_phi_arg (gimple gs, unsigned index)
3595 GIMPLE_CHECK (gs, GIMPLE_PHI);
3596 gcc_gimple_checking_assert (index <= gs->gimple_phi.capacity);
3597 return &(gs->gimple_phi.args[index]);
3600 /* Set PHIARG to be the argument corresponding to incoming edge INDEX
3601 for GIMPLE_PHI GS. */
3603 static inline void
3604 gimple_phi_set_arg (gimple gs, unsigned index, struct phi_arg_d * phiarg)
3606 GIMPLE_CHECK (gs, GIMPLE_PHI);
3607 gcc_gimple_checking_assert (index <= gs->gimple_phi.nargs);
3608 gs->gimple_phi.args[index] = *phiarg;
3611 /* PHI nodes should contain only ssa_names and invariants. A test
3612 for ssa_name is definitely simpler; don't let invalid contents
3613 slip in in the meantime. */
3615 static inline bool
3616 phi_ssa_name_p (const_tree t)
3618 if (TREE_CODE (t) == SSA_NAME)
3619 return true;
3620 gcc_checking_assert (is_gimple_min_invariant (t));
3621 return false;
3624 /* Return the PHI nodes for basic block BB, or NULL if there are no
3625 PHI nodes. */
3627 static inline gimple_seq
3628 phi_nodes (const_basic_block bb)
3630 gcc_checking_assert (!(bb->flags & BB_RTL));
3631 return bb->il.gimple.phi_nodes;
3634 /* Return a pointer to the PHI nodes for basic block BB. */
3636 static inline gimple_seq *
3637 phi_nodes_ptr (basic_block bb)
3639 gcc_checking_assert (!(bb->flags & BB_RTL));
3640 return &bb->il.gimple.phi_nodes;
3643 /* Return the tree operand for argument I of PHI node GS. */
3645 static inline tree
3646 gimple_phi_arg_def (gimple gs, size_t index)
3648 return gimple_phi_arg (gs, index)->def;
3652 /* Return a pointer to the tree operand for argument I of PHI node GS. */
3654 static inline tree *
3655 gimple_phi_arg_def_ptr (gimple gs, size_t index)
3657 return &gimple_phi_arg (gs, index)->def;
3660 /* Return the edge associated with argument I of phi node GS. */
3662 static inline edge
3663 gimple_phi_arg_edge (gimple gs, size_t i)
3665 return EDGE_PRED (gimple_bb (gs), i);
3668 /* Return the source location of gimple argument I of phi node GS. */
3670 static inline source_location
3671 gimple_phi_arg_location (gimple gs, size_t i)
3673 return gimple_phi_arg (gs, i)->locus;
3676 /* Return the source location of the argument on edge E of phi node GS. */
3678 static inline source_location
3679 gimple_phi_arg_location_from_edge (gimple gs, edge e)
3681 return gimple_phi_arg (gs, e->dest_idx)->locus;
3684 /* Set the source location of gimple argument I of phi node GS to LOC. */
3686 static inline void
3687 gimple_phi_arg_set_location (gimple gs, size_t i, source_location loc)
3689 gimple_phi_arg (gs, i)->locus = loc;
3692 /* Return TRUE if argument I of phi node GS has a location record. */
3694 static inline bool
3695 gimple_phi_arg_has_location (gimple gs, size_t i)
3697 return gimple_phi_arg_location (gs, i) != UNKNOWN_LOCATION;
3701 /* Return the region number for GIMPLE_RESX GS. */
3703 static inline int
3704 gimple_resx_region (const_gimple gs)
3706 GIMPLE_CHECK (gs, GIMPLE_RESX);
3707 return gs->gimple_eh_ctrl.region;
3710 /* Set REGION to be the region number for GIMPLE_RESX GS. */
3712 static inline void
3713 gimple_resx_set_region (gimple gs, int region)
3715 GIMPLE_CHECK (gs, GIMPLE_RESX);
3716 gs->gimple_eh_ctrl.region = region;
3719 /* Return the region number for GIMPLE_EH_DISPATCH GS. */
3721 static inline int
3722 gimple_eh_dispatch_region (const_gimple gs)
3724 GIMPLE_CHECK (gs, GIMPLE_EH_DISPATCH);
3725 return gs->gimple_eh_ctrl.region;
3728 /* Set REGION to be the region number for GIMPLE_EH_DISPATCH GS. */
3730 static inline void
3731 gimple_eh_dispatch_set_region (gimple gs, int region)
3733 GIMPLE_CHECK (gs, GIMPLE_EH_DISPATCH);
3734 gs->gimple_eh_ctrl.region = region;
3737 /* Return the number of labels associated with the switch statement GS. */
3739 static inline unsigned
3740 gimple_switch_num_labels (const_gimple gs)
3742 unsigned num_ops;
3743 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3744 num_ops = gimple_num_ops (gs);
3745 gcc_gimple_checking_assert (num_ops > 1);
3746 return num_ops - 1;
3750 /* Set NLABELS to be the number of labels for the switch statement GS. */
3752 static inline void
3753 gimple_switch_set_num_labels (gimple g, unsigned nlabels)
3755 GIMPLE_CHECK (g, GIMPLE_SWITCH);
3756 gimple_set_num_ops (g, nlabels + 1);
3760 /* Return the index variable used by the switch statement GS. */
3762 static inline tree
3763 gimple_switch_index (const_gimple gs)
3765 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3766 return gimple_op (gs, 0);
3770 /* Return a pointer to the index variable for the switch statement GS. */
3772 static inline tree *
3773 gimple_switch_index_ptr (const_gimple gs)
3775 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3776 return gimple_op_ptr (gs, 0);
3780 /* Set INDEX to be the index variable for switch statement GS. */
3782 static inline void
3783 gimple_switch_set_index (gimple gs, tree index)
3785 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3786 gcc_gimple_checking_assert (SSA_VAR_P (index) || CONSTANT_CLASS_P (index));
3787 gimple_set_op (gs, 0, index);
3791 /* Return the label numbered INDEX. The default label is 0, followed by any
3792 labels in a switch statement. */
3794 static inline tree
3795 gimple_switch_label (const_gimple gs, unsigned index)
3797 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3798 gcc_gimple_checking_assert (gimple_num_ops (gs) > index + 1);
3799 return gimple_op (gs, index + 1);
3802 /* Set the label number INDEX to LABEL. 0 is always the default label. */
3804 static inline void
3805 gimple_switch_set_label (gimple gs, unsigned index, tree label)
3807 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3808 gcc_gimple_checking_assert (gimple_num_ops (gs) > index + 1
3809 && (label == NULL_TREE
3810 || TREE_CODE (label) == CASE_LABEL_EXPR));
3811 gimple_set_op (gs, index + 1, label);
3814 /* Return the default label for a switch statement. */
3816 static inline tree
3817 gimple_switch_default_label (const_gimple gs)
3819 tree label = gimple_switch_label (gs, 0);
3820 gcc_checking_assert (!CASE_LOW (label) && !CASE_HIGH (label));
3821 return label;
3824 /* Set the default label for a switch statement. */
3826 static inline void
3827 gimple_switch_set_default_label (gimple gs, tree label)
3829 gcc_checking_assert (!CASE_LOW (label) && !CASE_HIGH (label));
3830 gimple_switch_set_label (gs, 0, label);
3833 /* Return true if GS is a GIMPLE_DEBUG statement. */
3835 static inline bool
3836 is_gimple_debug (const_gimple gs)
3838 return gimple_code (gs) == GIMPLE_DEBUG;
3841 /* Return true if S is a GIMPLE_DEBUG BIND statement. */
3843 static inline bool
3844 gimple_debug_bind_p (const_gimple s)
3846 if (is_gimple_debug (s))
3847 return s->gsbase.subcode == GIMPLE_DEBUG_BIND;
3849 return false;
3852 /* Return the variable bound in a GIMPLE_DEBUG bind statement. */
3854 static inline tree
3855 gimple_debug_bind_get_var (gimple dbg)
3857 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3858 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3859 return gimple_op (dbg, 0);
3862 /* Return the value bound to the variable in a GIMPLE_DEBUG bind
3863 statement. */
3865 static inline tree
3866 gimple_debug_bind_get_value (gimple dbg)
3868 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3869 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3870 return gimple_op (dbg, 1);
3873 /* Return a pointer to the value bound to the variable in a
3874 GIMPLE_DEBUG bind statement. */
3876 static inline tree *
3877 gimple_debug_bind_get_value_ptr (gimple dbg)
3879 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3880 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3881 return gimple_op_ptr (dbg, 1);
3884 /* Set the variable bound in a GIMPLE_DEBUG bind statement. */
3886 static inline void
3887 gimple_debug_bind_set_var (gimple dbg, tree var)
3889 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3890 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3891 gimple_set_op (dbg, 0, var);
3894 /* Set the value bound to the variable in a GIMPLE_DEBUG bind
3895 statement. */
3897 static inline void
3898 gimple_debug_bind_set_value (gimple dbg, tree value)
3900 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3901 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3902 gimple_set_op (dbg, 1, value);
3905 /* The second operand of a GIMPLE_DEBUG_BIND, when the value was
3906 optimized away. */
3907 #define GIMPLE_DEBUG_BIND_NOVALUE NULL_TREE /* error_mark_node */
3909 /* Remove the value bound to the variable in a GIMPLE_DEBUG bind
3910 statement. */
3912 static inline void
3913 gimple_debug_bind_reset_value (gimple dbg)
3915 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3916 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3917 gimple_set_op (dbg, 1, GIMPLE_DEBUG_BIND_NOVALUE);
3920 /* Return true if the GIMPLE_DEBUG bind statement is bound to a
3921 value. */
3923 static inline bool
3924 gimple_debug_bind_has_value_p (gimple dbg)
3926 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3927 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3928 return gimple_op (dbg, 1) != GIMPLE_DEBUG_BIND_NOVALUE;
3931 #undef GIMPLE_DEBUG_BIND_NOVALUE
3933 /* Return true if S is a GIMPLE_DEBUG SOURCE BIND statement. */
3935 static inline bool
3936 gimple_debug_source_bind_p (const_gimple s)
3938 if (is_gimple_debug (s))
3939 return s->gsbase.subcode == GIMPLE_DEBUG_SOURCE_BIND;
3941 return false;
3944 /* Return the variable bound in a GIMPLE_DEBUG source bind statement. */
3946 static inline tree
3947 gimple_debug_source_bind_get_var (gimple dbg)
3949 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3950 gcc_gimple_checking_assert (gimple_debug_source_bind_p (dbg));
3951 return gimple_op (dbg, 0);
3954 /* Return the value bound to the variable in a GIMPLE_DEBUG source bind
3955 statement. */
3957 static inline tree
3958 gimple_debug_source_bind_get_value (gimple dbg)
3960 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3961 gcc_gimple_checking_assert (gimple_debug_source_bind_p (dbg));
3962 return gimple_op (dbg, 1);
3965 /* Return a pointer to the value bound to the variable in a
3966 GIMPLE_DEBUG source bind statement. */
3968 static inline tree *
3969 gimple_debug_source_bind_get_value_ptr (gimple dbg)
3971 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3972 gcc_gimple_checking_assert (gimple_debug_source_bind_p (dbg));
3973 return gimple_op_ptr (dbg, 1);
3976 /* Set the variable bound in a GIMPLE_DEBUG source bind statement. */
3978 static inline void
3979 gimple_debug_source_bind_set_var (gimple dbg, tree var)
3981 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3982 gcc_gimple_checking_assert (gimple_debug_source_bind_p (dbg));
3983 gimple_set_op (dbg, 0, var);
3986 /* Set the value bound to the variable in a GIMPLE_DEBUG source bind
3987 statement. */
3989 static inline void
3990 gimple_debug_source_bind_set_value (gimple dbg, tree value)
3992 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3993 gcc_gimple_checking_assert (gimple_debug_source_bind_p (dbg));
3994 gimple_set_op (dbg, 1, value);
3997 /* Return the line number for EXPR, or return -1 if we have no line
3998 number information for it. */
3999 static inline int
4000 get_lineno (const_gimple stmt)
4002 location_t loc;
4004 if (!stmt)
4005 return -1;
4007 loc = gimple_location (stmt);
4008 if (loc == UNKNOWN_LOCATION)
4009 return -1;
4011 return LOCATION_LINE (loc);
4014 /* Return a pointer to the body for the OMP statement GS. */
4016 static inline gimple_seq *
4017 gimple_omp_body_ptr (gimple gs)
4019 return &gs->omp.body;
4022 /* Return the body for the OMP statement GS. */
4024 static inline gimple_seq
4025 gimple_omp_body (gimple gs)
4027 return *gimple_omp_body_ptr (gs);
4030 /* Set BODY to be the body for the OMP statement GS. */
4032 static inline void
4033 gimple_omp_set_body (gimple gs, gimple_seq body)
4035 gs->omp.body = body;
4039 /* Return the name associated with OMP_CRITICAL statement GS. */
4041 static inline tree
4042 gimple_omp_critical_name (const_gimple gs)
4044 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
4045 return gs->gimple_omp_critical.name;
4049 /* Return a pointer to the name associated with OMP critical statement GS. */
4051 static inline tree *
4052 gimple_omp_critical_name_ptr (gimple gs)
4054 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
4055 return &gs->gimple_omp_critical.name;
4059 /* Set NAME to be the name associated with OMP critical statement GS. */
4061 static inline void
4062 gimple_omp_critical_set_name (gimple gs, tree name)
4064 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
4065 gs->gimple_omp_critical.name = name;
4069 /* Return the kind of OMP for statemement. */
4071 static inline int
4072 gimple_omp_for_kind (const_gimple g)
4074 GIMPLE_CHECK (g, GIMPLE_OMP_FOR);
4075 return (gimple_omp_subcode (g) & GF_OMP_FOR_KIND_MASK);
4079 /* Set the OMP for kind. */
4081 static inline void
4082 gimple_omp_for_set_kind (gimple g, int kind)
4084 GIMPLE_CHECK (g, GIMPLE_OMP_FOR);
4085 g->gsbase.subcode = (g->gsbase.subcode & ~GF_OMP_FOR_KIND_MASK)
4086 | (kind & GF_OMP_FOR_KIND_MASK);
4090 /* Return true if OMP for statement G has the
4091 GF_OMP_FOR_COMBINED flag set. */
4093 static inline bool
4094 gimple_omp_for_combined_p (const_gimple g)
4096 GIMPLE_CHECK (g, GIMPLE_OMP_FOR);
4097 return (gimple_omp_subcode (g) & GF_OMP_FOR_COMBINED) != 0;
4101 /* Set the GF_OMP_FOR_COMBINED field in G depending on the boolean
4102 value of COMBINED_P. */
4104 static inline void
4105 gimple_omp_for_set_combined_p (gimple g, bool combined_p)
4107 GIMPLE_CHECK (g, GIMPLE_OMP_FOR);
4108 if (combined_p)
4109 g->gsbase.subcode |= GF_OMP_FOR_COMBINED;
4110 else
4111 g->gsbase.subcode &= ~GF_OMP_FOR_COMBINED;
4115 /* Return true if OMP for statement G has the
4116 GF_OMP_FOR_COMBINED_INTO flag set. */
4118 static inline bool
4119 gimple_omp_for_combined_into_p (const_gimple g)
4121 GIMPLE_CHECK (g, GIMPLE_OMP_FOR);
4122 return (gimple_omp_subcode (g) & GF_OMP_FOR_COMBINED_INTO) != 0;
4126 /* Set the GF_OMP_FOR_COMBINED_INTO field in G depending on the boolean
4127 value of COMBINED_P. */
4129 static inline void
4130 gimple_omp_for_set_combined_into_p (gimple g, bool combined_p)
4132 GIMPLE_CHECK (g, GIMPLE_OMP_FOR);
4133 if (combined_p)
4134 g->gsbase.subcode |= GF_OMP_FOR_COMBINED_INTO;
4135 else
4136 g->gsbase.subcode &= ~GF_OMP_FOR_COMBINED_INTO;
4140 /* Return the clauses associated with OMP_FOR GS. */
4142 static inline tree
4143 gimple_omp_for_clauses (const_gimple gs)
4145 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4146 return gs->gimple_omp_for.clauses;
4150 /* Return a pointer to the OMP_FOR GS. */
4152 static inline tree *
4153 gimple_omp_for_clauses_ptr (gimple gs)
4155 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4156 return &gs->gimple_omp_for.clauses;
4160 /* Set CLAUSES to be the list of clauses associated with OMP_FOR GS. */
4162 static inline void
4163 gimple_omp_for_set_clauses (gimple gs, tree clauses)
4165 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4166 gs->gimple_omp_for.clauses = clauses;
4170 /* Get the collapse count of OMP_FOR GS. */
4172 static inline size_t
4173 gimple_omp_for_collapse (gimple gs)
4175 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4176 return gs->gimple_omp_for.collapse;
4180 /* Return the index variable for OMP_FOR GS. */
4182 static inline tree
4183 gimple_omp_for_index (const_gimple gs, size_t i)
4185 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4186 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4187 return gs->gimple_omp_for.iter[i].index;
4191 /* Return a pointer to the index variable for OMP_FOR GS. */
4193 static inline tree *
4194 gimple_omp_for_index_ptr (gimple gs, size_t i)
4196 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4197 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4198 return &gs->gimple_omp_for.iter[i].index;
4202 /* Set INDEX to be the index variable for OMP_FOR GS. */
4204 static inline void
4205 gimple_omp_for_set_index (gimple gs, size_t i, tree index)
4207 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4208 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4209 gs->gimple_omp_for.iter[i].index = index;
4213 /* Return the initial value for OMP_FOR GS. */
4215 static inline tree
4216 gimple_omp_for_initial (const_gimple gs, size_t i)
4218 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4219 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4220 return gs->gimple_omp_for.iter[i].initial;
4224 /* Return a pointer to the initial value for OMP_FOR GS. */
4226 static inline tree *
4227 gimple_omp_for_initial_ptr (gimple gs, size_t i)
4229 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4230 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4231 return &gs->gimple_omp_for.iter[i].initial;
4235 /* Set INITIAL to be the initial value for OMP_FOR GS. */
4237 static inline void
4238 gimple_omp_for_set_initial (gimple gs, size_t i, tree initial)
4240 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4241 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4242 gs->gimple_omp_for.iter[i].initial = initial;
4246 /* Return the final value for OMP_FOR GS. */
4248 static inline tree
4249 gimple_omp_for_final (const_gimple gs, size_t i)
4251 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4252 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4253 return gs->gimple_omp_for.iter[i].final;
4257 /* Return a pointer to the final value for OMP_FOR GS. */
4259 static inline tree *
4260 gimple_omp_for_final_ptr (gimple gs, size_t i)
4262 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4263 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4264 return &gs->gimple_omp_for.iter[i].final;
4268 /* Set FINAL to be the final value for OMP_FOR GS. */
4270 static inline void
4271 gimple_omp_for_set_final (gimple gs, size_t i, tree final)
4273 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4274 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4275 gs->gimple_omp_for.iter[i].final = final;
4279 /* Return the increment value for OMP_FOR GS. */
4281 static inline tree
4282 gimple_omp_for_incr (const_gimple gs, size_t i)
4284 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4285 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4286 return gs->gimple_omp_for.iter[i].incr;
4290 /* Return a pointer to the increment value for OMP_FOR GS. */
4292 static inline tree *
4293 gimple_omp_for_incr_ptr (gimple gs, size_t i)
4295 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4296 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4297 return &gs->gimple_omp_for.iter[i].incr;
4301 /* Set INCR to be the increment value for OMP_FOR GS. */
4303 static inline void
4304 gimple_omp_for_set_incr (gimple gs, size_t i, tree incr)
4306 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4307 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4308 gs->gimple_omp_for.iter[i].incr = incr;
4312 /* Return a pointer to the sequence of statements to execute before the OMP_FOR
4313 statement GS starts. */
4315 static inline gimple_seq *
4316 gimple_omp_for_pre_body_ptr (gimple gs)
4318 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4319 return &gs->gimple_omp_for.pre_body;
4323 /* Return the sequence of statements to execute before the OMP_FOR
4324 statement GS starts. */
4326 static inline gimple_seq
4327 gimple_omp_for_pre_body (gimple gs)
4329 return *gimple_omp_for_pre_body_ptr (gs);
4333 /* Set PRE_BODY to be the sequence of statements to execute before the
4334 OMP_FOR statement GS starts. */
4336 static inline void
4337 gimple_omp_for_set_pre_body (gimple gs, gimple_seq pre_body)
4339 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4340 gs->gimple_omp_for.pre_body = pre_body;
4344 /* Return the clauses associated with OMP_PARALLEL GS. */
4346 static inline tree
4347 gimple_omp_parallel_clauses (const_gimple gs)
4349 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
4350 return gs->gimple_omp_parallel.clauses;
4354 /* Return a pointer to the clauses associated with OMP_PARALLEL GS. */
4356 static inline tree *
4357 gimple_omp_parallel_clauses_ptr (gimple gs)
4359 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
4360 return &gs->gimple_omp_parallel.clauses;
4364 /* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL
4365 GS. */
4367 static inline void
4368 gimple_omp_parallel_set_clauses (gimple gs, tree clauses)
4370 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
4371 gs->gimple_omp_parallel.clauses = clauses;
4375 /* Return the child function used to hold the body of OMP_PARALLEL GS. */
4377 static inline tree
4378 gimple_omp_parallel_child_fn (const_gimple gs)
4380 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
4381 return gs->gimple_omp_parallel.child_fn;
4384 /* Return a pointer to the child function used to hold the body of
4385 OMP_PARALLEL GS. */
4387 static inline tree *
4388 gimple_omp_parallel_child_fn_ptr (gimple gs)
4390 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
4391 return &gs->gimple_omp_parallel.child_fn;
4395 /* Set CHILD_FN to be the child function for OMP_PARALLEL GS. */
4397 static inline void
4398 gimple_omp_parallel_set_child_fn (gimple gs, tree child_fn)
4400 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
4401 gs->gimple_omp_parallel.child_fn = child_fn;
4405 /* Return the artificial argument used to send variables and values
4406 from the parent to the children threads in OMP_PARALLEL GS. */
4408 static inline tree
4409 gimple_omp_parallel_data_arg (const_gimple gs)
4411 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
4412 return gs->gimple_omp_parallel.data_arg;
4416 /* Return a pointer to the data argument for OMP_PARALLEL GS. */
4418 static inline tree *
4419 gimple_omp_parallel_data_arg_ptr (gimple gs)
4421 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
4422 return &gs->gimple_omp_parallel.data_arg;
4426 /* Set DATA_ARG to be the data argument for OMP_PARALLEL GS. */
4428 static inline void
4429 gimple_omp_parallel_set_data_arg (gimple gs, tree data_arg)
4431 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
4432 gs->gimple_omp_parallel.data_arg = data_arg;
4436 /* Return the clauses associated with OMP_TASK GS. */
4438 static inline tree
4439 gimple_omp_task_clauses (const_gimple gs)
4441 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4442 return gs->gimple_omp_parallel.clauses;
4446 /* Return a pointer to the clauses associated with OMP_TASK GS. */
4448 static inline tree *
4449 gimple_omp_task_clauses_ptr (gimple gs)
4451 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4452 return &gs->gimple_omp_parallel.clauses;
4456 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
4457 GS. */
4459 static inline void
4460 gimple_omp_task_set_clauses (gimple gs, tree clauses)
4462 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4463 gs->gimple_omp_parallel.clauses = clauses;
4467 /* Return the child function used to hold the body of OMP_TASK GS. */
4469 static inline tree
4470 gimple_omp_task_child_fn (const_gimple gs)
4472 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4473 return gs->gimple_omp_parallel.child_fn;
4476 /* Return a pointer to the child function used to hold the body of
4477 OMP_TASK GS. */
4479 static inline tree *
4480 gimple_omp_task_child_fn_ptr (gimple gs)
4482 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4483 return &gs->gimple_omp_parallel.child_fn;
4487 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
4489 static inline void
4490 gimple_omp_task_set_child_fn (gimple gs, tree child_fn)
4492 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4493 gs->gimple_omp_parallel.child_fn = child_fn;
4497 /* Return the artificial argument used to send variables and values
4498 from the parent to the children threads in OMP_TASK GS. */
4500 static inline tree
4501 gimple_omp_task_data_arg (const_gimple gs)
4503 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4504 return gs->gimple_omp_parallel.data_arg;
4508 /* Return a pointer to the data argument for OMP_TASK GS. */
4510 static inline tree *
4511 gimple_omp_task_data_arg_ptr (gimple gs)
4513 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4514 return &gs->gimple_omp_parallel.data_arg;
4518 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
4520 static inline void
4521 gimple_omp_task_set_data_arg (gimple gs, tree data_arg)
4523 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4524 gs->gimple_omp_parallel.data_arg = data_arg;
4528 /* Return the clauses associated with OMP_TASK GS. */
4530 static inline tree
4531 gimple_omp_taskreg_clauses (const_gimple gs)
4533 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4534 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4535 return gs->gimple_omp_parallel.clauses;
4539 /* Return a pointer to the clauses associated with OMP_TASK GS. */
4541 static inline tree *
4542 gimple_omp_taskreg_clauses_ptr (gimple gs)
4544 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4545 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4546 return &gs->gimple_omp_parallel.clauses;
4550 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
4551 GS. */
4553 static inline void
4554 gimple_omp_taskreg_set_clauses (gimple gs, tree clauses)
4556 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4557 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4558 gs->gimple_omp_parallel.clauses = clauses;
4562 /* Return the child function used to hold the body of OMP_TASK GS. */
4564 static inline tree
4565 gimple_omp_taskreg_child_fn (const_gimple gs)
4567 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4568 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4569 return gs->gimple_omp_parallel.child_fn;
4572 /* Return a pointer to the child function used to hold the body of
4573 OMP_TASK GS. */
4575 static inline tree *
4576 gimple_omp_taskreg_child_fn_ptr (gimple gs)
4578 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4579 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4580 return &gs->gimple_omp_parallel.child_fn;
4584 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
4586 static inline void
4587 gimple_omp_taskreg_set_child_fn (gimple gs, tree child_fn)
4589 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4590 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4591 gs->gimple_omp_parallel.child_fn = child_fn;
4595 /* Return the artificial argument used to send variables and values
4596 from the parent to the children threads in OMP_TASK GS. */
4598 static inline tree
4599 gimple_omp_taskreg_data_arg (const_gimple gs)
4601 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4602 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4603 return gs->gimple_omp_parallel.data_arg;
4607 /* Return a pointer to the data argument for OMP_TASK GS. */
4609 static inline tree *
4610 gimple_omp_taskreg_data_arg_ptr (gimple gs)
4612 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4613 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4614 return &gs->gimple_omp_parallel.data_arg;
4618 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
4620 static inline void
4621 gimple_omp_taskreg_set_data_arg (gimple gs, tree data_arg)
4623 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4624 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4625 gs->gimple_omp_parallel.data_arg = data_arg;
4629 /* Return the copy function used to hold the body of OMP_TASK GS. */
4631 static inline tree
4632 gimple_omp_task_copy_fn (const_gimple gs)
4634 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4635 return gs->gimple_omp_task.copy_fn;
4638 /* Return a pointer to the copy function used to hold the body of
4639 OMP_TASK GS. */
4641 static inline tree *
4642 gimple_omp_task_copy_fn_ptr (gimple gs)
4644 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4645 return &gs->gimple_omp_task.copy_fn;
4649 /* Set CHILD_FN to be the copy function for OMP_TASK GS. */
4651 static inline void
4652 gimple_omp_task_set_copy_fn (gimple gs, tree copy_fn)
4654 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4655 gs->gimple_omp_task.copy_fn = copy_fn;
4659 /* Return size of the data block in bytes in OMP_TASK GS. */
4661 static inline tree
4662 gimple_omp_task_arg_size (const_gimple gs)
4664 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4665 return gs->gimple_omp_task.arg_size;
4669 /* Return a pointer to the data block size for OMP_TASK GS. */
4671 static inline tree *
4672 gimple_omp_task_arg_size_ptr (gimple gs)
4674 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4675 return &gs->gimple_omp_task.arg_size;
4679 /* Set ARG_SIZE to be the data block size for OMP_TASK GS. */
4681 static inline void
4682 gimple_omp_task_set_arg_size (gimple gs, tree arg_size)
4684 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4685 gs->gimple_omp_task.arg_size = arg_size;
4689 /* Return align of the data block in bytes in OMP_TASK GS. */
4691 static inline tree
4692 gimple_omp_task_arg_align (const_gimple gs)
4694 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4695 return gs->gimple_omp_task.arg_align;
4699 /* Return a pointer to the data block align for OMP_TASK GS. */
4701 static inline tree *
4702 gimple_omp_task_arg_align_ptr (gimple gs)
4704 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4705 return &gs->gimple_omp_task.arg_align;
4709 /* Set ARG_SIZE to be the data block align for OMP_TASK GS. */
4711 static inline void
4712 gimple_omp_task_set_arg_align (gimple gs, tree arg_align)
4714 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4715 gs->gimple_omp_task.arg_align = arg_align;
4719 /* Return the clauses associated with OMP_SINGLE GS. */
4721 static inline tree
4722 gimple_omp_single_clauses (const_gimple gs)
4724 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
4725 return gs->gimple_omp_single.clauses;
4729 /* Return a pointer to the clauses associated with OMP_SINGLE GS. */
4731 static inline tree *
4732 gimple_omp_single_clauses_ptr (gimple gs)
4734 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
4735 return &gs->gimple_omp_single.clauses;
4739 /* Set CLAUSES to be the clauses associated with OMP_SINGLE GS. */
4741 static inline void
4742 gimple_omp_single_set_clauses (gimple gs, tree clauses)
4744 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
4745 gs->gimple_omp_single.clauses = clauses;
4749 /* Return the clauses associated with OMP_TARGET GS. */
4751 static inline tree
4752 gimple_omp_target_clauses (const_gimple gs)
4754 GIMPLE_CHECK (gs, GIMPLE_OMP_TARGET);
4755 return gs->gimple_omp_parallel.clauses;
4759 /* Return a pointer to the clauses associated with OMP_TARGET GS. */
4761 static inline tree *
4762 gimple_omp_target_clauses_ptr (gimple gs)
4764 GIMPLE_CHECK (gs, GIMPLE_OMP_TARGET);
4765 return &gs->gimple_omp_parallel.clauses;
4769 /* Set CLAUSES to be the clauses associated with OMP_TARGET GS. */
4771 static inline void
4772 gimple_omp_target_set_clauses (gimple gs, tree clauses)
4774 GIMPLE_CHECK (gs, GIMPLE_OMP_TARGET);
4775 gs->gimple_omp_parallel.clauses = clauses;
4779 /* Return the kind of OMP target statemement. */
4781 static inline int
4782 gimple_omp_target_kind (const_gimple g)
4784 GIMPLE_CHECK (g, GIMPLE_OMP_TARGET);
4785 return (gimple_omp_subcode (g) & GF_OMP_TARGET_KIND_MASK);
4789 /* Set the OMP target kind. */
4791 static inline void
4792 gimple_omp_target_set_kind (gimple g, int kind)
4794 GIMPLE_CHECK (g, GIMPLE_OMP_TARGET);
4795 g->gsbase.subcode = (g->gsbase.subcode & ~GF_OMP_TARGET_KIND_MASK)
4796 | (kind & GF_OMP_TARGET_KIND_MASK);
4800 /* Return the child function used to hold the body of OMP_TARGET GS. */
4802 static inline tree
4803 gimple_omp_target_child_fn (const_gimple gs)
4805 GIMPLE_CHECK (gs, GIMPLE_OMP_TARGET);
4806 return gs->gimple_omp_parallel.child_fn;
4809 /* Return a pointer to the child function used to hold the body of
4810 OMP_TARGET GS. */
4812 static inline tree *
4813 gimple_omp_target_child_fn_ptr (gimple gs)
4815 GIMPLE_CHECK (gs, GIMPLE_OMP_TARGET);
4816 return &gs->gimple_omp_parallel.child_fn;
4820 /* Set CHILD_FN to be the child function for OMP_TARGET GS. */
4822 static inline void
4823 gimple_omp_target_set_child_fn (gimple gs, tree child_fn)
4825 GIMPLE_CHECK (gs, GIMPLE_OMP_TARGET);
4826 gs->gimple_omp_parallel.child_fn = child_fn;
4830 /* Return the artificial argument used to send variables and values
4831 from the parent to the children threads in OMP_TARGET GS. */
4833 static inline tree
4834 gimple_omp_target_data_arg (const_gimple gs)
4836 GIMPLE_CHECK (gs, GIMPLE_OMP_TARGET);
4837 return gs->gimple_omp_parallel.data_arg;
4841 /* Return a pointer to the data argument for OMP_TARGET GS. */
4843 static inline tree *
4844 gimple_omp_target_data_arg_ptr (gimple gs)
4846 GIMPLE_CHECK (gs, GIMPLE_OMP_TARGET);
4847 return &gs->gimple_omp_parallel.data_arg;
4851 /* Set DATA_ARG to be the data argument for OMP_TARGET GS. */
4853 static inline void
4854 gimple_omp_target_set_data_arg (gimple gs, tree data_arg)
4856 GIMPLE_CHECK (gs, GIMPLE_OMP_TARGET);
4857 gs->gimple_omp_parallel.data_arg = data_arg;
4861 /* Return the clauses associated with OMP_TEAMS GS. */
4863 static inline tree
4864 gimple_omp_teams_clauses (const_gimple gs)
4866 GIMPLE_CHECK (gs, GIMPLE_OMP_TEAMS);
4867 return gs->gimple_omp_single.clauses;
4871 /* Return a pointer to the clauses associated with OMP_TEAMS GS. */
4873 static inline tree *
4874 gimple_omp_teams_clauses_ptr (gimple gs)
4876 GIMPLE_CHECK (gs, GIMPLE_OMP_TEAMS);
4877 return &gs->gimple_omp_single.clauses;
4881 /* Set CLAUSES to be the clauses associated with OMP_TEAMS GS. */
4883 static inline void
4884 gimple_omp_teams_set_clauses (gimple gs, tree clauses)
4886 GIMPLE_CHECK (gs, GIMPLE_OMP_TEAMS);
4887 gs->gimple_omp_single.clauses = clauses;
4891 /* Return the clauses associated with OMP_SECTIONS GS. */
4893 static inline tree
4894 gimple_omp_sections_clauses (const_gimple gs)
4896 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4897 return gs->gimple_omp_sections.clauses;
4901 /* Return a pointer to the clauses associated with OMP_SECTIONS GS. */
4903 static inline tree *
4904 gimple_omp_sections_clauses_ptr (gimple gs)
4906 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4907 return &gs->gimple_omp_sections.clauses;
4911 /* Set CLAUSES to be the set of clauses associated with OMP_SECTIONS
4912 GS. */
4914 static inline void
4915 gimple_omp_sections_set_clauses (gimple gs, tree clauses)
4917 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4918 gs->gimple_omp_sections.clauses = clauses;
4922 /* Return the control variable associated with the GIMPLE_OMP_SECTIONS
4923 in GS. */
4925 static inline tree
4926 gimple_omp_sections_control (const_gimple gs)
4928 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4929 return gs->gimple_omp_sections.control;
4933 /* Return a pointer to the clauses associated with the GIMPLE_OMP_SECTIONS
4934 GS. */
4936 static inline tree *
4937 gimple_omp_sections_control_ptr (gimple gs)
4939 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4940 return &gs->gimple_omp_sections.control;
4944 /* Set CONTROL to be the set of clauses associated with the
4945 GIMPLE_OMP_SECTIONS in GS. */
4947 static inline void
4948 gimple_omp_sections_set_control (gimple gs, tree control)
4950 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4951 gs->gimple_omp_sections.control = control;
4955 /* Set COND to be the condition code for OMP_FOR GS. */
4957 static inline void
4958 gimple_omp_for_set_cond (gimple gs, size_t i, enum tree_code cond)
4960 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4961 gcc_gimple_checking_assert (TREE_CODE_CLASS (cond) == tcc_comparison
4962 && i < gs->gimple_omp_for.collapse);
4963 gs->gimple_omp_for.iter[i].cond = cond;
4967 /* Return the condition code associated with OMP_FOR GS. */
4969 static inline enum tree_code
4970 gimple_omp_for_cond (const_gimple gs, size_t i)
4972 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4973 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4974 return gs->gimple_omp_for.iter[i].cond;
4978 /* Set the value being stored in an atomic store. */
4980 static inline void
4981 gimple_omp_atomic_store_set_val (gimple g, tree val)
4983 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4984 g->gimple_omp_atomic_store.val = val;
4988 /* Return the value being stored in an atomic store. */
4990 static inline tree
4991 gimple_omp_atomic_store_val (const_gimple g)
4993 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4994 return g->gimple_omp_atomic_store.val;
4998 /* Return a pointer to the value being stored in an atomic store. */
5000 static inline tree *
5001 gimple_omp_atomic_store_val_ptr (gimple g)
5003 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
5004 return &g->gimple_omp_atomic_store.val;
5008 /* Set the LHS of an atomic load. */
5010 static inline void
5011 gimple_omp_atomic_load_set_lhs (gimple g, tree lhs)
5013 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
5014 g->gimple_omp_atomic_load.lhs = lhs;
5018 /* Get the LHS of an atomic load. */
5020 static inline tree
5021 gimple_omp_atomic_load_lhs (const_gimple g)
5023 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
5024 return g->gimple_omp_atomic_load.lhs;
5028 /* Return a pointer to the LHS of an atomic load. */
5030 static inline tree *
5031 gimple_omp_atomic_load_lhs_ptr (gimple g)
5033 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
5034 return &g->gimple_omp_atomic_load.lhs;
5038 /* Set the RHS of an atomic load. */
5040 static inline void
5041 gimple_omp_atomic_load_set_rhs (gimple g, tree rhs)
5043 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
5044 g->gimple_omp_atomic_load.rhs = rhs;
5048 /* Get the RHS of an atomic load. */
5050 static inline tree
5051 gimple_omp_atomic_load_rhs (const_gimple g)
5053 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
5054 return g->gimple_omp_atomic_load.rhs;
5058 /* Return a pointer to the RHS of an atomic load. */
5060 static inline tree *
5061 gimple_omp_atomic_load_rhs_ptr (gimple g)
5063 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
5064 return &g->gimple_omp_atomic_load.rhs;
5068 /* Get the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
5070 static inline tree
5071 gimple_omp_continue_control_def (const_gimple g)
5073 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
5074 return g->gimple_omp_continue.control_def;
5077 /* The same as above, but return the address. */
5079 static inline tree *
5080 gimple_omp_continue_control_def_ptr (gimple g)
5082 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
5083 return &g->gimple_omp_continue.control_def;
5086 /* Set the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
5088 static inline void
5089 gimple_omp_continue_set_control_def (gimple g, tree def)
5091 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
5092 g->gimple_omp_continue.control_def = def;
5096 /* Get the use of the control variable in a GIMPLE_OMP_CONTINUE. */
5098 static inline tree
5099 gimple_omp_continue_control_use (const_gimple g)
5101 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
5102 return g->gimple_omp_continue.control_use;
5106 /* The same as above, but return the address. */
5108 static inline tree *
5109 gimple_omp_continue_control_use_ptr (gimple g)
5111 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
5112 return &g->gimple_omp_continue.control_use;
5116 /* Set the use of the control variable in a GIMPLE_OMP_CONTINUE. */
5118 static inline void
5119 gimple_omp_continue_set_control_use (gimple g, tree use)
5121 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
5122 g->gimple_omp_continue.control_use = use;
5125 /* Return a pointer to the body for the GIMPLE_TRANSACTION statement GS. */
5127 static inline gimple_seq *
5128 gimple_transaction_body_ptr (gimple gs)
5130 GIMPLE_CHECK (gs, GIMPLE_TRANSACTION);
5131 return &gs->gimple_transaction.body;
5134 /* Return the body for the GIMPLE_TRANSACTION statement GS. */
5136 static inline gimple_seq
5137 gimple_transaction_body (gimple gs)
5139 return *gimple_transaction_body_ptr (gs);
5142 /* Return the label associated with a GIMPLE_TRANSACTION. */
5144 static inline tree
5145 gimple_transaction_label (const_gimple gs)
5147 GIMPLE_CHECK (gs, GIMPLE_TRANSACTION);
5148 return gs->gimple_transaction.label;
5151 static inline tree *
5152 gimple_transaction_label_ptr (gimple gs)
5154 GIMPLE_CHECK (gs, GIMPLE_TRANSACTION);
5155 return &gs->gimple_transaction.label;
5158 /* Return the subcode associated with a GIMPLE_TRANSACTION. */
5160 static inline unsigned int
5161 gimple_transaction_subcode (const_gimple gs)
5163 GIMPLE_CHECK (gs, GIMPLE_TRANSACTION);
5164 return gs->gsbase.subcode;
5167 /* Set BODY to be the body for the GIMPLE_TRANSACTION statement GS. */
5169 static inline void
5170 gimple_transaction_set_body (gimple gs, gimple_seq body)
5172 GIMPLE_CHECK (gs, GIMPLE_TRANSACTION);
5173 gs->gimple_transaction.body = body;
5176 /* Set the label associated with a GIMPLE_TRANSACTION. */
5178 static inline void
5179 gimple_transaction_set_label (gimple gs, tree label)
5181 GIMPLE_CHECK (gs, GIMPLE_TRANSACTION);
5182 gs->gimple_transaction.label = label;
5185 /* Set the subcode associated with a GIMPLE_TRANSACTION. */
5187 static inline void
5188 gimple_transaction_set_subcode (gimple gs, unsigned int subcode)
5190 GIMPLE_CHECK (gs, GIMPLE_TRANSACTION);
5191 gs->gsbase.subcode = subcode;
5195 /* Return a pointer to the return value for GIMPLE_RETURN GS. */
5197 static inline tree *
5198 gimple_return_retval_ptr (const_gimple gs)
5200 GIMPLE_CHECK (gs, GIMPLE_RETURN);
5201 return gimple_op_ptr (gs, 0);
5204 /* Return the return value for GIMPLE_RETURN GS. */
5206 static inline tree
5207 gimple_return_retval (const_gimple gs)
5209 GIMPLE_CHECK (gs, GIMPLE_RETURN);
5210 return gimple_op (gs, 0);
5214 /* Set RETVAL to be the return value for GIMPLE_RETURN GS. */
5216 static inline void
5217 gimple_return_set_retval (gimple gs, tree retval)
5219 GIMPLE_CHECK (gs, GIMPLE_RETURN);
5220 gimple_set_op (gs, 0, retval);
5224 /* Returns true when the gimple statement STMT is any of the OpenMP types. */
5226 #define CASE_GIMPLE_OMP \
5227 case GIMPLE_OMP_PARALLEL: \
5228 case GIMPLE_OMP_TASK: \
5229 case GIMPLE_OMP_FOR: \
5230 case GIMPLE_OMP_SECTIONS: \
5231 case GIMPLE_OMP_SECTIONS_SWITCH: \
5232 case GIMPLE_OMP_SINGLE: \
5233 case GIMPLE_OMP_TARGET: \
5234 case GIMPLE_OMP_TEAMS: \
5235 case GIMPLE_OMP_SECTION: \
5236 case GIMPLE_OMP_MASTER: \
5237 case GIMPLE_OMP_TASKGROUP: \
5238 case GIMPLE_OMP_ORDERED: \
5239 case GIMPLE_OMP_CRITICAL: \
5240 case GIMPLE_OMP_RETURN: \
5241 case GIMPLE_OMP_ATOMIC_LOAD: \
5242 case GIMPLE_OMP_ATOMIC_STORE: \
5243 case GIMPLE_OMP_CONTINUE
5245 static inline bool
5246 is_gimple_omp (const_gimple stmt)
5248 switch (gimple_code (stmt))
5250 CASE_GIMPLE_OMP:
5251 return true;
5252 default:
5253 return false;
5258 /* Returns TRUE if statement G is a GIMPLE_NOP. */
5260 static inline bool
5261 gimple_nop_p (const_gimple g)
5263 return gimple_code (g) == GIMPLE_NOP;
5267 /* Return true if GS is a GIMPLE_RESX. */
5269 static inline bool
5270 is_gimple_resx (const_gimple gs)
5272 return gimple_code (gs) == GIMPLE_RESX;
5275 /* Return the predictor of GIMPLE_PREDICT statement GS. */
5277 static inline enum br_predictor
5278 gimple_predict_predictor (gimple gs)
5280 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
5281 return (enum br_predictor) (gs->gsbase.subcode & ~GF_PREDICT_TAKEN);
5285 /* Set the predictor of GIMPLE_PREDICT statement GS to PREDICT. */
5287 static inline void
5288 gimple_predict_set_predictor (gimple gs, enum br_predictor predictor)
5290 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
5291 gs->gsbase.subcode = (gs->gsbase.subcode & GF_PREDICT_TAKEN)
5292 | (unsigned) predictor;
5296 /* Return the outcome of GIMPLE_PREDICT statement GS. */
5298 static inline enum prediction
5299 gimple_predict_outcome (gimple gs)
5301 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
5302 return (gs->gsbase.subcode & GF_PREDICT_TAKEN) ? TAKEN : NOT_TAKEN;
5306 /* Set the outcome of GIMPLE_PREDICT statement GS to OUTCOME. */
5308 static inline void
5309 gimple_predict_set_outcome (gimple gs, enum prediction outcome)
5311 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
5312 if (outcome == TAKEN)
5313 gs->gsbase.subcode |= GF_PREDICT_TAKEN;
5314 else
5315 gs->gsbase.subcode &= ~GF_PREDICT_TAKEN;
5319 /* Return the type of the main expression computed by STMT. Return
5320 void_type_node if the statement computes nothing. */
5322 static inline tree
5323 gimple_expr_type (const_gimple stmt)
5325 enum gimple_code code = gimple_code (stmt);
5327 if (code == GIMPLE_ASSIGN || code == GIMPLE_CALL)
5329 tree type;
5330 /* In general we want to pass out a type that can be substituted
5331 for both the RHS and the LHS types if there is a possibly
5332 useless conversion involved. That means returning the
5333 original RHS type as far as we can reconstruct it. */
5334 if (code == GIMPLE_CALL)
5335 type = gimple_call_return_type (stmt);
5336 else
5337 switch (gimple_assign_rhs_code (stmt))
5339 case POINTER_PLUS_EXPR:
5340 type = TREE_TYPE (gimple_assign_rhs1 (stmt));
5341 break;
5343 default:
5344 /* As fallback use the type of the LHS. */
5345 type = TREE_TYPE (gimple_get_lhs (stmt));
5346 break;
5348 return type;
5350 else if (code == GIMPLE_COND)
5351 return boolean_type_node;
5352 else
5353 return void_type_node;
5356 /* Return true if TYPE is a suitable type for a scalar register variable. */
5358 static inline bool
5359 is_gimple_reg_type (tree type)
5361 return !AGGREGATE_TYPE_P (type);
5364 /* Return a new iterator pointing to GIMPLE_SEQ's first statement. */
5366 static inline gimple_stmt_iterator
5367 gsi_start_1 (gimple_seq *seq)
5369 gimple_stmt_iterator i;
5371 i.ptr = gimple_seq_first (*seq);
5372 i.seq = seq;
5373 i.bb = i.ptr ? gimple_bb (i.ptr) : NULL;
5375 return i;
5378 #define gsi_start(x) gsi_start_1 (&(x))
5380 static inline gimple_stmt_iterator
5381 gsi_none (void)
5383 gimple_stmt_iterator i;
5384 i.ptr = NULL;
5385 i.seq = NULL;
5386 i.bb = NULL;
5387 return i;
5390 /* Return a new iterator pointing to the first statement in basic block BB. */
5392 static inline gimple_stmt_iterator
5393 gsi_start_bb (basic_block bb)
5395 gimple_stmt_iterator i;
5396 gimple_seq *seq;
5398 seq = bb_seq_addr (bb);
5399 i.ptr = gimple_seq_first (*seq);
5400 i.seq = seq;
5401 i.bb = bb;
5403 return i;
5407 /* Return a new iterator initially pointing to GIMPLE_SEQ's last statement. */
5409 static inline gimple_stmt_iterator
5410 gsi_last_1 (gimple_seq *seq)
5412 gimple_stmt_iterator i;
5414 i.ptr = gimple_seq_last (*seq);
5415 i.seq = seq;
5416 i.bb = i.ptr ? gimple_bb (i.ptr) : NULL;
5418 return i;
5421 #define gsi_last(x) gsi_last_1 (&(x))
5423 /* Return a new iterator pointing to the last statement in basic block BB. */
5425 static inline gimple_stmt_iterator
5426 gsi_last_bb (basic_block bb)
5428 gimple_stmt_iterator i;
5429 gimple_seq *seq;
5431 seq = bb_seq_addr (bb);
5432 i.ptr = gimple_seq_last (*seq);
5433 i.seq = seq;
5434 i.bb = bb;
5436 return i;
5440 /* Return true if I is at the end of its sequence. */
5442 static inline bool
5443 gsi_end_p (gimple_stmt_iterator i)
5445 return i.ptr == NULL;
5449 /* Return true if I is one statement before the end of its sequence. */
5451 static inline bool
5452 gsi_one_before_end_p (gimple_stmt_iterator i)
5454 return i.ptr != NULL && i.ptr->gsbase.next == NULL;
5458 /* Advance the iterator to the next gimple statement. */
5460 static inline void
5461 gsi_next (gimple_stmt_iterator *i)
5463 i->ptr = i->ptr->gsbase.next;
5466 /* Advance the iterator to the previous gimple statement. */
5468 static inline void
5469 gsi_prev (gimple_stmt_iterator *i)
5471 gimple prev = i->ptr->gsbase.prev;
5472 if (prev->gsbase.next)
5473 i->ptr = prev;
5474 else
5475 i->ptr = NULL;
5478 /* Return the current stmt. */
5480 static inline gimple
5481 gsi_stmt (gimple_stmt_iterator i)
5483 return i.ptr;
5486 /* Return a block statement iterator that points to the first non-label
5487 statement in block BB. */
5489 static inline gimple_stmt_iterator
5490 gsi_after_labels (basic_block bb)
5492 gimple_stmt_iterator gsi = gsi_start_bb (bb);
5494 while (!gsi_end_p (gsi) && gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL)
5495 gsi_next (&gsi);
5497 return gsi;
5500 /* Advance the iterator to the next non-debug gimple statement. */
5502 static inline void
5503 gsi_next_nondebug (gimple_stmt_iterator *i)
5507 gsi_next (i);
5509 while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
5512 /* Advance the iterator to the next non-debug gimple statement. */
5514 static inline void
5515 gsi_prev_nondebug (gimple_stmt_iterator *i)
5519 gsi_prev (i);
5521 while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
5524 /* Return a new iterator pointing to the first non-debug statement in
5525 basic block BB. */
5527 static inline gimple_stmt_iterator
5528 gsi_start_nondebug_bb (basic_block bb)
5530 gimple_stmt_iterator i = gsi_start_bb (bb);
5532 if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
5533 gsi_next_nondebug (&i);
5535 return i;
5538 /* Return a new iterator pointing to the last non-debug statement in
5539 basic block BB. */
5541 static inline gimple_stmt_iterator
5542 gsi_last_nondebug_bb (basic_block bb)
5544 gimple_stmt_iterator i = gsi_last_bb (bb);
5546 if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
5547 gsi_prev_nondebug (&i);
5549 return i;
5553 /* Return the basic block associated with this iterator. */
5555 static inline basic_block
5556 gsi_bb (gimple_stmt_iterator i)
5558 return i.bb;
5562 /* Return the sequence associated with this iterator. */
5564 static inline gimple_seq
5565 gsi_seq (gimple_stmt_iterator i)
5567 return *i.seq;
5571 enum gsi_iterator_update
5573 GSI_NEW_STMT, /* Only valid when single statement is added, move
5574 iterator to it. */
5575 GSI_SAME_STMT, /* Leave the iterator at the same statement. */
5576 GSI_CONTINUE_LINKING /* Move iterator to whatever position is suitable
5577 for linking other statements in the same
5578 direction. */
5581 /* In gimple-iterator.c */
5582 gimple_stmt_iterator gsi_start_phis (basic_block);
5583 gimple_seq gsi_split_seq_after (gimple_stmt_iterator);
5584 void gsi_split_seq_before (gimple_stmt_iterator *, gimple_seq *);
5585 void gsi_set_stmt (gimple_stmt_iterator *, gimple);
5586 void gsi_replace (gimple_stmt_iterator *, gimple, bool);
5587 void gsi_replace_with_seq (gimple_stmt_iterator *, gimple_seq, bool);
5588 void gsi_insert_before (gimple_stmt_iterator *, gimple,
5589 enum gsi_iterator_update);
5590 void gsi_insert_before_without_update (gimple_stmt_iterator *, gimple,
5591 enum gsi_iterator_update);
5592 void gsi_insert_seq_before (gimple_stmt_iterator *, gimple_seq,
5593 enum gsi_iterator_update);
5594 void gsi_insert_seq_before_without_update (gimple_stmt_iterator *, gimple_seq,
5595 enum gsi_iterator_update);
5596 void gsi_insert_after (gimple_stmt_iterator *, gimple,
5597 enum gsi_iterator_update);
5598 void gsi_insert_after_without_update (gimple_stmt_iterator *, gimple,
5599 enum gsi_iterator_update);
5600 void gsi_insert_seq_after (gimple_stmt_iterator *, gimple_seq,
5601 enum gsi_iterator_update);
5602 void gsi_insert_seq_after_without_update (gimple_stmt_iterator *, gimple_seq,
5603 enum gsi_iterator_update);
5604 bool gsi_remove (gimple_stmt_iterator *, bool);
5605 gimple_stmt_iterator gsi_for_stmt (gimple);
5606 void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *);
5607 void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *);
5608 void gsi_move_to_bb_end (gimple_stmt_iterator *, basic_block);
5609 void gsi_insert_on_edge (edge, gimple);
5610 void gsi_insert_seq_on_edge (edge, gimple_seq);
5611 basic_block gsi_insert_on_edge_immediate (edge, gimple);
5612 basic_block gsi_insert_seq_on_edge_immediate (edge, gimple_seq);
5613 void gsi_commit_one_edge_insert (edge, basic_block *);
5614 void gsi_commit_edge_inserts (void);
5615 gimple gimple_call_copy_skip_args (gimple, bitmap);
5617 /* In gimplify.c. */
5618 tree force_gimple_operand_1 (tree, gimple_seq *, gimple_predicate, tree);
5619 tree force_gimple_operand (tree, gimple_seq *, bool, tree);
5620 tree force_gimple_operand_gsi_1 (gimple_stmt_iterator *, tree,
5621 gimple_predicate, tree,
5622 bool, enum gsi_iterator_update);
5623 tree force_gimple_operand_gsi (gimple_stmt_iterator *, tree, bool, tree,
5624 bool, enum gsi_iterator_update);
5626 /* Convenience routines to walk all statements of a gimple function.
5627 Note that this is useful exclusively before the code is converted
5628 into SSA form. Once the program is in SSA form, the standard
5629 operand interface should be used to analyze/modify statements. */
5630 struct walk_stmt_info
5632 /* Points to the current statement being walked. */
5633 gimple_stmt_iterator gsi;
5635 /* Additional data that the callback functions may want to carry
5636 through the recursion. */
5637 void *info;
5639 /* Pointer map used to mark visited tree nodes when calling
5640 walk_tree on each operand. If set to NULL, duplicate tree nodes
5641 will be visited more than once. */
5642 struct pointer_set_t *pset;
5644 /* Operand returned by the callbacks. This is set when calling
5645 walk_gimple_seq. If the walk_stmt_fn or walk_tree_fn callback
5646 returns non-NULL, this field will contain the tree returned by
5647 the last callback. */
5648 tree callback_result;
5650 /* Indicates whether the operand being examined may be replaced
5651 with something that matches is_gimple_val (if true) or something
5652 slightly more complicated (if false). "Something" technically
5653 means the common subset of is_gimple_lvalue and is_gimple_rhs,
5654 but we never try to form anything more complicated than that, so
5655 we don't bother checking.
5657 Also note that CALLBACK should update this flag while walking the
5658 sub-expressions of a statement. For instance, when walking the
5659 statement 'foo (&var)', the flag VAL_ONLY will initially be set
5660 to true, however, when walking &var, the operand of that
5661 ADDR_EXPR does not need to be a GIMPLE value. */
5662 BOOL_BITFIELD val_only : 1;
5664 /* True if we are currently walking the LHS of an assignment. */
5665 BOOL_BITFIELD is_lhs : 1;
5667 /* Optional. Set to true by the callback functions if they made any
5668 changes. */
5669 BOOL_BITFIELD changed : 1;
5671 /* True if we're interested in location information. */
5672 BOOL_BITFIELD want_locations : 1;
5674 /* True if we've removed the statement that was processed. */
5675 BOOL_BITFIELD removed_stmt : 1;
5678 /* Callback for walk_gimple_stmt. Called for every statement found
5679 during traversal. The first argument points to the statement to
5680 walk. The second argument is a flag that the callback sets to
5681 'true' if it the callback handled all the operands and
5682 sub-statements of the statement (the default value of this flag is
5683 'false'). The third argument is an anonymous pointer to data
5684 to be used by the callback. */
5685 typedef tree (*walk_stmt_fn) (gimple_stmt_iterator *, bool *,
5686 struct walk_stmt_info *);
5688 gimple walk_gimple_seq (gimple_seq, walk_stmt_fn, walk_tree_fn,
5689 struct walk_stmt_info *);
5690 gimple walk_gimple_seq_mod (gimple_seq *, walk_stmt_fn, walk_tree_fn,
5691 struct walk_stmt_info *);
5692 tree walk_gimple_stmt (gimple_stmt_iterator *, walk_stmt_fn, walk_tree_fn,
5693 struct walk_stmt_info *);
5694 tree walk_gimple_op (gimple, walk_tree_fn, struct walk_stmt_info *);
5696 /* Enum and arrays used for allocation stats. Keep in sync with
5697 gimple.c:gimple_alloc_kind_names. */
5698 enum gimple_alloc_kind
5700 gimple_alloc_kind_assign, /* Assignments. */
5701 gimple_alloc_kind_phi, /* PHI nodes. */
5702 gimple_alloc_kind_cond, /* Conditionals. */
5703 gimple_alloc_kind_rest, /* Everything else. */
5704 gimple_alloc_kind_all
5707 extern int gimple_alloc_counts[];
5708 extern int gimple_alloc_sizes[];
5710 /* Return the allocation kind for a given stmt CODE. */
5711 static inline enum gimple_alloc_kind
5712 gimple_alloc_kind (enum gimple_code code)
5714 switch (code)
5716 case GIMPLE_ASSIGN:
5717 return gimple_alloc_kind_assign;
5718 case GIMPLE_PHI:
5719 return gimple_alloc_kind_phi;
5720 case GIMPLE_COND:
5721 return gimple_alloc_kind_cond;
5722 default:
5723 return gimple_alloc_kind_rest;
5727 extern void dump_gimple_statistics (void);
5729 /* Set the location of all statements in SEQ to LOC. */
5731 static inline void
5732 gimple_seq_set_location (gimple_seq seq, location_t loc)
5734 for (gimple_stmt_iterator i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
5735 gimple_set_location (gsi_stmt (i), loc);
5738 /* Macros for showing usage statistics. */
5739 #define SCALE(x) ((unsigned long) ((x) < 1024*10 \
5740 ? (x) \
5741 : ((x) < 1024*1024*10 \
5742 ? (x) / 1024 \
5743 : (x) / (1024*1024))))
5745 #define LABEL(x) ((x) < 1024*10 ? 'b' : ((x) < 1024*1024*10 ? 'k' : 'M'))
5747 #define PERCENT(x,y) ((float)(x) * 100.0 / (float)(y))
5749 #endif /* GCC_GIMPLE_H */