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