2008-04-17 Doug Kwan <dougkwan@google.com>
[official-gcc.git] / gcc / gimple.h
blobafea6161a68359a6b11089ebd640b4c3532f342c
1 /* Gimple IR definitions.
3 Copyright 2007 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 2, 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 COPYING. If not, write to the Free
20 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
21 02110-1301, USA. */
23 #ifndef GCC_GIMPLE_H
24 #define GCC_GIMPLE_H
26 #include "pointer-set.h"
27 #include "vec.h"
28 #include "ggc.h"
29 #include "tm.h"
30 #include "hard-reg-set.h"
31 #include "basic-block.h"
32 #include "tree-ssa-operands.h"
34 DEF_VEC_P(gimple);
35 DEF_VEC_ALLOC_P(gimple,heap);
36 DEF_VEC_ALLOC_P(gimple,gc);
38 DEF_VEC_P(gimple_seq);
39 DEF_VEC_ALLOC_P(gimple_seq,gc);
40 DEF_VEC_ALLOC_P(gimple_seq,heap);
42 enum gimple_code {
43 #define DEFGSCODE(SYM, STRING) SYM,
44 #include "gimple.def"
45 #undef DEFGSCODE
46 LAST_AND_UNUSED_GIMPLE_CODE
49 /* Error out if a gimple tuple is addressed incorrectly. */
50 #if defined ENABLE_GIMPLE_CHECKING
51 extern void gimple_check_failed (const_gimple, const char *, int, \
52 const char *, enum gimple_code, \
53 enum tree_code) ATTRIBUTE_NORETURN;
54 extern void gimple_range_check_failed (const_gimple, const char *, int, \
55 const char *, enum gimple_code, \
56 enum gimple_code) ATTRIBUTE_NORETURN;
58 #define GIMPLE_CHECK(GS, CODE) \
59 do { \
60 const_gimple __gs = (GS); \
61 if (gimple_code (__gs) != (CODE)) \
62 gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__, \
63 (CODE), 0); \
64 } while (0)
65 #else /* not ENABLE_GIMPLE_CHECKING */
66 #define GIMPLE_CHECK(GS, CODE) (void)0
67 #endif
69 /* Specific flags for individual GIMPLE statements. These flags are
70 always stored in gimple_statement_base.subcode and they may only be
71 defined for statement codes that do not use sub-codes.
73 Values for the masks can overlap as long as the overlapping values
74 are never used in the same statement class.
76 The maximum mask value that can be defined is 1 << 7 (i.e., each
77 statement code can hold up to 8 bitflags).
79 Keep this list sorted. */
80 static const unsigned int GF_ASM_INPUT = 1 << 0;
81 static const unsigned int GF_ASM_VOLATILE = 1 << 1;
82 static const unsigned int GF_CALL_CANNOT_INLINE = 1 << 0;
83 static const unsigned int GF_CALL_FROM_THUNK = 1 << 1;
84 static const unsigned int GF_CALL_RETURN_SLOT_OPT = 1 << 2;
85 static const unsigned int GF_CALL_TAILCALL = 1 << 3;
86 static const unsigned int GF_CALL_VA_ARG_PACK = 1 << 4;
87 static const unsigned int GF_OMP_PARALLEL_COMBINED = 1 << 0;
89 /* True on an GIMPLE_OMP_RETURN statement if the return does not require a
90 thread synchronization via some sort of barrier. The exact barrier that
91 would otherwise be emitted is dependent on the OMP statement with which this
92 return is associated. */
93 static const unsigned int GF_OMP_RETURN_NOWAIT = 1 << 0;
95 static const unsigned int GF_OMP_SECTION_LAST = 1 << 0;
97 /* Masks for selecting a pass local flag (PLF) to work on. These
98 masks are used by gimple_set_plf and gimple_plf. */
99 enum plf_mask {
100 GF_PLF_1 = 1 << 0,
101 GF_PLF_2 = 1 << 1
104 /* A node in a gimple_seq_d. */
105 struct gimple_seq_node_d GTY((chain_next ("%h.next"), chain_prev ("%h.prev")))
107 gimple stmt;
108 struct gimple_seq_node_d *prev;
109 struct gimple_seq_node_d *next;
112 /* A double-linked sequence of gimple statements. */
113 struct gimple_seq_d GTY ((chain_next ("%h.next_free")))
115 /* First and last statements in the sequence. */
116 gimple_seq_node first;
117 gimple_seq_node last;
119 /* Sequences are created/destroyed frequently. To minimize
120 allocation activity, deallocated sequences are kept in a pool of
121 available sequences. This is the pointer to the next free
122 sequence in the pool. */
123 gimple_seq next_free;
127 /* Return the first node in GIMPLE sequence S. */
129 static inline gimple_seq_node
130 gimple_seq_first (const_gimple_seq s)
132 return s ? s->first : NULL;
136 /* Return the first statement in GIMPLE sequence S. */
138 static inline gimple
139 gimple_seq_first_stmt (const_gimple_seq s)
141 gimple_seq_node n = gimple_seq_first (s);
142 return (n) ? n->stmt : NULL;
146 /* Return the last node in GIMPLE sequence S. */
148 static inline gimple_seq_node
149 gimple_seq_last (const_gimple_seq s)
151 return s ? s->last : NULL;
155 /* Return the last statement in GIMPLE sequence S. */
157 static inline gimple
158 gimple_seq_last_stmt (const_gimple_seq s)
160 gimple_seq_node n = gimple_seq_last (s);
161 return (n) ? n->stmt : NULL;
165 /* Set the last node in GIMPLE sequence S to LAST. */
167 static inline void
168 gimple_seq_set_last (gimple_seq s, gimple_seq_node last)
170 s->last = last;
174 /* Set the first node in GIMPLE sequence S to FIRST. */
176 static inline void
177 gimple_seq_set_first (gimple_seq s, gimple_seq_node first)
179 s->first = first;
183 /* Return true if GIMPLE sequence S is empty. */
185 static inline bool
186 gimple_seq_empty_p (const_gimple_seq s)
188 return s == NULL || s->first == NULL;
192 void gimple_seq_add_stmt (gimple_seq *, gimple);
194 /* Allocate a new sequence and initialize its first element with STMT. */
196 static inline gimple_seq
197 gimple_seq_alloc_with_stmt (gimple stmt)
199 gimple_seq seq = NULL;
200 gimple_seq_add_stmt (&seq, stmt);
201 return seq;
205 /* Returns the sequence of statements in BB. */
207 static inline gimple_seq
208 bb_seq (const_basic_block bb)
210 return (!(bb->flags & BB_RTL) && bb->il.gimple) ? bb->il.gimple->seq : NULL;
214 /* Sets the sequence of statements in BB to SEQ. */
216 static inline void
217 set_bb_seq (basic_block bb, gimple_seq seq)
219 gcc_assert (!(bb->flags & BB_RTL));
220 bb->il.gimple->seq = seq;
223 /* Iterator object for GIMPLE statement sequences. */
225 typedef struct
227 /* Sequence node holding the current statement. */
228 gimple_seq_node ptr;
230 /* Sequence and basic block holding the statement. These fields
231 are necessary to handle edge cases such as when statement is
232 added to an empty basic block or when the last statement of a
233 block/sequence is removed. */
234 gimple_seq seq;
235 basic_block bb;
236 } gimple_stmt_iterator;
239 /* Data structure definitions for GIMPLE tuples. */
241 struct gimple_statement_base GTY(())
243 ENUM_BITFIELD(gimple_code) code : 16;
244 unsigned int subcode : 8;
246 /* NOTE for future expansion. It would be possible to have 32
247 additional bit flags. This would avoid wasting the 32bit hole
248 left in this structure on 64bit hosts, but it would make this
249 structure grow an additional word on 32bit hosts. */
250 unsigned int no_warning : 1;
251 unsigned int visited : 1;
252 unsigned int nontemporal_move : 1;
253 unsigned int unused_1 : 1;
254 unsigned int unused_2 : 1;
255 unsigned int unused_3 : 1;
257 /* Pass local flags. These flags are free for any pass to use as
258 they see fit. Passes should not assume that these flags contain
259 any useful value when the pass starts. Any initial state that
260 the pass requires should be set on entry to the pass. See
261 gimple_set_plf and gimple_plf for usage. */
262 unsigned int plf : 2;
264 /* Basic block holding this statement. */
265 struct basic_block_def *bb;
267 /* Locus information for debug info. */
268 location_t location;
270 /* Lexical block holding this statement. FIXME, needed? */
271 tree block;
273 /* Uid of this statement. */
274 unsigned uid;
278 /* Statements that take register operands. */
280 struct gimple_statement_with_ops GTY(())
282 struct gimple_statement_base gsbase;
283 unsigned modified : 1;
284 bitmap GTY((skip (""))) addresses_taken;
286 /* FIXME tuples. OP should be amalgamated with DEF_OPS and USE_OPS.
287 This duplication is unnecessary. */
288 struct def_optype_d GTY((skip (""))) *def_ops;
289 struct use_optype_d GTY((skip (""))) *use_ops;
291 /* FIXME tuples. For many tuples, the number of operands can
292 be deduced from the code. */
293 size_t num_ops;
294 tree * GTY((length ("%h.num_ops"))) op;
298 /* Statements that take both memory and register operands. */
300 struct gimple_statement_with_memory_ops GTY(())
302 struct gimple_statement_with_ops with_ops;
303 unsigned has_volatile_ops : 1;
304 unsigned references_memory_p : 1;
305 struct voptype_d GTY((skip (""))) *vdef_ops;
306 struct voptype_d GTY((skip (""))) *vuse_ops;
307 bitmap GTY((skip (""))) stores;
308 bitmap GTY((skip (""))) loads;
312 /* OpenMP statements (#pragma omp). */
314 struct gimple_statement_omp GTY(())
316 struct gimple_statement_base gsbase;
317 gimple_seq body;
321 /* GIMPLE_BIND */
323 struct gimple_statement_bind GTY(())
325 struct gimple_statement_base gsbase;
326 tree vars;
328 /* This is different than the ``block'' in gimple_statement_base, which
329 is analogous to TREE_BLOCK. This block is the equivalent of
330 BIND_EXPR_BLOCK in tree land. See gimple-low.c. */
331 tree block;
332 gimple_seq body;
336 /* GIMPLE_CATCH */
338 struct gimple_statement_catch GTY(())
340 struct gimple_statement_base gsbase;
341 tree types;
342 gimple_seq handler;
346 /* GIMPLE_EH_FILTER */
348 struct gimple_statement_eh_filter GTY(())
350 struct gimple_statement_base gsbase;
352 /* Subcode: EH_FILTER_MUST_NOT_THROW. A boolean flag analogous to
353 the tree counterpart. */
355 /* Filter types. */
356 tree types;
358 /* Failure actions. */
359 gimple_seq failure;
363 /* GIMPLE_PHI */
365 struct gimple_statement_phi GTY(())
367 struct gimple_statement_base gsbase;
368 size_t capacity;
369 size_t nargs;
370 tree result;
371 struct phi_arg_d GTY ((length ("%h.nargs"))) args[1];
375 /* GIMPLE_RESX */
377 struct gimple_statement_resx GTY(())
379 struct gimple_statement_base gsbase;
381 /* Exception region number. */
382 int region;
386 /* GIMPLE_TRY */
388 struct gimple_statement_try GTY(())
390 struct gimple_statement_base gsbase;
392 /* Expression to evaluate. */
393 gimple_seq eval;
395 /* Cleanup expression. */
396 gimple_seq cleanup;
399 /* Kind of GIMPLE_TRY statements. */
400 enum gimple_try_flags {
401 GIMPLE_TRY_CATCH = 1 << 0, /* A try/catch. */
402 GIMPLE_TRY_FINALLY = 1 << 1, /* A try/finally. */
403 GIMPLE_TRY_KIND = GIMPLE_TRY_CATCH | GIMPLE_TRY_FINALLY,
405 /* Analogous to TRY_CATCH_IS_CLEANUP. */
406 GIMPLE_TRY_CATCH_IS_CLEANUP = 1 << 2
409 /* GIMPLE_WITH_CLEANUP_EXPR */
411 struct gimple_statement_wce GTY(())
413 struct gimple_statement_base gsbase;
415 /* Subcode: CLEANUP_EH_ONLY. True if the cleanup should only be
416 executed if an exception is thrown, not on normal exit of its
417 scope. This flag is analogous to the CLEANUP_EH_ONLY flag
418 in TARGET_EXPRs. */
420 /* Cleanup expression. */
421 gimple_seq cleanup;
425 /* GIMPLE_ASM */
427 struct gimple_statement_asm GTY(())
429 struct gimple_statement_with_memory_ops with_mem_ops;
430 const char *string; /* __asm__ statement. */
431 size_t ni; /* Number of inputs. */
432 size_t no; /* Number of outputs. */
433 size_t nc; /* Number of clobbers. */
436 /* GIMPLE_OMP_CRITICAL */
438 struct gimple_statement_omp_critical GTY(())
440 struct gimple_statement_omp omp;
442 /* Critical section name. */
443 tree name;
447 /* GIMPLE_OMP_FOR */
449 struct gimple_statement_omp_for GTY(())
451 struct gimple_statement_omp omp;
452 tree clauses;
454 /* Index variable. */
455 tree index;
457 /* Initial value. */
458 tree initial;
460 /* Final value. */
461 tree final;
463 /* Increment. */
464 tree incr;
466 /* Pre-body evaluated before the loop body begins. */
467 gimple_seq pre_body;
471 /* GIMPLE_OMP_PARALLEL */
473 struct gimple_statement_omp_parallel GTY(())
475 struct gimple_statement_omp omp;
477 /* Clauses. */
478 tree clauses;
480 /* Child function holding the body of the parallel region. */
481 tree child_fn;
483 /* Shared data argument. */
484 tree data_arg;
487 /* GIMPLE_OMP_SECTION */
488 /* Uses struct gimple_statement_omp. */
491 /* GIMPLE_OMP_SECTIONS */
493 struct gimple_statement_omp_sections GTY(())
495 struct gimple_statement_omp omp;
497 tree clauses;
499 /* The control variable used for deciding which of the sections to
500 execute. */
501 tree control;
504 /* GIMPLE_OMP_CONTINUE.
506 Note: This does not inherit from gimple_statement_omp, because we
507 do not need the body field. */
509 struct gimple_statement_omp_continue GTY(())
511 struct gimple_statement_base gsbase;
512 tree control_def;
513 tree control_use;
516 /* GIMPLE_OMP_SINGLE */
518 struct gimple_statement_omp_single GTY(())
520 struct gimple_statement_omp omp;
521 tree clauses;
525 /* GIMPLE_CHANGE_DYNAMIC_TYPE */
527 struct gimple_statement_change_dynamic_type GTY(())
529 struct gimple_statement_with_ops with_ops;
530 tree type;
533 /* GIMPLE_OMP_ATOMIC_LOAD.
534 Note: This is based on gimple_statement_base, not g_s_omp, because g_s_omp
535 contains a sequence, which we don't need here. */
537 struct gimple_statement_omp_atomic_load GTY(())
539 struct gimple_statement_base gsbase;
540 tree rhs, lhs;
543 /* GIMPLE_OMP_ATOMIC_STORE.
544 See note on GIMPLE_OMP_ATOMIC_LOAD. */
546 struct gimple_statement_omp_atomic_store GTY(())
548 struct gimple_statement_base gsbase;
549 tree val;
552 enum gimple_statement_structure_enum {
553 #define DEFGSSTRUCT(SYM, STRING) SYM,
554 #include "gsstruct.def"
555 #undef DEFGSSTRUCT
556 LAST_GSS_ENUM
560 /* Define the overall contents of a gimple tuple. It may be any of the
561 structures declared above for various types of tuples. */
563 union gimple_statement_d GTY ((desc ("gimple_statement_structure (&%h)")))
565 struct gimple_statement_base GTY ((tag ("GSS_BASE"))) gsbase;
566 struct gimple_statement_with_ops GTY ((tag ("GSS_WITH_OPS"))) with_ops;
567 struct gimple_statement_with_memory_ops GTY ((tag ("GSS_WITH_MEM_OPS"))) with_mem_ops;
568 struct gimple_statement_omp GTY ((tag ("GSS_OMP"))) omp;
569 struct gimple_statement_bind GTY ((tag ("GSS_BIND"))) gimple_bind;
570 struct gimple_statement_catch GTY ((tag ("GSS_CATCH"))) gimple_catch;
571 struct gimple_statement_eh_filter GTY ((tag ("GSS_EH_FILTER"))) gimple_eh_filter;
572 struct gimple_statement_phi GTY ((tag ("GSS_PHI"))) gimple_phi;
573 struct gimple_statement_resx GTY ((tag ("GSS_RESX"))) gimple_resx;
574 struct gimple_statement_try GTY ((tag ("GSS_TRY"))) gimple_try;
575 struct gimple_statement_wce GTY ((tag ("GSS_WCE"))) gimple_wce;
576 struct gimple_statement_asm GTY ((tag ("GSS_ASM"))) gimple_asm;
577 struct gimple_statement_omp_critical GTY ((tag ("GSS_OMP_CRITICAL"))) gimple_omp_critical;
578 struct gimple_statement_omp_for GTY ((tag ("GSS_OMP_FOR"))) gimple_omp_for;
579 struct gimple_statement_omp_parallel GTY ((tag ("GSS_OMP_PARALLEL"))) gimple_omp_parallel;
580 struct gimple_statement_omp_sections GTY ((tag ("GSS_OMP_SECTIONS"))) gimple_omp_sections;
581 struct gimple_statement_omp_single GTY ((tag ("GSS_OMP_SINGLE"))) gimple_omp_single;
582 struct gimple_statement_omp_continue GTY ((tag ("GSS_OMP_CONTINUE"))) gimple_omp_continue;
583 struct gimple_statement_change_dynamic_type GTY ((tag ("GSS_CHANGE_DYNAMIC_TYPE"))) gimple_change_dynamic_type;
584 struct gimple_statement_omp_atomic_load GTY ((tag ("GSS_OMP_ATOMIC_LOAD"))) gimple_omp_atomic_load;
585 struct gimple_statement_omp_atomic_store GTY ((tag ("GSS_OMP_ATOMIC_STORE"))) gimple_omp_atomic_store;
588 /* In gimple.c. */
589 gimple gimple_build_return (tree);
590 gimple gimple_build_assign (tree, tree);
591 void extract_ops_from_tree (tree, enum tree_code *, tree *, tree *);
592 gimple gimple_build_assign_with_ops (enum tree_code, tree, tree, tree);
593 gimple gimple_build_call_vec (tree, VEC(tree, heap) *);
594 gimple gimple_build_call (tree, size_t, ...);
595 gimple gimple_build_call_from_tree (tree);
596 gimple gimple_build_cond (enum tree_code, tree, tree, tree, tree);
597 gimple gimple_build_label (tree label);
598 gimple gimple_build_goto (tree dest);
599 gimple gimple_build_nop (void);
600 gimple gimple_build_bind (tree, gimple_seq, tree);
601 gimple gimple_build_asm (const char *, size_t, size_t, size_t, ...);
602 gimple gimple_build_asm_vec (const char *, VEC(tree,gc) *, VEC(tree,gc) *,
603 VEC(tree,gc) *);
604 gimple gimple_build_catch (tree, gimple_seq);
605 gimple gimple_build_eh_filter (tree, gimple_seq);
606 gimple gimple_build_try (gimple_seq, gimple_seq, unsigned int);
607 gimple gimple_build_wce (gimple_seq);
608 gimple gimple_build_resx (int);
609 gimple gimple_build_switch (size_t, tree, tree, ...);
610 gimple gimple_build_switch_vec (tree, tree, VEC(tree,heap) *);
611 gimple gimple_build_omp_parallel (gimple_seq, tree, tree, tree);
612 gimple gimple_build_omp_for (gimple_seq, tree, tree, tree, tree, tree,
613 gimple_seq, enum tree_code);
614 gimple gimple_build_omp_critical (gimple_seq, tree);
615 gimple gimple_build_omp_section (gimple_seq);
616 gimple gimple_build_omp_continue (tree, tree);
617 gimple gimple_build_omp_master (gimple_seq);
618 gimple gimple_build_omp_return (bool);
619 gimple gimple_build_omp_ordered (gimple_seq);
620 gimple gimple_build_omp_sections (gimple_seq, tree);
621 gimple gimple_build_omp_single (gimple_seq, tree);
622 gimple gimple_build_cdt (tree, tree);
623 gimple gimple_build_omp_atomic_load (tree, tree);
624 gimple gimple_build_omp_atomic_store (tree);
625 enum gimple_statement_structure_enum gimple_statement_structure (gimple);
626 enum gimple_statement_structure_enum gss_for_assign (enum tree_code);
627 void sort_case_labels (VEC(tree,heap) *);
628 void gimple_set_body (tree, gimple_seq);
629 gimple_seq gimple_body (tree);
630 gimple_seq gimple_seq_alloc (void);
631 void gimple_seq_free (gimple_seq);
632 void gimple_seq_add_seq (gimple_seq *, gimple_seq);
633 gimple_seq gimple_seq_copy (gimple_seq);
634 int gimple_call_flags (const_gimple);
635 bool gimple_assign_copy_p (gimple);
636 bool gimple_assign_single_p (gimple);
637 bool gimple_assign_unary_nop_p (gimple);
638 void gimple_set_bb (gimple, struct basic_block_def *);
639 tree gimple_fold (const_gimple);
640 void gimple_assign_set_rhs_from_tree (gimple, tree);
641 void gimple_assign_set_rhs_with_ops (gimple, enum tree_code, tree, tree);
642 tree gimple_get_lhs (gimple);
643 void gimple_set_lhs (gimple, tree);
644 gimple gimple_copy (gimple);
645 gimple gimple_copy_no_def_use (gimple);
646 bool is_gimple_operand (const_tree);
647 void gimple_set_modified (gimple, bool);
648 void gimple_cond_get_ops_from_tree (tree, enum tree_code *, tree *, tree *);
649 gimple gimple_build_cond_from_tree (tree, tree, tree);
650 void gimple_cond_set_condition_from_tree (gimple, tree);
651 bool gimple_has_side_effects (const_gimple);
652 bool gimple_rhs_has_side_effects (const_gimple);
653 bool gimple_could_trap_p (gimple);
654 void gimple_regimplify_operands (gimple, gimple_stmt_iterator *);
655 bool empty_body_p (gimple_seq);
657 /* FIXME tuples.
658 Break a circular include dependency with tree-gimple.h.
659 We need to use some of the operand predicates declared there
660 for validating arguments in inline functions defined here.
661 We should merge gimple.[hc] and tree-gimple.[hc]. */
662 extern bool is_gimple_val (tree);
664 /* In builtins.c */
665 extern bool validate_gimple_arglist (const_gimple, ...);
667 /* In tree-ssa-operands.c */
668 extern void gimple_add_to_addresses_taken (gimple, tree);
670 /* Return the code for GIMPLE statement G. */
672 static inline enum gimple_code
673 gimple_code (const_gimple g)
675 return g->gsbase.code;
679 /* Set SUBCODE to be the code of the expression computed by statement G. */
681 static inline void
682 gimple_set_subcode (gimple g, enum tree_code subcode)
684 /* We only have 8 bits for the RHS code. Assert that we are not
685 overflowing it. */
686 gcc_assert (subcode < (1 << 8));
687 g->gsbase.subcode = subcode;
691 /* Return the code of the expression computed by statement G. */
693 static inline unsigned
694 gimple_subcode (const_gimple g)
696 return g->gsbase.subcode;
700 /* Return true if statement G has sub-statements. This is only true for
701 High GIMPLE statements. */
703 static inline bool
704 gimple_has_substatements (gimple g)
706 switch (gimple_code (g))
708 case GIMPLE_BIND:
709 case GIMPLE_CATCH:
710 case GIMPLE_EH_FILTER:
711 case GIMPLE_TRY:
712 case GIMPLE_OMP_FOR:
713 case GIMPLE_OMP_MASTER:
714 case GIMPLE_OMP_ORDERED:
715 case GIMPLE_OMP_SECTION:
716 case GIMPLE_OMP_PARALLEL:
717 case GIMPLE_OMP_SECTIONS:
718 case GIMPLE_OMP_SINGLE:
719 case GIMPLE_WITH_CLEANUP_EXPR:
720 return true;
722 default:
723 return false;
728 /* Return the basic block holding statement G. */
730 static inline struct basic_block_def *
731 gimple_bb (const_gimple g)
733 return g->gsbase.bb;
737 /* Return the lexical scope block holding statement G. */
739 static inline tree
740 gimple_block (const_gimple g)
742 return g->gsbase.block;
746 /* Set BLOCK to be the lexical scope block holding statement G. */
748 static inline void
749 gimple_set_block (gimple g, tree block)
751 g->gsbase.block = block;
755 /* Return location information for statement G. */
757 static inline location_t
758 gimple_location (const_gimple g)
760 return g->gsbase.location;
764 /* Set location information for statement G. */
766 static inline void
767 gimple_set_location (gimple g, location_t location)
769 g->gsbase.location = location;
773 /* Return true if G contains location information. */
775 static inline bool
776 gimple_has_location (const_gimple g)
778 return gimple_location (g) != UNKNOWN_LOCATION;
782 /* Return the file name of the location of STMT. */
784 static inline const char *
785 gimple_filename (const_gimple stmt)
787 return LOCATION_FILE (gimple_location (stmt));
791 /* Return the line number of the location of STMT. */
793 static inline int
794 gimple_lineno (const_gimple stmt)
796 return LOCATION_LINE (gimple_location (stmt));
800 /* Determine whether SEQ is a singleton. */
802 static inline bool
803 gimple_seq_singleton_p (gimple_seq seq)
805 return ((gimple_seq_first (seq) != NULL)
806 && (gimple_seq_first (seq) == gimple_seq_last (seq)));
809 /* Return true if no warnings should be emitted for statement STMT. */
811 static inline bool
812 gimple_no_warning_p (const_gimple stmt)
814 return stmt->gsbase.no_warning;
817 /* Set the no_warning flag of STMT to NO_WARNING. */
819 static inline void
820 gimple_set_no_warning (gimple stmt, bool no_warning)
822 stmt->gsbase.no_warning = (unsigned) no_warning;
825 /* Set the visited status on statement STMT to VISITED_P. */
827 static inline void
828 gimple_set_visited (gimple stmt, bool visited_p)
830 stmt->gsbase.visited = (unsigned) visited_p;
834 /* Return the visited status for statement STMT. */
836 static inline bool
837 gimple_visited_p (gimple stmt)
839 return stmt->gsbase.visited;
843 /* Set pass local flag PLF on statement STMT to VAL_P. */
845 static inline void
846 gimple_set_plf (gimple stmt, enum plf_mask plf, bool val_p)
848 if (val_p)
849 stmt->gsbase.plf |= (unsigned int) plf;
850 else
851 stmt->gsbase.plf &= ~((unsigned int) plf);
855 /* Return the value of pass local flag PLF on statement STMT. */
857 static inline unsigned int
858 gimple_plf (gimple stmt, enum plf_mask plf)
860 return stmt->gsbase.plf & ((unsigned int) plf);
864 /* Set the uid of statement */
866 static inline void
867 gimple_set_uid (gimple g, unsigned uid)
869 g->gsbase.uid = uid;
873 /* Return the uid of statement */
875 static inline unsigned
876 gimple_uid (const_gimple g)
878 return g->gsbase.uid;
882 /* Return true if GIMPLE statement G has register or memory operands. */
884 static inline bool
885 gimple_has_ops (const_gimple g)
887 return gimple_code (g) >= GIMPLE_COND && gimple_code (g) <= GIMPLE_RETURN;
891 /* Return true if GIMPLE statement G has memory operands. */
893 static inline bool
894 gimple_has_mem_ops (const_gimple g)
896 return gimple_code (g) >= GIMPLE_ASSIGN && gimple_code (g) <= GIMPLE_RETURN;
900 /* Return the set of DEF operands for statement G. */
902 static inline struct def_optype_d *
903 gimple_def_ops (const_gimple g)
905 if (!gimple_has_ops (g))
906 return NULL;
907 return g->with_ops.def_ops;
911 /* Set DEF to be the set of DEF operands for statement G. */
913 static inline void
914 gimple_set_def_ops (gimple g, struct def_optype_d *def)
916 gcc_assert (gimple_has_ops (g));
917 g->with_ops.def_ops = def;
921 /* Return the set of USE operands for statement G. */
923 static inline struct use_optype_d *
924 gimple_use_ops (const_gimple g)
926 if (!gimple_has_ops (g))
927 return NULL;
928 return g->with_ops.use_ops;
932 /* Set USE to be the set of USE operands for statement G. */
934 static inline void
935 gimple_set_use_ops (gimple g, struct use_optype_d *use)
937 gcc_assert (gimple_has_ops (g));
938 g->with_ops.use_ops = use;
942 /* Return the set of VUSE operands for statement G. */
944 static inline struct voptype_d *
945 gimple_vuse_ops (const_gimple g)
947 if (!gimple_has_mem_ops (g))
948 return NULL;
949 return g->with_mem_ops.vuse_ops;
953 /* Set OPS to be the set of VUSE operands for statement G. */
955 static inline void
956 gimple_set_vuse_ops (gimple g, struct voptype_d *ops)
958 gcc_assert (gimple_has_mem_ops (g));
959 g->with_mem_ops.vuse_ops = ops;
963 /* Return the set of VDEF operands for statement G. */
965 static inline struct voptype_d *
966 gimple_vdef_ops (const_gimple g)
968 if (!gimple_has_mem_ops (g))
969 return NULL;
970 return g->with_mem_ops.vdef_ops;
974 /* Set OPS to be the set of VDEF operands for statement G. */
976 static inline void
977 gimple_set_vdef_ops (gimple g, struct voptype_d *ops)
979 gcc_assert (gimple_has_mem_ops (g));
980 g->with_mem_ops.vdef_ops = ops;
984 /* Return the set of symbols loaded by statement G. Each element of the
985 set is the DECL_UID of the corresponding symbol. */
987 static inline bitmap
988 gimple_loaded_syms (const_gimple g)
990 if (!gimple_has_mem_ops (g))
991 return NULL;
992 return g->with_mem_ops.loads;
996 /* Return the set of symbols stored by statement G. Each element of
997 the set is the DECL_UID of the corresponding symbol. */
999 static inline bitmap
1000 gimple_stored_syms (const_gimple g)
1002 if (!gimple_has_mem_ops (g))
1003 return NULL;
1004 return g->with_mem_ops.stores;
1008 /* Return true if statement G has operands and the modified field has
1009 been set. */
1011 static inline bool
1012 gimple_modified_p (const_gimple g)
1014 return (gimple_has_ops (g)) ? (bool) g->with_ops.modified : false;
1018 /* Mark statement S as modified, and update it. */
1020 static inline void
1021 update_stmt (gimple s)
1023 if (gimple_has_ops (s))
1025 gimple_set_modified (s, true);
1026 update_stmt_operands (s);
1030 /* Update statement S if it has been optimized. */
1032 static inline void
1033 update_stmt_if_modified (gimple s)
1035 if (gimple_modified_p (s))
1036 update_stmt_operands (s);
1039 /* Return true if statement STMT contains volatile operands. */
1041 static inline bool
1042 gimple_has_volatile_ops (const_gimple stmt)
1044 if (gimple_has_mem_ops (stmt))
1045 return stmt->with_mem_ops.has_volatile_ops;
1046 else
1047 return false;
1051 /* Set the HAS_VOLATILE_OPS flag to VOLATILEP. */
1053 static inline void
1054 gimple_set_has_volatile_ops (gimple stmt, bool volatilep)
1056 if (gimple_has_mem_ops (stmt))
1057 stmt->with_mem_ops.has_volatile_ops = (unsigned) volatilep;
1061 /* Return true if statement STMT may access memory. */
1063 static inline bool
1064 gimple_references_memory_p (gimple stmt)
1066 return gimple_has_mem_ops (stmt) && stmt->with_mem_ops.references_memory_p;
1070 /* Set the REFERENCES_MEMORY_P flag for STMT to MEM_P. */
1072 static inline void
1073 gimple_set_references_memory (gimple stmt, bool mem_p)
1075 if (gimple_has_mem_ops (stmt))
1076 stmt->with_mem_ops.references_memory_p = (unsigned) mem_p;
1080 /* Set the nowait flag on OMP_RETURN statement S. */
1082 static inline void
1083 gimple_omp_return_set_nowait (gimple s)
1085 GIMPLE_CHECK (s, GIMPLE_OMP_RETURN);
1086 s->gsbase.subcode |= GF_OMP_RETURN_NOWAIT;
1090 /* Return true if OMP return statement G has the GF_OMP_RETURN_NOWAIT
1091 flag set. */
1093 static inline bool
1094 gimple_omp_return_nowait_p (const_gimple g)
1096 GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
1097 return (gimple_subcode (g) & GF_OMP_RETURN_NOWAIT) != 0;
1101 /* Return true if OMP section statement G has the GF_OMP_SECTION_LAST
1102 flag set. */
1104 static inline bool
1105 gimple_omp_section_last_p (const_gimple g)
1107 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1108 return (gimple_subcode (g) & GF_OMP_SECTION_LAST) != 0;
1112 /* Set the GF_OMP_SECTION_LAST flag on G. */
1114 static inline void
1115 gimple_omp_section_set_last (gimple g)
1117 GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1118 g->gsbase.subcode |= GF_OMP_SECTION_LAST;
1122 /* Return true if OMP parallel statement G has the
1123 GF_OMP_PARALLEL_COMBINED flag set. */
1125 static inline bool
1126 gimple_omp_parallel_combined_p (const_gimple g)
1128 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1129 return (gimple_subcode (g) & GF_OMP_PARALLEL_COMBINED) != 0;
1133 /* Set the GF_OMP_PARALLEL_COMBINED field in G. */
1135 static inline void
1136 gimple_omp_parallel_set_combined_p (gimple g)
1138 GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1139 g->gsbase.subcode |= GF_OMP_PARALLEL_COMBINED;
1143 extern const char *const gimple_code_name[];
1146 /* Return the number of operands for statement GS. FIXME, every
1147 GIMPLE statement should know how to reply to this. */
1149 static inline size_t
1150 gimple_num_ops (const_gimple gs)
1152 return (gimple_has_ops (gs)) ? gs->with_ops.num_ops : 0;
1156 /* Return the array of operands for statement GS. */
1158 static inline tree *
1159 gimple_ops (const_gimple gs)
1161 return (gimple_has_ops (gs)) ? gs->with_ops.op : NULL;
1165 /* Return operand I for statement GS. */
1167 static inline tree
1168 gimple_op (const_gimple gs, size_t i)
1170 if (gimple_has_ops (gs))
1172 gcc_assert (i < gs->with_ops.num_ops);
1173 return gs->with_ops.op[i];
1175 else
1176 return NULL_TREE;
1179 /* Return a pointer to operand I for statement GS. */
1181 static inline tree *
1182 gimple_op_ptr (const_gimple gs, size_t i)
1184 if (gimple_has_ops (gs))
1186 gcc_assert (i < gs->with_ops.num_ops);
1187 return &gs->with_ops.op[i];
1189 else
1190 return NULL;
1193 /* Set operand I of statement GS to OP. */
1195 static inline void
1196 gimple_set_op (gimple gs, size_t i, tree op)
1198 gcc_assert (gimple_has_ops (gs) && i < gs->with_ops.num_ops);
1200 /* Note. It may be tempting to assert that OP matches
1201 is_gimple_operand, but that would be wrong. Different tuples
1202 accept slightly different sets of tree operands. Each caller
1203 should perform its own validation. */
1204 gs->with_ops.op[i] = op;
1207 /* Return the set of symbols that have had their address taken by STMT. */
1209 static inline bitmap
1210 gimple_addresses_taken (gimple stmt)
1212 return gimple_has_ops (stmt) ? stmt->with_ops.addresses_taken : NULL;
1215 /* Return true if GS is a GIMPLE_ASSIGN. */
1217 static inline bool
1218 is_gimple_assign (const_gimple gs)
1220 return gimple_code (gs) == GIMPLE_ASSIGN;
1223 /* Return the LHS of assignment statement GS. */
1225 static inline tree
1226 gimple_assign_lhs (const_gimple gs)
1228 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1229 return gimple_op (gs, 0);
1233 /* Return a pointer to the LHS of assignment statement GS. */
1235 static inline tree *
1236 gimple_assign_lhs_ptr (const_gimple gs)
1238 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1239 return gimple_op_ptr (gs, 0);
1243 /* Set LHS to be the LHS operand of assignment statement GS. */
1245 static inline void
1246 gimple_assign_set_lhs (gimple gs, tree lhs)
1248 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1249 gcc_assert (is_gimple_operand (lhs));
1250 gimple_set_op (gs, 0, lhs);
1254 /* Return the first operand on the RHS of assignment statement GS. */
1256 static inline tree
1257 gimple_assign_rhs1 (const_gimple gs)
1259 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1260 return gimple_op (gs, 1);
1264 /* Return a pointer to the first operand on the RHS of assignment
1265 statement GS. */
1267 static inline tree *
1268 gimple_assign_rhs1_ptr (const_gimple gs)
1270 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1271 return gimple_op_ptr (gs, 1);
1274 /* Set RHS to be the first operand on the RHS of assignment statement GS. */
1276 static inline void
1277 gimple_assign_set_rhs1 (gimple gs, tree rhs)
1279 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1281 /* If there are 3 or more operands, the 2 operands on the RHS must be
1282 GIMPLE values. */
1283 if (gimple_num_ops (gs) >= 3)
1284 gcc_assert (is_gimple_val (rhs));
1285 else
1286 gcc_assert (is_gimple_operand (rhs));
1288 gimple_set_op (gs, 1, rhs);
1292 /* Return the second operand on the RHS of assignment statement GS.
1293 If GS does not have two operands, NULL is returned instead. */
1295 static inline tree
1296 gimple_assign_rhs2 (const_gimple gs)
1298 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1300 if (gimple_num_ops (gs) >= 3)
1301 return gimple_op (gs, 2);
1302 else
1303 return NULL_TREE;
1307 /* Return a pointer to the second operand on the RHS of assignment
1308 statement GS. */
1310 static inline tree *
1311 gimple_assign_rhs2_ptr (const_gimple gs)
1313 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1314 return gimple_op_ptr (gs, 2);
1318 /* Set RHS to be the second operand on the RHS of assignment statement GS. */
1320 static inline void
1321 gimple_assign_set_rhs2 (gimple gs, tree rhs)
1323 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1325 /* The 2 operands on the RHS must be GIMPLE values. */
1326 gcc_assert (is_gimple_val (rhs));
1328 gimple_set_op (gs, 2, rhs);
1331 /* Returns true if GS is a nontemporal move. */
1333 static inline bool
1334 gimple_assign_nontemporal_move_p (const_gimple gs)
1336 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1337 return gs->gsbase.nontemporal_move;
1340 /* Sets nontemporal move flag of GS to NONTEMPORAL. */
1342 static inline void
1343 gimple_assign_set_nontemporal_move (gimple gs, bool nontemporal)
1345 GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1346 gs->gsbase.nontemporal_move = nontemporal;
1349 /* Return true if S is an type-cast assignment. */
1351 static inline bool
1352 gimple_assign_cast_p (gimple s)
1354 return gimple_code (s) == GIMPLE_ASSIGN
1355 && (gimple_subcode (s) == NOP_EXPR
1356 || gimple_subcode (s) == CONVERT_EXPR
1357 || gimple_subcode (s) == FIX_TRUNC_EXPR);
1361 /* Return true if GS is a GIMPLE_CALL. */
1363 static inline bool
1364 is_gimple_call (const_gimple gs)
1366 return gimple_code (gs) == GIMPLE_CALL;
1369 /* Return the LHS of call statement GS. */
1371 static inline tree
1372 gimple_call_lhs (const_gimple gs)
1374 GIMPLE_CHECK (gs, GIMPLE_CALL);
1375 return gimple_op (gs, 0);
1379 /* Return a pointer to the LHS of call statement GS. */
1381 static inline tree *
1382 gimple_call_lhs_ptr (const_gimple gs)
1384 GIMPLE_CHECK (gs, GIMPLE_CALL);
1385 return gimple_op_ptr (gs, 0);
1389 /* Set LHS to be the LHS operand of call statement GS. */
1391 static inline void
1392 gimple_call_set_lhs (gimple gs, tree lhs)
1394 GIMPLE_CHECK (gs, GIMPLE_CALL);
1395 gcc_assert (!lhs || is_gimple_operand (lhs));
1396 gimple_set_op (gs, 0, lhs);
1400 /* Return the tree node representing the function called by call
1401 statement GS. This may or may not be a FUNCTION_DECL node. */
1403 static inline tree
1404 gimple_call_fn (const_gimple gs)
1406 GIMPLE_CHECK (gs, GIMPLE_CALL);
1407 return gimple_op (gs, 1);
1411 /* Return a pointer to the tree node representing the function called by call
1412 statement GS. */
1414 static inline tree *
1415 gimple_call_fn_ptr (const_gimple gs)
1417 GIMPLE_CHECK (gs, GIMPLE_CALL);
1418 return gimple_op_ptr (gs, 1);
1422 /* Set FN to be the function called by call statement GS. */
1424 static inline void
1425 gimple_call_set_fn (gimple gs, tree fn)
1427 GIMPLE_CHECK (gs, GIMPLE_CALL);
1428 gcc_assert (is_gimple_operand (fn));
1429 gimple_set_op (gs, 1, fn);
1433 /* If a given GIMPLE_CALL's callee is a FUNCTION_DECL, return it.
1434 Otherwise return NULL. This function is analogous to
1435 get_callee_fndecl in tree land. */
1437 static inline tree
1438 gimple_call_fndecl (const_gimple gs)
1440 tree decl = gimple_call_fn (gs);
1441 return (TREE_CODE (decl) == FUNCTION_DECL) ? decl : NULL_TREE;
1445 /* Return the type returned by call statement GS. */
1447 static inline tree
1448 gimple_call_return_type (const_gimple gs)
1450 tree fn = gimple_call_fn (gs);
1451 tree type = TREE_TYPE (fn);
1453 /* See through pointer to functions. */
1454 if (TREE_CODE (type) == POINTER_TYPE)
1455 type = TREE_TYPE (type);
1457 gcc_assert (TREE_CODE (type) == FUNCTION_TYPE
1458 || TREE_CODE (type) == METHOD_TYPE);
1460 /* The type returned by a FUNCTION_DECL is the type of its
1461 function type. */
1462 return TREE_TYPE (type);
1466 /* Return the static chain for call statement GS. */
1468 static inline tree
1469 gimple_call_chain (const_gimple gs)
1471 GIMPLE_CHECK (gs, GIMPLE_CALL);
1472 return gimple_op (gs, 2);
1476 /* Return a pointer to the static chain for call statement GS. */
1478 static inline tree *
1479 gimple_call_chain_ptr (const_gimple gs)
1481 GIMPLE_CHECK (gs, GIMPLE_CALL);
1482 return gimple_op_ptr (gs, 2);
1485 /* Set CHAIN to be the static chain for call statement GS. */
1487 static inline void
1488 gimple_call_set_chain (gimple gs, tree chain)
1490 GIMPLE_CHECK (gs, GIMPLE_CALL);
1491 gcc_assert (chain == NULL
1492 || TREE_CODE (chain) == ADDR_EXPR
1493 || DECL_P (chain));
1494 gimple_set_op (gs, 2, chain);
1498 /* Return the number of arguments used by call statement GS. */
1500 static inline size_t
1501 gimple_call_num_args (const_gimple gs)
1503 GIMPLE_CHECK (gs, GIMPLE_CALL);
1504 gcc_assert (gs->with_ops.num_ops >= 3);
1505 return gs->with_ops.num_ops - 3;
1509 /* Return the argument at position INDEX for call statement GS. */
1511 static inline tree
1512 gimple_call_arg (const_gimple gs, size_t index)
1514 GIMPLE_CHECK (gs, GIMPLE_CALL);
1515 return gimple_op (gs, index + 3);
1519 /* Return a pointer to the argument at position INDEX for call
1520 statement GS. */
1522 static inline tree *
1523 gimple_call_arg_ptr (const_gimple gs, size_t index)
1525 GIMPLE_CHECK (gs, GIMPLE_CALL);
1526 return gimple_op_ptr (gs, index + 3);
1530 /* Set ARG to be the argument at position INDEX for call statement GS. */
1532 static inline void
1533 gimple_call_set_arg (gimple gs, size_t index, tree arg)
1535 GIMPLE_CHECK (gs, GIMPLE_CALL);
1536 gcc_assert (is_gimple_operand (arg));
1537 gimple_set_op (gs, index + 3, arg);
1541 /* If TAIL_P is true, mark call statement S as being a tail call
1542 (i.e., a call just before the exit of a function). These calls are
1543 candidate for tail call optimization. */
1545 static inline void
1546 gimple_call_set_tail (gimple s, bool tail_p)
1548 GIMPLE_CHECK (s, GIMPLE_CALL);
1549 if (tail_p)
1550 s->gsbase.subcode |= GF_CALL_TAILCALL;
1551 else
1552 s->gsbase.subcode &= ~GF_CALL_TAILCALL;
1556 /* Return true if GIMPLE_CALL S is marked as a tail call. */
1558 static inline bool
1559 gimple_call_tail_p (gimple s)
1561 GIMPLE_CHECK (s, GIMPLE_CALL);
1562 return (gimple_subcode (s) & GF_CALL_TAILCALL) != 0;
1566 /* Set the inlinable status of GIMPLE_CALL S to INLINABLE_P. */
1568 static inline void
1569 gimple_call_set_cannot_inline (gimple s, bool inlinable_p)
1571 GIMPLE_CHECK (s, GIMPLE_CALL);
1572 if (inlinable_p)
1573 s->gsbase.subcode |= GF_CALL_CANNOT_INLINE;
1574 else
1575 s->gsbase.subcode &= ~GF_CALL_CANNOT_INLINE;
1579 /* Return true if GIMPLE_CALL S cannot be inlined. */
1581 static inline bool
1582 gimple_call_cannot_inline_p (gimple s)
1584 GIMPLE_CHECK (s, GIMPLE_CALL);
1585 return (gimple_subcode (s) & GF_CALL_CANNOT_INLINE) != 0;
1589 /* If RETURN_SLOT_OPT_P is true mark GIMPLE_CALL S as valid for return
1590 slot optimization. This transformation uses the target of the call
1591 expansion as the return slot for calls that return in memory. */
1593 static inline void
1594 gimple_call_set_return_slot_opt (gimple s, bool return_slot_opt_p)
1596 GIMPLE_CHECK (s, GIMPLE_CALL);
1597 if (return_slot_opt_p)
1598 s->gsbase.subcode |= GF_CALL_RETURN_SLOT_OPT;
1599 else
1600 s->gsbase.subcode &= ~GF_CALL_RETURN_SLOT_OPT;
1604 /* Return true if S is marked for return slot optimization. */
1606 static inline bool
1607 gimple_call_return_slot_opt_p (gimple s)
1609 GIMPLE_CHECK (s, GIMPLE_CALL);
1610 return (gimple_subcode (s) & GF_CALL_RETURN_SLOT_OPT) != 0;
1614 /* If FROM_THUNK_P is true, mark GIMPLE_CALL S as being the jump from a
1615 thunk to the thunked-to function. */
1617 static inline void
1618 gimple_call_set_from_thunk (gimple s, bool from_thunk_p)
1620 GIMPLE_CHECK (s, GIMPLE_CALL);
1621 if (from_thunk_p)
1622 s->gsbase.subcode |= GF_CALL_FROM_THUNK;
1623 else
1624 s->gsbase.subcode &= ~GF_CALL_FROM_THUNK;
1628 /* Return true if GIMPLE_CALL S is a jump from a thunk. */
1630 static inline bool
1631 gimple_call_from_thunk_p (gimple s)
1633 GIMPLE_CHECK (s, GIMPLE_CALL);
1634 return (gimple_subcode (s) & GF_CALL_FROM_THUNK) != 0;
1638 /* If PASS_ARG_PACK_P is true, GIMPLE_CALL S is a stdarg call that needs the
1639 argument pack in its argument list. */
1641 static inline void
1642 gimple_call_set_va_arg_pack (gimple s, bool pass_arg_pack_p)
1644 GIMPLE_CHECK (s, GIMPLE_CALL);
1645 if (pass_arg_pack_p)
1646 s->gsbase.subcode |= GF_CALL_VA_ARG_PACK;
1647 else
1648 s->gsbase.subcode &= ~GF_CALL_VA_ARG_PACK;
1652 /* Return true if GIMPLE_CALL S is a stdarg call that needs the
1653 argument pack in its argument list. */
1655 static inline bool
1656 gimple_call_va_arg_pack_p (gimple s)
1658 GIMPLE_CHECK (s, GIMPLE_CALL);
1659 return (gimple_subcode (s) & GF_CALL_VA_ARG_PACK) != 0;
1663 /* Return true if S is a noreturn call. */
1665 static inline bool
1666 gimple_call_noreturn_p (gimple s)
1668 GIMPLE_CHECK (s, GIMPLE_CALL);
1669 return (gimple_call_flags (s) & ECF_NORETURN) != 0;
1673 /* Return true if S is a nothrow call. */
1675 static inline bool
1676 gimple_call_nothrow_p (gimple s)
1678 GIMPLE_CHECK (s, GIMPLE_CALL);
1679 return (gimple_call_flags (s) & ECF_NOTHROW) != 0;
1683 /* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL. */
1685 static inline void
1686 gimple_call_copy_flags (gimple dest_call, gimple orig_call)
1688 GIMPLE_CHECK (dest_call, GIMPLE_CALL);
1689 GIMPLE_CHECK (orig_call, GIMPLE_CALL);
1690 gimple_set_subcode (dest_call, gimple_subcode (orig_call));
1694 /* Return the code of the predicate computed by conditional statement GS. */
1696 static inline enum tree_code
1697 gimple_cond_code (const_gimple gs)
1699 GIMPLE_CHECK (gs, GIMPLE_COND);
1700 return gimple_subcode (gs);
1704 /* Set CODE to be the predicate code for the conditional statement GS. */
1706 static inline void
1707 gimple_cond_set_code (gimple gs, enum tree_code code)
1709 GIMPLE_CHECK (gs, GIMPLE_COND);
1710 gcc_assert (TREE_CODE_CLASS (code) == tcc_comparison);
1711 gimple_set_subcode (gs, code);
1715 /* Return the LHS of the predicate computed by conditional statement GS. */
1717 static inline tree
1718 gimple_cond_lhs (const_gimple gs)
1720 GIMPLE_CHECK (gs, GIMPLE_COND);
1721 return gimple_op (gs, 0);
1724 /* Return the pointer to the LHS of the predicate computed by conditional
1725 statement GS. */
1727 static inline tree *
1728 gimple_cond_lhs_ptr (const_gimple gs)
1730 GIMPLE_CHECK (gs, GIMPLE_COND);
1731 return gimple_op_ptr (gs, 0);
1734 /* Set LHS to be the LHS operand of the predicate computed by
1735 conditional statement GS. */
1737 static inline void
1738 gimple_cond_set_lhs (gimple gs, tree lhs)
1740 GIMPLE_CHECK (gs, GIMPLE_COND);
1741 gcc_assert (is_gimple_operand (lhs));
1742 gimple_set_op (gs, 0, lhs);
1746 /* Return the RHS operand of the predicate computed by conditional GS. */
1748 static inline tree
1749 gimple_cond_rhs (const_gimple gs)
1751 GIMPLE_CHECK (gs, GIMPLE_COND);
1752 return gimple_op (gs, 1);
1755 /* Return the pointer to the RHS operand of the predicate computed by
1756 conditional GS. */
1758 static inline tree *
1759 gimple_cond_rhs_ptr (const_gimple gs)
1761 GIMPLE_CHECK (gs, GIMPLE_COND);
1762 return gimple_op_ptr (gs, 1);
1766 /* Set RHS to be the RHS operand of the predicate computed by
1767 conditional statement GS. */
1769 static inline void
1770 gimple_cond_set_rhs (gimple gs, tree rhs)
1772 GIMPLE_CHECK (gs, GIMPLE_COND);
1773 gcc_assert (is_gimple_operand (rhs));
1774 gimple_set_op (gs, 1, rhs);
1778 /* Return the label used by conditional statement GS when its
1779 predicate evaluates to true. */
1781 static inline tree
1782 gimple_cond_true_label (const_gimple gs)
1784 GIMPLE_CHECK (gs, GIMPLE_COND);
1785 return gimple_op (gs, 2);
1789 /* Set LABEL to be the label used by conditional statement GS when its
1790 predicate evaluates to true. */
1792 static inline void
1793 gimple_cond_set_true_label (gimple gs, tree label)
1795 GIMPLE_CHECK (gs, GIMPLE_COND);
1796 gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
1797 gimple_set_op (gs, 2, label);
1801 /* Set LABEL to be the label used by conditional statement GS when its
1802 predicate evaluates to false. */
1804 static inline void
1805 gimple_cond_set_false_label (gimple gs, tree label)
1807 GIMPLE_CHECK (gs, GIMPLE_COND);
1808 gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
1809 gimple_set_op (gs, 3, label);
1813 /* Return the label used by conditional statement GS when its
1814 predicate evaluates to false. */
1816 static inline tree
1817 gimple_cond_false_label (const_gimple gs)
1819 GIMPLE_CHECK (gs, GIMPLE_COND);
1820 return gimple_op (gs, 3);
1824 /* Set the conditional COND_STMT to be of the form 'if (1 == 0)'. */
1826 static inline void
1827 gimple_cond_make_false (gimple gs)
1829 gimple_set_subcode (gs, EQ_EXPR);
1830 gimple_cond_set_lhs (gs, boolean_true_node);
1831 gimple_cond_set_rhs (gs, boolean_false_node);
1835 /* Set the conditional COND_STMT to be of the form 'if (1 == 1)'. */
1837 static inline void
1838 gimple_cond_make_true (gimple gs)
1840 gimple_set_subcode (gs, EQ_EXPR);
1841 gimple_cond_set_lhs (gs, boolean_true_node);
1842 gimple_cond_set_rhs (gs, boolean_true_node);
1845 /* Check if conditional statemente GS is of the form 'if (1 == 1)',
1846 'if (0 == 0)', 'if (1 != 0)' or 'if (0 != 1)' */
1848 static inline bool
1849 gimple_cond_true_p (const_gimple gs)
1851 tree lhs = gimple_cond_lhs (gs);
1852 tree rhs = gimple_cond_rhs (gs);
1853 enum tree_code code = gimple_cond_code (gs);
1855 if (lhs != boolean_true_node && lhs != boolean_false_node)
1856 return false;
1858 if (rhs != boolean_true_node && rhs != boolean_false_node)
1859 return false;
1861 if (code == NE_EXPR && lhs != rhs)
1862 return true;
1864 if (code == EQ_EXPR && lhs == rhs)
1865 return true;
1867 return false;
1870 /* Check if conditional statement GS is of the form 'if (1 != 1)',
1871 'if (0 != 0)', 'if (1 == 0)' or 'if (0 == 1)' */
1873 static inline bool
1874 gimple_cond_false_p (const_gimple gs)
1876 tree lhs = gimple_cond_lhs (gs);
1877 tree rhs = gimple_cond_rhs (gs);
1878 enum tree_code code = gimple_cond_code (gs);
1880 if (lhs != boolean_true_node && lhs != boolean_false_node)
1881 return false;
1883 if (rhs != boolean_true_node && rhs != boolean_false_node)
1884 return false;
1886 if (code == NE_EXPR && lhs == rhs)
1887 return true;
1889 if (code == EQ_EXPR && lhs != rhs)
1890 return true;
1892 return false;
1895 /* Check if conditional statement GS is of the form 'if (var != 0)' or
1896 'if (var == 1)' */
1898 static inline bool
1899 gimple_cond_single_var_p (gimple gs)
1901 if (gimple_cond_code (gs) == NE_EXPR
1902 && gimple_cond_rhs (gs) == boolean_false_node)
1903 return true;
1905 if (gimple_cond_code (gs) == EQ_EXPR
1906 && gimple_cond_rhs (gs) == boolean_true_node)
1907 return true;
1909 return false;
1912 /* Return the LABEL_DECL node used by GIMPLE_LABEL statement GS. */
1914 static inline tree
1915 gimple_label_label (const_gimple gs)
1917 GIMPLE_CHECK (gs, GIMPLE_LABEL);
1918 return gimple_op (gs, 0);
1922 /* Set LABEL to be the LABEL_DECL node used by GIMPLE_LABEL statement
1923 GS. */
1925 static inline void
1926 gimple_label_set_label (gimple gs, tree label)
1928 GIMPLE_CHECK (gs, GIMPLE_LABEL);
1929 gcc_assert (TREE_CODE (label) == LABEL_DECL);
1930 gimple_set_op (gs, 0, label);
1934 /* Return the destination of the unconditional jump GS. */
1936 static inline tree
1937 gimple_goto_dest (const_gimple gs)
1939 GIMPLE_CHECK (gs, GIMPLE_GOTO);
1940 return gimple_op (gs, 0);
1944 /* Set DEST to be the destination of the unconditonal jump GS. */
1946 static inline void
1947 gimple_goto_set_dest (gimple gs, tree dest)
1949 GIMPLE_CHECK (gs, GIMPLE_GOTO);
1950 gcc_assert (is_gimple_operand (dest));
1951 gimple_set_op (gs, 0, dest);
1955 /* Return the variables declared in the GIMPLE_BIND statement GS. */
1957 static inline tree
1958 gimple_bind_vars (const_gimple gs)
1960 GIMPLE_CHECK (gs, GIMPLE_BIND);
1961 return gs->gimple_bind.vars;
1965 /* Set VARS to be the set of variables declared in the GIMPLE_BIND
1966 statement GS. */
1968 static inline void
1969 gimple_bind_set_vars (gimple gs, tree vars)
1971 GIMPLE_CHECK (gs, GIMPLE_BIND);
1972 gs->gimple_bind.vars = vars;
1976 /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS. */
1978 static inline gimple_seq
1979 gimple_bind_body (gimple gs)
1981 GIMPLE_CHECK (gs, GIMPLE_BIND);
1982 return gs->gimple_bind.body;
1986 /* Set SEQ to be the GIMPLE sequence contained in the GIMPLE_BIND
1987 statement GS. */
1989 static inline void
1990 gimple_bind_set_body (gimple gs, gimple_seq seq)
1992 GIMPLE_CHECK (gs, GIMPLE_BIND);
1993 gs->gimple_bind.body = seq;
1997 /* Append a statement to the end of a GIMPLE_BIND's body. */
1999 static inline void
2000 gimple_bind_add_stmt (gimple gs, gimple stmt)
2002 GIMPLE_CHECK (gs, GIMPLE_BIND);
2003 gimple_seq_add_stmt (&gs->gimple_bind.body, stmt);
2007 /* Append a sequence of statements to the end of a GIMPLE_BIND's body. */
2009 static inline void
2010 gimple_bind_add_seq (gimple gs, gimple_seq seq)
2012 GIMPLE_CHECK (gs, GIMPLE_BIND);
2013 gimple_seq_add_seq (&gs->gimple_bind.body, seq);
2017 /* Return the TREE_BLOCK node associated with GIMPLE_BIND statement
2018 GS. This is analogous to the BIND_EXPR_BLOCK field in trees. */
2020 static inline tree
2021 gimple_bind_block (const_gimple gs)
2023 GIMPLE_CHECK (gs, GIMPLE_BIND);
2024 return gs->gimple_bind.block;
2028 /* Set BLOCK to be the TREE_BLOCK node associated with GIMPLE_BIND
2029 statement GS. */
2031 static inline void
2032 gimple_bind_set_block (gimple gs, tree block)
2034 GIMPLE_CHECK (gs, GIMPLE_BIND);
2035 gcc_assert (TREE_CODE (block) == BLOCK);
2036 gs->gimple_bind.block = block;
2040 /* Return the number of input operands for GIMPLE_ASM GS. */
2042 static inline size_t
2043 gimple_asm_ninputs (const_gimple gs)
2045 GIMPLE_CHECK (gs, GIMPLE_ASM);
2046 return gs->gimple_asm.ni;
2050 /* Return the number of output operands for GIMPLE_ASM GS. */
2052 static inline size_t
2053 gimple_asm_noutputs (const_gimple gs)
2055 GIMPLE_CHECK (gs, GIMPLE_ASM);
2056 return gs->gimple_asm.no;
2060 /* Return the number of clobber operands for GIMPLE_ASM GS. */
2062 static inline size_t
2063 gimple_asm_nclobbers (const_gimple gs)
2065 GIMPLE_CHECK (gs, GIMPLE_ASM);
2066 return gs->gimple_asm.nc;
2070 /* Return input operand INDEX of GIMPLE_ASM GS. */
2072 static inline tree
2073 gimple_asm_input_op (const_gimple gs, size_t index)
2075 GIMPLE_CHECK (gs, GIMPLE_ASM);
2076 gcc_assert (index <= gs->gimple_asm.ni);
2077 return gimple_op (gs, index);
2080 /* Return a pointer to input operand INDEX of GIMPLE_ASM GS. */
2082 static inline tree *
2083 gimple_asm_input_op_ptr (const_gimple gs, size_t index)
2085 GIMPLE_CHECK (gs, GIMPLE_ASM);
2086 gcc_assert (index <= gs->gimple_asm.ni);
2087 return gimple_op_ptr (gs, index);
2091 /* Set IN_OP to be input operand INDEX in GIMPLE_ASM GS. */
2093 static inline void
2094 gimple_asm_set_input_op (gimple gs, size_t index, tree in_op)
2096 GIMPLE_CHECK (gs, GIMPLE_ASM);
2097 gcc_assert (index <= gs->gimple_asm.ni);
2098 gcc_assert (TREE_CODE (in_op) == TREE_LIST);
2099 gimple_set_op (gs, index, in_op);
2103 /* Return output operand INDEX of GIMPLE_ASM GS. */
2105 static inline tree
2106 gimple_asm_output_op (const_gimple gs, size_t index)
2108 GIMPLE_CHECK (gs, GIMPLE_ASM);
2109 gcc_assert (index <= gs->gimple_asm.no);
2110 return gimple_op (gs, index + gs->gimple_asm.ni);
2113 /* Return a pointer to output operand INDEX of GIMPLE_ASM GS. */
2115 static inline tree *
2116 gimple_asm_output_op_ptr (const_gimple gs, size_t index)
2118 GIMPLE_CHECK (gs, GIMPLE_ASM);
2119 gcc_assert (index <= gs->gimple_asm.no);
2120 return gimple_op_ptr (gs, index + gs->gimple_asm.ni);
2124 /* Set OUT_OP to be output operand INDEX in GIMPLE_ASM GS. */
2126 static inline void
2127 gimple_asm_set_output_op (gimple gs, size_t index, tree out_op)
2129 GIMPLE_CHECK (gs, GIMPLE_ASM);
2130 gcc_assert (index <= gs->gimple_asm.no);
2131 gcc_assert (TREE_CODE (out_op) == TREE_LIST);
2132 gimple_set_op (gs, index + gs->gimple_asm.ni, out_op);
2136 /* Return clobber operand INDEX of GIMPLE_ASM GS. */
2138 static inline tree
2139 gimple_asm_clobber_op (const_gimple gs, size_t index)
2141 GIMPLE_CHECK (gs, GIMPLE_ASM);
2142 gcc_assert (index <= gs->gimple_asm.nc);
2143 return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no);
2147 /* Set CLOBBER_OP to be clobber operand INDEX in GIMPLE_ASM GS. */
2149 static inline void
2150 gimple_asm_set_clobber_op (gimple gs, size_t index, tree clobber_op)
2152 GIMPLE_CHECK (gs, GIMPLE_ASM);
2153 gcc_assert (index <= gs->gimple_asm.nc);
2154 gcc_assert (TREE_CODE (clobber_op) == TREE_LIST);
2155 gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no, clobber_op);
2159 /* Return the string representing the assembly instruction in
2160 GIMPLE_ASM GS. */
2162 static inline const char *
2163 gimple_asm_string (const_gimple gs)
2165 GIMPLE_CHECK (gs, GIMPLE_ASM);
2166 return gs->gimple_asm.string;
2170 /* Return true if GS is an asm statement marked volatile. */
2172 static inline bool
2173 gimple_asm_volatile_p (const_gimple gs)
2175 GIMPLE_CHECK (gs, GIMPLE_ASM);
2176 return (gimple_subcode (gs) & GF_ASM_VOLATILE) != 0;
2180 /* If VOLATLE_P is true, mark asm statement GS as volatile. */
2182 static inline void
2183 gimple_asm_set_volatile (gimple gs, bool volatile_p)
2185 GIMPLE_CHECK (gs, GIMPLE_ASM);
2186 if (volatile_p)
2187 gs->gsbase.subcode |= GF_ASM_VOLATILE;
2188 else
2189 gs->gsbase.subcode &= ~GF_ASM_VOLATILE;
2193 /* If INPUT_P is true, mark asm GS as an ASM_INPUT. */
2195 static inline void
2196 gimple_asm_set_input (gimple gs, bool input_p)
2198 GIMPLE_CHECK (gs, GIMPLE_ASM);
2199 if (input_p)
2200 gs->gsbase.subcode |= GF_ASM_INPUT;
2201 else
2202 gs->gsbase.subcode &= ~GF_ASM_INPUT;
2206 /* Return true if asm GS is an ASM_INPUT. */
2208 static inline bool
2209 gimple_asm_input_p (const_gimple gs)
2211 GIMPLE_CHECK (gs, GIMPLE_ASM);
2212 return (gimple_subcode (gs) & GF_ASM_INPUT) != 0;
2216 /* Return the types handled by GIMPLE_CATCH statement GS. */
2218 static inline tree
2219 gimple_catch_types (const_gimple gs)
2221 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2222 return gs->gimple_catch.types;
2226 /* Return a pointer to the types handled by GIMPLE_CATCH statement GS. */
2228 static inline tree *
2229 gimple_catch_types_ptr (gimple gs)
2231 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2232 return &gs->gimple_catch.types;
2236 /* Return the GIMPLE sequence representing the body of the handler of
2237 GIMPLE_CATCH statement GS. */
2239 static inline gimple_seq
2240 gimple_catch_handler (gimple gs)
2242 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2243 return gs->gimple_catch.handler;
2247 /* Return a pointer to the GIMPLE sequence representing the body of
2248 the handler of GIMPLE_CATCH statement GS. */
2250 static inline gimple_seq *
2251 gimple_catch_handler_ptr (gimple gs)
2253 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2254 return &gs->gimple_catch.handler;
2258 /* Set T to be the set of types handled by GIMPLE_CATCH GS. */
2260 static inline void
2261 gimple_catch_set_types (gimple gs, tree t)
2263 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2264 gs->gimple_catch.types = t;
2268 /* Set HANDLER to be the body of GIMPLE_CATCH GS. */
2270 static inline void
2271 gimple_catch_set_handler (gimple gs, gimple_seq handler)
2273 GIMPLE_CHECK (gs, GIMPLE_CATCH);
2274 gs->gimple_catch.handler = handler;
2278 /* Return the types handled by GIMPLE_EH_FILTER statement GS. */
2280 static inline tree
2281 gimple_eh_filter_types (const_gimple gs)
2283 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2284 return gs->gimple_eh_filter.types;
2288 /* Return a pointer to the types handled by GIMPLE_EH_FILTER statement
2289 GS. */
2291 static inline tree *
2292 gimple_eh_filter_types_ptr (gimple gs)
2294 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2295 return &gs->gimple_eh_filter.types;
2299 /* Return the sequence of statement to execute when GIMPLE_EH_FILTER
2300 statement fails. */
2302 static inline gimple_seq
2303 gimple_eh_filter_failure (gimple gs)
2305 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2306 return gs->gimple_eh_filter.failure;
2310 /* Set TYPES to be the set of types handled by GIMPLE_EH_FILTER GS. */
2312 static inline void
2313 gimple_eh_filter_set_types (gimple gs, tree types)
2315 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2316 gs->gimple_eh_filter.types = types;
2320 /* Set FAILURE to be the sequence of statements to execute on failure
2321 for GIMPLE_EH_FILTER GS. */
2323 static inline void
2324 gimple_eh_filter_set_failure (gimple gs, gimple_seq failure)
2326 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2327 gs->gimple_eh_filter.failure = failure;
2330 /* Return the EH_FILTER_MUST_NOT_THROW flag. */
2331 static inline bool
2332 gimple_eh_filter_must_not_throw (gimple gs)
2334 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2335 return (bool) gimple_subcode (gs);
2338 /* Set the EH_FILTER_MUST_NOT_THROW flag to the value MNTP. */
2340 static inline void
2341 gimple_eh_filter_set_must_not_throw (gimple gs, bool mntp)
2343 GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
2344 gimple_set_subcode (gs, (unsigned int) mntp);
2348 /* GIMPLE_TRY accessors. */
2350 /* Return the kind of try block represented by GIMPLE_TRY GS. This is
2351 either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY. */
2353 static inline enum gimple_try_flags
2354 gimple_try_kind (const_gimple gs)
2356 GIMPLE_CHECK (gs, GIMPLE_TRY);
2357 return (enum gimple_try_flags) (gimple_subcode (gs) & GIMPLE_TRY_KIND);
2361 /* Return the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2363 static inline bool
2364 gimple_try_catch_is_cleanup (const_gimple gs)
2366 gcc_assert (gimple_try_kind (gs) == GIMPLE_TRY_CATCH);
2367 return (gimple_subcode (gs) & GIMPLE_TRY_CATCH_IS_CLEANUP) != 0;
2371 /* Return the sequence of statements used as the body for GIMPLE_TRY GS. */
2373 static inline gimple_seq
2374 gimple_try_eval (gimple gs)
2376 GIMPLE_CHECK (gs, GIMPLE_TRY);
2377 return gs->gimple_try.eval;
2381 /* Return the sequence of statements used as the cleanup body for
2382 GIMPLE_TRY GS. */
2384 static inline gimple_seq
2385 gimple_try_cleanup (gimple gs)
2387 GIMPLE_CHECK (gs, GIMPLE_TRY);
2388 return gs->gimple_try.cleanup;
2392 /* Set the GIMPLE_TRY_CATCH_IS_CLEANUP flag. */
2394 static inline void
2395 gimple_try_set_catch_is_cleanup (gimple g, bool catch_is_cleanup)
2397 gcc_assert (gimple_try_kind (g) == GIMPLE_TRY_CATCH);
2398 if (catch_is_cleanup)
2399 g->gsbase.subcode |= GIMPLE_TRY_CATCH_IS_CLEANUP;
2400 else
2401 g->gsbase.subcode &= ~GIMPLE_TRY_CATCH_IS_CLEANUP;
2405 /* Set EVAL to be the sequence of statements to use as the body for
2406 GIMPLE_TRY GS. */
2408 static inline void
2409 gimple_try_set_eval (gimple gs, gimple_seq eval)
2411 GIMPLE_CHECK (gs, GIMPLE_TRY);
2412 gs->gimple_try.eval = eval;
2416 /* Set CLEANUP to be the sequence of statements to use as the cleanup
2417 body for GIMPLE_TRY GS. */
2419 static inline void
2420 gimple_try_set_cleanup (gimple gs, gimple_seq cleanup)
2422 GIMPLE_CHECK (gs, GIMPLE_TRY);
2423 gs->gimple_try.cleanup = cleanup;
2427 /* Return the cleanup sequence for cleanup statement GS. */
2429 static inline gimple_seq
2430 gimple_wce_cleanup (gimple gs)
2432 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
2433 return gs->gimple_wce.cleanup;
2437 /* Set CLEANUP to be the cleanup sequence for GS. */
2439 static inline void
2440 gimple_wce_set_cleanup (gimple gs, gimple_seq cleanup)
2442 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
2443 gs->gimple_wce.cleanup = cleanup;
2447 /* Return the CLEANUP_EH_ONLY flag for a WCE tuple. */
2449 static inline bool
2450 gimple_wce_cleanup_eh_only (const_gimple gs)
2452 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
2453 return (bool) gimple_subcode (gs);
2457 /* Set the CLEANUP_EH_ONLY flag for a WCE tuple. */
2459 static inline void
2460 gimple_wce_set_cleanup_eh_only (gimple gs, bool eh_only_p)
2462 GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
2463 gimple_set_subcode (gs, (unsigned int) eh_only_p);
2467 /* Return the maximum number of arguments supported by GIMPLE_PHI GS. */
2469 static inline size_t
2470 gimple_phi_capacity (const_gimple gs)
2472 GIMPLE_CHECK (gs, GIMPLE_PHI);
2473 return gs->gimple_phi.capacity;
2477 /* Return the number of arguments in GIMPLE_PHI GS. This must always
2478 be exactly the number of incoming edges for the basic block holding
2479 GS. FIXME tuples, this field is useless then. */
2481 static inline size_t
2482 gimple_phi_num_args (const_gimple gs)
2484 GIMPLE_CHECK (gs, GIMPLE_PHI);
2485 return gs->gimple_phi.nargs;
2489 /* Return the SSA name created by GIMPLE_PHI GS. */
2491 static inline tree
2492 gimple_phi_result (const_gimple gs)
2494 GIMPLE_CHECK (gs, GIMPLE_PHI);
2495 return gs->gimple_phi.result;
2498 /* Return a pointer to the SSA name created by GIMPLE_PHI GS. */
2500 static inline tree *
2501 gimple_phi_result_ptr (gimple gs)
2503 GIMPLE_CHECK (gs, GIMPLE_PHI);
2504 return &gs->gimple_phi.result;
2507 /* Set RESULT to be the SSA name created by GIMPLE_PHI GS. */
2509 static inline void
2510 gimple_phi_set_result (gimple gs, tree result)
2512 GIMPLE_CHECK (gs, GIMPLE_PHI);
2513 gs->gimple_phi.result = result;
2517 /* Return the PHI argument corresponding to incoming edge INDEX for
2518 GIMPLE_PHI GS. */
2520 static inline struct phi_arg_d *
2521 gimple_phi_arg (gimple gs, size_t index)
2523 GIMPLE_CHECK (gs, GIMPLE_PHI);
2524 gcc_assert (index <= gs->gimple_phi.capacity);
2525 return &(gs->gimple_phi.args[index]);
2528 /* Set PHIARG to be the argument corresponding to incoming edge INDEX
2529 for GIMPLE_PHI GS. */
2531 static inline void
2532 gimple_phi_set_arg (gimple gs, size_t index, struct phi_arg_d * phiarg)
2534 GIMPLE_CHECK (gs, GIMPLE_PHI);
2535 gcc_assert (index <= gs->gimple_phi.nargs);
2536 memcpy (gs->gimple_phi.args + index, phiarg, sizeof (struct phi_arg_d));
2539 /* Return the region number for GIMPLE_RESX GS. */
2541 static inline int
2542 gimple_resx_region (const_gimple gs)
2544 GIMPLE_CHECK (gs, GIMPLE_RESX);
2545 return gs->gimple_resx.region;
2548 /* Set REGION to be the region number for GIMPLE_RESX GS. */
2550 static inline void
2551 gimple_resx_set_region (gimple gs, int region)
2553 GIMPLE_CHECK (gs, GIMPLE_RESX);
2554 gs->gimple_resx.region = region;
2558 /* Return the number of labels associated with the switch statement GS. */
2560 static inline size_t
2561 gimple_switch_num_labels (const_gimple gs)
2563 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
2564 gcc_assert (gs->with_ops.num_ops > 1);
2565 return gs->with_ops.num_ops - 1;
2569 /* Set NLABELS to be the number of labels for the switch statement GS. */
2571 static inline void
2572 gimple_switch_set_num_labels (gimple g, size_t nlabels)
2574 GIMPLE_CHECK (g, GIMPLE_SWITCH);
2575 g->with_ops.num_ops = nlabels + 1;
2579 /* Return the index variable used by the switch statement GS. */
2581 static inline tree
2582 gimple_switch_index (const_gimple gs)
2584 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
2585 return gimple_op (gs, 0);
2589 /* Return a pointer to the index variable for the switch statement GS. */
2591 static inline tree *
2592 gimple_switch_index_ptr (const_gimple gs)
2594 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
2595 return gimple_op_ptr (gs, 0);
2599 /* Set INDEX to be the index variable for switch statement GS. */
2601 static inline void
2602 gimple_switch_set_index (gimple gs, tree index)
2604 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
2605 gcc_assert (SSA_VAR_P (index) || CONSTANT_CLASS_P (index));
2606 gimple_set_op (gs, 0, index);
2610 /* Return the label numbered INDEX. The default label is 0, followed by any
2611 labels in a switch statement. */
2613 static inline tree
2614 gimple_switch_label (const_gimple gs, size_t index)
2616 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
2617 gcc_assert (gs->with_ops.num_ops > index + 1);
2618 return gimple_op (gs, index + 1);
2621 /* Set the label number INDEX to LABEL. 0 is always the default label. */
2623 static inline void
2624 gimple_switch_set_label (gimple gs, size_t index, tree label)
2626 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
2627 gcc_assert (gs->with_ops.num_ops > index + 1);
2628 gcc_assert (label == NULL_TREE || TREE_CODE (label) == CASE_LABEL_EXPR);
2629 gimple_set_op (gs, index + 1, label);
2632 /* Return the default label for a switch statement. */
2634 static inline tree
2635 gimple_switch_default_label (const_gimple gs)
2637 return gimple_switch_label (gs, 0);
2640 /* Set the default label for a switch statement. */
2642 static inline void
2643 gimple_switch_set_default_label (gimple gs, tree label)
2645 gimple_switch_set_label (gs, 0, label);
2649 /* Return the body for the OMP statement GS. */
2651 static inline gimple_seq
2652 gimple_omp_body (gimple gs)
2654 return gs->omp.body;
2657 /* Set BODY to be the body for the OMP statement GS. */
2659 static inline void
2660 gimple_omp_set_body (gimple gs, gimple_seq body)
2662 gs->omp.body = body;
2666 /* Return the name associated with OMP_CRITICAL statement GS. */
2668 static inline tree
2669 gimple_omp_critical_name (const_gimple gs)
2671 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
2672 return gs->gimple_omp_critical.name;
2676 /* Return a pointer to the name associated with OMP critical statement GS. */
2678 static inline tree *
2679 gimple_omp_critical_name_ptr (gimple gs)
2681 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
2682 return &gs->gimple_omp_critical.name;
2686 /* Set NAME to be the name associated with OMP critical statement GS. */
2688 static inline void
2689 gimple_omp_critical_set_name (gimple gs, tree name)
2691 GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
2692 gs->gimple_omp_critical.name = name;
2696 /* Return the clauses associated with OMP_FOR GS. */
2698 static inline tree
2699 gimple_omp_for_clauses (const_gimple gs)
2701 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
2702 return gs->gimple_omp_for.clauses;
2706 /* Return a pointer to the OMP_FOR GS. */
2708 static inline tree *
2709 gimple_omp_for_clauses_ptr (gimple gs)
2711 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
2712 return &gs->gimple_omp_for.clauses;
2716 /* Set CLAUSES to be the list of clauses associated with OMP_FOR GS. */
2718 static inline void
2719 gimple_omp_for_set_clauses (gimple gs, tree clauses)
2721 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
2722 gs->gimple_omp_for.clauses = clauses;
2726 /* Return the index variable for OMP_FOR GS. */
2728 static inline tree
2729 gimple_omp_for_index (const_gimple gs)
2731 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
2732 return gs->gimple_omp_for.index;
2736 /* Return a pointer to the index variable for OMP_FOR GS. */
2738 static inline tree *
2739 gimple_omp_for_index_ptr (gimple gs)
2741 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
2742 return &gs->gimple_omp_for.index;
2746 /* Set INDEX to be the index variable for OMP_FOR GS. */
2748 static inline void
2749 gimple_omp_for_set_index (gimple gs, tree index)
2751 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
2752 gs->gimple_omp_for.index = index;
2756 /* Return the initial value for OMP_FOR GS. */
2758 static inline tree
2759 gimple_omp_for_initial (const_gimple gs)
2761 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
2762 return gs->gimple_omp_for.initial;
2766 /* Return a pointer to the initial value for OMP_FOR GS. */
2768 static inline tree *
2769 gimple_omp_for_initial_ptr (gimple gs)
2771 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
2772 return &gs->gimple_omp_for.initial;
2776 /* Set INITIAL to be the initial value for OMP_FOR GS. */
2778 static inline void
2779 gimple_omp_for_set_initial (gimple gs, tree initial)
2781 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
2782 gs->gimple_omp_for.initial = initial;
2786 /* Return the final value for OMP_FOR GS. */
2788 static inline tree
2789 gimple_omp_for_final (const_gimple gs)
2791 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
2792 return gs->gimple_omp_for.final;
2796 /* Return a pointer to the final value for OMP_FOR GS. */
2798 static inline tree *
2799 gimple_omp_for_final_ptr (gimple gs)
2801 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
2802 return &gs->gimple_omp_for.final;
2806 /* Set FINAL to be the final value for OMP_FOR GS. */
2808 static inline void
2809 gimple_omp_for_set_final (gimple gs, tree final)
2811 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
2812 gs->gimple_omp_for.final = final;
2816 /* Return the increment value for OMP_FOR GS. */
2818 static inline tree
2819 gimple_omp_for_incr (const_gimple gs)
2821 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
2822 return gs->gimple_omp_for.incr;
2826 /* Return a pointer to the increment value for OMP_FOR GS. */
2828 static inline tree *
2829 gimple_omp_for_incr_ptr (gimple gs)
2831 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
2832 return &gs->gimple_omp_for.incr;
2836 /* Set INCR to be the increment value for OMP_FOR GS. */
2838 static inline void
2839 gimple_omp_for_set_incr (gimple gs, tree incr)
2841 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
2842 gs->gimple_omp_for.incr = incr;
2846 /* Return the sequence of statements to execute before the OMP_FOR
2847 statement GS starts. */
2849 static inline gimple_seq
2850 gimple_omp_for_pre_body (gimple gs)
2852 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
2853 return gs->gimple_omp_for.pre_body;
2857 /* Set PRE_BODY to be the sequence of statements to execute before the
2858 OMP_FOR statement GS starts. */
2860 static inline void
2861 gimple_omp_for_set_pre_body (gimple gs, gimple_seq pre_body)
2863 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
2864 gs->gimple_omp_for.pre_body = pre_body;
2868 /* Return the clauses associated with OMP_PARALLEL GS. */
2870 static inline tree
2871 gimple_omp_parallel_clauses (const_gimple gs)
2873 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
2874 return gs->gimple_omp_parallel.clauses;
2878 /* Return a pointer to the clauses associated with OMP_PARALLEL GS. */
2880 static inline tree *
2881 gimple_omp_parallel_clauses_ptr (gimple gs)
2883 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
2884 return &gs->gimple_omp_parallel.clauses;
2888 /* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL
2889 GS. */
2891 static inline void
2892 gimple_omp_parallel_set_clauses (gimple gs, tree clauses)
2894 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
2895 gs->gimple_omp_parallel.clauses = clauses;
2899 /* Return the child function used to hold the body of OMP_PARALLEL GS. */
2901 static inline tree
2902 gimple_omp_parallel_child_fn (const_gimple gs)
2904 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
2905 return gs->gimple_omp_parallel.child_fn;
2908 /* Return a pointer to the child function used to hold the body of
2909 OMP_PARALLEL GS. */
2911 static inline tree *
2912 gimple_omp_parallel_child_fn_ptr (gimple gs)
2914 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
2915 return &gs->gimple_omp_parallel.child_fn;
2919 /* Set CHILD_FN to be the child function for OMP_PARALLEL GS. */
2921 static inline void
2922 gimple_omp_parallel_set_child_fn (gimple gs, tree child_fn)
2924 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
2925 gs->gimple_omp_parallel.child_fn = child_fn;
2929 /* Return the artificial argument used to send variables and values
2930 from the parent to the children threads in OMP_PARALLEL GS. */
2932 static inline tree
2933 gimple_omp_parallel_data_arg (const_gimple gs)
2935 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
2936 return gs->gimple_omp_parallel.data_arg;
2940 /* Return a pointer to the data argument for OMP_PARALLEL GS. */
2942 static inline tree *
2943 gimple_omp_parallel_data_arg_ptr (gimple gs)
2945 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
2946 return &gs->gimple_omp_parallel.data_arg;
2950 /* Set DATA_ARG to be the data argument for OMP_PARALLEL GS. */
2952 static inline void
2953 gimple_omp_parallel_set_data_arg (gimple gs, tree data_arg)
2955 GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
2956 gs->gimple_omp_parallel.data_arg = data_arg;
2960 /* Return the clauses associated with OMP_SINGLE GS. */
2962 static inline tree
2963 gimple_omp_single_clauses (const_gimple gs)
2965 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
2966 return gs->gimple_omp_single.clauses;
2970 /* Return a pointer to the clauses associated with OMP_SINGLE GS. */
2972 static inline tree *
2973 gimple_omp_single_clauses_ptr (gimple gs)
2975 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
2976 return &gs->gimple_omp_single.clauses;
2980 /* Set CLAUSES to be the clauses associated with OMP_SINGLE GS. */
2982 static inline void
2983 gimple_omp_single_set_clauses (gimple gs, tree clauses)
2985 GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
2986 gs->gimple_omp_single.clauses = clauses;
2990 /* Return the clauses associated with OMP_SECTIONS GS. */
2992 static inline tree
2993 gimple_omp_sections_clauses (const_gimple gs)
2995 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
2996 return gs->gimple_omp_sections.clauses;
3000 /* Return a pointer to the clauses associated with OMP_SECTIONS GS. */
3002 static inline tree *
3003 gimple_omp_sections_clauses_ptr (gimple gs)
3005 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3006 return &gs->gimple_omp_sections.clauses;
3010 /* Set CLAUSES to be the set of clauses associated with OMP_SECTIONS
3011 GS. */
3013 static inline void
3014 gimple_omp_sections_set_clauses (gimple gs, tree clauses)
3016 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3017 gs->gimple_omp_sections.clauses = clauses;
3021 /* Return the control variable associated with the GIMPLE_OMP_SECTIONS
3022 in GS. */
3024 static inline tree
3025 gimple_omp_sections_control (const_gimple gs)
3027 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3028 return gs->gimple_omp_sections.control;
3032 /* Return a pointer to the clauses associated with the GIMPLE_OMP_SECTIONS
3033 GS. */
3035 static inline tree *
3036 gimple_omp_sections_control_ptr (gimple gs)
3038 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3039 return &gs->gimple_omp_sections.control;
3043 /* Set CONTROL to be the set of clauses associated with the
3044 GIMPLE_OMP_SECTIONS in GS. */
3046 static inline void
3047 gimple_omp_sections_set_control (gimple gs, tree control)
3049 GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
3050 gs->gimple_omp_sections.control = control;
3054 /* Set COND to be the condition code for OMP_FOR GS. */
3056 static inline void
3057 gimple_omp_for_set_cond (gimple gs, enum tree_code cond)
3059 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3060 gcc_assert (TREE_CODE_CLASS (cond) == tcc_comparison);
3061 gimple_set_subcode (gs, cond);
3065 /* Return the condition code associated with OMP_FOR GS. */
3067 static inline enum tree_code
3068 gimple_omp_for_cond (const_gimple gs)
3070 GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3071 return gimple_subcode (gs);
3075 /* Set the value being stored in an atomic store. */
3077 static inline void
3078 gimple_omp_atomic_store_set_val (gimple g, tree val)
3080 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3081 g->gimple_omp_atomic_store.val = val;
3085 /* Return the value being stored in an atomic store. */
3087 static inline tree
3088 gimple_omp_atomic_store_val (const_gimple g)
3090 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
3091 return g->gimple_omp_atomic_store.val;
3095 /* Set the LHS of an atomic load. */
3097 static inline void
3098 gimple_omp_atomic_load_set_lhs (gimple g, tree lhs)
3100 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
3101 g->gimple_omp_atomic_load.lhs = lhs;
3105 /* Get the LHS of an atomic load. */
3107 static inline tree
3108 gimple_omp_atomic_load_lhs (const_gimple g)
3110 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
3111 return g->gimple_omp_atomic_load.lhs;
3115 /* Set the RHS of an atomic set. */
3117 static inline void
3118 gimple_omp_atomic_load_set_rhs (gimple g, tree rhs)
3120 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
3121 g->gimple_omp_atomic_load.rhs = rhs;
3125 /* Get the RHS of an atomic set. */
3127 static inline tree
3128 gimple_omp_atomic_load_rhs (const_gimple g)
3130 GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
3131 return g->gimple_omp_atomic_load.rhs;
3135 /* Get the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
3137 static inline tree
3138 gimple_omp_continue_control_def (const_gimple g)
3140 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
3141 return g->gimple_omp_continue.control_def;
3144 /* The same as above, but return the address. */
3146 static inline tree *
3147 gimple_omp_continue_control_def_ptr (gimple g)
3149 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
3150 return &g->gimple_omp_continue.control_def;
3153 /* Set the definition of the control variable in a GIMPLE_OMP_CONTINUE. */
3155 static inline void
3156 gimple_omp_continue_set_control_def (gimple g, tree def)
3158 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
3159 g->gimple_omp_continue.control_def = def;
3163 /* Get the use of the control variable in a GIMPLE_OMP_CONTINUE. */
3165 static inline tree
3166 gimple_omp_continue_control_use (const_gimple g)
3168 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
3169 return g->gimple_omp_continue.control_use;
3173 /* The same as above, but return the address. */
3175 static inline tree *
3176 gimple_omp_continue_control_use_ptr (gimple g)
3178 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
3179 return &g->gimple_omp_continue.control_use;
3183 /* Set the use of the control variable in a GIMPLE_OMP_CONTINUE. */
3185 static inline void
3186 gimple_omp_continue_set_control_use (gimple g, tree use)
3188 GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
3189 g->gimple_omp_continue.control_use = use;
3193 /* Return a pointer to the return value for GIMPLE_RETURN GS. */
3195 static inline tree *
3196 gimple_return_retval_ptr (const_gimple gs)
3198 GIMPLE_CHECK (gs, GIMPLE_RETURN);
3199 gcc_assert (gs->with_ops.num_ops == 1);
3200 return gimple_op_ptr (gs, 0);
3203 /* Return the return value for GIMPLE_RETURN GS. */
3205 static inline tree
3206 gimple_return_retval (const_gimple gs)
3208 GIMPLE_CHECK (gs, GIMPLE_RETURN);
3209 gcc_assert (gs->with_ops.num_ops == 1);
3210 return gimple_op (gs, 0);
3214 /* Set RETVAL to be the return value for GIMPLE_RETURN GS. */
3216 static inline void
3217 gimple_return_set_retval (gimple gs, tree retval)
3219 GIMPLE_CHECK (gs, GIMPLE_RETURN);
3220 gcc_assert (gs->with_ops.num_ops == 1);
3221 gcc_assert (retval == NULL_TREE
3222 || TREE_CODE (retval) == RESULT_DECL
3223 || is_gimple_val (retval));
3224 gimple_set_op (gs, 0, retval);
3228 /* Returns true when the gimple statment STMT is any of the OpenMP types. */
3230 static inline bool
3231 is_gimple_omp (const_gimple stmt)
3233 return (gimple_code (stmt) == GIMPLE_OMP_PARALLEL
3234 || gimple_code (stmt) == GIMPLE_OMP_FOR
3235 || gimple_code (stmt) == GIMPLE_OMP_SECTIONS
3236 || gimple_code (stmt) == GIMPLE_OMP_SECTIONS_SWITCH
3237 || gimple_code (stmt) == GIMPLE_OMP_SINGLE
3238 || gimple_code (stmt) == GIMPLE_OMP_SECTION
3239 || gimple_code (stmt) == GIMPLE_OMP_MASTER
3240 || gimple_code (stmt) == GIMPLE_OMP_ORDERED
3241 || gimple_code (stmt) == GIMPLE_OMP_CRITICAL
3242 || gimple_code (stmt) == GIMPLE_OMP_RETURN
3243 || gimple_code (stmt) == OMP_ATOMIC_LOAD
3244 || gimple_code (stmt) == OMP_ATOMIC_STORE
3245 || gimple_code (stmt) == GIMPLE_OMP_CONTINUE);
3249 /* Returns TRUE if statement G is a GIMPLE_NOP. */
3251 static inline bool
3252 gimple_nop_p (const_gimple g)
3254 return gimple_code (g) == GIMPLE_NOP;
3258 /* Return the type of the main expression computed by STMT. Return
3259 void_type_node if the statement computes nothing. */
3261 static inline tree
3262 gimple_expr_type (const_gimple stmt)
3264 if (gimple_num_ops (stmt) > 0)
3265 return TREE_TYPE (gimple_op (stmt, 0));
3266 else
3267 return void_type_node;
3270 /* Return the new type set by GIMPLE_CHANGE_DYNAMIC_TYPE statement GS. */
3272 static inline tree
3273 gimple_cdt_new_type (gimple gs)
3275 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
3276 return gs->gimple_change_dynamic_type.type;
3279 /* Return a pointer to the new type set by GIMPLE_CHANGE_DYNAMIC_TYPE
3280 statement GS. */
3282 static inline tree *
3283 gimple_cdt_new_type_ptr (gimple gs)
3285 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
3286 return &gs->gimple_change_dynamic_type.type;
3289 /* Set NEW_TYPE to be the type returned by GIMPLE_CHANGE_DYNAMIC_TYPE
3290 statement GS. */
3292 static inline void
3293 gimple_cdt_set_new_type (gimple gs, tree new_type)
3295 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
3296 gs->gimple_change_dynamic_type.type = new_type;
3300 /* Return the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE statement GS. */
3302 static inline tree
3303 gimple_cdt_location (gimple gs)
3305 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
3306 return gimple_op (gs, 0);
3310 /* Return a pointer to the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE
3311 statement GS. */
3313 static inline tree *
3314 gimple_cdt_location_ptr (gimple gs)
3316 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
3317 return gimple_op_ptr (gs, 0);
3321 /* Set PTR to be the location affected by GIMPLE_CHANGE_DYNAMIC_TYPE
3322 statement GS. */
3324 static inline void
3325 gimple_cdt_set_location (gimple gs, tree ptr)
3327 GIMPLE_CHECK (gs, GIMPLE_CHANGE_DYNAMIC_TYPE);
3328 gimple_set_op (gs, 0, ptr);
3332 /* Return a new iterator pointing to GIMPLE_SEQ's first statement. */
3334 static inline gimple_stmt_iterator
3335 gsi_start (gimple_seq seq)
3337 gimple_stmt_iterator i;
3339 i.ptr = gimple_seq_first (seq);
3340 i.seq = seq;
3341 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
3343 return i;
3347 /* Return a new iterator pointing to the first statement in basic block BB. */
3349 static inline gimple_stmt_iterator
3350 gsi_start_bb (basic_block bb)
3352 gimple_stmt_iterator i;
3353 gimple_seq seq;
3355 seq = bb_seq (bb);
3356 i.ptr = gimple_seq_first (seq);
3357 i.seq = seq;
3358 i.bb = bb;
3360 return i;
3364 /* Return a new iterator initially pointing to GIMPLE_SEQ's last statement. */
3366 static inline gimple_stmt_iterator
3367 gsi_last (gimple_seq seq)
3369 gimple_stmt_iterator i;
3371 i.ptr = gimple_seq_last (seq);
3372 i.seq = seq;
3373 i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
3375 return i;
3379 /* Return a new iterator pointing to the last statement in basic block BB. */
3381 static inline gimple_stmt_iterator
3382 gsi_last_bb (basic_block bb)
3384 gimple_stmt_iterator i;
3385 gimple_seq seq;
3387 seq = bb_seq (bb);
3388 i.ptr = gimple_seq_last (seq);
3389 i.seq = seq;
3390 i.bb = bb;
3392 return i;
3396 /* Return true if I is at the end of its sequence. */
3398 static inline bool
3399 gsi_end_p (gimple_stmt_iterator i)
3401 return i.ptr == NULL;
3405 /* Return true if I is one statement before the end of its sequence. */
3407 static inline bool
3408 gsi_one_before_end_p (gimple_stmt_iterator i)
3410 return i.ptr != NULL && i.ptr->next == NULL;
3414 /* Advance the iterator to the next gimple statement. */
3416 static inline void
3417 gsi_next (gimple_stmt_iterator *i)
3419 i->ptr = i->ptr->next;
3422 /* Advance the iterator to the previous gimple statement. */
3424 static inline void
3425 gsi_prev (gimple_stmt_iterator *i)
3427 i->ptr = i->ptr->prev;
3430 /* Return the current stmt. */
3432 static inline gimple
3433 gsi_stmt (gimple_stmt_iterator i)
3435 return i.ptr->stmt;
3438 /* Return a block statement iterator that points to the first non-label
3439 statement in block BB. */
3441 static inline gimple_stmt_iterator
3442 gsi_after_labels (basic_block bb)
3444 gimple_stmt_iterator gsi = gsi_start_bb (bb);
3446 while (!gsi_end_p (gsi) && gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL)
3447 gsi_next (&gsi);
3449 return gsi;
3452 /* Return a pointer to the current stmt.
3454 NOTE: You may want to use gsi_replace on the iterator itself,
3455 as this performs additional bookkeeping that will not be done
3456 if you simply assign through a pointer returned by gsi_stmt_ptr. */
3458 static inline gimple *
3459 gsi_stmt_ptr (gimple_stmt_iterator *i)
3461 return &i->ptr->stmt;
3465 /* Return the basic block associated with this iterator. */
3467 static inline basic_block
3468 gsi_bb (gimple_stmt_iterator i)
3470 return i.bb;
3474 /* Return the sequence associated with this iterator. */
3476 static inline gimple_seq
3477 gsi_seq (gimple_stmt_iterator i)
3479 return i.seq;
3483 enum gsi_iterator_update
3485 GSI_NEW_STMT, /* Only valid when single statement is added, move
3486 iterator to it. */
3487 GSI_SAME_STMT, /* Leave the iterator at the same statement. */
3488 GSI_CONTINUE_LINKING /* Move iterator to whatever position is suitable
3489 for linking other statements in the same
3490 direction. */
3493 /* In gimple-iterator.c */
3494 gimple_stmt_iterator gsi_start_phis (basic_block);
3495 gimple_seq gsi_split_seq_after (gimple_stmt_iterator);
3496 gimple_seq gsi_split_seq_before (gimple_stmt_iterator *);
3497 void gsi_replace (gimple_stmt_iterator *, gimple, bool);
3498 void gsi_insert_before (gimple_stmt_iterator *, gimple,
3499 enum gsi_iterator_update);
3500 void gsi_insert_before_without_update (gimple_stmt_iterator *, gimple,
3501 enum gsi_iterator_update);
3502 void gsi_insert_seq_before (gimple_stmt_iterator *, gimple_seq,
3503 enum gsi_iterator_update);
3504 void gsi_insert_seq_before_without_update (gimple_stmt_iterator *, gimple_seq,
3505 enum gsi_iterator_update);
3506 void gsi_insert_after (gimple_stmt_iterator *, gimple,
3507 enum gsi_iterator_update);
3508 void gsi_insert_after_without_update (gimple_stmt_iterator *, gimple,
3509 enum gsi_iterator_update);
3510 void gsi_insert_seq_after (gimple_stmt_iterator *, gimple_seq,
3511 enum gsi_iterator_update);
3512 void gsi_insert_seq_after_without_update (gimple_stmt_iterator *, gimple_seq,
3513 enum gsi_iterator_update);
3514 void gsi_remove (gimple_stmt_iterator *, bool);
3515 gimple_stmt_iterator gsi_for_stmt (gimple);
3516 void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *);
3517 void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *);
3518 void gsi_move_to_bb_end (gimple_stmt_iterator *, struct basic_block_def *);
3519 void gsi_insert_on_edge (edge, gimple);
3520 void gsi_insert_seq_on_edge (edge, gimple_seq);
3521 basic_block gsi_insert_on_edge_immediate (edge, gimple);
3522 basic_block gsi_insert_seq_on_edge_immediate (edge, gimple_seq);
3523 void gsi_commit_one_edge_insert (edge, basic_block *);
3524 void gsi_commit_edge_inserts (void);
3527 /* Convenience routines to walk all statements of a gimple function.
3528 Note that this is useful exclusively before the code is converted
3529 into SSA form. Once the program is in SSA form, the standard
3530 operand interface should be used to analyze/modify statements. */
3531 struct walk_stmt_info
3533 /* Points to the current statement being walked. */
3534 gimple_stmt_iterator gsi;
3536 /* Additional data that the callback functions may want to carry
3537 through the recursion. */
3538 void *info;
3540 /* Pointer map used to mark visited tree nodes when calling
3541 walk_tree on each operand. If set to NULL, duplicate tree nodes
3542 will be visited more than once. */
3543 struct pointer_set_t *pset;
3545 /* Indicates whether the operand being examined may be replaced
3546 with something that matches is_gimple_val (if true) or something
3547 slightly more complicated (if false). "Something" technically
3548 means the common subset of is_gimple_lvalue and is_gimple_rhs,
3549 but we never try to form anything more complicated than that, so
3550 we don't bother checking.
3552 Also note that CALLBACK should update this flag while walking the
3553 sub-expressions of a statement. For instance, when walking the
3554 statement 'foo (&var)', the flag VAL_ONLY will initially be set
3555 to true, however, when walking &var, the operand of that
3556 ADDR_EXPR does not need to be a GIMPLE value. */
3557 bool val_only;
3559 /* True if we are currently walking the LHS of an assignment. */
3560 bool is_lhs;
3562 /* Optional. Set to true by the callback functions if they made any
3563 changes. */
3564 bool changed;
3566 /* True if we're interested in location information. */
3567 bool want_locations;
3569 /* Operand returned by the callbacks. This is set when calling
3570 walk_gimple_seq. If the walk_stmt_fn or walk_tree_fn callback
3571 returns non-NULL, this field will contain the tree returned by
3572 the last callback. */
3573 tree callback_result;
3576 /* Callback for walk_gimple_stmt. Called for every statement found
3577 during traversal. The first argument points to the statement to
3578 walk. The second argument is a flag that the callback sets to
3579 'true' if it the callback handled all the operands and
3580 sub-statements of the statement (the default value of this flag is
3581 'false'). The third argument is an anonymous pointer to data
3582 to be used by the callback. */
3583 typedef tree (*walk_stmt_fn) (gimple_stmt_iterator *, bool *,
3584 struct walk_stmt_info *);
3586 gimple walk_gimple_seq (gimple_seq, walk_stmt_fn, walk_tree_fn,
3587 struct walk_stmt_info *);
3588 tree walk_gimple_stmt (gimple_stmt_iterator *, walk_stmt_fn, walk_tree_fn,
3589 struct walk_stmt_info *);
3590 tree walk_gimple_op (gimple, walk_tree_fn, struct walk_stmt_info *);
3592 #ifdef GATHER_STATISTICS
3593 /* Enum and arrays used for allocation stats. Keep in sync with
3594 gimple.c:gimple_alloc_kind_names. */
3595 enum gimple_alloc_kind
3597 gimple_alloc_kind_assign, /* Assignments. */
3598 gimple_alloc_kind_phi, /* PHI nodes. */
3599 gimple_alloc_kind_cond, /* Conditionals. */
3600 gimple_alloc_kind_seq, /* Sequences. */
3601 gimple_alloc_kind_rest, /* Everything else. */
3602 gimple_alloc_kind_all
3605 extern int gimple_alloc_counts[];
3606 extern int gimple_alloc_sizes[];
3608 /* Return the allocation kind for a given stmt CODE. */
3609 static inline enum gimple_alloc_kind
3610 gimple_alloc_kind (enum gimple_code code)
3612 switch (code)
3614 case GIMPLE_ASSIGN:
3615 return gimple_alloc_kind_assign;
3616 case GIMPLE_PHI:
3617 return gimple_alloc_kind_phi;
3618 case GIMPLE_COND:
3619 return gimple_alloc_kind_cond;
3620 default:
3621 return gimple_alloc_kind_rest;
3624 #endif /* GATHER_STATISTICS */
3626 extern void dump_gimple_statistics (void);
3628 #endif /* GCC_GIMPLE_H */