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