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