re PR tree-optimization/58143 (wrong code at -O3)
[official-gcc.git] / gcc / gimple.h
blobc0c19ce995a9c29a2a398a650aa6ddecca4f2fa6
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.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 scalar register variable. */
851 extern bool is_gimple_reg (tree);
852 /* Returns true iff T is any sort of variable. */
853 extern bool is_gimple_variable (tree);
854 /* Returns true iff T is any sort of symbol. */
855 extern bool is_gimple_id (tree);
856 /* Returns true iff T is a variable or an INDIRECT_REF (of a variable). */
857 extern bool is_gimple_min_lval (tree);
858 /* Returns true iff T is something whose address can be taken. */
859 extern bool is_gimple_addressable (tree);
860 /* Returns true iff T is any valid GIMPLE lvalue. */
861 extern bool is_gimple_lvalue (tree);
863 /* Returns true iff T is a GIMPLE address. */
864 bool is_gimple_address (const_tree);
865 /* Returns true iff T is a GIMPLE invariant address. */
866 bool is_gimple_invariant_address (const_tree);
867 /* Returns true iff T is a GIMPLE invariant address at interprocedural
868 level. */
869 bool is_gimple_ip_invariant_address (const_tree);
870 /* Returns true iff T is a valid GIMPLE constant. */
871 bool is_gimple_constant (const_tree);
872 /* Returns true iff T is a GIMPLE restricted function invariant. */
873 extern bool is_gimple_min_invariant (const_tree);
874 /* Returns true iff T is a GIMPLE restricted interprecodural invariant. */
875 extern bool is_gimple_ip_invariant (const_tree);
876 /* Returns true iff T is a GIMPLE rvalue. */
877 extern bool is_gimple_val (tree);
878 /* Returns true iff T is a GIMPLE asm statement input. */
879 extern bool is_gimple_asm_val (tree);
880 /* Returns true iff T is a valid address operand of a MEM_REF. */
881 bool is_gimple_mem_ref_addr (tree);
883 /* Returns true iff T is a valid if-statement condition. */
884 extern bool is_gimple_condexpr (tree);
886 /* Returns true iff T is a valid call address expression. */
887 extern bool is_gimple_call_addr (tree);
889 /* Return TRUE iff stmt is a call to a built-in function. */
890 extern bool is_gimple_builtin_call (gimple stmt);
892 extern void recalculate_side_effects (tree);
893 extern bool gimple_compare_field_offset (tree, tree);
894 extern tree gimple_unsigned_type (tree);
895 extern tree gimple_signed_type (tree);
896 extern alias_set_type gimple_get_alias_set (tree);
897 extern bool walk_stmt_load_store_addr_ops (gimple, void *,
898 bool (*)(gimple, tree, void *),
899 bool (*)(gimple, tree, void *),
900 bool (*)(gimple, tree, void *));
901 extern bool walk_stmt_load_store_ops (gimple, void *,
902 bool (*)(gimple, tree, void *),
903 bool (*)(gimple, tree, void *));
904 extern bool gimple_ior_addresses_taken (bitmap, gimple);
905 extern bool gimple_call_builtin_p (gimple, enum built_in_class);
906 extern bool gimple_call_builtin_p (gimple, enum built_in_function);
907 extern bool gimple_asm_clobbers_memory_p (const_gimple);
908 extern bool useless_type_conversion_p (tree, tree);
909 extern bool types_compatible_p (tree, tree);
911 /* In gimplify.c */
912 extern tree create_tmp_var_raw (tree, const char *);
913 extern tree create_tmp_var_name (const char *);
914 extern tree create_tmp_var (tree, const char *);
915 extern tree create_tmp_reg (tree, const char *);
916 extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq *);
917 extern tree get_formal_tmp_var (tree, gimple_seq *);
918 extern void declare_vars (tree, gimple, bool);
919 extern void annotate_all_with_location (gimple_seq, location_t);
921 /* Validation of GIMPLE expressions. Note that these predicates only check
922 the basic form of the expression, they don't recurse to make sure that
923 underlying nodes are also of the right form. */
924 typedef bool (*gimple_predicate)(tree);
927 /* FIXME we should deduce this from the predicate. */
928 enum fallback {
929 fb_none = 0, /* Do not generate a temporary. */
931 fb_rvalue = 1, /* Generate an rvalue to hold the result of a
932 gimplified expression. */
934 fb_lvalue = 2, /* Generate an lvalue to hold the result of a
935 gimplified expression. */
937 fb_mayfail = 4, /* Gimplification may fail. Error issued
938 afterwards. */
939 fb_either= fb_rvalue | fb_lvalue
942 typedef int fallback_t;
944 enum gimplify_status {
945 GS_ERROR = -2, /* Something Bad Seen. */
946 GS_UNHANDLED = -1, /* A langhook result for "I dunno". */
947 GS_OK = 0, /* We did something, maybe more to do. */
948 GS_ALL_DONE = 1 /* The expression is fully gimplified. */
951 /* Formal (expression) temporary table handling: multiple occurrences of
952 the same scalar expression are evaluated into the same temporary. */
954 typedef struct gimple_temp_hash_elt
956 tree val; /* Key */
957 tree temp; /* Value */
958 } elt_t;
960 /* Gimplify hashtable helper. */
962 struct gimplify_hasher : typed_free_remove <elt_t>
964 typedef elt_t value_type;
965 typedef elt_t compare_type;
966 static inline hashval_t hash (const value_type *);
967 static inline bool equal (const value_type *, const compare_type *);
970 inline hashval_t
971 gimplify_hasher::hash (const value_type *p)
973 tree t = p->val;
974 return iterative_hash_expr (t, 0);
977 inline bool
978 gimplify_hasher::equal (const value_type *p1, const compare_type *p2)
980 tree t1 = p1->val;
981 tree t2 = p2->val;
982 enum tree_code code = TREE_CODE (t1);
984 if (TREE_CODE (t2) != code
985 || TREE_TYPE (t1) != TREE_TYPE (t2))
986 return false;
988 if (!operand_equal_p (t1, t2, 0))
989 return false;
991 #ifdef ENABLE_CHECKING
992 /* Only allow them to compare equal if they also hash equal; otherwise
993 results are nondeterminate, and we fail bootstrap comparison. */
994 gcc_assert (hash (p1) == hash (p2));
995 #endif
997 return true;
1000 struct gimplify_ctx
1002 struct gimplify_ctx *prev_context;
1004 vec<gimple> bind_expr_stack;
1005 tree temps;
1006 gimple_seq conditional_cleanups;
1007 tree exit_label;
1008 tree return_temp;
1010 vec<tree> case_labels;
1011 /* The formal temporary table. Should this be persistent? */
1012 hash_table <gimplify_hasher> temp_htab;
1014 int conditions;
1015 bool save_stack;
1016 bool into_ssa;
1017 bool allow_rhs_cond_expr;
1018 bool in_cleanup_point_expr;
1021 /* Return true if gimplify_one_sizepos doesn't need to gimplify
1022 expr (when in TYPE_SIZE{,_UNIT} and similar type/decl size/bitsize
1023 fields). */
1024 static inline bool
1025 is_gimple_sizepos (tree expr)
1027 /* gimplify_one_sizepos doesn't need to do anything if the value isn't there,
1028 is constant, or contains A PLACEHOLDER_EXPR. We also don't want to do
1029 anything if it's already a VAR_DECL. If it's a VAR_DECL from another
1030 function, the gimplifier will want to replace it with a new variable,
1031 but that will cause problems if this type is from outside the function.
1032 It's OK to have that here. */
1033 return (expr == NULL_TREE
1034 || TREE_CONSTANT (expr)
1035 || TREE_CODE (expr) == VAR_DECL
1036 || CONTAINS_PLACEHOLDER_P (expr));
1039 /* Get the number of the next statement uid to be allocated. */
1040 static inline unsigned int
1041 gimple_stmt_max_uid (struct function *fn)
1043 return fn->last_stmt_uid;
1046 /* Set the number of the next statement uid to be allocated. */
1047 static inline void
1048 set_gimple_stmt_max_uid (struct function *fn, unsigned int maxid)
1050 fn->last_stmt_uid = maxid;
1053 /* Set the number of the next statement uid to be allocated. */
1054 static inline unsigned int
1055 inc_gimple_stmt_max_uid (struct function *fn)
1057 return fn->last_stmt_uid++;
1060 extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *,
1061 bool (*) (tree), fallback_t);
1062 extern void gimplify_type_sizes (tree, gimple_seq *);
1063 extern void gimplify_one_sizepos (tree *, gimple_seq *);
1064 enum gimplify_status gimplify_self_mod_expr (tree *, gimple_seq *, gimple_seq *,
1065 bool, tree);
1066 extern bool gimplify_stmt (tree *, gimple_seq *);
1067 extern gimple gimplify_body (tree, bool);
1068 extern void push_gimplify_context (struct gimplify_ctx *);
1069 extern void pop_gimplify_context (gimple);
1070 extern void gimplify_and_add (tree, gimple_seq *);
1072 /* Miscellaneous helpers. */
1073 extern void gimple_add_tmp_var (tree);
1074 extern gimple gimple_current_bind_expr (void);
1075 extern vec<gimple> gimple_bind_expr_stack (void);
1076 extern tree voidify_wrapper_expr (tree, tree);
1077 extern tree build_and_jump (tree *);
1078 extern tree force_labels_r (tree *, int *, void *);
1079 extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *,
1080 gimple_seq *);
1081 struct gimplify_omp_ctx;
1082 extern void omp_firstprivatize_variable (struct gimplify_omp_ctx *, tree);
1083 extern tree gimple_boolify (tree);
1084 extern gimple_predicate rhs_predicate_for (tree);
1085 extern tree canonicalize_cond_expr_cond (tree);
1086 extern void dump_decl_set (FILE *, bitmap);
1087 extern bool gimple_can_coalesce_p (tree, tree);
1088 extern bool nonfreeing_call_p (gimple);
1090 /* In omp-low.c. */
1091 extern tree omp_reduction_init (tree, tree);
1093 /* In trans-mem.c. */
1094 extern void diagnose_tm_safe_errors (tree);
1095 extern void compute_transaction_bits (void);
1097 /* In tree-nested.c. */
1098 extern void lower_nested_functions (tree);
1099 extern void insert_field_into_struct (tree, tree);
1101 /* In gimplify.c. */
1102 extern void gimplify_function_tree (tree);
1104 /* In cfgexpand.c. */
1105 extern tree gimple_assign_rhs_to_tree (gimple);
1107 /* In builtins.c */
1108 extern bool validate_gimple_arglist (const_gimple, ...);
1110 /* Return the first node in GIMPLE sequence S. */
1112 static inline gimple_seq_node
1113 gimple_seq_first (gimple_seq s)
1115 return s;
1119 /* Return the first statement in GIMPLE sequence S. */
1121 static inline gimple
1122 gimple_seq_first_stmt (gimple_seq s)
1124 gimple_seq_node n = gimple_seq_first (s);
1125 return n;
1129 /* Return the last node in GIMPLE sequence S. */
1131 static inline gimple_seq_node
1132 gimple_seq_last (gimple_seq s)
1134 return s ? s->gsbase.prev : NULL;
1138 /* Return the last statement in GIMPLE sequence S. */
1140 static inline gimple
1141 gimple_seq_last_stmt (gimple_seq s)
1143 gimple_seq_node n = gimple_seq_last (s);
1144 return n;
1148 /* Set the last node in GIMPLE sequence *PS to LAST. */
1150 static inline void
1151 gimple_seq_set_last (gimple_seq *ps, gimple_seq_node last)
1153 (*ps)->gsbase.prev = last;
1157 /* Set the first node in GIMPLE sequence *PS to FIRST. */
1159 static inline void
1160 gimple_seq_set_first (gimple_seq *ps, gimple_seq_node first)
1162 *ps = first;
1166 /* Return true if GIMPLE sequence S is empty. */
1168 static inline bool
1169 gimple_seq_empty_p (gimple_seq s)
1171 return s == NULL;
1174 void gimple_seq_add_stmt (gimple_seq *, gimple);
1176 /* Link gimple statement GS to the end of the sequence *SEQ_P. If
1177 *SEQ_P is NULL, a new sequence is allocated. This function is
1178 similar to gimple_seq_add_stmt, but does not scan the operands.
1179 During gimplification, we need to manipulate statement sequences
1180 before the def/use vectors have been constructed. */
1181 void gimple_seq_add_stmt_without_update (gimple_seq *, gimple);
1183 /* Allocate a new sequence and initialize its first element with STMT. */
1185 static inline gimple_seq
1186 gimple_seq_alloc_with_stmt (gimple stmt)
1188 gimple_seq seq = NULL;
1189 gimple_seq_add_stmt (&seq, stmt);
1190 return seq;
1194 /* Returns the sequence of statements in BB. */
1196 static inline gimple_seq
1197 bb_seq (const_basic_block bb)
1199 return (!(bb->flags & BB_RTL)) ? bb->il.gimple.seq : NULL;
1202 static inline gimple_seq *
1203 bb_seq_addr (basic_block bb)
1205 return (!(bb->flags & BB_RTL)) ? &bb->il.gimple.seq : NULL;
1208 /* Sets the sequence of statements in BB to SEQ. */
1210 static inline void
1211 set_bb_seq (basic_block bb, gimple_seq seq)
1213 gcc_checking_assert (!(bb->flags & BB_RTL));
1214 bb->il.gimple.seq = seq;
1218 /* Return the code for GIMPLE statement G. */
1220 static inline enum gimple_code
1221 gimple_code (const_gimple g)
1223 return g->gsbase.code;
1227 /* Return the GSS code used by a GIMPLE code. */
1229 static inline enum gimple_statement_structure_enum
1230 gss_for_code (enum gimple_code code)
1232 gcc_gimple_checking_assert ((unsigned int)code < LAST_AND_UNUSED_GIMPLE_CODE);
1233 return gss_for_code_[code];
1237 /* Return which GSS code is used by GS. */
1239 static inline enum gimple_statement_structure_enum
1240 gimple_statement_structure (gimple gs)
1242 return gss_for_code (gimple_code (gs));
1246 /* Return true if statement G has sub-statements. This is only true for
1247 High GIMPLE statements. */
1249 static inline bool
1250 gimple_has_substatements (gimple g)
1252 switch (gimple_code (g))
1254 case GIMPLE_BIND:
1255 case GIMPLE_CATCH:
1256 case GIMPLE_EH_FILTER:
1257 case GIMPLE_EH_ELSE:
1258 case GIMPLE_TRY:
1259 case GIMPLE_OMP_FOR:
1260 case GIMPLE_OMP_MASTER:
1261 case GIMPLE_OMP_TASKGROUP:
1262 case GIMPLE_OMP_ORDERED:
1263 case GIMPLE_OMP_SECTION:
1264 case GIMPLE_OMP_PARALLEL:
1265 case GIMPLE_OMP_TASK:
1266 case GIMPLE_OMP_SECTIONS:
1267 case GIMPLE_OMP_SINGLE:
1268 case GIMPLE_OMP_TARGET:
1269 case GIMPLE_OMP_TEAMS:
1270 case GIMPLE_OMP_CRITICAL:
1271 case GIMPLE_WITH_CLEANUP_EXPR:
1272 case GIMPLE_TRANSACTION:
1273 return true;
1275 default:
1276 return false;
1281 /* Return the basic block holding statement G. */
1283 static inline basic_block
1284 gimple_bb (const_gimple g)
1286 return g->gsbase.bb;
1290 /* Return the lexical scope block holding statement G. */
1292 static inline tree
1293 gimple_block (const_gimple g)
1295 return LOCATION_BLOCK (g->gsbase.location);
1299 /* Set BLOCK to be the lexical scope block holding statement G. */
1301 static inline void
1302 gimple_set_block (gimple g, tree block)
1304 if (block)
1305 g->gsbase.location =
1306 COMBINE_LOCATION_DATA (line_table, g->gsbase.location, block);
1307 else
1308 g->gsbase.location = LOCATION_LOCUS (g->gsbase.location);
1312 /* Return location information for statement G. */
1314 static inline location_t
1315 gimple_location (const_gimple g)
1317 return g->gsbase.location;
1320 /* Return pointer to location information for statement G. */
1322 static inline const location_t *
1323 gimple_location_ptr (const_gimple g)
1325 return &g->gsbase.location;
1329 /* Set location information for statement G. */
1331 static inline void
1332 gimple_set_location (gimple g, location_t location)
1334 g->gsbase.location = location;
1338 /* Return true if G contains location information. */
1340 static inline bool
1341 gimple_has_location (const_gimple g)
1343 return LOCATION_LOCUS (gimple_location (g)) != UNKNOWN_LOCATION;
1347 /* Return the file name of the location of STMT. */
1349 static inline const char *
1350 gimple_filename (const_gimple stmt)
1352 return LOCATION_FILE (gimple_location (stmt));
1356 /* Return the line number of the location of STMT. */
1358 static inline int
1359 gimple_lineno (const_gimple stmt)
1361 return LOCATION_LINE (gimple_location (stmt));
1365 /* Determine whether SEQ is a singleton. */
1367 static inline bool
1368 gimple_seq_singleton_p (gimple_seq seq)
1370 return ((gimple_seq_first (seq) != NULL)
1371 && (gimple_seq_first (seq) == gimple_seq_last (seq)));
1374 /* Return true if no warnings should be emitted for statement STMT. */
1376 static inline bool
1377 gimple_no_warning_p (const_gimple stmt)
1379 return stmt->gsbase.no_warning;
1382 /* Set the no_warning flag of STMT to NO_WARNING. */
1384 static inline void
1385 gimple_set_no_warning (gimple stmt, bool no_warning)
1387 stmt->gsbase.no_warning = (unsigned) no_warning;
1390 /* Set the visited status on statement STMT to VISITED_P. */
1392 static inline void
1393 gimple_set_visited (gimple stmt, bool visited_p)
1395 stmt->gsbase.visited = (unsigned) visited_p;
1399 /* Return the visited status for statement STMT. */
1401 static inline bool
1402 gimple_visited_p (gimple stmt)
1404 return stmt->gsbase.visited;
1408 /* Set pass local flag PLF on statement STMT to VAL_P. */
1410 static inline void
1411 gimple_set_plf (gimple stmt, enum plf_mask plf, bool val_p)
1413 if (val_p)
1414 stmt->gsbase.plf |= (unsigned int) plf;
1415 else
1416 stmt->gsbase.plf &= ~((unsigned int) plf);
1420 /* Return the value of pass local flag PLF on statement STMT. */
1422 static inline unsigned int
1423 gimple_plf (gimple stmt, enum plf_mask plf)
1425 return stmt->gsbase.plf & ((unsigned int) plf);
1429 /* Set the UID of statement. */
1431 static inline void
1432 gimple_set_uid (gimple g, unsigned uid)
1434 g->gsbase.uid = uid;
1438 /* Return the UID of statement. */
1440 static inline unsigned
1441 gimple_uid (const_gimple g)
1443 return g->gsbase.uid;
1447 /* Make statement G a singleton sequence. */
1449 static inline void
1450 gimple_init_singleton (gimple g)
1452 g->gsbase.next = NULL;
1453 g->gsbase.prev = g;
1457 /* Return true if GIMPLE statement G has register or memory operands. */
1459 static inline bool
1460 gimple_has_ops (const_gimple g)
1462 return gimple_code (g) >= GIMPLE_COND && gimple_code (g) <= GIMPLE_RETURN;
1466 /* Return true if GIMPLE statement G has memory operands. */
1468 static inline bool
1469 gimple_has_mem_ops (const_gimple g)
1471 return gimple_code (g) >= GIMPLE_ASSIGN && gimple_code (g) <= GIMPLE_RETURN;
1475 /* Return the set of USE operands for statement G. */
1477 static inline struct use_optype_d *
1478 gimple_use_ops (const_gimple g)
1480 if (!gimple_has_ops (g))
1481 return NULL;
1482 return g->gsops.opbase.use_ops;
1486 /* Set USE to be the set of USE operands for statement G. */
1488 static inline void
1489 gimple_set_use_ops (gimple g, struct use_optype_d *use)
1491 gcc_gimple_checking_assert (gimple_has_ops (g));
1492 g->gsops.opbase.use_ops = use;
1496 /* Return the single VUSE operand of the statement G. */
1498 static inline tree
1499 gimple_vuse (const_gimple g)
1501 if (!gimple_has_mem_ops (g))
1502 return NULL_TREE;
1503 return g->gsmembase.vuse;
1506 /* Return the single VDEF operand of the statement G. */
1508 static inline tree
1509 gimple_vdef (const_gimple g)
1511 if (!gimple_has_mem_ops (g))
1512 return NULL_TREE;
1513 return g->gsmembase.vdef;
1516 /* Return the single VUSE operand of the statement G. */
1518 static inline tree *
1519 gimple_vuse_ptr (gimple g)
1521 if (!gimple_has_mem_ops (g))
1522 return NULL;
1523 return &g->gsmembase.vuse;
1526 /* Return the single VDEF operand of the statement G. */
1528 static inline tree *
1529 gimple_vdef_ptr (gimple g)
1531 if (!gimple_has_mem_ops (g))
1532 return NULL;
1533 return &g->gsmembase.vdef;
1536 /* Set the single VUSE operand of the statement G. */
1538 static inline void
1539 gimple_set_vuse (gimple g, tree vuse)
1541 gcc_gimple_checking_assert (gimple_has_mem_ops (g));
1542 g->gsmembase.vuse = vuse;
1545 /* Set the single VDEF operand of the statement G. */
1547 static inline void
1548 gimple_set_vdef (gimple g, tree vdef)
1550 gcc_gimple_checking_assert (gimple_has_mem_ops (g));
1551 g->gsmembase.vdef = vdef;
1555 /* Return true if statement G has operands and the modified field has
1556 been set. */
1558 static inline bool
1559 gimple_modified_p (const_gimple g)
1561 return (gimple_has_ops (g)) ? (bool) g->gsbase.modified : false;
1565 /* Set the MODIFIED flag to MODIFIEDP, iff the gimple statement G has
1566 a MODIFIED field. */
1568 static inline void
1569 gimple_set_modified (gimple s, bool modifiedp)
1571 if (gimple_has_ops (s))
1572 s->gsbase.modified = (unsigned) modifiedp;
1576 /* Return the tree code for the expression computed by STMT. This is
1577 only valid for GIMPLE_COND, GIMPLE_CALL and GIMPLE_ASSIGN. For
1578 GIMPLE_CALL, return CALL_EXPR as the expression code for
1579 consistency. This is useful when the caller needs to deal with the
1580 three kinds of computation that GIMPLE supports. */
1582 static inline enum tree_code
1583 gimple_expr_code (const_gimple stmt)
1585 enum gimple_code code = gimple_code (stmt);
1586 if (code == GIMPLE_ASSIGN || code == GIMPLE_COND)
1587 return (enum tree_code) stmt->gsbase.subcode;
1588 else
1590 gcc_gimple_checking_assert (code == GIMPLE_CALL);
1591 return CALL_EXPR;
1596 /* Return true if statement STMT contains volatile operands. */
1598 static inline bool
1599 gimple_has_volatile_ops (const_gimple stmt)
1601 if (gimple_has_mem_ops (stmt))
1602 return stmt->gsbase.has_volatile_ops;
1603 else
1604 return false;
1608 /* Set the HAS_VOLATILE_OPS flag to VOLATILEP. */
1610 static inline void
1611 gimple_set_has_volatile_ops (gimple stmt, bool volatilep)
1613 if (gimple_has_mem_ops (stmt))
1614 stmt->gsbase.has_volatile_ops = (unsigned) volatilep;
1617 /* Return true if BB is in a transaction. */
1619 static inline bool
1620 block_in_transaction (basic_block bb)
1622 return flag_tm && bb->flags & BB_IN_TRANSACTION;
1625 /* Return true if STMT is in a transaction. */
1627 static inline bool
1628 gimple_in_transaction (gimple stmt)
1630 return block_in_transaction (gimple_bb (stmt));
1633 /* Return true if statement STMT may access memory. */
1635 static inline bool
1636 gimple_references_memory_p (gimple stmt)
1638 return gimple_has_mem_ops (stmt) && gimple_vuse (stmt);
1642 /* Return the subcode for OMP statement S. */
1644 static inline unsigned
1645 gimple_omp_subcode (const_gimple s)
1647 gcc_gimple_checking_assert (gimple_code (s) >= GIMPLE_OMP_ATOMIC_LOAD
1648 && gimple_code (s) <= GIMPLE_OMP_TEAMS);
1649 return s->gsbase.subcode;
1652 /* Set the subcode for OMP statement S to SUBCODE. */
1654 static inline void
1655 gimple_omp_set_subcode (gimple s, unsigned int subcode)
1657 /* We only have 16 bits for the subcode. Assert that we are not
1658 overflowing it. */
1659 gcc_gimple_checking_assert (subcode < (1 << 16));
1660 s->gsbase.subcode = subcode;
1663 /* Set the nowait flag on OMP_RETURN statement S. */
1665 static inline void
1666 gimple_omp_return_set_nowait (gimple s)
1668 GIMPLE_CHECK (s, GIMPLE_OMP_RETURN);
1669 s->gsbase.subcode |= GF_OMP_RETURN_NOWAIT;
1673 /* Return true if OMP return statement G has the GF_OMP_RETURN_NOWAIT
1674 flag set. */
1676 static inline bool
1677 gimple_omp_return_nowait_p (const_gimple g)
1679 GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
1680 return (gimple_omp_subcode (g) & GF_OMP_RETURN_NOWAIT) != 0;
1684 /* Set the LHS of OMP return. */
1686 static inline void
1687 gimple_omp_return_set_lhs (gimple g, tree lhs)
1689 GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
1690 g->gimple_omp_atomic_store.val = lhs;
1694 /* Get the LHS of OMP return. */
1696 static inline tree
1697 gimple_omp_return_lhs (const_gimple g)
1699 GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
1700 return g->gimple_omp_atomic_store.val;
1704 /* Return a pointer to the LHS of OMP return. */
1706 static inline tree *
1707 gimple_omp_return_lhs_ptr (gimple g)
1709 GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
1710 return &g->gimple_omp_atomic_store.val;
1714 /* Return true if OMP section statement G has the GF_OMP_SECTION_LAST
1715 flag set. */
1717 static inline bool
1718 gimple_omp_section_last_p (const_gimple g)
1720 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1721 return (gimple_omp_subcode (g) & GF_OMP_SECTION_LAST) != 0;
1725 /* Set the GF_OMP_SECTION_LAST flag on G. */
1727 static inline void
1728 gimple_omp_section_set_last (gimple g)
1730 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1731 g->gsbase.subcode |= GF_OMP_SECTION_LAST;
1735 /* Return true if OMP parallel statement G has the
1736 GF_OMP_PARALLEL_COMBINED flag set. */
1738 static inline bool
1739 gimple_omp_parallel_combined_p (const_gimple g)
1741 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1742 return (gimple_omp_subcode (g) & GF_OMP_PARALLEL_COMBINED) != 0;
1746 /* Set the GF_OMP_PARALLEL_COMBINED field in G depending on the boolean
1747 value of COMBINED_P. */
1749 static inline void
1750 gimple_omp_parallel_set_combined_p (gimple g, bool combined_p)
1752 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1753 if (combined_p)
1754 g->gsbase.subcode |= GF_OMP_PARALLEL_COMBINED;
1755 else
1756 g->gsbase.subcode &= ~GF_OMP_PARALLEL_COMBINED;
1760 /* Return true if OMP atomic load/store statement G has the
1761 GF_OMP_ATOMIC_NEED_VALUE flag set. */
1763 static inline bool
1764 gimple_omp_atomic_need_value_p (const_gimple g)
1766 if (gimple_code (g) != GIMPLE_OMP_ATOMIC_LOAD)
1767 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
1768 return (gimple_omp_subcode (g) & GF_OMP_ATOMIC_NEED_VALUE) != 0;
1772 /* Set the GF_OMP_ATOMIC_NEED_VALUE flag on G. */
1774 static inline void
1775 gimple_omp_atomic_set_need_value (gimple g)
1777 if (gimple_code (g) != GIMPLE_OMP_ATOMIC_LOAD)
1778 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
1779 g->gsbase.subcode |= GF_OMP_ATOMIC_NEED_VALUE;
1783 /* Return true if OMP atomic load/store statement G has the
1784 GF_OMP_ATOMIC_SEQ_CST flag set. */
1786 static inline bool
1787 gimple_omp_atomic_seq_cst_p (const_gimple g)
1789 if (gimple_code (g) != GIMPLE_OMP_ATOMIC_LOAD)
1790 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
1791 return (gimple_omp_subcode (g) & GF_OMP_ATOMIC_SEQ_CST) != 0;
1795 /* Set the GF_OMP_ATOMIC_SEQ_CST flag on G. */
1797 static inline void
1798 gimple_omp_atomic_set_seq_cst (gimple g)
1800 if (gimple_code (g) != GIMPLE_OMP_ATOMIC_LOAD)
1801 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
1802 g->gsbase.subcode |= GF_OMP_ATOMIC_SEQ_CST;
1806 /* Return the number of operands for statement GS. */
1808 static inline unsigned
1809 gimple_num_ops (const_gimple gs)
1811 return gs->gsbase.num_ops;
1815 /* Set the number of operands for statement GS. */
1817 static inline void
1818 gimple_set_num_ops (gimple gs, unsigned num_ops)
1820 gs->gsbase.num_ops = num_ops;
1824 /* Return the array of operands for statement GS. */
1826 static inline tree *
1827 gimple_ops (gimple gs)
1829 size_t off;
1831 /* All the tuples have their operand vector at the very bottom
1832 of the structure. Note that those structures that do not
1833 have an operand vector have a zero offset. */
1834 off = gimple_ops_offset_[gimple_statement_structure (gs)];
1835 gcc_gimple_checking_assert (off != 0);
1837 return (tree *) ((char *) gs + off);
1841 /* Return operand I for statement GS. */
1843 static inline tree
1844 gimple_op (const_gimple gs, unsigned i)
1846 if (gimple_has_ops (gs))
1848 gcc_gimple_checking_assert (i < gimple_num_ops (gs));
1849 return gimple_ops (CONST_CAST_GIMPLE (gs))[i];
1851 else
1852 return NULL_TREE;
1855 /* Return a pointer to operand I for statement GS. */
1857 static inline tree *
1858 gimple_op_ptr (const_gimple gs, unsigned i)
1860 if (gimple_has_ops (gs))
1862 gcc_gimple_checking_assert (i < gimple_num_ops (gs));
1863 return gimple_ops (CONST_CAST_GIMPLE (gs)) + i;
1865 else
1866 return NULL;
1869 /* Set operand I of statement GS to OP. */
1871 static inline void
1872 gimple_set_op (gimple gs, unsigned i, tree op)
1874 gcc_gimple_checking_assert (gimple_has_ops (gs) && i < gimple_num_ops (gs));
1876 /* Note. It may be tempting to assert that OP matches
1877 is_gimple_operand, but that would be wrong. Different tuples
1878 accept slightly different sets of tree operands. Each caller
1879 should perform its own validation. */
1880 gimple_ops (gs)[i] = op;
1883 /* Return true if GS is a GIMPLE_ASSIGN. */
1885 static inline bool
1886 is_gimple_assign (const_gimple gs)
1888 return gimple_code (gs) == GIMPLE_ASSIGN;
1891 /* Determine if expression CODE is one of the valid expressions that can
1892 be used on the RHS of GIMPLE assignments. */
1894 static inline enum gimple_rhs_class
1895 get_gimple_rhs_class (enum tree_code code)
1897 return (enum gimple_rhs_class) gimple_rhs_class_table[(int) code];
1900 /* Return the LHS of assignment statement GS. */
1902 static inline tree
1903 gimple_assign_lhs (const_gimple gs)
1905 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1906 return gimple_op (gs, 0);
1910 /* Return a pointer to the LHS of assignment statement GS. */
1912 static inline tree *
1913 gimple_assign_lhs_ptr (const_gimple gs)
1915 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1916 return gimple_op_ptr (gs, 0);
1920 /* Set LHS to be the LHS operand of assignment statement GS. */
1922 static inline void
1923 gimple_assign_set_lhs (gimple gs, tree lhs)
1925 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1926 gimple_set_op (gs, 0, lhs);
1928 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1929 SSA_NAME_DEF_STMT (lhs) = gs;
1933 /* Return the first operand on the RHS of assignment statement GS. */
1935 static inline tree
1936 gimple_assign_rhs1 (const_gimple gs)
1938 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1939 return gimple_op (gs, 1);
1943 /* Return a pointer to the first operand on the RHS of assignment
1944 statement GS. */
1946 static inline tree *
1947 gimple_assign_rhs1_ptr (const_gimple gs)
1949 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1950 return gimple_op_ptr (gs, 1);
1953 /* Set RHS to be the first operand on the RHS of assignment statement GS. */
1955 static inline void
1956 gimple_assign_set_rhs1 (gimple gs, tree rhs)
1958 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1960 gimple_set_op (gs, 1, rhs);
1964 /* Return the second operand on the RHS of assignment statement GS.
1965 If GS does not have two operands, NULL is returned instead. */
1967 static inline tree
1968 gimple_assign_rhs2 (const_gimple gs)
1970 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1972 if (gimple_num_ops (gs) >= 3)
1973 return gimple_op (gs, 2);
1974 else
1975 return NULL_TREE;
1979 /* Return a pointer to the second operand on the RHS of assignment
1980 statement GS. */
1982 static inline tree *
1983 gimple_assign_rhs2_ptr (const_gimple gs)
1985 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1986 return gimple_op_ptr (gs, 2);
1990 /* Set RHS to be the second operand on the RHS of assignment statement GS. */
1992 static inline void
1993 gimple_assign_set_rhs2 (gimple gs, tree rhs)
1995 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1997 gimple_set_op (gs, 2, rhs);
2000 /* Return the third operand on the RHS of assignment statement GS.
2001 If GS does not have two operands, NULL is returned instead. */
2003 static inline tree
2004 gimple_assign_rhs3 (const_gimple gs)
2006 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
2008 if (gimple_num_ops (gs) >= 4)
2009 return gimple_op (gs, 3);
2010 else
2011 return NULL_TREE;
2014 /* Return a pointer to the third operand on the RHS of assignment
2015 statement GS. */
2017 static inline tree *
2018 gimple_assign_rhs3_ptr (const_gimple gs)
2020 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
2021 return gimple_op_ptr (gs, 3);
2025 /* Set RHS to be the third operand on the RHS of assignment statement GS. */
2027 static inline void
2028 gimple_assign_set_rhs3 (gimple gs, tree rhs)
2030 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
2032 gimple_set_op (gs, 3, rhs);
2035 /* A wrapper around gimple_assign_set_rhs_with_ops_1, for callers which expect
2036 to see only a maximum of two operands. */
2038 static inline void
2039 gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *gsi, enum tree_code code,
2040 tree op1, tree op2)
2042 gimple_assign_set_rhs_with_ops_1 (gsi, code, op1, op2, NULL);
2045 /* A wrapper around extract_ops_from_tree_1, for callers which expect
2046 to see only a maximum of two operands. */
2048 static inline void
2049 extract_ops_from_tree (tree expr, enum tree_code *code, tree *op0,
2050 tree *op1)
2052 tree op2;
2053 extract_ops_from_tree_1 (expr, code, op0, op1, &op2);
2054 gcc_assert (op2 == NULL_TREE);
2057 /* Returns true if GS is a nontemporal move. */
2059 static inline bool
2060 gimple_assign_nontemporal_move_p (const_gimple gs)
2062 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
2063 return gs->gsbase.nontemporal_move;
2066 /* Sets nontemporal move flag of GS to NONTEMPORAL. */
2068 static inline void
2069 gimple_assign_set_nontemporal_move (gimple gs, bool nontemporal)
2071 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
2072 gs->gsbase.nontemporal_move = nontemporal;
2076 /* Return the code of the expression computed on the rhs of assignment
2077 statement GS. In case that the RHS is a single object, returns the
2078 tree code of the object. */
2080 static inline enum tree_code
2081 gimple_assign_rhs_code (const_gimple gs)
2083 enum tree_code code;
2084 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
2086 code = (enum tree_code) gs->gsbase.subcode;
2087 /* While we initially set subcode to the TREE_CODE of the rhs for
2088 GIMPLE_SINGLE_RHS assigns we do not update that subcode to stay
2089 in sync when we rewrite stmts into SSA form or do SSA propagations. */
2090 if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS)
2091 code = TREE_CODE (gimple_assign_rhs1 (gs));
2093 return code;
2097 /* Set CODE to be the code for the expression computed on the RHS of
2098 assignment S. */
2100 static inline void
2101 gimple_assign_set_rhs_code (gimple s, enum tree_code code)
2103 GIMPLE_CHECK (s, GIMPLE_ASSIGN);
2104 s->gsbase.subcode = code;
2108 /* Return the gimple rhs class of the code of the expression computed on
2109 the rhs of assignment statement GS.
2110 This will never return GIMPLE_INVALID_RHS. */
2112 static inline enum gimple_rhs_class
2113 gimple_assign_rhs_class (const_gimple gs)
2115 return get_gimple_rhs_class (gimple_assign_rhs_code (gs));
2118 /* Return true if GS is an assignment with a singleton RHS, i.e.,
2119 there is no operator associated with the assignment itself.
2120 Unlike gimple_assign_copy_p, this predicate returns true for
2121 any RHS operand, including those that perform an operation
2122 and do not have the semantics of a copy, such as COND_EXPR. */
2124 static inline bool
2125 gimple_assign_single_p (gimple gs)
2127 return (is_gimple_assign (gs)
2128 && gimple_assign_rhs_class (gs) == GIMPLE_SINGLE_RHS);
2131 /* Return true if GS performs a store to its lhs. */
2133 static inline bool
2134 gimple_store_p (gimple gs)
2136 tree lhs = gimple_get_lhs (gs);
2137 return lhs && !is_gimple_reg (lhs);
2140 /* Return true if GS is an assignment that loads from its rhs1. */
2142 static inline bool
2143 gimple_assign_load_p (gimple gs)
2145 tree rhs;
2146 if (!gimple_assign_single_p (gs))
2147 return false;
2148 rhs = gimple_assign_rhs1 (gs);
2149 if (TREE_CODE (rhs) == WITH_SIZE_EXPR)
2150 return true;
2151 rhs = get_base_address (rhs);
2152 return (DECL_P (rhs)
2153 || TREE_CODE (rhs) == MEM_REF || TREE_CODE (rhs) == TARGET_MEM_REF);
2157 /* Return true if S is a type-cast assignment. */
2159 static inline bool
2160 gimple_assign_cast_p (gimple s)
2162 if (is_gimple_assign (s))
2164 enum tree_code sc = gimple_assign_rhs_code (s);
2165 return CONVERT_EXPR_CODE_P (sc)
2166 || sc == VIEW_CONVERT_EXPR
2167 || sc == FIX_TRUNC_EXPR;
2170 return false;
2173 /* Return true if S is a clobber statement. */
2175 static inline bool
2176 gimple_clobber_p (gimple s)
2178 return gimple_assign_single_p (s)
2179 && TREE_CLOBBER_P (gimple_assign_rhs1 (s));
2182 /* Return true if GS is a GIMPLE_CALL. */
2184 static inline bool
2185 is_gimple_call (const_gimple gs)
2187 return gimple_code (gs) == GIMPLE_CALL;
2190 /* Return the LHS of call statement GS. */
2192 static inline tree
2193 gimple_call_lhs (const_gimple gs)
2195 GIMPLE_CHECK (gs, GIMPLE_CALL);
2196 return gimple_op (gs, 0);
2200 /* Return a pointer to the LHS of call statement GS. */
2202 static inline tree *
2203 gimple_call_lhs_ptr (const_gimple gs)
2205 GIMPLE_CHECK (gs, GIMPLE_CALL);
2206 return gimple_op_ptr (gs, 0);
2210 /* Set LHS to be the LHS operand of call statement GS. */
2212 static inline void
2213 gimple_call_set_lhs (gimple gs, tree lhs)
2215 GIMPLE_CHECK (gs, GIMPLE_CALL);
2216 gimple_set_op (gs, 0, lhs);
2217 if (lhs && TREE_CODE (lhs) == SSA_NAME)
2218 SSA_NAME_DEF_STMT (lhs) = gs;
2222 /* Return true if call GS calls an internal-only function, as enumerated
2223 by internal_fn. */
2225 static inline bool
2226 gimple_call_internal_p (const_gimple gs)
2228 GIMPLE_CHECK (gs, GIMPLE_CALL);
2229 return (gs->gsbase.subcode & GF_CALL_INTERNAL) != 0;
2233 /* Return the target of internal call GS. */
2235 static inline enum internal_fn
2236 gimple_call_internal_fn (const_gimple gs)
2238 gcc_gimple_checking_assert (gimple_call_internal_p (gs));
2239 return gs->gimple_call.u.internal_fn;
2243 /* Return the function type of the function called by GS. */
2245 static inline tree
2246 gimple_call_fntype (const_gimple gs)
2248 GIMPLE_CHECK (gs, GIMPLE_CALL);
2249 if (gimple_call_internal_p (gs))
2250 return NULL_TREE;
2251 return gs->gimple_call.u.fntype;
2254 /* Set the type of the function called by GS to FNTYPE. */
2256 static inline void
2257 gimple_call_set_fntype (gimple gs, tree fntype)
2259 GIMPLE_CHECK (gs, GIMPLE_CALL);
2260 gcc_gimple_checking_assert (!gimple_call_internal_p (gs));
2261 gs->gimple_call.u.fntype = fntype;
2265 /* Return the tree node representing the function called by call
2266 statement GS. */
2268 static inline tree
2269 gimple_call_fn (const_gimple gs)
2271 GIMPLE_CHECK (gs, GIMPLE_CALL);
2272 return gimple_op (gs, 1);
2275 /* Return a pointer to the tree node representing the function called by call
2276 statement GS. */
2278 static inline tree *
2279 gimple_call_fn_ptr (const_gimple gs)
2281 GIMPLE_CHECK (gs, GIMPLE_CALL);
2282 return gimple_op_ptr (gs, 1);
2286 /* Set FN to be the function called by call statement GS. */
2288 static inline void
2289 gimple_call_set_fn (gimple gs, tree fn)
2291 GIMPLE_CHECK (gs, GIMPLE_CALL);
2292 gcc_gimple_checking_assert (!gimple_call_internal_p (gs));
2293 gimple_set_op (gs, 1, fn);
2297 /* Set FNDECL to be the function called by call statement GS. */
2299 static inline void
2300 gimple_call_set_fndecl (gimple gs, tree decl)
2302 GIMPLE_CHECK (gs, GIMPLE_CALL);
2303 gcc_gimple_checking_assert (!gimple_call_internal_p (gs));
2304 gimple_set_op (gs, 1, build_fold_addr_expr_loc (gimple_location (gs), decl));
2308 /* Set internal function FN to be the function called by call statement GS. */
2310 static inline void
2311 gimple_call_set_internal_fn (gimple gs, enum internal_fn fn)
2313 GIMPLE_CHECK (gs, GIMPLE_CALL);
2314 gcc_gimple_checking_assert (gimple_call_internal_p (gs));
2315 gs->gimple_call.u.internal_fn = fn;
2319 /* Given a valid GIMPLE_CALL function address return the FUNCTION_DECL
2320 associated with the callee if known. Otherwise return NULL_TREE. */
2322 static inline tree
2323 gimple_call_addr_fndecl (const_tree fn)
2325 if (fn && TREE_CODE (fn) == ADDR_EXPR)
2327 tree fndecl = TREE_OPERAND (fn, 0);
2328 if (TREE_CODE (fndecl) == MEM_REF
2329 && TREE_CODE (TREE_OPERAND (fndecl, 0)) == ADDR_EXPR
2330 && integer_zerop (TREE_OPERAND (fndecl, 1)))
2331 fndecl = TREE_OPERAND (TREE_OPERAND (fndecl, 0), 0);
2332 if (TREE_CODE (fndecl) == FUNCTION_DECL)
2333 return fndecl;
2335 return NULL_TREE;
2338 /* If a given GIMPLE_CALL's callee is a FUNCTION_DECL, return it.
2339 Otherwise return NULL. This function is analogous to
2340 get_callee_fndecl in tree land. */
2342 static inline tree
2343 gimple_call_fndecl (const_gimple gs)
2345 return gimple_call_addr_fndecl (gimple_call_fn (gs));
2349 /* Return the type returned by call statement GS. */
2351 static inline tree
2352 gimple_call_return_type (const_gimple gs)
2354 tree type = gimple_call_fntype (gs);
2356 if (type == NULL_TREE)
2357 return TREE_TYPE (gimple_call_lhs (gs));
2359 /* The type returned by a function is the type of its
2360 function type. */
2361 return TREE_TYPE (type);
2365 /* Return the static chain for call statement GS. */
2367 static inline tree
2368 gimple_call_chain (const_gimple gs)
2370 GIMPLE_CHECK (gs, GIMPLE_CALL);
2371 return gimple_op (gs, 2);
2375 /* Return a pointer to the static chain for call statement GS. */
2377 static inline tree *
2378 gimple_call_chain_ptr (const_gimple gs)
2380 GIMPLE_CHECK (gs, GIMPLE_CALL);
2381 return gimple_op_ptr (gs, 2);
2384 /* Set CHAIN to be the static chain for call statement GS. */
2386 static inline void
2387 gimple_call_set_chain (gimple gs, tree chain)
2389 GIMPLE_CHECK (gs, GIMPLE_CALL);
2391 gimple_set_op (gs, 2, chain);
2395 /* Return the number of arguments used by call statement GS. */
2397 static inline unsigned
2398 gimple_call_num_args (const_gimple gs)
2400 unsigned num_ops;
2401 GIMPLE_CHECK (gs, GIMPLE_CALL);
2402 num_ops = gimple_num_ops (gs);
2403 return num_ops - 3;
2407 /* Return the argument at position INDEX for call statement GS. */
2409 static inline tree
2410 gimple_call_arg (const_gimple gs, unsigned index)
2412 GIMPLE_CHECK (gs, GIMPLE_CALL);
2413 return gimple_op (gs, index + 3);
2417 /* Return a pointer to the argument at position INDEX for call
2418 statement GS. */
2420 static inline tree *
2421 gimple_call_arg_ptr (const_gimple gs, unsigned index)
2423 GIMPLE_CHECK (gs, GIMPLE_CALL);
2424 return gimple_op_ptr (gs, index + 3);
2428 /* Set ARG to be the argument at position INDEX for call statement GS. */
2430 static inline void
2431 gimple_call_set_arg (gimple gs, unsigned index, tree arg)
2433 GIMPLE_CHECK (gs, GIMPLE_CALL);
2434 gimple_set_op (gs, index + 3, arg);
2438 /* If TAIL_P is true, mark call statement S as being a tail call
2439 (i.e., a call just before the exit of a function). These calls are
2440 candidate for tail call optimization. */
2442 static inline void
2443 gimple_call_set_tail (gimple s, bool tail_p)
2445 GIMPLE_CHECK (s, GIMPLE_CALL);
2446 if (tail_p)
2447 s->gsbase.subcode |= GF_CALL_TAILCALL;
2448 else
2449 s->gsbase.subcode &= ~GF_CALL_TAILCALL;
2453 /* Return true if GIMPLE_CALL S is marked as a tail call. */
2455 static inline bool
2456 gimple_call_tail_p (gimple s)
2458 GIMPLE_CHECK (s, GIMPLE_CALL);
2459 return (s->gsbase.subcode & GF_CALL_TAILCALL) != 0;
2463 /* If RETURN_SLOT_OPT_P is true mark GIMPLE_CALL S as valid for return
2464 slot optimization. This transformation uses the target of the call
2465 expansion as the return slot for calls that return in memory. */
2467 static inline void
2468 gimple_call_set_return_slot_opt (gimple s, bool return_slot_opt_p)
2470 GIMPLE_CHECK (s, GIMPLE_CALL);
2471 if (return_slot_opt_p)
2472 s->gsbase.subcode |= GF_CALL_RETURN_SLOT_OPT;
2473 else
2474 s->gsbase.subcode &= ~GF_CALL_RETURN_SLOT_OPT;
2478 /* Return true if S is marked for return slot optimization. */
2480 static inline bool
2481 gimple_call_return_slot_opt_p (gimple s)
2483 GIMPLE_CHECK (s, GIMPLE_CALL);
2484 return (s->gsbase.subcode & GF_CALL_RETURN_SLOT_OPT) != 0;
2488 /* If FROM_THUNK_P is true, mark GIMPLE_CALL S as being the jump from a
2489 thunk to the thunked-to function. */
2491 static inline void
2492 gimple_call_set_from_thunk (gimple s, bool from_thunk_p)
2494 GIMPLE_CHECK (s, GIMPLE_CALL);
2495 if (from_thunk_p)
2496 s->gsbase.subcode |= GF_CALL_FROM_THUNK;
2497 else
2498 s->gsbase.subcode &= ~GF_CALL_FROM_THUNK;
2502 /* Return true if GIMPLE_CALL S is a jump from a thunk. */
2504 static inline bool
2505 gimple_call_from_thunk_p (gimple s)
2507 GIMPLE_CHECK (s, GIMPLE_CALL);
2508 return (s->gsbase.subcode & GF_CALL_FROM_THUNK) != 0;
2512 /* If PASS_ARG_PACK_P is true, GIMPLE_CALL S is a stdarg call that needs the
2513 argument pack in its argument list. */
2515 static inline void
2516 gimple_call_set_va_arg_pack (gimple s, bool pass_arg_pack_p)
2518 GIMPLE_CHECK (s, GIMPLE_CALL);
2519 if (pass_arg_pack_p)
2520 s->gsbase.subcode |= GF_CALL_VA_ARG_PACK;
2521 else
2522 s->gsbase.subcode &= ~GF_CALL_VA_ARG_PACK;
2526 /* Return true if GIMPLE_CALL S is a stdarg call that needs the
2527 argument pack in its argument list. */
2529 static inline bool
2530 gimple_call_va_arg_pack_p (gimple s)
2532 GIMPLE_CHECK (s, GIMPLE_CALL);
2533 return (s->gsbase.subcode & GF_CALL_VA_ARG_PACK) != 0;
2537 /* Return true if S is a noreturn call. */
2539 static inline bool
2540 gimple_call_noreturn_p (gimple s)
2542 GIMPLE_CHECK (s, GIMPLE_CALL);
2543 return (gimple_call_flags (s) & ECF_NORETURN) != 0;
2547 /* If NOTHROW_P is true, GIMPLE_CALL S is a call that is known to not throw
2548 even if the called function can throw in other cases. */
2550 static inline void
2551 gimple_call_set_nothrow (gimple s, bool nothrow_p)
2553 GIMPLE_CHECK (s, GIMPLE_CALL);
2554 if (nothrow_p)
2555 s->gsbase.subcode |= GF_CALL_NOTHROW;
2556 else
2557 s->gsbase.subcode &= ~GF_CALL_NOTHROW;
2560 /* Return true if S is a nothrow call. */
2562 static inline bool
2563 gimple_call_nothrow_p (gimple s)
2565 GIMPLE_CHECK (s, GIMPLE_CALL);
2566 return (gimple_call_flags (s) & ECF_NOTHROW) != 0;
2569 /* If FOR_VAR is true, GIMPLE_CALL S is a call to builtin_alloca that
2570 is known to be emitted for VLA objects. Those are wrapped by
2571 stack_save/stack_restore calls and hence can't lead to unbounded
2572 stack growth even when they occur in loops. */
2574 static inline void
2575 gimple_call_set_alloca_for_var (gimple s, bool for_var)
2577 GIMPLE_CHECK (s, GIMPLE_CALL);
2578 if (for_var)
2579 s->gsbase.subcode |= GF_CALL_ALLOCA_FOR_VAR;
2580 else
2581 s->gsbase.subcode &= ~GF_CALL_ALLOCA_FOR_VAR;
2584 /* Return true of S is a call to builtin_alloca emitted for VLA objects. */
2586 static inline bool
2587 gimple_call_alloca_for_var_p (gimple s)
2589 GIMPLE_CHECK (s, GIMPLE_CALL);
2590 return (s->gsbase.subcode & GF_CALL_ALLOCA_FOR_VAR) != 0;
2593 /* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL. */
2595 static inline void
2596 gimple_call_copy_flags (gimple dest_call, gimple orig_call)
2598 GIMPLE_CHECK (dest_call, GIMPLE_CALL);
2599 GIMPLE_CHECK (orig_call, GIMPLE_CALL);
2600 dest_call->gsbase.subcode = orig_call->gsbase.subcode;
2604 /* Return a pointer to the points-to solution for the set of call-used
2605 variables of the call CALL. */
2607 static inline struct pt_solution *
2608 gimple_call_use_set (gimple call)
2610 GIMPLE_CHECK (call, GIMPLE_CALL);
2611 return &call->gimple_call.call_used;
2615 /* Return a pointer to the points-to solution for the set of call-used
2616 variables of the call CALL. */
2618 static inline struct pt_solution *
2619 gimple_call_clobber_set (gimple call)
2621 GIMPLE_CHECK (call, GIMPLE_CALL);
2622 return &call->gimple_call.call_clobbered;
2626 /* Returns true if this is a GIMPLE_ASSIGN or a GIMPLE_CALL with a
2627 non-NULL lhs. */
2629 static inline bool
2630 gimple_has_lhs (gimple stmt)
2632 return (is_gimple_assign (stmt)
2633 || (is_gimple_call (stmt)
2634 && gimple_call_lhs (stmt) != NULL_TREE));
2638 /* Return the code of the predicate computed by conditional statement GS. */
2640 static inline enum tree_code
2641 gimple_cond_code (const_gimple gs)
2643 GIMPLE_CHECK (gs, GIMPLE_COND);
2644 return (enum tree_code) gs->gsbase.subcode;
2648 /* Set CODE to be the predicate code for the conditional statement GS. */
2650 static inline void
2651 gimple_cond_set_code (gimple gs, enum tree_code code)
2653 GIMPLE_CHECK (gs, GIMPLE_COND);
2654 gs->gsbase.subcode = code;
2658 /* Return the LHS of the predicate computed by conditional statement GS. */
2660 static inline tree
2661 gimple_cond_lhs (const_gimple gs)
2663 GIMPLE_CHECK (gs, GIMPLE_COND);
2664 return gimple_op (gs, 0);
2667 /* Return the pointer to the LHS of the predicate computed by conditional
2668 statement GS. */
2670 static inline tree *
2671 gimple_cond_lhs_ptr (const_gimple gs)
2673 GIMPLE_CHECK (gs, GIMPLE_COND);
2674 return gimple_op_ptr (gs, 0);
2677 /* Set LHS to be the LHS operand of the predicate computed by
2678 conditional statement GS. */
2680 static inline void
2681 gimple_cond_set_lhs (gimple gs, tree lhs)
2683 GIMPLE_CHECK (gs, GIMPLE_COND);
2684 gimple_set_op (gs, 0, lhs);
2688 /* Return the RHS operand of the predicate computed by conditional GS. */
2690 static inline tree
2691 gimple_cond_rhs (const_gimple gs)
2693 GIMPLE_CHECK (gs, GIMPLE_COND);
2694 return gimple_op (gs, 1);
2697 /* Return the pointer to the RHS operand of the predicate computed by
2698 conditional GS. */
2700 static inline tree *
2701 gimple_cond_rhs_ptr (const_gimple gs)
2703 GIMPLE_CHECK (gs, GIMPLE_COND);
2704 return gimple_op_ptr (gs, 1);
2708 /* Set RHS to be the RHS operand of the predicate computed by
2709 conditional statement GS. */
2711 static inline void
2712 gimple_cond_set_rhs (gimple gs, tree rhs)
2714 GIMPLE_CHECK (gs, GIMPLE_COND);
2715 gimple_set_op (gs, 1, rhs);
2719 /* Return the label used by conditional statement GS when its
2720 predicate evaluates to true. */
2722 static inline tree
2723 gimple_cond_true_label (const_gimple gs)
2725 GIMPLE_CHECK (gs, GIMPLE_COND);
2726 return gimple_op (gs, 2);
2730 /* Set LABEL to be the label used by conditional statement GS when its
2731 predicate evaluates to true. */
2733 static inline void
2734 gimple_cond_set_true_label (gimple gs, tree label)
2736 GIMPLE_CHECK (gs, GIMPLE_COND);
2737 gimple_set_op (gs, 2, label);
2741 /* Set LABEL to be the label used by conditional statement GS when its
2742 predicate evaluates to false. */
2744 static inline void
2745 gimple_cond_set_false_label (gimple gs, tree label)
2747 GIMPLE_CHECK (gs, GIMPLE_COND);
2748 gimple_set_op (gs, 3, label);
2752 /* Return the label used by conditional statement GS when its
2753 predicate evaluates to false. */
2755 static inline tree
2756 gimple_cond_false_label (const_gimple gs)
2758 GIMPLE_CHECK (gs, GIMPLE_COND);
2759 return gimple_op (gs, 3);
2763 /* Set the conditional COND_STMT to be of the form 'if (1 == 0)'. */
2765 static inline void
2766 gimple_cond_make_false (gimple gs)
2768 gimple_cond_set_lhs (gs, boolean_true_node);
2769 gimple_cond_set_rhs (gs, boolean_false_node);
2770 gs->gsbase.subcode = EQ_EXPR;
2774 /* Set the conditional COND_STMT to be of the form 'if (1 == 1)'. */
2776 static inline void
2777 gimple_cond_make_true (gimple gs)
2779 gimple_cond_set_lhs (gs, boolean_true_node);
2780 gimple_cond_set_rhs (gs, boolean_true_node);
2781 gs->gsbase.subcode = EQ_EXPR;
2784 /* Check if conditional statemente GS is of the form 'if (1 == 1)',
2785 'if (0 == 0)', 'if (1 != 0)' or 'if (0 != 1)' */
2787 static inline bool
2788 gimple_cond_true_p (const_gimple gs)
2790 tree lhs = gimple_cond_lhs (gs);
2791 tree rhs = gimple_cond_rhs (gs);
2792 enum tree_code code = gimple_cond_code (gs);
2794 if (lhs != boolean_true_node && lhs != boolean_false_node)
2795 return false;
2797 if (rhs != boolean_true_node && rhs != boolean_false_node)
2798 return false;
2800 if (code == NE_EXPR && lhs != rhs)
2801 return true;
2803 if (code == EQ_EXPR && lhs == rhs)
2804 return true;
2806 return false;
2809 /* Check if conditional statement GS is of the form 'if (1 != 1)',
2810 'if (0 != 0)', 'if (1 == 0)' or 'if (0 == 1)' */
2812 static inline bool
2813 gimple_cond_false_p (const_gimple gs)
2815 tree lhs = gimple_cond_lhs (gs);
2816 tree rhs = gimple_cond_rhs (gs);
2817 enum tree_code code = gimple_cond_code (gs);
2819 if (lhs != boolean_true_node && lhs != boolean_false_node)
2820 return false;
2822 if (rhs != boolean_true_node && rhs != boolean_false_node)
2823 return false;
2825 if (code == NE_EXPR && lhs == rhs)
2826 return true;
2828 if (code == EQ_EXPR && lhs != rhs)
2829 return true;
2831 return false;
2834 /* Set the code, LHS and RHS of GIMPLE_COND STMT from CODE, LHS and RHS. */
2836 static inline void
2837 gimple_cond_set_condition (gimple stmt, enum tree_code code, tree lhs, tree rhs)
2839 gimple_cond_set_code (stmt, code);
2840 gimple_cond_set_lhs (stmt, lhs);
2841 gimple_cond_set_rhs (stmt, rhs);
2844 /* Return the LABEL_DECL node used by GIMPLE_LABEL statement GS. */
2846 static inline tree
2847 gimple_label_label (const_gimple gs)
2849 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2850 return gimple_op (gs, 0);
2854 /* Set LABEL to be the LABEL_DECL node used by GIMPLE_LABEL statement
2855 GS. */
2857 static inline void
2858 gimple_label_set_label (gimple gs, tree label)
2860 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2861 gimple_set_op (gs, 0, label);
2865 /* Return the destination of the unconditional jump GS. */
2867 static inline tree
2868 gimple_goto_dest (const_gimple gs)
2870 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2871 return gimple_op (gs, 0);
2875 /* Set DEST to be the destination of the unconditonal jump GS. */
2877 static inline void
2878 gimple_goto_set_dest (gimple gs, tree dest)
2880 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2881 gimple_set_op (gs, 0, dest);
2885 /* Return the variables declared in the GIMPLE_BIND statement GS. */
2887 static inline tree
2888 gimple_bind_vars (const_gimple gs)
2890 GIMPLE_CHECK (gs, GIMPLE_BIND);
2891 return gs->gimple_bind.vars;
2895 /* Set VARS to be the set of variables declared in the GIMPLE_BIND
2896 statement GS. */
2898 static inline void
2899 gimple_bind_set_vars (gimple gs, tree vars)
2901 GIMPLE_CHECK (gs, GIMPLE_BIND);
2902 gs->gimple_bind.vars = vars;
2906 /* Append VARS to the set of variables declared in the GIMPLE_BIND
2907 statement GS. */
2909 static inline void
2910 gimple_bind_append_vars (gimple gs, tree vars)
2912 GIMPLE_CHECK (gs, GIMPLE_BIND);
2913 gs->gimple_bind.vars = chainon (gs->gimple_bind.vars, vars);
2917 static inline gimple_seq *
2918 gimple_bind_body_ptr (gimple gs)
2920 GIMPLE_CHECK (gs, GIMPLE_BIND);
2921 return &gs->gimple_bind.body;
2924 /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS. */
2926 static inline gimple_seq
2927 gimple_bind_body (gimple gs)
2929 return *gimple_bind_body_ptr (gs);
2933 /* Set SEQ to be the GIMPLE sequence contained in the GIMPLE_BIND
2934 statement GS. */
2936 static inline void
2937 gimple_bind_set_body (gimple gs, gimple_seq seq)
2939 GIMPLE_CHECK (gs, GIMPLE_BIND);
2940 gs->gimple_bind.body = seq;
2944 /* Append a statement to the end of a GIMPLE_BIND's body. */
2946 static inline void
2947 gimple_bind_add_stmt (gimple gs, gimple stmt)
2949 GIMPLE_CHECK (gs, GIMPLE_BIND);
2950 gimple_seq_add_stmt (&gs->gimple_bind.body, stmt);
2954 /* Append a sequence of statements to the end of a GIMPLE_BIND's body. */
2956 static inline void
2957 gimple_bind_add_seq (gimple gs, gimple_seq seq)
2959 GIMPLE_CHECK (gs, GIMPLE_BIND);
2960 gimple_seq_add_seq (&gs->gimple_bind.body, seq);
2964 /* Return the TREE_BLOCK node associated with GIMPLE_BIND statement
2965 GS. This is analogous to the BIND_EXPR_BLOCK field in trees. */
2967 static inline tree
2968 gimple_bind_block (const_gimple gs)
2970 GIMPLE_CHECK (gs, GIMPLE_BIND);
2971 return gs->gimple_bind.block;
2975 /* Set BLOCK to be the TREE_BLOCK node associated with GIMPLE_BIND
2976 statement GS. */
2978 static inline void
2979 gimple_bind_set_block (gimple gs, tree block)
2981 GIMPLE_CHECK (gs, GIMPLE_BIND);
2982 gcc_gimple_checking_assert (block == NULL_TREE
2983 || TREE_CODE (block) == BLOCK);
2984 gs->gimple_bind.block = block;
2988 /* Return the number of input operands for GIMPLE_ASM GS. */
2990 static inline unsigned
2991 gimple_asm_ninputs (const_gimple gs)
2993 GIMPLE_CHECK (gs, GIMPLE_ASM);
2994 return gs->gimple_asm.ni;
2998 /* Return the number of output operands for GIMPLE_ASM GS. */
3000 static inline unsigned
3001 gimple_asm_noutputs (const_gimple gs)
3003 GIMPLE_CHECK (gs, GIMPLE_ASM);
3004 return gs->gimple_asm.no;
3008 /* Return the number of clobber operands for GIMPLE_ASM GS. */
3010 static inline unsigned
3011 gimple_asm_nclobbers (const_gimple gs)
3013 GIMPLE_CHECK (gs, GIMPLE_ASM);
3014 return gs->gimple_asm.nc;
3017 /* Return the number of label operands for GIMPLE_ASM GS. */
3019 static inline unsigned
3020 gimple_asm_nlabels (const_gimple gs)
3022 GIMPLE_CHECK (gs, GIMPLE_ASM);
3023 return gs->gimple_asm.nl;
3026 /* Return input operand INDEX of GIMPLE_ASM GS. */
3028 static inline tree
3029 gimple_asm_input_op (const_gimple gs, unsigned index)
3031 GIMPLE_CHECK (gs, GIMPLE_ASM);
3032 gcc_gimple_checking_assert (index < gs->gimple_asm.ni);
3033 return gimple_op (gs, index + gs->gimple_asm.no);
3036 /* Return a pointer to input operand INDEX of GIMPLE_ASM GS. */
3038 static inline tree *
3039 gimple_asm_input_op_ptr (const_gimple gs, unsigned index)
3041 GIMPLE_CHECK (gs, GIMPLE_ASM);
3042 gcc_gimple_checking_assert (index < gs->gimple_asm.ni);
3043 return gimple_op_ptr (gs, index + gs->gimple_asm.no);
3047 /* Set IN_OP to be input operand INDEX in GIMPLE_ASM GS. */
3049 static inline void
3050 gimple_asm_set_input_op (gimple gs, unsigned index, tree in_op)
3052 GIMPLE_CHECK (gs, GIMPLE_ASM);
3053 gcc_gimple_checking_assert (index < gs->gimple_asm.ni
3054 && TREE_CODE (in_op) == TREE_LIST);
3055 gimple_set_op (gs, index + gs->gimple_asm.no, in_op);
3059 /* Return output operand INDEX of GIMPLE_ASM GS. */
3061 static inline tree
3062 gimple_asm_output_op (const_gimple gs, unsigned index)
3064 GIMPLE_CHECK (gs, GIMPLE_ASM);
3065 gcc_gimple_checking_assert (index < gs->gimple_asm.no);
3066 return gimple_op (gs, index);
3069 /* Return a pointer to output operand INDEX of GIMPLE_ASM GS. */
3071 static inline tree *
3072 gimple_asm_output_op_ptr (const_gimple gs, unsigned index)
3074 GIMPLE_CHECK (gs, GIMPLE_ASM);
3075 gcc_gimple_checking_assert (index < gs->gimple_asm.no);
3076 return gimple_op_ptr (gs, index);
3080 /* Set OUT_OP to be output operand INDEX in GIMPLE_ASM GS. */
3082 static inline void
3083 gimple_asm_set_output_op (gimple gs, unsigned index, tree out_op)
3085 GIMPLE_CHECK (gs, GIMPLE_ASM);
3086 gcc_gimple_checking_assert (index < gs->gimple_asm.no
3087 && TREE_CODE (out_op) == TREE_LIST);
3088 gimple_set_op (gs, index, out_op);
3092 /* Return clobber operand INDEX of GIMPLE_ASM GS. */
3094 static inline tree
3095 gimple_asm_clobber_op (const_gimple gs, unsigned index)
3097 GIMPLE_CHECK (gs, GIMPLE_ASM);
3098 gcc_gimple_checking_assert (index < gs->gimple_asm.nc);
3099 return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no);
3103 /* Set CLOBBER_OP to be clobber operand INDEX in GIMPLE_ASM GS. */
3105 static inline void
3106 gimple_asm_set_clobber_op (gimple gs, unsigned index, tree clobber_op)
3108 GIMPLE_CHECK (gs, GIMPLE_ASM);
3109 gcc_gimple_checking_assert (index < gs->gimple_asm.nc
3110 && TREE_CODE (clobber_op) == TREE_LIST);
3111 gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no, clobber_op);
3114 /* Return label operand INDEX of GIMPLE_ASM GS. */
3116 static inline tree
3117 gimple_asm_label_op (const_gimple gs, unsigned index)
3119 GIMPLE_CHECK (gs, GIMPLE_ASM);
3120 gcc_gimple_checking_assert (index < gs->gimple_asm.nl);
3121 return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.nc);
3124 /* Set LABEL_OP to be label operand INDEX in GIMPLE_ASM GS. */
3126 static inline void
3127 gimple_asm_set_label_op (gimple gs, unsigned index, tree label_op)
3129 GIMPLE_CHECK (gs, GIMPLE_ASM);
3130 gcc_gimple_checking_assert (index < gs->gimple_asm.nl
3131 && TREE_CODE (label_op) == TREE_LIST);
3132 gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.nc, label_op);
3135 /* Return the string representing the assembly instruction in
3136 GIMPLE_ASM GS. */
3138 static inline const char *
3139 gimple_asm_string (const_gimple gs)
3141 GIMPLE_CHECK (gs, GIMPLE_ASM);
3142 return gs->gimple_asm.string;
3146 /* Return true if GS is an asm statement marked volatile. */
3148 static inline bool
3149 gimple_asm_volatile_p (const_gimple gs)
3151 GIMPLE_CHECK (gs, GIMPLE_ASM);
3152 return (gs->gsbase.subcode & GF_ASM_VOLATILE) != 0;
3156 /* If VOLATLE_P is true, mark asm statement GS as volatile. */
3158 static inline void
3159 gimple_asm_set_volatile (gimple gs, bool volatile_p)
3161 GIMPLE_CHECK (gs, GIMPLE_ASM);
3162 if (volatile_p)
3163 gs->gsbase.subcode |= GF_ASM_VOLATILE;
3164 else
3165 gs->gsbase.subcode &= ~GF_ASM_VOLATILE;
3169 /* If INPUT_P is true, mark asm GS as an ASM_INPUT. */
3171 static inline void
3172 gimple_asm_set_input (gimple gs, bool input_p)
3174 GIMPLE_CHECK (gs, GIMPLE_ASM);
3175 if (input_p)
3176 gs->gsbase.subcode |= GF_ASM_INPUT;
3177 else
3178 gs->gsbase.subcode &= ~GF_ASM_INPUT;
3182 /* Return true if asm GS is an ASM_INPUT. */
3184 static inline bool
3185 gimple_asm_input_p (const_gimple gs)
3187 GIMPLE_CHECK (gs, GIMPLE_ASM);
3188 return (gs->gsbase.subcode & GF_ASM_INPUT) != 0;
3192 /* Return the types handled by GIMPLE_CATCH statement GS. */
3194 static inline tree
3195 gimple_catch_types (const_gimple gs)
3197 GIMPLE_CHECK (gs, GIMPLE_CATCH);
3198 return gs->gimple_catch.types;
3202 /* Return a pointer to the types handled by GIMPLE_CATCH statement GS. */
3204 static inline tree *
3205 gimple_catch_types_ptr (gimple gs)
3207 GIMPLE_CHECK (gs, GIMPLE_CATCH);
3208 return &gs->gimple_catch.types;
3212 /* Return a pointer to the GIMPLE sequence representing the body of
3213 the handler of GIMPLE_CATCH statement GS. */
3215 static inline gimple_seq *
3216 gimple_catch_handler_ptr (gimple gs)
3218 GIMPLE_CHECK (gs, GIMPLE_CATCH);
3219 return &gs->gimple_catch.handler;
3223 /* Return the GIMPLE sequence representing the body of the handler of
3224 GIMPLE_CATCH statement GS. */
3226 static inline gimple_seq
3227 gimple_catch_handler (gimple gs)
3229 return *gimple_catch_handler_ptr (gs);
3233 /* Set T to be the set of types handled by GIMPLE_CATCH GS. */
3235 static inline void
3236 gimple_catch_set_types (gimple gs, tree t)
3238 GIMPLE_CHECK (gs, GIMPLE_CATCH);
3239 gs->gimple_catch.types = t;
3243 /* Set HANDLER to be the body of GIMPLE_CATCH GS. */
3245 static inline void
3246 gimple_catch_set_handler (gimple gs, gimple_seq handler)
3248 GIMPLE_CHECK (gs, GIMPLE_CATCH);
3249 gs->gimple_catch.handler = handler;
3253 /* Return the types handled by GIMPLE_EH_FILTER statement GS. */
3255 static inline tree
3256 gimple_eh_filter_types (const_gimple gs)
3258 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
3259 return gs->gimple_eh_filter.types;
3263 /* Return a pointer to the types handled by GIMPLE_EH_FILTER statement
3264 GS. */
3266 static inline tree *
3267 gimple_eh_filter_types_ptr (gimple gs)
3269 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
3270 return &gs->gimple_eh_filter.types;
3274 /* Return a pointer to the sequence of statement to execute when
3275 GIMPLE_EH_FILTER statement fails. */
3277 static inline gimple_seq *
3278 gimple_eh_filter_failure_ptr (gimple gs)
3280 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
3281 return &gs->gimple_eh_filter.failure;
3285 /* Return the sequence of statement to execute when GIMPLE_EH_FILTER
3286 statement fails. */
3288 static inline gimple_seq
3289 gimple_eh_filter_failure (gimple gs)
3291 return *gimple_eh_filter_failure_ptr (gs);
3295 /* Set TYPES to be the set of types handled by GIMPLE_EH_FILTER GS. */
3297 static inline void
3298 gimple_eh_filter_set_types (gimple gs, tree types)
3300 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
3301 gs->gimple_eh_filter.types = types;
3305 /* Set FAILURE to be the sequence of statements to execute on failure
3306 for GIMPLE_EH_FILTER GS. */
3308 static inline void
3309 gimple_eh_filter_set_failure (gimple gs, gimple_seq failure)
3311 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
3312 gs->gimple_eh_filter.failure = failure;
3315 /* Get the function decl to be called by the MUST_NOT_THROW region. */
3317 static inline tree
3318 gimple_eh_must_not_throw_fndecl (gimple gs)
3320 GIMPLE_CHECK (gs, GIMPLE_EH_MUST_NOT_THROW);
3321 return gs->gimple_eh_mnt.fndecl;
3324 /* Set the function decl to be called by GS to DECL. */
3326 static inline void
3327 gimple_eh_must_not_throw_set_fndecl (gimple gs, tree decl)
3329 GIMPLE_CHECK (gs, GIMPLE_EH_MUST_NOT_THROW);
3330 gs->gimple_eh_mnt.fndecl = decl;
3333 /* GIMPLE_EH_ELSE accessors. */
3335 static inline gimple_seq *
3336 gimple_eh_else_n_body_ptr (gimple gs)
3338 GIMPLE_CHECK (gs, GIMPLE_EH_ELSE);
3339 return &gs->gimple_eh_else.n_body;
3342 static inline gimple_seq
3343 gimple_eh_else_n_body (gimple gs)
3345 return *gimple_eh_else_n_body_ptr (gs);
3348 static inline gimple_seq *
3349 gimple_eh_else_e_body_ptr (gimple gs)
3351 GIMPLE_CHECK (gs, GIMPLE_EH_ELSE);
3352 return &gs->gimple_eh_else.e_body;
3355 static inline gimple_seq
3356 gimple_eh_else_e_body (gimple gs)
3358 return *gimple_eh_else_e_body_ptr (gs);
3361 static inline void
3362 gimple_eh_else_set_n_body (gimple gs, gimple_seq seq)
3364 GIMPLE_CHECK (gs, GIMPLE_EH_ELSE);
3365 gs->gimple_eh_else.n_body = seq;
3368 static inline void
3369 gimple_eh_else_set_e_body (gimple gs, gimple_seq seq)
3371 GIMPLE_CHECK (gs, GIMPLE_EH_ELSE);
3372 gs->gimple_eh_else.e_body = seq;
3375 /* GIMPLE_TRY accessors. */
3377 /* Return the kind of try block represented by GIMPLE_TRY GS. This is
3378 either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY. */
3380 static inline enum gimple_try_flags
3381 gimple_try_kind (const_gimple gs)
3383 GIMPLE_CHECK (gs, GIMPLE_TRY);
3384 return (enum gimple_try_flags) (gs->gsbase.subcode & GIMPLE_TRY_KIND);
3388 /* Set the kind of try block represented by GIMPLE_TRY GS. */
3390 static inline void
3391 gimple_try_set_kind (gimple gs, enum gimple_try_flags kind)
3393 GIMPLE_CHECK (gs, GIMPLE_TRY);
3394 gcc_gimple_checking_assert (kind == GIMPLE_TRY_CATCH
3395 || kind == GIMPLE_TRY_FINALLY);
3396 if (gimple_try_kind (gs) != kind)
3397 gs->gsbase.subcode = (unsigned int) kind;
3401 /* Return the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
3403 static inline bool
3404 gimple_try_catch_is_cleanup (const_gimple gs)
3406 gcc_gimple_checking_assert (gimple_try_kind (gs) == GIMPLE_TRY_CATCH);
3407 return (gs->gsbase.subcode & GIMPLE_TRY_CATCH_IS_CLEANUP) != 0;
3411 /* Return a pointer to the sequence of statements used as the
3412 body for GIMPLE_TRY GS. */
3414 static inline gimple_seq *
3415 gimple_try_eval_ptr (gimple gs)
3417 GIMPLE_CHECK (gs, GIMPLE_TRY);
3418 return &gs->gimple_try.eval;
3422 /* Return the sequence of statements used as the body for GIMPLE_TRY GS. */
3424 static inline gimple_seq
3425 gimple_try_eval (gimple gs)
3427 return *gimple_try_eval_ptr (gs);
3431 /* Return a pointer to the sequence of statements used as the cleanup body for
3432 GIMPLE_TRY GS. */
3434 static inline gimple_seq *
3435 gimple_try_cleanup_ptr (gimple gs)
3437 GIMPLE_CHECK (gs, GIMPLE_TRY);
3438 return &gs->gimple_try.cleanup;
3442 /* Return the sequence of statements used as the cleanup body for
3443 GIMPLE_TRY GS. */
3445 static inline gimple_seq
3446 gimple_try_cleanup (gimple gs)
3448 return *gimple_try_cleanup_ptr (gs);
3452 /* Set the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
3454 static inline void
3455 gimple_try_set_catch_is_cleanup (gimple g, bool catch_is_cleanup)
3457 gcc_gimple_checking_assert (gimple_try_kind (g) == GIMPLE_TRY_CATCH);
3458 if (catch_is_cleanup)
3459 g->gsbase.subcode |= GIMPLE_TRY_CATCH_IS_CLEANUP;
3460 else
3461 g->gsbase.subcode &= ~GIMPLE_TRY_CATCH_IS_CLEANUP;
3465 /* Set EVAL to be the sequence of statements to use as the body for
3466 GIMPLE_TRY GS. */
3468 static inline void
3469 gimple_try_set_eval (gimple gs, gimple_seq eval)
3471 GIMPLE_CHECK (gs, GIMPLE_TRY);
3472 gs->gimple_try.eval = eval;
3476 /* Set CLEANUP to be the sequence of statements to use as the cleanup
3477 body for GIMPLE_TRY GS. */
3479 static inline void
3480 gimple_try_set_cleanup (gimple gs, gimple_seq cleanup)
3482 GIMPLE_CHECK (gs, GIMPLE_TRY);
3483 gs->gimple_try.cleanup = cleanup;
3487 /* Return a pointer to the cleanup sequence for cleanup statement GS. */
3489 static inline gimple_seq *
3490 gimple_wce_cleanup_ptr (gimple gs)
3492 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3493 return &gs->gimple_wce.cleanup;
3497 /* Return the cleanup sequence for cleanup statement GS. */
3499 static inline gimple_seq
3500 gimple_wce_cleanup (gimple gs)
3502 return *gimple_wce_cleanup_ptr (gs);
3506 /* Set CLEANUP to be the cleanup sequence for GS. */
3508 static inline void
3509 gimple_wce_set_cleanup (gimple gs, gimple_seq cleanup)
3511 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3512 gs->gimple_wce.cleanup = cleanup;
3516 /* Return the CLEANUP_EH_ONLY flag for a WCE tuple. */
3518 static inline bool
3519 gimple_wce_cleanup_eh_only (const_gimple gs)
3521 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3522 return gs->gsbase.subcode != 0;
3526 /* Set the CLEANUP_EH_ONLY flag for a WCE tuple. */
3528 static inline void
3529 gimple_wce_set_cleanup_eh_only (gimple gs, bool eh_only_p)
3531 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3532 gs->gsbase.subcode = (unsigned int) eh_only_p;
3536 /* Return the maximum number of arguments supported by GIMPLE_PHI GS. */
3538 static inline unsigned
3539 gimple_phi_capacity (const_gimple gs)
3541 GIMPLE_CHECK (gs, GIMPLE_PHI);
3542 return gs->gimple_phi.capacity;
3546 /* Return the number of arguments in GIMPLE_PHI GS. This must always
3547 be exactly the number of incoming edges for the basic block holding
3548 GS. */
3550 static inline unsigned
3551 gimple_phi_num_args (const_gimple gs)
3553 GIMPLE_CHECK (gs, GIMPLE_PHI);
3554 return gs->gimple_phi.nargs;
3558 /* Return the SSA name created by GIMPLE_PHI GS. */
3560 static inline tree
3561 gimple_phi_result (const_gimple gs)
3563 GIMPLE_CHECK (gs, GIMPLE_PHI);
3564 return gs->gimple_phi.result;
3567 /* Return a pointer to the SSA name created by GIMPLE_PHI GS. */
3569 static inline tree *
3570 gimple_phi_result_ptr (gimple gs)
3572 GIMPLE_CHECK (gs, GIMPLE_PHI);
3573 return &gs->gimple_phi.result;
3576 /* Set RESULT to be the SSA name created by GIMPLE_PHI GS. */
3578 static inline void
3579 gimple_phi_set_result (gimple gs, tree result)
3581 GIMPLE_CHECK (gs, GIMPLE_PHI);
3582 gs->gimple_phi.result = result;
3583 if (result && TREE_CODE (result) == SSA_NAME)
3584 SSA_NAME_DEF_STMT (result) = gs;
3588 /* Return the PHI argument corresponding to incoming edge INDEX for
3589 GIMPLE_PHI GS. */
3591 static inline struct phi_arg_d *
3592 gimple_phi_arg (gimple gs, unsigned index)
3594 GIMPLE_CHECK (gs, GIMPLE_PHI);
3595 gcc_gimple_checking_assert (index <= gs->gimple_phi.capacity);
3596 return &(gs->gimple_phi.args[index]);
3599 /* Set PHIARG to be the argument corresponding to incoming edge INDEX
3600 for GIMPLE_PHI GS. */
3602 static inline void
3603 gimple_phi_set_arg (gimple gs, unsigned index, struct phi_arg_d * phiarg)
3605 GIMPLE_CHECK (gs, GIMPLE_PHI);
3606 gcc_gimple_checking_assert (index <= gs->gimple_phi.nargs);
3607 gs->gimple_phi.args[index] = *phiarg;
3610 /* PHI nodes should contain only ssa_names and invariants. A test
3611 for ssa_name is definitely simpler; don't let invalid contents
3612 slip in in the meantime. */
3614 static inline bool
3615 phi_ssa_name_p (const_tree t)
3617 if (TREE_CODE (t) == SSA_NAME)
3618 return true;
3619 gcc_checking_assert (is_gimple_min_invariant (t));
3620 return false;
3623 /* Return the PHI nodes for basic block BB, or NULL if there are no
3624 PHI nodes. */
3626 static inline gimple_seq
3627 phi_nodes (const_basic_block bb)
3629 gcc_checking_assert (!(bb->flags & BB_RTL));
3630 return bb->il.gimple.phi_nodes;
3633 /* Return a pointer to the PHI nodes for basic block BB. */
3635 static inline gimple_seq *
3636 phi_nodes_ptr (basic_block bb)
3638 gcc_checking_assert (!(bb->flags & BB_RTL));
3639 return &bb->il.gimple.phi_nodes;
3642 /* Return the tree operand for argument I of PHI node GS. */
3644 static inline tree
3645 gimple_phi_arg_def (gimple gs, size_t index)
3647 return gimple_phi_arg (gs, index)->def;
3651 /* Return a pointer to the tree operand for argument I of PHI node GS. */
3653 static inline tree *
3654 gimple_phi_arg_def_ptr (gimple gs, size_t index)
3656 return &gimple_phi_arg (gs, index)->def;
3659 /* Return the edge associated with argument I of phi node GS. */
3661 static inline edge
3662 gimple_phi_arg_edge (gimple gs, size_t i)
3664 return EDGE_PRED (gimple_bb (gs), i);
3667 /* Return the source location of gimple argument I of phi node GS. */
3669 static inline source_location
3670 gimple_phi_arg_location (gimple gs, size_t i)
3672 return gimple_phi_arg (gs, i)->locus;
3675 /* Return the source location of the argument on edge E of phi node GS. */
3677 static inline source_location
3678 gimple_phi_arg_location_from_edge (gimple gs, edge e)
3680 return gimple_phi_arg (gs, e->dest_idx)->locus;
3683 /* Set the source location of gimple argument I of phi node GS to LOC. */
3685 static inline void
3686 gimple_phi_arg_set_location (gimple gs, size_t i, source_location loc)
3688 gimple_phi_arg (gs, i)->locus = loc;
3691 /* Return TRUE if argument I of phi node GS has a location record. */
3693 static inline bool
3694 gimple_phi_arg_has_location (gimple gs, size_t i)
3696 return gimple_phi_arg_location (gs, i) != UNKNOWN_LOCATION;
3700 /* Return the region number for GIMPLE_RESX GS. */
3702 static inline int
3703 gimple_resx_region (const_gimple gs)
3705 GIMPLE_CHECK (gs, GIMPLE_RESX);
3706 return gs->gimple_eh_ctrl.region;
3709 /* Set REGION to be the region number for GIMPLE_RESX GS. */
3711 static inline void
3712 gimple_resx_set_region (gimple gs, int region)
3714 GIMPLE_CHECK (gs, GIMPLE_RESX);
3715 gs->gimple_eh_ctrl.region = region;
3718 /* Return the region number for GIMPLE_EH_DISPATCH GS. */
3720 static inline int
3721 gimple_eh_dispatch_region (const_gimple gs)
3723 GIMPLE_CHECK (gs, GIMPLE_EH_DISPATCH);
3724 return gs->gimple_eh_ctrl.region;
3727 /* Set REGION to be the region number for GIMPLE_EH_DISPATCH GS. */
3729 static inline void
3730 gimple_eh_dispatch_set_region (gimple gs, int region)
3732 GIMPLE_CHECK (gs, GIMPLE_EH_DISPATCH);
3733 gs->gimple_eh_ctrl.region = region;
3736 /* Return the number of labels associated with the switch statement GS. */
3738 static inline unsigned
3739 gimple_switch_num_labels (const_gimple gs)
3741 unsigned num_ops;
3742 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3743 num_ops = gimple_num_ops (gs);
3744 gcc_gimple_checking_assert (num_ops > 1);
3745 return num_ops - 1;
3749 /* Set NLABELS to be the number of labels for the switch statement GS. */
3751 static inline void
3752 gimple_switch_set_num_labels (gimple g, unsigned nlabels)
3754 GIMPLE_CHECK (g, GIMPLE_SWITCH);
3755 gimple_set_num_ops (g, nlabels + 1);
3759 /* Return the index variable used by the switch statement GS. */
3761 static inline tree
3762 gimple_switch_index (const_gimple gs)
3764 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3765 return gimple_op (gs, 0);
3769 /* Return a pointer to the index variable for the switch statement GS. */
3771 static inline tree *
3772 gimple_switch_index_ptr (const_gimple gs)
3774 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3775 return gimple_op_ptr (gs, 0);
3779 /* Set INDEX to be the index variable for switch statement GS. */
3781 static inline void
3782 gimple_switch_set_index (gimple gs, tree index)
3784 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3785 gcc_gimple_checking_assert (SSA_VAR_P (index) || CONSTANT_CLASS_P (index));
3786 gimple_set_op (gs, 0, index);
3790 /* Return the label numbered INDEX. The default label is 0, followed by any
3791 labels in a switch statement. */
3793 static inline tree
3794 gimple_switch_label (const_gimple gs, unsigned index)
3796 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3797 gcc_gimple_checking_assert (gimple_num_ops (gs) > index + 1);
3798 return gimple_op (gs, index + 1);
3801 /* Set the label number INDEX to LABEL. 0 is always the default label. */
3803 static inline void
3804 gimple_switch_set_label (gimple gs, unsigned index, tree label)
3806 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3807 gcc_gimple_checking_assert (gimple_num_ops (gs) > index + 1
3808 && (label == NULL_TREE
3809 || TREE_CODE (label) == CASE_LABEL_EXPR));
3810 gimple_set_op (gs, index + 1, label);
3813 /* Return the default label for a switch statement. */
3815 static inline tree
3816 gimple_switch_default_label (const_gimple gs)
3818 tree label = gimple_switch_label (gs, 0);
3819 gcc_checking_assert (!CASE_LOW (label) && !CASE_HIGH (label));
3820 return label;
3823 /* Set the default label for a switch statement. */
3825 static inline void
3826 gimple_switch_set_default_label (gimple gs, tree label)
3828 gcc_checking_assert (!CASE_LOW (label) && !CASE_HIGH (label));
3829 gimple_switch_set_label (gs, 0, label);
3832 /* Return true if GS is a GIMPLE_DEBUG statement. */
3834 static inline bool
3835 is_gimple_debug (const_gimple gs)
3837 return gimple_code (gs) == GIMPLE_DEBUG;
3840 /* Return true if S is a GIMPLE_DEBUG BIND statement. */
3842 static inline bool
3843 gimple_debug_bind_p (const_gimple s)
3845 if (is_gimple_debug (s))
3846 return s->gsbase.subcode == GIMPLE_DEBUG_BIND;
3848 return false;
3851 /* Return the variable bound in a GIMPLE_DEBUG bind statement. */
3853 static inline tree
3854 gimple_debug_bind_get_var (gimple dbg)
3856 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3857 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3858 return gimple_op (dbg, 0);
3861 /* Return the value bound to the variable in a GIMPLE_DEBUG bind
3862 statement. */
3864 static inline tree
3865 gimple_debug_bind_get_value (gimple dbg)
3867 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3868 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3869 return gimple_op (dbg, 1);
3872 /* Return a pointer to the value bound to the variable in a
3873 GIMPLE_DEBUG bind statement. */
3875 static inline tree *
3876 gimple_debug_bind_get_value_ptr (gimple dbg)
3878 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3879 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3880 return gimple_op_ptr (dbg, 1);
3883 /* Set the variable bound in a GIMPLE_DEBUG bind statement. */
3885 static inline void
3886 gimple_debug_bind_set_var (gimple dbg, tree var)
3888 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3889 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3890 gimple_set_op (dbg, 0, var);
3893 /* Set the value bound to the variable in a GIMPLE_DEBUG bind
3894 statement. */
3896 static inline void
3897 gimple_debug_bind_set_value (gimple dbg, tree value)
3899 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3900 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3901 gimple_set_op (dbg, 1, value);
3904 /* The second operand of a GIMPLE_DEBUG_BIND, when the value was
3905 optimized away. */
3906 #define GIMPLE_DEBUG_BIND_NOVALUE NULL_TREE /* error_mark_node */
3908 /* Remove the value bound to the variable in a GIMPLE_DEBUG bind
3909 statement. */
3911 static inline void
3912 gimple_debug_bind_reset_value (gimple dbg)
3914 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3915 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3916 gimple_set_op (dbg, 1, GIMPLE_DEBUG_BIND_NOVALUE);
3919 /* Return true if the GIMPLE_DEBUG bind statement is bound to a
3920 value. */
3922 static inline bool
3923 gimple_debug_bind_has_value_p (gimple dbg)
3925 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3926 gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3927 return gimple_op (dbg, 1) != GIMPLE_DEBUG_BIND_NOVALUE;
3930 #undef GIMPLE_DEBUG_BIND_NOVALUE
3932 /* Return true if S is a GIMPLE_DEBUG SOURCE BIND statement. */
3934 static inline bool
3935 gimple_debug_source_bind_p (const_gimple s)
3937 if (is_gimple_debug (s))
3938 return s->gsbase.subcode == GIMPLE_DEBUG_SOURCE_BIND;
3940 return false;
3943 /* Return the variable bound in a GIMPLE_DEBUG source bind statement. */
3945 static inline tree
3946 gimple_debug_source_bind_get_var (gimple dbg)
3948 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3949 gcc_gimple_checking_assert (gimple_debug_source_bind_p (dbg));
3950 return gimple_op (dbg, 0);
3953 /* Return the value bound to the variable in a GIMPLE_DEBUG source bind
3954 statement. */
3956 static inline tree
3957 gimple_debug_source_bind_get_value (gimple dbg)
3959 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3960 gcc_gimple_checking_assert (gimple_debug_source_bind_p (dbg));
3961 return gimple_op (dbg, 1);
3964 /* Return a pointer to the value bound to the variable in a
3965 GIMPLE_DEBUG source bind statement. */
3967 static inline tree *
3968 gimple_debug_source_bind_get_value_ptr (gimple dbg)
3970 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3971 gcc_gimple_checking_assert (gimple_debug_source_bind_p (dbg));
3972 return gimple_op_ptr (dbg, 1);
3975 /* Set the variable bound in a GIMPLE_DEBUG source bind statement. */
3977 static inline void
3978 gimple_debug_source_bind_set_var (gimple dbg, tree var)
3980 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3981 gcc_gimple_checking_assert (gimple_debug_source_bind_p (dbg));
3982 gimple_set_op (dbg, 0, var);
3985 /* Set the value bound to the variable in a GIMPLE_DEBUG source bind
3986 statement. */
3988 static inline void
3989 gimple_debug_source_bind_set_value (gimple dbg, tree value)
3991 GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3992 gcc_gimple_checking_assert (gimple_debug_source_bind_p (dbg));
3993 gimple_set_op (dbg, 1, value);
3996 /* Return the line number for EXPR, or return -1 if we have no line
3997 number information for it. */
3998 static inline int
3999 get_lineno (const_gimple stmt)
4001 location_t loc;
4003 if (!stmt)
4004 return -1;
4006 loc = gimple_location (stmt);
4007 if (loc == UNKNOWN_LOCATION)
4008 return -1;
4010 return LOCATION_LINE (loc);
4013 /* Return a pointer to the body for the OMP statement GS. */
4015 static inline gimple_seq *
4016 gimple_omp_body_ptr (gimple gs)
4018 return &gs->omp.body;
4021 /* Return the body for the OMP statement GS. */
4023 static inline gimple_seq
4024 gimple_omp_body (gimple gs)
4026 return *gimple_omp_body_ptr (gs);
4029 /* Set BODY to be the body for the OMP statement GS. */
4031 static inline void
4032 gimple_omp_set_body (gimple gs, gimple_seq body)
4034 gs->omp.body = body;
4038 /* Return the name associated with OMP_CRITICAL statement GS. */
4040 static inline tree
4041 gimple_omp_critical_name (const_gimple gs)
4043 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
4044 return gs->gimple_omp_critical.name;
4048 /* Return a pointer to the name associated with OMP critical statement GS. */
4050 static inline tree *
4051 gimple_omp_critical_name_ptr (gimple gs)
4053 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
4054 return &gs->gimple_omp_critical.name;
4058 /* Set NAME to be the name associated with OMP critical statement GS. */
4060 static inline void
4061 gimple_omp_critical_set_name (gimple gs, tree name)
4063 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
4064 gs->gimple_omp_critical.name = name;
4068 /* Return the kind of OMP for statemement. */
4070 static inline int
4071 gimple_omp_for_kind (const_gimple g)
4073 GIMPLE_CHECK (g, GIMPLE_OMP_FOR);
4074 return (gimple_omp_subcode (g) & GF_OMP_FOR_KIND_MASK);
4078 /* Set the OMP for kind. */
4080 static inline void
4081 gimple_omp_for_set_kind (gimple g, int kind)
4083 GIMPLE_CHECK (g, GIMPLE_OMP_FOR);
4084 g->gsbase.subcode = (g->gsbase.subcode & ~GF_OMP_FOR_KIND_MASK)
4085 | (kind & GF_OMP_FOR_KIND_MASK);
4089 /* Return true if OMP for statement G has the
4090 GF_OMP_FOR_COMBINED flag set. */
4092 static inline bool
4093 gimple_omp_for_combined_p (const_gimple g)
4095 GIMPLE_CHECK (g, GIMPLE_OMP_FOR);
4096 return (gimple_omp_subcode (g) & GF_OMP_FOR_COMBINED) != 0;
4100 /* Set the GF_OMP_FOR_COMBINED field in G depending on the boolean
4101 value of COMBINED_P. */
4103 static inline void
4104 gimple_omp_for_set_combined_p (gimple g, bool combined_p)
4106 GIMPLE_CHECK (g, GIMPLE_OMP_FOR);
4107 if (combined_p)
4108 g->gsbase.subcode |= GF_OMP_FOR_COMBINED;
4109 else
4110 g->gsbase.subcode &= ~GF_OMP_FOR_COMBINED;
4114 /* Return true if OMP for statement G has the
4115 GF_OMP_FOR_COMBINED_INTO flag set. */
4117 static inline bool
4118 gimple_omp_for_combined_into_p (const_gimple g)
4120 GIMPLE_CHECK (g, GIMPLE_OMP_FOR);
4121 return (gimple_omp_subcode (g) & GF_OMP_FOR_COMBINED_INTO) != 0;
4125 /* Set the GF_OMP_FOR_COMBINED_INTO field in G depending on the boolean
4126 value of COMBINED_P. */
4128 static inline void
4129 gimple_omp_for_set_combined_into_p (gimple g, bool combined_p)
4131 GIMPLE_CHECK (g, GIMPLE_OMP_FOR);
4132 if (combined_p)
4133 g->gsbase.subcode |= GF_OMP_FOR_COMBINED_INTO;
4134 else
4135 g->gsbase.subcode &= ~GF_OMP_FOR_COMBINED_INTO;
4139 /* Return the clauses associated with OMP_FOR GS. */
4141 static inline tree
4142 gimple_omp_for_clauses (const_gimple gs)
4144 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4145 return gs->gimple_omp_for.clauses;
4149 /* Return a pointer to the OMP_FOR GS. */
4151 static inline tree *
4152 gimple_omp_for_clauses_ptr (gimple gs)
4154 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4155 return &gs->gimple_omp_for.clauses;
4159 /* Set CLAUSES to be the list of clauses associated with OMP_FOR GS. */
4161 static inline void
4162 gimple_omp_for_set_clauses (gimple gs, tree clauses)
4164 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4165 gs->gimple_omp_for.clauses = clauses;
4169 /* Get the collapse count of OMP_FOR GS. */
4171 static inline size_t
4172 gimple_omp_for_collapse (gimple gs)
4174 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4175 return gs->gimple_omp_for.collapse;
4179 /* Return the index variable for OMP_FOR GS. */
4181 static inline tree
4182 gimple_omp_for_index (const_gimple gs, size_t i)
4184 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4185 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4186 return gs->gimple_omp_for.iter[i].index;
4190 /* Return a pointer to the index variable for OMP_FOR GS. */
4192 static inline tree *
4193 gimple_omp_for_index_ptr (gimple gs, size_t i)
4195 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4196 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4197 return &gs->gimple_omp_for.iter[i].index;
4201 /* Set INDEX to be the index variable for OMP_FOR GS. */
4203 static inline void
4204 gimple_omp_for_set_index (gimple gs, size_t i, tree index)
4206 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4207 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4208 gs->gimple_omp_for.iter[i].index = index;
4212 /* Return the initial value for OMP_FOR GS. */
4214 static inline tree
4215 gimple_omp_for_initial (const_gimple gs, size_t i)
4217 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4218 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4219 return gs->gimple_omp_for.iter[i].initial;
4223 /* Return a pointer to the initial value for OMP_FOR GS. */
4225 static inline tree *
4226 gimple_omp_for_initial_ptr (gimple gs, size_t i)
4228 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4229 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4230 return &gs->gimple_omp_for.iter[i].initial;
4234 /* Set INITIAL to be the initial value for OMP_FOR GS. */
4236 static inline void
4237 gimple_omp_for_set_initial (gimple gs, size_t i, tree initial)
4239 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4240 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4241 gs->gimple_omp_for.iter[i].initial = initial;
4245 /* Return the final value for OMP_FOR GS. */
4247 static inline tree
4248 gimple_omp_for_final (const_gimple gs, size_t i)
4250 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4251 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4252 return gs->gimple_omp_for.iter[i].final;
4256 /* Return a pointer to the final value for OMP_FOR GS. */
4258 static inline tree *
4259 gimple_omp_for_final_ptr (gimple gs, size_t i)
4261 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4262 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4263 return &gs->gimple_omp_for.iter[i].final;
4267 /* Set FINAL to be the final value for OMP_FOR GS. */
4269 static inline void
4270 gimple_omp_for_set_final (gimple gs, size_t i, tree final)
4272 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4273 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4274 gs->gimple_omp_for.iter[i].final = final;
4278 /* Return the increment value for OMP_FOR GS. */
4280 static inline tree
4281 gimple_omp_for_incr (const_gimple gs, size_t i)
4283 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4284 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4285 return gs->gimple_omp_for.iter[i].incr;
4289 /* Return a pointer to the increment value for OMP_FOR GS. */
4291 static inline tree *
4292 gimple_omp_for_incr_ptr (gimple gs, size_t i)
4294 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4295 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4296 return &gs->gimple_omp_for.iter[i].incr;
4300 /* Set INCR to be the increment value for OMP_FOR GS. */
4302 static inline void
4303 gimple_omp_for_set_incr (gimple gs, size_t i, tree incr)
4305 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4306 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4307 gs->gimple_omp_for.iter[i].incr = incr;
4311 /* Return a pointer to the sequence of statements to execute before the OMP_FOR
4312 statement GS starts. */
4314 static inline gimple_seq *
4315 gimple_omp_for_pre_body_ptr (gimple gs)
4317 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4318 return &gs->gimple_omp_for.pre_body;
4322 /* Return the sequence of statements to execute before the OMP_FOR
4323 statement GS starts. */
4325 static inline gimple_seq
4326 gimple_omp_for_pre_body (gimple gs)
4328 return *gimple_omp_for_pre_body_ptr (gs);
4332 /* Set PRE_BODY to be the sequence of statements to execute before the
4333 OMP_FOR statement GS starts. */
4335 static inline void
4336 gimple_omp_for_set_pre_body (gimple gs, gimple_seq pre_body)
4338 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4339 gs->gimple_omp_for.pre_body = pre_body;
4343 /* Return the clauses associated with OMP_PARALLEL GS. */
4345 static inline tree
4346 gimple_omp_parallel_clauses (const_gimple gs)
4348 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
4349 return gs->gimple_omp_parallel.clauses;
4353 /* Return a pointer to the clauses associated with OMP_PARALLEL GS. */
4355 static inline tree *
4356 gimple_omp_parallel_clauses_ptr (gimple gs)
4358 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
4359 return &gs->gimple_omp_parallel.clauses;
4363 /* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL
4364 GS. */
4366 static inline void
4367 gimple_omp_parallel_set_clauses (gimple gs, tree clauses)
4369 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
4370 gs->gimple_omp_parallel.clauses = clauses;
4374 /* Return the child function used to hold the body of OMP_PARALLEL GS. */
4376 static inline tree
4377 gimple_omp_parallel_child_fn (const_gimple gs)
4379 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
4380 return gs->gimple_omp_parallel.child_fn;
4383 /* Return a pointer to the child function used to hold the body of
4384 OMP_PARALLEL GS. */
4386 static inline tree *
4387 gimple_omp_parallel_child_fn_ptr (gimple gs)
4389 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
4390 return &gs->gimple_omp_parallel.child_fn;
4394 /* Set CHILD_FN to be the child function for OMP_PARALLEL GS. */
4396 static inline void
4397 gimple_omp_parallel_set_child_fn (gimple gs, tree child_fn)
4399 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
4400 gs->gimple_omp_parallel.child_fn = child_fn;
4404 /* Return the artificial argument used to send variables and values
4405 from the parent to the children threads in OMP_PARALLEL GS. */
4407 static inline tree
4408 gimple_omp_parallel_data_arg (const_gimple gs)
4410 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
4411 return gs->gimple_omp_parallel.data_arg;
4415 /* Return a pointer to the data argument for OMP_PARALLEL GS. */
4417 static inline tree *
4418 gimple_omp_parallel_data_arg_ptr (gimple gs)
4420 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
4421 return &gs->gimple_omp_parallel.data_arg;
4425 /* Set DATA_ARG to be the data argument for OMP_PARALLEL GS. */
4427 static inline void
4428 gimple_omp_parallel_set_data_arg (gimple gs, tree data_arg)
4430 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
4431 gs->gimple_omp_parallel.data_arg = data_arg;
4435 /* Return the clauses associated with OMP_TASK GS. */
4437 static inline tree
4438 gimple_omp_task_clauses (const_gimple gs)
4440 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4441 return gs->gimple_omp_parallel.clauses;
4445 /* Return a pointer to the clauses associated with OMP_TASK GS. */
4447 static inline tree *
4448 gimple_omp_task_clauses_ptr (gimple gs)
4450 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4451 return &gs->gimple_omp_parallel.clauses;
4455 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
4456 GS. */
4458 static inline void
4459 gimple_omp_task_set_clauses (gimple gs, tree clauses)
4461 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4462 gs->gimple_omp_parallel.clauses = clauses;
4466 /* Return the child function used to hold the body of OMP_TASK GS. */
4468 static inline tree
4469 gimple_omp_task_child_fn (const_gimple gs)
4471 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4472 return gs->gimple_omp_parallel.child_fn;
4475 /* Return a pointer to the child function used to hold the body of
4476 OMP_TASK GS. */
4478 static inline tree *
4479 gimple_omp_task_child_fn_ptr (gimple gs)
4481 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4482 return &gs->gimple_omp_parallel.child_fn;
4486 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
4488 static inline void
4489 gimple_omp_task_set_child_fn (gimple gs, tree child_fn)
4491 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4492 gs->gimple_omp_parallel.child_fn = child_fn;
4496 /* Return the artificial argument used to send variables and values
4497 from the parent to the children threads in OMP_TASK GS. */
4499 static inline tree
4500 gimple_omp_task_data_arg (const_gimple gs)
4502 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4503 return gs->gimple_omp_parallel.data_arg;
4507 /* Return a pointer to the data argument for OMP_TASK GS. */
4509 static inline tree *
4510 gimple_omp_task_data_arg_ptr (gimple gs)
4512 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4513 return &gs->gimple_omp_parallel.data_arg;
4517 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
4519 static inline void
4520 gimple_omp_task_set_data_arg (gimple gs, tree data_arg)
4522 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4523 gs->gimple_omp_parallel.data_arg = data_arg;
4527 /* Return the clauses associated with OMP_TASK GS. */
4529 static inline tree
4530 gimple_omp_taskreg_clauses (const_gimple gs)
4532 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4533 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4534 return gs->gimple_omp_parallel.clauses;
4538 /* Return a pointer to the clauses associated with OMP_TASK GS. */
4540 static inline tree *
4541 gimple_omp_taskreg_clauses_ptr (gimple gs)
4543 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4544 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4545 return &gs->gimple_omp_parallel.clauses;
4549 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
4550 GS. */
4552 static inline void
4553 gimple_omp_taskreg_set_clauses (gimple gs, tree clauses)
4555 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4556 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4557 gs->gimple_omp_parallel.clauses = clauses;
4561 /* Return the child function used to hold the body of OMP_TASK GS. */
4563 static inline tree
4564 gimple_omp_taskreg_child_fn (const_gimple gs)
4566 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4567 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4568 return gs->gimple_omp_parallel.child_fn;
4571 /* Return a pointer to the child function used to hold the body of
4572 OMP_TASK GS. */
4574 static inline tree *
4575 gimple_omp_taskreg_child_fn_ptr (gimple gs)
4577 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4578 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4579 return &gs->gimple_omp_parallel.child_fn;
4583 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
4585 static inline void
4586 gimple_omp_taskreg_set_child_fn (gimple gs, tree child_fn)
4588 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4589 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4590 gs->gimple_omp_parallel.child_fn = child_fn;
4594 /* Return the artificial argument used to send variables and values
4595 from the parent to the children threads in OMP_TASK GS. */
4597 static inline tree
4598 gimple_omp_taskreg_data_arg (const_gimple gs)
4600 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4601 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4602 return gs->gimple_omp_parallel.data_arg;
4606 /* Return a pointer to the data argument for OMP_TASK GS. */
4608 static inline tree *
4609 gimple_omp_taskreg_data_arg_ptr (gimple gs)
4611 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4612 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4613 return &gs->gimple_omp_parallel.data_arg;
4617 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
4619 static inline void
4620 gimple_omp_taskreg_set_data_arg (gimple gs, tree data_arg)
4622 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4623 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4624 gs->gimple_omp_parallel.data_arg = data_arg;
4628 /* Return the copy function used to hold the body of OMP_TASK GS. */
4630 static inline tree
4631 gimple_omp_task_copy_fn (const_gimple gs)
4633 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4634 return gs->gimple_omp_task.copy_fn;
4637 /* Return a pointer to the copy function used to hold the body of
4638 OMP_TASK GS. */
4640 static inline tree *
4641 gimple_omp_task_copy_fn_ptr (gimple gs)
4643 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4644 return &gs->gimple_omp_task.copy_fn;
4648 /* Set CHILD_FN to be the copy function for OMP_TASK GS. */
4650 static inline void
4651 gimple_omp_task_set_copy_fn (gimple gs, tree copy_fn)
4653 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4654 gs->gimple_omp_task.copy_fn = copy_fn;
4658 /* Return size of the data block in bytes in OMP_TASK GS. */
4660 static inline tree
4661 gimple_omp_task_arg_size (const_gimple gs)
4663 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4664 return gs->gimple_omp_task.arg_size;
4668 /* Return a pointer to the data block size for OMP_TASK GS. */
4670 static inline tree *
4671 gimple_omp_task_arg_size_ptr (gimple gs)
4673 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4674 return &gs->gimple_omp_task.arg_size;
4678 /* Set ARG_SIZE to be the data block size for OMP_TASK GS. */
4680 static inline void
4681 gimple_omp_task_set_arg_size (gimple gs, tree arg_size)
4683 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4684 gs->gimple_omp_task.arg_size = arg_size;
4688 /* Return align of the data block in bytes in OMP_TASK GS. */
4690 static inline tree
4691 gimple_omp_task_arg_align (const_gimple gs)
4693 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4694 return gs->gimple_omp_task.arg_align;
4698 /* Return a pointer to the data block align for OMP_TASK GS. */
4700 static inline tree *
4701 gimple_omp_task_arg_align_ptr (gimple gs)
4703 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4704 return &gs->gimple_omp_task.arg_align;
4708 /* Set ARG_SIZE to be the data block align for OMP_TASK GS. */
4710 static inline void
4711 gimple_omp_task_set_arg_align (gimple gs, tree arg_align)
4713 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4714 gs->gimple_omp_task.arg_align = arg_align;
4718 /* Return the clauses associated with OMP_SINGLE GS. */
4720 static inline tree
4721 gimple_omp_single_clauses (const_gimple gs)
4723 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
4724 return gs->gimple_omp_single.clauses;
4728 /* Return a pointer to the clauses associated with OMP_SINGLE GS. */
4730 static inline tree *
4731 gimple_omp_single_clauses_ptr (gimple gs)
4733 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
4734 return &gs->gimple_omp_single.clauses;
4738 /* Set CLAUSES to be the clauses associated with OMP_SINGLE GS. */
4740 static inline void
4741 gimple_omp_single_set_clauses (gimple gs, tree clauses)
4743 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
4744 gs->gimple_omp_single.clauses = clauses;
4748 /* Return the clauses associated with OMP_TARGET GS. */
4750 static inline tree
4751 gimple_omp_target_clauses (const_gimple gs)
4753 GIMPLE_CHECK (gs, GIMPLE_OMP_TARGET);
4754 return gs->gimple_omp_parallel.clauses;
4758 /* Return a pointer to the clauses associated with OMP_TARGET GS. */
4760 static inline tree *
4761 gimple_omp_target_clauses_ptr (gimple gs)
4763 GIMPLE_CHECK (gs, GIMPLE_OMP_TARGET);
4764 return &gs->gimple_omp_parallel.clauses;
4768 /* Set CLAUSES to be the clauses associated with OMP_TARGET GS. */
4770 static inline void
4771 gimple_omp_target_set_clauses (gimple gs, tree clauses)
4773 GIMPLE_CHECK (gs, GIMPLE_OMP_TARGET);
4774 gs->gimple_omp_parallel.clauses = clauses;
4778 /* Return the kind of OMP target statemement. */
4780 static inline int
4781 gimple_omp_target_kind (const_gimple g)
4783 GIMPLE_CHECK (g, GIMPLE_OMP_TARGET);
4784 return (gimple_omp_subcode (g) & GF_OMP_TARGET_KIND_MASK);
4788 /* Set the OMP target kind. */
4790 static inline void
4791 gimple_omp_target_set_kind (gimple g, int kind)
4793 GIMPLE_CHECK (g, GIMPLE_OMP_TARGET);
4794 g->gsbase.subcode = (g->gsbase.subcode & ~GF_OMP_TARGET_KIND_MASK)
4795 | (kind & GF_OMP_TARGET_KIND_MASK);
4799 /* Return the child function used to hold the body of OMP_TARGET GS. */
4801 static inline tree
4802 gimple_omp_target_child_fn (const_gimple gs)
4804 GIMPLE_CHECK (gs, GIMPLE_OMP_TARGET);
4805 return gs->gimple_omp_parallel.child_fn;
4808 /* Return a pointer to the child function used to hold the body of
4809 OMP_TARGET GS. */
4811 static inline tree *
4812 gimple_omp_target_child_fn_ptr (gimple gs)
4814 GIMPLE_CHECK (gs, GIMPLE_OMP_TARGET);
4815 return &gs->gimple_omp_parallel.child_fn;
4819 /* Set CHILD_FN to be the child function for OMP_TARGET GS. */
4821 static inline void
4822 gimple_omp_target_set_child_fn (gimple gs, tree child_fn)
4824 GIMPLE_CHECK (gs, GIMPLE_OMP_TARGET);
4825 gs->gimple_omp_parallel.child_fn = child_fn;
4829 /* Return the artificial argument used to send variables and values
4830 from the parent to the children threads in OMP_TARGET GS. */
4832 static inline tree
4833 gimple_omp_target_data_arg (const_gimple gs)
4835 GIMPLE_CHECK (gs, GIMPLE_OMP_TARGET);
4836 return gs->gimple_omp_parallel.data_arg;
4840 /* Return a pointer to the data argument for OMP_TARGET GS. */
4842 static inline tree *
4843 gimple_omp_target_data_arg_ptr (gimple gs)
4845 GIMPLE_CHECK (gs, GIMPLE_OMP_TARGET);
4846 return &gs->gimple_omp_parallel.data_arg;
4850 /* Set DATA_ARG to be the data argument for OMP_TARGET GS. */
4852 static inline void
4853 gimple_omp_target_set_data_arg (gimple gs, tree data_arg)
4855 GIMPLE_CHECK (gs, GIMPLE_OMP_TARGET);
4856 gs->gimple_omp_parallel.data_arg = data_arg;
4860 /* Return the clauses associated with OMP_TEAMS GS. */
4862 static inline tree
4863 gimple_omp_teams_clauses (const_gimple gs)
4865 GIMPLE_CHECK (gs, GIMPLE_OMP_TEAMS);
4866 return gs->gimple_omp_single.clauses;
4870 /* Return a pointer to the clauses associated with OMP_TEAMS GS. */
4872 static inline tree *
4873 gimple_omp_teams_clauses_ptr (gimple gs)
4875 GIMPLE_CHECK (gs, GIMPLE_OMP_TEAMS);
4876 return &gs->gimple_omp_single.clauses;
4880 /* Set CLAUSES to be the clauses associated with OMP_TEAMS GS. */
4882 static inline void
4883 gimple_omp_teams_set_clauses (gimple gs, tree clauses)
4885 GIMPLE_CHECK (gs, GIMPLE_OMP_TEAMS);
4886 gs->gimple_omp_single.clauses = clauses;
4890 /* Return the clauses associated with OMP_SECTIONS GS. */
4892 static inline tree
4893 gimple_omp_sections_clauses (const_gimple gs)
4895 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4896 return gs->gimple_omp_sections.clauses;
4900 /* Return a pointer to the clauses associated with OMP_SECTIONS GS. */
4902 static inline tree *
4903 gimple_omp_sections_clauses_ptr (gimple gs)
4905 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4906 return &gs->gimple_omp_sections.clauses;
4910 /* Set CLAUSES to be the set of clauses associated with OMP_SECTIONS
4911 GS. */
4913 static inline void
4914 gimple_omp_sections_set_clauses (gimple gs, tree clauses)
4916 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4917 gs->gimple_omp_sections.clauses = clauses;
4921 /* Return the control variable associated with the GIMPLE_OMP_SECTIONS
4922 in GS. */
4924 static inline tree
4925 gimple_omp_sections_control (const_gimple gs)
4927 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4928 return gs->gimple_omp_sections.control;
4932 /* Return a pointer to the clauses associated with the GIMPLE_OMP_SECTIONS
4933 GS. */
4935 static inline tree *
4936 gimple_omp_sections_control_ptr (gimple gs)
4938 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4939 return &gs->gimple_omp_sections.control;
4943 /* Set CONTROL to be the set of clauses associated with the
4944 GIMPLE_OMP_SECTIONS in GS. */
4946 static inline void
4947 gimple_omp_sections_set_control (gimple gs, tree control)
4949 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4950 gs->gimple_omp_sections.control = control;
4954 /* Set COND to be the condition code for OMP_FOR GS. */
4956 static inline void
4957 gimple_omp_for_set_cond (gimple gs, size_t i, enum tree_code cond)
4959 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4960 gcc_gimple_checking_assert (TREE_CODE_CLASS (cond) == tcc_comparison
4961 && i < gs->gimple_omp_for.collapse);
4962 gs->gimple_omp_for.iter[i].cond = cond;
4966 /* Return the condition code associated with OMP_FOR GS. */
4968 static inline enum tree_code
4969 gimple_omp_for_cond (const_gimple gs, size_t i)
4971 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4972 gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4973 return gs->gimple_omp_for.iter[i].cond;
4977 /* Set the value being stored in an atomic store. */
4979 static inline void
4980 gimple_omp_atomic_store_set_val (gimple g, tree val)
4982 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4983 g->gimple_omp_atomic_store.val = val;
4987 /* Return the value being stored in an atomic store. */
4989 static inline tree
4990 gimple_omp_atomic_store_val (const_gimple g)
4992 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4993 return g->gimple_omp_atomic_store.val;
4997 /* Return a pointer to the value being stored in an atomic store. */
4999 static inline tree *
5000 gimple_omp_atomic_store_val_ptr (gimple g)
5002 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
5003 return &g->gimple_omp_atomic_store.val;
5007 /* Set the LHS of an atomic load. */
5009 static inline void
5010 gimple_omp_atomic_load_set_lhs (gimple g, tree lhs)
5012 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
5013 g->gimple_omp_atomic_load.lhs = lhs;
5017 /* Get the LHS of an atomic load. */
5019 static inline tree
5020 gimple_omp_atomic_load_lhs (const_gimple g)
5022 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
5023 return g->gimple_omp_atomic_load.lhs;
5027 /* Return a pointer to the LHS of an atomic load. */
5029 static inline tree *
5030 gimple_omp_atomic_load_lhs_ptr (gimple g)
5032 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
5033 return &g->gimple_omp_atomic_load.lhs;
5037 /* Set the RHS of an atomic load. */
5039 static inline void
5040 gimple_omp_atomic_load_set_rhs (gimple g, tree rhs)
5042 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
5043 g->gimple_omp_atomic_load.rhs = rhs;
5047 /* Get the RHS of an atomic load. */
5049 static inline tree
5050 gimple_omp_atomic_load_rhs (const_gimple g)
5052 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
5053 return g->gimple_omp_atomic_load.rhs;
5057 /* Return a pointer to the RHS of an atomic load. */
5059 static inline tree *
5060 gimple_omp_atomic_load_rhs_ptr (gimple g)
5062 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
5063 return &g->gimple_omp_atomic_load.rhs;
5067 /* Get the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
5069 static inline tree
5070 gimple_omp_continue_control_def (const_gimple g)
5072 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
5073 return g->gimple_omp_continue.control_def;
5076 /* The same as above, but return the address. */
5078 static inline tree *
5079 gimple_omp_continue_control_def_ptr (gimple g)
5081 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
5082 return &g->gimple_omp_continue.control_def;
5085 /* Set the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
5087 static inline void
5088 gimple_omp_continue_set_control_def (gimple g, tree def)
5090 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
5091 g->gimple_omp_continue.control_def = def;
5095 /* Get the use of the control variable in a GIMPLE_OMP_CONTINUE. */
5097 static inline tree
5098 gimple_omp_continue_control_use (const_gimple g)
5100 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
5101 return g->gimple_omp_continue.control_use;
5105 /* The same as above, but return the address. */
5107 static inline tree *
5108 gimple_omp_continue_control_use_ptr (gimple g)
5110 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
5111 return &g->gimple_omp_continue.control_use;
5115 /* Set the use of the control variable in a GIMPLE_OMP_CONTINUE. */
5117 static inline void
5118 gimple_omp_continue_set_control_use (gimple g, tree use)
5120 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
5121 g->gimple_omp_continue.control_use = use;
5124 /* Return a pointer to the body for the GIMPLE_TRANSACTION statement GS. */
5126 static inline gimple_seq *
5127 gimple_transaction_body_ptr (gimple gs)
5129 GIMPLE_CHECK (gs, GIMPLE_TRANSACTION);
5130 return &gs->gimple_transaction.body;
5133 /* Return the body for the GIMPLE_TRANSACTION statement GS. */
5135 static inline gimple_seq
5136 gimple_transaction_body (gimple gs)
5138 return *gimple_transaction_body_ptr (gs);
5141 /* Return the label associated with a GIMPLE_TRANSACTION. */
5143 static inline tree
5144 gimple_transaction_label (const_gimple gs)
5146 GIMPLE_CHECK (gs, GIMPLE_TRANSACTION);
5147 return gs->gimple_transaction.label;
5150 static inline tree *
5151 gimple_transaction_label_ptr (gimple gs)
5153 GIMPLE_CHECK (gs, GIMPLE_TRANSACTION);
5154 return &gs->gimple_transaction.label;
5157 /* Return the subcode associated with a GIMPLE_TRANSACTION. */
5159 static inline unsigned int
5160 gimple_transaction_subcode (const_gimple gs)
5162 GIMPLE_CHECK (gs, GIMPLE_TRANSACTION);
5163 return gs->gsbase.subcode;
5166 /* Set BODY to be the body for the GIMPLE_TRANSACTION statement GS. */
5168 static inline void
5169 gimple_transaction_set_body (gimple gs, gimple_seq body)
5171 GIMPLE_CHECK (gs, GIMPLE_TRANSACTION);
5172 gs->gimple_transaction.body = body;
5175 /* Set the label associated with a GIMPLE_TRANSACTION. */
5177 static inline void
5178 gimple_transaction_set_label (gimple gs, tree label)
5180 GIMPLE_CHECK (gs, GIMPLE_TRANSACTION);
5181 gs->gimple_transaction.label = label;
5184 /* Set the subcode associated with a GIMPLE_TRANSACTION. */
5186 static inline void
5187 gimple_transaction_set_subcode (gimple gs, unsigned int subcode)
5189 GIMPLE_CHECK (gs, GIMPLE_TRANSACTION);
5190 gs->gsbase.subcode = subcode;
5194 /* Return a pointer to the return value for GIMPLE_RETURN GS. */
5196 static inline tree *
5197 gimple_return_retval_ptr (const_gimple gs)
5199 GIMPLE_CHECK (gs, GIMPLE_RETURN);
5200 return gimple_op_ptr (gs, 0);
5203 /* Return the return value for GIMPLE_RETURN GS. */
5205 static inline tree
5206 gimple_return_retval (const_gimple gs)
5208 GIMPLE_CHECK (gs, GIMPLE_RETURN);
5209 return gimple_op (gs, 0);
5213 /* Set RETVAL to be the return value for GIMPLE_RETURN GS. */
5215 static inline void
5216 gimple_return_set_retval (gimple gs, tree retval)
5218 GIMPLE_CHECK (gs, GIMPLE_RETURN);
5219 gimple_set_op (gs, 0, retval);
5223 /* Returns true when the gimple statement STMT is any of the OpenMP types. */
5225 #define CASE_GIMPLE_OMP \
5226 case GIMPLE_OMP_PARALLEL: \
5227 case GIMPLE_OMP_TASK: \
5228 case GIMPLE_OMP_FOR: \
5229 case GIMPLE_OMP_SECTIONS: \
5230 case GIMPLE_OMP_SECTIONS_SWITCH: \
5231 case GIMPLE_OMP_SINGLE: \
5232 case GIMPLE_OMP_TARGET: \
5233 case GIMPLE_OMP_TEAMS: \
5234 case GIMPLE_OMP_SECTION: \
5235 case GIMPLE_OMP_MASTER: \
5236 case GIMPLE_OMP_TASKGROUP: \
5237 case GIMPLE_OMP_ORDERED: \
5238 case GIMPLE_OMP_CRITICAL: \
5239 case GIMPLE_OMP_RETURN: \
5240 case GIMPLE_OMP_ATOMIC_LOAD: \
5241 case GIMPLE_OMP_ATOMIC_STORE: \
5242 case GIMPLE_OMP_CONTINUE
5244 static inline bool
5245 is_gimple_omp (const_gimple stmt)
5247 switch (gimple_code (stmt))
5249 CASE_GIMPLE_OMP:
5250 return true;
5251 default:
5252 return false;
5257 /* Returns TRUE if statement G is a GIMPLE_NOP. */
5259 static inline bool
5260 gimple_nop_p (const_gimple g)
5262 return gimple_code (g) == GIMPLE_NOP;
5266 /* Return true if GS is a GIMPLE_RESX. */
5268 static inline bool
5269 is_gimple_resx (const_gimple gs)
5271 return gimple_code (gs) == GIMPLE_RESX;
5274 /* Return the predictor of GIMPLE_PREDICT statement GS. */
5276 static inline enum br_predictor
5277 gimple_predict_predictor (gimple gs)
5279 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
5280 return (enum br_predictor) (gs->gsbase.subcode & ~GF_PREDICT_TAKEN);
5284 /* Set the predictor of GIMPLE_PREDICT statement GS to PREDICT. */
5286 static inline void
5287 gimple_predict_set_predictor (gimple gs, enum br_predictor predictor)
5289 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
5290 gs->gsbase.subcode = (gs->gsbase.subcode & GF_PREDICT_TAKEN)
5291 | (unsigned) predictor;
5295 /* Return the outcome of GIMPLE_PREDICT statement GS. */
5297 static inline enum prediction
5298 gimple_predict_outcome (gimple gs)
5300 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
5301 return (gs->gsbase.subcode & GF_PREDICT_TAKEN) ? TAKEN : NOT_TAKEN;
5305 /* Set the outcome of GIMPLE_PREDICT statement GS to OUTCOME. */
5307 static inline void
5308 gimple_predict_set_outcome (gimple gs, enum prediction outcome)
5310 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
5311 if (outcome == TAKEN)
5312 gs->gsbase.subcode |= GF_PREDICT_TAKEN;
5313 else
5314 gs->gsbase.subcode &= ~GF_PREDICT_TAKEN;
5318 /* Return the type of the main expression computed by STMT. Return
5319 void_type_node if the statement computes nothing. */
5321 static inline tree
5322 gimple_expr_type (const_gimple stmt)
5324 enum gimple_code code = gimple_code (stmt);
5326 if (code == GIMPLE_ASSIGN || code == GIMPLE_CALL)
5328 tree type;
5329 /* In general we want to pass out a type that can be substituted
5330 for both the RHS and the LHS types if there is a possibly
5331 useless conversion involved. That means returning the
5332 original RHS type as far as we can reconstruct it. */
5333 if (code == GIMPLE_CALL)
5334 type = gimple_call_return_type (stmt);
5335 else
5336 switch (gimple_assign_rhs_code (stmt))
5338 case POINTER_PLUS_EXPR:
5339 type = TREE_TYPE (gimple_assign_rhs1 (stmt));
5340 break;
5342 default:
5343 /* As fallback use the type of the LHS. */
5344 type = TREE_TYPE (gimple_get_lhs (stmt));
5345 break;
5347 return type;
5349 else if (code == GIMPLE_COND)
5350 return boolean_type_node;
5351 else
5352 return void_type_node;
5355 /* Return true if TYPE is a suitable type for a scalar register variable. */
5357 static inline bool
5358 is_gimple_reg_type (tree type)
5360 return !AGGREGATE_TYPE_P (type);
5363 /* Return a new iterator pointing to GIMPLE_SEQ's first statement. */
5365 static inline gimple_stmt_iterator
5366 gsi_start_1 (gimple_seq *seq)
5368 gimple_stmt_iterator i;
5370 i.ptr = gimple_seq_first (*seq);
5371 i.seq = seq;
5372 i.bb = i.ptr ? gimple_bb (i.ptr) : NULL;
5374 return i;
5377 #define gsi_start(x) gsi_start_1 (&(x))
5379 static inline gimple_stmt_iterator
5380 gsi_none (void)
5382 gimple_stmt_iterator i;
5383 i.ptr = NULL;
5384 i.seq = NULL;
5385 i.bb = NULL;
5386 return i;
5389 /* Return a new iterator pointing to the first statement in basic block BB. */
5391 static inline gimple_stmt_iterator
5392 gsi_start_bb (basic_block bb)
5394 gimple_stmt_iterator i;
5395 gimple_seq *seq;
5397 seq = bb_seq_addr (bb);
5398 i.ptr = gimple_seq_first (*seq);
5399 i.seq = seq;
5400 i.bb = bb;
5402 return i;
5406 /* Return a new iterator initially pointing to GIMPLE_SEQ's last statement. */
5408 static inline gimple_stmt_iterator
5409 gsi_last_1 (gimple_seq *seq)
5411 gimple_stmt_iterator i;
5413 i.ptr = gimple_seq_last (*seq);
5414 i.seq = seq;
5415 i.bb = i.ptr ? gimple_bb (i.ptr) : NULL;
5417 return i;
5420 #define gsi_last(x) gsi_last_1 (&(x))
5422 /* Return a new iterator pointing to the last statement in basic block BB. */
5424 static inline gimple_stmt_iterator
5425 gsi_last_bb (basic_block bb)
5427 gimple_stmt_iterator i;
5428 gimple_seq *seq;
5430 seq = bb_seq_addr (bb);
5431 i.ptr = gimple_seq_last (*seq);
5432 i.seq = seq;
5433 i.bb = bb;
5435 return i;
5439 /* Return true if I is at the end of its sequence. */
5441 static inline bool
5442 gsi_end_p (gimple_stmt_iterator i)
5444 return i.ptr == NULL;
5448 /* Return true if I is one statement before the end of its sequence. */
5450 static inline bool
5451 gsi_one_before_end_p (gimple_stmt_iterator i)
5453 return i.ptr != NULL && i.ptr->gsbase.next == NULL;
5457 /* Advance the iterator to the next gimple statement. */
5459 static inline void
5460 gsi_next (gimple_stmt_iterator *i)
5462 i->ptr = i->ptr->gsbase.next;
5465 /* Advance the iterator to the previous gimple statement. */
5467 static inline void
5468 gsi_prev (gimple_stmt_iterator *i)
5470 gimple prev = i->ptr->gsbase.prev;
5471 if (prev->gsbase.next)
5472 i->ptr = prev;
5473 else
5474 i->ptr = NULL;
5477 /* Return the current stmt. */
5479 static inline gimple
5480 gsi_stmt (gimple_stmt_iterator i)
5482 return i.ptr;
5485 /* Return a block statement iterator that points to the first non-label
5486 statement in block BB. */
5488 static inline gimple_stmt_iterator
5489 gsi_after_labels (basic_block bb)
5491 gimple_stmt_iterator gsi = gsi_start_bb (bb);
5493 while (!gsi_end_p (gsi) && gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL)
5494 gsi_next (&gsi);
5496 return gsi;
5499 /* Advance the iterator to the next non-debug gimple statement. */
5501 static inline void
5502 gsi_next_nondebug (gimple_stmt_iterator *i)
5506 gsi_next (i);
5508 while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
5511 /* Advance the iterator to the next non-debug gimple statement. */
5513 static inline void
5514 gsi_prev_nondebug (gimple_stmt_iterator *i)
5518 gsi_prev (i);
5520 while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
5523 /* Return a new iterator pointing to the first non-debug statement in
5524 basic block BB. */
5526 static inline gimple_stmt_iterator
5527 gsi_start_nondebug_bb (basic_block bb)
5529 gimple_stmt_iterator i = gsi_start_bb (bb);
5531 if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
5532 gsi_next_nondebug (&i);
5534 return i;
5537 /* Return a new iterator pointing to the last non-debug statement in
5538 basic block BB. */
5540 static inline gimple_stmt_iterator
5541 gsi_last_nondebug_bb (basic_block bb)
5543 gimple_stmt_iterator i = gsi_last_bb (bb);
5545 if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
5546 gsi_prev_nondebug (&i);
5548 return i;
5552 /* Return the basic block associated with this iterator. */
5554 static inline basic_block
5555 gsi_bb (gimple_stmt_iterator i)
5557 return i.bb;
5561 /* Return the sequence associated with this iterator. */
5563 static inline gimple_seq
5564 gsi_seq (gimple_stmt_iterator i)
5566 return *i.seq;
5570 enum gsi_iterator_update
5572 GSI_NEW_STMT, /* Only valid when single statement is added, move
5573 iterator to it. */
5574 GSI_SAME_STMT, /* Leave the iterator at the same statement. */
5575 GSI_CONTINUE_LINKING /* Move iterator to whatever position is suitable
5576 for linking other statements in the same
5577 direction. */
5580 /* In gimple-iterator.c */
5581 gimple_stmt_iterator gsi_start_phis (basic_block);
5582 gimple_seq gsi_split_seq_after (gimple_stmt_iterator);
5583 void gsi_split_seq_before (gimple_stmt_iterator *, gimple_seq *);
5584 void gsi_set_stmt (gimple_stmt_iterator *, gimple);
5585 void gsi_replace (gimple_stmt_iterator *, gimple, bool);
5586 void gsi_replace_with_seq (gimple_stmt_iterator *, gimple_seq, bool);
5587 void gsi_insert_before (gimple_stmt_iterator *, gimple,
5588 enum gsi_iterator_update);
5589 void gsi_insert_before_without_update (gimple_stmt_iterator *, gimple,
5590 enum gsi_iterator_update);
5591 void gsi_insert_seq_before (gimple_stmt_iterator *, gimple_seq,
5592 enum gsi_iterator_update);
5593 void gsi_insert_seq_before_without_update (gimple_stmt_iterator *, gimple_seq,
5594 enum gsi_iterator_update);
5595 void gsi_insert_after (gimple_stmt_iterator *, gimple,
5596 enum gsi_iterator_update);
5597 void gsi_insert_after_without_update (gimple_stmt_iterator *, gimple,
5598 enum gsi_iterator_update);
5599 void gsi_insert_seq_after (gimple_stmt_iterator *, gimple_seq,
5600 enum gsi_iterator_update);
5601 void gsi_insert_seq_after_without_update (gimple_stmt_iterator *, gimple_seq,
5602 enum gsi_iterator_update);
5603 bool gsi_remove (gimple_stmt_iterator *, bool);
5604 gimple_stmt_iterator gsi_for_stmt (gimple);
5605 void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *);
5606 void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *);
5607 void gsi_move_to_bb_end (gimple_stmt_iterator *, basic_block);
5608 void gsi_insert_on_edge (edge, gimple);
5609 void gsi_insert_seq_on_edge (edge, gimple_seq);
5610 basic_block gsi_insert_on_edge_immediate (edge, gimple);
5611 basic_block gsi_insert_seq_on_edge_immediate (edge, gimple_seq);
5612 void gsi_commit_one_edge_insert (edge, basic_block *);
5613 void gsi_commit_edge_inserts (void);
5614 gimple gimple_call_copy_skip_args (gimple, bitmap);
5616 /* In gimplify.c. */
5617 tree force_gimple_operand_1 (tree, gimple_seq *, gimple_predicate, tree);
5618 tree force_gimple_operand (tree, gimple_seq *, bool, tree);
5619 tree force_gimple_operand_gsi_1 (gimple_stmt_iterator *, tree,
5620 gimple_predicate, tree,
5621 bool, enum gsi_iterator_update);
5622 tree force_gimple_operand_gsi (gimple_stmt_iterator *, tree, bool, tree,
5623 bool, enum gsi_iterator_update);
5625 /* Convenience routines to walk all statements of a gimple function.
5626 Note that this is useful exclusively before the code is converted
5627 into SSA form. Once the program is in SSA form, the standard
5628 operand interface should be used to analyze/modify statements. */
5629 struct walk_stmt_info
5631 /* Points to the current statement being walked. */
5632 gimple_stmt_iterator gsi;
5634 /* Additional data that the callback functions may want to carry
5635 through the recursion. */
5636 void *info;
5638 /* Pointer map used to mark visited tree nodes when calling
5639 walk_tree on each operand. If set to NULL, duplicate tree nodes
5640 will be visited more than once. */
5641 struct pointer_set_t *pset;
5643 /* Operand returned by the callbacks. This is set when calling
5644 walk_gimple_seq. If the walk_stmt_fn or walk_tree_fn callback
5645 returns non-NULL, this field will contain the tree returned by
5646 the last callback. */
5647 tree callback_result;
5649 /* Indicates whether the operand being examined may be replaced
5650 with something that matches is_gimple_val (if true) or something
5651 slightly more complicated (if false). "Something" technically
5652 means the common subset of is_gimple_lvalue and is_gimple_rhs,
5653 but we never try to form anything more complicated than that, so
5654 we don't bother checking.
5656 Also note that CALLBACK should update this flag while walking the
5657 sub-expressions of a statement. For instance, when walking the
5658 statement 'foo (&var)', the flag VAL_ONLY will initially be set
5659 to true, however, when walking &var, the operand of that
5660 ADDR_EXPR does not need to be a GIMPLE value. */
5661 BOOL_BITFIELD val_only : 1;
5663 /* True if we are currently walking the LHS of an assignment. */
5664 BOOL_BITFIELD is_lhs : 1;
5666 /* Optional. Set to true by the callback functions if they made any
5667 changes. */
5668 BOOL_BITFIELD changed : 1;
5670 /* True if we're interested in location information. */
5671 BOOL_BITFIELD want_locations : 1;
5673 /* True if we've removed the statement that was processed. */
5674 BOOL_BITFIELD removed_stmt : 1;
5677 /* Callback for walk_gimple_stmt. Called for every statement found
5678 during traversal. The first argument points to the statement to
5679 walk. The second argument is a flag that the callback sets to
5680 'true' if it the callback handled all the operands and
5681 sub-statements of the statement (the default value of this flag is
5682 'false'). The third argument is an anonymous pointer to data
5683 to be used by the callback. */
5684 typedef tree (*walk_stmt_fn) (gimple_stmt_iterator *, bool *,
5685 struct walk_stmt_info *);
5687 gimple walk_gimple_seq (gimple_seq, walk_stmt_fn, walk_tree_fn,
5688 struct walk_stmt_info *);
5689 gimple walk_gimple_seq_mod (gimple_seq *, walk_stmt_fn, walk_tree_fn,
5690 struct walk_stmt_info *);
5691 tree walk_gimple_stmt (gimple_stmt_iterator *, walk_stmt_fn, walk_tree_fn,
5692 struct walk_stmt_info *);
5693 tree walk_gimple_op (gimple, walk_tree_fn, struct walk_stmt_info *);
5695 /* Enum and arrays used for allocation stats. Keep in sync with
5696 gimple.c:gimple_alloc_kind_names. */
5697 enum gimple_alloc_kind
5699 gimple_alloc_kind_assign, /* Assignments. */
5700 gimple_alloc_kind_phi, /* PHI nodes. */
5701 gimple_alloc_kind_cond, /* Conditionals. */
5702 gimple_alloc_kind_rest, /* Everything else. */
5703 gimple_alloc_kind_all
5706 extern int gimple_alloc_counts[];
5707 extern int gimple_alloc_sizes[];
5709 /* Return the allocation kind for a given stmt CODE. */
5710 static inline enum gimple_alloc_kind
5711 gimple_alloc_kind (enum gimple_code code)
5713 switch (code)
5715 case GIMPLE_ASSIGN:
5716 return gimple_alloc_kind_assign;
5717 case GIMPLE_PHI:
5718 return gimple_alloc_kind_phi;
5719 case GIMPLE_COND:
5720 return gimple_alloc_kind_cond;
5721 default:
5722 return gimple_alloc_kind_rest;
5726 extern void dump_gimple_statistics (void);
5728 /* Set the location of all statements in SEQ to LOC. */
5730 static inline void
5731 gimple_seq_set_location (gimple_seq seq, location_t loc)
5733 for (gimple_stmt_iterator i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
5734 gimple_set_location (gsi_stmt (i), loc);
5737 /* Macros for showing usage statistics. */
5738 #define SCALE(x) ((unsigned long) ((x) < 1024*10 \
5739 ? (x) \
5740 : ((x) < 1024*1024*10 \
5741 ? (x) / 1024 \
5742 : (x) / (1024*1024))))
5744 #define LABEL(x) ((x) < 1024*10 ? 'b' : ((x) < 1024*1024*10 ? 'k' : 'M'))
5746 #define PERCENT(x,y) ((float)(x) * 100.0 / (float)(y))
5748 #endif /* GCC_GIMPLE_H */