OSDN Git Service

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