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