OSDN Git Service

2011-04-19 Martin Jambor <mjambor@suse.cz>
[pf3gnuchains/gcc-fork.git] / gcc / gimple.h
1 /* Gimple IR definitions.
2
3    Copyright 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
4    Contributed by Aldy Hernandez <aldyh@redhat.com>
5
6 This file is part of GCC.
7
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.
12
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.
17
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/>.  */
21
22 #ifndef GCC_GIMPLE_H
23 #define GCC_GIMPLE_H
24
25 #include "pointer-set.h"
26 #include "vec.h"
27 #include "vecprim.h"
28 #include "vecir.h"
29 #include "ggc.h"
30 #include "basic-block.h"
31 #include "tree-ssa-operands.h"
32 #include "tree-ssa-alias.h"
33
34 struct gimple_seq_node_d;
35 typedef struct gimple_seq_node_d *gimple_seq_node;
36 typedef const struct gimple_seq_node_d *const_gimple_seq_node;
37
38 /* For each block, the PHI nodes that need to be rewritten are stored into
39    these vectors.  */
40 typedef VEC(gimple, heap) *gimple_vec;
41 DEF_VEC_P (gimple_vec);
42 DEF_VEC_ALLOC_P (gimple_vec, heap);
43
44 enum gimple_code {
45 #define DEFGSCODE(SYM, STRING, STRUCT)  SYM,
46 #include "gimple.def"
47 #undef DEFGSCODE
48     LAST_AND_UNUSED_GIMPLE_CODE
49 };
50
51 extern const char *const gimple_code_name[];
52 extern const unsigned char gimple_rhs_class_table[];
53
54 /* Error out if a gimple tuple is addressed incorrectly.  */
55 #if defined ENABLE_GIMPLE_CHECKING
56 #define gcc_gimple_checking_assert(EXPR) gcc_assert (EXPR)
57 extern void gimple_check_failed (const_gimple, const char *, int,          \
58                                  const char *, enum gimple_code,           \
59                                  enum tree_code) ATTRIBUTE_NORETURN;
60
61 #define GIMPLE_CHECK(GS, CODE)                                          \
62   do {                                                                  \
63     const_gimple __gs = (GS);                                           \
64     if (gimple_code (__gs) != (CODE))                                   \
65       gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__,      \
66                            (CODE), ERROR_MARK);                         \
67   } while (0)
68 #else  /* not ENABLE_GIMPLE_CHECKING  */
69 #define gcc_gimple_checking_assert(EXPR) ((void)(0 && (EXPR)))
70 #define GIMPLE_CHECK(GS, CODE)                  (void)0
71 #endif
72
73 /* Class of GIMPLE expressions suitable for the RHS of assignments.  See
74    get_gimple_rhs_class.  */
75 enum gimple_rhs_class
76 {
77   GIMPLE_INVALID_RHS,   /* The expression cannot be used on the RHS.  */
78   GIMPLE_TERNARY_RHS,   /* The expression is a ternary operation.  */
79   GIMPLE_BINARY_RHS,    /* The expression is a binary operation.  */
80   GIMPLE_UNARY_RHS,     /* The expression is a unary operation.  */
81   GIMPLE_SINGLE_RHS     /* The expression is a single object (an SSA
82                            name, a _DECL, a _REF, etc.  */
83 };
84
85 /* Specific flags for individual GIMPLE statements.  These flags are
86    always stored in gimple_statement_base.subcode and they may only be
87    defined for statement codes that do not use sub-codes.
88
89    Values for the masks can overlap as long as the overlapping values
90    are never used in the same statement class.
91
92    The maximum mask value that can be defined is 1 << 15 (i.e., each
93    statement code can hold up to 16 bitflags).
94
95    Keep this list sorted.  */
96 enum gf_mask {
97     GF_ASM_INPUT                = 1 << 0,
98     GF_ASM_VOLATILE             = 1 << 1,
99     GF_CALL_CANNOT_INLINE       = 1 << 0,
100     GF_CALL_FROM_THUNK          = 1 << 1,
101     GF_CALL_RETURN_SLOT_OPT     = 1 << 2,
102     GF_CALL_TAILCALL            = 1 << 3,
103     GF_CALL_VA_ARG_PACK         = 1 << 4,
104     GF_CALL_NOTHROW             = 1 << 5,
105     GF_CALL_ALLOCA_FOR_VAR      = 1 << 6,
106     GF_OMP_PARALLEL_COMBINED    = 1 << 0,
107
108     /* True on an GIMPLE_OMP_RETURN statement if the return does not require
109        a thread synchronization via some sort of barrier.  The exact barrier
110        that would otherwise be emitted is dependent on the OMP statement with
111        which this return is associated.  */
112     GF_OMP_RETURN_NOWAIT        = 1 << 0,
113
114     GF_OMP_SECTION_LAST         = 1 << 0,
115     GF_PREDICT_TAKEN            = 1 << 15
116 };
117
118 /* Currently, there's only one type of gimple debug stmt.  Others are
119    envisioned, for example, to enable the generation of is_stmt notes
120    in line number information, to mark sequence points, etc.  This
121    subcode is to be used to tell them apart.  */
122 enum gimple_debug_subcode {
123   GIMPLE_DEBUG_BIND = 0
124 };
125
126 /* Masks for selecting a pass local flag (PLF) to work on.  These
127    masks are used by gimple_set_plf and gimple_plf.  */
128 enum plf_mask {
129     GF_PLF_1    = 1 << 0,
130     GF_PLF_2    = 1 << 1
131 };
132
133 /* A node in a gimple_seq_d.  */
134 struct GTY((chain_next ("%h.next"), chain_prev ("%h.prev"))) gimple_seq_node_d {
135   gimple stmt;
136   struct gimple_seq_node_d *prev;
137   struct gimple_seq_node_d *next;
138 };
139
140 /* A double-linked sequence of gimple statements.  */
141 struct GTY ((chain_next ("%h.next_free"))) gimple_seq_d {
142   /* First and last statements in the sequence.  */
143   gimple_seq_node first;
144   gimple_seq_node last;
145
146   /* Sequences are created/destroyed frequently.  To minimize
147      allocation activity, deallocated sequences are kept in a pool of
148      available sequences.  This is the pointer to the next free
149      sequence in the pool.  */
150   gimple_seq next_free;
151 };
152
153
154 /* Return the first node in GIMPLE sequence S.  */
155
156 static inline gimple_seq_node
157 gimple_seq_first (const_gimple_seq s)
158 {
159   return s ? s->first : NULL;
160 }
161
162
163 /* Return the first statement in GIMPLE sequence S.  */
164
165 static inline gimple
166 gimple_seq_first_stmt (const_gimple_seq s)
167 {
168   gimple_seq_node n = gimple_seq_first (s);
169   return (n) ? n->stmt : NULL;
170 }
171
172
173 /* Return the last node in GIMPLE sequence S.  */
174
175 static inline gimple_seq_node
176 gimple_seq_last (const_gimple_seq s)
177 {
178   return s ? s->last : NULL;
179 }
180
181
182 /* Return the last statement in GIMPLE sequence S.  */
183
184 static inline gimple
185 gimple_seq_last_stmt (const_gimple_seq s)
186 {
187   gimple_seq_node n = gimple_seq_last (s);
188   return (n) ? n->stmt : NULL;
189 }
190
191
192 /* Set the last node in GIMPLE sequence S to LAST.  */
193
194 static inline void
195 gimple_seq_set_last (gimple_seq s, gimple_seq_node last)
196 {
197   s->last = last;
198 }
199
200
201 /* Set the first node in GIMPLE sequence S to FIRST.  */
202
203 static inline void
204 gimple_seq_set_first (gimple_seq s, gimple_seq_node first)
205 {
206   s->first = first;
207 }
208
209
210 /* Return true if GIMPLE sequence S is empty.  */
211
212 static inline bool
213 gimple_seq_empty_p (const_gimple_seq s)
214 {
215   return s == NULL || s->first == NULL;
216 }
217
218
219 void gimple_seq_add_stmt (gimple_seq *, gimple);
220
221 /* Link gimple statement GS to the end of the sequence *SEQ_P.  If
222    *SEQ_P is NULL, a new sequence is allocated.  This function is
223    similar to gimple_seq_add_stmt, but does not scan the operands.
224    During gimplification, we need to manipulate statement sequences
225    before the def/use vectors have been constructed.  */
226 void gimplify_seq_add_stmt (gimple_seq *, gimple);
227
228 /* Allocate a new sequence and initialize its first element with STMT.  */
229
230 static inline gimple_seq
231 gimple_seq_alloc_with_stmt (gimple stmt)
232 {
233   gimple_seq seq = NULL;
234   gimple_seq_add_stmt (&seq, stmt);
235   return seq;
236 }
237
238
239 /* Returns the sequence of statements in BB.  */
240
241 static inline gimple_seq
242 bb_seq (const_basic_block bb)
243 {
244   return (!(bb->flags & BB_RTL) && bb->il.gimple) ? bb->il.gimple->seq : NULL;
245 }
246
247
248 /* Sets the sequence of statements in BB to SEQ.  */
249
250 static inline void
251 set_bb_seq (basic_block bb, gimple_seq seq)
252 {
253   gcc_checking_assert (!(bb->flags & BB_RTL));
254   bb->il.gimple->seq = seq;
255 }
256
257 /* Iterator object for GIMPLE statement sequences.  */
258
259 typedef struct
260 {
261   /* Sequence node holding the current statement.  */
262   gimple_seq_node ptr;
263
264   /* Sequence and basic block holding the statement.  These fields
265      are necessary to handle edge cases such as when statement is
266      added to an empty basic block or when the last statement of a
267      block/sequence is removed.  */
268   gimple_seq seq;
269   basic_block bb;
270 } gimple_stmt_iterator;
271
272
273 /* Data structure definitions for GIMPLE tuples.  NOTE: word markers
274    are for 64 bit hosts.  */
275
276 struct GTY(()) gimple_statement_base {
277   /* [ WORD 1 ]
278      Main identifying code for a tuple.  */
279   ENUM_BITFIELD(gimple_code) code : 8;
280
281   /* Nonzero if a warning should not be emitted on this tuple.  */
282   unsigned int no_warning       : 1;
283
284   /* Nonzero if this tuple has been visited.  Passes are responsible
285      for clearing this bit before using it.  */
286   unsigned int visited          : 1;
287
288   /* Nonzero if this tuple represents a non-temporal move.  */
289   unsigned int nontemporal_move : 1;
290
291   /* Pass local flags.  These flags are free for any pass to use as
292      they see fit.  Passes should not assume that these flags contain
293      any useful value when the pass starts.  Any initial state that
294      the pass requires should be set on entry to the pass.  See
295      gimple_set_plf and gimple_plf for usage.  */
296   unsigned int plf              : 2;
297
298   /* Nonzero if this statement has been modified and needs to have its
299      operands rescanned.  */
300   unsigned modified             : 1;
301
302   /* Nonzero if this statement contains volatile operands.  */
303   unsigned has_volatile_ops     : 1;
304
305   /* Padding to get subcode to 16 bit alignment.  */
306   unsigned pad                  : 1;
307
308   /* The SUBCODE field can be used for tuple-specific flags for tuples
309      that do not require subcodes.  Note that SUBCODE should be at
310      least as wide as tree codes, as several tuples store tree codes
311      in there.  */
312   unsigned int subcode          : 16;
313
314   /* UID of this statement.  This is used by passes that want to
315      assign IDs to statements.  It must be assigned and used by each
316      pass.  By default it should be assumed to contain garbage.  */
317   unsigned uid;
318
319   /* [ WORD 2 ]
320      Locus information for debug info.  */
321   location_t location;
322
323   /* Number of operands in this tuple.  */
324   unsigned num_ops;
325
326   /* [ WORD 3 ]
327      Basic block holding this statement.  */
328   struct basic_block_def *bb;
329
330   /* [ WORD 4 ]
331      Lexical block holding this statement.  */
332   tree block;
333 };
334
335
336 /* Base structure for tuples with operands.  */
337
338 struct GTY(()) gimple_statement_with_ops_base
339 {
340   /* [ WORD 1-4 ]  */
341   struct gimple_statement_base gsbase;
342
343   /* [ WORD 5-6 ]
344      SSA operand vectors.  NOTE: It should be possible to
345      amalgamate these vectors with the operand vector OP.  However,
346      the SSA operand vectors are organized differently and contain
347      more information (like immediate use chaining).  */
348   struct def_optype_d GTY((skip (""))) *def_ops;
349   struct use_optype_d GTY((skip (""))) *use_ops;
350 };
351
352
353 /* Statements that take register operands.  */
354
355 struct GTY(()) gimple_statement_with_ops
356 {
357   /* [ WORD 1-6 ]  */
358   struct gimple_statement_with_ops_base opbase;
359
360   /* [ WORD 7 ]
361      Operand vector.  NOTE!  This must always be the last field
362      of this structure.  In particular, this means that this
363      structure cannot be embedded inside another one.  */
364   tree GTY((length ("%h.opbase.gsbase.num_ops"))) op[1];
365 };
366
367
368 /* Base for statements that take both memory and register operands.  */
369
370 struct GTY(()) gimple_statement_with_memory_ops_base
371 {
372   /* [ WORD 1-6 ]  */
373   struct gimple_statement_with_ops_base opbase;
374
375   /* [ WORD 7-8 ]
376      Virtual operands for this statement.  The GC will pick them
377      up via the ssa_names array.  */
378   tree GTY((skip (""))) vdef;
379   tree GTY((skip (""))) vuse;
380 };
381
382
383 /* Statements that take both memory and register operands.  */
384
385 struct GTY(()) gimple_statement_with_memory_ops
386 {
387   /* [ WORD 1-8 ]  */
388   struct gimple_statement_with_memory_ops_base membase;
389
390   /* [ WORD 9 ]
391      Operand vector.  NOTE!  This must always be the last field
392      of this structure.  In particular, this means that this
393      structure cannot be embedded inside another one.  */
394   tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
395 };
396
397
398 /* Call statements that take both memory and register operands.  */
399
400 struct GTY(()) gimple_statement_call
401 {
402   /* [ WORD 1-8 ]  */
403   struct gimple_statement_with_memory_ops_base membase;
404
405   /* [ WORD 9-12 ]  */
406   struct pt_solution call_used;
407   struct pt_solution call_clobbered;
408
409   /* [ WORD 13 ]  */
410   tree fntype;
411
412   /* [ WORD 14 ]
413      Operand vector.  NOTE!  This must always be the last field
414      of this structure.  In particular, this means that this
415      structure cannot be embedded inside another one.  */
416   tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
417 };
418
419
420 /* OpenMP statements (#pragma omp).  */
421
422 struct GTY(()) gimple_statement_omp {
423   /* [ WORD 1-4 ]  */
424   struct gimple_statement_base gsbase;
425
426   /* [ WORD 5 ]  */
427   gimple_seq body;
428 };
429
430
431 /* GIMPLE_BIND */
432
433 struct GTY(()) gimple_statement_bind {
434   /* [ WORD 1-4 ]  */
435   struct gimple_statement_base gsbase;
436
437   /* [ WORD 5 ]
438      Variables declared in this scope.  */
439   tree vars;
440
441   /* [ WORD 6 ]
442      This is different than the BLOCK field in gimple_statement_base,
443      which is analogous to TREE_BLOCK (i.e., the lexical block holding
444      this statement).  This field is the equivalent of BIND_EXPR_BLOCK
445      in tree land (i.e., the lexical scope defined by this bind).  See
446      gimple-low.c.  */
447   tree block;
448
449   /* [ WORD 7 ]  */
450   gimple_seq body;
451 };
452
453
454 /* GIMPLE_CATCH */
455
456 struct GTY(()) gimple_statement_catch {
457   /* [ WORD 1-4 ]  */
458   struct gimple_statement_base gsbase;
459
460   /* [ WORD 5 ]  */
461   tree types;
462
463   /* [ WORD 6 ]  */
464   gimple_seq handler;
465 };
466
467
468 /* GIMPLE_EH_FILTER */
469
470 struct GTY(()) gimple_statement_eh_filter {
471   /* [ WORD 1-4 ]  */
472   struct gimple_statement_base gsbase;
473
474   /* [ WORD 5 ]
475      Filter types.  */
476   tree types;
477
478   /* [ WORD 6 ]
479      Failure actions.  */
480   gimple_seq failure;
481 };
482
483
484 /* GIMPLE_EH_MUST_NOT_THROW */
485
486 struct GTY(()) gimple_statement_eh_mnt {
487   /* [ WORD 1-4 ]  */
488   struct gimple_statement_base gsbase;
489
490   /* [ WORD 5 ] Abort function decl.  */
491   tree fndecl;
492 };
493
494 /* GIMPLE_PHI */
495
496 struct GTY(()) gimple_statement_phi {
497   /* [ WORD 1-4 ]  */
498   struct gimple_statement_base gsbase;
499
500   /* [ WORD 5 ]  */
501   unsigned capacity;
502   unsigned nargs;
503
504   /* [ WORD 6 ]  */
505   tree result;
506
507   /* [ WORD 7 ]  */
508   struct phi_arg_d GTY ((length ("%h.nargs"))) args[1];
509 };
510
511
512 /* GIMPLE_RESX, GIMPLE_EH_DISPATCH */
513
514 struct GTY(()) gimple_statement_eh_ctrl
515 {
516   /* [ WORD 1-4 ]  */
517   struct gimple_statement_base gsbase;
518
519   /* [ WORD 5 ]
520      Exception region number.  */
521   int region;
522 };
523
524
525 /* GIMPLE_TRY */
526
527 struct GTY(()) gimple_statement_try {
528   /* [ WORD 1-4 ]  */
529   struct gimple_statement_base gsbase;
530
531   /* [ WORD 5 ]
532      Expression to evaluate.  */
533   gimple_seq eval;
534
535   /* [ WORD 6 ]
536      Cleanup expression.  */
537   gimple_seq cleanup;
538 };
539
540 /* Kind of GIMPLE_TRY statements.  */
541 enum gimple_try_flags
542 {
543   /* A try/catch.  */
544   GIMPLE_TRY_CATCH = 1 << 0,
545
546   /* A try/finally.  */
547   GIMPLE_TRY_FINALLY = 1 << 1,
548   GIMPLE_TRY_KIND = GIMPLE_TRY_CATCH | GIMPLE_TRY_FINALLY,
549
550   /* Analogous to TRY_CATCH_IS_CLEANUP.  */
551   GIMPLE_TRY_CATCH_IS_CLEANUP = 1 << 2
552 };
553
554 /* GIMPLE_WITH_CLEANUP_EXPR */
555
556 struct GTY(()) gimple_statement_wce {
557   /* [ WORD 1-4 ]  */
558   struct gimple_statement_base gsbase;
559
560   /* Subcode: CLEANUP_EH_ONLY.  True if the cleanup should only be
561               executed if an exception is thrown, not on normal exit of its
562               scope.  This flag is analogous to the CLEANUP_EH_ONLY flag
563               in TARGET_EXPRs.  */
564
565   /* [ WORD 5 ]
566      Cleanup expression.  */
567   gimple_seq cleanup;
568 };
569
570
571 /* GIMPLE_ASM  */
572
573 struct GTY(()) gimple_statement_asm
574 {
575   /* [ WORD 1-8 ]  */
576   struct gimple_statement_with_memory_ops_base membase;
577
578   /* [ WORD 9 ]
579      __asm__ statement.  */
580   const char *string;
581
582   /* [ WORD 10 ]
583        Number of inputs, outputs, clobbers, labels.  */
584   unsigned char ni;
585   unsigned char no;
586   unsigned char nc;
587   unsigned char nl;
588
589   /* [ WORD 11 ]
590      Operand vector.  NOTE!  This must always be the last field
591      of this structure.  In particular, this means that this
592      structure cannot be embedded inside another one.  */
593   tree GTY((length ("%h.membase.opbase.gsbase.num_ops"))) op[1];
594 };
595
596 /* GIMPLE_OMP_CRITICAL */
597
598 struct GTY(()) gimple_statement_omp_critical {
599   /* [ WORD 1-5 ]  */
600   struct gimple_statement_omp omp;
601
602   /* [ WORD 6 ]
603      Critical section name.  */
604   tree name;
605 };
606
607
608 struct GTY(()) gimple_omp_for_iter {
609   /* Condition code.  */
610   enum tree_code cond;
611
612   /* Index variable.  */
613   tree index;
614
615   /* Initial value.  */
616   tree initial;
617
618   /* Final value.  */
619   tree final;
620
621   /* Increment.  */
622   tree incr;
623 };
624
625 /* GIMPLE_OMP_FOR */
626
627 struct GTY(()) gimple_statement_omp_for {
628   /* [ WORD 1-5 ]  */
629   struct gimple_statement_omp omp;
630
631   /* [ WORD 6 ]  */
632   tree clauses;
633
634   /* [ WORD 7 ]
635      Number of elements in iter array.  */
636   size_t collapse;
637
638   /* [ WORD 8 ]  */
639   struct gimple_omp_for_iter * GTY((length ("%h.collapse"))) iter;
640
641   /* [ WORD 9 ]
642      Pre-body evaluated before the loop body begins.  */
643   gimple_seq pre_body;
644 };
645
646
647 /* GIMPLE_OMP_PARALLEL */
648
649 struct GTY(()) gimple_statement_omp_parallel {
650   /* [ WORD 1-5 ]  */
651   struct gimple_statement_omp omp;
652
653   /* [ WORD 6 ]
654      Clauses.  */
655   tree clauses;
656
657   /* [ WORD 7 ]
658      Child function holding the body of the parallel region.  */
659   tree child_fn;
660
661   /* [ WORD 8 ]
662      Shared data argument.  */
663   tree data_arg;
664 };
665
666
667 /* GIMPLE_OMP_TASK */
668
669 struct GTY(()) gimple_statement_omp_task {
670   /* [ WORD 1-8 ]  */
671   struct gimple_statement_omp_parallel par;
672
673   /* [ WORD 9 ]
674      Child function holding firstprivate initialization if needed.  */
675   tree copy_fn;
676
677   /* [ WORD 10-11 ]
678      Size and alignment in bytes of the argument data block.  */
679   tree arg_size;
680   tree arg_align;
681 };
682
683
684 /* GIMPLE_OMP_SECTION */
685 /* Uses struct gimple_statement_omp.  */
686
687
688 /* GIMPLE_OMP_SECTIONS */
689
690 struct GTY(()) gimple_statement_omp_sections {
691   /* [ WORD 1-5 ]  */
692   struct gimple_statement_omp omp;
693
694   /* [ WORD 6 ]  */
695   tree clauses;
696
697   /* [ WORD 7 ]
698      The control variable used for deciding which of the sections to
699      execute.  */
700   tree control;
701 };
702
703 /* GIMPLE_OMP_CONTINUE.
704
705    Note: This does not inherit from gimple_statement_omp, because we
706          do not need the body field.  */
707
708 struct GTY(()) gimple_statement_omp_continue {
709   /* [ WORD 1-4 ]  */
710   struct gimple_statement_base gsbase;
711
712   /* [ WORD 5 ]  */
713   tree control_def;
714
715   /* [ WORD 6 ]  */
716   tree control_use;
717 };
718
719 /* GIMPLE_OMP_SINGLE */
720
721 struct GTY(()) gimple_statement_omp_single {
722   /* [ WORD 1-5 ]  */
723   struct gimple_statement_omp omp;
724
725   /* [ WORD 6 ]  */
726   tree clauses;
727 };
728
729
730 /* GIMPLE_OMP_ATOMIC_LOAD.
731    Note: This is based on gimple_statement_base, not g_s_omp, because g_s_omp
732    contains a sequence, which we don't need here.  */
733
734 struct GTY(()) gimple_statement_omp_atomic_load {
735   /* [ WORD 1-4 ]  */
736   struct gimple_statement_base gsbase;
737
738   /* [ WORD 5-6 ]  */
739   tree rhs, lhs;
740 };
741
742 /* GIMPLE_OMP_ATOMIC_STORE.
743    See note on GIMPLE_OMP_ATOMIC_LOAD.  */
744
745 struct GTY(()) gimple_statement_omp_atomic_store {
746   /* [ WORD 1-4 ]  */
747   struct gimple_statement_base gsbase;
748
749   /* [ WORD 5 ]  */
750   tree val;
751 };
752
753 #define DEFGSSTRUCT(SYM, STRUCT, HAS_TREE_OP)   SYM,
754 enum gimple_statement_structure_enum {
755 #include "gsstruct.def"
756     LAST_GSS_ENUM
757 };
758 #undef DEFGSSTRUCT
759
760
761 /* Define the overall contents of a gimple tuple.  It may be any of the
762    structures declared above for various types of tuples.  */
763
764 union GTY ((desc ("gimple_statement_structure (&%h)"), variable_size)) gimple_statement_d {
765   struct gimple_statement_base GTY ((tag ("GSS_BASE"))) gsbase;
766   struct gimple_statement_with_ops GTY ((tag ("GSS_WITH_OPS"))) gsops;
767   struct gimple_statement_with_memory_ops_base GTY ((tag ("GSS_WITH_MEM_OPS_BASE"))) gsmembase;
768   struct gimple_statement_with_memory_ops GTY ((tag ("GSS_WITH_MEM_OPS"))) gsmem;
769   struct gimple_statement_call GTY ((tag ("GSS_CALL"))) gimple_call;
770   struct gimple_statement_omp GTY ((tag ("GSS_OMP"))) omp;
771   struct gimple_statement_bind GTY ((tag ("GSS_BIND"))) gimple_bind;
772   struct gimple_statement_catch GTY ((tag ("GSS_CATCH"))) gimple_catch;
773   struct gimple_statement_eh_filter GTY ((tag ("GSS_EH_FILTER"))) gimple_eh_filter;
774   struct gimple_statement_eh_mnt GTY ((tag ("GSS_EH_MNT"))) gimple_eh_mnt;
775   struct gimple_statement_phi GTY ((tag ("GSS_PHI"))) gimple_phi;
776   struct gimple_statement_eh_ctrl GTY ((tag ("GSS_EH_CTRL"))) gimple_eh_ctrl;
777   struct gimple_statement_try GTY ((tag ("GSS_TRY"))) gimple_try;
778   struct gimple_statement_wce GTY ((tag ("GSS_WCE"))) gimple_wce;
779   struct gimple_statement_asm GTY ((tag ("GSS_ASM"))) gimple_asm;
780   struct gimple_statement_omp_critical GTY ((tag ("GSS_OMP_CRITICAL"))) gimple_omp_critical;
781   struct gimple_statement_omp_for GTY ((tag ("GSS_OMP_FOR"))) gimple_omp_for;
782   struct gimple_statement_omp_parallel GTY ((tag ("GSS_OMP_PARALLEL"))) gimple_omp_parallel;
783   struct gimple_statement_omp_task GTY ((tag ("GSS_OMP_TASK"))) gimple_omp_task;
784   struct gimple_statement_omp_sections GTY ((tag ("GSS_OMP_SECTIONS"))) gimple_omp_sections;
785   struct gimple_statement_omp_single GTY ((tag ("GSS_OMP_SINGLE"))) gimple_omp_single;
786   struct gimple_statement_omp_continue GTY ((tag ("GSS_OMP_CONTINUE"))) gimple_omp_continue;
787   struct gimple_statement_omp_atomic_load GTY ((tag ("GSS_OMP_ATOMIC_LOAD"))) gimple_omp_atomic_load;
788   struct gimple_statement_omp_atomic_store GTY ((tag ("GSS_OMP_ATOMIC_STORE"))) gimple_omp_atomic_store;
789 };
790
791 /* In gimple.c.  */
792
793 /* Offset in bytes to the location of the operand vector.
794    Zero if there is no operand vector for this tuple structure.  */
795 extern size_t const gimple_ops_offset_[];
796
797 /* Map GIMPLE codes to GSS codes.  */
798 extern enum gimple_statement_structure_enum const gss_for_code_[];
799
800 /* This variable holds the currently expanded gimple statement for purposes
801    of comminucating the profile info to the builtin expanders.  */
802 extern gimple currently_expanding_gimple_stmt;
803
804 gimple gimple_build_return (tree);
805
806 gimple gimple_build_assign_stat (tree, tree MEM_STAT_DECL);
807 #define gimple_build_assign(l,r) gimple_build_assign_stat (l, r MEM_STAT_INFO)
808
809 void extract_ops_from_tree_1 (tree, enum tree_code *, tree *, tree *, tree *);
810
811 gimple gimple_build_assign_with_ops_stat (enum tree_code, tree, tree,
812                                           tree, tree MEM_STAT_DECL);
813 #define gimple_build_assign_with_ops(c,o1,o2,o3)                        \
814   gimple_build_assign_with_ops_stat (c, o1, o2, o3, NULL_TREE MEM_STAT_INFO)
815 #define gimple_build_assign_with_ops3(c,o1,o2,o3,o4)                    \
816   gimple_build_assign_with_ops_stat (c, o1, o2, o3, o4 MEM_STAT_INFO)
817
818 gimple gimple_build_debug_bind_stat (tree, tree, gimple MEM_STAT_DECL);
819 #define gimple_build_debug_bind(var,val,stmt)                   \
820   gimple_build_debug_bind_stat ((var), (val), (stmt) MEM_STAT_INFO)
821
822 gimple gimple_build_call_vec (tree, VEC(tree, heap) *);
823 gimple gimple_build_call (tree, unsigned, ...);
824 gimple gimple_build_call_from_tree (tree);
825 gimple gimplify_assign (tree, tree, gimple_seq *);
826 gimple gimple_build_cond (enum tree_code, tree, tree, tree, tree);
827 gimple gimple_build_label (tree label);
828 gimple gimple_build_goto (tree dest);
829 gimple gimple_build_nop (void);
830 gimple gimple_build_bind (tree, gimple_seq, tree);
831 gimple gimple_build_asm_vec (const char *, VEC(tree,gc) *, VEC(tree,gc) *,
832                              VEC(tree,gc) *, VEC(tree,gc) *);
833 gimple gimple_build_catch (tree, gimple_seq);
834 gimple gimple_build_eh_filter (tree, gimple_seq);
835 gimple gimple_build_eh_must_not_throw (tree);
836 gimple gimple_build_try (gimple_seq, gimple_seq, enum gimple_try_flags);
837 gimple gimple_build_wce (gimple_seq);
838 gimple gimple_build_resx (int);
839 gimple gimple_build_eh_dispatch (int);
840 gimple gimple_build_switch_nlabels (unsigned, tree, tree);
841 gimple gimple_build_switch (unsigned, tree, tree, ...);
842 gimple gimple_build_switch_vec (tree, tree, VEC(tree,heap) *);
843 gimple gimple_build_omp_parallel (gimple_seq, tree, tree, tree);
844 gimple gimple_build_omp_task (gimple_seq, tree, tree, tree, tree, tree, tree);
845 gimple gimple_build_omp_for (gimple_seq, tree, size_t, gimple_seq);
846 gimple gimple_build_omp_critical (gimple_seq, tree);
847 gimple gimple_build_omp_section (gimple_seq);
848 gimple gimple_build_omp_continue (tree, tree);
849 gimple gimple_build_omp_master (gimple_seq);
850 gimple gimple_build_omp_return (bool);
851 gimple gimple_build_omp_ordered (gimple_seq);
852 gimple gimple_build_omp_sections (gimple_seq, tree);
853 gimple gimple_build_omp_sections_switch (void);
854 gimple gimple_build_omp_single (gimple_seq, tree);
855 gimple gimple_build_cdt (tree, tree);
856 gimple gimple_build_omp_atomic_load (tree, tree);
857 gimple gimple_build_omp_atomic_store (tree);
858 gimple gimple_build_predict (enum br_predictor, enum prediction);
859 enum gimple_statement_structure_enum gss_for_assign (enum tree_code);
860 void sort_case_labels (VEC(tree,heap) *);
861 void gimple_set_body (tree, gimple_seq);
862 gimple_seq gimple_body (tree);
863 bool gimple_has_body_p (tree);
864 gimple_seq gimple_seq_alloc (void);
865 void gimple_seq_free (gimple_seq);
866 void gimple_seq_add_seq (gimple_seq *, gimple_seq);
867 gimple_seq gimple_seq_copy (gimple_seq);
868 int gimple_call_flags (const_gimple);
869 int gimple_call_return_flags (const_gimple);
870 int gimple_call_arg_flags (const_gimple, unsigned);
871 void gimple_call_reset_alias_info (gimple);
872 bool gimple_assign_copy_p (gimple);
873 bool gimple_assign_ssa_name_copy_p (gimple);
874 bool gimple_assign_unary_nop_p (gimple);
875 void gimple_set_bb (gimple, struct basic_block_def *);
876 void gimple_assign_set_rhs_from_tree (gimple_stmt_iterator *, tree);
877 void gimple_assign_set_rhs_with_ops_1 (gimple_stmt_iterator *, enum tree_code,
878                                        tree, tree, tree);
879 tree gimple_get_lhs (const_gimple);
880 void gimple_set_lhs (gimple, tree);
881 void gimple_replace_lhs (gimple, tree);
882 gimple gimple_copy (gimple);
883 void gimple_set_modified (gimple, bool);
884 void gimple_cond_get_ops_from_tree (tree, enum tree_code *, tree *, tree *);
885 gimple gimple_build_cond_from_tree (tree, tree, tree);
886 void gimple_cond_set_condition_from_tree (gimple, tree);
887 bool gimple_has_side_effects (const_gimple);
888 bool gimple_rhs_has_side_effects (const_gimple);
889 bool gimple_could_trap_p (gimple);
890 bool gimple_could_trap_p_1 (gimple, bool, bool);
891 bool gimple_assign_rhs_could_trap_p (gimple);
892 void gimple_regimplify_operands (gimple, gimple_stmt_iterator *);
893 bool empty_body_p (gimple_seq);
894 unsigned get_gimple_rhs_num_ops (enum tree_code);
895 #define gimple_alloc(c, n) gimple_alloc_stat (c, n MEM_STAT_INFO)
896 gimple gimple_alloc_stat (enum gimple_code, unsigned MEM_STAT_DECL);
897 const char *gimple_decl_printable_name (tree, int);
898 bool gimple_fold_call (gimple_stmt_iterator *gsi, bool inplace);
899 tree gimple_get_virt_method_for_binfo (HOST_WIDE_INT, tree, tree *, bool);
900 void gimple_adjust_this_by_delta (gimple_stmt_iterator *, tree);
901 tree gimple_extract_devirt_binfo_from_cst (tree);
902 /* Returns true iff T is a valid GIMPLE statement.  */
903 extern bool is_gimple_stmt (tree);
904
905 /* Returns true iff TYPE is a valid type for a scalar register variable.  */
906 extern bool is_gimple_reg_type (tree);
907 /* Returns true iff T is a scalar register variable.  */
908 extern bool is_gimple_reg (tree);
909 /* Returns true iff T is any sort of variable.  */
910 extern bool is_gimple_variable (tree);
911 /* Returns true iff T is any sort of symbol.  */
912 extern bool is_gimple_id (tree);
913 /* Returns true iff T is a variable or an INDIRECT_REF (of a variable).  */
914 extern bool is_gimple_min_lval (tree);
915 /* Returns true iff T is something whose address can be taken.  */
916 extern bool is_gimple_addressable (tree);
917 /* Returns true iff T is any valid GIMPLE lvalue.  */
918 extern bool is_gimple_lvalue (tree);
919
920 /* Returns true iff T is a GIMPLE address.  */
921 bool is_gimple_address (const_tree);
922 /* Returns true iff T is a GIMPLE invariant address.  */
923 bool is_gimple_invariant_address (const_tree);
924 /* Returns true iff T is a GIMPLE invariant address at interprocedural
925    level.  */
926 bool is_gimple_ip_invariant_address (const_tree);
927 /* Returns true iff T is a valid GIMPLE constant.  */
928 bool is_gimple_constant (const_tree);
929 /* Returns true iff T is a GIMPLE restricted function invariant.  */
930 extern bool is_gimple_min_invariant (const_tree);
931 /* Returns true iff T is a GIMPLE restricted interprecodural invariant.  */
932 extern bool is_gimple_ip_invariant (const_tree);
933 /* Returns true iff T is a GIMPLE rvalue.  */
934 extern bool is_gimple_val (tree);
935 /* Returns true iff T is a GIMPLE asm statement input.  */
936 extern bool is_gimple_asm_val (tree);
937 /* Returns true iff T is a valid address operand of a MEM_REF.  */
938 bool is_gimple_mem_ref_addr (tree);
939 /* Returns true iff T is a valid rhs for a MODIFY_EXPR where the LHS is a
940    GIMPLE temporary, a renamed user variable, or something else,
941    respectively.  */
942 extern bool is_gimple_reg_rhs (tree);
943 extern bool is_gimple_mem_rhs (tree);
944
945 /* Returns true iff T is a valid if-statement condition.  */
946 extern bool is_gimple_condexpr (tree);
947
948 /* Returns true iff T is a variable that does not need to live in memory.  */
949 extern bool is_gimple_non_addressable (tree t);
950
951 /* Returns true iff T is a valid call address expression.  */
952 extern bool is_gimple_call_addr (tree);
953 /* If T makes a function call, returns the CALL_EXPR operand.  */
954 extern tree get_call_expr_in (tree t);
955
956 extern void recalculate_side_effects (tree);
957 extern bool gimple_compare_field_offset (tree, tree);
958 extern tree gimple_register_type (tree);
959 extern tree gimple_register_canonical_type (tree);
960 enum gtc_mode { GTC_MERGE = 0, GTC_DIAG = 1 };
961 extern bool gimple_types_compatible_p (tree, tree, enum gtc_mode);
962 extern void print_gimple_types_stats (void);
963 extern void free_gimple_type_tables (void);
964 extern tree gimple_unsigned_type (tree);
965 extern tree gimple_signed_type (tree);
966 extern alias_set_type gimple_get_alias_set (tree);
967 extern void count_uses_and_derefs (tree, gimple, unsigned *, unsigned *,
968                                    unsigned *);
969 extern bool walk_stmt_load_store_addr_ops (gimple, void *,
970                                            bool (*)(gimple, tree, void *),
971                                            bool (*)(gimple, tree, void *),
972                                            bool (*)(gimple, tree, void *));
973 extern bool walk_stmt_load_store_ops (gimple, void *,
974                                       bool (*)(gimple, tree, void *),
975                                       bool (*)(gimple, tree, void *));
976 extern bool gimple_ior_addresses_taken (bitmap, gimple);
977 extern bool gimple_call_builtin_p (gimple, enum built_in_function);
978 extern bool gimple_asm_clobbers_memory_p (const_gimple);
979
980 /* In gimplify.c  */
981 extern tree create_tmp_var_raw (tree, const char *);
982 extern tree create_tmp_var_name (const char *);
983 extern tree create_tmp_var (tree, const char *);
984 extern tree create_tmp_reg (tree, const char *);
985 extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq *);
986 extern tree get_formal_tmp_var (tree, gimple_seq *);
987 extern void declare_vars (tree, gimple, bool);
988 extern void annotate_all_with_location (gimple_seq, location_t);
989
990 /* Validation of GIMPLE expressions.  Note that these predicates only check
991    the basic form of the expression, they don't recurse to make sure that
992    underlying nodes are also of the right form.  */
993 typedef bool (*gimple_predicate)(tree);
994
995
996 /* FIXME we should deduce this from the predicate.  */
997 enum fallback {
998   fb_none = 0,          /* Do not generate a temporary.  */
999
1000   fb_rvalue = 1,        /* Generate an rvalue to hold the result of a
1001                            gimplified expression.  */
1002
1003   fb_lvalue = 2,        /* Generate an lvalue to hold the result of a
1004                            gimplified expression.  */
1005
1006   fb_mayfail = 4,       /* Gimplification may fail.  Error issued
1007                            afterwards.  */
1008   fb_either= fb_rvalue | fb_lvalue
1009 };
1010
1011 typedef int fallback_t;
1012
1013 enum gimplify_status {
1014   GS_ERROR      = -2,   /* Something Bad Seen.  */
1015   GS_UNHANDLED  = -1,   /* A langhook result for "I dunno".  */
1016   GS_OK         = 0,    /* We did something, maybe more to do.  */
1017   GS_ALL_DONE   = 1     /* The expression is fully gimplified.  */
1018 };
1019
1020 struct gimplify_ctx
1021 {
1022   struct gimplify_ctx *prev_context;
1023
1024   VEC(gimple,heap) *bind_expr_stack;
1025   tree temps;
1026   gimple_seq conditional_cleanups;
1027   tree exit_label;
1028   tree return_temp;
1029
1030   VEC(tree,heap) *case_labels;
1031   /* The formal temporary table.  Should this be persistent?  */
1032   htab_t temp_htab;
1033
1034   int conditions;
1035   bool save_stack;
1036   bool into_ssa;
1037   bool allow_rhs_cond_expr;
1038 };
1039
1040 extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *,
1041                                            bool (*) (tree), fallback_t);
1042 extern void gimplify_type_sizes (tree, gimple_seq *);
1043 extern void gimplify_one_sizepos (tree *, gimple_seq *);
1044 extern bool gimplify_stmt (tree *, gimple_seq *);
1045 extern gimple gimplify_body (tree *, tree, bool);
1046 extern void push_gimplify_context (struct gimplify_ctx *);
1047 extern void pop_gimplify_context (gimple);
1048 extern void gimplify_and_add (tree, gimple_seq *);
1049
1050 /* Miscellaneous helpers.  */
1051 extern void gimple_add_tmp_var (tree);
1052 extern gimple gimple_current_bind_expr (void);
1053 extern VEC(gimple, heap) *gimple_bind_expr_stack (void);
1054 extern tree voidify_wrapper_expr (tree, tree);
1055 extern tree build_and_jump (tree *);
1056 extern tree force_labels_r (tree *, int *, void *);
1057 extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *,
1058                                                   gimple_seq *);
1059 struct gimplify_omp_ctx;
1060 extern void omp_firstprivatize_variable (struct gimplify_omp_ctx *, tree);
1061 extern tree gimple_boolify (tree);
1062 extern gimple_predicate rhs_predicate_for (tree);
1063 extern tree canonicalize_cond_expr_cond (tree);
1064
1065 /* In omp-low.c.  */
1066 extern tree omp_reduction_init (tree, tree);
1067
1068 /* In tree-nested.c.  */
1069 extern void lower_nested_functions (tree);
1070 extern void insert_field_into_struct (tree, tree);
1071
1072 /* In gimplify.c.  */
1073 extern void gimplify_function_tree (tree);
1074
1075 /* In cfgexpand.c.  */
1076 extern tree gimple_assign_rhs_to_tree (gimple);
1077
1078 /* In builtins.c  */
1079 extern bool validate_gimple_arglist (const_gimple, ...);
1080
1081 /* In tree-ssa.c  */
1082 extern bool tree_ssa_useless_type_conversion (tree);
1083 extern tree tree_ssa_strip_useless_type_conversions (tree);
1084 extern bool useless_type_conversion_p (tree, tree);
1085 extern bool types_compatible_p (tree, tree);
1086
1087 /* Return the code for GIMPLE statement G.  */
1088
1089 static inline enum gimple_code
1090 gimple_code (const_gimple g)
1091 {
1092   return g->gsbase.code;
1093 }
1094
1095
1096 /* Return the GSS code used by a GIMPLE code.  */
1097
1098 static inline enum gimple_statement_structure_enum
1099 gss_for_code (enum gimple_code code)
1100 {
1101   gcc_gimple_checking_assert ((unsigned int)code < LAST_AND_UNUSED_GIMPLE_CODE);
1102   return gss_for_code_[code];
1103 }
1104
1105
1106 /* Return which GSS code is used by GS.  */
1107
1108 static inline enum gimple_statement_structure_enum
1109 gimple_statement_structure (gimple gs)
1110 {
1111   return gss_for_code (gimple_code (gs));
1112 }
1113
1114
1115 /* Return true if statement G has sub-statements.  This is only true for
1116    High GIMPLE statements.  */
1117
1118 static inline bool
1119 gimple_has_substatements (gimple g)
1120 {
1121   switch (gimple_code (g))
1122     {
1123     case GIMPLE_BIND:
1124     case GIMPLE_CATCH:
1125     case GIMPLE_EH_FILTER:
1126     case GIMPLE_TRY:
1127     case GIMPLE_OMP_FOR:
1128     case GIMPLE_OMP_MASTER:
1129     case GIMPLE_OMP_ORDERED:
1130     case GIMPLE_OMP_SECTION:
1131     case GIMPLE_OMP_PARALLEL:
1132     case GIMPLE_OMP_TASK:
1133     case GIMPLE_OMP_SECTIONS:
1134     case GIMPLE_OMP_SINGLE:
1135     case GIMPLE_OMP_CRITICAL:
1136     case GIMPLE_WITH_CLEANUP_EXPR:
1137       return true;
1138
1139     default:
1140       return false;
1141     }
1142 }
1143
1144
1145 /* Return the basic block holding statement G.  */
1146
1147 static inline struct basic_block_def *
1148 gimple_bb (const_gimple g)
1149 {
1150   return g->gsbase.bb;
1151 }
1152
1153
1154 /* Return the lexical scope block holding statement G.  */
1155
1156 static inline tree
1157 gimple_block (const_gimple g)
1158 {
1159   return g->gsbase.block;
1160 }
1161
1162
1163 /* Set BLOCK to be the lexical scope block holding statement G.  */
1164
1165 static inline void
1166 gimple_set_block (gimple g, tree block)
1167 {
1168   g->gsbase.block = block;
1169 }
1170
1171
1172 /* Return location information for statement G.  */
1173
1174 static inline location_t
1175 gimple_location (const_gimple g)
1176 {
1177   return g->gsbase.location;
1178 }
1179
1180 /* Return pointer to location information for statement G.  */
1181
1182 static inline const location_t *
1183 gimple_location_ptr (const_gimple g)
1184 {
1185   return &g->gsbase.location;
1186 }
1187
1188
1189 /* Set location information for statement G.  */
1190
1191 static inline void
1192 gimple_set_location (gimple g, location_t location)
1193 {
1194   g->gsbase.location = location;
1195 }
1196
1197
1198 /* Return true if G contains location information.  */
1199
1200 static inline bool
1201 gimple_has_location (const_gimple g)
1202 {
1203   return gimple_location (g) != UNKNOWN_LOCATION;
1204 }
1205
1206
1207 /* Return the file name of the location of STMT.  */
1208
1209 static inline const char *
1210 gimple_filename (const_gimple stmt)
1211 {
1212   return LOCATION_FILE (gimple_location (stmt));
1213 }
1214
1215
1216 /* Return the line number of the location of STMT.  */
1217
1218 static inline int
1219 gimple_lineno (const_gimple stmt)
1220 {
1221   return LOCATION_LINE (gimple_location (stmt));
1222 }
1223
1224
1225 /* Determine whether SEQ is a singleton. */
1226
1227 static inline bool
1228 gimple_seq_singleton_p (gimple_seq seq)
1229 {
1230   return ((gimple_seq_first (seq) != NULL)
1231           && (gimple_seq_first (seq) == gimple_seq_last (seq)));
1232 }
1233
1234 /* Return true if no warnings should be emitted for statement STMT.  */
1235
1236 static inline bool
1237 gimple_no_warning_p (const_gimple stmt)
1238 {
1239   return stmt->gsbase.no_warning;
1240 }
1241
1242 /* Set the no_warning flag of STMT to NO_WARNING.  */
1243
1244 static inline void
1245 gimple_set_no_warning (gimple stmt, bool no_warning)
1246 {
1247   stmt->gsbase.no_warning = (unsigned) no_warning;
1248 }
1249
1250 /* Set the visited status on statement STMT to VISITED_P.  */
1251
1252 static inline void
1253 gimple_set_visited (gimple stmt, bool visited_p)
1254 {
1255   stmt->gsbase.visited = (unsigned) visited_p;
1256 }
1257
1258
1259 /* Return the visited status for statement STMT.  */
1260
1261 static inline bool
1262 gimple_visited_p (gimple stmt)
1263 {
1264   return stmt->gsbase.visited;
1265 }
1266
1267
1268 /* Set pass local flag PLF on statement STMT to VAL_P.  */
1269
1270 static inline void
1271 gimple_set_plf (gimple stmt, enum plf_mask plf, bool val_p)
1272 {
1273   if (val_p)
1274     stmt->gsbase.plf |= (unsigned int) plf;
1275   else
1276     stmt->gsbase.plf &= ~((unsigned int) plf);
1277 }
1278
1279
1280 /* Return the value of pass local flag PLF on statement STMT.  */
1281
1282 static inline unsigned int
1283 gimple_plf (gimple stmt, enum plf_mask plf)
1284 {
1285   return stmt->gsbase.plf & ((unsigned int) plf);
1286 }
1287
1288
1289 /* Set the UID of statement.  */
1290
1291 static inline void
1292 gimple_set_uid (gimple g, unsigned uid)
1293 {
1294   g->gsbase.uid = uid;
1295 }
1296
1297
1298 /* Return the UID of statement.  */
1299
1300 static inline unsigned
1301 gimple_uid (const_gimple g)
1302 {
1303   return g->gsbase.uid;
1304 }
1305
1306
1307 /* Return true if GIMPLE statement G has register or memory operands.  */
1308
1309 static inline bool
1310 gimple_has_ops (const_gimple g)
1311 {
1312   return gimple_code (g) >= GIMPLE_COND && gimple_code (g) <= GIMPLE_RETURN;
1313 }
1314
1315
1316 /* Return true if GIMPLE statement G has memory operands.  */
1317
1318 static inline bool
1319 gimple_has_mem_ops (const_gimple g)
1320 {
1321   return gimple_code (g) >= GIMPLE_ASSIGN && gimple_code (g) <= GIMPLE_RETURN;
1322 }
1323
1324
1325 /* Return the set of DEF operands for statement G.  */
1326
1327 static inline struct def_optype_d *
1328 gimple_def_ops (const_gimple g)
1329 {
1330   if (!gimple_has_ops (g))
1331     return NULL;
1332   return g->gsops.opbase.def_ops;
1333 }
1334
1335
1336 /* Set DEF to be the set of DEF operands for statement G.  */
1337
1338 static inline void
1339 gimple_set_def_ops (gimple g, struct def_optype_d *def)
1340 {
1341   gcc_gimple_checking_assert (gimple_has_ops (g));
1342   g->gsops.opbase.def_ops = def;
1343 }
1344
1345
1346 /* Return the set of USE operands for statement G.  */
1347
1348 static inline struct use_optype_d *
1349 gimple_use_ops (const_gimple g)
1350 {
1351   if (!gimple_has_ops (g))
1352     return NULL;
1353   return g->gsops.opbase.use_ops;
1354 }
1355
1356
1357 /* Set USE to be the set of USE operands for statement G.  */
1358
1359 static inline void
1360 gimple_set_use_ops (gimple g, struct use_optype_d *use)
1361 {
1362   gcc_gimple_checking_assert (gimple_has_ops (g));
1363   g->gsops.opbase.use_ops = use;
1364 }
1365
1366
1367 /* Return the set of VUSE operand for statement G.  */
1368
1369 static inline use_operand_p
1370 gimple_vuse_op (const_gimple g)
1371 {
1372   struct use_optype_d *ops;
1373   if (!gimple_has_mem_ops (g))
1374     return NULL_USE_OPERAND_P;
1375   ops = g->gsops.opbase.use_ops;
1376   if (ops
1377       && USE_OP_PTR (ops)->use == &g->gsmembase.vuse)
1378     return USE_OP_PTR (ops);
1379   return NULL_USE_OPERAND_P;
1380 }
1381
1382 /* Return the set of VDEF operand for statement G.  */
1383
1384 static inline def_operand_p
1385 gimple_vdef_op (const_gimple g)
1386 {
1387   struct def_optype_d *ops;
1388   if (!gimple_has_mem_ops (g))
1389     return NULL_DEF_OPERAND_P;
1390   ops = g->gsops.opbase.def_ops;
1391   if (ops
1392       && DEF_OP_PTR (ops) == &g->gsmembase.vdef)
1393     return DEF_OP_PTR (ops);
1394   return NULL_DEF_OPERAND_P;
1395 }
1396
1397
1398 /* Return the single VUSE operand of the statement G.  */
1399
1400 static inline tree
1401 gimple_vuse (const_gimple g)
1402 {
1403   if (!gimple_has_mem_ops (g))
1404     return NULL_TREE;
1405   return g->gsmembase.vuse;
1406 }
1407
1408 /* Return the single VDEF operand of the statement G.  */
1409
1410 static inline tree
1411 gimple_vdef (const_gimple g)
1412 {
1413   if (!gimple_has_mem_ops (g))
1414     return NULL_TREE;
1415   return g->gsmembase.vdef;
1416 }
1417
1418 /* Return the single VUSE operand of the statement G.  */
1419
1420 static inline tree *
1421 gimple_vuse_ptr (gimple g)
1422 {
1423   if (!gimple_has_mem_ops (g))
1424     return NULL;
1425   return &g->gsmembase.vuse;
1426 }
1427
1428 /* Return the single VDEF operand of the statement G.  */
1429
1430 static inline tree *
1431 gimple_vdef_ptr (gimple g)
1432 {
1433   if (!gimple_has_mem_ops (g))
1434     return NULL;
1435   return &g->gsmembase.vdef;
1436 }
1437
1438 /* Set the single VUSE operand of the statement G.  */
1439
1440 static inline void
1441 gimple_set_vuse (gimple g, tree vuse)
1442 {
1443   gcc_gimple_checking_assert (gimple_has_mem_ops (g));
1444   g->gsmembase.vuse = vuse;
1445 }
1446
1447 /* Set the single VDEF operand of the statement G.  */
1448
1449 static inline void
1450 gimple_set_vdef (gimple g, tree vdef)
1451 {
1452   gcc_gimple_checking_assert (gimple_has_mem_ops (g));
1453   g->gsmembase.vdef = vdef;
1454 }
1455
1456
1457 /* Return true if statement G has operands and the modified field has
1458    been set.  */
1459
1460 static inline bool
1461 gimple_modified_p (const_gimple g)
1462 {
1463   return (gimple_has_ops (g)) ? (bool) g->gsbase.modified : false;
1464 }
1465
1466
1467 /* Return the tree code for the expression computed by STMT.  This is
1468    only valid for GIMPLE_COND, GIMPLE_CALL and GIMPLE_ASSIGN.  For
1469    GIMPLE_CALL, return CALL_EXPR as the expression code for
1470    consistency.  This is useful when the caller needs to deal with the
1471    three kinds of computation that GIMPLE supports.  */
1472
1473 static inline enum tree_code
1474 gimple_expr_code (const_gimple stmt)
1475 {
1476   enum gimple_code code = gimple_code (stmt);
1477   if (code == GIMPLE_ASSIGN || code == GIMPLE_COND)
1478     return (enum tree_code) stmt->gsbase.subcode;
1479   else
1480     {
1481       gcc_gimple_checking_assert (code == GIMPLE_CALL);
1482       return CALL_EXPR;
1483     }
1484 }
1485
1486
1487 /* Mark statement S as modified, and update it.  */
1488
1489 static inline void
1490 update_stmt (gimple s)
1491 {
1492   if (gimple_has_ops (s))
1493     {
1494       gimple_set_modified (s, true);
1495       update_stmt_operands (s);
1496     }
1497 }
1498
1499 /* Update statement S if it has been optimized.  */
1500
1501 static inline void
1502 update_stmt_if_modified (gimple s)
1503 {
1504   if (gimple_modified_p (s))
1505     update_stmt_operands (s);
1506 }
1507
1508 /* Return true if statement STMT contains volatile operands.  */
1509
1510 static inline bool
1511 gimple_has_volatile_ops (const_gimple stmt)
1512 {
1513   if (gimple_has_mem_ops (stmt))
1514     return stmt->gsbase.has_volatile_ops;
1515   else
1516     return false;
1517 }
1518
1519
1520 /* Set the HAS_VOLATILE_OPS flag to VOLATILEP.  */
1521
1522 static inline void
1523 gimple_set_has_volatile_ops (gimple stmt, bool volatilep)
1524 {
1525   if (gimple_has_mem_ops (stmt))
1526     stmt->gsbase.has_volatile_ops = (unsigned) volatilep;
1527 }
1528
1529
1530 /* Return true if statement STMT may access memory.  */
1531
1532 static inline bool
1533 gimple_references_memory_p (gimple stmt)
1534 {
1535   return gimple_has_mem_ops (stmt) && gimple_vuse (stmt);
1536 }
1537
1538
1539 /* Return the subcode for OMP statement S.  */
1540
1541 static inline unsigned
1542 gimple_omp_subcode (const_gimple s)
1543 {
1544   gcc_gimple_checking_assert (gimple_code (s) >= GIMPLE_OMP_ATOMIC_LOAD
1545               && gimple_code (s) <= GIMPLE_OMP_SINGLE);
1546   return s->gsbase.subcode;
1547 }
1548
1549 /* Set the subcode for OMP statement S to SUBCODE.  */
1550
1551 static inline void
1552 gimple_omp_set_subcode (gimple s, unsigned int subcode)
1553 {
1554   /* We only have 16 bits for the subcode.  Assert that we are not
1555      overflowing it.  */
1556   gcc_gimple_checking_assert (subcode < (1 << 16));
1557   s->gsbase.subcode = subcode;
1558 }
1559
1560 /* Set the nowait flag on OMP_RETURN statement S.  */
1561
1562 static inline void
1563 gimple_omp_return_set_nowait (gimple s)
1564 {
1565   GIMPLE_CHECK (s, GIMPLE_OMP_RETURN);
1566   s->gsbase.subcode |= GF_OMP_RETURN_NOWAIT;
1567 }
1568
1569
1570 /* Return true if OMP return statement G has the GF_OMP_RETURN_NOWAIT
1571    flag set.  */
1572
1573 static inline bool
1574 gimple_omp_return_nowait_p (const_gimple g)
1575 {
1576   GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
1577   return (gimple_omp_subcode (g) & GF_OMP_RETURN_NOWAIT) != 0;
1578 }
1579
1580
1581 /* Return true if OMP section statement G has the GF_OMP_SECTION_LAST
1582    flag set.  */
1583
1584 static inline bool
1585 gimple_omp_section_last_p (const_gimple g)
1586 {
1587   GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1588   return (gimple_omp_subcode (g) & GF_OMP_SECTION_LAST) != 0;
1589 }
1590
1591
1592 /* Set the GF_OMP_SECTION_LAST flag on G.  */
1593
1594 static inline void
1595 gimple_omp_section_set_last (gimple g)
1596 {
1597   GIMPLE_CHECK (g, GIMPLE_OMP_SECTION);
1598   g->gsbase.subcode |= GF_OMP_SECTION_LAST;
1599 }
1600
1601
1602 /* Return true if OMP parallel statement G has the
1603    GF_OMP_PARALLEL_COMBINED flag set.  */
1604
1605 static inline bool
1606 gimple_omp_parallel_combined_p (const_gimple g)
1607 {
1608   GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1609   return (gimple_omp_subcode (g) & GF_OMP_PARALLEL_COMBINED) != 0;
1610 }
1611
1612
1613 /* Set the GF_OMP_PARALLEL_COMBINED field in G depending on the boolean
1614    value of COMBINED_P.  */
1615
1616 static inline void
1617 gimple_omp_parallel_set_combined_p (gimple g, bool combined_p)
1618 {
1619   GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
1620   if (combined_p)
1621     g->gsbase.subcode |= GF_OMP_PARALLEL_COMBINED;
1622   else
1623     g->gsbase.subcode &= ~GF_OMP_PARALLEL_COMBINED;
1624 }
1625
1626
1627 /* Return the number of operands for statement GS.  */
1628
1629 static inline unsigned
1630 gimple_num_ops (const_gimple gs)
1631 {
1632   return gs->gsbase.num_ops;
1633 }
1634
1635
1636 /* Set the number of operands for statement GS.  */
1637
1638 static inline void
1639 gimple_set_num_ops (gimple gs, unsigned num_ops)
1640 {
1641   gs->gsbase.num_ops = num_ops;
1642 }
1643
1644
1645 /* Return the array of operands for statement GS.  */
1646
1647 static inline tree *
1648 gimple_ops (gimple gs)
1649 {
1650   size_t off;
1651
1652   /* All the tuples have their operand vector at the very bottom
1653      of the structure.  Note that those structures that do not
1654      have an operand vector have a zero offset.  */
1655   off = gimple_ops_offset_[gimple_statement_structure (gs)];
1656   gcc_gimple_checking_assert (off != 0);
1657
1658   return (tree *) ((char *) gs + off);
1659 }
1660
1661
1662 /* Return operand I for statement GS.  */
1663
1664 static inline tree
1665 gimple_op (const_gimple gs, unsigned i)
1666 {
1667   if (gimple_has_ops (gs))
1668     {
1669       gcc_gimple_checking_assert (i < gimple_num_ops (gs));
1670       return gimple_ops (CONST_CAST_GIMPLE (gs))[i];
1671     }
1672   else
1673     return NULL_TREE;
1674 }
1675
1676 /* Return a pointer to operand I for statement GS.  */
1677
1678 static inline tree *
1679 gimple_op_ptr (const_gimple gs, unsigned i)
1680 {
1681   if (gimple_has_ops (gs))
1682     {
1683       gcc_gimple_checking_assert (i < gimple_num_ops (gs));
1684       return gimple_ops (CONST_CAST_GIMPLE (gs)) + i;
1685     }
1686   else
1687     return NULL;
1688 }
1689
1690 /* Set operand I of statement GS to OP.  */
1691
1692 static inline void
1693 gimple_set_op (gimple gs, unsigned i, tree op)
1694 {
1695   gcc_gimple_checking_assert (gimple_has_ops (gs) && i < gimple_num_ops (gs));
1696
1697   /* Note.  It may be tempting to assert that OP matches
1698      is_gimple_operand, but that would be wrong.  Different tuples
1699      accept slightly different sets of tree operands.  Each caller
1700      should perform its own validation.  */
1701   gimple_ops (gs)[i] = op;
1702 }
1703
1704 /* Return true if GS is a GIMPLE_ASSIGN.  */
1705
1706 static inline bool
1707 is_gimple_assign (const_gimple gs)
1708 {
1709   return gimple_code (gs) == GIMPLE_ASSIGN;
1710 }
1711
1712 /* Determine if expression CODE is one of the valid expressions that can
1713    be used on the RHS of GIMPLE assignments.  */
1714
1715 static inline enum gimple_rhs_class
1716 get_gimple_rhs_class (enum tree_code code)
1717 {
1718   return (enum gimple_rhs_class) gimple_rhs_class_table[(int) code];
1719 }
1720
1721 /* Return the LHS of assignment statement GS.  */
1722
1723 static inline tree
1724 gimple_assign_lhs (const_gimple gs)
1725 {
1726   GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1727   return gimple_op (gs, 0);
1728 }
1729
1730
1731 /* Return a pointer to the LHS of assignment statement GS.  */
1732
1733 static inline tree *
1734 gimple_assign_lhs_ptr (const_gimple gs)
1735 {
1736   GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1737   return gimple_op_ptr (gs, 0);
1738 }
1739
1740
1741 /* Set LHS to be the LHS operand of assignment statement GS.  */
1742
1743 static inline void
1744 gimple_assign_set_lhs (gimple gs, tree lhs)
1745 {
1746   GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1747   gimple_set_op (gs, 0, lhs);
1748
1749   if (lhs && TREE_CODE (lhs) == SSA_NAME)
1750     SSA_NAME_DEF_STMT (lhs) = gs;
1751 }
1752
1753
1754 /* Return the first operand on the RHS of assignment statement GS.  */
1755
1756 static inline tree
1757 gimple_assign_rhs1 (const_gimple gs)
1758 {
1759   GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1760   return gimple_op (gs, 1);
1761 }
1762
1763
1764 /* Return a pointer to the first operand on the RHS of assignment
1765    statement GS.  */
1766
1767 static inline tree *
1768 gimple_assign_rhs1_ptr (const_gimple gs)
1769 {
1770   GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1771   return gimple_op_ptr (gs, 1);
1772 }
1773
1774 /* Set RHS to be the first operand on the RHS of assignment statement GS.  */
1775
1776 static inline void
1777 gimple_assign_set_rhs1 (gimple gs, tree rhs)
1778 {
1779   GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1780
1781   gimple_set_op (gs, 1, rhs);
1782 }
1783
1784
1785 /* Return the second operand on the RHS of assignment statement GS.
1786    If GS does not have two operands, NULL is returned instead.  */
1787
1788 static inline tree
1789 gimple_assign_rhs2 (const_gimple gs)
1790 {
1791   GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1792
1793   if (gimple_num_ops (gs) >= 3)
1794     return gimple_op (gs, 2);
1795   else
1796     return NULL_TREE;
1797 }
1798
1799
1800 /* Return a pointer to the second operand on the RHS of assignment
1801    statement GS.  */
1802
1803 static inline tree *
1804 gimple_assign_rhs2_ptr (const_gimple gs)
1805 {
1806   GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1807   return gimple_op_ptr (gs, 2);
1808 }
1809
1810
1811 /* Set RHS to be the second operand on the RHS of assignment statement GS.  */
1812
1813 static inline void
1814 gimple_assign_set_rhs2 (gimple gs, tree rhs)
1815 {
1816   GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1817
1818   gimple_set_op (gs, 2, rhs);
1819 }
1820
1821 /* Return the third operand on the RHS of assignment statement GS.
1822    If GS does not have two operands, NULL is returned instead.  */
1823
1824 static inline tree
1825 gimple_assign_rhs3 (const_gimple gs)
1826 {
1827   GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1828
1829   if (gimple_num_ops (gs) >= 4)
1830     return gimple_op (gs, 3);
1831   else
1832     return NULL_TREE;
1833 }
1834
1835 /* Return a pointer to the third operand on the RHS of assignment
1836    statement GS.  */
1837
1838 static inline tree *
1839 gimple_assign_rhs3_ptr (const_gimple gs)
1840 {
1841   GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1842   return gimple_op_ptr (gs, 3);
1843 }
1844
1845
1846 /* Set RHS to be the third operand on the RHS of assignment statement GS.  */
1847
1848 static inline void
1849 gimple_assign_set_rhs3 (gimple gs, tree rhs)
1850 {
1851   GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1852
1853   gimple_set_op (gs, 3, rhs);
1854 }
1855
1856 /* A wrapper around gimple_assign_set_rhs_with_ops_1, for callers which expect
1857    to see only a maximum of two operands.  */
1858
1859 static inline void
1860 gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *gsi, enum tree_code code,
1861                                 tree op1, tree op2)
1862 {
1863   gimple_assign_set_rhs_with_ops_1 (gsi, code, op1, op2, NULL);
1864 }
1865
1866 /* A wrapper around extract_ops_from_tree_1, for callers which expect
1867    to see only a maximum of two operands.  */
1868
1869 static inline void
1870 extract_ops_from_tree (tree expr, enum tree_code *code, tree *op0,
1871                        tree *op1)
1872 {
1873   tree op2;
1874   extract_ops_from_tree_1 (expr, code, op0, op1, &op2);
1875   gcc_assert (op2 == NULL_TREE);
1876 }
1877
1878 /* Returns true if GS is a nontemporal move.  */
1879
1880 static inline bool
1881 gimple_assign_nontemporal_move_p (const_gimple gs)
1882 {
1883   GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1884   return gs->gsbase.nontemporal_move;
1885 }
1886
1887 /* Sets nontemporal move flag of GS to NONTEMPORAL.  */
1888
1889 static inline void
1890 gimple_assign_set_nontemporal_move (gimple gs, bool nontemporal)
1891 {
1892   GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1893   gs->gsbase.nontemporal_move = nontemporal;
1894 }
1895
1896
1897 /* Return the code of the expression computed on the rhs of assignment
1898    statement GS.  In case that the RHS is a single object, returns the
1899    tree code of the object.  */
1900
1901 static inline enum tree_code
1902 gimple_assign_rhs_code (const_gimple gs)
1903 {
1904   enum tree_code code;
1905   GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
1906
1907   code = (enum tree_code) gs->gsbase.subcode;
1908   /* While we initially set subcode to the TREE_CODE of the rhs for
1909      GIMPLE_SINGLE_RHS assigns we do not update that subcode to stay
1910      in sync when we rewrite stmts into SSA form or do SSA propagations.  */
1911   if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS)
1912     code = TREE_CODE (gimple_assign_rhs1 (gs));
1913
1914   return code;
1915 }
1916
1917
1918 /* Set CODE to be the code for the expression computed on the RHS of
1919    assignment S.  */
1920
1921 static inline void
1922 gimple_assign_set_rhs_code (gimple s, enum tree_code code)
1923 {
1924   GIMPLE_CHECK (s, GIMPLE_ASSIGN);
1925   s->gsbase.subcode = code;
1926 }
1927
1928
1929 /* Return the gimple rhs class of the code of the expression computed on
1930    the rhs of assignment statement GS.
1931    This will never return GIMPLE_INVALID_RHS.  */
1932
1933 static inline enum gimple_rhs_class
1934 gimple_assign_rhs_class (const_gimple gs)
1935 {
1936   return get_gimple_rhs_class (gimple_assign_rhs_code (gs));
1937 }
1938
1939 /* Return true if GS is an assignment with a singleton RHS, i.e.,
1940    there is no operator associated with the assignment itself.
1941    Unlike gimple_assign_copy_p, this predicate returns true for
1942    any RHS operand, including those that perform an operation
1943    and do not have the semantics of a copy, such as COND_EXPR.  */
1944
1945 static inline bool
1946 gimple_assign_single_p (gimple gs)
1947 {
1948   return (is_gimple_assign (gs)
1949           && gimple_assign_rhs_class (gs) == GIMPLE_SINGLE_RHS);
1950 }
1951
1952
1953 /* Return true if S is a type-cast assignment.  */
1954
1955 static inline bool
1956 gimple_assign_cast_p (gimple s)
1957 {
1958   if (is_gimple_assign (s))
1959     {
1960       enum tree_code sc = gimple_assign_rhs_code (s);
1961       return CONVERT_EXPR_CODE_P (sc)
1962              || sc == VIEW_CONVERT_EXPR
1963              || sc == FIX_TRUNC_EXPR;
1964     }
1965
1966   return false;
1967 }
1968
1969
1970 /* Return true if GS is a GIMPLE_CALL.  */
1971
1972 static inline bool
1973 is_gimple_call (const_gimple gs)
1974 {
1975   return gimple_code (gs) == GIMPLE_CALL;
1976 }
1977
1978 /* Return the LHS of call statement GS.  */
1979
1980 static inline tree
1981 gimple_call_lhs (const_gimple gs)
1982 {
1983   GIMPLE_CHECK (gs, GIMPLE_CALL);
1984   return gimple_op (gs, 0);
1985 }
1986
1987
1988 /* Return a pointer to the LHS of call statement GS.  */
1989
1990 static inline tree *
1991 gimple_call_lhs_ptr (const_gimple gs)
1992 {
1993   GIMPLE_CHECK (gs, GIMPLE_CALL);
1994   return gimple_op_ptr (gs, 0);
1995 }
1996
1997
1998 /* Set LHS to be the LHS operand of call statement GS.  */
1999
2000 static inline void
2001 gimple_call_set_lhs (gimple gs, tree lhs)
2002 {
2003   GIMPLE_CHECK (gs, GIMPLE_CALL);
2004   gimple_set_op (gs, 0, lhs);
2005   if (lhs && TREE_CODE (lhs) == SSA_NAME)
2006     SSA_NAME_DEF_STMT (lhs) = gs;
2007 }
2008
2009
2010 /* Return the function type of the function called by GS.  */
2011
2012 static inline tree
2013 gimple_call_fntype (const_gimple gs)
2014 {
2015   GIMPLE_CHECK (gs, GIMPLE_CALL);
2016   return gs->gimple_call.fntype;
2017 }
2018
2019 /* Set the type of the function called by GS to FNTYPE.  */
2020
2021 static inline void
2022 gimple_call_set_fntype (gimple gs, tree fntype)
2023 {
2024   GIMPLE_CHECK (gs, GIMPLE_CALL);
2025   gs->gimple_call.fntype = fntype;
2026 }
2027
2028
2029 /* Return the tree node representing the function called by call
2030    statement GS.  */
2031
2032 static inline tree
2033 gimple_call_fn (const_gimple gs)
2034 {
2035   GIMPLE_CHECK (gs, GIMPLE_CALL);
2036   return gimple_op (gs, 1);
2037 }
2038
2039 /* Return a pointer to the tree node representing the function called by call
2040    statement GS.  */
2041
2042 static inline tree *
2043 gimple_call_fn_ptr (const_gimple gs)
2044 {
2045   GIMPLE_CHECK (gs, GIMPLE_CALL);
2046   return gimple_op_ptr (gs, 1);
2047 }
2048
2049
2050 /* Set FN to be the function called by call statement GS.  */
2051
2052 static inline void
2053 gimple_call_set_fn (gimple gs, tree fn)
2054 {
2055   GIMPLE_CHECK (gs, GIMPLE_CALL);
2056   gimple_set_op (gs, 1, fn);
2057 }
2058
2059
2060 /* Set FNDECL to be the function called by call statement GS.  */
2061
2062 static inline void
2063 gimple_call_set_fndecl (gimple gs, tree decl)
2064 {
2065   GIMPLE_CHECK (gs, GIMPLE_CALL);
2066   gimple_set_op (gs, 1, build_fold_addr_expr_loc (gimple_location (gs), decl));
2067 }
2068
2069 /* Given a valid GIMPLE_CALL function address return the FUNCTION_DECL
2070    associated with the callee if known.  Otherwise return NULL_TREE.  */
2071
2072 static inline tree
2073 gimple_call_addr_fndecl (const_tree fn)
2074 {
2075   if (TREE_CODE (fn) == ADDR_EXPR)
2076     {
2077       tree fndecl = TREE_OPERAND (fn, 0);
2078       if (TREE_CODE (fndecl) == MEM_REF
2079           && TREE_CODE (TREE_OPERAND (fndecl, 0)) == ADDR_EXPR
2080           && integer_zerop (TREE_OPERAND (fndecl, 1)))
2081         fndecl = TREE_OPERAND (TREE_OPERAND (fndecl, 0), 0);
2082       if (TREE_CODE (fndecl) == FUNCTION_DECL)
2083         return fndecl;
2084     }
2085   return NULL_TREE;
2086 }
2087
2088 /* If a given GIMPLE_CALL's callee is a FUNCTION_DECL, return it.
2089    Otherwise return NULL.  This function is analogous to
2090    get_callee_fndecl in tree land.  */
2091
2092 static inline tree
2093 gimple_call_fndecl (const_gimple gs)
2094 {
2095   return gimple_call_addr_fndecl (gimple_call_fn (gs));
2096 }
2097
2098
2099 /* Return the type returned by call statement GS.  */
2100
2101 static inline tree
2102 gimple_call_return_type (const_gimple gs)
2103 {
2104   tree type = gimple_call_fntype (gs);
2105
2106   /* The type returned by a function is the type of its
2107      function type.  */
2108   return TREE_TYPE (type);
2109 }
2110
2111
2112 /* Return the static chain for call statement GS.  */
2113
2114 static inline tree
2115 gimple_call_chain (const_gimple gs)
2116 {
2117   GIMPLE_CHECK (gs, GIMPLE_CALL);
2118   return gimple_op (gs, 2);
2119 }
2120
2121
2122 /* Return a pointer to the static chain for call statement GS.  */
2123
2124 static inline tree *
2125 gimple_call_chain_ptr (const_gimple gs)
2126 {
2127   GIMPLE_CHECK (gs, GIMPLE_CALL);
2128   return gimple_op_ptr (gs, 2);
2129 }
2130
2131 /* Set CHAIN to be the static chain for call statement GS.  */
2132
2133 static inline void
2134 gimple_call_set_chain (gimple gs, tree chain)
2135 {
2136   GIMPLE_CHECK (gs, GIMPLE_CALL);
2137
2138   gimple_set_op (gs, 2, chain);
2139 }
2140
2141
2142 /* Return the number of arguments used by call statement GS.  */
2143
2144 static inline unsigned
2145 gimple_call_num_args (const_gimple gs)
2146 {
2147   unsigned num_ops;
2148   GIMPLE_CHECK (gs, GIMPLE_CALL);
2149   num_ops = gimple_num_ops (gs);
2150   return num_ops - 3;
2151 }
2152
2153
2154 /* Return the argument at position INDEX for call statement GS.  */
2155
2156 static inline tree
2157 gimple_call_arg (const_gimple gs, unsigned index)
2158 {
2159   GIMPLE_CHECK (gs, GIMPLE_CALL);
2160   return gimple_op (gs, index + 3);
2161 }
2162
2163
2164 /* Return a pointer to the argument at position INDEX for call
2165    statement GS.  */
2166
2167 static inline tree *
2168 gimple_call_arg_ptr (const_gimple gs, unsigned index)
2169 {
2170   GIMPLE_CHECK (gs, GIMPLE_CALL);
2171   return gimple_op_ptr (gs, index + 3);
2172 }
2173
2174
2175 /* Set ARG to be the argument at position INDEX for call statement GS.  */
2176
2177 static inline void
2178 gimple_call_set_arg (gimple gs, unsigned index, tree arg)
2179 {
2180   GIMPLE_CHECK (gs, GIMPLE_CALL);
2181   gimple_set_op (gs, index + 3, arg);
2182 }
2183
2184
2185 /* If TAIL_P is true, mark call statement S as being a tail call
2186    (i.e., a call just before the exit of a function).  These calls are
2187    candidate for tail call optimization.  */
2188
2189 static inline void
2190 gimple_call_set_tail (gimple s, bool tail_p)
2191 {
2192   GIMPLE_CHECK (s, GIMPLE_CALL);
2193   if (tail_p)
2194     s->gsbase.subcode |= GF_CALL_TAILCALL;
2195   else
2196     s->gsbase.subcode &= ~GF_CALL_TAILCALL;
2197 }
2198
2199
2200 /* Return true if GIMPLE_CALL S is marked as a tail call.  */
2201
2202 static inline bool
2203 gimple_call_tail_p (gimple s)
2204 {
2205   GIMPLE_CHECK (s, GIMPLE_CALL);
2206   return (s->gsbase.subcode & GF_CALL_TAILCALL) != 0;
2207 }
2208
2209
2210 /* Set the inlinable status of GIMPLE_CALL S to INLINABLE_P.  */
2211
2212 static inline void
2213 gimple_call_set_cannot_inline (gimple s, bool inlinable_p)
2214 {
2215   GIMPLE_CHECK (s, GIMPLE_CALL);
2216   if (inlinable_p)
2217     s->gsbase.subcode |= GF_CALL_CANNOT_INLINE;
2218   else
2219     s->gsbase.subcode &= ~GF_CALL_CANNOT_INLINE;
2220 }
2221
2222
2223 /* Return true if GIMPLE_CALL S cannot be inlined.  */
2224
2225 static inline bool
2226 gimple_call_cannot_inline_p (gimple s)
2227 {
2228   GIMPLE_CHECK (s, GIMPLE_CALL);
2229   return (s->gsbase.subcode & GF_CALL_CANNOT_INLINE) != 0;
2230 }
2231
2232
2233 /* If RETURN_SLOT_OPT_P is true mark GIMPLE_CALL S as valid for return
2234    slot optimization.  This transformation uses the target of the call
2235    expansion as the return slot for calls that return in memory.  */
2236
2237 static inline void
2238 gimple_call_set_return_slot_opt (gimple s, bool return_slot_opt_p)
2239 {
2240   GIMPLE_CHECK (s, GIMPLE_CALL);
2241   if (return_slot_opt_p)
2242     s->gsbase.subcode |= GF_CALL_RETURN_SLOT_OPT;
2243   else
2244     s->gsbase.subcode &= ~GF_CALL_RETURN_SLOT_OPT;
2245 }
2246
2247
2248 /* Return true if S is marked for return slot optimization.  */
2249
2250 static inline bool
2251 gimple_call_return_slot_opt_p (gimple s)
2252 {
2253   GIMPLE_CHECK (s, GIMPLE_CALL);
2254   return (s->gsbase.subcode & GF_CALL_RETURN_SLOT_OPT) != 0;
2255 }
2256
2257
2258 /* If FROM_THUNK_P is true, mark GIMPLE_CALL S as being the jump from a
2259    thunk to the thunked-to function.  */
2260
2261 static inline void
2262 gimple_call_set_from_thunk (gimple s, bool from_thunk_p)
2263 {
2264   GIMPLE_CHECK (s, GIMPLE_CALL);
2265   if (from_thunk_p)
2266     s->gsbase.subcode |= GF_CALL_FROM_THUNK;
2267   else
2268     s->gsbase.subcode &= ~GF_CALL_FROM_THUNK;
2269 }
2270
2271
2272 /* Return true if GIMPLE_CALL S is a jump from a thunk.  */
2273
2274 static inline bool
2275 gimple_call_from_thunk_p (gimple s)
2276 {
2277   GIMPLE_CHECK (s, GIMPLE_CALL);
2278   return (s->gsbase.subcode & GF_CALL_FROM_THUNK) != 0;
2279 }
2280
2281
2282 /* If PASS_ARG_PACK_P is true, GIMPLE_CALL S is a stdarg call that needs the
2283    argument pack in its argument list.  */
2284
2285 static inline void
2286 gimple_call_set_va_arg_pack (gimple s, bool pass_arg_pack_p)
2287 {
2288   GIMPLE_CHECK (s, GIMPLE_CALL);
2289   if (pass_arg_pack_p)
2290     s->gsbase.subcode |= GF_CALL_VA_ARG_PACK;
2291   else
2292     s->gsbase.subcode &= ~GF_CALL_VA_ARG_PACK;
2293 }
2294
2295
2296 /* Return true if GIMPLE_CALL S is a stdarg call that needs the
2297    argument pack in its argument list.  */
2298
2299 static inline bool
2300 gimple_call_va_arg_pack_p (gimple s)
2301 {
2302   GIMPLE_CHECK (s, GIMPLE_CALL);
2303   return (s->gsbase.subcode & GF_CALL_VA_ARG_PACK) != 0;
2304 }
2305
2306
2307 /* Return true if S is a noreturn call.  */
2308
2309 static inline bool
2310 gimple_call_noreturn_p (gimple s)
2311 {
2312   GIMPLE_CHECK (s, GIMPLE_CALL);
2313   return (gimple_call_flags (s) & ECF_NORETURN) != 0;
2314 }
2315
2316
2317 /* If NOTHROW_P is true, GIMPLE_CALL S is a call that is known to not throw
2318    even if the called function can throw in other cases.  */
2319
2320 static inline void
2321 gimple_call_set_nothrow (gimple s, bool nothrow_p)
2322 {
2323   GIMPLE_CHECK (s, GIMPLE_CALL);
2324   if (nothrow_p)
2325     s->gsbase.subcode |= GF_CALL_NOTHROW;
2326   else
2327     s->gsbase.subcode &= ~GF_CALL_NOTHROW;
2328 }
2329
2330 /* Return true if S is a nothrow call.  */
2331
2332 static inline bool
2333 gimple_call_nothrow_p (gimple s)
2334 {
2335   GIMPLE_CHECK (s, GIMPLE_CALL);
2336   return (gimple_call_flags (s) & ECF_NOTHROW) != 0;
2337 }
2338
2339 /* If FOR_VAR is true, GIMPLE_CALL S is a call to builtin_alloca that
2340    is known to be emitted for VLA objects.  Those are wrapped by
2341    stack_save/stack_restore calls and hence can't lead to unbounded
2342    stack growth even when they occur in loops.  */
2343
2344 static inline void
2345 gimple_call_set_alloca_for_var (gimple s, bool for_var)
2346 {
2347   GIMPLE_CHECK (s, GIMPLE_CALL);
2348   if (for_var)
2349     s->gsbase.subcode |= GF_CALL_ALLOCA_FOR_VAR;
2350   else
2351     s->gsbase.subcode &= ~GF_CALL_ALLOCA_FOR_VAR;
2352 }
2353
2354 /* Return true of S is a call to builtin_alloca emitted for VLA objects.  */
2355
2356 static inline bool
2357 gimple_call_alloca_for_var_p (gimple s)
2358 {
2359   GIMPLE_CHECK (s, GIMPLE_CALL);
2360   return (s->gsbase.subcode & GF_CALL_ALLOCA_FOR_VAR) != 0;
2361 }
2362
2363 /* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL.  */
2364
2365 static inline void
2366 gimple_call_copy_flags (gimple dest_call, gimple orig_call)
2367 {
2368   GIMPLE_CHECK (dest_call, GIMPLE_CALL);
2369   GIMPLE_CHECK (orig_call, GIMPLE_CALL);
2370   dest_call->gsbase.subcode = orig_call->gsbase.subcode;
2371 }
2372
2373
2374 /* Return a pointer to the points-to solution for the set of call-used
2375    variables of the call CALL.  */
2376
2377 static inline struct pt_solution *
2378 gimple_call_use_set (gimple call)
2379 {
2380   GIMPLE_CHECK (call, GIMPLE_CALL);
2381   return &call->gimple_call.call_used;
2382 }
2383
2384
2385 /* Return a pointer to the points-to solution for the set of call-used
2386    variables of the call CALL.  */
2387
2388 static inline struct pt_solution *
2389 gimple_call_clobber_set (gimple call)
2390 {
2391   GIMPLE_CHECK (call, GIMPLE_CALL);
2392   return &call->gimple_call.call_clobbered;
2393 }
2394
2395
2396 /* Returns true if this is a GIMPLE_ASSIGN or a GIMPLE_CALL with a
2397    non-NULL lhs.  */
2398
2399 static inline bool
2400 gimple_has_lhs (gimple stmt)
2401 {
2402   return (is_gimple_assign (stmt)
2403           || (is_gimple_call (stmt)
2404               && gimple_call_lhs (stmt) != NULL_TREE));
2405 }
2406
2407
2408 /* Return the code of the predicate computed by conditional statement GS.  */
2409
2410 static inline enum tree_code
2411 gimple_cond_code (const_gimple gs)
2412 {
2413   GIMPLE_CHECK (gs, GIMPLE_COND);
2414   return (enum tree_code) gs->gsbase.subcode;
2415 }
2416
2417
2418 /* Set CODE to be the predicate code for the conditional statement GS.  */
2419
2420 static inline void
2421 gimple_cond_set_code (gimple gs, enum tree_code code)
2422 {
2423   GIMPLE_CHECK (gs, GIMPLE_COND);
2424   gs->gsbase.subcode = code;
2425 }
2426
2427
2428 /* Return the LHS of the predicate computed by conditional statement GS.  */
2429
2430 static inline tree
2431 gimple_cond_lhs (const_gimple gs)
2432 {
2433   GIMPLE_CHECK (gs, GIMPLE_COND);
2434   return gimple_op (gs, 0);
2435 }
2436
2437 /* Return the pointer to the LHS of the predicate computed by conditional
2438    statement GS.  */
2439
2440 static inline tree *
2441 gimple_cond_lhs_ptr (const_gimple gs)
2442 {
2443   GIMPLE_CHECK (gs, GIMPLE_COND);
2444   return gimple_op_ptr (gs, 0);
2445 }
2446
2447 /* Set LHS to be the LHS operand of the predicate computed by
2448    conditional statement GS.  */
2449
2450 static inline void
2451 gimple_cond_set_lhs (gimple gs, tree lhs)
2452 {
2453   GIMPLE_CHECK (gs, GIMPLE_COND);
2454   gimple_set_op (gs, 0, lhs);
2455 }
2456
2457
2458 /* Return the RHS operand of the predicate computed by conditional GS.  */
2459
2460 static inline tree
2461 gimple_cond_rhs (const_gimple gs)
2462 {
2463   GIMPLE_CHECK (gs, GIMPLE_COND);
2464   return gimple_op (gs, 1);
2465 }
2466
2467 /* Return the pointer to the RHS operand of the predicate computed by
2468    conditional GS.  */
2469
2470 static inline tree *
2471 gimple_cond_rhs_ptr (const_gimple gs)
2472 {
2473   GIMPLE_CHECK (gs, GIMPLE_COND);
2474   return gimple_op_ptr (gs, 1);
2475 }
2476
2477
2478 /* Set RHS to be the RHS operand of the predicate computed by
2479    conditional statement GS.  */
2480
2481 static inline void
2482 gimple_cond_set_rhs (gimple gs, tree rhs)
2483 {
2484   GIMPLE_CHECK (gs, GIMPLE_COND);
2485   gimple_set_op (gs, 1, rhs);
2486 }
2487
2488
2489 /* Return the label used by conditional statement GS when its
2490    predicate evaluates to true.  */
2491
2492 static inline tree
2493 gimple_cond_true_label (const_gimple gs)
2494 {
2495   GIMPLE_CHECK (gs, GIMPLE_COND);
2496   return gimple_op (gs, 2);
2497 }
2498
2499
2500 /* Set LABEL to be the label used by conditional statement GS when its
2501    predicate evaluates to true.  */
2502
2503 static inline void
2504 gimple_cond_set_true_label (gimple gs, tree label)
2505 {
2506   GIMPLE_CHECK (gs, GIMPLE_COND);
2507   gimple_set_op (gs, 2, label);
2508 }
2509
2510
2511 /* Set LABEL to be the label used by conditional statement GS when its
2512    predicate evaluates to false.  */
2513
2514 static inline void
2515 gimple_cond_set_false_label (gimple gs, tree label)
2516 {
2517   GIMPLE_CHECK (gs, GIMPLE_COND);
2518   gimple_set_op (gs, 3, label);
2519 }
2520
2521
2522 /* Return the label used by conditional statement GS when its
2523    predicate evaluates to false.  */
2524
2525 static inline tree
2526 gimple_cond_false_label (const_gimple gs)
2527 {
2528   GIMPLE_CHECK (gs, GIMPLE_COND);
2529   return gimple_op (gs, 3);
2530 }
2531
2532
2533 /* Set the conditional COND_STMT to be of the form 'if (1 == 0)'.  */
2534
2535 static inline void
2536 gimple_cond_make_false (gimple gs)
2537 {
2538   gimple_cond_set_lhs (gs, boolean_true_node);
2539   gimple_cond_set_rhs (gs, boolean_false_node);
2540   gs->gsbase.subcode = EQ_EXPR;
2541 }
2542
2543
2544 /* Set the conditional COND_STMT to be of the form 'if (1 == 1)'.  */
2545
2546 static inline void
2547 gimple_cond_make_true (gimple gs)
2548 {
2549   gimple_cond_set_lhs (gs, boolean_true_node);
2550   gimple_cond_set_rhs (gs, boolean_true_node);
2551   gs->gsbase.subcode = EQ_EXPR;
2552 }
2553
2554 /* Check if conditional statemente GS is of the form 'if (1 == 1)',
2555   'if (0 == 0)', 'if (1 != 0)' or 'if (0 != 1)' */
2556
2557 static inline bool
2558 gimple_cond_true_p (const_gimple gs)
2559 {
2560   tree lhs = gimple_cond_lhs (gs);
2561   tree rhs = gimple_cond_rhs (gs);
2562   enum tree_code code = gimple_cond_code (gs);
2563
2564   if (lhs != boolean_true_node && lhs != boolean_false_node)
2565     return false;
2566
2567   if (rhs != boolean_true_node && rhs != boolean_false_node)
2568     return false;
2569
2570   if (code == NE_EXPR && lhs != rhs)
2571     return true;
2572
2573   if (code == EQ_EXPR && lhs == rhs)
2574       return true;
2575
2576   return false;
2577 }
2578
2579 /* Check if conditional statement GS is of the form 'if (1 != 1)',
2580    'if (0 != 0)', 'if (1 == 0)' or 'if (0 == 1)' */
2581
2582 static inline bool
2583 gimple_cond_false_p (const_gimple gs)
2584 {
2585   tree lhs = gimple_cond_lhs (gs);
2586   tree rhs = gimple_cond_rhs (gs);
2587   enum tree_code code = gimple_cond_code (gs);
2588
2589   if (lhs != boolean_true_node && lhs != boolean_false_node)
2590     return false;
2591
2592   if (rhs != boolean_true_node && rhs != boolean_false_node)
2593     return false;
2594
2595   if (code == NE_EXPR && lhs == rhs)
2596     return true;
2597
2598   if (code == EQ_EXPR && lhs != rhs)
2599       return true;
2600
2601   return false;
2602 }
2603
2604 /* Check if conditional statement GS is of the form 'if (var != 0)' or
2605    'if (var == 1)' */
2606
2607 static inline bool
2608 gimple_cond_single_var_p (gimple gs)
2609 {
2610   if (gimple_cond_code (gs) == NE_EXPR
2611       && gimple_cond_rhs (gs) == boolean_false_node)
2612     return true;
2613
2614   if (gimple_cond_code (gs) == EQ_EXPR
2615       && gimple_cond_rhs (gs) == boolean_true_node)
2616     return true;
2617
2618   return false;
2619 }
2620
2621 /* Set the code, LHS and RHS of GIMPLE_COND STMT from CODE, LHS and RHS.  */
2622
2623 static inline void
2624 gimple_cond_set_condition (gimple stmt, enum tree_code code, tree lhs, tree rhs)
2625 {
2626   gimple_cond_set_code (stmt, code);
2627   gimple_cond_set_lhs (stmt, lhs);
2628   gimple_cond_set_rhs (stmt, rhs);
2629 }
2630
2631 /* Return the LABEL_DECL node used by GIMPLE_LABEL statement GS.  */
2632
2633 static inline tree
2634 gimple_label_label (const_gimple gs)
2635 {
2636   GIMPLE_CHECK (gs, GIMPLE_LABEL);
2637   return gimple_op (gs, 0);
2638 }
2639
2640
2641 /* Set LABEL to be the LABEL_DECL node used by GIMPLE_LABEL statement
2642    GS.  */
2643
2644 static inline void
2645 gimple_label_set_label (gimple gs, tree label)
2646 {
2647   GIMPLE_CHECK (gs, GIMPLE_LABEL);
2648   gimple_set_op (gs, 0, label);
2649 }
2650
2651
2652 /* Return the destination of the unconditional jump GS.  */
2653
2654 static inline tree
2655 gimple_goto_dest (const_gimple gs)
2656 {
2657   GIMPLE_CHECK (gs, GIMPLE_GOTO);
2658   return gimple_op (gs, 0);
2659 }
2660
2661
2662 /* Set DEST to be the destination of the unconditonal jump GS.  */
2663
2664 static inline void
2665 gimple_goto_set_dest (gimple gs, tree dest)
2666 {
2667   GIMPLE_CHECK (gs, GIMPLE_GOTO);
2668   gimple_set_op (gs, 0, dest);
2669 }
2670
2671
2672 /* Return the variables declared in the GIMPLE_BIND statement GS.  */
2673
2674 static inline tree
2675 gimple_bind_vars (const_gimple gs)
2676 {
2677   GIMPLE_CHECK (gs, GIMPLE_BIND);
2678   return gs->gimple_bind.vars;
2679 }
2680
2681
2682 /* Set VARS to be the set of variables declared in the GIMPLE_BIND
2683    statement GS.  */
2684
2685 static inline void
2686 gimple_bind_set_vars (gimple gs, tree vars)
2687 {
2688   GIMPLE_CHECK (gs, GIMPLE_BIND);
2689   gs->gimple_bind.vars = vars;
2690 }
2691
2692
2693 /* Append VARS to the set of variables declared in the GIMPLE_BIND
2694    statement GS.  */
2695
2696 static inline void
2697 gimple_bind_append_vars (gimple gs, tree vars)
2698 {
2699   GIMPLE_CHECK (gs, GIMPLE_BIND);
2700   gs->gimple_bind.vars = chainon (gs->gimple_bind.vars, vars);
2701 }
2702
2703
2704 /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS.  */
2705
2706 static inline gimple_seq
2707 gimple_bind_body (gimple gs)
2708 {
2709   GIMPLE_CHECK (gs, GIMPLE_BIND);
2710   return gs->gimple_bind.body;
2711 }
2712
2713
2714 /* Set SEQ to be the GIMPLE sequence contained in the GIMPLE_BIND
2715    statement GS.  */
2716
2717 static inline void
2718 gimple_bind_set_body (gimple gs, gimple_seq seq)
2719 {
2720   GIMPLE_CHECK (gs, GIMPLE_BIND);
2721   gs->gimple_bind.body = seq;
2722 }
2723
2724
2725 /* Append a statement to the end of a GIMPLE_BIND's body.  */
2726
2727 static inline void
2728 gimple_bind_add_stmt (gimple gs, gimple stmt)
2729 {
2730   GIMPLE_CHECK (gs, GIMPLE_BIND);
2731   gimple_seq_add_stmt (&gs->gimple_bind.body, stmt);
2732 }
2733
2734
2735 /* Append a sequence of statements to the end of a GIMPLE_BIND's body.  */
2736
2737 static inline void
2738 gimple_bind_add_seq (gimple gs, gimple_seq seq)
2739 {
2740   GIMPLE_CHECK (gs, GIMPLE_BIND);
2741   gimple_seq_add_seq (&gs->gimple_bind.body, seq);
2742 }
2743
2744
2745 /* Return the TREE_BLOCK node associated with GIMPLE_BIND statement
2746    GS.  This is analogous to the BIND_EXPR_BLOCK field in trees.  */
2747
2748 static inline tree
2749 gimple_bind_block (const_gimple gs)
2750 {
2751   GIMPLE_CHECK (gs, GIMPLE_BIND);
2752   return gs->gimple_bind.block;
2753 }
2754
2755
2756 /* Set BLOCK to be the TREE_BLOCK node associated with GIMPLE_BIND
2757    statement GS.  */
2758
2759 static inline void
2760 gimple_bind_set_block (gimple gs, tree block)
2761 {
2762   GIMPLE_CHECK (gs, GIMPLE_BIND);
2763   gcc_gimple_checking_assert (block == NULL_TREE
2764                               || TREE_CODE (block) == BLOCK);
2765   gs->gimple_bind.block = block;
2766 }
2767
2768
2769 /* Return the number of input operands for GIMPLE_ASM GS.  */
2770
2771 static inline unsigned
2772 gimple_asm_ninputs (const_gimple gs)
2773 {
2774   GIMPLE_CHECK (gs, GIMPLE_ASM);
2775   return gs->gimple_asm.ni;
2776 }
2777
2778
2779 /* Return the number of output operands for GIMPLE_ASM GS.  */
2780
2781 static inline unsigned
2782 gimple_asm_noutputs (const_gimple gs)
2783 {
2784   GIMPLE_CHECK (gs, GIMPLE_ASM);
2785   return gs->gimple_asm.no;
2786 }
2787
2788
2789 /* Return the number of clobber operands for GIMPLE_ASM GS.  */
2790
2791 static inline unsigned
2792 gimple_asm_nclobbers (const_gimple gs)
2793 {
2794   GIMPLE_CHECK (gs, GIMPLE_ASM);
2795   return gs->gimple_asm.nc;
2796 }
2797
2798 /* Return the number of label operands for GIMPLE_ASM GS.  */
2799
2800 static inline unsigned
2801 gimple_asm_nlabels (const_gimple gs)
2802 {
2803   GIMPLE_CHECK (gs, GIMPLE_ASM);
2804   return gs->gimple_asm.nl;
2805 }
2806
2807 /* Return input operand INDEX of GIMPLE_ASM GS.  */
2808
2809 static inline tree
2810 gimple_asm_input_op (const_gimple gs, unsigned index)
2811 {
2812   GIMPLE_CHECK (gs, GIMPLE_ASM);
2813   gcc_gimple_checking_assert (index <= gs->gimple_asm.ni);
2814   return gimple_op (gs, index);
2815 }
2816
2817 /* Return a pointer to input operand INDEX of GIMPLE_ASM GS.  */
2818
2819 static inline tree *
2820 gimple_asm_input_op_ptr (const_gimple gs, unsigned index)
2821 {
2822   GIMPLE_CHECK (gs, GIMPLE_ASM);
2823   gcc_gimple_checking_assert (index <= gs->gimple_asm.ni);
2824   return gimple_op_ptr (gs, index);
2825 }
2826
2827
2828 /* Set IN_OP to be input operand INDEX in GIMPLE_ASM GS.  */
2829
2830 static inline void
2831 gimple_asm_set_input_op (gimple gs, unsigned index, tree in_op)
2832 {
2833   GIMPLE_CHECK (gs, GIMPLE_ASM);
2834   gcc_gimple_checking_assert (index <= gs->gimple_asm.ni
2835                               && TREE_CODE (in_op) == TREE_LIST);
2836   gimple_set_op (gs, index, in_op);
2837 }
2838
2839
2840 /* Return output operand INDEX of GIMPLE_ASM GS.  */
2841
2842 static inline tree
2843 gimple_asm_output_op (const_gimple gs, unsigned index)
2844 {
2845   GIMPLE_CHECK (gs, GIMPLE_ASM);
2846   gcc_gimple_checking_assert (index <= gs->gimple_asm.no);
2847   return gimple_op (gs, index + gs->gimple_asm.ni);
2848 }
2849
2850 /* Return a pointer to output operand INDEX of GIMPLE_ASM GS.  */
2851
2852 static inline tree *
2853 gimple_asm_output_op_ptr (const_gimple gs, unsigned index)
2854 {
2855   GIMPLE_CHECK (gs, GIMPLE_ASM);
2856   gcc_gimple_checking_assert (index <= gs->gimple_asm.no);
2857   return gimple_op_ptr (gs, index + gs->gimple_asm.ni);
2858 }
2859
2860
2861 /* Set OUT_OP to be output operand INDEX in GIMPLE_ASM GS.  */
2862
2863 static inline void
2864 gimple_asm_set_output_op (gimple gs, unsigned index, tree out_op)
2865 {
2866   GIMPLE_CHECK (gs, GIMPLE_ASM);
2867   gcc_gimple_checking_assert (index <= gs->gimple_asm.no
2868                               && TREE_CODE (out_op) == TREE_LIST);
2869   gimple_set_op (gs, index + gs->gimple_asm.ni, out_op);
2870 }
2871
2872
2873 /* Return clobber operand INDEX of GIMPLE_ASM GS.  */
2874
2875 static inline tree
2876 gimple_asm_clobber_op (const_gimple gs, unsigned index)
2877 {
2878   GIMPLE_CHECK (gs, GIMPLE_ASM);
2879   gcc_gimple_checking_assert (index <= gs->gimple_asm.nc);
2880   return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no);
2881 }
2882
2883
2884 /* Set CLOBBER_OP to be clobber operand INDEX in GIMPLE_ASM GS.  */
2885
2886 static inline void
2887 gimple_asm_set_clobber_op (gimple gs, unsigned index, tree clobber_op)
2888 {
2889   GIMPLE_CHECK (gs, GIMPLE_ASM);
2890   gcc_gimple_checking_assert (index <= gs->gimple_asm.nc
2891                               && TREE_CODE (clobber_op) == TREE_LIST);
2892   gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.no, clobber_op);
2893 }
2894
2895 /* Return label operand INDEX of GIMPLE_ASM GS.  */
2896
2897 static inline tree
2898 gimple_asm_label_op (const_gimple gs, unsigned index)
2899 {
2900   GIMPLE_CHECK (gs, GIMPLE_ASM);
2901   gcc_gimple_checking_assert (index <= gs->gimple_asm.nl);
2902   return gimple_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.nc);
2903 }
2904
2905 /* Set LABEL_OP to be label operand INDEX in GIMPLE_ASM GS.  */
2906
2907 static inline void
2908 gimple_asm_set_label_op (gimple gs, unsigned index, tree label_op)
2909 {
2910   GIMPLE_CHECK (gs, GIMPLE_ASM);
2911   gcc_gimple_checking_assert (index <= gs->gimple_asm.nl
2912                               && TREE_CODE (label_op) == TREE_LIST);
2913   gimple_set_op (gs, index + gs->gimple_asm.ni + gs->gimple_asm.nc, label_op);
2914 }
2915
2916 /* Return the string representing the assembly instruction in
2917    GIMPLE_ASM GS.  */
2918
2919 static inline const char *
2920 gimple_asm_string (const_gimple gs)
2921 {
2922   GIMPLE_CHECK (gs, GIMPLE_ASM);
2923   return gs->gimple_asm.string;
2924 }
2925
2926
2927 /* Return true if GS is an asm statement marked volatile.  */
2928
2929 static inline bool
2930 gimple_asm_volatile_p (const_gimple gs)
2931 {
2932   GIMPLE_CHECK (gs, GIMPLE_ASM);
2933   return (gs->gsbase.subcode & GF_ASM_VOLATILE) != 0;
2934 }
2935
2936
2937 /* If VOLATLE_P is true, mark asm statement GS as volatile.  */
2938
2939 static inline void
2940 gimple_asm_set_volatile (gimple gs, bool volatile_p)
2941 {
2942   GIMPLE_CHECK (gs, GIMPLE_ASM);
2943   if (volatile_p)
2944     gs->gsbase.subcode |= GF_ASM_VOLATILE;
2945   else
2946     gs->gsbase.subcode &= ~GF_ASM_VOLATILE;
2947 }
2948
2949
2950 /* If INPUT_P is true, mark asm GS as an ASM_INPUT.  */
2951
2952 static inline void
2953 gimple_asm_set_input (gimple gs, bool input_p)
2954 {
2955   GIMPLE_CHECK (gs, GIMPLE_ASM);
2956   if (input_p)
2957     gs->gsbase.subcode |= GF_ASM_INPUT;
2958   else
2959     gs->gsbase.subcode &= ~GF_ASM_INPUT;
2960 }
2961
2962
2963 /* Return true if asm GS is an ASM_INPUT.  */
2964
2965 static inline bool
2966 gimple_asm_input_p (const_gimple gs)
2967 {
2968   GIMPLE_CHECK (gs, GIMPLE_ASM);
2969   return (gs->gsbase.subcode & GF_ASM_INPUT) != 0;
2970 }
2971
2972
2973 /* Return the types handled by GIMPLE_CATCH statement GS.  */
2974
2975 static inline tree
2976 gimple_catch_types (const_gimple gs)
2977 {
2978   GIMPLE_CHECK (gs, GIMPLE_CATCH);
2979   return gs->gimple_catch.types;
2980 }
2981
2982
2983 /* Return a pointer to the types handled by GIMPLE_CATCH statement GS.  */
2984
2985 static inline tree *
2986 gimple_catch_types_ptr (gimple gs)
2987 {
2988   GIMPLE_CHECK (gs, GIMPLE_CATCH);
2989   return &gs->gimple_catch.types;
2990 }
2991
2992
2993 /* Return the GIMPLE sequence representing the body of the handler of
2994    GIMPLE_CATCH statement GS.  */
2995
2996 static inline gimple_seq
2997 gimple_catch_handler (gimple gs)
2998 {
2999   GIMPLE_CHECK (gs, GIMPLE_CATCH);
3000   return gs->gimple_catch.handler;
3001 }
3002
3003
3004 /* Return a pointer to the GIMPLE sequence representing the body of
3005    the handler of GIMPLE_CATCH statement GS.  */
3006
3007 static inline gimple_seq *
3008 gimple_catch_handler_ptr (gimple gs)
3009 {
3010   GIMPLE_CHECK (gs, GIMPLE_CATCH);
3011   return &gs->gimple_catch.handler;
3012 }
3013
3014
3015 /* Set T to be the set of types handled by GIMPLE_CATCH GS.  */
3016
3017 static inline void
3018 gimple_catch_set_types (gimple gs, tree t)
3019 {
3020   GIMPLE_CHECK (gs, GIMPLE_CATCH);
3021   gs->gimple_catch.types = t;
3022 }
3023
3024
3025 /* Set HANDLER to be the body of GIMPLE_CATCH GS.  */
3026
3027 static inline void
3028 gimple_catch_set_handler (gimple gs, gimple_seq handler)
3029 {
3030   GIMPLE_CHECK (gs, GIMPLE_CATCH);
3031   gs->gimple_catch.handler = handler;
3032 }
3033
3034
3035 /* Return the types handled by GIMPLE_EH_FILTER statement GS.  */
3036
3037 static inline tree
3038 gimple_eh_filter_types (const_gimple gs)
3039 {
3040   GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
3041   return gs->gimple_eh_filter.types;
3042 }
3043
3044
3045 /* Return a pointer to the types handled by GIMPLE_EH_FILTER statement
3046    GS.  */
3047
3048 static inline tree *
3049 gimple_eh_filter_types_ptr (gimple gs)
3050 {
3051   GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
3052   return &gs->gimple_eh_filter.types;
3053 }
3054
3055
3056 /* Return the sequence of statement to execute when GIMPLE_EH_FILTER
3057    statement fails.  */
3058
3059 static inline gimple_seq
3060 gimple_eh_filter_failure (gimple gs)
3061 {
3062   GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
3063   return gs->gimple_eh_filter.failure;
3064 }
3065
3066
3067 /* Set TYPES to be the set of types handled by GIMPLE_EH_FILTER GS.  */
3068
3069 static inline void
3070 gimple_eh_filter_set_types (gimple gs, tree types)
3071 {
3072   GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
3073   gs->gimple_eh_filter.types = types;
3074 }
3075
3076
3077 /* Set FAILURE to be the sequence of statements to execute on failure
3078    for GIMPLE_EH_FILTER GS.  */
3079
3080 static inline void
3081 gimple_eh_filter_set_failure (gimple gs, gimple_seq failure)
3082 {
3083   GIMPLE_CHECK (gs, GIMPLE_EH_FILTER);
3084   gs->gimple_eh_filter.failure = failure;
3085 }
3086
3087 /* Get the function decl to be called by the MUST_NOT_THROW region.  */
3088
3089 static inline tree
3090 gimple_eh_must_not_throw_fndecl (gimple gs)
3091 {
3092   GIMPLE_CHECK (gs, GIMPLE_EH_MUST_NOT_THROW);
3093   return gs->gimple_eh_mnt.fndecl;
3094 }
3095
3096 /* Set the function decl to be called by GS to DECL.  */
3097
3098 static inline void
3099 gimple_eh_must_not_throw_set_fndecl (gimple gs, tree decl)
3100 {
3101   GIMPLE_CHECK (gs, GIMPLE_EH_MUST_NOT_THROW);
3102   gs->gimple_eh_mnt.fndecl = decl;
3103 }
3104
3105
3106 /* GIMPLE_TRY accessors. */
3107
3108 /* Return the kind of try block represented by GIMPLE_TRY GS.  This is
3109    either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY.  */
3110
3111 static inline enum gimple_try_flags
3112 gimple_try_kind (const_gimple gs)
3113 {
3114   GIMPLE_CHECK (gs, GIMPLE_TRY);
3115   return (enum gimple_try_flags) (gs->gsbase.subcode & GIMPLE_TRY_KIND);
3116 }
3117
3118
3119 /* Set the kind of try block represented by GIMPLE_TRY GS.  */
3120
3121 static inline void
3122 gimple_try_set_kind (gimple gs, enum gimple_try_flags kind)
3123 {
3124   GIMPLE_CHECK (gs, GIMPLE_TRY);
3125   gcc_gimple_checking_assert (kind == GIMPLE_TRY_CATCH
3126                               || kind == GIMPLE_TRY_FINALLY);
3127   if (gimple_try_kind (gs) != kind)
3128     gs->gsbase.subcode = (unsigned int) kind;
3129 }
3130
3131
3132 /* Return the GIMPLE_TRY_CATCH_IS_CLEANUP flag.  */
3133
3134 static inline bool
3135 gimple_try_catch_is_cleanup (const_gimple gs)
3136 {
3137   gcc_gimple_checking_assert (gimple_try_kind (gs) == GIMPLE_TRY_CATCH);
3138   return (gs->gsbase.subcode & GIMPLE_TRY_CATCH_IS_CLEANUP) != 0;
3139 }
3140
3141
3142 /* Return the sequence of statements used as the body for GIMPLE_TRY GS.  */
3143
3144 static inline gimple_seq
3145 gimple_try_eval (gimple gs)
3146 {
3147   GIMPLE_CHECK (gs, GIMPLE_TRY);
3148   return gs->gimple_try.eval;
3149 }
3150
3151
3152 /* Return the sequence of statements used as the cleanup body for
3153    GIMPLE_TRY GS.  */
3154
3155 static inline gimple_seq
3156 gimple_try_cleanup (gimple gs)
3157 {
3158   GIMPLE_CHECK (gs, GIMPLE_TRY);
3159   return gs->gimple_try.cleanup;
3160 }
3161
3162
3163 /* Set the GIMPLE_TRY_CATCH_IS_CLEANUP flag.  */
3164
3165 static inline void
3166 gimple_try_set_catch_is_cleanup (gimple g, bool catch_is_cleanup)
3167 {
3168   gcc_gimple_checking_assert (gimple_try_kind (g) == GIMPLE_TRY_CATCH);
3169   if (catch_is_cleanup)
3170     g->gsbase.subcode |= GIMPLE_TRY_CATCH_IS_CLEANUP;
3171   else
3172     g->gsbase.subcode &= ~GIMPLE_TRY_CATCH_IS_CLEANUP;
3173 }
3174
3175
3176 /* Set EVAL to be the sequence of statements to use as the body for
3177    GIMPLE_TRY GS.  */
3178
3179 static inline void
3180 gimple_try_set_eval (gimple gs, gimple_seq eval)
3181 {
3182   GIMPLE_CHECK (gs, GIMPLE_TRY);
3183   gs->gimple_try.eval = eval;
3184 }
3185
3186
3187 /* Set CLEANUP to be the sequence of statements to use as the cleanup
3188    body for GIMPLE_TRY GS.  */
3189
3190 static inline void
3191 gimple_try_set_cleanup (gimple gs, gimple_seq cleanup)
3192 {
3193   GIMPLE_CHECK (gs, GIMPLE_TRY);
3194   gs->gimple_try.cleanup = cleanup;
3195 }
3196
3197
3198 /* Return the cleanup sequence for cleanup statement GS.  */
3199
3200 static inline gimple_seq
3201 gimple_wce_cleanup (gimple gs)
3202 {
3203   GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3204   return gs->gimple_wce.cleanup;
3205 }
3206
3207
3208 /* Set CLEANUP to be the cleanup sequence for GS.  */
3209
3210 static inline void
3211 gimple_wce_set_cleanup (gimple gs, gimple_seq cleanup)
3212 {
3213   GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3214   gs->gimple_wce.cleanup = cleanup;
3215 }
3216
3217
3218 /* Return the CLEANUP_EH_ONLY flag for a WCE tuple.  */
3219
3220 static inline bool
3221 gimple_wce_cleanup_eh_only (const_gimple gs)
3222 {
3223   GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3224   return gs->gsbase.subcode != 0;
3225 }
3226
3227
3228 /* Set the CLEANUP_EH_ONLY flag for a WCE tuple.  */
3229
3230 static inline void
3231 gimple_wce_set_cleanup_eh_only (gimple gs, bool eh_only_p)
3232 {
3233   GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
3234   gs->gsbase.subcode = (unsigned int) eh_only_p;
3235 }
3236
3237
3238 /* Return the maximum number of arguments supported by GIMPLE_PHI GS.  */
3239
3240 static inline unsigned
3241 gimple_phi_capacity (const_gimple gs)
3242 {
3243   GIMPLE_CHECK (gs, GIMPLE_PHI);
3244   return gs->gimple_phi.capacity;
3245 }
3246
3247
3248 /* Return the number of arguments in GIMPLE_PHI GS.  This must always
3249    be exactly the number of incoming edges for the basic block holding
3250    GS.  */
3251
3252 static inline unsigned
3253 gimple_phi_num_args (const_gimple gs)
3254 {
3255   GIMPLE_CHECK (gs, GIMPLE_PHI);
3256   return gs->gimple_phi.nargs;
3257 }
3258
3259
3260 /* Return the SSA name created by GIMPLE_PHI GS.  */
3261
3262 static inline tree
3263 gimple_phi_result (const_gimple gs)
3264 {
3265   GIMPLE_CHECK (gs, GIMPLE_PHI);
3266   return gs->gimple_phi.result;
3267 }
3268
3269 /* Return a pointer to the SSA name created by GIMPLE_PHI GS.  */
3270
3271 static inline tree *
3272 gimple_phi_result_ptr (gimple gs)
3273 {
3274   GIMPLE_CHECK (gs, GIMPLE_PHI);
3275   return &gs->gimple_phi.result;
3276 }
3277
3278 /* Set RESULT to be the SSA name created by GIMPLE_PHI GS.  */
3279
3280 static inline void
3281 gimple_phi_set_result (gimple gs, tree result)
3282 {
3283   GIMPLE_CHECK (gs, GIMPLE_PHI);
3284   gs->gimple_phi.result = result;
3285 }
3286
3287
3288 /* Return the PHI argument corresponding to incoming edge INDEX for
3289    GIMPLE_PHI GS.  */
3290
3291 static inline struct phi_arg_d *
3292 gimple_phi_arg (gimple gs, unsigned index)
3293 {
3294   GIMPLE_CHECK (gs, GIMPLE_PHI);
3295   gcc_gimple_checking_assert (index <= gs->gimple_phi.capacity);
3296   return &(gs->gimple_phi.args[index]);
3297 }
3298
3299 /* Set PHIARG to be the argument corresponding to incoming edge INDEX
3300    for GIMPLE_PHI GS.  */
3301
3302 static inline void
3303 gimple_phi_set_arg (gimple gs, unsigned index, struct phi_arg_d * phiarg)
3304 {
3305   GIMPLE_CHECK (gs, GIMPLE_PHI);
3306   gcc_gimple_checking_assert (index <= gs->gimple_phi.nargs);
3307   gs->gimple_phi.args[index] = *phiarg;
3308 }
3309
3310 /* Return the region number for GIMPLE_RESX GS.  */
3311
3312 static inline int
3313 gimple_resx_region (const_gimple gs)
3314 {
3315   GIMPLE_CHECK (gs, GIMPLE_RESX);
3316   return gs->gimple_eh_ctrl.region;
3317 }
3318
3319 /* Set REGION to be the region number for GIMPLE_RESX GS.  */
3320
3321 static inline void
3322 gimple_resx_set_region (gimple gs, int region)
3323 {
3324   GIMPLE_CHECK (gs, GIMPLE_RESX);
3325   gs->gimple_eh_ctrl.region = region;
3326 }
3327
3328 /* Return the region number for GIMPLE_EH_DISPATCH GS.  */
3329
3330 static inline int
3331 gimple_eh_dispatch_region (const_gimple gs)
3332 {
3333   GIMPLE_CHECK (gs, GIMPLE_EH_DISPATCH);
3334   return gs->gimple_eh_ctrl.region;
3335 }
3336
3337 /* Set REGION to be the region number for GIMPLE_EH_DISPATCH GS.  */
3338
3339 static inline void
3340 gimple_eh_dispatch_set_region (gimple gs, int region)
3341 {
3342   GIMPLE_CHECK (gs, GIMPLE_EH_DISPATCH);
3343   gs->gimple_eh_ctrl.region = region;
3344 }
3345
3346 /* Return the number of labels associated with the switch statement GS.  */
3347
3348 static inline unsigned
3349 gimple_switch_num_labels (const_gimple gs)
3350 {
3351   unsigned num_ops;
3352   GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3353   num_ops = gimple_num_ops (gs);
3354   gcc_gimple_checking_assert (num_ops > 1);
3355   return num_ops - 1;
3356 }
3357
3358
3359 /* Set NLABELS to be the number of labels for the switch statement GS.  */
3360
3361 static inline void
3362 gimple_switch_set_num_labels (gimple g, unsigned nlabels)
3363 {
3364   GIMPLE_CHECK (g, GIMPLE_SWITCH);
3365   gimple_set_num_ops (g, nlabels + 1);
3366 }
3367
3368
3369 /* Return the index variable used by the switch statement GS.  */
3370
3371 static inline tree
3372 gimple_switch_index (const_gimple gs)
3373 {
3374   GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3375   return gimple_op (gs, 0);
3376 }
3377
3378
3379 /* Return a pointer to the index variable for the switch statement GS.  */
3380
3381 static inline tree *
3382 gimple_switch_index_ptr (const_gimple gs)
3383 {
3384   GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3385   return gimple_op_ptr (gs, 0);
3386 }
3387
3388
3389 /* Set INDEX to be the index variable for switch statement GS.  */
3390
3391 static inline void
3392 gimple_switch_set_index (gimple gs, tree index)
3393 {
3394   GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3395   gcc_gimple_checking_assert (SSA_VAR_P (index) || CONSTANT_CLASS_P (index));
3396   gimple_set_op (gs, 0, index);
3397 }
3398
3399
3400 /* Return the label numbered INDEX.  The default label is 0, followed by any
3401    labels in a switch statement.  */
3402
3403 static inline tree
3404 gimple_switch_label (const_gimple gs, unsigned index)
3405 {
3406   GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3407   gcc_gimple_checking_assert (gimple_num_ops (gs) > index + 1);
3408   return gimple_op (gs, index + 1);
3409 }
3410
3411 /* Set the label number INDEX to LABEL.  0 is always the default label.  */
3412
3413 static inline void
3414 gimple_switch_set_label (gimple gs, unsigned index, tree label)
3415 {
3416   GIMPLE_CHECK (gs, GIMPLE_SWITCH);
3417   gcc_gimple_checking_assert (gimple_num_ops (gs) > index + 1
3418                               && (label == NULL_TREE
3419                                   || TREE_CODE (label) == CASE_LABEL_EXPR));
3420   gimple_set_op (gs, index + 1, label);
3421 }
3422
3423 /* Return the default label for a switch statement.  */
3424
3425 static inline tree
3426 gimple_switch_default_label (const_gimple gs)
3427 {
3428   return gimple_switch_label (gs, 0);
3429 }
3430
3431 /* Set the default label for a switch statement.  */
3432
3433 static inline void
3434 gimple_switch_set_default_label (gimple gs, tree label)
3435 {
3436   gimple_switch_set_label (gs, 0, label);
3437 }
3438
3439 /* Return true if GS is a GIMPLE_DEBUG statement.  */
3440
3441 static inline bool
3442 is_gimple_debug (const_gimple gs)
3443 {
3444   return gimple_code (gs) == GIMPLE_DEBUG;
3445 }
3446
3447 /* Return true if S is a GIMPLE_DEBUG BIND statement.  */
3448
3449 static inline bool
3450 gimple_debug_bind_p (const_gimple s)
3451 {
3452   if (is_gimple_debug (s))
3453     return s->gsbase.subcode == GIMPLE_DEBUG_BIND;
3454
3455   return false;
3456 }
3457
3458 /* Return the variable bound in a GIMPLE_DEBUG bind statement.  */
3459
3460 static inline tree
3461 gimple_debug_bind_get_var (gimple dbg)
3462 {
3463   GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3464   gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3465   return gimple_op (dbg, 0);
3466 }
3467
3468 /* Return the value bound to the variable in a GIMPLE_DEBUG bind
3469    statement.  */
3470
3471 static inline tree
3472 gimple_debug_bind_get_value (gimple dbg)
3473 {
3474   GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3475   gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3476   return gimple_op (dbg, 1);
3477 }
3478
3479 /* Return a pointer to the value bound to the variable in a
3480    GIMPLE_DEBUG bind statement.  */
3481
3482 static inline tree *
3483 gimple_debug_bind_get_value_ptr (gimple dbg)
3484 {
3485   GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3486   gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3487   return gimple_op_ptr (dbg, 1);
3488 }
3489
3490 /* Set the variable bound in a GIMPLE_DEBUG bind statement.  */
3491
3492 static inline void
3493 gimple_debug_bind_set_var (gimple dbg, tree var)
3494 {
3495   GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3496   gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3497   gimple_set_op (dbg, 0, var);
3498 }
3499
3500 /* Set the value bound to the variable in a GIMPLE_DEBUG bind
3501    statement.  */
3502
3503 static inline void
3504 gimple_debug_bind_set_value (gimple dbg, tree value)
3505 {
3506   GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3507   gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3508   gimple_set_op (dbg, 1, value);
3509 }
3510
3511 /* The second operand of a GIMPLE_DEBUG_BIND, when the value was
3512    optimized away.  */
3513 #define GIMPLE_DEBUG_BIND_NOVALUE NULL_TREE /* error_mark_node */
3514
3515 /* Remove the value bound to the variable in a GIMPLE_DEBUG bind
3516    statement.  */
3517
3518 static inline void
3519 gimple_debug_bind_reset_value (gimple dbg)
3520 {
3521   GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3522   gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3523   gimple_set_op (dbg, 1, GIMPLE_DEBUG_BIND_NOVALUE);
3524 }
3525
3526 /* Return true if the GIMPLE_DEBUG bind statement is bound to a
3527    value.  */
3528
3529 static inline bool
3530 gimple_debug_bind_has_value_p (gimple dbg)
3531 {
3532   GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
3533   gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
3534   return gimple_op (dbg, 1) != GIMPLE_DEBUG_BIND_NOVALUE;
3535 }
3536
3537 #undef GIMPLE_DEBUG_BIND_NOVALUE
3538
3539 /* Return the body for the OMP statement GS.  */
3540
3541 static inline gimple_seq
3542 gimple_omp_body (gimple gs)
3543 {
3544   return gs->omp.body;
3545 }
3546
3547 /* Set BODY to be the body for the OMP statement GS.  */
3548
3549 static inline void
3550 gimple_omp_set_body (gimple gs, gimple_seq body)
3551 {
3552   gs->omp.body = body;
3553 }
3554
3555
3556 /* Return the name associated with OMP_CRITICAL statement GS.  */
3557
3558 static inline tree
3559 gimple_omp_critical_name (const_gimple gs)
3560 {
3561   GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3562   return gs->gimple_omp_critical.name;
3563 }
3564
3565
3566 /* Return a pointer to the name associated with OMP critical statement GS.  */
3567
3568 static inline tree *
3569 gimple_omp_critical_name_ptr (gimple gs)
3570 {
3571   GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3572   return &gs->gimple_omp_critical.name;
3573 }
3574
3575
3576 /* Set NAME to be the name associated with OMP critical statement GS.  */
3577
3578 static inline void
3579 gimple_omp_critical_set_name (gimple gs, tree name)
3580 {
3581   GIMPLE_CHECK (gs, GIMPLE_OMP_CRITICAL);
3582   gs->gimple_omp_critical.name = name;
3583 }
3584
3585
3586 /* Return the clauses associated with OMP_FOR GS.  */
3587
3588 static inline tree
3589 gimple_omp_for_clauses (const_gimple gs)
3590 {
3591   GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3592   return gs->gimple_omp_for.clauses;
3593 }
3594
3595
3596 /* Return a pointer to the OMP_FOR GS.  */
3597
3598 static inline tree *
3599 gimple_omp_for_clauses_ptr (gimple gs)
3600 {
3601   GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3602   return &gs->gimple_omp_for.clauses;
3603 }
3604
3605
3606 /* Set CLAUSES to be the list of clauses associated with OMP_FOR GS.  */
3607
3608 static inline void
3609 gimple_omp_for_set_clauses (gimple gs, tree clauses)
3610 {
3611   GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3612   gs->gimple_omp_for.clauses = clauses;
3613 }
3614
3615
3616 /* Get the collapse count of OMP_FOR GS.  */
3617
3618 static inline size_t
3619 gimple_omp_for_collapse (gimple gs)
3620 {
3621   GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3622   return gs->gimple_omp_for.collapse;
3623 }
3624
3625
3626 /* Return the index variable for OMP_FOR GS.  */
3627
3628 static inline tree
3629 gimple_omp_for_index (const_gimple gs, size_t i)
3630 {
3631   GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3632   gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3633   return gs->gimple_omp_for.iter[i].index;
3634 }
3635
3636
3637 /* Return a pointer to the index variable for OMP_FOR GS.  */
3638
3639 static inline tree *
3640 gimple_omp_for_index_ptr (gimple gs, size_t i)
3641 {
3642   GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3643   gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3644   return &gs->gimple_omp_for.iter[i].index;
3645 }
3646
3647
3648 /* Set INDEX to be the index variable for OMP_FOR GS.  */
3649
3650 static inline void
3651 gimple_omp_for_set_index (gimple gs, size_t i, tree index)
3652 {
3653   GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3654   gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3655   gs->gimple_omp_for.iter[i].index = index;
3656 }
3657
3658
3659 /* Return the initial value for OMP_FOR GS.  */
3660
3661 static inline tree
3662 gimple_omp_for_initial (const_gimple gs, size_t i)
3663 {
3664   GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3665   gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3666   return gs->gimple_omp_for.iter[i].initial;
3667 }
3668
3669
3670 /* Return a pointer to the initial value for OMP_FOR GS.  */
3671
3672 static inline tree *
3673 gimple_omp_for_initial_ptr (gimple gs, size_t i)
3674 {
3675   GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3676   gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3677   return &gs->gimple_omp_for.iter[i].initial;
3678 }
3679
3680
3681 /* Set INITIAL to be the initial value for OMP_FOR GS.  */
3682
3683 static inline void
3684 gimple_omp_for_set_initial (gimple gs, size_t i, tree initial)
3685 {
3686   GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3687   gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3688   gs->gimple_omp_for.iter[i].initial = initial;
3689 }
3690
3691
3692 /* Return the final value for OMP_FOR GS.  */
3693
3694 static inline tree
3695 gimple_omp_for_final (const_gimple gs, size_t i)
3696 {
3697   GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3698   gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3699   return gs->gimple_omp_for.iter[i].final;
3700 }
3701
3702
3703 /* Return a pointer to the final value for OMP_FOR GS.  */
3704
3705 static inline tree *
3706 gimple_omp_for_final_ptr (gimple gs, size_t i)
3707 {
3708   GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3709   gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3710   return &gs->gimple_omp_for.iter[i].final;
3711 }
3712
3713
3714 /* Set FINAL to be the final value for OMP_FOR GS.  */
3715
3716 static inline void
3717 gimple_omp_for_set_final (gimple gs, size_t i, tree final)
3718 {
3719   GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3720   gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3721   gs->gimple_omp_for.iter[i].final = final;
3722 }
3723
3724
3725 /* Return the increment value for OMP_FOR GS.  */
3726
3727 static inline tree
3728 gimple_omp_for_incr (const_gimple gs, size_t i)
3729 {
3730   GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3731   gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3732   return gs->gimple_omp_for.iter[i].incr;
3733 }
3734
3735
3736 /* Return a pointer to the increment value for OMP_FOR GS.  */
3737
3738 static inline tree *
3739 gimple_omp_for_incr_ptr (gimple gs, size_t i)
3740 {
3741   GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3742   gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3743   return &gs->gimple_omp_for.iter[i].incr;
3744 }
3745
3746
3747 /* Set INCR to be the increment value for OMP_FOR GS.  */
3748
3749 static inline void
3750 gimple_omp_for_set_incr (gimple gs, size_t i, tree incr)
3751 {
3752   GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3753   gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
3754   gs->gimple_omp_for.iter[i].incr = incr;
3755 }
3756
3757
3758 /* Return the sequence of statements to execute before the OMP_FOR
3759    statement GS starts.  */
3760
3761 static inline gimple_seq
3762 gimple_omp_for_pre_body (gimple gs)
3763 {
3764   GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3765   return gs->gimple_omp_for.pre_body;
3766 }
3767
3768
3769 /* Set PRE_BODY to be the sequence of statements to execute before the
3770    OMP_FOR statement GS starts.  */
3771
3772 static inline void
3773 gimple_omp_for_set_pre_body (gimple gs, gimple_seq pre_body)
3774 {
3775   GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
3776   gs->gimple_omp_for.pre_body = pre_body;
3777 }
3778
3779
3780 /* Return the clauses associated with OMP_PARALLEL GS.  */
3781
3782 static inline tree
3783 gimple_omp_parallel_clauses (const_gimple gs)
3784 {
3785   GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3786   return gs->gimple_omp_parallel.clauses;
3787 }
3788
3789
3790 /* Return a pointer to the clauses associated with OMP_PARALLEL GS.  */
3791
3792 static inline tree *
3793 gimple_omp_parallel_clauses_ptr (gimple gs)
3794 {
3795   GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3796   return &gs->gimple_omp_parallel.clauses;
3797 }
3798
3799
3800 /* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL
3801    GS.  */
3802
3803 static inline void
3804 gimple_omp_parallel_set_clauses (gimple gs, tree clauses)
3805 {
3806   GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3807   gs->gimple_omp_parallel.clauses = clauses;
3808 }
3809
3810
3811 /* Return the child function used to hold the body of OMP_PARALLEL GS.  */
3812
3813 static inline tree
3814 gimple_omp_parallel_child_fn (const_gimple gs)
3815 {
3816   GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3817   return gs->gimple_omp_parallel.child_fn;
3818 }
3819
3820 /* Return a pointer to the child function used to hold the body of
3821    OMP_PARALLEL GS.  */
3822
3823 static inline tree *
3824 gimple_omp_parallel_child_fn_ptr (gimple gs)
3825 {
3826   GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3827   return &gs->gimple_omp_parallel.child_fn;
3828 }
3829
3830
3831 /* Set CHILD_FN to be the child function for OMP_PARALLEL GS.  */
3832
3833 static inline void
3834 gimple_omp_parallel_set_child_fn (gimple gs, tree child_fn)
3835 {
3836   GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3837   gs->gimple_omp_parallel.child_fn = child_fn;
3838 }
3839
3840
3841 /* Return the artificial argument used to send variables and values
3842    from the parent to the children threads in OMP_PARALLEL GS.  */
3843
3844 static inline tree
3845 gimple_omp_parallel_data_arg (const_gimple gs)
3846 {
3847   GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3848   return gs->gimple_omp_parallel.data_arg;
3849 }
3850
3851
3852 /* Return a pointer to the data argument for OMP_PARALLEL GS.  */
3853
3854 static inline tree *
3855 gimple_omp_parallel_data_arg_ptr (gimple gs)
3856 {
3857   GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3858   return &gs->gimple_omp_parallel.data_arg;
3859 }
3860
3861
3862 /* Set DATA_ARG to be the data argument for OMP_PARALLEL GS.  */
3863
3864 static inline void
3865 gimple_omp_parallel_set_data_arg (gimple gs, tree data_arg)
3866 {
3867   GIMPLE_CHECK (gs, GIMPLE_OMP_PARALLEL);
3868   gs->gimple_omp_parallel.data_arg = data_arg;
3869 }
3870
3871
3872 /* Return the clauses associated with OMP_TASK GS.  */
3873
3874 static inline tree
3875 gimple_omp_task_clauses (const_gimple gs)
3876 {
3877   GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3878   return gs->gimple_omp_parallel.clauses;
3879 }
3880
3881
3882 /* Return a pointer to the clauses associated with OMP_TASK GS.  */
3883
3884 static inline tree *
3885 gimple_omp_task_clauses_ptr (gimple gs)
3886 {
3887   GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3888   return &gs->gimple_omp_parallel.clauses;
3889 }
3890
3891
3892 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3893    GS.  */
3894
3895 static inline void
3896 gimple_omp_task_set_clauses (gimple gs, tree clauses)
3897 {
3898   GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3899   gs->gimple_omp_parallel.clauses = clauses;
3900 }
3901
3902
3903 /* Return the child function used to hold the body of OMP_TASK GS.  */
3904
3905 static inline tree
3906 gimple_omp_task_child_fn (const_gimple gs)
3907 {
3908   GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3909   return gs->gimple_omp_parallel.child_fn;
3910 }
3911
3912 /* Return a pointer to the child function used to hold the body of
3913    OMP_TASK GS.  */
3914
3915 static inline tree *
3916 gimple_omp_task_child_fn_ptr (gimple gs)
3917 {
3918   GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3919   return &gs->gimple_omp_parallel.child_fn;
3920 }
3921
3922
3923 /* Set CHILD_FN to be the child function for OMP_TASK GS.  */
3924
3925 static inline void
3926 gimple_omp_task_set_child_fn (gimple gs, tree child_fn)
3927 {
3928   GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3929   gs->gimple_omp_parallel.child_fn = child_fn;
3930 }
3931
3932
3933 /* Return the artificial argument used to send variables and values
3934    from the parent to the children threads in OMP_TASK GS.  */
3935
3936 static inline tree
3937 gimple_omp_task_data_arg (const_gimple gs)
3938 {
3939   GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3940   return gs->gimple_omp_parallel.data_arg;
3941 }
3942
3943
3944 /* Return a pointer to the data argument for OMP_TASK GS.  */
3945
3946 static inline tree *
3947 gimple_omp_task_data_arg_ptr (gimple gs)
3948 {
3949   GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3950   return &gs->gimple_omp_parallel.data_arg;
3951 }
3952
3953
3954 /* Set DATA_ARG to be the data argument for OMP_TASK GS.  */
3955
3956 static inline void
3957 gimple_omp_task_set_data_arg (gimple gs, tree data_arg)
3958 {
3959   GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3960   gs->gimple_omp_parallel.data_arg = data_arg;
3961 }
3962
3963
3964 /* Return the clauses associated with OMP_TASK GS.  */
3965
3966 static inline tree
3967 gimple_omp_taskreg_clauses (const_gimple gs)
3968 {
3969   if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3970     GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3971   return gs->gimple_omp_parallel.clauses;
3972 }
3973
3974
3975 /* Return a pointer to the clauses associated with OMP_TASK GS.  */
3976
3977 static inline tree *
3978 gimple_omp_taskreg_clauses_ptr (gimple gs)
3979 {
3980   if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3981     GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3982   return &gs->gimple_omp_parallel.clauses;
3983 }
3984
3985
3986 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
3987    GS.  */
3988
3989 static inline void
3990 gimple_omp_taskreg_set_clauses (gimple gs, tree clauses)
3991 {
3992   if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
3993     GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
3994   gs->gimple_omp_parallel.clauses = clauses;
3995 }
3996
3997
3998 /* Return the child function used to hold the body of OMP_TASK GS.  */
3999
4000 static inline tree
4001 gimple_omp_taskreg_child_fn (const_gimple gs)
4002 {
4003   if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4004     GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4005   return gs->gimple_omp_parallel.child_fn;
4006 }
4007
4008 /* Return a pointer to the child function used to hold the body of
4009    OMP_TASK GS.  */
4010
4011 static inline tree *
4012 gimple_omp_taskreg_child_fn_ptr (gimple gs)
4013 {
4014   if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4015     GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4016   return &gs->gimple_omp_parallel.child_fn;
4017 }
4018
4019
4020 /* Set CHILD_FN to be the child function for OMP_TASK GS.  */
4021
4022 static inline void
4023 gimple_omp_taskreg_set_child_fn (gimple gs, tree child_fn)
4024 {
4025   if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4026     GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4027   gs->gimple_omp_parallel.child_fn = child_fn;
4028 }
4029
4030
4031 /* Return the artificial argument used to send variables and values
4032    from the parent to the children threads in OMP_TASK GS.  */
4033
4034 static inline tree
4035 gimple_omp_taskreg_data_arg (const_gimple gs)
4036 {
4037   if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4038     GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4039   return gs->gimple_omp_parallel.data_arg;
4040 }
4041
4042
4043 /* Return a pointer to the data argument for OMP_TASK GS.  */
4044
4045 static inline tree *
4046 gimple_omp_taskreg_data_arg_ptr (gimple gs)
4047 {
4048   if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4049     GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4050   return &gs->gimple_omp_parallel.data_arg;
4051 }
4052
4053
4054 /* Set DATA_ARG to be the data argument for OMP_TASK GS.  */
4055
4056 static inline void
4057 gimple_omp_taskreg_set_data_arg (gimple gs, tree data_arg)
4058 {
4059   if (gimple_code (gs) != GIMPLE_OMP_PARALLEL)
4060     GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4061   gs->gimple_omp_parallel.data_arg = data_arg;
4062 }
4063
4064
4065 /* Return the copy function used to hold the body of OMP_TASK GS.  */
4066
4067 static inline tree
4068 gimple_omp_task_copy_fn (const_gimple gs)
4069 {
4070   GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4071   return gs->gimple_omp_task.copy_fn;
4072 }
4073
4074 /* Return a pointer to the copy function used to hold the body of
4075    OMP_TASK GS.  */
4076
4077 static inline tree *
4078 gimple_omp_task_copy_fn_ptr (gimple gs)
4079 {
4080   GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4081   return &gs->gimple_omp_task.copy_fn;
4082 }
4083
4084
4085 /* Set CHILD_FN to be the copy function for OMP_TASK GS.  */
4086
4087 static inline void
4088 gimple_omp_task_set_copy_fn (gimple gs, tree copy_fn)
4089 {
4090   GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4091   gs->gimple_omp_task.copy_fn = copy_fn;
4092 }
4093
4094
4095 /* Return size of the data block in bytes in OMP_TASK GS.  */
4096
4097 static inline tree
4098 gimple_omp_task_arg_size (const_gimple gs)
4099 {
4100   GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4101   return gs->gimple_omp_task.arg_size;
4102 }
4103
4104
4105 /* Return a pointer to the data block size for OMP_TASK GS.  */
4106
4107 static inline tree *
4108 gimple_omp_task_arg_size_ptr (gimple gs)
4109 {
4110   GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4111   return &gs->gimple_omp_task.arg_size;
4112 }
4113
4114
4115 /* Set ARG_SIZE to be the data block size for OMP_TASK GS.  */
4116
4117 static inline void
4118 gimple_omp_task_set_arg_size (gimple gs, tree arg_size)
4119 {
4120   GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4121   gs->gimple_omp_task.arg_size = arg_size;
4122 }
4123
4124
4125 /* Return align of the data block in bytes in OMP_TASK GS.  */
4126
4127 static inline tree
4128 gimple_omp_task_arg_align (const_gimple gs)
4129 {
4130   GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4131   return gs->gimple_omp_task.arg_align;
4132 }
4133
4134
4135 /* Return a pointer to the data block align for OMP_TASK GS.  */
4136
4137 static inline tree *
4138 gimple_omp_task_arg_align_ptr (gimple gs)
4139 {
4140   GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4141   return &gs->gimple_omp_task.arg_align;
4142 }
4143
4144
4145 /* Set ARG_SIZE to be the data block align for OMP_TASK GS.  */
4146
4147 static inline void
4148 gimple_omp_task_set_arg_align (gimple gs, tree arg_align)
4149 {
4150   GIMPLE_CHECK (gs, GIMPLE_OMP_TASK);
4151   gs->gimple_omp_task.arg_align = arg_align;
4152 }
4153
4154
4155 /* Return the clauses associated with OMP_SINGLE GS.  */
4156
4157 static inline tree
4158 gimple_omp_single_clauses (const_gimple gs)
4159 {
4160   GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
4161   return gs->gimple_omp_single.clauses;
4162 }
4163
4164
4165 /* Return a pointer to the clauses associated with OMP_SINGLE GS.  */
4166
4167 static inline tree *
4168 gimple_omp_single_clauses_ptr (gimple gs)
4169 {
4170   GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
4171   return &gs->gimple_omp_single.clauses;
4172 }
4173
4174
4175 /* Set CLAUSES to be the clauses associated with OMP_SINGLE GS.  */
4176
4177 static inline void
4178 gimple_omp_single_set_clauses (gimple gs, tree clauses)
4179 {
4180   GIMPLE_CHECK (gs, GIMPLE_OMP_SINGLE);
4181   gs->gimple_omp_single.clauses = clauses;
4182 }
4183
4184
4185 /* Return the clauses associated with OMP_SECTIONS GS.  */
4186
4187 static inline tree
4188 gimple_omp_sections_clauses (const_gimple gs)
4189 {
4190   GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4191   return gs->gimple_omp_sections.clauses;
4192 }
4193
4194
4195 /* Return a pointer to the clauses associated with OMP_SECTIONS GS.  */
4196
4197 static inline tree *
4198 gimple_omp_sections_clauses_ptr (gimple gs)
4199 {
4200   GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4201   return &gs->gimple_omp_sections.clauses;
4202 }
4203
4204
4205 /* Set CLAUSES to be the set of clauses associated with OMP_SECTIONS
4206    GS.  */
4207
4208 static inline void
4209 gimple_omp_sections_set_clauses (gimple gs, tree clauses)
4210 {
4211   GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4212   gs->gimple_omp_sections.clauses = clauses;
4213 }
4214
4215
4216 /* Return the control variable associated with the GIMPLE_OMP_SECTIONS
4217    in GS.  */
4218
4219 static inline tree
4220 gimple_omp_sections_control (const_gimple gs)
4221 {
4222   GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4223   return gs->gimple_omp_sections.control;
4224 }
4225
4226
4227 /* Return a pointer to the clauses associated with the GIMPLE_OMP_SECTIONS
4228    GS.  */
4229
4230 static inline tree *
4231 gimple_omp_sections_control_ptr (gimple gs)
4232 {
4233   GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4234   return &gs->gimple_omp_sections.control;
4235 }
4236
4237
4238 /* Set CONTROL to be the set of clauses associated with the
4239    GIMPLE_OMP_SECTIONS in GS.  */
4240
4241 static inline void
4242 gimple_omp_sections_set_control (gimple gs, tree control)
4243 {
4244   GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
4245   gs->gimple_omp_sections.control = control;
4246 }
4247
4248
4249 /* Set COND to be the condition code for OMP_FOR GS.  */
4250
4251 static inline void
4252 gimple_omp_for_set_cond (gimple gs, size_t i, enum tree_code cond)
4253 {
4254   GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4255   gcc_gimple_checking_assert (TREE_CODE_CLASS (cond) == tcc_comparison
4256                               && i < gs->gimple_omp_for.collapse);
4257   gs->gimple_omp_for.iter[i].cond = cond;
4258 }
4259
4260
4261 /* Return the condition code associated with OMP_FOR GS.  */
4262
4263 static inline enum tree_code
4264 gimple_omp_for_cond (const_gimple gs, size_t i)
4265 {
4266   GIMPLE_CHECK (gs, GIMPLE_OMP_FOR);
4267   gcc_gimple_checking_assert (i < gs->gimple_omp_for.collapse);
4268   return gs->gimple_omp_for.iter[i].cond;
4269 }
4270
4271
4272 /* Set the value being stored in an atomic store.  */
4273
4274 static inline void
4275 gimple_omp_atomic_store_set_val (gimple g, tree val)
4276 {
4277   GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4278   g->gimple_omp_atomic_store.val = val;
4279 }
4280
4281
4282 /* Return the value being stored in an atomic store.  */
4283
4284 static inline tree
4285 gimple_omp_atomic_store_val (const_gimple g)
4286 {
4287   GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4288   return g->gimple_omp_atomic_store.val;
4289 }
4290
4291
4292 /* Return a pointer to the value being stored in an atomic store.  */
4293
4294 static inline tree *
4295 gimple_omp_atomic_store_val_ptr (gimple g)
4296 {
4297   GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
4298   return &g->gimple_omp_atomic_store.val;
4299 }
4300
4301
4302 /* Set the LHS of an atomic load.  */
4303
4304 static inline void
4305 gimple_omp_atomic_load_set_lhs (gimple g, tree lhs)
4306 {
4307   GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4308   g->gimple_omp_atomic_load.lhs = lhs;
4309 }
4310
4311
4312 /* Get the LHS of an atomic load.  */
4313
4314 static inline tree
4315 gimple_omp_atomic_load_lhs (const_gimple g)
4316 {
4317   GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4318   return g->gimple_omp_atomic_load.lhs;
4319 }
4320
4321
4322 /* Return a pointer to the LHS of an atomic load.  */
4323
4324 static inline tree *
4325 gimple_omp_atomic_load_lhs_ptr (gimple g)
4326 {
4327   GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4328   return &g->gimple_omp_atomic_load.lhs;
4329 }
4330
4331
4332 /* Set the RHS of an atomic load.  */
4333
4334 static inline void
4335 gimple_omp_atomic_load_set_rhs (gimple g, tree rhs)
4336 {
4337   GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4338   g->gimple_omp_atomic_load.rhs = rhs;
4339 }
4340
4341
4342 /* Get the RHS of an atomic load.  */
4343
4344 static inline tree
4345 gimple_omp_atomic_load_rhs (const_gimple g)
4346 {
4347   GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4348   return g->gimple_omp_atomic_load.rhs;
4349 }
4350
4351
4352 /* Return a pointer to the RHS of an atomic load.  */
4353
4354 static inline tree *
4355 gimple_omp_atomic_load_rhs_ptr (gimple g)
4356 {
4357   GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_LOAD);
4358   return &g->gimple_omp_atomic_load.rhs;
4359 }
4360
4361
4362 /* Get the definition of the control variable in a GIMPLE_OMP_CONTINUE.  */
4363
4364 static inline tree
4365 gimple_omp_continue_control_def (const_gimple g)
4366 {
4367   GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4368   return g->gimple_omp_continue.control_def;
4369 }
4370
4371 /* The same as above, but return the address.  */
4372
4373 static inline tree *
4374 gimple_omp_continue_control_def_ptr (gimple g)
4375 {
4376   GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4377   return &g->gimple_omp_continue.control_def;
4378 }
4379
4380 /* Set the definition of the control variable in a GIMPLE_OMP_CONTINUE.  */
4381
4382 static inline void
4383 gimple_omp_continue_set_control_def (gimple g, tree def)
4384 {
4385   GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4386   g->gimple_omp_continue.control_def = def;
4387 }
4388
4389
4390 /* Get the use of the control variable in a GIMPLE_OMP_CONTINUE.  */
4391
4392 static inline tree
4393 gimple_omp_continue_control_use (const_gimple g)
4394 {
4395   GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4396   return g->gimple_omp_continue.control_use;
4397 }
4398
4399
4400 /* The same as above, but return the address.  */
4401
4402 static inline tree *
4403 gimple_omp_continue_control_use_ptr (gimple g)
4404 {
4405   GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4406   return &g->gimple_omp_continue.control_use;
4407 }
4408
4409
4410 /* Set the use of the control variable in a GIMPLE_OMP_CONTINUE.  */
4411
4412 static inline void
4413 gimple_omp_continue_set_control_use (gimple g, tree use)
4414 {
4415   GIMPLE_CHECK (g, GIMPLE_OMP_CONTINUE);
4416   g->gimple_omp_continue.control_use = use;
4417 }
4418
4419
4420 /* Return a pointer to the return value for GIMPLE_RETURN GS.  */
4421
4422 static inline tree *
4423 gimple_return_retval_ptr (const_gimple gs)
4424 {
4425   GIMPLE_CHECK (gs, GIMPLE_RETURN);
4426   return gimple_op_ptr (gs, 0);
4427 }
4428
4429 /* Return the return value for GIMPLE_RETURN GS.  */
4430
4431 static inline tree
4432 gimple_return_retval (const_gimple gs)
4433 {
4434   GIMPLE_CHECK (gs, GIMPLE_RETURN);
4435   return gimple_op (gs, 0);
4436 }
4437
4438
4439 /* Set RETVAL to be the return value for GIMPLE_RETURN GS.  */
4440
4441 static inline void
4442 gimple_return_set_retval (gimple gs, tree retval)
4443 {
4444   GIMPLE_CHECK (gs, GIMPLE_RETURN);
4445   gimple_set_op (gs, 0, retval);
4446 }
4447
4448
4449 /* Returns true when the gimple statment STMT is any of the OpenMP types.  */
4450
4451 #define CASE_GIMPLE_OMP                         \
4452     case GIMPLE_OMP_PARALLEL:                   \
4453     case GIMPLE_OMP_TASK:                       \
4454     case GIMPLE_OMP_FOR:                        \
4455     case GIMPLE_OMP_SECTIONS:                   \
4456     case GIMPLE_OMP_SECTIONS_SWITCH:            \
4457     case GIMPLE_OMP_SINGLE:                     \
4458     case GIMPLE_OMP_SECTION:                    \
4459     case GIMPLE_OMP_MASTER:                     \
4460     case GIMPLE_OMP_ORDERED:                    \
4461     case GIMPLE_OMP_CRITICAL:                   \
4462     case GIMPLE_OMP_RETURN:                     \
4463     case GIMPLE_OMP_ATOMIC_LOAD:                \
4464     case GIMPLE_OMP_ATOMIC_STORE:               \
4465     case GIMPLE_OMP_CONTINUE
4466
4467 static inline bool
4468 is_gimple_omp (const_gimple stmt)
4469 {
4470   switch (gimple_code (stmt))
4471     {
4472     CASE_GIMPLE_OMP:
4473       return true;
4474     default:
4475       return false;
4476     }
4477 }
4478
4479
4480 /* Returns TRUE if statement G is a GIMPLE_NOP.  */
4481
4482 static inline bool
4483 gimple_nop_p (const_gimple g)
4484 {
4485   return gimple_code (g) == GIMPLE_NOP;
4486 }
4487
4488
4489 /* Return true if GS is a GIMPLE_RESX.  */
4490
4491 static inline bool
4492 is_gimple_resx (const_gimple gs)
4493 {
4494   return gimple_code (gs) == GIMPLE_RESX;
4495 }
4496
4497 /* Return the predictor of GIMPLE_PREDICT statement GS.  */
4498
4499 static inline enum br_predictor
4500 gimple_predict_predictor (gimple gs)
4501 {
4502   GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4503   return (enum br_predictor) (gs->gsbase.subcode & ~GF_PREDICT_TAKEN);
4504 }
4505
4506
4507 /* Set the predictor of GIMPLE_PREDICT statement GS to PREDICT.  */
4508
4509 static inline void
4510 gimple_predict_set_predictor (gimple gs, enum br_predictor predictor)
4511 {
4512   GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4513   gs->gsbase.subcode = (gs->gsbase.subcode & GF_PREDICT_TAKEN)
4514                        | (unsigned) predictor;
4515 }
4516
4517
4518 /* Return the outcome of GIMPLE_PREDICT statement GS.  */
4519
4520 static inline enum prediction
4521 gimple_predict_outcome (gimple gs)
4522 {
4523   GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4524   return (gs->gsbase.subcode & GF_PREDICT_TAKEN) ? TAKEN : NOT_TAKEN;
4525 }
4526
4527
4528 /* Set the outcome of GIMPLE_PREDICT statement GS to OUTCOME.  */
4529
4530 static inline void
4531 gimple_predict_set_outcome (gimple gs, enum prediction outcome)
4532 {
4533   GIMPLE_CHECK (gs, GIMPLE_PREDICT);
4534   if (outcome == TAKEN)
4535     gs->gsbase.subcode |= GF_PREDICT_TAKEN;
4536   else
4537     gs->gsbase.subcode &= ~GF_PREDICT_TAKEN;
4538 }
4539
4540
4541 /* Return the type of the main expression computed by STMT.  Return
4542    void_type_node if the statement computes nothing.  */
4543
4544 static inline tree
4545 gimple_expr_type (const_gimple stmt)
4546 {
4547   enum gimple_code code = gimple_code (stmt);
4548
4549   if (code == GIMPLE_ASSIGN || code == GIMPLE_CALL)
4550     {
4551       tree type;
4552       /* In general we want to pass out a type that can be substituted
4553          for both the RHS and the LHS types if there is a possibly
4554          useless conversion involved.  That means returning the
4555          original RHS type as far as we can reconstruct it.  */
4556       if (code == GIMPLE_CALL)
4557         type = gimple_call_return_type (stmt);
4558       else
4559         switch (gimple_assign_rhs_code (stmt))
4560           {
4561           case POINTER_PLUS_EXPR:
4562             type = TREE_TYPE (gimple_assign_rhs1 (stmt));
4563             break;
4564
4565           default:
4566             /* As fallback use the type of the LHS.  */
4567             type = TREE_TYPE (gimple_get_lhs (stmt));
4568             break;
4569           }
4570       return type;
4571     }
4572   else if (code == GIMPLE_COND)
4573     return boolean_type_node;
4574   else
4575     return void_type_node;
4576 }
4577
4578
4579 /* Return a new iterator pointing to GIMPLE_SEQ's first statement.  */
4580
4581 static inline gimple_stmt_iterator
4582 gsi_start (gimple_seq seq)
4583 {
4584   gimple_stmt_iterator i;
4585
4586   i.ptr = gimple_seq_first (seq);
4587   i.seq = seq;
4588   i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4589
4590   return i;
4591 }
4592
4593
4594 /* Return a new iterator pointing to the first statement in basic block BB.  */
4595
4596 static inline gimple_stmt_iterator
4597 gsi_start_bb (basic_block bb)
4598 {
4599   gimple_stmt_iterator i;
4600   gimple_seq seq;
4601
4602   seq = bb_seq (bb);
4603   i.ptr = gimple_seq_first (seq);
4604   i.seq = seq;
4605   i.bb = bb;
4606
4607   return i;
4608 }
4609
4610
4611 /* Return a new iterator initially pointing to GIMPLE_SEQ's last statement.  */
4612
4613 static inline gimple_stmt_iterator
4614 gsi_last (gimple_seq seq)
4615 {
4616   gimple_stmt_iterator i;
4617
4618   i.ptr = gimple_seq_last (seq);
4619   i.seq = seq;
4620   i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL;
4621
4622   return i;
4623 }
4624
4625
4626 /* Return a new iterator pointing to the last statement in basic block BB.  */
4627
4628 static inline gimple_stmt_iterator
4629 gsi_last_bb (basic_block bb)
4630 {
4631   gimple_stmt_iterator i;
4632   gimple_seq seq;
4633
4634   seq = bb_seq (bb);
4635   i.ptr = gimple_seq_last (seq);
4636   i.seq = seq;
4637   i.bb = bb;
4638
4639   return i;
4640 }
4641
4642
4643 /* Return true if I is at the end of its sequence.  */
4644
4645 static inline bool
4646 gsi_end_p (gimple_stmt_iterator i)
4647 {
4648   return i.ptr == NULL;
4649 }
4650
4651
4652 /* Return true if I is one statement before the end of its sequence.  */
4653
4654 static inline bool
4655 gsi_one_before_end_p (gimple_stmt_iterator i)
4656 {
4657   return i.ptr != NULL && i.ptr->next == NULL;
4658 }
4659
4660
4661 /* Advance the iterator to the next gimple statement.  */
4662
4663 static inline void
4664 gsi_next (gimple_stmt_iterator *i)
4665 {
4666   i->ptr = i->ptr->next;
4667 }
4668
4669 /* Advance the iterator to the previous gimple statement.  */
4670
4671 static inline void
4672 gsi_prev (gimple_stmt_iterator *i)
4673 {
4674   i->ptr = i->ptr->prev;
4675 }
4676
4677 /* Return the current stmt.  */
4678
4679 static inline gimple
4680 gsi_stmt (gimple_stmt_iterator i)
4681 {
4682   return i.ptr->stmt;
4683 }
4684
4685 /* Return a block statement iterator that points to the first non-label
4686    statement in block BB.  */
4687
4688 static inline gimple_stmt_iterator
4689 gsi_after_labels (basic_block bb)
4690 {
4691   gimple_stmt_iterator gsi = gsi_start_bb (bb);
4692
4693   while (!gsi_end_p (gsi) && gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL)
4694     gsi_next (&gsi);
4695
4696   return gsi;
4697 }
4698
4699 /* Advance the iterator to the next non-debug gimple statement.  */
4700
4701 static inline void
4702 gsi_next_nondebug (gimple_stmt_iterator *i)
4703 {
4704   do
4705     {
4706       gsi_next (i);
4707     }
4708   while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
4709 }
4710
4711 /* Advance the iterator to the next non-debug gimple statement.  */
4712
4713 static inline void
4714 gsi_prev_nondebug (gimple_stmt_iterator *i)
4715 {
4716   do
4717     {
4718       gsi_prev (i);
4719     }
4720   while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
4721 }
4722
4723 /* Return a new iterator pointing to the first non-debug statement in
4724    basic block BB.  */
4725
4726 static inline gimple_stmt_iterator
4727 gsi_start_nondebug_bb (basic_block bb)
4728 {
4729   gimple_stmt_iterator i = gsi_start_bb (bb);
4730
4731   if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
4732     gsi_next_nondebug (&i);
4733
4734   return i;
4735 }
4736
4737 /* Return a new iterator pointing to the last non-debug statement in
4738    basic block BB.  */
4739
4740 static inline gimple_stmt_iterator
4741 gsi_last_nondebug_bb (basic_block bb)
4742 {
4743   gimple_stmt_iterator i = gsi_last_bb (bb);
4744
4745   if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
4746     gsi_prev_nondebug (&i);
4747
4748   return i;
4749 }
4750
4751 /* Return a pointer to the current stmt.
4752
4753   NOTE: You may want to use gsi_replace on the iterator itself,
4754   as this performs additional bookkeeping that will not be done
4755   if you simply assign through a pointer returned by gsi_stmt_ptr.  */
4756
4757 static inline gimple *
4758 gsi_stmt_ptr (gimple_stmt_iterator *i)
4759 {
4760   return &i->ptr->stmt;
4761 }
4762
4763
4764 /* Return the basic block associated with this iterator.  */
4765
4766 static inline basic_block
4767 gsi_bb (gimple_stmt_iterator i)
4768 {
4769   return i.bb;
4770 }
4771
4772
4773 /* Return the sequence associated with this iterator.  */
4774
4775 static inline gimple_seq
4776 gsi_seq (gimple_stmt_iterator i)
4777 {
4778   return i.seq;
4779 }
4780
4781
4782 enum gsi_iterator_update
4783 {
4784   GSI_NEW_STMT,         /* Only valid when single statement is added, move
4785                            iterator to it.  */
4786   GSI_SAME_STMT,        /* Leave the iterator at the same statement.  */
4787   GSI_CONTINUE_LINKING  /* Move iterator to whatever position is suitable
4788                            for linking other statements in the same
4789                            direction.  */
4790 };
4791
4792 /* In gimple-iterator.c  */
4793 gimple_stmt_iterator gsi_start_phis (basic_block);
4794 gimple_seq gsi_split_seq_after (gimple_stmt_iterator);
4795 gimple_seq gsi_split_seq_before (gimple_stmt_iterator *);
4796 void gsi_replace (gimple_stmt_iterator *, gimple, bool);
4797 void gsi_insert_before (gimple_stmt_iterator *, gimple,
4798                         enum gsi_iterator_update);
4799 void gsi_insert_before_without_update (gimple_stmt_iterator *, gimple,
4800                                        enum gsi_iterator_update);
4801 void gsi_insert_seq_before (gimple_stmt_iterator *, gimple_seq,
4802                             enum gsi_iterator_update);
4803 void gsi_insert_seq_before_without_update (gimple_stmt_iterator *, gimple_seq,
4804                                            enum gsi_iterator_update);
4805 void gsi_insert_after (gimple_stmt_iterator *, gimple,
4806                        enum gsi_iterator_update);
4807 void gsi_insert_after_without_update (gimple_stmt_iterator *, gimple,
4808                                       enum gsi_iterator_update);
4809 void gsi_insert_seq_after (gimple_stmt_iterator *, gimple_seq,
4810                            enum gsi_iterator_update);
4811 void gsi_insert_seq_after_without_update (gimple_stmt_iterator *, gimple_seq,
4812                                           enum gsi_iterator_update);
4813 void gsi_remove (gimple_stmt_iterator *, bool);
4814 gimple_stmt_iterator gsi_for_stmt (gimple);
4815 void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *);
4816 void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *);
4817 void gsi_move_to_bb_end (gimple_stmt_iterator *, struct basic_block_def *);
4818 void gsi_insert_on_edge (edge, gimple);
4819 void gsi_insert_seq_on_edge (edge, gimple_seq);
4820 basic_block gsi_insert_on_edge_immediate (edge, gimple);
4821 basic_block gsi_insert_seq_on_edge_immediate (edge, gimple_seq);
4822 void gsi_commit_one_edge_insert (edge, basic_block *);
4823 void gsi_commit_edge_inserts (void);
4824 gimple gimple_call_copy_skip_args (gimple, bitmap);
4825
4826
4827 /* Convenience routines to walk all statements of a gimple function.
4828    Note that this is useful exclusively before the code is converted
4829    into SSA form.  Once the program is in SSA form, the standard
4830    operand interface should be used to analyze/modify statements.  */
4831 struct walk_stmt_info
4832 {
4833   /* Points to the current statement being walked.  */
4834   gimple_stmt_iterator gsi;
4835
4836   /* Additional data that the callback functions may want to carry
4837      through the recursion.  */
4838   void *info;
4839
4840   /* Pointer map used to mark visited tree nodes when calling
4841      walk_tree on each operand.  If set to NULL, duplicate tree nodes
4842      will be visited more than once.  */
4843   struct pointer_set_t *pset;
4844
4845   /* Indicates whether the operand being examined may be replaced
4846      with something that matches is_gimple_val (if true) or something
4847      slightly more complicated (if false).  "Something" technically
4848      means the common subset of is_gimple_lvalue and is_gimple_rhs,
4849      but we never try to form anything more complicated than that, so
4850      we don't bother checking.
4851
4852      Also note that CALLBACK should update this flag while walking the
4853      sub-expressions of a statement.  For instance, when walking the
4854      statement 'foo (&var)', the flag VAL_ONLY will initially be set
4855      to true, however, when walking &var, the operand of that
4856      ADDR_EXPR does not need to be a GIMPLE value.  */
4857   bool val_only;
4858
4859   /* True if we are currently walking the LHS of an assignment.  */
4860   bool is_lhs;
4861
4862   /* Optional.  Set to true by the callback functions if they made any
4863      changes.  */
4864   bool changed;
4865
4866   /* True if we're interested in location information.  */
4867   bool want_locations;
4868
4869   /* Operand returned by the callbacks.  This is set when calling
4870      walk_gimple_seq.  If the walk_stmt_fn or walk_tree_fn callback
4871      returns non-NULL, this field will contain the tree returned by
4872      the last callback.  */
4873   tree callback_result;
4874 };
4875
4876 /* Callback for walk_gimple_stmt.  Called for every statement found
4877    during traversal.  The first argument points to the statement to
4878    walk.  The second argument is a flag that the callback sets to
4879    'true' if it the callback handled all the operands and
4880    sub-statements of the statement (the default value of this flag is
4881    'false').  The third argument is an anonymous pointer to data
4882    to be used by the callback.  */
4883 typedef tree (*walk_stmt_fn) (gimple_stmt_iterator *, bool *,
4884                               struct walk_stmt_info *);
4885
4886 gimple walk_gimple_seq (gimple_seq, walk_stmt_fn, walk_tree_fn,
4887                         struct walk_stmt_info *);
4888 tree walk_gimple_stmt (gimple_stmt_iterator *, walk_stmt_fn, walk_tree_fn,
4889                        struct walk_stmt_info *);
4890 tree walk_gimple_op (gimple, walk_tree_fn, struct walk_stmt_info *);
4891
4892 #ifdef GATHER_STATISTICS
4893 /* Enum and arrays used for allocation stats.  Keep in sync with
4894    gimple.c:gimple_alloc_kind_names.  */
4895 enum gimple_alloc_kind
4896 {
4897   gimple_alloc_kind_assign,     /* Assignments.  */
4898   gimple_alloc_kind_phi,        /* PHI nodes.  */
4899   gimple_alloc_kind_cond,       /* Conditionals.  */
4900   gimple_alloc_kind_seq,        /* Sequences.  */
4901   gimple_alloc_kind_rest,       /* Everything else.  */
4902   gimple_alloc_kind_all
4903 };
4904
4905 extern int gimple_alloc_counts[];
4906 extern int gimple_alloc_sizes[];
4907
4908 /* Return the allocation kind for a given stmt CODE.  */
4909 static inline enum gimple_alloc_kind
4910 gimple_alloc_kind (enum gimple_code code)
4911 {
4912   switch (code)
4913     {
4914       case GIMPLE_ASSIGN:
4915         return gimple_alloc_kind_assign;
4916       case GIMPLE_PHI:
4917         return gimple_alloc_kind_phi;
4918       case GIMPLE_COND:
4919         return gimple_alloc_kind_cond;
4920       default:
4921         return gimple_alloc_kind_rest;
4922     }
4923 }
4924 #endif /* GATHER_STATISTICS */
4925
4926 extern void dump_gimple_statistics (void);
4927
4928 /* In gimple-fold.c.  */
4929 void gimplify_and_update_call_from_tree (gimple_stmt_iterator *, tree);
4930 tree gimple_fold_builtin (gimple);
4931 bool fold_stmt (gimple_stmt_iterator *);
4932 bool fold_stmt_inplace (gimple);
4933 tree maybe_fold_offset_to_address (location_t, tree, tree, tree);
4934 tree maybe_fold_offset_to_reference (location_t, tree, tree, tree);
4935 tree maybe_fold_stmt_addition (location_t, tree, tree, tree);
4936 tree get_symbol_constant_value (tree);
4937 tree canonicalize_constructor_val (tree);
4938 bool may_propagate_address_into_dereference (tree, tree);
4939 extern tree maybe_fold_and_comparisons (enum tree_code, tree, tree, 
4940                                         enum tree_code, tree, tree);
4941 extern tree maybe_fold_or_comparisons (enum tree_code, tree, tree,
4942                                        enum tree_code, tree, tree);
4943
4944 #endif  /* GCC_GIMPLE_H */