2009-05-06 Tobias Burnus <burnus@net-b.de>
[official-gcc/alias-decl.git] / gcc / gimple.h
blobd3f8f8fb8c449271eace53dfac0ff275bbe1e4fd
1 /* Gimple IR definitions.
3 Copyright 2007, 2008, 2009 Free Software Foundation, Inc.
4 Contributed by Aldy Hernandez <aldyh@redhat.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
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 "vec.h"
27 #include "ggc.h"
28 #include "tm.h"
29 #include "hard-reg-set.h"
30 #include "basic-block.h"
31 #include "tree-ssa-operands.h"
33 DEF_VEC_P(gimple);
34 DEF_VEC_ALLOC_P(gimple,heap);
35 DEF_VEC_ALLOC_P(gimple,gc);
37 typedef gimple *gimple_p;
38 DEF_VEC_P(gimple_p);
39 DEF_VEC_ALLOC_P(gimple_p,heap);
41 DEF_VEC_P(gimple_seq);
42 DEF_VEC_ALLOC_P(gimple_seq,gc);
43 DEF_VEC_ALLOC_P(gimple_seq,heap);
45 /* For each block, the PHI nodes that need to be rewritten are stored into
46 these vectors. */
47 typedef VEC(gimple, heap) *gimple_vec;
48 DEF_VEC_P (gimple_vec);
49 DEF_VEC_ALLOC_P (gimple_vec, heap);
51 enum gimple_code {
52 #define DEFGSCODE(SYM, STRING, STRUCT) SYM,
53 #include "gimple.def"
54 #undef DEFGSCODE
55 LAST_AND_UNUSED_GIMPLE_CODE
58 extern const char *const gimple_code_name[];
59 extern const unsigned char gimple_rhs_class_table[];
61 /* Error out if a gimple tuple is addressed incorrectly. */
62 #if defined ENABLE_GIMPLE_CHECKING
63 extern void gimple_check_failed (const_gimple, const char *, int, \
64 const char *, enum gimple_code, \
65 enum tree_code) ATTRIBUTE_NORETURN;
67 #define GIMPLE_CHECK(GS, CODE) \
68 do { \
69 const_gimple __gs = (GS); \
70 if (gimple_code (__gs) != (CODE)) \
71 gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__, \
72 (CODE), ERROR_MARK); \
73 } while (0)
74 #else /* not ENABLE_GIMPLE_CHECKING */
75 #define GIMPLE_CHECK(GS, CODE) (void)0
76 #endif
78 /* Class of GIMPLE expressions suitable for the RHS of assignments. See
79 get_gimple_rhs_class. */
80 enum gimple_rhs_class
82 GIMPLE_INVALID_RHS, /* The expression cannot be used on the RHS. */
83 GIMPLE_BINARY_RHS, /* The expression is a binary operation. */
84 GIMPLE_UNARY_RHS, /* The expression is a unary operation. */
85 GIMPLE_SINGLE_RHS /* The expression is a single object (an SSA
86 name, a _DECL, a _REF, etc. */
89 /* Specific flags for individual GIMPLE statements. These flags are
90 always stored in gimple_statement_base.subcode and they may only be
91 defined for statement codes that do not use sub-codes.
93 Values for the masks can overlap as long as the overlapping values
94 are never used in the same statement class.
96 The maximum mask value that can be defined is 1 << 15 (i.e., each
97 statement code can hold up to 16 bitflags).
99 Keep this list sorted. */
100 enum gf_mask {
101 GF_ASM_INPUT = 1 << 0,
102 GF_ASM_VOLATILE = 1 << 1,
103 GF_CALL_CANNOT_INLINE = 1 << 0,
104 GF_CALL_FROM_THUNK = 1 << 1,
105 GF_CALL_RETURN_SLOT_OPT = 1 << 2,
106 GF_CALL_TAILCALL = 1 << 3,
107 GF_CALL_VA_ARG_PACK = 1 << 4,
108 GF_OMP_PARALLEL_COMBINED = 1 << 0,
110 /* True on an GIMPLE_OMP_RETURN statement if the return does not require
111 a thread synchronization via some sort of barrier. The exact barrier
112 that would otherwise be emitted is dependent on the OMP statement with
113 which this return is associated. */
114 GF_OMP_RETURN_NOWAIT = 1 << 0,
116 GF_OMP_SECTION_LAST = 1 << 0,
117 GF_PREDICT_TAKEN = 1 << 15
120 /* Masks for selecting a pass local flag (PLF) to work on. These
121 masks are used by gimple_set_plf and gimple_plf. */
122 enum plf_mask {
123 GF_PLF_1 = 1 << 0,
124 GF_PLF_2 = 1 << 1
127 /* A node in a gimple_seq_d. */
128 struct GTY((chain_next ("%h.next"), chain_prev ("%h.prev"))) gimple_seq_node_d {
129 gimple stmt;
130 struct gimple_seq_node_d *prev;
131 struct gimple_seq_node_d *next;
134 /* A double-linked sequence of gimple statements. */
135 struct GTY ((chain_next ("%h.next_free"))) gimple_seq_d {
136 /* First and last statements in the sequence. */
137 gimple_seq_node first;
138 gimple_seq_node last;
140 /* Sequences are created/destroyed frequently. To minimize
141 allocation activity, deallocated sequences are kept in a pool of
142 available sequences. This is the pointer to the next free
143 sequence in the pool. */
144 gimple_seq next_free;
148 /* Return the first node in GIMPLE sequence S. */
150 static inline gimple_seq_node
151 gimple_seq_first (const_gimple_seq s)
153 return s ? s->first : NULL;
157 /* Return the first statement in GIMPLE sequence S. */
159 static inline gimple
160 gimple_seq_first_stmt (const_gimple_seq s)
162 gimple_seq_node n = gimple_seq_first (s);
163 return (n) ? n->stmt : NULL;
167 /* Return the last node in GIMPLE sequence S. */
169 static inline gimple_seq_node
170 gimple_seq_last (const_gimple_seq s)
172 return s ? s->last : NULL;
176 /* Return the last statement in GIMPLE sequence S. */
178 static inline gimple
179 gimple_seq_last_stmt (const_gimple_seq s)
181 gimple_seq_node n = gimple_seq_last (s);
182 return (n) ? n->stmt : NULL;
186 /* Set the last node in GIMPLE sequence S to LAST. */
188 static inline void
189 gimple_seq_set_last (gimple_seq s, gimple_seq_node last)
191 s->last = last;
195 /* Set the first node in GIMPLE sequence S to FIRST. */
197 static inline void
198 gimple_seq_set_first (gimple_seq s, gimple_seq_node first)
200 s->first = first;
204 /* Return true if GIMPLE sequence S is empty. */
206 static inline bool
207 gimple_seq_empty_p (const_gimple_seq s)
209 return s == NULL || s->first == NULL;
213 void gimple_seq_add_stmt (gimple_seq *, gimple);
215 /* Allocate a new sequence and initialize its first element with STMT. */
217 static inline gimple_seq
218 gimple_seq_alloc_with_stmt (gimple stmt)
220 gimple_seq seq = NULL;
221 gimple_seq_add_stmt (&seq, stmt);
222 return seq;
226 /* Returns the sequence of statements in BB. */
228 static inline gimple_seq
229 bb_seq (const_basic_block bb)
231 return (!(bb->flags & BB_RTL) && bb->il.gimple) ? bb->il.gimple->seq : NULL;
235 /* Sets the sequence of statements in BB to SEQ. */
237 static inline void
238 set_bb_seq (basic_block bb, gimple_seq seq)
240 gcc_assert (!(bb->flags & BB_RTL));
241 bb->il.gimple->seq = seq;
244 /* Iterator object for GIMPLE statement sequences. */
246 typedef struct
248 /* Sequence node holding the current statement. */
249 gimple_seq_node ptr;
251 /* Sequence and basic block holding the statement. These fields
252 are necessary to handle edge cases such as when statement is
253 added to an empty basic block or when the last statement of a
254 block/sequence is removed. */
255 gimple_seq seq;
256 basic_block bb;
257 } gimple_stmt_iterator;
260 /* Data structure definitions for GIMPLE tuples. NOTE: word markers
261 are for 64 bit hosts. */
263 struct GTY(()) gimple_statement_base {
264 /* [ WORD 1 ]
265 Main identifying code for a tuple. */
266 ENUM_BITFIELD(gimple_code) code : 8;
268 /* Nonzero if a warning should not be emitted on this tuple. */
269 unsigned int no_warning : 1;
271 /* Nonzero if this tuple has been visited. Passes are responsible
272 for clearing this bit before using it. */
273 unsigned int visited : 1;
275 /* Nonzero if this tuple represents a non-temporal move. */
276 unsigned int nontemporal_move : 1;
278 /* Pass local flags. These flags are free for any pass to use as
279 they see fit. Passes should not assume that these flags contain
280 any useful value when the pass starts. Any initial state that
281 the pass requires should be set on entry to the pass. See
282 gimple_set_plf and gimple_plf for usage. */
283 unsigned int plf : 2;
285 /* Nonzero if this statement has been modified and needs to have its
286 operands rescanned. */
287 unsigned modified : 1;
289 /* Nonzero if this statement contains volatile operands. */
290 unsigned has_volatile_ops : 1;
292 /* Padding to get subcode to 16 bit alignment. */
293 unsigned pad : 1;
295 /* The SUBCODE field can be used for tuple-specific flags for tuples
296 that do not require subcodes. Note that SUBCODE should be at
297 least as wide as tree codes, as several tuples store tree codes
298 in there. */
299 unsigned int subcode : 16;
301 /* UID of this statement. This is used by passes that want to
302 assign IDs to statements. It must be assigned and used by each
303 pass. By default it should be assumed to contain garbage. */
304 unsigned uid;
306 /* [ WORD 2 ]
307 Locus information for debug info. */
308 location_t location;
310 /* Number of operands in this tuple. */
311 unsigned num_ops;
313 /* [ WORD 3 ]
314 Basic block holding this statement. */
315 struct basic_block_def *bb;
317 /* [ WORD 4 ]
318 Lexical block holding this statement. */
319 tree block;
323 /* Base structure for tuples with operands. */
325 struct GTY(()) gimple_statement_with_ops_base
327 /* [ WORD 1-4 ] */
328 struct gimple_statement_base gsbase;
330 /* [ WORD 5-6 ]
331 SSA operand vectors. NOTE: It should be possible to
332 amalgamate these vectors with the operand vector OP. However,
333 the SSA operand vectors are organized differently and contain
334 more information (like immediate use chaining). */
335 struct def_optype_d GTY((skip (""))) *def_ops;
336 struct use_optype_d GTY((skip (""))) *use_ops;
340 /* Statements that take register operands. */
342 struct GTY(()) gimple_statement_with_ops
344 /* [ WORD 1-6 ] */
345 struct gimple_statement_with_ops_base opbase;
347 /* [ WORD 7 ]
348 Operand vector. NOTE! This must always be the last field
349 of this structure. In particular, this means that this
350 structure cannot be embedded inside another one. */
351 tree GTY((length ("%h.opbase.gsbase.num_ops"))) op[1];
355 /* Base for statements that take both memory and register operands. */
357 struct GTY(()) gimple_statement_with_memory_ops_base
359 /* [ WORD 1-6 ] */
360 struct gimple_statement_with_ops_base opbase;
362 /* [ WORD 7-8 ]
363 Virtual operands for this statement. The GC will pick them
364 up via the ssa_names array. */
365 tree GTY((skip (""))) vdef;
366 tree GTY((skip (""))) vuse;
370 /* Statements that take both memory and register operands. */
372 struct GTY(()) gimple_statement_with_memory_ops
374 /* [ WORD 1-8 ] */
375 struct gimple_statement_with_memory_ops_base membase;
377 /* [ WORD 9 ]
378 Operand vector. NOTE! This must always be the last field
379 of this structure. In particular, this means that this
380 structure cannot be embedded inside another one. */
381 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
385 /* OpenMP statements (#pragma omp). */
387 struct GTY(()) gimple_statement_omp {
388 /* [ WORD 1-4 ] */
389 struct gimple_statement_base gsbase;
391 /* [ WORD 5 ] */
392 gimple_seq body;
396 /* GIMPLE_BIND */
398 struct GTY(()) gimple_statement_bind {
399 /* [ WORD 1-4 ] */
400 struct gimple_statement_base gsbase;
402 /* [ WORD 5 ]
403 Variables declared in this scope. */
404 tree vars;
406 /* [ WORD 6 ]
407 This is different than the BLOCK field in gimple_statement_base,
408 which is analogous to TREE_BLOCK (i.e., the lexical block holding
409 this statement). This field is the equivalent of BIND_EXPR_BLOCK
410 in tree land (i.e., the lexical scope defined by this bind). See
411 gimple-low.c. */
412 tree block;
414 /* [ WORD 7 ] */
415 gimple_seq body;
419 /* GIMPLE_CATCH */
421 struct GTY(()) gimple_statement_catch {
422 /* [ WORD 1-4 ] */
423 struct gimple_statement_base gsbase;
425 /* [ WORD 5 ] */
426 tree types;
428 /* [ WORD 6 ] */
429 gimple_seq handler;
433 /* GIMPLE_EH_FILTER */
435 struct GTY(()) gimple_statement_eh_filter {
436 /* [ WORD 1-4 ] */
437 struct gimple_statement_base gsbase;
439 /* Subcode: EH_FILTER_MUST_NOT_THROW. A boolean flag analogous to
440 the tree counterpart. */
442 /* [ WORD 5 ]
443 Filter types. */
444 tree types;
446 /* [ WORD 6 ]
447 Failure actions. */
448 gimple_seq failure;
452 /* GIMPLE_PHI */
454 struct GTY(()) gimple_statement_phi {
455 /* [ WORD 1-4 ] */
456 struct gimple_statement_base gsbase;
458 /* [ WORD 5 ] */
459 unsigned capacity;
460 unsigned nargs;
462 /* [ WORD 6 ] */
463 tree result;
465 /* [ WORD 7 ] */
466 struct phi_arg_d GTY ((length ("%h.nargs"))) args[1];
470 /* GIMPLE_RESX */
472 struct GTY(()) gimple_statement_resx {
473 /* [ WORD 1-4 ] */
474 struct gimple_statement_base gsbase;
476 /* [ WORD 5 ]
477 Exception region number. */
478 int region;
482 /* GIMPLE_TRY */
484 struct GTY(()) gimple_statement_try {
485 /* [ WORD 1-4 ] */
486 struct gimple_statement_base gsbase;
488 /* [ WORD 5 ]
489 Expression to evaluate. */
490 gimple_seq eval;
492 /* [ WORD 6 ]
493 Cleanup expression. */
494 gimple_seq cleanup;
497 /* Kind of GIMPLE_TRY statements. */
498 enum gimple_try_flags
500 /* A try/catch. */
501 GIMPLE_TRY_CATCH = 1 << 0,
503 /* A try/finally. */
504 GIMPLE_TRY_FINALLY = 1 << 1,
505 GIMPLE_TRY_KIND = GIMPLE_TRY_CATCH | GIMPLE_TRY_FINALLY,
507 /* Analogous to TRY_CATCH_IS_CLEANUP. */
508 GIMPLE_TRY_CATCH_IS_CLEANUP = 1 << 2
511 /* GIMPLE_WITH_CLEANUP_EXPR */
513 struct GTY(()) gimple_statement_wce {
514 /* [ WORD 1-4 ] */
515 struct gimple_statement_base gsbase;
517 /* Subcode: CLEANUP_EH_ONLY. True if the cleanup should only be
518 executed if an exception is thrown, not on normal exit of its
519 scope. This flag is analogous to the CLEANUP_EH_ONLY flag
520 in TARGET_EXPRs. */
522 /* [ WORD 5 ]
523 Cleanup expression. */
524 gimple_seq cleanup;
528 /* GIMPLE_ASM */
530 struct GTY(()) gimple_statement_asm
532 /* [ WORD 1-8 ] */
533 struct gimple_statement_with_memory_ops_base membase;
535 /* [ WORD 9 ]
536 __asm__ statement. */
537 const char *string;
539 /* [ WORD 10 ]
540 Number of inputs, outputs and clobbers. */
541 unsigned char ni;
542 unsigned char no;
543 unsigned short nc;
545 /* [ WORD 11 ]
546 Operand vector. NOTE! This must always be the last field
547 of this structure. In particular, this means that this
548 structure cannot be embedded inside another one. */
549 tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
552 /* GIMPLE_OMP_CRITICAL */
554 struct GTY(()) gimple_statement_omp_critical {
555 /* [ WORD 1-5 ] */
556 struct gimple_statement_omp omp;
558 /* [ WORD 6 ]
559 Critical section name. */
560 tree name;
564 struct GTY(()) gimple_omp_for_iter {
565 /* Condition code. */
566 enum tree_code cond;
568 /* Index variable. */
569 tree index;
571 /* Initial value. */
572 tree initial;
574 /* Final value. */
575 tree final;
577 /* Increment. */
578 tree incr;
581 /* GIMPLE_OMP_FOR */
583 struct GTY(()) gimple_statement_omp_for {
584 /* [ WORD 1-5 ] */
585 struct gimple_statement_omp omp;
587 /* [ WORD 6 ] */
588 tree clauses;
590 /* [ WORD 7 ]
591 Number of elements in iter array. */
592 size_t collapse;
594 /* [ WORD 8 ] */
595 struct gimple_omp_for_iter * GTY((length ("%h.collapse"))) iter;
597 /* [ WORD 9 ]
598 Pre-body evaluated before the loop body begins. */
599 gimple_seq pre_body;
603 /* GIMPLE_OMP_PARALLEL */
605 struct GTY(()) gimple_statement_omp_parallel {
606 /* [ WORD 1-5 ] */
607 struct gimple_statement_omp omp;
609 /* [ WORD 6 ]
610 Clauses. */
611 tree clauses;
613 /* [ WORD 7 ]
614 Child function holding the body of the parallel region. */
615 tree child_fn;
617 /* [ WORD 8 ]
618 Shared data argument. */
619 tree data_arg;
623 /* GIMPLE_OMP_TASK */
625 struct GTY(()) gimple_statement_omp_task {
626 /* [ WORD 1-8 ] */
627 struct gimple_statement_omp_parallel par;
629 /* [ WORD 9 ]
630 Child function holding firstprivate initialization if needed. */
631 tree copy_fn;
633 /* [ WORD 10-11 ]
634 Size and alignment in bytes of the argument data block. */
635 tree arg_size;
636 tree arg_align;
640 /* GIMPLE_OMP_SECTION */
641 /* Uses struct gimple_statement_omp. */
644 /* GIMPLE_OMP_SECTIONS */
646 struct GTY(()) gimple_statement_omp_sections {
647 /* [ WORD 1-5 ] */
648 struct gimple_statement_omp omp;
650 /* [ WORD 6 ] */
651 tree clauses;
653 /* [ WORD 7 ]
654 The control variable used for deciding which of the sections to
655 execute. */
656 tree control;
659 /* GIMPLE_OMP_CONTINUE.
661 Note: This does not inherit from gimple_statement_omp, because we
662 do not need the body field. */
664 struct GTY(()) gimple_statement_omp_continue {
665 /* [ WORD 1-4 ] */
666 struct gimple_statement_base gsbase;
668 /* [ WORD 5 ] */
669 tree control_def;
671 /* [ WORD 6 ] */
672 tree control_use;
675 /* GIMPLE_OMP_SINGLE */
677 struct GTY(()) gimple_statement_omp_single {
678 /* [ WORD 1-5 ] */
679 struct gimple_statement_omp omp;
681 /* [ WORD 6 ] */
682 tree clauses;
686 /* GIMPLE_OMP_ATOMIC_LOAD.
687 Note: This is based on gimple_statement_base, not g_s_omp, because g_s_omp
688 contains a sequence, which we don't need here. */
690 struct GTY(()) gimple_statement_omp_atomic_load {
691 /* [ WORD 1-4 ] */
692 struct gimple_statement_base gsbase;
694 /* [ WORD 5-6 ] */
695 tree rhs, lhs;
698 /* GIMPLE_OMP_ATOMIC_STORE.
699 See note on GIMPLE_OMP_ATOMIC_LOAD. */
701 struct GTY(()) gimple_statement_omp_atomic_store {
702 /* [ WORD 1-4 ] */
703 struct gimple_statement_base gsbase;
705 /* [ WORD 5 ] */
706 tree val;
709 enum gimple_statement_structure_enum {
710 #define DEFGSSTRUCT(SYM, STRING) SYM,
711 #include "gsstruct.def"
712 #undef DEFGSSTRUCT
713 LAST_GSS_ENUM
717 /* Define the overall contents of a gimple tuple. It may be any of the
718 structures declared above for various types of tuples. */
720 union GTY ((desc ("gimple_statement_structure (&%h)"))) gimple_statement_d {
721 struct gimple_statement_base GTY ((tag ("GSS_BASE"))) gsbase;
722 struct gimple_statement_with_ops GTY ((tag ("GSS_WITH_OPS"))) gsops;
723 struct gimple_statement_with_memory_ops GTY ((tag ("GSS_WITH_MEM_OPS"))) gsmem;
724 struct gimple_statement_omp GTY ((tag ("GSS_OMP"))) omp;
725 struct gimple_statement_bind GTY ((tag ("GSS_BIND"))) gimple_bind;
726 struct gimple_statement_catch GTY ((tag ("GSS_CATCH"))) gimple_catch;
727 struct gimple_statement_eh_filter GTY ((tag ("GSS_EH_FILTER"))) gimple_eh_filter;
728 struct gimple_statement_phi GTY ((tag ("GSS_PHI"))) gimple_phi;
729 struct gimple_statement_resx GTY ((tag ("GSS_RESX"))) gimple_resx;
730 struct gimple_statement_try GTY ((tag ("GSS_TRY"))) gimple_try;
731 struct gimple_statement_wce GTY ((tag ("GSS_WCE"))) gimple_wce;
732 struct gimple_statement_asm GTY ((tag ("GSS_ASM"))) gimple_asm;
733 struct gimple_statement_omp_critical GTY ((tag ("GSS_OMP_CRITICAL"))) gimple_omp_critical;
734 struct gimple_statement_omp_for GTY ((tag ("GSS_OMP_FOR"))) gimple_omp_for;
735 struct gimple_statement_omp_parallel GTY ((tag ("GSS_OMP_PARALLEL"))) gimple_omp_parallel;
736 struct gimple_statement_omp_task GTY ((tag ("GSS_OMP_TASK"))) gimple_omp_task;
737 struct gimple_statement_omp_sections GTY ((tag ("GSS_OMP_SECTIONS"))) gimple_omp_sections;
738 struct gimple_statement_omp_single GTY ((tag ("GSS_OMP_SINGLE"))) gimple_omp_single;
739 struct gimple_statement_omp_continue GTY ((tag ("GSS_OMP_CONTINUE"))) gimple_omp_continue;
740 struct gimple_statement_omp_atomic_load GTY ((tag ("GSS_OMP_ATOMIC_LOAD"))) gimple_omp_atomic_load;
741 struct gimple_statement_omp_atomic_store GTY ((tag ("GSS_OMP_ATOMIC_STORE"))) gimple_omp_atomic_store;
744 /* In gimple.c. */
745 gimple gimple_build_return (tree);
747 gimple gimple_build_assign_stat (tree, tree MEM_STAT_DECL);
748 #define gimple_build_assign(l,r) gimple_build_assign_stat (l, r MEM_STAT_INFO)
750 void extract_ops_from_tree (tree, enum tree_code *, tree *, tree *);
752 gimple gimple_build_assign_with_ops_stat (enum tree_code, tree, tree,
753 tree MEM_STAT_DECL);
754 #define gimple_build_assign_with_ops(c,o1,o2,o3) \
755 gimple_build_assign_with_ops_stat (c, o1, o2, o3 MEM_STAT_INFO)
757 gimple gimple_build_call_vec (tree, VEC(tree, heap) *);
758 gimple gimple_build_call (tree, unsigned, ...);
759 gimple gimple_build_call_from_tree (tree);
760 gimple gimplify_assign (tree, tree, gimple_seq *);
761 gimple gimple_build_cond (enum tree_code, tree, tree, tree, tree);
762 gimple gimple_build_label (tree label);
763 gimple gimple_build_goto (tree dest);
764 gimple gimple_build_nop (void);
765 gimple gimple_build_bind (tree, gimple_seq, tree);
766 gimple gimple_build_asm (const char *, unsigned, unsigned, unsigned, ...);
767 gimple gimple_build_asm_vec (const char *, VEC(tree,gc) *, VEC(tree,gc) *,
768 VEC(tree,gc) *);
769 gimple gimple_build_catch (tree, gimple_seq);
770 gimple gimple_build_eh_filter (tree, gimple_seq);
771 gimple gimple_build_try (gimple_seq, gimple_seq, enum gimple_try_flags);
772 gimple gimple_build_wce (gimple_seq);
773 gimple gimple_build_resx (int);
774 gimple gimple_build_switch (unsigned, tree, tree, ...);
775 gimple gimple_build_switch_vec (tree, tree, VEC(tree,heap) *);
776 gimple gimple_build_omp_parallel (gimple_seq, tree, tree, tree);
777 gimple gimple_build_omp_task (gimple_seq, tree, tree, tree, tree, tree, tree);
778 gimple gimple_build_omp_for (gimple_seq, tree, size_t, gimple_seq);
779 gimple gimple_build_omp_critical (gimple_seq, tree);
780 gimple gimple_build_omp_section (gimple_seq);
781 gimple gimple_build_omp_continue (tree, tree);
782 gimple gimple_build_omp_master (gimple_seq);
783 gimple gimple_build_omp_return (bool);
784 gimple gimple_build_omp_ordered (gimple_seq);
785 gimple gimple_build_omp_sections (gimple_seq, tree);
786 gimple gimple_build_omp_sections_switch (void);
787 gimple gimple_build_omp_single (gimple_seq, tree);
788 gimple gimple_build_cdt (tree, tree);
789 gimple gimple_build_omp_atomic_load (tree, tree);
790 gimple gimple_build_omp_atomic_store (tree);
791 gimple gimple_build_predict (enum br_predictor, enum prediction);
792 enum gimple_statement_structure_enum gimple_statement_structure (gimple);
793 enum gimple_statement_structure_enum gss_for_assign (enum tree_code);
794 void sort_case_labels (VEC(tree,heap) *);
795 void gimple_set_body (tree, gimple_seq);
796 gimple_seq gimple_body (tree);
797 bool gimple_has_body_p (tree);
798 gimple_seq gimple_seq_alloc (void);
799 void gimple_seq_free (gimple_seq);
800 void gimple_seq_add_seq (gimple_seq *, gimple_seq);
801 gimple_seq gimple_seq_copy (gimple_seq);
802 int gimple_call_flags (const_gimple);
803 bool gimple_assign_copy_p (gimple);
804 bool gimple_assign_ssa_name_copy_p (gimple);
805 bool gimple_assign_single_p (gimple);
806 bool gimple_assign_unary_nop_p (gimple);
807 void gimple_set_bb (gimple, struct basic_block_def *);
808 tree gimple_fold (const_gimple);
809 void gimple_assign_set_rhs_from_tree (gimple_stmt_iterator *, tree);
810 void gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *, enum tree_code,
811 tree, tree);
812 tree gimple_get_lhs (const_gimple);
813 void gimple_set_lhs (gimple, tree);
814 gimple gimple_copy (gimple);
815 bool is_gimple_operand (const_tree);
816 void gimple_set_modified (gimple, bool);
817 void gimple_cond_get_ops_from_tree (tree, enum tree_code *, tree *, tree *);
818 gimple gimple_build_cond_from_tree (tree, tree, tree);
819 void gimple_cond_set_condition_from_tree (gimple, tree);
820 bool gimple_has_side_effects (const_gimple);
821 bool gimple_rhs_has_side_effects (const_gimple);
822 bool gimple_could_trap_p (gimple);
823 bool gimple_assign_rhs_could_trap_p (gimple);
824 void gimple_regimplify_operands (gimple, gimple_stmt_iterator *);
825 bool empty_body_p (gimple_seq);
826 unsigned get_gimple_rhs_num_ops (enum tree_code);
828 /* Returns true iff T is a valid GIMPLE statement. */
829 extern bool is_gimple_stmt (tree);
831 /* Returns true iff TYPE is a valid type for a scalar register variable. */
832 extern bool is_gimple_reg_type (tree);
833 /* Returns true iff T is a scalar register variable. */
834 extern bool is_gimple_reg (tree);
835 /* Returns true iff T is any sort of variable. */
836 extern bool is_gimple_variable (tree);
837 /* Returns true iff T is any sort of symbol. */
838 extern bool is_gimple_id (tree);
839 /* Returns true iff T is a variable or an INDIRECT_REF (of a variable). */
840 extern bool is_gimple_min_lval (tree);
841 /* Returns true iff T is something whose address can be taken. */
842 extern bool is_gimple_addressable (tree);
843 /* Returns true iff T is any valid GIMPLE lvalue. */
844 extern bool is_gimple_lvalue (tree);
846 /* Returns true iff T is a GIMPLE address. */
847 bool is_gimple_address (const_tree);
848 /* Returns true iff T is a GIMPLE invariant address. */
849 bool is_gimple_invariant_address (const_tree);
850 /* Returns true iff T is a GIMPLE invariant address at interprocedural
851 level. */
852 bool is_gimple_ip_invariant_address (const_tree);
853 /* Returns true iff T is a valid GIMPLE constant. */
854 bool is_gimple_constant (const_tree);
855 /* Returns true iff T is a GIMPLE restricted function invariant. */
856 extern bool is_gimple_min_invariant (const_tree);
857 /* Returns true iff T is a GIMPLE restricted interprecodural invariant. */
858 extern bool is_gimple_ip_invariant (const_tree);
859 /* Returns true iff T is a GIMPLE rvalue. */
860 extern bool is_gimple_val (tree);
861 /* Returns true iff T is a GIMPLE asm statement input. */
862 extern bool is_gimple_asm_val (tree);
863 /* Returns true iff T is a valid rhs for a MODIFY_EXPR where the LHS is a
864 GIMPLE temporary, a renamed user variable, or something else,
865 respectively. */
866 extern bool is_gimple_reg_rhs (tree);
867 extern bool is_gimple_mem_rhs (tree);
869 /* Returns true iff T is a valid if-statement condition. */
870 extern bool is_gimple_condexpr (tree);
872 /* Returns true iff T is a type conversion. */
873 extern bool is_gimple_cast (tree);
874 /* Returns true iff T is a variable that does not need to live in memory. */
875 extern bool is_gimple_non_addressable (tree t);
877 /* Returns true iff T is a valid call address expression. */
878 extern bool is_gimple_call_addr (tree);
879 /* If T makes a function call, returns the CALL_EXPR operand. */
880 extern tree get_call_expr_in (tree t);
882 extern void recalculate_side_effects (tree);
883 extern void count_uses_and_derefs (tree, gimple, unsigned *, unsigned *,
884 unsigned *);
885 extern bool walk_stmt_load_store_addr_ops (gimple, void *,
886 bool (*)(gimple, tree, void *),
887 bool (*)(gimple, tree, void *),
888 bool (*)(gimple, tree, void *));
889 extern bool walk_stmt_load_store_ops (gimple, void *,
890 bool (*)(gimple, tree, void *),
891 bool (*)(gimple, tree, void *));
892 extern bool gimple_ior_addresses_taken (bitmap, gimple);
894 /* In gimplify.c */
895 extern tree create_tmp_var_raw (tree, const char *);
896 extern tree create_tmp_var_name (const char *);
897 extern tree create_tmp_var (tree, const char *);
898 extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq *);
899 extern tree get_formal_tmp_var (tree, gimple_seq *);
900 extern void declare_vars (tree, gimple, bool);
901 extern void tree_annotate_all_with_location (tree *, location_t);
902 extern void annotate_all_with_location (gimple_seq, location_t);
904 /* Validation of GIMPLE expressions. Note that these predicates only check
905 the basic form of the expression, they don't recurse to make sure that
906 underlying nodes are also of the right form. */
907 typedef bool (*gimple_predicate)(tree);
910 /* FIXME we should deduce this from the predicate. */
911 enum fallback {
912 fb_none = 0, /* Do not generate a temporary. */
914 fb_rvalue = 1, /* Generate an rvalue to hold the result of a
915 gimplified expression. */
917 fb_lvalue = 2, /* Generate an lvalue to hold the result of a
918 gimplified expression. */
920 fb_mayfail = 4, /* Gimplification may fail. Error issued
921 afterwards. */
922 fb_either= fb_rvalue | fb_lvalue
925 typedef int fallback_t;
927 enum gimplify_status {
928 GS_ERROR = -2, /* Something Bad Seen. */
929 GS_UNHANDLED = -1, /* A langhook result for "I dunno". */
930 GS_OK = 0, /* We did something, maybe more to do. */
931 GS_ALL_DONE = 1 /* The expression is fully gimplified. */
934 struct gimplify_ctx
936 struct gimplify_ctx *prev_context;
938 VEC(gimple,heap) *bind_expr_stack;
939 tree temps;
940 gimple_seq conditional_cleanups;
941 tree exit_label;
942 tree return_temp;
944 VEC(tree,heap) *case_labels;
945 /* The formal temporary table. Should this be persistent? */
946 htab_t temp_htab;
948 int conditions;
949 bool save_stack;
950 bool into_ssa;
951 bool allow_rhs_cond_expr;
954 extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *,
955 bool (*) (tree), fallback_t);
956 extern void gimplify_type_sizes (tree, gimple_seq *);
957 extern void gimplify_one_sizepos (tree *, gimple_seq *);
958 extern bool gimplify_stmt (tree *, gimple_seq *);
959 extern gimple gimplify_body (tree *, tree, bool);
960 extern void push_gimplify_context (struct gimplify_ctx *);
961 extern void pop_gimplify_context (gimple);
962 extern void gimplify_and_add (tree, gimple_seq *);
964 /* Miscellaneous helpers. */
965 extern void gimple_add_tmp_var (tree);
966 extern gimple gimple_current_bind_expr (void);
967 extern VEC(gimple, heap) *gimple_bind_expr_stack (void);
968 extern tree voidify_wrapper_expr (tree, tree);
969 extern tree build_and_jump (tree *);
970 extern tree alloc_stmt_list (void);
971 extern void free_stmt_list (tree);
972 extern tree force_labels_r (tree *, int *, void *);
973 extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *,
974 gimple_seq *);
975 struct gimplify_omp_ctx;
976 extern void omp_firstprivatize_variable (struct gimplify_omp_ctx *, tree);
977 extern tree gimple_boolify (tree);
978 extern gimple_predicate rhs_predicate_for (tree);
979 extern tree canonicalize_cond_expr_cond (tree);
981 /* In omp-low.c. */
982 extern void diagnose_omp_structured_block_errors (tree);
983 extern tree omp_reduction_init (tree, tree);
985 /* In tree-nested.c. */
986 extern void lower_nested_functions (tree);
987 extern void insert_field_into_struct (tree, tree);
989 /* In gimplify.c. */
990 extern void gimplify_function_tree (tree);
992 /* In cfgexpand.c. */
993 extern tree gimple_assign_rhs_to_tree (gimple);
995 /* In builtins.c */
996 extern bool validate_gimple_arglist (const_gimple, ...);
998 /* In tree-ssa.c */
999 extern bool tree_ssa_useless_type_conversion (tree);
1000 extern bool useless_type_conversion_p (tree, tree);
1001 extern bool types_compatible_p (tree, tree);
1003 /* Return the code for GIMPLE statement G. */
1005 static inline enum gimple_code
1006 gimple_code (const_gimple g)
1008 return g->gsbase.code;
1012 /* Return true if statement G has sub-statements. This is only true for
1013 High GIMPLE statements. */
1015 static inline bool
1016 gimple_has_substatements (gimple g)
1018 switch (gimple_code (g))
1020 case GIMPLE_BIND:
1021 case GIMPLE_CATCH:
1022 case GIMPLE_EH_FILTER:
1023 case GIMPLE_TRY:
1024 case GIMPLE_OMP_FOR:
1025 case GIMPLE_OMP_MASTER:
1026 case GIMPLE_OMP_ORDERED:
1027 case GIMPLE_OMP_SECTION:
1028 case GIMPLE_OMP_PARALLEL:
1029 case GIMPLE_OMP_TASK:
1030 case GIMPLE_OMP_SECTIONS:
1031 case GIMPLE_OMP_SINGLE:
1032 case GIMPLE_OMP_CRITICAL:
1033 case GIMPLE_WITH_CLEANUP_EXPR:
1034 return true;
1036 default:
1037 return false;
1042 /* Return the basic block holding statement G. */
1044 static inline struct basic_block_def *
1045 gimple_bb (const_gimple g)
1047 return g->gsbase.bb;
1051 /* Return the lexical scope block holding statement G. */
1053 static inline tree
1054 gimple_block (const_gimple g)
1056 return g->gsbase.block;
1060 /* Set BLOCK to be the lexical scope block holding statement G. */
1062 static inline void
1063 gimple_set_block (gimple g, tree block)
1065 g->gsbase.block = block;
1069 /* Return location information for statement G. */
1071 static inline location_t
1072 gimple_location (const_gimple g)
1074 return g->gsbase.location;
1077 /* Return pointer to location information for statement G. */
1079 static inline const location_t *
1080 gimple_location_ptr (const_gimple g)
1082 return &g->gsbase.location;
1086 /* Set location information for statement G. */
1088 static inline void
1089 gimple_set_location (gimple g, location_t location)
1091 g->gsbase.location = location;
1095 /* Return true if G contains location information. */
1097 static inline bool
1098 gimple_has_location (const_gimple g)
1100 return gimple_location (g) != UNKNOWN_LOCATION;
1104 /* Return the file name of the location of STMT. */
1106 static inline const char *
1107 gimple_filename (const_gimple stmt)
1109 return LOCATION_FILE (gimple_location (stmt));
1113 /* Return the line number of the location of STMT. */
1115 static inline int
1116 gimple_lineno (const_gimple stmt)
1118 return LOCATION_LINE (gimple_location (stmt));
1122 /* Determine whether SEQ is a singleton. */
1124 static inline bool
1125 gimple_seq_singleton_p (gimple_seq seq)
1127 return ((gimple_seq_first (seq) != NULL)
1128 && (gimple_seq_first (seq) == gimple_seq_last (seq)));
1131 /* Return true if no warnings should be emitted for statement STMT. */
1133 static inline bool
1134 gimple_no_warning_p (const_gimple stmt)
1136 return stmt->gsbase.no_warning;
1139 /* Set the no_warning flag of STMT to NO_WARNING. */
1141 static inline void
1142 gimple_set_no_warning (gimple stmt, bool no_warning)
1144 stmt->gsbase.no_warning = (unsigned) no_warning;
1147 /* Set the visited status on statement STMT to VISITED_P. */
1149 static inline void
1150 gimple_set_visited (gimple stmt, bool visited_p)
1152 stmt->gsbase.visited = (unsigned) visited_p;
1156 /* Return the visited status for statement STMT. */
1158 static inline bool
1159 gimple_visited_p (gimple stmt)
1161 return stmt->gsbase.visited;
1165 /* Set pass local flag PLF on statement STMT to VAL_P. */
1167 static inline void
1168 gimple_set_plf (gimple stmt, enum plf_mask plf, bool val_p)
1170 if (val_p)
1171 stmt->gsbase.plf |= (unsigned int) plf;
1172 else
1173 stmt->gsbase.plf &= ~((unsigned int) plf);
1177 /* Return the value of pass local flag PLF on statement STMT. */
1179 static inline unsigned int
1180 gimple_plf (gimple stmt, enum plf_mask plf)
1182 return stmt->gsbase.plf & ((unsigned int) plf);
1186 /* Set the UID of statement. */
1188 static inline void
1189 gimple_set_uid (gimple g, unsigned uid)
1191 g->gsbase.uid = uid;
1195 /* Return the UID of statement. */
1197 static inline unsigned
1198 gimple_uid (const_gimple g)
1200 return g->gsbase.uid;
1204 /* Return true if GIMPLE statement G has register or memory operands. */
1206 static inline bool
1207 gimple_has_ops (const_gimple g)
1209 return gimple_code (g) >= GIMPLE_COND && gimple_code (g) <= GIMPLE_RETURN;
1213 /* Return true if GIMPLE statement G has memory operands. */
1215 static inline bool
1216 gimple_has_mem_ops (const_gimple g)
1218 return gimple_code (g) >= GIMPLE_ASSIGN && gimple_code (g) <= GIMPLE_RETURN;
1222 /* Return the set of DEF operands for statement G. */
1224 static inline struct def_optype_d *
1225 gimple_def_ops (const_gimple g)
1227 if (!gimple_has_ops (g))
1228 return NULL;
1229 return g->gsops.opbase.def_ops;
1233 /* Set DEF to be the set of DEF operands for statement G. */
1235 static inline void
1236 gimple_set_def_ops (gimple g, struct def_optype_d *def)
1238 gcc_assert (gimple_has_ops (g));
1239 g->gsops.opbase.def_ops = def;
1243 /* Return the set of USE operands for statement G. */
1245 static inline struct use_optype_d *
1246 gimple_use_ops (const_gimple g)
1248 if (!gimple_has_ops (g))
1249 return NULL;
1250 return g->gsops.opbase.use_ops;
1254 /* Set USE to be the set of USE operands for statement G. */
1256 static inline void
1257 gimple_set_use_ops (gimple g, struct use_optype_d *use)
1259 gcc_assert (gimple_has_ops (g));
1260 g->gsops.opbase.use_ops = use;
1264 /* Return the set of VUSE operand for statement G. */
1266 static inline use_operand_p
1267 gimple_vuse_op (const_gimple g)
1269 struct use_optype_d *ops;
1270 if (!gimple_has_mem_ops (g))
1271 return NULL_USE_OPERAND_P;
1272 ops = g->gsops.opbase.use_ops;
1273 if (ops
1274 && USE_OP_PTR (ops)->use == &g->gsmem.membase.vuse)
1275 return USE_OP_PTR (ops);
1276 return NULL_USE_OPERAND_P;
1279 /* Return the set of VDEF operand for statement G. */
1281 static inline def_operand_p
1282 gimple_vdef_op (const_gimple g)
1284 struct def_optype_d *ops;
1285 if (!gimple_has_mem_ops (g))
1286 return NULL_DEF_OPERAND_P;
1287 ops = g->gsops.opbase.def_ops;
1288 if (ops
1289 && DEF_OP_PTR (ops) == &g->gsmem.membase.vdef)
1290 return DEF_OP_PTR (ops);
1291 return NULL_DEF_OPERAND_P;
1295 /* Return the single VUSE operand of the statement G. */
1297 static inline tree
1298 gimple_vuse (const_gimple g)
1300 if (!gimple_has_mem_ops (g))
1301 return NULL_TREE;
1302 return g->gsmem.membase.vuse;
1305 /* Return the single VDEF operand of the statement G. */
1307 static inline tree
1308 gimple_vdef (const_gimple g)
1310 if (!gimple_has_mem_ops (g))
1311 return NULL_TREE;
1312 return g->gsmem.membase.vdef;
1315 /* Return the single VUSE operand of the statement G. */
1317 static inline tree *
1318 gimple_vuse_ptr (gimple g)
1320 if (!gimple_has_mem_ops (g))
1321 return NULL;
1322 return &g->gsmem.membase.vuse;
1325 /* Return the single VDEF operand of the statement G. */
1327 static inline tree *
1328 gimple_vdef_ptr (gimple g)
1330 if (!gimple_has_mem_ops (g))
1331 return NULL;
1332 return &g->gsmem.membase.vdef;
1335 /* Set the single VUSE operand of the statement G. */
1337 static inline void
1338 gimple_set_vuse (gimple g, tree vuse)
1340 gcc_assert (gimple_has_mem_ops (g));
1341 g->gsmem.membase.vuse = vuse;
1344 /* Set the single VDEF operand of the statement G. */
1346 static inline void
1347 gimple_set_vdef (gimple g, tree vdef)
1349 gcc_assert (gimple_has_mem_ops (g));
1350 g->gsmem.membase.vdef = vdef;
1354 /* Return true if statement G has operands and the modified field has
1355 been set. */
1357 static inline bool
1358 gimple_modified_p (const_gimple g)
1360 return (gimple_has_ops (g)) ? (bool) g->gsbase.modified : false;
1363 /* Return the type of the main expression computed by STMT. Return
1364 void_type_node if the statement computes nothing. */
1366 static inline tree
1367 gimple_expr_type (const_gimple stmt)
1369 enum gimple_code code = gimple_code (stmt);
1371 if (code == GIMPLE_ASSIGN || code == GIMPLE_CALL)
1373 tree type = TREE_TYPE (gimple_get_lhs (stmt));
1374 /* Integral sub-types are never the type of the expression,
1375 but they still can be the type of the result as the base
1376 type (in which expressions are computed) is trivially
1377 convertible to one of its sub-types. So always return
1378 the base type here. */
1379 if (INTEGRAL_TYPE_P (type)
1380 && TREE_TYPE (type)
1381 /* But only if they are trivially convertible. */
1382 && useless_type_conversion_p (type, TREE_TYPE (type)))
1383 type = TREE_TYPE (type);
1384 return type;
1386 else if (code == GIMPLE_COND)
1387 return boolean_type_node;
1388 else
1389 return void_type_node;
1393 /* Return the tree code for the expression computed by STMT. This is
1394 only valid for GIMPLE_COND, GIMPLE_CALL and GIMPLE_ASSIGN. For
1395 GIMPLE_CALL, return CALL_EXPR as the expression code for
1396 consistency. This is useful when the caller needs to deal with the
1397 three kinds of computation that GIMPLE supports. */
1399 static inline enum tree_code
1400 gimple_expr_code (const_gimple stmt)
1402 enum gimple_code code = gimple_code (stmt);
1403 if (code == GIMPLE_ASSIGN || code == GIMPLE_COND)
1404 return (enum tree_code) stmt->gsbase.subcode;
1405 else if (code == GIMPLE_CALL)
1406 return CALL_EXPR;
1407 else
1408 gcc_unreachable ();
1412 /* Mark statement S as modified, and update it. */
1414 static inline void
1415 update_stmt (gimple s)
1417 if (gimple_has_ops (s))
1419 gimple_set_modified (s, true);
1420 update_stmt_operands (s);
1424 /* Update statement S if it has been optimized. */
1426 static inline void
1427 update_stmt_if_modified (gimple s)
1429 if (gimple_modified_p (s))
1430 update_stmt_operands (s);
1433 /* Return true if statement STMT contains volatile operands. */
1435 static inline bool
1436 gimple_has_volatile_ops (const_gimple stmt)
1438 if (gimple_has_mem_ops (stmt))
1439 return stmt->gsbase.has_volatile_ops;
1440 else
1441 return false;
1445 /* Set the HAS_VOLATILE_OPS flag to VOLATILEP. */
1447 static inline void
1448 gimple_set_has_volatile_ops (gimple stmt, bool volatilep)
1450 if (gimple_has_mem_ops (stmt))
1451 stmt->gsbase.has_volatile_ops = (unsigned) volatilep;
1455 /* Return true if statement STMT may access memory. */
1457 static inline bool
1458 gimple_references_memory_p (gimple stmt)
1460 return gimple_has_mem_ops (stmt) && gimple_vuse (stmt);
1464 /* Return the subcode for OMP statement S. */
1466 static inline unsigned
1467 gimple_omp_subcode (const_gimple s)
1469 gcc_assert (gimple_code (s) >= GIMPLE_OMP_ATOMIC_LOAD
1470 && gimple_code (s) <= GIMPLE_OMP_SINGLE);
1471 return s->gsbase.subcode;
1474 /* Set the subcode for OMP statement S to SUBCODE. */
1476 static inline void
1477 gimple_omp_set_subcode (gimple s, unsigned int subcode)
1479 /* We only have 16 bits for the subcode. Assert that we are not
1480 overflowing it. */
1481 gcc_assert (subcode < (1 << 16));
1482 s->gsbase.subcode = subcode;
1485 /* Set the nowait flag on OMP_RETURN statement S. */
1487 static inline void
1488 gimple_omp_return_set_nowait (gimple s)
1490 GIMPLE_CHECK (s, GIMPLE_OMP_RETURN);
1491 s->gsbase.subcode |= GF_OMP_RETURN_NOWAIT;
1495 /* Return true if OMP return statement G has the GF_OMP_RETURN_NOWAIT
1496 flag set. */
1498 static inline bool
1499 gimple_omp_return_nowait_p (const_gimple g)
1501 GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
1502 return (gimple_omp_subcode (g) & GF_OMP_RETURN_NOWAIT) != 0;
1506 /* Return true if OMP section statement G has the GF_OMP_SECTION_LAST
1507 flag set. */
1509 static inline bool
1510 gimple_omp_section_last_p (const_gimple g)
1512 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1513 return (gimple_omp_subcode (g) & GF_OMP_SECTION_LAST) != 0;
1517 /* Set the GF_OMP_SECTION_LAST flag on G. */
1519 static inline void
1520 gimple_omp_section_set_last (gimple g)
1522 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1523 g->gsbase.subcode |= GF_OMP_SECTION_LAST;
1527 /* Return true if OMP parallel statement G has the
1528 GF_OMP_PARALLEL_COMBINED flag set. */
1530 static inline bool
1531 gimple_omp_parallel_combined_p (const_gimple g)
1533 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1534 return (gimple_omp_subcode (g) & GF_OMP_PARALLEL_COMBINED) != 0;
1538 /* Set the GF_OMP_PARALLEL_COMBINED field in G depending on the boolean
1539 value of COMBINED_P. */
1541 static inline void
1542 gimple_omp_parallel_set_combined_p (gimple g, bool combined_p)
1544 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1545 if (combined_p)
1546 g->gsbase.subcode |= GF_OMP_PARALLEL_COMBINED;
1547 else
1548 g->gsbase.subcode &= ~GF_OMP_PARALLEL_COMBINED;
1552 /* Return the number of operands for statement GS. */
1554 static inline unsigned
1555 gimple_num_ops (const_gimple gs)
1557 return gs->gsbase.num_ops;
1561 /* Set the number of operands for statement GS. */
1563 static inline void
1564 gimple_set_num_ops (gimple gs, unsigned num_ops)
1566 gs->gsbase.num_ops = num_ops;
1570 /* Return the array of operands for statement GS. */
1572 static inline tree *
1573 gimple_ops (gimple gs)
1575 /* Offset in bytes to the location of the operand vector in every
1576 tuple structure. Defined in gimple.c */
1577 extern size_t const gimple_ops_offset_[];
1579 if (!gimple_has_ops (gs))
1580 return NULL;
1582 /* All the tuples have their operand vector at the very bottom
1583 of the structure. */
1584 return ((tree *) ((char *) gs + gimple_ops_offset_[gimple_code (gs)]));
1588 /* Return operand I for statement GS. */
1590 static inline tree
1591 gimple_op (const_gimple gs, unsigned i)
1593 if (gimple_has_ops (gs))
1595 gcc_assert (i < gimple_num_ops (gs));
1596 return gimple_ops (CONST_CAST_GIMPLE (gs))[i];
1598 else
1599 return NULL_TREE;
1602 /* Return a pointer to operand I for statement GS. */
1604 static inline tree *
1605 gimple_op_ptr (const_gimple gs, unsigned i)
1607 if (gimple_has_ops (gs))
1609 gcc_assert (i < gimple_num_ops (gs));
1610 return gimple_ops (CONST_CAST_GIMPLE (gs)) + i;
1612 else
1613 return NULL;
1616 /* Set operand I of statement GS to OP. */
1618 static inline void
1619 gimple_set_op (gimple gs, unsigned i, tree op)
1621 gcc_assert (gimple_has_ops (gs) && i < gimple_num_ops (gs));
1623 /* Note. It may be tempting to assert that OP matches
1624 is_gimple_operand, but that would be wrong. Different tuples
1625 accept slightly different sets of tree operands. Each caller
1626 should perform its own validation. */
1627 gimple_ops (gs)[i] = op;
1630 /* Return true if GS is a GIMPLE_ASSIGN. */
1632 static inline bool
1633 is_gimple_assign (const_gimple gs)
1635 return gimple_code (gs) == GIMPLE_ASSIGN;
1638 /* Determine if expression CODE is one of the valid expressions that can
1639 be used on the RHS of GIMPLE assignments. */
1641 static inline enum gimple_rhs_class
1642 get_gimple_rhs_class (enum tree_code code)
1644 return (enum gimple_rhs_class) gimple_rhs_class_table[(int) code];
1647 /* Return the LHS of assignment statement GS. */
1649 static inline tree
1650 gimple_assign_lhs (const_gimple gs)
1652 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1653 return gimple_op (gs, 0);
1657 /* Return a pointer to the LHS of assignment statement GS. */
1659 static inline tree *
1660 gimple_assign_lhs_ptr (const_gimple gs)
1662 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1663 return gimple_op_ptr (gs, 0);
1667 /* Set LHS to be the LHS operand of assignment statement GS. */
1669 static inline void
1670 gimple_assign_set_lhs (gimple gs, tree lhs)
1672 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1673 gcc_assert (is_gimple_operand (lhs));
1674 gimple_set_op (gs, 0, lhs);
1676 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1677 SSA_NAME_DEF_STMT (lhs) = gs;
1681 /* Return the first operand on the RHS of assignment statement GS. */
1683 static inline tree
1684 gimple_assign_rhs1 (const_gimple gs)
1686 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1687 return gimple_op (gs, 1);
1691 /* Return a pointer to the first operand on the RHS of assignment
1692 statement GS. */
1694 static inline tree *
1695 gimple_assign_rhs1_ptr (const_gimple gs)
1697 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1698 return gimple_op_ptr (gs, 1);
1701 /* Set RHS to be the first operand on the RHS of assignment statement GS. */
1703 static inline void
1704 gimple_assign_set_rhs1 (gimple gs, tree rhs)
1706 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1708 /* If there are 3 or more operands, the 2 operands on the RHS must be
1709 GIMPLE values. */
1710 if (gimple_num_ops (gs) >= 3)
1711 gcc_assert (is_gimple_val (rhs));
1712 else
1713 gcc_assert (is_gimple_operand (rhs));
1715 gimple_set_op (gs, 1, rhs);
1719 /* Return the second operand on the RHS of assignment statement GS.
1720 If GS does not have two operands, NULL is returned instead. */
1722 static inline tree
1723 gimple_assign_rhs2 (const_gimple gs)
1725 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1727 if (gimple_num_ops (gs) >= 3)
1728 return gimple_op (gs, 2);
1729 else
1730 return NULL_TREE;
1734 /* Return a pointer to the second operand on the RHS of assignment
1735 statement GS. */
1737 static inline tree *
1738 gimple_assign_rhs2_ptr (const_gimple gs)
1740 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1741 return gimple_op_ptr (gs, 2);
1745 /* Set RHS to be the second operand on the RHS of assignment statement GS. */
1747 static inline void
1748 gimple_assign_set_rhs2 (gimple gs, tree rhs)
1750 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1752 /* The 2 operands on the RHS must be GIMPLE values. */
1753 gcc_assert (is_gimple_val (rhs));
1755 gimple_set_op (gs, 2, rhs);
1758 /* Returns true if GS is a nontemporal move. */
1760 static inline bool
1761 gimple_assign_nontemporal_move_p (const_gimple gs)
1763 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1764 return gs->gsbase.nontemporal_move;
1767 /* Sets nontemporal move flag of GS to NONTEMPORAL. */
1769 static inline void
1770 gimple_assign_set_nontemporal_move (gimple gs, bool nontemporal)
1772 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1773 gs->gsbase.nontemporal_move = nontemporal;
1777 /* Return the code of the expression computed on the rhs of assignment
1778 statement GS. In case that the RHS is a single object, returns the
1779 tree code of the object. */
1781 static inline enum tree_code
1782 gimple_assign_rhs_code (const_gimple gs)
1784 enum tree_code code;
1785 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1787 code = gimple_expr_code (gs);
1788 if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS)
1789 code = TREE_CODE (gimple_assign_rhs1 (gs));
1791 return code;
1795 /* Set CODE to be the code for the expression computed on the RHS of
1796 assignment S. */
1798 static inline void
1799 gimple_assign_set_rhs_code (gimple s, enum tree_code code)
1801 GIMPLE_CHECK (s, GIMPLE_ASSIGN);
1802 s->gsbase.subcode = code;
1806 /* Return the gimple rhs class of the code of the expression computed on
1807 the rhs of assignment statement GS.
1808 This will never return GIMPLE_INVALID_RHS. */
1810 static inline enum gimple_rhs_class
1811 gimple_assign_rhs_class (const_gimple gs)
1813 return get_gimple_rhs_class (gimple_assign_rhs_code (gs));
1817 /* Return true if S is a type-cast assignment. */
1819 static inline bool
1820 gimple_assign_cast_p (gimple s)
1822 if (is_gimple_assign (s))
1824 enum tree_code sc = gimple_assign_rhs_code (s);
1825 return CONVERT_EXPR_CODE_P (sc)
1826 || sc == VIEW_CONVERT_EXPR
1827 || sc == FIX_TRUNC_EXPR;
1830 return false;
1834 /* Return true if GS is a GIMPLE_CALL. */
1836 static inline bool
1837 is_gimple_call (const_gimple gs)
1839 return gimple_code (gs) == GIMPLE_CALL;
1842 /* Return the LHS of call statement GS. */
1844 static inline tree
1845 gimple_call_lhs (const_gimple gs)
1847 GIMPLE_CHECK (gs, GIMPLE_CALL);
1848 return gimple_op (gs, 0);
1852 /* Return a pointer to the LHS of call statement GS. */
1854 static inline tree *
1855 gimple_call_lhs_ptr (const_gimple gs)
1857 GIMPLE_CHECK (gs, GIMPLE_CALL);
1858 return gimple_op_ptr (gs, 0);
1862 /* Set LHS to be the LHS operand of call statement GS. */
1864 static inline void
1865 gimple_call_set_lhs (gimple gs, tree lhs)
1867 GIMPLE_CHECK (gs, GIMPLE_CALL);
1868 gcc_assert (!lhs || is_gimple_operand (lhs));
1869 gimple_set_op (gs, 0, lhs);
1870 if (lhs && TREE_CODE (lhs) == SSA_NAME)
1871 SSA_NAME_DEF_STMT (lhs) = gs;
1875 /* Return the tree node representing the function called by call
1876 statement GS. */
1878 static inline tree
1879 gimple_call_fn (const_gimple gs)
1881 GIMPLE_CHECK (gs, GIMPLE_CALL);
1882 return gimple_op (gs, 1);
1886 /* Return a pointer to the tree node representing the function called by call
1887 statement GS. */
1889 static inline tree *
1890 gimple_call_fn_ptr (const_gimple gs)
1892 GIMPLE_CHECK (gs, GIMPLE_CALL);
1893 return gimple_op_ptr (gs, 1);
1897 /* Set FN to be the function called by call statement GS. */
1899 static inline void
1900 gimple_call_set_fn (gimple gs, tree fn)
1902 GIMPLE_CHECK (gs, GIMPLE_CALL);
1903 gcc_assert (is_gimple_operand (fn));
1904 gimple_set_op (gs, 1, fn);
1908 /* Set FNDECL to be the function called by call statement GS. */
1910 static inline void
1911 gimple_call_set_fndecl (gimple gs, tree decl)
1913 GIMPLE_CHECK (gs, GIMPLE_CALL);
1914 gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
1915 gimple_set_op (gs, 1, build_fold_addr_expr (decl));
1919 /* If a given GIMPLE_CALL's callee is a FUNCTION_DECL, return it.
1920 Otherwise return NULL. This function is analogous to
1921 get_callee_fndecl in tree land. */
1923 static inline tree
1924 gimple_call_fndecl (const_gimple gs)
1926 tree addr = gimple_call_fn (gs);
1927 if (TREE_CODE (addr) == ADDR_EXPR)
1929 gcc_assert (TREE_CODE (TREE_OPERAND (addr, 0)) == FUNCTION_DECL);
1930 return TREE_OPERAND (addr, 0);
1932 return NULL_TREE;
1936 /* Return the type returned by call statement GS. */
1938 static inline tree
1939 gimple_call_return_type (const_gimple gs)
1941 tree fn = gimple_call_fn (gs);
1942 tree type = TREE_TYPE (fn);
1944 /* See through the pointer. */
1945 gcc_assert (POINTER_TYPE_P (type));
1946 type = TREE_TYPE (type);
1948 gcc_assert (TREE_CODE (type) == FUNCTION_TYPE
1949 || TREE_CODE (type) == METHOD_TYPE);
1951 /* The type returned by a FUNCTION_DECL is the type of its
1952 function type. */
1953 return TREE_TYPE (type);
1957 /* Return the static chain for call statement GS. */
1959 static inline tree
1960 gimple_call_chain (const_gimple gs)
1962 GIMPLE_CHECK (gs, GIMPLE_CALL);
1963 return gimple_op (gs, 2);
1967 /* Return a pointer to the static chain for call statement GS. */
1969 static inline tree *
1970 gimple_call_chain_ptr (const_gimple gs)
1972 GIMPLE_CHECK (gs, GIMPLE_CALL);
1973 return gimple_op_ptr (gs, 2);
1976 /* Set CHAIN to be the static chain for call statement GS. */
1978 static inline void
1979 gimple_call_set_chain (gimple gs, tree chain)
1981 GIMPLE_CHECK (gs, GIMPLE_CALL);
1982 gcc_assert (chain == NULL
1983 || TREE_CODE (chain) == ADDR_EXPR
1984 || SSA_VAR_P (chain));
1985 gimple_set_op (gs, 2, chain);
1989 /* Return the number of arguments used by call statement GS. */
1991 static inline unsigned
1992 gimple_call_num_args (const_gimple gs)
1994 unsigned num_ops;
1995 GIMPLE_CHECK (gs, GIMPLE_CALL);
1996 num_ops = gimple_num_ops (gs);
1997 gcc_assert (num_ops >= 3);
1998 return num_ops - 3;
2002 /* Return the argument at position INDEX for call statement GS. */
2004 static inline tree
2005 gimple_call_arg (const_gimple gs, unsigned index)
2007 GIMPLE_CHECK (gs, GIMPLE_CALL);
2008 return gimple_op (gs, index + 3);
2012 /* Return a pointer to the argument at position INDEX for call
2013 statement GS. */
2015 static inline tree *
2016 gimple_call_arg_ptr (const_gimple gs, unsigned index)
2018 GIMPLE_CHECK (gs, GIMPLE_CALL);
2019 return gimple_op_ptr (gs, index + 3);
2023 /* Set ARG to be the argument at position INDEX for call statement GS. */
2025 static inline void
2026 gimple_call_set_arg (gimple gs, unsigned index, tree arg)
2028 GIMPLE_CHECK (gs, GIMPLE_CALL);
2029 gcc_assert (is_gimple_operand (arg));
2030 gimple_set_op (gs, index + 3, arg);
2034 /* If TAIL_P is true, mark call statement S as being a tail call
2035 (i.e., a call just before the exit of a function). These calls are
2036 candidate for tail call optimization. */
2038 static inline void
2039 gimple_call_set_tail (gimple s, bool tail_p)
2041 GIMPLE_CHECK (s, GIMPLE_CALL);
2042 if (tail_p)
2043 s->gsbase.subcode |= GF_CALL_TAILCALL;
2044 else
2045 s->gsbase.subcode &= ~GF_CALL_TAILCALL;
2049 /* Return true if GIMPLE_CALL S is marked as a tail call. */
2051 static inline bool
2052 gimple_call_tail_p (gimple s)
2054 GIMPLE_CHECK (s, GIMPLE_CALL);
2055 return (s->gsbase.subcode & GF_CALL_TAILCALL) != 0;
2059 /* Set the inlinable status of GIMPLE_CALL S to INLINABLE_P. */
2061 static inline void
2062 gimple_call_set_cannot_inline (gimple s, bool inlinable_p)
2064 GIMPLE_CHECK (s, GIMPLE_CALL);
2065 if (inlinable_p)
2066 s->gsbase.subcode |= GF_CALL_CANNOT_INLINE;
2067 else
2068 s->gsbase.subcode &= ~GF_CALL_CANNOT_INLINE;
2072 /* Return true if GIMPLE_CALL S cannot be inlined. */
2074 static inline bool
2075 gimple_call_cannot_inline_p (gimple s)
2077 GIMPLE_CHECK (s, GIMPLE_CALL);
2078 return (s->gsbase.subcode & GF_CALL_CANNOT_INLINE) != 0;
2082 /* If RETURN_SLOT_OPT_P is true mark GIMPLE_CALL S as valid for return
2083 slot optimization. This transformation uses the target of the call
2084 expansion as the return slot for calls that return in memory. */
2086 static inline void
2087 gimple_call_set_return_slot_opt (gimple s, bool return_slot_opt_p)
2089 GIMPLE_CHECK (s, GIMPLE_CALL);
2090 if (return_slot_opt_p)
2091 s->gsbase.subcode |= GF_CALL_RETURN_SLOT_OPT;
2092 else
2093 s->gsbase.subcode &= ~GF_CALL_RETURN_SLOT_OPT;
2097 /* Return true if S is marked for return slot optimization. */
2099 static inline bool
2100 gimple_call_return_slot_opt_p (gimple s)
2102 GIMPLE_CHECK (s, GIMPLE_CALL);
2103 return (s->gsbase.subcode & GF_CALL_RETURN_SLOT_OPT) != 0;
2107 /* If FROM_THUNK_P is true, mark GIMPLE_CALL S as being the jump from a
2108 thunk to the thunked-to function. */
2110 static inline void
2111 gimple_call_set_from_thunk (gimple s, bool from_thunk_p)
2113 GIMPLE_CHECK (s, GIMPLE_CALL);
2114 if (from_thunk_p)
2115 s->gsbase.subcode |= GF_CALL_FROM_THUNK;
2116 else
2117 s->gsbase.subcode &= ~GF_CALL_FROM_THUNK;
2121 /* Return true if GIMPLE_CALL S is a jump from a thunk. */
2123 static inline bool
2124 gimple_call_from_thunk_p (gimple s)
2126 GIMPLE_CHECK (s, GIMPLE_CALL);
2127 return (s->gsbase.subcode & GF_CALL_FROM_THUNK) != 0;
2131 /* If PASS_ARG_PACK_P is true, GIMPLE_CALL S is a stdarg call that needs the
2132 argument pack in its argument list. */
2134 static inline void
2135 gimple_call_set_va_arg_pack (gimple s, bool pass_arg_pack_p)
2137 GIMPLE_CHECK (s, GIMPLE_CALL);
2138 if (pass_arg_pack_p)
2139 s->gsbase.subcode |= GF_CALL_VA_ARG_PACK;
2140 else
2141 s->gsbase.subcode &= ~GF_CALL_VA_ARG_PACK;
2145 /* Return true if GIMPLE_CALL S is a stdarg call that needs the
2146 argument pack in its argument list. */
2148 static inline bool
2149 gimple_call_va_arg_pack_p (gimple s)
2151 GIMPLE_CHECK (s, GIMPLE_CALL);
2152 return (s->gsbase.subcode & GF_CALL_VA_ARG_PACK) != 0;
2156 /* Return true if S is a noreturn call. */
2158 static inline bool
2159 gimple_call_noreturn_p (gimple s)
2161 GIMPLE_CHECK (s, GIMPLE_CALL);
2162 return (gimple_call_flags (s) & ECF_NORETURN) != 0;
2166 /* Return true if S is a nothrow call. */
2168 static inline bool
2169 gimple_call_nothrow_p (gimple s)
2171 GIMPLE_CHECK (s, GIMPLE_CALL);
2172 return (gimple_call_flags (s) & ECF_NOTHROW) != 0;
2176 /* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL. */
2178 static inline void
2179 gimple_call_copy_flags (gimple dest_call, gimple orig_call)
2181 GIMPLE_CHECK (dest_call, GIMPLE_CALL);
2182 GIMPLE_CHECK (orig_call, GIMPLE_CALL);
2183 dest_call->gsbase.subcode = orig_call->gsbase.subcode;
2187 /* Returns true if this is a GIMPLE_ASSIGN or a GIMPLE_CALL with a
2188 non-NULL lhs. */
2190 static inline bool
2191 gimple_has_lhs (gimple stmt)
2193 return (is_gimple_assign (stmt)
2194 || (is_gimple_call (stmt)
2195 && gimple_call_lhs (stmt) != NULL_TREE));
2199 /* Return the code of the predicate computed by conditional statement GS. */
2201 static inline enum tree_code
2202 gimple_cond_code (const_gimple gs)
2204 GIMPLE_CHECK (gs, GIMPLE_COND);
2205 return (enum tree_code) gs->gsbase.subcode;
2209 /* Set CODE to be the predicate code for the conditional statement GS. */
2211 static inline void
2212 gimple_cond_set_code (gimple gs, enum tree_code code)
2214 GIMPLE_CHECK (gs, GIMPLE_COND);
2215 gcc_assert (TREE_CODE_CLASS (code) == tcc_comparison);
2216 gs->gsbase.subcode = code;
2220 /* Return the LHS of the predicate computed by conditional statement GS. */
2222 static inline tree
2223 gimple_cond_lhs (const_gimple gs)
2225 GIMPLE_CHECK (gs, GIMPLE_COND);
2226 return gimple_op (gs, 0);
2229 /* Return the pointer to the LHS of the predicate computed by conditional
2230 statement GS. */
2232 static inline tree *
2233 gimple_cond_lhs_ptr (const_gimple gs)
2235 GIMPLE_CHECK (gs, GIMPLE_COND);
2236 return gimple_op_ptr (gs, 0);
2239 /* Set LHS to be the LHS operand of the predicate computed by
2240 conditional statement GS. */
2242 static inline void
2243 gimple_cond_set_lhs (gimple gs, tree lhs)
2245 GIMPLE_CHECK (gs, GIMPLE_COND);
2246 gcc_assert (is_gimple_operand (lhs));
2247 gimple_set_op (gs, 0, lhs);
2251 /* Return the RHS operand of the predicate computed by conditional GS. */
2253 static inline tree
2254 gimple_cond_rhs (const_gimple gs)
2256 GIMPLE_CHECK (gs, GIMPLE_COND);
2257 return gimple_op (gs, 1);
2260 /* Return the pointer to the RHS operand of the predicate computed by
2261 conditional GS. */
2263 static inline tree *
2264 gimple_cond_rhs_ptr (const_gimple gs)
2266 GIMPLE_CHECK (gs, GIMPLE_COND);
2267 return gimple_op_ptr (gs, 1);
2271 /* Set RHS to be the RHS operand of the predicate computed by
2272 conditional statement GS. */
2274 static inline void
2275 gimple_cond_set_rhs (gimple gs, tree rhs)
2277 GIMPLE_CHECK (gs, GIMPLE_COND);
2278 gcc_assert (is_gimple_operand (rhs));
2279 gimple_set_op (gs, 1, rhs);
2283 /* Return the label used by conditional statement GS when its
2284 predicate evaluates to true. */
2286 static inline tree
2287 gimple_cond_true_label (const_gimple gs)
2289 GIMPLE_CHECK (gs, GIMPLE_COND);
2290 return gimple_op (gs, 2);
2294 /* Set LABEL to be the label used by conditional statement GS when its
2295 predicate evaluates to true. */
2297 static inline void
2298 gimple_cond_set_true_label (gimple gs, tree label)
2300 GIMPLE_CHECK (gs, GIMPLE_COND);
2301 gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
2302 gimple_set_op (gs, 2, label);
2306 /* Set LABEL to be the label used by conditional statement GS when its
2307 predicate evaluates to false. */
2309 static inline void
2310 gimple_cond_set_false_label (gimple gs, tree label)
2312 GIMPLE_CHECK (gs, GIMPLE_COND);
2313 gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
2314 gimple_set_op (gs, 3, label);
2318 /* Return the label used by conditional statement GS when its
2319 predicate evaluates to false. */
2321 static inline tree
2322 gimple_cond_false_label (const_gimple gs)
2324 GIMPLE_CHECK (gs, GIMPLE_COND);
2325 return gimple_op (gs, 3);
2329 /* Set the conditional COND_STMT to be of the form 'if (1 == 0)'. */
2331 static inline void
2332 gimple_cond_make_false (gimple gs)
2334 gimple_cond_set_lhs (gs, boolean_true_node);
2335 gimple_cond_set_rhs (gs, boolean_false_node);
2336 gs->gsbase.subcode = EQ_EXPR;
2340 /* Set the conditional COND_STMT to be of the form 'if (1 == 1)'. */
2342 static inline void
2343 gimple_cond_make_true (gimple gs)
2345 gimple_cond_set_lhs (gs, boolean_true_node);
2346 gimple_cond_set_rhs (gs, boolean_true_node);
2347 gs->gsbase.subcode = EQ_EXPR;
2350 /* Check if conditional statemente GS is of the form 'if (1 == 1)',
2351 'if (0 == 0)', 'if (1 != 0)' or 'if (0 != 1)' */
2353 static inline bool
2354 gimple_cond_true_p (const_gimple gs)
2356 tree lhs = gimple_cond_lhs (gs);
2357 tree rhs = gimple_cond_rhs (gs);
2358 enum tree_code code = gimple_cond_code (gs);
2360 if (lhs != boolean_true_node && lhs != boolean_false_node)
2361 return false;
2363 if (rhs != boolean_true_node && rhs != boolean_false_node)
2364 return false;
2366 if (code == NE_EXPR && lhs != rhs)
2367 return true;
2369 if (code == EQ_EXPR && lhs == rhs)
2370 return true;
2372 return false;
2375 /* Check if conditional statement GS is of the form 'if (1 != 1)',
2376 'if (0 != 0)', 'if (1 == 0)' or 'if (0 == 1)' */
2378 static inline bool
2379 gimple_cond_false_p (const_gimple gs)
2381 tree lhs = gimple_cond_lhs (gs);
2382 tree rhs = gimple_cond_rhs (gs);
2383 enum tree_code code = gimple_cond_code (gs);
2385 if (lhs != boolean_true_node && lhs != boolean_false_node)
2386 return false;
2388 if (rhs != boolean_true_node && rhs != boolean_false_node)
2389 return false;
2391 if (code == NE_EXPR && lhs == rhs)
2392 return true;
2394 if (code == EQ_EXPR && lhs != rhs)
2395 return true;
2397 return false;
2400 /* Check if conditional statement GS is of the form 'if (var != 0)' or
2401 'if (var == 1)' */
2403 static inline bool
2404 gimple_cond_single_var_p (gimple gs)
2406 if (gimple_cond_code (gs) == NE_EXPR
2407 && gimple_cond_rhs (gs) == boolean_false_node)
2408 return true;
2410 if (gimple_cond_code (gs) == EQ_EXPR
2411 && gimple_cond_rhs (gs) == boolean_true_node)
2412 return true;
2414 return false;
2417 /* Set the code, LHS and RHS of GIMPLE_COND STMT from CODE, LHS and RHS. */
2419 static inline void
2420 gimple_cond_set_condition (gimple stmt, enum tree_code code, tree lhs, tree rhs)
2422 gimple_cond_set_code (stmt, code);
2423 gimple_cond_set_lhs (stmt, lhs);
2424 gimple_cond_set_rhs (stmt, rhs);
2427 /* Return the LABEL_DECL node used by GIMPLE_LABEL statement GS. */
2429 static inline tree
2430 gimple_label_label (const_gimple gs)
2432 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2433 return gimple_op (gs, 0);
2437 /* Set LABEL to be the LABEL_DECL node used by GIMPLE_LABEL statement
2438 GS. */
2440 static inline void
2441 gimple_label_set_label (gimple gs, tree label)
2443 GIMPLE_CHECK (gs, GIMPLE_LABEL);
2444 gcc_assert (TREE_CODE (label) == LABEL_DECL);
2445 gimple_set_op (gs, 0, label);
2449 /* Return the destination of the unconditional jump GS. */
2451 static inline tree
2452 gimple_goto_dest (const_gimple gs)
2454 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2455 return gimple_op (gs, 0);
2459 /* Set DEST to be the destination of the unconditonal jump GS. */
2461 static inline void
2462 gimple_goto_set_dest (gimple gs, tree dest)
2464 GIMPLE_CHECK (gs, GIMPLE_GOTO);
2465 gcc_assert (is_gimple_operand (dest));
2466 gimple_set_op (gs, 0, dest);
2470 /* Return the variables declared in the GIMPLE_BIND statement GS. */
2472 static inline tree
2473 gimple_bind_vars (const_gimple gs)
2475 GIMPLE_CHECK (gs, GIMPLE_BIND);
2476 return gs->gimple_bind.vars;
2480 /* Set VARS to be the set of variables declared in the GIMPLE_BIND
2481 statement GS. */
2483 static inline void
2484 gimple_bind_set_vars (gimple gs, tree vars)
2486 GIMPLE_CHECK (gs, GIMPLE_BIND);
2487 gs->gimple_bind.vars = vars;
2491 /* Append VARS to the set of variables declared in the GIMPLE_BIND
2492 statement GS. */
2494 static inline void
2495 gimple_bind_append_vars (gimple gs, tree vars)
2497 GIMPLE_CHECK (gs, GIMPLE_BIND);
2498 gs->gimple_bind.vars = chainon (gs->gimple_bind.vars, vars);
2502 /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS. */
2504 static inline gimple_seq
2505 gimple_bind_body (gimple gs)
2507 GIMPLE_CHECK (gs, GIMPLE_BIND);
2508 return gs->gimple_bind.body;
2512 /* Set SEQ to be the GIMPLE sequence contained in the GIMPLE_BIND
2513 statement GS. */
2515 static inline void
2516 gimple_bind_set_body (gimple gs, gimple_seq seq)
2518 GIMPLE_CHECK (gs, GIMPLE_BIND);
2519 gs->gimple_bind.body = seq;
2523 /* Append a statement to the end of a GIMPLE_BIND's body. */
2525 static inline void
2526 gimple_bind_add_stmt (gimple gs, gimple stmt)
2528 GIMPLE_CHECK (gs, GIMPLE_BIND);
2529 gimple_seq_add_stmt (&gs->gimple_bind.body, stmt);
2533 /* Append a sequence of statements to the end of a GIMPLE_BIND's body. */
2535 static inline void
2536 gimple_bind_add_seq (gimple gs, gimple_seq seq)
2538 GIMPLE_CHECK (gs, GIMPLE_BIND);
2539 gimple_seq_add_seq (&gs->gimple_bind.body, seq);
2543 /* Return the TREE_BLOCK node associated with GIMPLE_BIND statement
2544 GS. This is analogous to the BIND_EXPR_BLOCK field in trees. */
2546 static inline tree
2547 gimple_bind_block (const_gimple gs)
2549 GIMPLE_CHECK (gs, GIMPLE_BIND);
2550 return gs->gimple_bind.block;
2554 /* Set BLOCK to be the TREE_BLOCK node associated with GIMPLE_BIND
2555 statement GS. */
2557 static inline void
2558 gimple_bind_set_block (gimple gs, tree block)
2560 GIMPLE_CHECK (gs, GIMPLE_BIND);
2561 gcc_assert (block == NULL_TREE || TREE_CODE (block) == BLOCK);
2562 gs->gimple_bind.block = block;
2566 /* Return the number of input operands for GIMPLE_ASM GS. */
2568 static inline unsigned
2569 gimple_asm_ninputs (const_gimple gs)
2571 GIMPLE_CHECK (gs, GIMPLE_ASM);
2572 return gs->gimple_asm.ni;
2576 /* Return the number of output operands for GIMPLE_ASM GS. */
2578 static inline unsigned
2579 gimple_asm_noutputs (const_gimple gs)
2581 GIMPLE_CHECK (gs, GIMPLE_ASM);
2582 return gs->gimple_asm.no;
2586 /* Return the number of clobber operands for GIMPLE_ASM GS. */
2588 static inline unsigned
2589 gimple_asm_nclobbers (const_gimple gs)
2591 GIMPLE_CHECK (gs, GIMPLE_ASM);
2592 return gs->gimple_asm.nc;
2596 /* Return input operand INDEX of GIMPLE_ASM GS. */
2598 static inline tree
2599 gimple_asm_input_op (const_gimple gs, unsigned index)
2601 GIMPLE_CHECK (gs, GIMPLE_ASM);
2602 gcc_assert (index <= gs->gimple_asm.ni);
2603 return gimple_op (gs, index);
2606 /* Return a pointer to input operand INDEX of GIMPLE_ASM GS. */
2608 static inline tree *
2609 gimple_asm_input_op_ptr (const_gimple gs, unsigned index)
2611 GIMPLE_CHECK (gs, GIMPLE_ASM);
2612 gcc_assert (index <= gs->gimple_asm.ni);
2613 return gimple_op_ptr (gs, index);
2617 /* Set IN_OP to be input operand INDEX in GIMPLE_ASM GS. */
2619 static inline void
2620 gimple_asm_set_input_op (gimple gs, unsigned index, tree in_op)
2622 GIMPLE_CHECK (gs, GIMPLE_ASM);
2623 gcc_assert (index <= gs->gimple_asm.ni);
2624 gcc_assert (TREE_CODE (in_op) == TREE_LIST);
2625 gimple_set_op (gs, index, in_op);
2629 /* Return output operand INDEX of GIMPLE_ASM GS. */
2631 static inline tree
2632 gimple_asm_output_op (const_gimple gs, unsigned index)
2634 GIMPLE_CHECK (gs, GIMPLE_ASM);
2635 gcc_assert (index <= gs->gimple_asm.no);
2636 return gimple_op (gs, index + gs->gimple_asm.ni);
2639 /* Return a pointer to output operand INDEX of GIMPLE_ASM GS. */
2641 static inline tree *
2642 gimple_asm_output_op_ptr (const_gimple gs, unsigned index)
2644 GIMPLE_CHECK (gs, GIMPLE_ASM);
2645 gcc_assert (index <= gs->gimple_asm.no);
2646 return gimple_op_ptr (gs, index + gs->gimple_asm.ni);
2650 /* Set OUT_OP to be output operand INDEX in GIMPLE_ASM GS. */
2652 static inline void
2653 gimple_asm_set_output_op (gimple gs, unsigned index, tree out_op)
2655 GIMPLE_CHECK (gs, GIMPLE_ASM);
2656 gcc_assert (index <= gs->gimple_asm.no);
2657 gcc_assert (TREE_CODE (out_op) == TREE_LIST);
2658 gimple_set_op (gs, index + gs->gimple_asm.ni, out_op);
2662 /* Return clobber operand INDEX of GIMPLE_ASM GS. */
2664 static inline tree
2665 gimple_asm_clobber_op (const_gimple gs, unsigned index)
2667 GIMPLE_CHECK (gs, GIMPLE_ASM);
2668 gcc_assert (index <= gs->gimple_asm.nc);
2669 return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no);
2673 /* Set CLOBBER_OP to be clobber operand INDEX in GIMPLE_ASM GS. */
2675 static inline void
2676 gimple_asm_set_clobber_op (gimple gs, unsigned index, tree clobber_op)
2678 GIMPLE_CHECK (gs, GIMPLE_ASM);
2679 gcc_assert (index <= gs->gimple_asm.nc);
2680 gcc_assert (TREE_CODE (clobber_op) == TREE_LIST);
2681 gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no, clobber_op);
2685 /* Return the string representing the assembly instruction in
2686 GIMPLE_ASM GS. */
2688 static inline const char *
2689 gimple_asm_string (const_gimple gs)
2691 GIMPLE_CHECK (gs, GIMPLE_ASM);
2692 return gs->gimple_asm.string;
2696 /* Return true if GS is an asm statement marked volatile. */
2698 static inline bool
2699 gimple_asm_volatile_p (const_gimple gs)
2701 GIMPLE_CHECK (gs, GIMPLE_ASM);
2702 return (gs->gsbase.subcode & GF_ASM_VOLATILE) != 0;
2706 /* If VOLATLE_P is true, mark asm statement GS as volatile. */
2708 static inline void
2709 gimple_asm_set_volatile (gimple gs, bool volatile_p)
2711 GIMPLE_CHECK (gs, GIMPLE_ASM);
2712 if (volatile_p)
2713 gs->gsbase.subcode |= GF_ASM_VOLATILE;
2714 else
2715 gs->gsbase.subcode &= ~GF_ASM_VOLATILE;
2719 /* If INPUT_P is true, mark asm GS as an ASM_INPUT. */
2721 static inline void
2722 gimple_asm_set_input (gimple gs, bool input_p)
2724 GIMPLE_CHECK (gs, GIMPLE_ASM);
2725 if (input_p)
2726 gs->gsbase.subcode |= GF_ASM_INPUT;
2727 else
2728 gs->gsbase.subcode &= ~GF_ASM_INPUT;
2732 /* Return true if asm GS is an ASM_INPUT. */
2734 static inline bool
2735 gimple_asm_input_p (const_gimple gs)
2737 GIMPLE_CHECK (gs, GIMPLE_ASM);
2738 return (gs->gsbase.subcode & GF_ASM_INPUT) != 0;
2742 /* Return the types handled by GIMPLE_CATCH statement GS. */
2744 static inline tree
2745 gimple_catch_types (const_gimple gs)
2747 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2748 return gs->gimple_catch.types;
2752 /* Return a pointer to the types handled by GIMPLE_CATCH statement GS. */
2754 static inline tree *
2755 gimple_catch_types_ptr (gimple gs)
2757 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2758 return &gs->gimple_catch.types;
2762 /* Return the GIMPLE sequence representing the body of the handler of
2763 GIMPLE_CATCH statement GS. */
2765 static inline gimple_seq
2766 gimple_catch_handler (gimple gs)
2768 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2769 return gs->gimple_catch.handler;
2773 /* Return a pointer to the GIMPLE sequence representing the body of
2774 the handler of GIMPLE_CATCH statement GS. */
2776 static inline gimple_seq *
2777 gimple_catch_handler_ptr (gimple gs)
2779 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2780 return &gs->gimple_catch.handler;
2784 /* Set T to be the set of types handled by GIMPLE_CATCH GS. */
2786 static inline void
2787 gimple_catch_set_types (gimple gs, tree t)
2789 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2790 gs->gimple_catch.types = t;
2794 /* Set HANDLER to be the body of GIMPLE_CATCH GS. */
2796 static inline void
2797 gimple_catch_set_handler (gimple gs, gimple_seq handler)
2799 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2800 gs->gimple_catch.handler = handler;
2804 /* Return the types handled by GIMPLE_EH_FILTER statement GS. */
2806 static inline tree
2807 gimple_eh_filter_types (const_gimple gs)
2809 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2810 return gs->gimple_eh_filter.types;
2814 /* Return a pointer to the types handled by GIMPLE_EH_FILTER statement
2815 GS. */
2817 static inline tree *
2818 gimple_eh_filter_types_ptr (gimple gs)
2820 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2821 return &gs->gimple_eh_filter.types;
2825 /* Return the sequence of statement to execute when GIMPLE_EH_FILTER
2826 statement fails. */
2828 static inline gimple_seq
2829 gimple_eh_filter_failure (gimple gs)
2831 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2832 return gs->gimple_eh_filter.failure;
2836 /* Set TYPES to be the set of types handled by GIMPLE_EH_FILTER GS. */
2838 static inline void
2839 gimple_eh_filter_set_types (gimple gs, tree types)
2841 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2842 gs->gimple_eh_filter.types = types;
2846 /* Set FAILURE to be the sequence of statements to execute on failure
2847 for GIMPLE_EH_FILTER GS. */
2849 static inline void
2850 gimple_eh_filter_set_failure (gimple gs, gimple_seq failure)
2852 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2853 gs->gimple_eh_filter.failure = failure;
2856 /* Return the EH_FILTER_MUST_NOT_THROW flag. */
2858 static inline bool
2860 gimple_eh_filter_must_not_throw (gimple gs)
2862 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2863 return gs->gsbase.subcode != 0;
2866 /* Set the EH_FILTER_MUST_NOT_THROW flag to the value MNTP. */
2868 static inline void
2869 gimple_eh_filter_set_must_not_throw (gimple gs, bool mntp)
2871 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2872 gs->gsbase.subcode = (unsigned int) mntp;
2876 /* GIMPLE_TRY accessors. */
2878 /* Return the kind of try block represented by GIMPLE_TRY GS. This is
2879 either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY. */
2881 static inline enum gimple_try_flags
2882 gimple_try_kind (const_gimple gs)
2884 GIMPLE_CHECK (gs, GIMPLE_TRY);
2885 return (enum gimple_try_flags) (gs->gsbase.subcode & GIMPLE_TRY_KIND);
2889 /* Set the kind of try block represented by GIMPLE_TRY GS. */
2891 static inline void
2892 gimple_try_set_kind (gimple gs, enum gimple_try_flags kind)
2894 GIMPLE_CHECK (gs, GIMPLE_TRY);
2895 gcc_assert (kind == GIMPLE_TRY_CATCH || kind == GIMPLE_TRY_FINALLY);
2896 if (gimple_try_kind (gs) != kind)
2897 gs->gsbase.subcode = (unsigned int) kind;
2901 /* Return the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2903 static inline bool
2904 gimple_try_catch_is_cleanup (const_gimple gs)
2906 gcc_assert (gimple_try_kind (gs) == GIMPLE_TRY_CATCH);
2907 return (gs->gsbase.subcode & GIMPLE_TRY_CATCH_IS_CLEANUP) != 0;
2911 /* Return the sequence of statements used as the body for GIMPLE_TRY GS. */
2913 static inline gimple_seq
2914 gimple_try_eval (gimple gs)
2916 GIMPLE_CHECK (gs, GIMPLE_TRY);
2917 return gs->gimple_try.eval;
2921 /* Return the sequence of statements used as the cleanup body for
2922 GIMPLE_TRY GS. */
2924 static inline gimple_seq
2925 gimple_try_cleanup (gimple gs)
2927 GIMPLE_CHECK (gs, GIMPLE_TRY);
2928 return gs->gimple_try.cleanup;
2932 /* Set the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2934 static inline void
2935 gimple_try_set_catch_is_cleanup (gimple g, bool catch_is_cleanup)
2937 gcc_assert (gimple_try_kind (g) == GIMPLE_TRY_CATCH);
2938 if (catch_is_cleanup)
2939 g->gsbase.subcode |= GIMPLE_TRY_CATCH_IS_CLEANUP;
2940 else
2941 g->gsbase.subcode &= ~GIMPLE_TRY_CATCH_IS_CLEANUP;
2945 /* Set EVAL to be the sequence of statements to use as the body for
2946 GIMPLE_TRY GS. */
2948 static inline void
2949 gimple_try_set_eval (gimple gs, gimple_seq eval)
2951 GIMPLE_CHECK (gs, GIMPLE_TRY);
2952 gs->gimple_try.eval = eval;
2956 /* Set CLEANUP to be the sequence of statements to use as the cleanup
2957 body for GIMPLE_TRY GS. */
2959 static inline void
2960 gimple_try_set_cleanup (gimple gs, gimple_seq cleanup)
2962 GIMPLE_CHECK (gs, GIMPLE_TRY);
2963 gs->gimple_try.cleanup = cleanup;
2967 /* Return the cleanup sequence for cleanup statement GS. */
2969 static inline gimple_seq
2970 gimple_wce_cleanup (gimple gs)
2972 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
2973 return gs->gimple_wce.cleanup;
2977 /* Set CLEANUP to be the cleanup sequence for GS. */
2979 static inline void
2980 gimple_wce_set_cleanup (gimple gs, gimple_seq cleanup)
2982 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
2983 gs->gimple_wce.cleanup = cleanup;
2987 /* Return the CLEANUP_EH_ONLY flag for a WCE tuple. */
2989 static inline bool
2990 gimple_wce_cleanup_eh_only (const_gimple gs)
2992 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
2993 return gs->gsbase.subcode != 0;
2997 /* Set the CLEANUP_EH_ONLY flag for a WCE tuple. */
2999 static inline void
3000 gimple_wce_set_cleanup_eh_only (gimple gs, bool eh_only_p)
3002 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3003 gs->gsbase.subcode = (unsigned int) eh_only_p;
3007 /* Return the maximum number of arguments supported by GIMPLE_PHI GS. */
3009 static inline unsigned
3010 gimple_phi_capacity (const_gimple gs)
3012 GIMPLE_CHECK (gs, GIMPLE_PHI);
3013 return gs->gimple_phi.capacity;
3017 /* Return the number of arguments in GIMPLE_PHI GS. This must always
3018 be exactly the number of incoming edges for the basic block holding
3019 GS. */
3021 static inline unsigned
3022 gimple_phi_num_args (const_gimple gs)
3024 GIMPLE_CHECK (gs, GIMPLE_PHI);
3025 return gs->gimple_phi.nargs;
3029 /* Return the SSA name created by GIMPLE_PHI GS. */
3031 static inline tree
3032 gimple_phi_result (const_gimple gs)
3034 GIMPLE_CHECK (gs, GIMPLE_PHI);
3035 return gs->gimple_phi.result;
3038 /* Return a pointer to the SSA name created by GIMPLE_PHI GS. */
3040 static inline tree *
3041 gimple_phi_result_ptr (gimple gs)
3043 GIMPLE_CHECK (gs, GIMPLE_PHI);
3044 return &gs->gimple_phi.result;
3047 /* Set RESULT to be the SSA name created by GIMPLE_PHI GS. */
3049 static inline void
3050 gimple_phi_set_result (gimple gs, tree result)
3052 GIMPLE_CHECK (gs, GIMPLE_PHI);
3053 gs->gimple_phi.result = result;
3057 /* Return the PHI argument corresponding to incoming edge INDEX for
3058 GIMPLE_PHI GS. */
3060 static inline struct phi_arg_d *
3061 gimple_phi_arg (gimple gs, unsigned index)
3063 GIMPLE_CHECK (gs, GIMPLE_PHI);
3064 gcc_assert (index <= gs->gimple_phi.capacity);
3065 return &(gs->gimple_phi.args[index]);
3068 /* Set PHIARG to be the argument corresponding to incoming edge INDEX
3069 for GIMPLE_PHI GS. */
3071 static inline void
3072 gimple_phi_set_arg (gimple gs, unsigned index, struct phi_arg_d * phiarg)
3074 GIMPLE_CHECK (gs, GIMPLE_PHI);
3075 gcc_assert (index <= gs->gimple_phi.nargs);
3076 memcpy (gs->gimple_phi.args + index, phiarg, sizeof (struct phi_arg_d));
3079 /* Return the region number for GIMPLE_RESX GS. */
3081 static inline int
3082 gimple_resx_region (const_gimple gs)
3084 GIMPLE_CHECK (gs, GIMPLE_RESX);
3085 return gs->gimple_resx.region;
3088 /* Set REGION to be the region number for GIMPLE_RESX GS. */
3090 static inline void
3091 gimple_resx_set_region (gimple gs, int region)
3093 GIMPLE_CHECK (gs, GIMPLE_RESX);
3094 gs->gimple_resx.region = region;
3098 /* Return the number of labels associated with the switch statement GS. */
3100 static inline unsigned
3101 gimple_switch_num_labels (const_gimple gs)
3103 unsigned num_ops;
3104 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3105 num_ops = gimple_num_ops (gs);
3106 gcc_assert (num_ops > 1);
3107 return num_ops - 1;
3111 /* Set NLABELS to be the number of labels for the switch statement GS. */
3113 static inline void
3114 gimple_switch_set_num_labels (gimple g, unsigned nlabels)
3116 GIMPLE_CHECK (g, GIMPLE_SWITCH);
3117 gimple_set_num_ops (g, nlabels + 1);
3121 /* Return the index variable used by the switch statement GS. */
3123 static inline tree
3124 gimple_switch_index (const_gimple gs)
3126 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3127 return gimple_op (gs, 0);
3131 /* Return a pointer to the index variable for the switch statement GS. */
3133 static inline tree *
3134 gimple_switch_index_ptr (const_gimple gs)
3136 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3137 return gimple_op_ptr (gs, 0);
3141 /* Set INDEX to be the index variable for switch statement GS. */
3143 static inline void
3144 gimple_switch_set_index (gimple gs, tree index)
3146 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3147 gcc_assert (SSA_VAR_P (index) || CONSTANT_CLASS_P (index));
3148 gimple_set_op (gs, 0, index);
3152 /* Return the label numbered INDEX. The default label is 0, followed by any
3153 labels in a switch statement. */
3155 static inline tree
3156 gimple_switch_label (const_gimple gs, unsigned index)
3158 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3159 gcc_assert (gimple_num_ops (gs) > index + 1);
3160 return gimple_op (gs, index + 1);
3163 /* Set the label number INDEX to LABEL. 0 is always the default label. */
3165 static inline void
3166 gimple_switch_set_label (gimple gs, unsigned index, tree label)
3168 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3169 gcc_assert (gimple_num_ops (gs) > index + 1);
3170 gcc_assert (label == NULL_TREE || TREE_CODE (label) == CASE_LABEL_EXPR);
3171 gimple_set_op (gs, index + 1, label);
3174 /* Return the default label for a switch statement. */
3176 static inline tree
3177 gimple_switch_default_label (const_gimple gs)
3179 return gimple_switch_label (gs, 0);
3182 /* Set the default label for a switch statement. */
3184 static inline void
3185 gimple_switch_set_default_label (gimple gs, tree label)
3187 gimple_switch_set_label (gs, 0, label);
3191 /* Return the body for the OMP statement GS. */
3193 static inline gimple_seq
3194 gimple_omp_body (gimple gs)
3196 return gs->omp.body;
3199 /* Set BODY to be the body for the OMP statement GS. */
3201 static inline void
3202 gimple_omp_set_body (gimple gs, gimple_seq body)
3204 gs->omp.body = body;
3208 /* Return the name associated with OMP_CRITICAL statement GS. */
3210 static inline tree
3211 gimple_omp_critical_name (const_gimple gs)
3213 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3214 return gs->gimple_omp_critical.name;
3218 /* Return a pointer to the name associated with OMP critical statement GS. */
3220 static inline tree *
3221 gimple_omp_critical_name_ptr (gimple gs)
3223 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3224 return &gs->gimple_omp_critical.name;
3228 /* Set NAME to be the name associated with OMP critical statement GS. */
3230 static inline void
3231 gimple_omp_critical_set_name (gimple gs, tree name)
3233 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3234 gs->gimple_omp_critical.name = name;
3238 /* Return the clauses associated with OMP_FOR GS. */
3240 static inline tree
3241 gimple_omp_for_clauses (const_gimple gs)
3243 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3244 return gs->gimple_omp_for.clauses;
3248 /* Return a pointer to the OMP_FOR GS. */
3250 static inline tree *
3251 gimple_omp_for_clauses_ptr (gimple gs)
3253 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3254 return &gs->gimple_omp_for.clauses;
3258 /* Set CLAUSES to be the list of clauses associated with OMP_FOR GS. */
3260 static inline void
3261 gimple_omp_for_set_clauses (gimple gs, tree clauses)
3263 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3264 gs->gimple_omp_for.clauses = clauses;
3268 /* Get the collapse count of OMP_FOR GS. */
3270 static inline size_t
3271 gimple_omp_for_collapse (gimple gs)
3273 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3274 return gs->gimple_omp_for.collapse;
3278 /* Return the index variable for OMP_FOR GS. */
3280 static inline tree
3281 gimple_omp_for_index (const_gimple gs, size_t i)
3283 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3284 gcc_assert (i < gs->gimple_omp_for.collapse);
3285 return gs->gimple_omp_for.iter[i].index;
3289 /* Return a pointer to the index variable for OMP_FOR GS. */
3291 static inline tree *
3292 gimple_omp_for_index_ptr (gimple gs, size_t i)
3294 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3295 gcc_assert (i < gs->gimple_omp_for.collapse);
3296 return &gs->gimple_omp_for.iter[i].index;
3300 /* Set INDEX to be the index variable for OMP_FOR GS. */
3302 static inline void
3303 gimple_omp_for_set_index (gimple gs, size_t i, tree index)
3305 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3306 gcc_assert (i < gs->gimple_omp_for.collapse);
3307 gs->gimple_omp_for.iter[i].index = index;
3311 /* Return the initial value for OMP_FOR GS. */
3313 static inline tree
3314 gimple_omp_for_initial (const_gimple gs, size_t i)
3316 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3317 gcc_assert (i < gs->gimple_omp_for.collapse);
3318 return gs->gimple_omp_for.iter[i].initial;
3322 /* Return a pointer to the initial value for OMP_FOR GS. */
3324 static inline tree *
3325 gimple_omp_for_initial_ptr (gimple gs, size_t i)
3327 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3328 gcc_assert (i < gs->gimple_omp_for.collapse);
3329 return &gs->gimple_omp_for.iter[i].initial;
3333 /* Set INITIAL to be the initial value for OMP_FOR GS. */
3335 static inline void
3336 gimple_omp_for_set_initial (gimple gs, size_t i, tree initial)
3338 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3339 gcc_assert (i < gs->gimple_omp_for.collapse);
3340 gs->gimple_omp_for.iter[i].initial = initial;
3344 /* Return the final value for OMP_FOR GS. */
3346 static inline tree
3347 gimple_omp_for_final (const_gimple gs, size_t i)
3349 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3350 gcc_assert (i < gs->gimple_omp_for.collapse);
3351 return gs->gimple_omp_for.iter[i].final;
3355 /* Return a pointer to the final value for OMP_FOR GS. */
3357 static inline tree *
3358 gimple_omp_for_final_ptr (gimple gs, size_t i)
3360 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3361 gcc_assert (i < gs->gimple_omp_for.collapse);
3362 return &gs->gimple_omp_for.iter[i].final;
3366 /* Set FINAL to be the final value for OMP_FOR GS. */
3368 static inline void
3369 gimple_omp_for_set_final (gimple gs, size_t i, tree final)
3371 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3372 gcc_assert (i < gs->gimple_omp_for.collapse);
3373 gs->gimple_omp_for.iter[i].final = final;
3377 /* Return the increment value for OMP_FOR GS. */
3379 static inline tree
3380 gimple_omp_for_incr (const_gimple gs, size_t i)
3382 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3383 gcc_assert (i < gs->gimple_omp_for.collapse);
3384 return gs->gimple_omp_for.iter[i].incr;
3388 /* Return a pointer to the increment value for OMP_FOR GS. */
3390 static inline tree *
3391 gimple_omp_for_incr_ptr (gimple gs, size_t i)
3393 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3394 gcc_assert (i < gs->gimple_omp_for.collapse);
3395 return &gs->gimple_omp_for.iter[i].incr;
3399 /* Set INCR to be the increment value for OMP_FOR GS. */
3401 static inline void
3402 gimple_omp_for_set_incr (gimple gs, size_t i, tree incr)
3404 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3405 gcc_assert (i < gs->gimple_omp_for.collapse);
3406 gs->gimple_omp_for.iter[i].incr = incr;
3410 /* Return the sequence of statements to execute before the OMP_FOR
3411 statement GS starts. */
3413 static inline gimple_seq
3414 gimple_omp_for_pre_body (gimple gs)
3416 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3417 return gs->gimple_omp_for.pre_body;
3421 /* Set PRE_BODY to be the sequence of statements to execute before the
3422 OMP_FOR statement GS starts. */
3424 static inline void
3425 gimple_omp_for_set_pre_body (gimple gs, gimple_seq pre_body)
3427 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3428 gs->gimple_omp_for.pre_body = pre_body;
3432 /* Return the clauses associated with OMP_PARALLEL GS. */
3434 static inline tree
3435 gimple_omp_parallel_clauses (const_gimple gs)
3437 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3438 return gs->gimple_omp_parallel.clauses;
3442 /* Return a pointer to the clauses associated with OMP_PARALLEL GS. */
3444 static inline tree *
3445 gimple_omp_parallel_clauses_ptr (gimple gs)
3447 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3448 return &gs->gimple_omp_parallel.clauses;
3452 /* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL
3453 GS. */
3455 static inline void
3456 gimple_omp_parallel_set_clauses (gimple gs, tree clauses)
3458 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3459 gs->gimple_omp_parallel.clauses = clauses;
3463 /* Return the child function used to hold the body of OMP_PARALLEL GS. */
3465 static inline tree
3466 gimple_omp_parallel_child_fn (const_gimple gs)
3468 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3469 return gs->gimple_omp_parallel.child_fn;
3472 /* Return a pointer to the child function used to hold the body of
3473 OMP_PARALLEL GS. */
3475 static inline tree *
3476 gimple_omp_parallel_child_fn_ptr (gimple gs)
3478 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3479 return &gs->gimple_omp_parallel.child_fn;
3483 /* Set CHILD_FN to be the child function for OMP_PARALLEL GS. */
3485 static inline void
3486 gimple_omp_parallel_set_child_fn (gimple gs, tree child_fn)
3488 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3489 gs->gimple_omp_parallel.child_fn = child_fn;
3493 /* Return the artificial argument used to send variables and values
3494 from the parent to the children threads in OMP_PARALLEL GS. */
3496 static inline tree
3497 gimple_omp_parallel_data_arg (const_gimple gs)
3499 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3500 return gs->gimple_omp_parallel.data_arg;
3504 /* Return a pointer to the data argument for OMP_PARALLEL GS. */
3506 static inline tree *
3507 gimple_omp_parallel_data_arg_ptr (gimple gs)
3509 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3510 return &gs->gimple_omp_parallel.data_arg;
3514 /* Set DATA_ARG to be the data argument for OMP_PARALLEL GS. */
3516 static inline void
3517 gimple_omp_parallel_set_data_arg (gimple gs, tree data_arg)
3519 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3520 gs->gimple_omp_parallel.data_arg = data_arg;
3524 /* Return the clauses associated with OMP_TASK GS. */
3526 static inline tree
3527 gimple_omp_task_clauses (const_gimple gs)
3529 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3530 return gs->gimple_omp_parallel.clauses;
3534 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3536 static inline tree *
3537 gimple_omp_task_clauses_ptr (gimple gs)
3539 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3540 return &gs->gimple_omp_parallel.clauses;
3544 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3545 GS. */
3547 static inline void
3548 gimple_omp_task_set_clauses (gimple gs, tree clauses)
3550 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3551 gs->gimple_omp_parallel.clauses = clauses;
3555 /* Return the child function used to hold the body of OMP_TASK GS. */
3557 static inline tree
3558 gimple_omp_task_child_fn (const_gimple gs)
3560 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3561 return gs->gimple_omp_parallel.child_fn;
3564 /* Return a pointer to the child function used to hold the body of
3565 OMP_TASK GS. */
3567 static inline tree *
3568 gimple_omp_task_child_fn_ptr (gimple gs)
3570 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3571 return &gs->gimple_omp_parallel.child_fn;
3575 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3577 static inline void
3578 gimple_omp_task_set_child_fn (gimple gs, tree child_fn)
3580 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3581 gs->gimple_omp_parallel.child_fn = child_fn;
3585 /* Return the artificial argument used to send variables and values
3586 from the parent to the children threads in OMP_TASK GS. */
3588 static inline tree
3589 gimple_omp_task_data_arg (const_gimple gs)
3591 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3592 return gs->gimple_omp_parallel.data_arg;
3596 /* Return a pointer to the data argument for OMP_TASK GS. */
3598 static inline tree *
3599 gimple_omp_task_data_arg_ptr (gimple gs)
3601 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3602 return &gs->gimple_omp_parallel.data_arg;
3606 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3608 static inline void
3609 gimple_omp_task_set_data_arg (gimple gs, tree data_arg)
3611 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3612 gs->gimple_omp_parallel.data_arg = data_arg;
3616 /* Return the clauses associated with OMP_TASK GS. */
3618 static inline tree
3619 gimple_omp_taskreg_clauses (const_gimple gs)
3621 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3622 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3623 return gs->gimple_omp_parallel.clauses;
3627 /* Return a pointer to the clauses associated with OMP_TASK GS. */
3629 static inline tree *
3630 gimple_omp_taskreg_clauses_ptr (gimple gs)
3632 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3633 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3634 return &gs->gimple_omp_parallel.clauses;
3638 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3639 GS. */
3641 static inline void
3642 gimple_omp_taskreg_set_clauses (gimple gs, tree clauses)
3644 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3645 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3646 gs->gimple_omp_parallel.clauses = clauses;
3650 /* Return the child function used to hold the body of OMP_TASK GS. */
3652 static inline tree
3653 gimple_omp_taskreg_child_fn (const_gimple gs)
3655 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3656 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3657 return gs->gimple_omp_parallel.child_fn;
3660 /* Return a pointer to the child function used to hold the body of
3661 OMP_TASK GS. */
3663 static inline tree *
3664 gimple_omp_taskreg_child_fn_ptr (gimple gs)
3666 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3667 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3668 return &gs->gimple_omp_parallel.child_fn;
3672 /* Set CHILD_FN to be the child function for OMP_TASK GS. */
3674 static inline void
3675 gimple_omp_taskreg_set_child_fn (gimple gs, tree child_fn)
3677 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3678 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3679 gs->gimple_omp_parallel.child_fn = child_fn;
3683 /* Return the artificial argument used to send variables and values
3684 from the parent to the children threads in OMP_TASK GS. */
3686 static inline tree
3687 gimple_omp_taskreg_data_arg (const_gimple gs)
3689 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3690 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3691 return gs->gimple_omp_parallel.data_arg;
3695 /* Return a pointer to the data argument for OMP_TASK GS. */
3697 static inline tree *
3698 gimple_omp_taskreg_data_arg_ptr (gimple gs)
3700 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3701 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3702 return &gs->gimple_omp_parallel.data_arg;
3706 /* Set DATA_ARG to be the data argument for OMP_TASK GS. */
3708 static inline void
3709 gimple_omp_taskreg_set_data_arg (gimple gs, tree data_arg)
3711 if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3712 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3713 gs->gimple_omp_parallel.data_arg = data_arg;
3717 /* Return the copy function used to hold the body of OMP_TASK GS. */
3719 static inline tree
3720 gimple_omp_task_copy_fn (const_gimple gs)
3722 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3723 return gs->gimple_omp_task.copy_fn;
3726 /* Return a pointer to the copy function used to hold the body of
3727 OMP_TASK GS. */
3729 static inline tree *
3730 gimple_omp_task_copy_fn_ptr (gimple gs)
3732 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3733 return &gs->gimple_omp_task.copy_fn;
3737 /* Set CHILD_FN to be the copy function for OMP_TASK GS. */
3739 static inline void
3740 gimple_omp_task_set_copy_fn (gimple gs, tree copy_fn)
3742 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3743 gs->gimple_omp_task.copy_fn = copy_fn;
3747 /* Return size of the data block in bytes in OMP_TASK GS. */
3749 static inline tree
3750 gimple_omp_task_arg_size (const_gimple gs)
3752 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3753 return gs->gimple_omp_task.arg_size;
3757 /* Return a pointer to the data block size for OMP_TASK GS. */
3759 static inline tree *
3760 gimple_omp_task_arg_size_ptr (gimple gs)
3762 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3763 return &gs->gimple_omp_task.arg_size;
3767 /* Set ARG_SIZE to be the data block size for OMP_TASK GS. */
3769 static inline void
3770 gimple_omp_task_set_arg_size (gimple gs, tree arg_size)
3772 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3773 gs->gimple_omp_task.arg_size = arg_size;
3777 /* Return align of the data block in bytes in OMP_TASK GS. */
3779 static inline tree
3780 gimple_omp_task_arg_align (const_gimple gs)
3782 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3783 return gs->gimple_omp_task.arg_align;
3787 /* Return a pointer to the data block align for OMP_TASK GS. */
3789 static inline tree *
3790 gimple_omp_task_arg_align_ptr (gimple gs)
3792 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3793 return &gs->gimple_omp_task.arg_align;
3797 /* Set ARG_SIZE to be the data block align for OMP_TASK GS. */
3799 static inline void
3800 gimple_omp_task_set_arg_align (gimple gs, tree arg_align)
3802 GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3803 gs->gimple_omp_task.arg_align = arg_align;
3807 /* Return the clauses associated with OMP_SINGLE GS. */
3809 static inline tree
3810 gimple_omp_single_clauses (const_gimple gs)
3812 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3813 return gs->gimple_omp_single.clauses;
3817 /* Return a pointer to the clauses associated with OMP_SINGLE GS. */
3819 static inline tree *
3820 gimple_omp_single_clauses_ptr (gimple gs)
3822 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3823 return &gs->gimple_omp_single.clauses;
3827 /* Set CLAUSES to be the clauses associated with OMP_SINGLE GS. */
3829 static inline void
3830 gimple_omp_single_set_clauses (gimple gs, tree clauses)
3832 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
3833 gs->gimple_omp_single.clauses = clauses;
3837 /* Return the clauses associated with OMP_SECTIONS GS. */
3839 static inline tree
3840 gimple_omp_sections_clauses (const_gimple gs)
3842 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3843 return gs->gimple_omp_sections.clauses;
3847 /* Return a pointer to the clauses associated with OMP_SECTIONS GS. */
3849 static inline tree *
3850 gimple_omp_sections_clauses_ptr (gimple gs)
3852 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3853 return &gs->gimple_omp_sections.clauses;
3857 /* Set CLAUSES to be the set of clauses associated with OMP_SECTIONS
3858 GS. */
3860 static inline void
3861 gimple_omp_sections_set_clauses (gimple gs, tree clauses)
3863 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3864 gs->gimple_omp_sections.clauses = clauses;
3868 /* Return the control variable associated with the GIMPLE_OMP_SECTIONS
3869 in GS. */
3871 static inline tree
3872 gimple_omp_sections_control (const_gimple gs)
3874 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3875 return gs->gimple_omp_sections.control;
3879 /* Return a pointer to the clauses associated with the GIMPLE_OMP_SECTIONS
3880 GS. */
3882 static inline tree *
3883 gimple_omp_sections_control_ptr (gimple gs)
3885 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3886 return &gs->gimple_omp_sections.control;
3890 /* Set CONTROL to be the set of clauses associated with the
3891 GIMPLE_OMP_SECTIONS in GS. */
3893 static inline void
3894 gimple_omp_sections_set_control (gimple gs, tree control)
3896 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3897 gs->gimple_omp_sections.control = control;
3901 /* Set COND to be the condition code for OMP_FOR GS. */
3903 static inline void
3904 gimple_omp_for_set_cond (gimple gs, size_t i, enum tree_code cond)
3906 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3907 gcc_assert (TREE_CODE_CLASS (cond) == tcc_comparison);
3908 gcc_assert (i < gs->gimple_omp_for.collapse);
3909 gs->gimple_omp_for.iter[i].cond = cond;
3913 /* Return the condition code associated with OMP_FOR GS. */
3915 static inline enum tree_code
3916 gimple_omp_for_cond (const_gimple gs, size_t i)
3918 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3919 gcc_assert (i < gs->gimple_omp_for.collapse);
3920 return gs->gimple_omp_for.iter[i].cond;
3924 /* Set the value being stored in an atomic store. */
3926 static inline void
3927 gimple_omp_atomic_store_set_val (gimple g, tree val)
3929 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3930 g->gimple_omp_atomic_store.val = val;
3934 /* Return the value being stored in an atomic store. */
3936 static inline tree
3937 gimple_omp_atomic_store_val (const_gimple g)
3939 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3940 return g->gimple_omp_atomic_store.val;
3944 /* Return a pointer to the value being stored in an atomic store. */
3946 static inline tree *
3947 gimple_omp_atomic_store_val_ptr (gimple g)
3949 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3950 return &g->gimple_omp_atomic_store.val;
3954 /* Set the LHS of an atomic load. */
3956 static inline void
3957 gimple_omp_atomic_load_set_lhs (gimple g, tree lhs)
3959 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
3960 g->gimple_omp_atomic_load.lhs = lhs;
3964 /* Get the LHS of an atomic load. */
3966 static inline tree
3967 gimple_omp_atomic_load_lhs (const_gimple g)
3969 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
3970 return g->gimple_omp_atomic_load.lhs;
3974 /* Return a pointer to the LHS of an atomic load. */
3976 static inline tree *
3977 gimple_omp_atomic_load_lhs_ptr (gimple g)
3979 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
3980 return &g->gimple_omp_atomic_load.lhs;
3984 /* Set the RHS of an atomic load. */
3986 static inline void
3987 gimple_omp_atomic_load_set_rhs (gimple g, tree rhs)
3989 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
3990 g->gimple_omp_atomic_load.rhs = rhs;
3994 /* Get the RHS of an atomic load. */
3996 static inline tree
3997 gimple_omp_atomic_load_rhs (const_gimple g)
3999 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4000 return g->gimple_omp_atomic_load.rhs;
4004 /* Return a pointer to the RHS of an atomic load. */
4006 static inline tree *
4007 gimple_omp_atomic_load_rhs_ptr (gimple g)
4009 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4010 return &g->gimple_omp_atomic_load.rhs;
4014 /* Get the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4016 static inline tree
4017 gimple_omp_continue_control_def (const_gimple g)
4019 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4020 return g->gimple_omp_continue.control_def;
4023 /* The same as above, but return the address. */
4025 static inline tree *
4026 gimple_omp_continue_control_def_ptr (gimple g)
4028 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4029 return &g->gimple_omp_continue.control_def;
4032 /* Set the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
4034 static inline void
4035 gimple_omp_continue_set_control_def (gimple g, tree def)
4037 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4038 g->gimple_omp_continue.control_def = def;
4042 /* Get the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4044 static inline tree
4045 gimple_omp_continue_control_use (const_gimple g)
4047 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4048 return g->gimple_omp_continue.control_use;
4052 /* The same as above, but return the address. */
4054 static inline tree *
4055 gimple_omp_continue_control_use_ptr (gimple g)
4057 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4058 return &g->gimple_omp_continue.control_use;
4062 /* Set the use of the control variable in a GIMPLE_OMP_CONTINUE. */
4064 static inline void
4065 gimple_omp_continue_set_control_use (gimple g, tree use)
4067 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4068 g->gimple_omp_continue.control_use = use;
4072 /* Return a pointer to the return value for GIMPLE_RETURN GS. */
4074 static inline tree *
4075 gimple_return_retval_ptr (const_gimple gs)
4077 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4078 gcc_assert (gimple_num_ops (gs) == 1);
4079 return gimple_op_ptr (gs, 0);
4082 /* Return the return value for GIMPLE_RETURN GS. */
4084 static inline tree
4085 gimple_return_retval (const_gimple gs)
4087 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4088 gcc_assert (gimple_num_ops (gs) == 1);
4089 return gimple_op (gs, 0);
4093 /* Set RETVAL to be the return value for GIMPLE_RETURN GS. */
4095 static inline void
4096 gimple_return_set_retval (gimple gs, tree retval)
4098 GIMPLE_CHECK (gs, GIMPLE_RETURN);
4099 gcc_assert (gimple_num_ops (gs) == 1);
4100 gcc_assert (retval == NULL_TREE
4101 || TREE_CODE (retval) == RESULT_DECL
4102 || is_gimple_val (retval));
4103 gimple_set_op (gs, 0, retval);
4107 /* Returns true when the gimple statment STMT is any of the OpenMP types. */
4109 static inline bool
4110 is_gimple_omp (const_gimple stmt)
4112 return (gimple_code (stmt) == GIMPLE_OMP_PARALLEL
4113 || gimple_code (stmt) == GIMPLE_OMP_TASK
4114 || gimple_code (stmt) == GIMPLE_OMP_FOR
4115 || gimple_code (stmt) == GIMPLE_OMP_SECTIONS
4116 || gimple_code (stmt) == GIMPLE_OMP_SECTIONS_SWITCH
4117 || gimple_code (stmt) == GIMPLE_OMP_SINGLE
4118 || gimple_code (stmt) == GIMPLE_OMP_SECTION
4119 || gimple_code (stmt) == GIMPLE_OMP_MASTER
4120 || gimple_code (stmt) == GIMPLE_OMP_ORDERED
4121 || gimple_code (stmt) == GIMPLE_OMP_CRITICAL
4122 || gimple_code (stmt) == GIMPLE_OMP_RETURN
4123 || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_LOAD
4124 || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_STORE
4125 || gimple_code (stmt) == GIMPLE_OMP_CONTINUE);
4129 /* Returns TRUE if statement G is a GIMPLE_NOP. */
4131 static inline bool
4132 gimple_nop_p (const_gimple g)
4134 return gimple_code (g) == GIMPLE_NOP;
4138 /* Return the new type set by GIMPLE_CHANGE_DYNAMIC_TYPE statement GS. */
4140 static inline tree
4141 gimple_cdt_new_type (gimple gs)
4143 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4144 return gimple_op (gs, 1);
4147 /* Return a pointer to the new type set by GIMPLE_CHANGE_DYNAMIC_TYPE
4148 statement GS. */
4150 static inline tree *
4151 gimple_cdt_new_type_ptr (gimple gs)
4153 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4154 return gimple_op_ptr (gs, 1);
4157 /* Set NEW_TYPE to be the type returned by GIMPLE_CHANGE_DYNAMIC_TYPE
4158 statement GS. */
4160 static inline void
4161 gimple_cdt_set_new_type (gimple gs, tree new_type)
4163 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4164 gcc_assert (TREE_CODE_CLASS (TREE_CODE (new_type)) == tcc_type);
4165 gimple_set_op (gs, 1, new_type);
4169 /* Return the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE statement GS. */
4171 static inline tree
4172 gimple_cdt_location (gimple gs)
4174 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4175 return gimple_op (gs, 0);
4179 /* Return a pointer to the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE
4180 statement GS. */
4182 static inline tree *
4183 gimple_cdt_location_ptr (gimple gs)
4185 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4186 return gimple_op_ptr (gs, 0);
4190 /* Set PTR to be the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE
4191 statement GS. */
4193 static inline void
4194 gimple_cdt_set_location (gimple gs, tree ptr)
4196 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
4197 gimple_set_op (gs, 0, ptr);
4201 /* Return the predictor of GIMPLE_PREDICT statement GS. */
4203 static inline enum br_predictor
4204 gimple_predict_predictor (gimple gs)
4206 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4207 return (enum br_predictor) (gs->gsbase.subcode & ~GF_PREDICT_TAKEN);
4211 /* Set the predictor of GIMPLE_PREDICT statement GS to PREDICT. */
4213 static inline void
4214 gimple_predict_set_predictor (gimple gs, enum br_predictor predictor)
4216 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4217 gs->gsbase.subcode = (gs->gsbase.subcode & GF_PREDICT_TAKEN)
4218 | (unsigned) predictor;
4222 /* Return the outcome of GIMPLE_PREDICT statement GS. */
4224 static inline enum prediction
4225 gimple_predict_outcome (gimple gs)
4227 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4228 return (gs->gsbase.subcode & GF_PREDICT_TAKEN) ? TAKEN : NOT_TAKEN;
4232 /* Set the outcome of GIMPLE_PREDICT statement GS to OUTCOME. */
4234 static inline void
4235 gimple_predict_set_outcome (gimple gs, enum prediction outcome)
4237 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4238 if (outcome == TAKEN)
4239 gs->gsbase.subcode |= GF_PREDICT_TAKEN;
4240 else
4241 gs->gsbase.subcode &= ~GF_PREDICT_TAKEN;
4245 /* Return a new iterator pointing to GIMPLE_SEQ's first statement. */
4247 static inline gimple_stmt_iterator
4248 gsi_start (gimple_seq seq)
4250 gimple_stmt_iterator i;
4252 i.ptr = gimple_seq_first (seq);
4253 i.seq = seq;
4254 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4256 return i;
4260 /* Return a new iterator pointing to the first statement in basic block BB. */
4262 static inline gimple_stmt_iterator
4263 gsi_start_bb (basic_block bb)
4265 gimple_stmt_iterator i;
4266 gimple_seq seq;
4268 seq = bb_seq (bb);
4269 i.ptr = gimple_seq_first (seq);
4270 i.seq = seq;
4271 i.bb = bb;
4273 return i;
4277 /* Return a new iterator initially pointing to GIMPLE_SEQ's last statement. */
4279 static inline gimple_stmt_iterator
4280 gsi_last (gimple_seq seq)
4282 gimple_stmt_iterator i;
4284 i.ptr = gimple_seq_last (seq);
4285 i.seq = seq;
4286 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4288 return i;
4292 /* Return a new iterator pointing to the last statement in basic block BB. */
4294 static inline gimple_stmt_iterator
4295 gsi_last_bb (basic_block bb)
4297 gimple_stmt_iterator i;
4298 gimple_seq seq;
4300 seq = bb_seq (bb);
4301 i.ptr = gimple_seq_last (seq);
4302 i.seq = seq;
4303 i.bb = bb;
4305 return i;
4309 /* Return true if I is at the end of its sequence. */
4311 static inline bool
4312 gsi_end_p (gimple_stmt_iterator i)
4314 return i.ptr == NULL;
4318 /* Return true if I is one statement before the end of its sequence. */
4320 static inline bool
4321 gsi_one_before_end_p (gimple_stmt_iterator i)
4323 return i.ptr != NULL && i.ptr->next == NULL;
4327 /* Advance the iterator to the next gimple statement. */
4329 static inline void
4330 gsi_next (gimple_stmt_iterator *i)
4332 i->ptr = i->ptr->next;
4335 /* Advance the iterator to the previous gimple statement. */
4337 static inline void
4338 gsi_prev (gimple_stmt_iterator *i)
4340 i->ptr = i->ptr->prev;
4343 /* Return the current stmt. */
4345 static inline gimple
4346 gsi_stmt (gimple_stmt_iterator i)
4348 return i.ptr->stmt;
4351 /* Return a block statement iterator that points to the first non-label
4352 statement in block BB. */
4354 static inline gimple_stmt_iterator
4355 gsi_after_labels (basic_block bb)
4357 gimple_stmt_iterator gsi = gsi_start_bb (bb);
4359 while (!gsi_end_p (gsi) && gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL)
4360 gsi_next (&gsi);
4362 return gsi;
4365 /* Return a pointer to the current stmt.
4367 NOTE: You may want to use gsi_replace on the iterator itself,
4368 as this performs additional bookkeeping that will not be done
4369 if you simply assign through a pointer returned by gsi_stmt_ptr. */
4371 static inline gimple *
4372 gsi_stmt_ptr (gimple_stmt_iterator *i)
4374 return &i->ptr->stmt;
4378 /* Return the basic block associated with this iterator. */
4380 static inline basic_block
4381 gsi_bb (gimple_stmt_iterator i)
4383 return i.bb;
4387 /* Return the sequence associated with this iterator. */
4389 static inline gimple_seq
4390 gsi_seq (gimple_stmt_iterator i)
4392 return i.seq;
4396 enum gsi_iterator_update
4398 GSI_NEW_STMT, /* Only valid when single statement is added, move
4399 iterator to it. */
4400 GSI_SAME_STMT, /* Leave the iterator at the same statement. */
4401 GSI_CONTINUE_LINKING /* Move iterator to whatever position is suitable
4402 for linking other statements in the same
4403 direction. */
4406 /* In gimple-iterator.c */
4407 gimple_stmt_iterator gsi_start_phis (basic_block);
4408 gimple_seq gsi_split_seq_after (gimple_stmt_iterator);
4409 gimple_seq gsi_split_seq_before (gimple_stmt_iterator *);
4410 void gsi_replace (gimple_stmt_iterator *, gimple, bool);
4411 void gsi_insert_before (gimple_stmt_iterator *, gimple,
4412 enum gsi_iterator_update);
4413 void gsi_insert_before_without_update (gimple_stmt_iterator *, gimple,
4414 enum gsi_iterator_update);
4415 void gsi_insert_seq_before (gimple_stmt_iterator *, gimple_seq,
4416 enum gsi_iterator_update);
4417 void gsi_insert_seq_before_without_update (gimple_stmt_iterator *, gimple_seq,
4418 enum gsi_iterator_update);
4419 void gsi_insert_after (gimple_stmt_iterator *, gimple,
4420 enum gsi_iterator_update);
4421 void gsi_insert_after_without_update (gimple_stmt_iterator *, gimple,
4422 enum gsi_iterator_update);
4423 void gsi_insert_seq_after (gimple_stmt_iterator *, gimple_seq,
4424 enum gsi_iterator_update);
4425 void gsi_insert_seq_after_without_update (gimple_stmt_iterator *, gimple_seq,
4426 enum gsi_iterator_update);
4427 void gsi_remove (gimple_stmt_iterator *, bool);
4428 gimple_stmt_iterator gsi_for_stmt (gimple);
4429 void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *);
4430 void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *);
4431 void gsi_move_to_bb_end (gimple_stmt_iterator *, struct basic_block_def *);
4432 void gsi_insert_on_edge (edge, gimple);
4433 void gsi_insert_seq_on_edge (edge, gimple_seq);
4434 basic_block gsi_insert_on_edge_immediate (edge, gimple);
4435 basic_block gsi_insert_seq_on_edge_immediate (edge, gimple_seq);
4436 void gsi_commit_one_edge_insert (edge, basic_block *);
4437 void gsi_commit_edge_inserts (void);
4438 gimple gimple_call_copy_skip_args (gimple, bitmap);
4441 /* Convenience routines to walk all statements of a gimple function.
4442 Note that this is useful exclusively before the code is converted
4443 into SSA form. Once the program is in SSA form, the standard
4444 operand interface should be used to analyze/modify statements. */
4445 struct walk_stmt_info
4447 /* Points to the current statement being walked. */
4448 gimple_stmt_iterator gsi;
4450 /* Additional data that the callback functions may want to carry
4451 through the recursion. */
4452 void *info;
4454 /* Pointer map used to mark visited tree nodes when calling
4455 walk_tree on each operand. If set to NULL, duplicate tree nodes
4456 will be visited more than once. */
4457 struct pointer_set_t *pset;
4459 /* Indicates whether the operand being examined may be replaced
4460 with something that matches is_gimple_val (if true) or something
4461 slightly more complicated (if false). "Something" technically
4462 means the common subset of is_gimple_lvalue and is_gimple_rhs,
4463 but we never try to form anything more complicated than that, so
4464 we don't bother checking.
4466 Also note that CALLBACK should update this flag while walking the
4467 sub-expressions of a statement. For instance, when walking the
4468 statement 'foo (&var)', the flag VAL_ONLY will initially be set
4469 to true, however, when walking &var, the operand of that
4470 ADDR_EXPR does not need to be a GIMPLE value. */
4471 bool val_only;
4473 /* True if we are currently walking the LHS of an assignment. */
4474 bool is_lhs;
4476 /* Optional. Set to true by the callback functions if they made any
4477 changes. */
4478 bool changed;
4480 /* True if we're interested in location information. */
4481 bool want_locations;
4483 /* Operand returned by the callbacks. This is set when calling
4484 walk_gimple_seq. If the walk_stmt_fn or walk_tree_fn callback
4485 returns non-NULL, this field will contain the tree returned by
4486 the last callback. */
4487 tree callback_result;
4490 /* Callback for walk_gimple_stmt. Called for every statement found
4491 during traversal. The first argument points to the statement to
4492 walk. The second argument is a flag that the callback sets to
4493 'true' if it the callback handled all the operands and
4494 sub-statements of the statement (the default value of this flag is
4495 'false'). The third argument is an anonymous pointer to data
4496 to be used by the callback. */
4497 typedef tree (*walk_stmt_fn) (gimple_stmt_iterator *, bool *,
4498 struct walk_stmt_info *);
4500 gimple walk_gimple_seq (gimple_seq, walk_stmt_fn, walk_tree_fn,
4501 struct walk_stmt_info *);
4502 tree walk_gimple_stmt (gimple_stmt_iterator *, walk_stmt_fn, walk_tree_fn,
4503 struct walk_stmt_info *);
4504 tree walk_gimple_op (gimple, walk_tree_fn, struct walk_stmt_info *);
4506 #ifdef GATHER_STATISTICS
4507 /* Enum and arrays used for allocation stats. Keep in sync with
4508 gimple.c:gimple_alloc_kind_names. */
4509 enum gimple_alloc_kind
4511 gimple_alloc_kind_assign, /* Assignments. */
4512 gimple_alloc_kind_phi, /* PHI nodes. */
4513 gimple_alloc_kind_cond, /* Conditionals. */
4514 gimple_alloc_kind_seq, /* Sequences. */
4515 gimple_alloc_kind_rest, /* Everything else. */
4516 gimple_alloc_kind_all
4519 extern int gimple_alloc_counts[];
4520 extern int gimple_alloc_sizes[];
4522 /* Return the allocation kind for a given stmt CODE. */
4523 static inline enum gimple_alloc_kind
4524 gimple_alloc_kind (enum gimple_code code)
4526 switch (code)
4528 case GIMPLE_ASSIGN:
4529 return gimple_alloc_kind_assign;
4530 case GIMPLE_PHI:
4531 return gimple_alloc_kind_phi;
4532 case GIMPLE_COND:
4533 return gimple_alloc_kind_cond;
4534 default:
4535 return gimple_alloc_kind_rest;
4538 #endif /* GATHER_STATISTICS */
4540 extern void dump_gimple_statistics (void);
4542 #endif /* GCC_GIMPLE_H */