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