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