1 /* Register Transfer Language (RTL) definitions for GCC 2 Copyright (C) 1987-2020 Free Software Foundation, Inc. 3 4 This file is part of GCC. 5 6 GCC is free software; you can redistribute it and/or modify it under 7 the terms of the GNU General Public License as published by the Free 8 Software Foundation; either version 3, or (at your option) any later 9 version. 10 11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY 12 WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with GCC; see the file COPYING3. If not see 18 <http://www.gnu.org/licenses/>. */ 19 20 #ifndef GCC_RTL_H 21 #define GCC_RTL_H 22 23 /* This file is occasionally included by generator files which expect 24 machmode.h and other files to exist and would not normally have been 25 included by coretypes.h. */ 26 #ifdef GENERATOR_FILE 27 #include "real.h" 28 #include "fixed-value.h" 29 #include "statistics.h" 30 #include "vec.h" 31 #include "hash-table.h" 32 #include "hash-set.h" 33 #include "input.h" 34 #include "is-a.h" 35 #endif /* GENERATOR_FILE */ 36 37 #include "hard-reg-set.h" 38 39 class predefined_function_abi; 40 41 /* Value used by some passes to "recognize" noop moves as valid 42 instructions. */ 43 #define NOOP_MOVE_INSN_CODE INT_MAX 44 45 /* Register Transfer Language EXPRESSIONS CODES */ 46 47 #define RTX_CODE enum rtx_code 48 enum rtx_code { 49 50 #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) ENUM , 51 #include "rtl.def" /* rtl expressions are documented here */ 52 #undef DEF_RTL_EXPR 53 54 LAST_AND_UNUSED_RTX_CODE}; /* A convenient way to get a value for 55 NUM_RTX_CODE. 56 Assumes default enum value assignment. */ 57 58 /* The cast here, saves many elsewhere. */ 59 #define NUM_RTX_CODE ((int) LAST_AND_UNUSED_RTX_CODE) 60 61 /* Similar, but since generator files get more entries... */ 62 #ifdef GENERATOR_FILE 63 # define NON_GENERATOR_NUM_RTX_CODE ((int) MATCH_OPERAND) 64 #endif 65 66 /* Register Transfer Language EXPRESSIONS CODE CLASSES */ 67 68 enum rtx_class { 69 /* We check bit 0-1 of some rtx class codes in the predicates below. */ 70 71 /* Bit 0 = comparison if 0, arithmetic is 1 72 Bit 1 = 1 if commutative. */ 73 RTX_COMPARE, /* 0 */ 74 RTX_COMM_COMPARE, 75 RTX_BIN_ARITH, 76 RTX_COMM_ARITH, 77 78 /* Must follow the four preceding values. */ 79 RTX_UNARY, /* 4 */ 80 81 RTX_EXTRA, 82 RTX_MATCH, 83 RTX_INSN, 84 85 /* Bit 0 = 1 if constant. */ 86 RTX_OBJ, /* 8 */ 87 RTX_CONST_OBJ, 88 89 RTX_TERNARY, 90 RTX_BITFIELD_OPS, 91 RTX_AUTOINC 92 }; 93 94 #define RTX_OBJ_MASK (~1) 95 #define RTX_OBJ_RESULT (RTX_OBJ & RTX_OBJ_MASK) 96 #define RTX_COMPARE_MASK (~1) 97 #define RTX_COMPARE_RESULT (RTX_COMPARE & RTX_COMPARE_MASK) 98 #define RTX_ARITHMETIC_MASK (~1) 99 #define RTX_ARITHMETIC_RESULT (RTX_COMM_ARITH & RTX_ARITHMETIC_MASK) 100 #define RTX_BINARY_MASK (~3) 101 #define RTX_BINARY_RESULT (RTX_COMPARE & RTX_BINARY_MASK) 102 #define RTX_COMMUTATIVE_MASK (~2) 103 #define RTX_COMMUTATIVE_RESULT (RTX_COMM_COMPARE & RTX_COMMUTATIVE_MASK) 104 #define RTX_NON_COMMUTATIVE_RESULT (RTX_COMPARE & RTX_COMMUTATIVE_MASK) 105 106 extern const unsigned char rtx_length[NUM_RTX_CODE]; 107 #define GET_RTX_LENGTH(CODE) (rtx_length[(int) (CODE)]) 108 109 extern const char * const rtx_name[NUM_RTX_CODE]; 110 #define GET_RTX_NAME(CODE) (rtx_name[(int) (CODE)]) 111 112 extern const char * const rtx_format[NUM_RTX_CODE]; 113 #define GET_RTX_FORMAT(CODE) (rtx_format[(int) (CODE)]) 114 115 extern const enum rtx_class rtx_class[NUM_RTX_CODE]; 116 #define GET_RTX_CLASS(CODE) (rtx_class[(int) (CODE)]) 117 118 /* True if CODE is part of the insn chain (i.e. has INSN_UID, PREV_INSN 119 and NEXT_INSN fields). */ 120 #define INSN_CHAIN_CODE_P(CODE) IN_RANGE (CODE, DEBUG_INSN, NOTE) 121 122 extern const unsigned char rtx_code_size[NUM_RTX_CODE]; 123 extern const unsigned char rtx_next[NUM_RTX_CODE]; 124 125 /* The flags and bitfields of an ADDR_DIFF_VEC. BASE is the base label 126 relative to which the offsets are calculated, as explained in rtl.def. */ 127 struct addr_diff_vec_flags 128 { 129 /* Set at the start of shorten_branches - ONLY WHEN OPTIMIZING - : */ 130 unsigned min_align: 8; 131 /* Flags: */ 132 unsigned base_after_vec: 1; /* BASE is after the ADDR_DIFF_VEC. */ 133 unsigned min_after_vec: 1; /* minimum address target label is 134 after the ADDR_DIFF_VEC. */ 135 unsigned max_after_vec: 1; /* maximum address target label is 136 after the ADDR_DIFF_VEC. */ 137 unsigned min_after_base: 1; /* minimum address target label is 138 after BASE. */ 139 unsigned max_after_base: 1; /* maximum address target label is 140 after BASE. */ 141 /* Set by the actual branch shortening process - ONLY WHEN OPTIMIZING - : */ 142 unsigned offset_unsigned: 1; /* offsets have to be treated as unsigned. */ 143 unsigned : 2; 144 unsigned scale : 8; 145 }; 146 147 /* Structure used to describe the attributes of a MEM. These are hashed 148 so MEMs that the same attributes share a data structure. This means 149 they cannot be modified in place. */ 150 class GTY(()) mem_attrs 151 { 152 public: 153 mem_attrs (); 154 155 /* The expression that the MEM accesses, or null if not known. 156 This expression might be larger than the memory reference itself. 157 (In other words, the MEM might access only part of the object.) */ 158 tree expr; 159 160 /* The offset of the memory reference from the start of EXPR. 161 Only valid if OFFSET_KNOWN_P. */ 162 poly_int64 offset; 163 164 /* The size of the memory reference in bytes. Only valid if 165 SIZE_KNOWN_P. */ 166 poly_int64 size; 167 168 /* The alias set of the memory reference. */ 169 alias_set_type alias; 170 171 /* The alignment of the reference in bits. Always a multiple of 172 BITS_PER_UNIT. Note that EXPR may have a stricter alignment 173 than the memory reference itself. */ 174 unsigned int align; 175 176 /* The address space that the memory reference uses. */ 177 unsigned char addrspace; 178 179 /* True if OFFSET is known. */ 180 bool offset_known_p; 181 182 /* True if SIZE is known. */ 183 bool size_known_p; 184 }; 185 186 /* Structure used to describe the attributes of a REG in similar way as 187 mem_attrs does for MEM above. Note that the OFFSET field is calculated 188 in the same way as for mem_attrs, rather than in the same way as a 189 SUBREG_BYTE. For example, if a big-endian target stores a byte 190 object in the low part of a 4-byte register, the OFFSET field 191 will be -3 rather than 0. */ 192 193 class GTY((for_user)) reg_attrs { 194 public: 195 tree decl; /* decl corresponding to REG. */ 196 poly_int64 offset; /* Offset from start of DECL. */ 197 }; 198 199 /* Common union for an element of an rtx. */ 200 201 union rtunion 202 { 203 int rt_int; 204 unsigned int rt_uint; 205 poly_uint16_pod rt_subreg; 206 const char *rt_str; 207 rtx rt_rtx; 208 rtvec rt_rtvec; 209 machine_mode rt_type; 210 addr_diff_vec_flags rt_addr_diff_vec_flags; 211 struct cselib_val *rt_cselib; 212 tree rt_tree; 213 basic_block rt_bb; 214 mem_attrs *rt_mem; 215 class constant_descriptor_rtx *rt_constant; 216 struct dw_cfi_node *rt_cfi; 217 }; 218 219 /* Describes the properties of a REG. */ 220 struct GTY(()) reg_info { 221 /* The value of REGNO. */ 222 unsigned int regno; 223 224 /* The value of REG_NREGS. */ 225 unsigned int nregs : 8; 226 unsigned int unused : 24; 227 228 /* The value of REG_ATTRS. */ 229 reg_attrs *attrs; 230 }; 231 232 /* This structure remembers the position of a SYMBOL_REF within an 233 object_block structure. A SYMBOL_REF only provides this information 234 if SYMBOL_REF_HAS_BLOCK_INFO_P is true. */ 235 struct GTY(()) block_symbol { 236 /* The usual SYMBOL_REF fields. */ 237 rtunion GTY ((skip)) fld[2]; 238 239 /* The block that contains this object. */ 240 struct object_block *block; 241 242 /* The offset of this object from the start of its block. It is negative 243 if the symbol has not yet been assigned an offset. */ 244 HOST_WIDE_INT offset; 245 }; 246 247 /* Describes a group of objects that are to be placed together in such 248 a way that their relative positions are known. */ 249 struct GTY((for_user)) object_block { 250 /* The section in which these objects should be placed. */ 251 section *sect; 252 253 /* The alignment of the first object, measured in bits. */ 254 unsigned int alignment; 255 256 /* The total size of the objects, measured in bytes. */ 257 HOST_WIDE_INT size; 258 259 /* The SYMBOL_REFs for each object. The vector is sorted in 260 order of increasing offset and the following conditions will 261 hold for each element X: 262 263 SYMBOL_REF_HAS_BLOCK_INFO_P (X) 264 !SYMBOL_REF_ANCHOR_P (X) 265 SYMBOL_REF_BLOCK (X) == [address of this structure] 266 SYMBOL_REF_BLOCK_OFFSET (X) >= 0. */ 267 vec<rtx, va_gc> *objects; 268 269 /* All the anchor SYMBOL_REFs used to address these objects, sorted 270 in order of increasing offset, and then increasing TLS model. 271 The following conditions will hold for each element X in this vector: 272 273 SYMBOL_REF_HAS_BLOCK_INFO_P (X) 274 SYMBOL_REF_ANCHOR_P (X) 275 SYMBOL_REF_BLOCK (X) == [address of this structure] 276 SYMBOL_REF_BLOCK_OFFSET (X) >= 0. */ 277 vec<rtx, va_gc> *anchors; 278 }; 279 280 struct GTY((variable_size)) hwivec_def { 281 HOST_WIDE_INT elem[1]; 282 }; 283 284 /* Number of elements of the HWIVEC if RTX is a CONST_WIDE_INT. */ 285 #define CWI_GET_NUM_ELEM(RTX) \ 286 ((int)RTL_FLAG_CHECK1("CWI_GET_NUM_ELEM", (RTX), CONST_WIDE_INT)->u2.num_elem) 287 #define CWI_PUT_NUM_ELEM(RTX, NUM) \ 288 (RTL_FLAG_CHECK1("CWI_PUT_NUM_ELEM", (RTX), CONST_WIDE_INT)->u2.num_elem = (NUM)) 289 290 struct GTY((variable_size)) const_poly_int_def { 291 trailing_wide_ints<NUM_POLY_INT_COEFFS> coeffs; 292 }; 293 294 /* RTL expression ("rtx"). */ 295 296 /* The GTY "desc" and "tag" options below are a kludge: we need a desc 297 field for gengtype to recognize that inheritance is occurring, 298 so that all subclasses are redirected to the traversal hook for the 299 base class. 300 However, all of the fields are in the base class, and special-casing 301 is at work. Hence we use desc and tag of 0, generating a switch 302 statement of the form: 303 switch (0) 304 { 305 case 0: // all the work happens here 306 } 307 in order to work with the existing special-casing in gengtype. */ 308 309 struct GTY((desc("0"), tag("0"), 310 chain_next ("RTX_NEXT (&%h)"), 311 chain_prev ("RTX_PREV (&%h)"))) rtx_def { 312 /* The kind of expression this is. */ 313 ENUM_BITFIELD(rtx_code) code: 16; 314 315 /* The kind of value the expression has. */ 316 ENUM_BITFIELD(machine_mode) mode : 8; 317 318 /* 1 in a MEM if we should keep the alias set for this mem unchanged 319 when we access a component. 320 1 in a JUMP_INSN if it is a crossing jump. 321 1 in a CALL_INSN if it is a sibling call. 322 1 in a SET that is for a return. 323 In a CODE_LABEL, part of the two-bit alternate entry field. 324 1 in a CONCAT is VAL_EXPR_IS_COPIED in var-tracking.c. 325 1 in a VALUE is SP_BASED_VALUE_P in cselib.c. 326 1 in a SUBREG generated by LRA for reload insns. 327 1 in a REG if this is a static chain register. 328 Dumped as "/j" in RTL dumps. */ 329 unsigned int jump : 1; 330 /* In a CODE_LABEL, part of the two-bit alternate entry field. 331 1 in a MEM if it cannot trap. 332 1 in a CALL_INSN logically equivalent to 333 ECF_LOOPING_CONST_OR_PURE and DECL_LOOPING_CONST_OR_PURE_P. 334 1 in a VALUE is SP_DERIVED_VALUE_P in cselib.c. 335 Dumped as "/c" in RTL dumps. */ 336 unsigned int call : 1; 337 /* 1 in a REG, MEM, or CONCAT if the value is set at most once, anywhere. 338 1 in a SUBREG used for SUBREG_PROMOTED_UNSIGNED_P. 339 1 in a SYMBOL_REF if it addresses something in the per-function 340 constants pool. 341 1 in a CALL_INSN logically equivalent to ECF_CONST and TREE_READONLY. 342 1 in a NOTE, or EXPR_LIST for a const call. 343 1 in a JUMP_INSN of an annulling branch. 344 1 in a CONCAT is VAL_EXPR_IS_CLOBBERED in var-tracking.c. 345 1 in a preserved VALUE is PRESERVED_VALUE_P in cselib.c. 346 1 in a clobber temporarily created for LRA. 347 Dumped as "/u" in RTL dumps. */ 348 unsigned int unchanging : 1; 349 /* 1 in a MEM or ASM_OPERANDS expression if the memory reference is volatile. 350 1 in an INSN, CALL_INSN, JUMP_INSN, CODE_LABEL, BARRIER, or NOTE 351 if it has been deleted. 352 1 in a REG expression if corresponds to a variable declared by the user, 353 0 for an internally generated temporary. 354 1 in a SUBREG used for SUBREG_PROMOTED_UNSIGNED_P. 355 1 in a LABEL_REF, REG_LABEL_TARGET or REG_LABEL_OPERAND note for a 356 non-local label. 357 In a SYMBOL_REF, this flag is used for machine-specific purposes. 358 In a PREFETCH, this flag indicates that it should be considered a 359 scheduling barrier. 360 1 in a CONCAT is VAL_NEEDS_RESOLUTION in var-tracking.c. 361 Dumped as "/v" in RTL dumps. */ 362 unsigned int volatil : 1; 363 /* 1 in a REG if the register is used only in exit code a loop. 364 1 in a SUBREG expression if was generated from a variable with a 365 promoted mode. 366 1 in a CODE_LABEL if the label is used for nonlocal gotos 367 and must not be deleted even if its count is zero. 368 1 in an INSN, JUMP_INSN or CALL_INSN if this insn must be scheduled 369 together with the preceding insn. Valid only within sched. 370 1 in an INSN, JUMP_INSN, or CALL_INSN if insn is in a delay slot and 371 from the target of a branch. Valid from reorg until end of compilation; 372 cleared before used. 373 374 The name of the field is historical. It used to be used in MEMs 375 to record whether the MEM accessed part of a structure. 376 Dumped as "/s" in RTL dumps. */ 377 unsigned int in_struct : 1; 378 /* At the end of RTL generation, 1 if this rtx is used. This is used for 379 copying shared structure. See `unshare_all_rtl'. 380 In a REG, this is not needed for that purpose, and used instead 381 in `leaf_renumber_regs_insn'. 382 1 in a SYMBOL_REF, means that emit_library_call 383 has used it as the function. 384 1 in a CONCAT is VAL_HOLDS_TRACK_EXPR in var-tracking.c. 385 1 in a VALUE or DEBUG_EXPR is VALUE_RECURSED_INTO in var-tracking.c. */ 386 unsigned int used : 1; 387 /* 1 in an INSN or a SET if this rtx is related to the call frame, 388 either changing how we compute the frame address or saving and 389 restoring registers in the prologue and epilogue. 390 1 in a REG or MEM if it is a pointer. 391 1 in a SYMBOL_REF if it addresses something in the per-function 392 constant string pool. 393 1 in a VALUE is VALUE_CHANGED in var-tracking.c. 394 Dumped as "/f" in RTL dumps. */ 395 unsigned frame_related : 1; 396 /* 1 in a REG or PARALLEL that is the current function's return value. 397 1 in a SYMBOL_REF for a weak symbol. 398 1 in a CALL_INSN logically equivalent to ECF_PURE and DECL_PURE_P. 399 1 in a CONCAT is VAL_EXPR_HAS_REVERSE in var-tracking.c. 400 1 in a VALUE or DEBUG_EXPR is NO_LOC_P in var-tracking.c. 401 Dumped as "/i" in RTL dumps. */ 402 unsigned return_val : 1; 403 404 union { 405 /* The final union field is aligned to 64 bits on LP64 hosts, 406 giving a 32-bit gap after the fields above. We optimize the 407 layout for that case and use the gap for extra code-specific 408 information. */ 409 410 /* The ORIGINAL_REGNO of a REG. */ 411 unsigned int original_regno; 412 413 /* The INSN_UID of an RTX_INSN-class code. */ 414 int insn_uid; 415 416 /* The SYMBOL_REF_FLAGS of a SYMBOL_REF. */ 417 unsigned int symbol_ref_flags; 418 419 /* The PAT_VAR_LOCATION_STATUS of a VAR_LOCATION. */ 420 enum var_init_status var_location_status; 421 422 /* In a CONST_WIDE_INT (aka hwivec_def), this is the number of 423 HOST_WIDE_INTs in the hwivec_def. */ 424 unsigned int num_elem; 425 426 /* Information about a CONST_VECTOR. */ 427 struct 428 { 429 /* The value of CONST_VECTOR_NPATTERNS. */ 430 unsigned int npatterns : 16; 431 432 /* The value of CONST_VECTOR_NELTS_PER_PATTERN. */ 433 unsigned int nelts_per_pattern : 8; 434 435 /* For future expansion. */ 436 unsigned int unused : 8; 437 } const_vector; 438 } GTY ((skip)) u2; 439 440 /* The first element of the operands of this rtx. 441 The number of operands and their types are controlled 442 by the `code' field, according to rtl.def. */ 443 union u { 444 rtunion fld[1]; 445 HOST_WIDE_INT hwint[1]; 446 struct reg_info reg; 447 struct block_symbol block_sym; 448 struct real_value rv; 449 struct fixed_value fv; 450 struct hwivec_def hwiv; 451 struct const_poly_int_def cpi; 452 } GTY ((special ("rtx_def"), desc ("GET_CODE (&%0)"))) u; 453 }; 454 455 /* A node for constructing singly-linked lists of rtx. */ 456 457 struct GTY(()) rtx_expr_list : public rtx_def 458 { 459 private: 460 /* No extra fields, but adds invariant: (GET_CODE (X) == EXPR_LIST). */ 461 462 public: 463 /* Get next in list. */ 464 rtx_expr_list *next () const; 465 466 /* Get at the underlying rtx. */ 467 rtx element () const; 468 }; 469 470 template <> 471 template <> 472 inline bool 473 is_a_helper <rtx_expr_list *>::test (rtx rt) 474 { 475 return rt->code == EXPR_LIST; 476 } 477 478 struct GTY(()) rtx_insn_list : public rtx_def 479 { 480 private: 481 /* No extra fields, but adds invariant: (GET_CODE (X) == INSN_LIST). 482 483 This is an instance of: 484 485 DEF_RTL_EXPR(INSN_LIST, "insn_list", "ue", RTX_EXTRA) 486 487 i.e. a node for constructing singly-linked lists of rtx_insn *, where 488 the list is "external" to the insn (as opposed to the doubly-linked 489 list embedded within rtx_insn itself). */ 490 491 public: 492 /* Get next in list. */ 493 rtx_insn_list *next () const; 494 495 /* Get at the underlying instruction. */ 496 rtx_insn *insn () const; 497 498 }; 499 500 template <> 501 template <> 502 inline bool 503 is_a_helper <rtx_insn_list *>::test (rtx rt) 504 { 505 return rt->code == INSN_LIST; 506 } 507 508 /* A node with invariant GET_CODE (X) == SEQUENCE i.e. a vector of rtx, 509 typically (but not always) of rtx_insn *, used in the late passes. */ 510 511 struct GTY(()) rtx_sequence : public rtx_def 512 { 513 private: 514 /* No extra fields, but adds invariant: (GET_CODE (X) == SEQUENCE). */ 515 516 public: 517 /* Get number of elements in sequence. */ 518 int len () const; 519 520 /* Get i-th element of the sequence. */ 521 rtx element (int index) const; 522 523 /* Get i-th element of the sequence, with a checked cast to 524 rtx_insn *. */ 525 rtx_insn *insn (int index) const; 526 }; 527 528 template <> 529 template <> 530 inline bool 531 is_a_helper <rtx_sequence *>::test (rtx rt) 532 { 533 return rt->code == SEQUENCE; 534 } 535 536 template <> 537 template <> 538 inline bool 539 is_a_helper <const rtx_sequence *>::test (const_rtx rt) 540 { 541 return rt->code == SEQUENCE; 542 } 543 544 struct GTY(()) rtx_insn : public rtx_def 545 { 546 public: 547 /* No extra fields, but adds the invariant: 548 549 (INSN_P (X) 550 || NOTE_P (X) 551 || JUMP_TABLE_DATA_P (X) 552 || BARRIER_P (X) 553 || LABEL_P (X)) 554 555 i.e. that we must be able to use the following: 556 INSN_UID () 557 NEXT_INSN () 558 PREV_INSN () 559 i.e. we have an rtx that has an INSN_UID field and can be part of 560 a linked list of insns. 561 */ 562 563 /* Returns true if this insn has been deleted. */ 564 565 bool deleted () const { return volatil; } 566 567 /* Mark this insn as deleted. */ 568 569 void set_deleted () { volatil = true; } 570 571 /* Mark this insn as not deleted. */ 572 573 void set_undeleted () { volatil = false; } 574 }; 575 576 /* Subclasses of rtx_insn. */ 577 578 struct GTY(()) rtx_debug_insn : public rtx_insn 579 { 580 /* No extra fields, but adds the invariant: 581 DEBUG_INSN_P (X) aka (GET_CODE (X) == DEBUG_INSN) 582 i.e. an annotation for tracking variable assignments. 583 584 This is an instance of: 585 DEF_RTL_EXPR(DEBUG_INSN, "debug_insn", "uuBeiie", RTX_INSN) 586 from rtl.def. */ 587 }; 588 589 struct GTY(()) rtx_nonjump_insn : public rtx_insn 590 { 591 /* No extra fields, but adds the invariant: 592 NONJUMP_INSN_P (X) aka (GET_CODE (X) == INSN) 593 i.e an instruction that cannot jump. 594 595 This is an instance of: 596 DEF_RTL_EXPR(INSN, "insn", "uuBeiie", RTX_INSN) 597 from rtl.def. */ 598 }; 599 600 struct GTY(()) rtx_jump_insn : public rtx_insn 601 { 602 public: 603 /* No extra fields, but adds the invariant: 604 JUMP_P (X) aka (GET_CODE (X) == JUMP_INSN) 605 i.e. an instruction that can possibly jump. 606 607 This is an instance of: 608 DEF_RTL_EXPR(JUMP_INSN, "jump_insn", "uuBeiie0", RTX_INSN) 609 from rtl.def. */ 610 611 /* Returns jump target of this instruction. The returned value is not 612 necessarily a code label: it may also be a RETURN or SIMPLE_RETURN 613 expression. Also, when the code label is marked "deleted", it is 614 replaced by a NOTE. In some cases the value is NULL_RTX. */ 615 616 inline rtx jump_label () const; 617 618 /* Returns jump target cast to rtx_code_label *. */ 619 620 inline rtx_code_label *jump_target () const; 621 622 /* Set jump target. */ 623 624 inline void set_jump_target (rtx_code_label *); 625 }; 626 627 struct GTY(()) rtx_call_insn : public rtx_insn 628 { 629 /* No extra fields, but adds the invariant: 630 CALL_P (X) aka (GET_CODE (X) == CALL_INSN) 631 i.e. an instruction that can possibly call a subroutine 632 but which will not change which instruction comes next 633 in the current function. 634 635 This is an instance of: 636 DEF_RTL_EXPR(CALL_INSN, "call_insn", "uuBeiiee", RTX_INSN) 637 from rtl.def. */ 638 }; 639 640 struct GTY(()) rtx_jump_table_data : public rtx_insn 641 { 642 /* No extra fields, but adds the invariant: 643 JUMP_TABLE_DATA_P (X) aka (GET_CODE (INSN) == JUMP_TABLE_DATA) 644 i.e. a data for a jump table, considered an instruction for 645 historical reasons. 646 647 This is an instance of: 648 DEF_RTL_EXPR(JUMP_TABLE_DATA, "jump_table_data", "uuBe0000", RTX_INSN) 649 from rtl.def. */ 650 651 /* This can be either: 652 653 (a) a table of absolute jumps, in which case PATTERN (this) is an 654 ADDR_VEC with arg 0 a vector of labels, or 655 656 (b) a table of relative jumps (e.g. for -fPIC), in which case 657 PATTERN (this) is an ADDR_DIFF_VEC, with arg 0 a LABEL_REF and 658 arg 1 the vector of labels. 659 660 This method gets the underlying vec. */ 661 662 inline rtvec get_labels () const; 663 inline scalar_int_mode get_data_mode () const; 664 }; 665 666 struct GTY(()) rtx_barrier : public rtx_insn 667 { 668 /* No extra fields, but adds the invariant: 669 BARRIER_P (X) aka (GET_CODE (X) == BARRIER) 670 i.e. a marker that indicates that control will not flow through. 671 672 This is an instance of: 673 DEF_RTL_EXPR(BARRIER, "barrier", "uu00000", RTX_EXTRA) 674 from rtl.def. */ 675 }; 676 677 struct GTY(()) rtx_code_label : public rtx_insn 678 { 679 /* No extra fields, but adds the invariant: 680 LABEL_P (X) aka (GET_CODE (X) == CODE_LABEL) 681 i.e. a label in the assembler. 682 683 This is an instance of: 684 DEF_RTL_EXPR(CODE_LABEL, "code_label", "uuB00is", RTX_EXTRA) 685 from rtl.def. */ 686 }; 687 688 struct GTY(()) rtx_note : public rtx_insn 689 { 690 /* No extra fields, but adds the invariant: 691 NOTE_P(X) aka (GET_CODE (X) == NOTE) 692 i.e. a note about the corresponding source code. 693 694 This is an instance of: 695 DEF_RTL_EXPR(NOTE, "note", "uuB0ni", RTX_EXTRA) 696 from rtl.def. */ 697 }; 698 699 /* The size in bytes of an rtx header (code, mode and flags). */ 700 #define RTX_HDR_SIZE offsetof (struct rtx_def, u) 701 702 /* The size in bytes of an rtx with code CODE. */ 703 #define RTX_CODE_SIZE(CODE) rtx_code_size[CODE] 704 705 #define NULL_RTX (rtx) 0 706 707 /* The "next" and "previous" RTX, relative to this one. */ 708 709 #define RTX_NEXT(X) (rtx_next[GET_CODE (X)] == 0 ? NULL \ 710 : *(rtx *)(((char *)X) + rtx_next[GET_CODE (X)])) 711 712 /* FIXME: the "NEXT_INSN (PREV_INSN (X)) == X" condition shouldn't be needed. 713 */ 714 #define RTX_PREV(X) ((INSN_P (X) \ 715 || NOTE_P (X) \ 716 || JUMP_TABLE_DATA_P (X) \ 717 || BARRIER_P (X) \ 718 || LABEL_P (X)) \ 719 && PREV_INSN (as_a <rtx_insn *> (X)) != NULL \ 720 && NEXT_INSN (PREV_INSN (as_a <rtx_insn *> (X))) == X \ 721 ? PREV_INSN (as_a <rtx_insn *> (X)) : NULL) 722 723 /* Define macros to access the `code' field of the rtx. */ 724 725 #define GET_CODE(RTX) ((enum rtx_code) (RTX)->code) 726 #define PUT_CODE(RTX, CODE) ((RTX)->code = (CODE)) 727 728 #define GET_MODE(RTX) ((machine_mode) (RTX)->mode) 729 #define PUT_MODE_RAW(RTX, MODE) ((RTX)->mode = (MODE)) 730 731 /* RTL vector. These appear inside RTX's when there is a need 732 for a variable number of things. The principle use is inside 733 PARALLEL expressions. */ 734 735 struct GTY(()) rtvec_def { 736 int num_elem; /* number of elements */ 737 rtx GTY ((length ("%h.num_elem"))) elem[1]; 738 }; 739 740 #define NULL_RTVEC (rtvec) 0 741 742 #define GET_NUM_ELEM(RTVEC) ((RTVEC)->num_elem) 743 #define PUT_NUM_ELEM(RTVEC, NUM) ((RTVEC)->num_elem = (NUM)) 744 745 /* Predicate yielding nonzero iff X is an rtx for a register. */ 746 #define REG_P(X) (GET_CODE (X) == REG) 747 748 /* Predicate yielding nonzero iff X is an rtx for a memory location. */ 749 #define MEM_P(X) (GET_CODE (X) == MEM) 750 751 #if TARGET_SUPPORTS_WIDE_INT 752 753 /* Match CONST_*s that can represent compile-time constant integers. */ 754 #define CASE_CONST_SCALAR_INT \ 755 case CONST_INT: \ 756 case CONST_WIDE_INT 757 758 /* Match CONST_*s for which pointer equality corresponds to value 759 equality. */ 760 #define CASE_CONST_UNIQUE \ 761 case CONST_INT: \ 762 case CONST_WIDE_INT: \ 763 case CONST_POLY_INT: \ 764 case CONST_DOUBLE: \ 765 case CONST_FIXED 766 767 /* Match all CONST_* rtxes. */ 768 #define CASE_CONST_ANY \ 769 case CONST_INT: \ 770 case CONST_WIDE_INT: \ 771 case CONST_POLY_INT: \ 772 case CONST_DOUBLE: \ 773 case CONST_FIXED: \ 774 case CONST_VECTOR 775 776 #else 777 778 /* Match CONST_*s that can represent compile-time constant integers. */ 779 #define CASE_CONST_SCALAR_INT \ 780 case CONST_INT: \ 781 case CONST_DOUBLE 782 783 /* Match CONST_*s for which pointer equality corresponds to value 784 equality. */ 785 #define CASE_CONST_UNIQUE \ 786 case CONST_INT: \ 787 case CONST_DOUBLE: \ 788 case CONST_FIXED 789 790 /* Match all CONST_* rtxes. */ 791 #define CASE_CONST_ANY \ 792 case CONST_INT: \ 793 case CONST_DOUBLE: \ 794 case CONST_FIXED: \ 795 case CONST_VECTOR 796 #endif 797 798 /* Predicate yielding nonzero iff X is an rtx for a constant integer. */ 799 #define CONST_INT_P(X) (GET_CODE (X) == CONST_INT) 800 801 /* Predicate yielding nonzero iff X is an rtx for a constant integer. */ 802 #define CONST_WIDE_INT_P(X) (GET_CODE (X) == CONST_WIDE_INT) 803 804 /* Predicate yielding nonzero iff X is an rtx for a polynomial constant 805 integer. */ 806 #define CONST_POLY_INT_P(X) \ 807 (NUM_POLY_INT_COEFFS > 1 && GET_CODE (X) == CONST_POLY_INT) 808 809 /* Predicate yielding nonzero iff X is an rtx for a constant fixed-point. */ 810 #define CONST_FIXED_P(X) (GET_CODE (X) == CONST_FIXED) 811 812 /* Predicate yielding true iff X is an rtx for a double-int 813 or floating point constant. */ 814 #define CONST_DOUBLE_P(X) (GET_CODE (X) == CONST_DOUBLE) 815 816 /* Predicate yielding true iff X is an rtx for a double-int. */ 817 #define CONST_DOUBLE_AS_INT_P(X) \ 818 (GET_CODE (X) == CONST_DOUBLE && GET_MODE (X) == VOIDmode) 819 820 /* Predicate yielding true iff X is an rtx for a integer const. */ 821 #if TARGET_SUPPORTS_WIDE_INT 822 #define CONST_SCALAR_INT_P(X) \ 823 (CONST_INT_P (X) || CONST_WIDE_INT_P (X)) 824 #else 825 #define CONST_SCALAR_INT_P(X) \ 826 (CONST_INT_P (X) || CONST_DOUBLE_AS_INT_P (X)) 827 #endif 828 829 /* Predicate yielding true iff X is an rtx for a double-int. */ 830 #define CONST_DOUBLE_AS_FLOAT_P(X) \ 831 (GET_CODE (X) == CONST_DOUBLE && GET_MODE (X) != VOIDmode) 832 833 /* Predicate yielding nonzero iff X is a label insn. */ 834 #define LABEL_P(X) (GET_CODE (X) == CODE_LABEL) 835 836 /* Predicate yielding nonzero iff X is a jump insn. */ 837 #define JUMP_P(X) (GET_CODE (X) == JUMP_INSN) 838 839 /* Predicate yielding nonzero iff X is a call insn. */ 840 #define CALL_P(X) (GET_CODE (X) == CALL_INSN) 841 842 /* Predicate yielding nonzero iff X is an insn that cannot jump. */ 843 #define NONJUMP_INSN_P(X) (GET_CODE (X) == INSN) 844 845 /* Predicate yielding nonzero iff X is a debug note/insn. */ 846 #define DEBUG_INSN_P(X) (GET_CODE (X) == DEBUG_INSN) 847 848 /* Predicate yielding nonzero iff X is an insn that is not a debug insn. */ 849 #define NONDEBUG_INSN_P(X) (NONJUMP_INSN_P (X) || JUMP_P (X) || CALL_P (X)) 850 851 /* Nonzero if DEBUG_MARKER_INSN_P may possibly hold. */ 852 #define MAY_HAVE_DEBUG_MARKER_INSNS debug_nonbind_markers_p 853 /* Nonzero if DEBUG_BIND_INSN_P may possibly hold. */ 854 #define MAY_HAVE_DEBUG_BIND_INSNS flag_var_tracking_assignments 855 /* Nonzero if DEBUG_INSN_P may possibly hold. */ 856 #define MAY_HAVE_DEBUG_INSNS \ 857 (MAY_HAVE_DEBUG_MARKER_INSNS || MAY_HAVE_DEBUG_BIND_INSNS) 858 859 /* Predicate yielding nonzero iff X is a real insn. */ 860 #define INSN_P(X) (NONDEBUG_INSN_P (X) || DEBUG_INSN_P (X)) 861 862 /* Predicate yielding nonzero iff X is a note insn. */ 863 #define NOTE_P(X) (GET_CODE (X) == NOTE) 864 865 /* Predicate yielding nonzero iff X is a barrier insn. */ 866 #define BARRIER_P(X) (GET_CODE (X) == BARRIER) 867 868 /* Predicate yielding nonzero iff X is a data for a jump table. */ 869 #define JUMP_TABLE_DATA_P(INSN) (GET_CODE (INSN) == JUMP_TABLE_DATA) 870 871 /* Predicate yielding nonzero iff RTX is a subreg. */ 872 #define SUBREG_P(RTX) (GET_CODE (RTX) == SUBREG) 873 874 /* Predicate yielding true iff RTX is a symbol ref. */ 875 #define SYMBOL_REF_P(RTX) (GET_CODE (RTX) == SYMBOL_REF) 876 877 template <> 878 template <> 879 inline bool 880 is_a_helper <rtx_insn *>::test (rtx rt) 881 { 882 return (INSN_P (rt) 883 || NOTE_P (rt) 884 || JUMP_TABLE_DATA_P (rt) 885 || BARRIER_P (rt) 886 || LABEL_P (rt)); 887 } 888 889 template <> 890 template <> 891 inline bool 892 is_a_helper <const rtx_insn *>::test (const_rtx rt) 893 { 894 return (INSN_P (rt) 895 || NOTE_P (rt) 896 || JUMP_TABLE_DATA_P (rt) 897 || BARRIER_P (rt) 898 || LABEL_P (rt)); 899 } 900 901 template <> 902 template <> 903 inline bool 904 is_a_helper <rtx_debug_insn *>::test (rtx rt) 905 { 906 return DEBUG_INSN_P (rt); 907 } 908 909 template <> 910 template <> 911 inline bool 912 is_a_helper <rtx_nonjump_insn *>::test (rtx rt) 913 { 914 return NONJUMP_INSN_P (rt); 915 } 916 917 template <> 918 template <> 919 inline bool 920 is_a_helper <rtx_jump_insn *>::test (rtx rt) 921 { 922 return JUMP_P (rt); 923 } 924 925 template <> 926 template <> 927 inline bool 928 is_a_helper <rtx_jump_insn *>::test (rtx_insn *insn) 929 { 930 return JUMP_P (insn); 931 } 932 933 template <> 934 template <> 935 inline bool 936 is_a_helper <rtx_call_insn *>::test (rtx rt) 937 { 938 return CALL_P (rt); 939 } 940 941 template <> 942 template <> 943 inline bool 944 is_a_helper <rtx_call_insn *>::test (rtx_insn *insn) 945 { 946 return CALL_P (insn); 947 } 948 949 template <> 950 template <> 951 inline bool 952 is_a_helper <rtx_jump_table_data *>::test (rtx rt) 953 { 954 return JUMP_TABLE_DATA_P (rt); 955 } 956 957 template <> 958 template <> 959 inline bool 960 is_a_helper <rtx_jump_table_data *>::test (rtx_insn *insn) 961 { 962 return JUMP_TABLE_DATA_P (insn); 963 } 964 965 template <> 966 template <> 967 inline bool 968 is_a_helper <rtx_barrier *>::test (rtx rt) 969 { 970 return BARRIER_P (rt); 971 } 972 973 template <> 974 template <> 975 inline bool 976 is_a_helper <rtx_code_label *>::test (rtx rt) 977 { 978 return LABEL_P (rt); 979 } 980 981 template <> 982 template <> 983 inline bool 984 is_a_helper <rtx_code_label *>::test (rtx_insn *insn) 985 { 986 return LABEL_P (insn); 987 } 988 989 template <> 990 template <> 991 inline bool 992 is_a_helper <rtx_note *>::test (rtx rt) 993 { 994 return NOTE_P (rt); 995 } 996 997 template <> 998 template <> 999 inline bool 1000 is_a_helper <rtx_note *>::test (rtx_insn *insn) 1001 { 1002 return NOTE_P (insn); 1003 } 1004 1005 /* Predicate yielding nonzero iff X is a return or simple_return. */ 1006 #define ANY_RETURN_P(X) \ 1007 (GET_CODE (X) == RETURN || GET_CODE (X) == SIMPLE_RETURN) 1008 1009 /* 1 if X is a unary operator. */ 1010 1011 #define UNARY_P(X) \ 1012 (GET_RTX_CLASS (GET_CODE (X)) == RTX_UNARY) 1013 1014 /* 1 if X is a binary operator. */ 1015 1016 #define BINARY_P(X) \ 1017 ((GET_RTX_CLASS (GET_CODE (X)) & RTX_BINARY_MASK) == RTX_BINARY_RESULT) 1018 1019 /* 1 if X is an arithmetic operator. */ 1020 1021 #define ARITHMETIC_P(X) \ 1022 ((GET_RTX_CLASS (GET_CODE (X)) & RTX_ARITHMETIC_MASK) \ 1023 == RTX_ARITHMETIC_RESULT) 1024 1025 /* 1 if X is an arithmetic operator. */ 1026 1027 #define COMMUTATIVE_ARITH_P(X) \ 1028 (GET_RTX_CLASS (GET_CODE (X)) == RTX_COMM_ARITH) 1029 1030 /* 1 if X is a commutative arithmetic operator or a comparison operator. 1031 These two are sometimes selected together because it is possible to 1032 swap the two operands. */ 1033 1034 #define SWAPPABLE_OPERANDS_P(X) \ 1035 ((1 << GET_RTX_CLASS (GET_CODE (X))) \ 1036 & ((1 << RTX_COMM_ARITH) | (1 << RTX_COMM_COMPARE) \ 1037 | (1 << RTX_COMPARE))) 1038 1039 /* 1 if X is a non-commutative operator. */ 1040 1041 #define NON_COMMUTATIVE_P(X) \ 1042 ((GET_RTX_CLASS (GET_CODE (X)) & RTX_COMMUTATIVE_MASK) \ 1043 == RTX_NON_COMMUTATIVE_RESULT) 1044 1045 /* 1 if X is a commutative operator on integers. */ 1046 1047 #define COMMUTATIVE_P(X) \ 1048 ((GET_RTX_CLASS (GET_CODE (X)) & RTX_COMMUTATIVE_MASK) \ 1049 == RTX_COMMUTATIVE_RESULT) 1050 1051 /* 1 if X is a relational operator. */ 1052 1053 #define COMPARISON_P(X) \ 1054 ((GET_RTX_CLASS (GET_CODE (X)) & RTX_COMPARE_MASK) == RTX_COMPARE_RESULT) 1055 1056 /* 1 if X is a constant value that is an integer. */ 1057 1058 #define CONSTANT_P(X) \ 1059 (GET_RTX_CLASS (GET_CODE (X)) == RTX_CONST_OBJ) 1060 1061 /* 1 if X is a LABEL_REF. */ 1062 #define LABEL_REF_P(X) \ 1063 (GET_CODE (X) == LABEL_REF) 1064 1065 /* 1 if X can be used to represent an object. */ 1066 #define OBJECT_P(X) \ 1067 ((GET_RTX_CLASS (GET_CODE (X)) & RTX_OBJ_MASK) == RTX_OBJ_RESULT) 1068 1069 /* General accessor macros for accessing the fields of an rtx. */ 1070 1071 #if defined ENABLE_RTL_CHECKING && (GCC_VERSION >= 2007) 1072 /* The bit with a star outside the statement expr and an & inside is 1073 so that N can be evaluated only once. */ 1074 #define RTL_CHECK1(RTX, N, C1) __extension__ \ 1075 (*({ __typeof (RTX) const _rtx = (RTX); const int _n = (N); \ 1076 const enum rtx_code _code = GET_CODE (_rtx); \ 1077 if (_n < 0 || _n >= GET_RTX_LENGTH (_code)) \ 1078 rtl_check_failed_bounds (_rtx, _n, __FILE__, __LINE__, \ 1079 __FUNCTION__); \ 1080 if (GET_RTX_FORMAT (_code)[_n] != C1) \ 1081 rtl_check_failed_type1 (_rtx, _n, C1, __FILE__, __LINE__, \ 1082 __FUNCTION__); \ 1083 &_rtx->u.fld[_n]; })) 1084 1085 #define RTL_CHECK2(RTX, N, C1, C2) __extension__ \ 1086 (*({ __typeof (RTX) const _rtx = (RTX); const int _n = (N); \ 1087 const enum rtx_code _code = GET_CODE (_rtx); \ 1088 if (_n < 0 || _n >= GET_RTX_LENGTH (_code)) \ 1089 rtl_check_failed_bounds (_rtx, _n, __FILE__, __LINE__, \ 1090 __FUNCTION__); \ 1091 if (GET_RTX_FORMAT (_code)[_n] != C1 \ 1092 && GET_RTX_FORMAT (_code)[_n] != C2) \ 1093 rtl_check_failed_type2 (_rtx, _n, C1, C2, __FILE__, __LINE__, \ 1094 __FUNCTION__); \ 1095 &_rtx->u.fld[_n]; })) 1096 1097 #define RTL_CHECKC1(RTX, N, C) __extension__ \ 1098 (*({ __typeof (RTX) const _rtx = (RTX); const int _n = (N); \ 1099 if (GET_CODE (_rtx) != (C)) \ 1100 rtl_check_failed_code1 (_rtx, (C), __FILE__, __LINE__, \ 1101 __FUNCTION__); \ 1102 &_rtx->u.fld[_n]; })) 1103 1104 #define RTL_CHECKC2(RTX, N, C1, C2) __extension__ \ 1105 (*({ __typeof (RTX) const _rtx = (RTX); const int _n = (N); \ 1106 const enum rtx_code _code = GET_CODE (_rtx); \ 1107 if (_code != (C1) && _code != (C2)) \ 1108 rtl_check_failed_code2 (_rtx, (C1), (C2), __FILE__, __LINE__, \ 1109 __FUNCTION__); \ 1110 &_rtx->u.fld[_n]; })) 1111 1112 #define RTL_CHECKC3(RTX, N, C1, C2, C3) __extension__ \ 1113 (*({ __typeof (RTX) const _rtx = (RTX); const int _n = (N); \ 1114 const enum rtx_code _code = GET_CODE (_rtx); \ 1115 if (_code != (C1) && _code != (C2) && _code != (C3)) \ 1116 rtl_check_failed_code3 (_rtx, (C1), (C2), (C3), __FILE__, \ 1117 __LINE__, __FUNCTION__); \ 1118 &_rtx->u.fld[_n]; })) 1119 1120 #define RTVEC_ELT(RTVEC, I) __extension__ \ 1121 (*({ __typeof (RTVEC) const _rtvec = (RTVEC); const int _i = (I); \ 1122 if (_i < 0 || _i >= GET_NUM_ELEM (_rtvec)) \ 1123 rtvec_check_failed_bounds (_rtvec, _i, __FILE__, __LINE__, \ 1124 __FUNCTION__); \ 1125 &_rtvec->elem[_i]; })) 1126 1127 #define XWINT(RTX, N) __extension__ \ 1128 (*({ __typeof (RTX) const _rtx = (RTX); const int _n = (N); \ 1129 const enum rtx_code _code = GET_CODE (_rtx); \ 1130 if (_n < 0 || _n >= GET_RTX_LENGTH (_code)) \ 1131 rtl_check_failed_bounds (_rtx, _n, __FILE__, __LINE__, \ 1132 __FUNCTION__); \ 1133 if (GET_RTX_FORMAT (_code)[_n] != 'w') \ 1134 rtl_check_failed_type1 (_rtx, _n, 'w', __FILE__, __LINE__, \ 1135 __FUNCTION__); \ 1136 &_rtx->u.hwint[_n]; })) 1137 1138 #define CWI_ELT(RTX, I) __extension__ \ 1139 (*({ __typeof (RTX) const _cwi = (RTX); \ 1140 int _max = CWI_GET_NUM_ELEM (_cwi); \ 1141 const int _i = (I); \ 1142 if (_i < 0 || _i >= _max) \ 1143 cwi_check_failed_bounds (_cwi, _i, __FILE__, __LINE__, \ 1144 __FUNCTION__); \ 1145 &_cwi->u.hwiv.elem[_i]; })) 1146 1147 #define XCWINT(RTX, N, C) __extension__ \ 1148 (*({ __typeof (RTX) const _rtx = (RTX); \ 1149 if (GET_CODE (_rtx) != (C)) \ 1150 rtl_check_failed_code1 (_rtx, (C), __FILE__, __LINE__, \ 1151 __FUNCTION__); \ 1152 &_rtx->u.hwint[N]; })) 1153 1154 #define XCMWINT(RTX, N, C, M) __extension__ \ 1155 (*({ __typeof (RTX) const _rtx = (RTX); \ 1156 if (GET_CODE (_rtx) != (C) || GET_MODE (_rtx) != (M)) \ 1157 rtl_check_failed_code_mode (_rtx, (C), (M), false, __FILE__, \ 1158 __LINE__, __FUNCTION__); \ 1159 &_rtx->u.hwint[N]; })) 1160 1161 #define XCNMPRV(RTX, C, M) __extension__ \ 1162 ({ __typeof (RTX) const _rtx = (RTX); \ 1163 if (GET_CODE (_rtx) != (C) || GET_MODE (_rtx) == (M)) \ 1164 rtl_check_failed_code_mode (_rtx, (C), (M), true, __FILE__, \ 1165 __LINE__, __FUNCTION__); \ 1166 &_rtx->u.rv; }) 1167 1168 #define XCNMPFV(RTX, C, M) __extension__ \ 1169 ({ __typeof (RTX) const _rtx = (RTX); \ 1170 if (GET_CODE (_rtx) != (C) || GET_MODE (_rtx) == (M)) \ 1171 rtl_check_failed_code_mode (_rtx, (C), (M), true, __FILE__, \ 1172 __LINE__, __FUNCTION__); \ 1173 &_rtx->u.fv; }) 1174 1175 #define REG_CHECK(RTX) __extension__ \ 1176 ({ __typeof (RTX) const _rtx = (RTX); \ 1177 if (GET_CODE (_rtx) != REG) \ 1178 rtl_check_failed_code1 (_rtx, REG, __FILE__, __LINE__, \ 1179 __FUNCTION__); \ 1180 &_rtx->u.reg; }) 1181 1182 #define BLOCK_SYMBOL_CHECK(RTX) __extension__ \ 1183 ({ __typeof (RTX) const _symbol = (RTX); \ 1184 const unsigned int flags = SYMBOL_REF_FLAGS (_symbol); \ 1185 if ((flags & SYMBOL_FLAG_HAS_BLOCK_INFO) == 0) \ 1186 rtl_check_failed_block_symbol (__FILE__, __LINE__, \ 1187 __FUNCTION__); \ 1188 &_symbol->u.block_sym; }) 1189 1190 #define HWIVEC_CHECK(RTX,C) __extension__ \ 1191 ({ __typeof (RTX) const _symbol = (RTX); \ 1192 RTL_CHECKC1 (_symbol, 0, C); \ 1193 &_symbol->u.hwiv; }) 1194 1195 extern void rtl_check_failed_bounds (const_rtx, int, const char *, int, 1196 const char *) 1197 ATTRIBUTE_NORETURN ATTRIBUTE_COLD; 1198 extern void rtl_check_failed_type1 (const_rtx, int, int, const char *, int, 1199 const char *) 1200 ATTRIBUTE_NORETURN ATTRIBUTE_COLD; 1201 extern void rtl_check_failed_type2 (const_rtx, int, int, int, const char *, 1202 int, const char *) 1203 ATTRIBUTE_NORETURN ATTRIBUTE_COLD; 1204 extern void rtl_check_failed_code1 (const_rtx, enum rtx_code, const char *, 1205 int, const char *) 1206 ATTRIBUTE_NORETURN ATTRIBUTE_COLD; 1207 extern void rtl_check_failed_code2 (const_rtx, enum rtx_code, enum rtx_code, 1208 const char *, int, const char *) 1209 ATTRIBUTE_NORETURN ATTRIBUTE_COLD; 1210 extern void rtl_check_failed_code3 (const_rtx, enum rtx_code, enum rtx_code, 1211 enum rtx_code, const char *, int, 1212 const char *) 1213 ATTRIBUTE_NORETURN ATTRIBUTE_COLD; 1214 extern void rtl_check_failed_code_mode (const_rtx, enum rtx_code, machine_mode, 1215 bool, const char *, int, const char *) 1216 ATTRIBUTE_NORETURN ATTRIBUTE_COLD; 1217 extern void rtl_check_failed_block_symbol (const char *, int, const char *) 1218 ATTRIBUTE_NORETURN ATTRIBUTE_COLD; 1219 extern void cwi_check_failed_bounds (const_rtx, int, const char *, int, 1220 const char *) 1221 ATTRIBUTE_NORETURN ATTRIBUTE_COLD; 1222 extern void rtvec_check_failed_bounds (const_rtvec, int, const char *, int, 1223 const char *) 1224 ATTRIBUTE_NORETURN ATTRIBUTE_COLD; 1225 1226 #else /* not ENABLE_RTL_CHECKING */ 1227 1228 #define RTL_CHECK1(RTX, N, C1) ((RTX)->u.fld[N]) 1229 #define RTL_CHECK2(RTX, N, C1, C2) ((RTX)->u.fld[N]) 1230 #define RTL_CHECKC1(RTX, N, C) ((RTX)->u.fld[N]) 1231 #define RTL_CHECKC2(RTX, N, C1, C2) ((RTX)->u.fld[N]) 1232 #define RTL_CHECKC3(RTX, N, C1, C2, C3) ((RTX)->u.fld[N]) 1233 #define RTVEC_ELT(RTVEC, I) ((RTVEC)->elem[I]) 1234 #define XWINT(RTX, N) ((RTX)->u.hwint[N]) 1235 #define CWI_ELT(RTX, I) ((RTX)->u.hwiv.elem[I]) 1236 #define XCWINT(RTX, N, C) ((RTX)->u.hwint[N]) 1237 #define XCMWINT(RTX, N, C, M) ((RTX)->u.hwint[N]) 1238 #define XCNMWINT(RTX, N, C, M) ((RTX)->u.hwint[N]) 1239 #define XCNMPRV(RTX, C, M) (&(RTX)->u.rv) 1240 #define XCNMPFV(RTX, C, M) (&(RTX)->u.fv) 1241 #define REG_CHECK(RTX) (&(RTX)->u.reg) 1242 #define BLOCK_SYMBOL_CHECK(RTX) (&(RTX)->u.block_sym) 1243 #define HWIVEC_CHECK(RTX,C) (&(RTX)->u.hwiv) 1244 1245 #endif 1246 1247 /* General accessor macros for accessing the flags of an rtx. */ 1248 1249 /* Access an individual rtx flag, with no checking of any kind. */ 1250 #define RTX_FLAG(RTX, FLAG) ((RTX)->FLAG) 1251 1252 #if defined ENABLE_RTL_FLAG_CHECKING && (GCC_VERSION >= 2007) 1253 #define RTL_FLAG_CHECK1(NAME, RTX, C1) __extension__ \ 1254 ({ __typeof (RTX) const _rtx = (RTX); \ 1255 if (GET_CODE (_rtx) != C1) \ 1256 rtl_check_failed_flag (NAME, _rtx, __FILE__, __LINE__, \ 1257 __FUNCTION__); \ 1258 _rtx; }) 1259 1260 #define RTL_FLAG_CHECK2(NAME, RTX, C1, C2) __extension__ \ 1261 ({ __typeof (RTX) const _rtx = (RTX); \ 1262 if (GET_CODE (_rtx) != C1 && GET_CODE(_rtx) != C2) \ 1263 rtl_check_failed_flag (NAME,_rtx, __FILE__, __LINE__, \ 1264 __FUNCTION__); \ 1265 _rtx; }) 1266 1267 #define RTL_FLAG_CHECK3(NAME, RTX, C1, C2, C3) __extension__ \ 1268 ({ __typeof (RTX) const _rtx = (RTX); \ 1269 if (GET_CODE (_rtx) != C1 && GET_CODE(_rtx) != C2 \ 1270 && GET_CODE (_rtx) != C3) \ 1271 rtl_check_failed_flag (NAME, _rtx, __FILE__, __LINE__, \ 1272 __FUNCTION__); \ 1273 _rtx; }) 1274 1275 #define RTL_FLAG_CHECK4(NAME, RTX, C1, C2, C3, C4) __extension__ \ 1276 ({ __typeof (RTX) const _rtx = (RTX); \ 1277 if (GET_CODE (_rtx) != C1 && GET_CODE(_rtx) != C2 \ 1278 && GET_CODE (_rtx) != C3 && GET_CODE(_rtx) != C4) \ 1279 rtl_check_failed_flag (NAME, _rtx, __FILE__, __LINE__, \ 1280 __FUNCTION__); \ 1281 _rtx; }) 1282 1283 #define RTL_FLAG_CHECK5(NAME, RTX, C1, C2, C3, C4, C5) __extension__ \ 1284 ({ __typeof (RTX) const _rtx = (RTX); \ 1285 if (GET_CODE (_rtx) != C1 && GET_CODE (_rtx) != C2 \ 1286 && GET_CODE (_rtx) != C3 && GET_CODE (_rtx) != C4 \ 1287 && GET_CODE (_rtx) != C5) \ 1288 rtl_check_failed_flag (NAME, _rtx, __FILE__, __LINE__, \ 1289 __FUNCTION__); \ 1290 _rtx; }) 1291 1292 #define RTL_FLAG_CHECK6(NAME, RTX, C1, C2, C3, C4, C5, C6) \ 1293 __extension__ \ 1294 ({ __typeof (RTX) const _rtx = (RTX); \ 1295 if (GET_CODE (_rtx) != C1 && GET_CODE (_rtx) != C2 \ 1296 && GET_CODE (_rtx) != C3 && GET_CODE (_rtx) != C4 \ 1297 && GET_CODE (_rtx) != C5 && GET_CODE (_rtx) != C6) \ 1298 rtl_check_failed_flag (NAME,_rtx, __FILE__, __LINE__, \ 1299 __FUNCTION__); \ 1300 _rtx; }) 1301 1302 #define RTL_FLAG_CHECK7(NAME, RTX, C1, C2, C3, C4, C5, C6, C7) \ 1303 __extension__ \ 1304 ({ __typeof (RTX) const _rtx = (RTX); \ 1305 if (GET_CODE (_rtx) != C1 && GET_CODE (_rtx) != C2 \ 1306 && GET_CODE (_rtx) != C3 && GET_CODE (_rtx) != C4 \ 1307 && GET_CODE (_rtx) != C5 && GET_CODE (_rtx) != C6 \ 1308 && GET_CODE (_rtx) != C7) \ 1309 rtl_check_failed_flag (NAME, _rtx, __FILE__, __LINE__, \ 1310 __FUNCTION__); \ 1311 _rtx; }) 1312 1313 #define RTL_INSN_CHAIN_FLAG_CHECK(NAME, RTX) \ 1314 __extension__ \ 1315 ({ __typeof (RTX) const _rtx = (RTX); \ 1316 if (!INSN_CHAIN_CODE_P (GET_CODE (_rtx))) \ 1317 rtl_check_failed_flag (NAME, _rtx, __FILE__, __LINE__, \ 1318 __FUNCTION__); \ 1319 _rtx; }) 1320 1321 extern void rtl_check_failed_flag (const char *, const_rtx, const char *, 1322 int, const char *) 1323 ATTRIBUTE_NORETURN ATTRIBUTE_COLD 1324 ; 1325 1326 #else /* not ENABLE_RTL_FLAG_CHECKING */ 1327 1328 #define RTL_FLAG_CHECK1(NAME, RTX, C1) (RTX) 1329 #define RTL_FLAG_CHECK2(NAME, RTX, C1, C2) (RTX) 1330 #define RTL_FLAG_CHECK3(NAME, RTX, C1, C2, C3) (RTX) 1331 #define RTL_FLAG_CHECK4(NAME, RTX, C1, C2, C3, C4) (RTX) 1332 #define RTL_FLAG_CHECK5(NAME, RTX, C1, C2, C3, C4, C5) (RTX) 1333 #define RTL_FLAG_CHECK6(NAME, RTX, C1, C2, C3, C4, C5, C6) (RTX) 1334 #define RTL_FLAG_CHECK7(NAME, RTX, C1, C2, C3, C4, C5, C6, C7) (RTX) 1335 #define RTL_INSN_CHAIN_FLAG_CHECK(NAME, RTX) (RTX) 1336 #endif 1337 1338 #define XINT(RTX, N) (RTL_CHECK2 (RTX, N, 'i', 'n').rt_int) 1339 #define XUINT(RTX, N) (RTL_CHECK2 (RTX, N, 'i', 'n').rt_uint) 1340 #define XSTR(RTX, N) (RTL_CHECK2 (RTX, N, 's', 'S').rt_str) 1341 #define XEXP(RTX, N) (RTL_CHECK2 (RTX, N, 'e', 'u').rt_rtx) 1342 #define XVEC(RTX, N) (RTL_CHECK2 (RTX, N, 'E', 'V').rt_rtvec) 1343 #define XMODE(RTX, N) (RTL_CHECK1 (RTX, N, 'M').rt_type) 1344 #define XTREE(RTX, N) (RTL_CHECK1 (RTX, N, 't').rt_tree) 1345 #define XBBDEF(RTX, N) (RTL_CHECK1 (RTX, N, 'B').rt_bb) 1346 #define XTMPL(RTX, N) (RTL_CHECK1 (RTX, N, 'T').rt_str) 1347 #define XCFI(RTX, N) (RTL_CHECK1 (RTX, N, 'C').rt_cfi) 1348 1349 #define XVECEXP(RTX, N, M) RTVEC_ELT (XVEC (RTX, N), M) 1350 #define XVECLEN(RTX, N) GET_NUM_ELEM (XVEC (RTX, N)) 1351 1352 /* These are like XINT, etc. except that they expect a '0' field instead 1353 of the normal type code. */ 1354 1355 #define X0INT(RTX, N) (RTL_CHECK1 (RTX, N, '0').rt_int) 1356 #define X0UINT(RTX, N) (RTL_CHECK1 (RTX, N, '0').rt_uint) 1357 #define X0STR(RTX, N) (RTL_CHECK1 (RTX, N, '0').rt_str) 1358 #define X0EXP(RTX, N) (RTL_CHECK1 (RTX, N, '0').rt_rtx) 1359 #define X0VEC(RTX, N) (RTL_CHECK1 (RTX, N, '0').rt_rtvec) 1360 #define X0MODE(RTX, N) (RTL_CHECK1 (RTX, N, '0').rt_type) 1361 #define X0TREE(RTX, N) (RTL_CHECK1 (RTX, N, '0').rt_tree) 1362 #define X0BBDEF(RTX, N) (RTL_CHECK1 (RTX, N, '0').rt_bb) 1363 #define X0ADVFLAGS(RTX, N) (RTL_CHECK1 (RTX, N, '0').rt_addr_diff_vec_flags) 1364 #define X0CSELIB(RTX, N) (RTL_CHECK1 (RTX, N, '0').rt_cselib) 1365 #define X0MEMATTR(RTX, N) (RTL_CHECKC1 (RTX, N, MEM).rt_mem) 1366 #define X0CONSTANT(RTX, N) (RTL_CHECK1 (RTX, N, '0').rt_constant) 1367 1368 /* Access a '0' field with any type. */ 1369 #define X0ANY(RTX, N) RTL_CHECK1 (RTX, N, '0') 1370 1371 #define XCINT(RTX, N, C) (RTL_CHECKC1 (RTX, N, C).rt_int) 1372 #define XCUINT(RTX, N, C) (RTL_CHECKC1 (RTX, N, C).rt_uint) 1373 #define XCSUBREG(RTX, N, C) (RTL_CHECKC1 (RTX, N, C).rt_subreg) 1374 #define XCSTR(RTX, N, C) (RTL_CHECKC1 (RTX, N, C).rt_str) 1375 #define XCEXP(RTX, N, C) (RTL_CHECKC1 (RTX, N, C).rt_rtx) 1376 #define XCVEC(RTX, N, C) (RTL_CHECKC1 (RTX, N, C).rt_rtvec) 1377 #define XCMODE(RTX, N, C) (RTL_CHECKC1 (RTX, N, C).rt_type) 1378 #define XCTREE(RTX, N, C) (RTL_CHECKC1 (RTX, N, C).rt_tree) 1379 #define XCBBDEF(RTX, N, C) (RTL_CHECKC1 (RTX, N, C).rt_bb) 1380 #define XCCFI(RTX, N, C) (RTL_CHECKC1 (RTX, N, C).rt_cfi) 1381 #define XCCSELIB(RTX, N, C) (RTL_CHECKC1 (RTX, N, C).rt_cselib) 1382 1383 #define XCVECEXP(RTX, N, M, C) RTVEC_ELT (XCVEC (RTX, N, C), M) 1384 #define XCVECLEN(RTX, N, C) GET_NUM_ELEM (XCVEC (RTX, N, C)) 1385 1386 #define XC2EXP(RTX, N, C1, C2) (RTL_CHECKC2 (RTX, N, C1, C2).rt_rtx) 1387 #define XC3EXP(RTX, N, C1, C2, C3) (RTL_CHECKC3 (RTX, N, C1, C2, C3).rt_rtx) 1388 1389 1390 /* Methods of rtx_expr_list. */ 1391 1392 inline rtx_expr_list *rtx_expr_list::next () const 1393 { 1394 rtx tmp = XEXP (this, 1); 1395 return safe_as_a <rtx_expr_list *> (tmp); 1396 } 1397 1398 inline rtx rtx_expr_list::element () const 1399 { 1400 return XEXP (this, 0); 1401 } 1402 1403 /* Methods of rtx_insn_list. */ 1404 1405 inline rtx_insn_list *rtx_insn_list::next () const 1406 { 1407 rtx tmp = XEXP (this, 1); 1408 return safe_as_a <rtx_insn_list *> (tmp); 1409 } 1410 1411 inline rtx_insn *rtx_insn_list::insn () const 1412 { 1413 rtx tmp = XEXP (this, 0); 1414 return safe_as_a <rtx_insn *> (tmp); 1415 } 1416 1417 /* Methods of rtx_sequence. */ 1418 1419 inline int rtx_sequence::len () const 1420 { 1421 return XVECLEN (this, 0); 1422 } 1423 1424 inline rtx rtx_sequence::element (int index) const 1425 { 1426 return XVECEXP (this, 0, index); 1427 } 1428 1429 inline rtx_insn *rtx_sequence::insn (int index) const 1430 { 1431 return as_a <rtx_insn *> (XVECEXP (this, 0, index)); 1432 } 1433 1434 /* ACCESS MACROS for particular fields of insns. */ 1435 1436 /* Holds a unique number for each insn. 1437 These are not necessarily sequentially increasing. */ 1438 inline int INSN_UID (const_rtx insn) 1439 { 1440 return RTL_INSN_CHAIN_FLAG_CHECK ("INSN_UID", 1441 (insn))->u2.insn_uid; 1442 } 1443 inline int& INSN_UID (rtx insn) 1444 { 1445 return RTL_INSN_CHAIN_FLAG_CHECK ("INSN_UID", 1446 (insn))->u2.insn_uid; 1447 } 1448 1449 /* Chain insns together in sequence. */ 1450 1451 /* For now these are split in two: an rvalue form: 1452 PREV_INSN/NEXT_INSN 1453 and an lvalue form: 1454 SET_NEXT_INSN/SET_PREV_INSN. */ 1455 1456 inline rtx_insn *PREV_INSN (const rtx_insn *insn) 1457 { 1458 rtx prev = XEXP (insn, 0); 1459 return safe_as_a <rtx_insn *> (prev); 1460 } 1461 1462 inline rtx& SET_PREV_INSN (rtx_insn *insn) 1463 { 1464 return XEXP (insn, 0); 1465 } 1466 1467 inline rtx_insn *NEXT_INSN (const rtx_insn *insn) 1468 { 1469 rtx next = XEXP (insn, 1); 1470 return safe_as_a <rtx_insn *> (next); 1471 } 1472 1473 inline rtx& SET_NEXT_INSN (rtx_insn *insn) 1474 { 1475 return XEXP (insn, 1); 1476 } 1477 1478 inline basic_block BLOCK_FOR_INSN (const_rtx insn) 1479 { 1480 return XBBDEF (insn, 2); 1481 } 1482 1483 inline basic_block& BLOCK_FOR_INSN (rtx insn) 1484 { 1485 return XBBDEF (insn, 2); 1486 } 1487 1488 inline void set_block_for_insn (rtx_insn *insn, basic_block bb) 1489 { 1490 BLOCK_FOR_INSN (insn) = bb; 1491 } 1492 1493 /* The body of an insn. */ 1494 inline rtx PATTERN (const_rtx insn) 1495 { 1496 return XEXP (insn, 3); 1497 } 1498 1499 inline rtx& PATTERN (rtx insn) 1500 { 1501 return XEXP (insn, 3); 1502 } 1503 1504 inline unsigned int INSN_LOCATION (const rtx_insn *insn) 1505 { 1506 return XUINT (insn, 4); 1507 } 1508 1509 inline unsigned int& INSN_LOCATION (rtx_insn *insn) 1510 { 1511 return XUINT (insn, 4); 1512 } 1513 1514 inline bool INSN_HAS_LOCATION (const rtx_insn *insn) 1515 { 1516 return LOCATION_LOCUS (INSN_LOCATION (insn)) != UNKNOWN_LOCATION; 1517 } 1518 1519 /* LOCATION of an RTX if relevant. */ 1520 #define RTL_LOCATION(X) (INSN_P (X) ? \ 1521 INSN_LOCATION (as_a <rtx_insn *> (X)) \ 1522 : UNKNOWN_LOCATION) 1523 1524 /* Code number of instruction, from when it was recognized. 1525 -1 means this instruction has not been recognized yet. */ 1526 #define INSN_CODE(INSN) XINT (INSN, 5) 1527 1528 inline rtvec rtx_jump_table_data::get_labels () const 1529 { 1530 rtx pat = PATTERN (this); 1531 if (GET_CODE (pat) == ADDR_VEC) 1532 return XVEC (pat, 0); 1533 else 1534 return XVEC (pat, 1); /* presumably an ADDR_DIFF_VEC */ 1535 } 1536 1537 /* Return the mode of the data in the table, which is always a scalar 1538 integer. */ 1539 1540 inline scalar_int_mode 1541 rtx_jump_table_data::get_data_mode () const 1542 { 1543 return as_a <scalar_int_mode> (GET_MODE (PATTERN (this))); 1544 } 1545 1546 /* If LABEL is followed by a jump table, return the table, otherwise 1547 return null. */ 1548 1549 inline rtx_jump_table_data * 1550 jump_table_for_label (const rtx_code_label *label) 1551 { 1552 return safe_dyn_cast <rtx_jump_table_data *> (NEXT_INSN (label)); 1553 } 1554 1555 #define RTX_FRAME_RELATED_P(RTX) \ 1556 (RTL_FLAG_CHECK6 ("RTX_FRAME_RELATED_P", (RTX), DEBUG_INSN, INSN, \ 1557 CALL_INSN, JUMP_INSN, BARRIER, SET)->frame_related) 1558 1559 /* 1 if JUMP RTX is a crossing jump. */ 1560 #define CROSSING_JUMP_P(RTX) \ 1561 (RTL_FLAG_CHECK1 ("CROSSING_JUMP_P", (RTX), JUMP_INSN)->jump) 1562 1563 /* 1 if RTX is a call to a const function. Built from ECF_CONST and 1564 TREE_READONLY. */ 1565 #define RTL_CONST_CALL_P(RTX) \ 1566 (RTL_FLAG_CHECK1 ("RTL_CONST_CALL_P", (RTX), CALL_INSN)->unchanging) 1567 1568 /* 1 if RTX is a call to a pure function. Built from ECF_PURE and 1569 DECL_PURE_P. */ 1570 #define RTL_PURE_CALL_P(RTX) \ 1571 (RTL_FLAG_CHECK1 ("RTL_PURE_CALL_P", (RTX), CALL_INSN)->return_val) 1572 1573 /* 1 if RTX is a call to a const or pure function. */ 1574 #define RTL_CONST_OR_PURE_CALL_P(RTX) \ 1575 (RTL_CONST_CALL_P (RTX) || RTL_PURE_CALL_P (RTX)) 1576 1577 /* 1 if RTX is a call to a looping const or pure function. Built from 1578 ECF_LOOPING_CONST_OR_PURE and DECL_LOOPING_CONST_OR_PURE_P. */ 1579 #define RTL_LOOPING_CONST_OR_PURE_CALL_P(RTX) \ 1580 (RTL_FLAG_CHECK1 ("CONST_OR_PURE_CALL_P", (RTX), CALL_INSN)->call) 1581 1582 /* 1 if RTX is a call_insn for a sibling call. */ 1583 #define SIBLING_CALL_P(RTX) \ 1584 (RTL_FLAG_CHECK1 ("SIBLING_CALL_P", (RTX), CALL_INSN)->jump) 1585 1586 /* 1 if RTX is a jump_insn, call_insn, or insn that is an annulling branch. */ 1587 #define INSN_ANNULLED_BRANCH_P(RTX) \ 1588 (RTL_FLAG_CHECK1 ("INSN_ANNULLED_BRANCH_P", (RTX), JUMP_INSN)->unchanging) 1589 1590 /* 1 if RTX is an insn in a delay slot and is from the target of the branch. 1591 If the branch insn has INSN_ANNULLED_BRANCH_P set, this insn should only be 1592 executed if the branch is taken. For annulled branches with this bit 1593 clear, the insn should be executed only if the branch is not taken. */ 1594 #define INSN_FROM_TARGET_P(RTX) \ 1595 (RTL_FLAG_CHECK3 ("INSN_FROM_TARGET_P", (RTX), INSN, JUMP_INSN, \ 1596 CALL_INSN)->in_struct) 1597 1598 /* In an ADDR_DIFF_VEC, the flags for RTX for use by branch shortening. 1599 See the comments for ADDR_DIFF_VEC in rtl.def. */ 1600 #define ADDR_DIFF_VEC_FLAGS(RTX) X0ADVFLAGS (RTX, 4) 1601 1602 /* In a VALUE, the value cselib has assigned to RTX. 1603 This is a "struct cselib_val", see cselib.h. */ 1604 #define CSELIB_VAL_PTR(RTX) X0CSELIB (RTX, 0) 1605 1606 /* Holds a list of notes on what this insn does to various REGs. 1607 It is a chain of EXPR_LIST rtx's, where the second operand is the 1608 chain pointer and the first operand is the REG being described. 1609 The mode field of the EXPR_LIST contains not a real machine mode 1610 but a value from enum reg_note. */ 1611 #define REG_NOTES(INSN) XEXP(INSN, 6) 1612 1613 /* In an ENTRY_VALUE this is the DECL_INCOMING_RTL of the argument in 1614 question. */ 1615 #define ENTRY_VALUE_EXP(RTX) (RTL_CHECKC1 (RTX, 0, ENTRY_VALUE).rt_rtx) 1616 1617 enum reg_note 1618 { 1619 #define DEF_REG_NOTE(NAME) NAME, 1620 #include "reg-notes.def" 1621 #undef DEF_REG_NOTE 1622 REG_NOTE_MAX 1623 }; 1624 1625 /* Define macros to extract and insert the reg-note kind in an EXPR_LIST. */ 1626 #define REG_NOTE_KIND(LINK) ((enum reg_note) GET_MODE (LINK)) 1627 #define PUT_REG_NOTE_KIND(LINK, KIND) \ 1628 PUT_MODE_RAW (LINK, (machine_mode) (KIND)) 1629 1630 /* Names for REG_NOTE's in EXPR_LIST insn's. */ 1631 1632 extern const char * const reg_note_name[]; 1633 #define GET_REG_NOTE_NAME(MODE) (reg_note_name[(int) (MODE)]) 1634 1635 /* This field is only present on CALL_INSNs. It holds a chain of EXPR_LIST of 1636 USE, CLOBBER and SET expressions. 1637 USE expressions list the registers filled with arguments that 1638 are passed to the function. 1639 CLOBBER expressions document the registers explicitly clobbered 1640 by this CALL_INSN. 1641 SET expressions say that the return value of the call (the SET_DEST) 1642 is equivalent to a value available before the call (the SET_SRC). 1643 This kind of SET is used when the return value is predictable in 1644 advance. It is purely an optimisation hint; unlike USEs and CLOBBERs, 1645 it does not affect register liveness. 1646 1647 Pseudo registers cannot be mentioned in this list. */ 1648 #define CALL_INSN_FUNCTION_USAGE(INSN) XEXP(INSN, 7) 1649 1650 /* The label-number of a code-label. The assembler label 1651 is made from `L' and the label-number printed in decimal. 1652 Label numbers are unique in a compilation. */ 1653 #define CODE_LABEL_NUMBER(INSN) XINT (INSN, 5) 1654 1655 /* In a NOTE that is a line number, this is a string for the file name that the 1656 line is in. We use the same field to record block numbers temporarily in 1657 NOTE_INSN_BLOCK_BEG and NOTE_INSN_BLOCK_END notes. (We avoid lots of casts 1658 between ints and pointers if we use a different macro for the block number.) 1659 */ 1660 1661 /* Opaque data. */ 1662 #define NOTE_DATA(INSN) RTL_CHECKC1 (INSN, 3, NOTE) 1663 #define NOTE_DELETED_LABEL_NAME(INSN) XCSTR (INSN, 3, NOTE) 1664 #define SET_INSN_DELETED(INSN) set_insn_deleted (INSN); 1665 #define NOTE_BLOCK(INSN) XCTREE (INSN, 3, NOTE) 1666 #define NOTE_EH_HANDLER(INSN) XCINT (INSN, 3, NOTE) 1667 #define NOTE_BASIC_BLOCK(INSN) XCBBDEF (INSN, 3, NOTE) 1668 #define NOTE_VAR_LOCATION(INSN) XCEXP (INSN, 3, NOTE) 1669 #define NOTE_MARKER_LOCATION(INSN) XCUINT (INSN, 3, NOTE) 1670 #define NOTE_CFI(INSN) XCCFI (INSN, 3, NOTE) 1671 #define NOTE_LABEL_NUMBER(INSN) XCINT (INSN, 3, NOTE) 1672 1673 /* In a NOTE that is a line number, this is the line number. 1674 Other kinds of NOTEs are identified by negative numbers here. */ 1675 #define NOTE_KIND(INSN) XCINT (INSN, 4, NOTE) 1676 1677 /* Nonzero if INSN is a note marking the beginning of a basic block. */ 1678 #define NOTE_INSN_BASIC_BLOCK_P(INSN) \ 1679 (NOTE_P (INSN) && NOTE_KIND (INSN) == NOTE_INSN_BASIC_BLOCK) 1680 1681 /* Nonzero if INSN is a debug nonbind marker note, 1682 for which NOTE_MARKER_LOCATION can be used. */ 1683 #define NOTE_MARKER_P(INSN) \ 1684 (NOTE_P (INSN) && \ 1685 (NOTE_KIND (INSN) == NOTE_INSN_BEGIN_STMT \ 1686 || NOTE_KIND (INSN) == NOTE_INSN_INLINE_ENTRY)) 1687 1688 /* Variable declaration and the location of a variable. */ 1689 #define PAT_VAR_LOCATION_DECL(PAT) (XCTREE ((PAT), 0, VAR_LOCATION)) 1690 #define PAT_VAR_LOCATION_LOC(PAT) (XCEXP ((PAT), 1, VAR_LOCATION)) 1691 1692 /* Initialization status of the variable in the location. Status 1693 can be unknown, uninitialized or initialized. See enumeration 1694 type below. */ 1695 #define PAT_VAR_LOCATION_STATUS(PAT) \ 1696 (RTL_FLAG_CHECK1 ("PAT_VAR_LOCATION_STATUS", PAT, VAR_LOCATION) \ 1697 ->u2.var_location_status) 1698 1699 /* Accessors for a NOTE_INSN_VAR_LOCATION. */ 1700 #define NOTE_VAR_LOCATION_DECL(NOTE) \ 1701 PAT_VAR_LOCATION_DECL (NOTE_VAR_LOCATION (NOTE)) 1702 #define NOTE_VAR_LOCATION_LOC(NOTE) \ 1703 PAT_VAR_LOCATION_LOC (NOTE_VAR_LOCATION (NOTE)) 1704 #define NOTE_VAR_LOCATION_STATUS(NOTE) \ 1705 PAT_VAR_LOCATION_STATUS (NOTE_VAR_LOCATION (NOTE)) 1706 1707 /* Evaluate to TRUE if INSN is a debug insn that denotes a variable 1708 location/value tracking annotation. */ 1709 #define DEBUG_BIND_INSN_P(INSN) \ 1710 (DEBUG_INSN_P (INSN) \ 1711 && (GET_CODE (PATTERN (INSN)) \ 1712 == VAR_LOCATION)) 1713 /* Evaluate to TRUE if INSN is a debug insn that denotes a program 1714 source location marker. */ 1715 #define DEBUG_MARKER_INSN_P(INSN) \ 1716 (DEBUG_INSN_P (INSN) \ 1717 && (GET_CODE (PATTERN (INSN)) \ 1718 != VAR_LOCATION)) 1719 /* Evaluate to the marker kind. */ 1720 #define INSN_DEBUG_MARKER_KIND(INSN) \ 1721 (GET_CODE (PATTERN (INSN)) == DEBUG_MARKER \ 1722 ? (GET_MODE (PATTERN (INSN)) == VOIDmode \ 1723 ? NOTE_INSN_BEGIN_STMT \ 1724 : GET_MODE (PATTERN (INSN)) == BLKmode \ 1725 ? NOTE_INSN_INLINE_ENTRY \ 1726 : (enum insn_note)-1) \ 1727 : (enum insn_note)-1) 1728 /* Create patterns for debug markers. These and the above abstract 1729 the representation, so that it's easier to get rid of the abuse of 1730 the mode to hold the marker kind. Other marker types are 1731 envisioned, so a single bit flag won't do; maybe separate RTL codes 1732 wouldn't be a problem. */ 1733 #define GEN_RTX_DEBUG_MARKER_BEGIN_STMT_PAT() \ 1734 gen_rtx_DEBUG_MARKER (VOIDmode) 1735 #define GEN_RTX_DEBUG_MARKER_INLINE_ENTRY_PAT() \ 1736 gen_rtx_DEBUG_MARKER (BLKmode) 1737 1738 /* The VAR_LOCATION rtx in a DEBUG_INSN. */ 1739 #define INSN_VAR_LOCATION(INSN) \ 1740 (RTL_FLAG_CHECK1 ("INSN_VAR_LOCATION", PATTERN (INSN), VAR_LOCATION)) 1741 /* A pointer to the VAR_LOCATION rtx in a DEBUG_INSN. */ 1742 #define INSN_VAR_LOCATION_PTR(INSN) \ 1743 (&PATTERN (INSN)) 1744 1745 /* Accessors for a tree-expanded var location debug insn. */ 1746 #define INSN_VAR_LOCATION_DECL(INSN) \ 1747 PAT_VAR_LOCATION_DECL (INSN_VAR_LOCATION (INSN)) 1748 #define INSN_VAR_LOCATION_LOC(INSN) \ 1749 PAT_VAR_LOCATION_LOC (INSN_VAR_LOCATION (INSN)) 1750 #define INSN_VAR_LOCATION_STATUS(INSN) \ 1751 PAT_VAR_LOCATION_STATUS (INSN_VAR_LOCATION (INSN)) 1752 1753 /* Expand to the RTL that denotes an unknown variable location in a 1754 DEBUG_INSN. */ 1755 #define gen_rtx_UNKNOWN_VAR_LOC() (gen_rtx_CLOBBER (VOIDmode, const0_rtx)) 1756 1757 /* Determine whether X is such an unknown location. */ 1758 #define VAR_LOC_UNKNOWN_P(X) \ 1759 (GET_CODE (X) == CLOBBER && XEXP ((X), 0) == const0_rtx) 1760 1761 /* 1 if RTX is emitted after a call, but it should take effect before 1762 the call returns. */ 1763 #define NOTE_DURING_CALL_P(RTX) \ 1764 (RTL_FLAG_CHECK1 ("NOTE_VAR_LOCATION_DURING_CALL_P", (RTX), NOTE)->call) 1765 1766 /* DEBUG_EXPR_DECL corresponding to a DEBUG_EXPR RTX. */ 1767 #define DEBUG_EXPR_TREE_DECL(RTX) XCTREE (RTX, 0, DEBUG_EXPR) 1768 1769 /* VAR_DECL/PARM_DECL DEBUG_IMPLICIT_PTR takes address of. */ 1770 #define DEBUG_IMPLICIT_PTR_DECL(RTX) XCTREE (RTX, 0, DEBUG_IMPLICIT_PTR) 1771 1772 /* PARM_DECL DEBUG_PARAMETER_REF references. */ 1773 #define DEBUG_PARAMETER_REF_DECL(RTX) XCTREE (RTX, 0, DEBUG_PARAMETER_REF) 1774 1775 /* Codes that appear in the NOTE_KIND field for kinds of notes 1776 that are not line numbers. These codes are all negative. 1777 1778 Notice that we do not try to use zero here for any of 1779 the special note codes because sometimes the source line 1780 actually can be zero! This happens (for example) when we 1781 are generating code for the per-translation-unit constructor 1782 and destructor routines for some C++ translation unit. */ 1783 1784 enum insn_note 1785 { 1786 #define DEF_INSN_NOTE(NAME) NAME, 1787 #include "insn-notes.def" 1788 #undef DEF_INSN_NOTE 1789 1790 NOTE_INSN_MAX 1791 }; 1792 1793 /* Names for NOTE insn's other than line numbers. */ 1794 1795 extern const char * const note_insn_name[NOTE_INSN_MAX]; 1796 #define GET_NOTE_INSN_NAME(NOTE_CODE) \ 1797 (note_insn_name[(NOTE_CODE)]) 1798 1799 /* The name of a label, in case it corresponds to an explicit label 1800 in the input source code. */ 1801 #define LABEL_NAME(RTX) XCSTR (RTX, 6, CODE_LABEL) 1802 1803 /* In jump.c, each label contains a count of the number 1804 of LABEL_REFs that point at it, so unused labels can be deleted. */ 1805 #define LABEL_NUSES(RTX) XCINT (RTX, 4, CODE_LABEL) 1806 1807 /* Labels carry a two-bit field composed of the ->jump and ->call 1808 bits. This field indicates whether the label is an alternate 1809 entry point, and if so, what kind. */ 1810 enum label_kind 1811 { 1812 LABEL_NORMAL = 0, /* ordinary label */ 1813 LABEL_STATIC_ENTRY, /* alternate entry point, not exported */ 1814 LABEL_GLOBAL_ENTRY, /* alternate entry point, exported */ 1815 LABEL_WEAK_ENTRY /* alternate entry point, exported as weak symbol */ 1816 }; 1817 1818 #if defined ENABLE_RTL_FLAG_CHECKING && (GCC_VERSION > 2007) 1819 1820 /* Retrieve the kind of LABEL. */ 1821 #define LABEL_KIND(LABEL) __extension__ \ 1822 ({ __typeof (LABEL) const _label = (LABEL); \ 1823 if (! LABEL_P (_label)) \ 1824 rtl_check_failed_flag ("LABEL_KIND", _label, __FILE__, __LINE__, \ 1825 __FUNCTION__); \ 1826 (enum label_kind) ((_label->jump << 1) | _label->call); }) 1827 1828 /* Set the kind of LABEL. */ 1829 #define SET_LABEL_KIND(LABEL, KIND) do { \ 1830 __typeof (LABEL) const _label = (LABEL); \ 1831 const unsigned int _kind = (KIND); \ 1832 if (! LABEL_P (_label)) \ 1833 rtl_check_failed_flag ("SET_LABEL_KIND", _label, __FILE__, __LINE__, \ 1834 __FUNCTION__); \ 1835 _label->jump = ((_kind >> 1) & 1); \ 1836 _label->call = (_kind & 1); \ 1837 } while (0) 1838 1839 #else 1840 1841 /* Retrieve the kind of LABEL. */ 1842 #define LABEL_KIND(LABEL) \ 1843 ((enum label_kind) (((LABEL)->jump << 1) | (LABEL)->call)) 1844 1845 /* Set the kind of LABEL. */ 1846 #define SET_LABEL_KIND(LABEL, KIND) do { \ 1847 rtx const _label = (LABEL); \ 1848 const unsigned int _kind = (KIND); \ 1849 _label->jump = ((_kind >> 1) & 1); \ 1850 _label->call = (_kind & 1); \ 1851 } while (0) 1852 1853 #endif /* rtl flag checking */ 1854 1855 #define LABEL_ALT_ENTRY_P(LABEL) (LABEL_KIND (LABEL) != LABEL_NORMAL) 1856 1857 /* In jump.c, each JUMP_INSN can point to a label that it can jump to, 1858 so that if the JUMP_INSN is deleted, the label's LABEL_NUSES can 1859 be decremented and possibly the label can be deleted. */ 1860 #define JUMP_LABEL(INSN) XCEXP (INSN, 7, JUMP_INSN) 1861 1862 inline rtx_insn *JUMP_LABEL_AS_INSN (const rtx_insn *insn) 1863 { 1864 return safe_as_a <rtx_insn *> (JUMP_LABEL (insn)); 1865 } 1866 1867 /* Methods of rtx_jump_insn. */ 1868 1869 inline rtx rtx_jump_insn::jump_label () const 1870 { 1871 return JUMP_LABEL (this); 1872 } 1873 1874 inline rtx_code_label *rtx_jump_insn::jump_target () const 1875 { 1876 return safe_as_a <rtx_code_label *> (JUMP_LABEL (this)); 1877 } 1878 1879 inline void rtx_jump_insn::set_jump_target (rtx_code_label *target) 1880 { 1881 JUMP_LABEL (this) = target; 1882 } 1883 1884 /* Once basic blocks are found, each CODE_LABEL starts a chain that 1885 goes through all the LABEL_REFs that jump to that label. The chain 1886 eventually winds up at the CODE_LABEL: it is circular. */ 1887 #define LABEL_REFS(LABEL) XCEXP (LABEL, 3, CODE_LABEL) 1888 1889 /* Get the label that a LABEL_REF references. */ 1890 static inline rtx_insn * 1891 label_ref_label (const_rtx ref) 1892 { 1893 return as_a<rtx_insn *> (XCEXP (ref, 0, LABEL_REF)); 1894 } 1895 1896 /* Set the label that LABEL_REF ref refers to. */ 1897 1898 static inline void 1899 set_label_ref_label (rtx ref, rtx_insn *label) 1900 { 1901 XCEXP (ref, 0, LABEL_REF) = label; 1902 } 1903 1904 /* For a REG rtx, REGNO extracts the register number. REGNO can only 1905 be used on RHS. Use SET_REGNO to change the value. */ 1906 #define REGNO(RTX) (rhs_regno(RTX)) 1907 #define SET_REGNO(RTX, N) (df_ref_change_reg_with_loc (RTX, N)) 1908 1909 /* Return the number of consecutive registers in a REG. This is always 1910 1 for pseudo registers and is determined by TARGET_HARD_REGNO_NREGS for 1911 hard registers. */ 1912 #define REG_NREGS(RTX) (REG_CHECK (RTX)->nregs) 1913 1914 /* ORIGINAL_REGNO holds the number the register originally had; for a 1915 pseudo register turned into a hard reg this will hold the old pseudo 1916 register number. */ 1917 #define ORIGINAL_REGNO(RTX) \ 1918 (RTL_FLAG_CHECK1 ("ORIGINAL_REGNO", (RTX), REG)->u2.original_regno) 1919 1920 /* Force the REGNO macro to only be used on the lhs. */ 1921 static inline unsigned int 1922 rhs_regno (const_rtx x) 1923 { 1924 return REG_CHECK (x)->regno; 1925 } 1926 1927 /* Return the final register in REG X plus one. */ 1928 static inline unsigned int 1929 END_REGNO (const_rtx x) 1930 { 1931 return REGNO (x) + REG_NREGS (x); 1932 } 1933 1934 /* Change the REGNO and REG_NREGS of REG X to the specified values, 1935 bypassing the df machinery. */ 1936 static inline void 1937 set_regno_raw (rtx x, unsigned int regno, unsigned int nregs) 1938 { 1939 reg_info *reg = REG_CHECK (x); 1940 reg->regno = regno; 1941 reg->nregs = nregs; 1942 } 1943 1944 /* 1 if RTX is a reg or parallel that is the current function's return 1945 value. */ 1946 #define REG_FUNCTION_VALUE_P(RTX) \ 1947 (RTL_FLAG_CHECK2 ("REG_FUNCTION_VALUE_P", (RTX), REG, PARALLEL)->return_val) 1948 1949 /* 1 if RTX is a reg that corresponds to a variable declared by the user. */ 1950 #define REG_USERVAR_P(RTX) \ 1951 (RTL_FLAG_CHECK1 ("REG_USERVAR_P", (RTX), REG)->volatil) 1952 1953 /* 1 if RTX is a reg that holds a pointer value. */ 1954 #define REG_POINTER(RTX) \ 1955 (RTL_FLAG_CHECK1 ("REG_POINTER", (RTX), REG)->frame_related) 1956 1957 /* 1 if RTX is a mem that holds a pointer value. */ 1958 #define MEM_POINTER(RTX) \ 1959 (RTL_FLAG_CHECK1 ("MEM_POINTER", (RTX), MEM)->frame_related) 1960 1961 /* 1 if the given register REG corresponds to a hard register. */ 1962 #define HARD_REGISTER_P(REG) (HARD_REGISTER_NUM_P (REGNO (REG))) 1963 1964 /* 1 if the given register number REG_NO corresponds to a hard register. */ 1965 #define HARD_REGISTER_NUM_P(REG_NO) ((REG_NO) < FIRST_PSEUDO_REGISTER) 1966 1967 /* For a CONST_INT rtx, INTVAL extracts the integer. */ 1968 #define INTVAL(RTX) XCWINT (RTX, 0, CONST_INT) 1969 #define UINTVAL(RTX) ((unsigned HOST_WIDE_INT) INTVAL (RTX)) 1970 1971 /* For a CONST_WIDE_INT, CONST_WIDE_INT_NUNITS is the number of 1972 elements actually needed to represent the constant. 1973 CONST_WIDE_INT_ELT gets one of the elements. 0 is the least 1974 significant HOST_WIDE_INT. */ 1975 #define CONST_WIDE_INT_VEC(RTX) HWIVEC_CHECK (RTX, CONST_WIDE_INT) 1976 #define CONST_WIDE_INT_NUNITS(RTX) CWI_GET_NUM_ELEM (RTX) 1977 #define CONST_WIDE_INT_ELT(RTX, N) CWI_ELT (RTX, N) 1978 1979 /* For a CONST_POLY_INT, CONST_POLY_INT_COEFFS gives access to the 1980 individual coefficients, in the form of a trailing_wide_ints structure. */ 1981 #define CONST_POLY_INT_COEFFS(RTX) \ 1982 (RTL_FLAG_CHECK1("CONST_POLY_INT_COEFFS", (RTX), \ 1983 CONST_POLY_INT)->u.cpi.coeffs) 1984 1985 /* For a CONST_DOUBLE: 1986 #if TARGET_SUPPORTS_WIDE_INT == 0 1987 For a VOIDmode, there are two integers CONST_DOUBLE_LOW is the 1988 low-order word and ..._HIGH the high-order. 1989 #endif 1990 For a float, there is a REAL_VALUE_TYPE structure, and 1991 CONST_DOUBLE_REAL_VALUE(r) is a pointer to it. */ 1992 #define CONST_DOUBLE_LOW(r) XCMWINT (r, 0, CONST_DOUBLE, VOIDmode) 1993 #define CONST_DOUBLE_HIGH(r) XCMWINT (r, 1, CONST_DOUBLE, VOIDmode) 1994 #define CONST_DOUBLE_REAL_VALUE(r) \ 1995 ((const struct real_value *) XCNMPRV (r, CONST_DOUBLE, VOIDmode)) 1996 1997 #define CONST_FIXED_VALUE(r) \ 1998 ((const struct fixed_value *) XCNMPFV (r, CONST_FIXED, VOIDmode)) 1999 #define CONST_FIXED_VALUE_HIGH(r) \ 2000 ((HOST_WIDE_INT) (CONST_FIXED_VALUE (r)->data.high)) 2001 #define CONST_FIXED_VALUE_LOW(r) \ 2002 ((HOST_WIDE_INT) (CONST_FIXED_VALUE (r)->data.low)) 2003 2004 /* For a CONST_VECTOR, return element #n. */ 2005 #define CONST_VECTOR_ELT(RTX, N) const_vector_elt (RTX, N) 2006 2007 /* See rtl.texi for a description of these macros. */ 2008 #define CONST_VECTOR_NPATTERNS(RTX) \ 2009 (RTL_FLAG_CHECK1 ("CONST_VECTOR_NPATTERNS", (RTX), CONST_VECTOR) \ 2010 ->u2.const_vector.npatterns) 2011 2012 #define CONST_VECTOR_NELTS_PER_PATTERN(RTX) \ 2013 (RTL_FLAG_CHECK1 ("CONST_VECTOR_NELTS_PER_PATTERN", (RTX), CONST_VECTOR) \ 2014 ->u2.const_vector.nelts_per_pattern) 2015 2016 #define CONST_VECTOR_DUPLICATE_P(RTX) \ 2017 (CONST_VECTOR_NELTS_PER_PATTERN (RTX) == 1) 2018 2019 #define CONST_VECTOR_STEPPED_P(RTX) \ 2020 (CONST_VECTOR_NELTS_PER_PATTERN (RTX) == 3) 2021 2022 #define CONST_VECTOR_ENCODED_ELT(RTX, N) XCVECEXP (RTX, 0, N, CONST_VECTOR) 2023 2024 /* Return the number of elements encoded directly in a CONST_VECTOR. */ 2025 2026 inline unsigned int 2027 const_vector_encoded_nelts (const_rtx x) 2028 { 2029 return CONST_VECTOR_NPATTERNS (x) * CONST_VECTOR_NELTS_PER_PATTERN (x); 2030 } 2031 2032 /* For a CONST_VECTOR, return the number of elements in a vector. */ 2033 #define CONST_VECTOR_NUNITS(RTX) GET_MODE_NUNITS (GET_MODE (RTX)) 2034 2035 /* For a SUBREG rtx, SUBREG_REG extracts the value we want a subreg of. 2036 SUBREG_BYTE extracts the byte-number. */ 2037 2038 #define SUBREG_REG(RTX) XCEXP (RTX, 0, SUBREG) 2039 #define SUBREG_BYTE(RTX) XCSUBREG (RTX, 1, SUBREG) 2040 2041 /* in rtlanal.c */ 2042 /* Return the right cost to give to an operation 2043 to make the cost of the corresponding register-to-register instruction 2044 N times that of a fast register-to-register instruction. */ 2045 #define COSTS_N_INSNS(N) ((N) * 4) 2046 2047 /* Maximum cost of an rtl expression. This value has the special meaning 2048 not to use an rtx with this cost under any circumstances. */ 2049 #define MAX_COST INT_MAX 2050 2051 /* Return true if CODE always has VOIDmode. */ 2052 2053 static inline bool 2054 always_void_p (enum rtx_code code) 2055 { 2056 return code == SET; 2057 } 2058 2059 /* A structure to hold all available cost information about an rtl 2060 expression. */ 2061 struct full_rtx_costs 2062 { 2063 int speed; 2064 int size; 2065 }; 2066 2067 /* Initialize a full_rtx_costs structure C to the maximum cost. */ 2068 static inline void 2069 init_costs_to_max (struct full_rtx_costs *c) 2070 { 2071 c->speed = MAX_COST; 2072 c->size = MAX_COST; 2073 } 2074 2075 /* Initialize a full_rtx_costs structure C to zero cost. */ 2076 static inline void 2077 init_costs_to_zero (struct full_rtx_costs *c) 2078 { 2079 c->speed = 0; 2080 c->size = 0; 2081 } 2082 2083 /* Compare two full_rtx_costs structures A and B, returning true 2084 if A < B when optimizing for speed. */ 2085 static inline bool 2086 costs_lt_p (struct full_rtx_costs *a, struct full_rtx_costs *b, 2087 bool speed) 2088 { 2089 if (speed) 2090 return (a->speed < b->speed 2091 || (a->speed == b->speed && a->size < b->size)); 2092 else 2093 return (a->size < b->size 2094 || (a->size == b->size && a->speed < b->speed)); 2095 } 2096 2097 /* Increase both members of the full_rtx_costs structure C by the 2098 cost of N insns. */ 2099 static inline void 2100 costs_add_n_insns (struct full_rtx_costs *c, int n) 2101 { 2102 c->speed += COSTS_N_INSNS (n); 2103 c->size += COSTS_N_INSNS (n); 2104 } 2105 2106 /* Describes the shape of a subreg: 2107 2108 inner_mode == the mode of the SUBREG_REG 2109 offset == the SUBREG_BYTE 2110 outer_mode == the mode of the SUBREG itself. */ 2111 class subreg_shape { 2112 public: 2113 subreg_shape (machine_mode, poly_uint16, machine_mode); 2114 bool operator == (const subreg_shape &) const; 2115 bool operator != (const subreg_shape &) const; 2116 unsigned HOST_WIDE_INT unique_id () const; 2117 2118 machine_mode inner_mode; 2119 poly_uint16 offset; 2120 machine_mode outer_mode; 2121 }; 2122 2123 inline 2124 subreg_shape::subreg_shape (machine_mode inner_mode_in, 2125 poly_uint16 offset_in, 2126 machine_mode outer_mode_in) 2127 : inner_mode (inner_mode_in), offset (offset_in), outer_mode (outer_mode_in) 2128 {} 2129 2130 inline bool 2131 subreg_shape::operator == (const subreg_shape &other) const 2132 { 2133 return (inner_mode == other.inner_mode 2134 && known_eq (offset, other.offset) 2135 && outer_mode == other.outer_mode); 2136 } 2137 2138 inline bool 2139 subreg_shape::operator != (const subreg_shape &other) const 2140 { 2141 return !operator == (other); 2142 } 2143 2144 /* Return an integer that uniquely identifies this shape. Structures 2145 like rtx_def assume that a mode can fit in an 8-bit bitfield and no 2146 current mode is anywhere near being 65536 bytes in size, so the 2147 id comfortably fits in an int. */ 2148 2149 inline unsigned HOST_WIDE_INT 2150 subreg_shape::unique_id () const 2151 { 2152 { STATIC_ASSERT (MAX_MACHINE_MODE <= 256); } 2153 { STATIC_ASSERT (NUM_POLY_INT_COEFFS <= 3); } 2154 { STATIC_ASSERT (sizeof (offset.coeffs[0]) <= 2); } 2155 int res = (int) inner_mode + ((int) outer_mode << 8); 2156 for (int i = 0; i < NUM_POLY_INT_COEFFS; ++i) 2157 res += (HOST_WIDE_INT) offset.coeffs[i] << ((1 + i) * 16); 2158 return res; 2159 } 2160 2161 /* Return the shape of a SUBREG rtx. */ 2162 2163 static inline subreg_shape 2164 shape_of_subreg (const_rtx x) 2165 { 2166 return subreg_shape (GET_MODE (SUBREG_REG (x)), 2167 SUBREG_BYTE (x), GET_MODE (x)); 2168 } 2169 2170 /* Information about an address. This structure is supposed to be able 2171 to represent all supported target addresses. Please extend it if it 2172 is not yet general enough. */ 2173 struct address_info { 2174 /* The mode of the value being addressed, or VOIDmode if this is 2175 a load-address operation with no known address mode. */ 2176 machine_mode mode; 2177 2178 /* The address space. */ 2179 addr_space_t as; 2180 2181 /* True if this is an RTX_AUTOINC address. */ 2182 bool autoinc_p; 2183 2184 /* A pointer to the top-level address. */ 2185 rtx *outer; 2186 2187 /* A pointer to the inner address, after all address mutations 2188 have been stripped from the top-level address. It can be one 2189 of the following: 2190 2191 - A {PRE,POST}_{INC,DEC} of *BASE. SEGMENT, INDEX and DISP are null. 2192 2193 - A {PRE,POST}_MODIFY of *BASE. In this case either INDEX or DISP 2194 points to the step value, depending on whether the step is variable 2195 or constant respectively. SEGMENT is null. 2196 2197 - A plain sum of the form SEGMENT + BASE + INDEX + DISP, 2198 with null fields evaluating to 0. */ 2199 rtx *inner; 2200 2201 /* Components that make up *INNER. Each one may be null or nonnull. 2202 When nonnull, their meanings are as follows: 2203 2204 - *SEGMENT is the "segment" of memory to which the address refers. 2205 This value is entirely target-specific and is only called a "segment" 2206 because that's its most typical use. It contains exactly one UNSPEC, 2207 pointed to by SEGMENT_TERM. The contents of *SEGMENT do not need 2208 reloading. 2209 2210 - *BASE is a variable expression representing a base address. 2211 It contains exactly one REG, SUBREG or MEM, pointed to by BASE_TERM. 2212 2213 - *INDEX is a variable expression representing an index value. 2214 It may be a scaled expression, such as a MULT. It has exactly 2215 one REG, SUBREG or MEM, pointed to by INDEX_TERM. 2216 2217 - *DISP is a constant, possibly mutated. DISP_TERM points to the 2218 unmutated RTX_CONST_OBJ. */ 2219 rtx *segment; 2220 rtx *base; 2221 rtx *index; 2222 rtx *disp; 2223 2224 rtx *segment_term; 2225 rtx *base_term; 2226 rtx *index_term; 2227 rtx *disp_term; 2228 2229 /* In a {PRE,POST}_MODIFY address, this points to a second copy 2230 of BASE_TERM, otherwise it is null. */ 2231 rtx *base_term2; 2232 2233 /* ADDRESS if this structure describes an address operand, MEM if 2234 it describes a MEM address. */ 2235 enum rtx_code addr_outer_code; 2236 2237 /* If BASE is nonnull, this is the code of the rtx that contains it. */ 2238 enum rtx_code base_outer_code; 2239 }; 2240 2241 /* This is used to bundle an rtx and a mode together so that the pair 2242 can be used with the wi:: routines. If we ever put modes into rtx 2243 integer constants, this should go away and then just pass an rtx in. */ 2244 typedef std::pair <rtx, machine_mode> rtx_mode_t; 2245 2246 namespace wi 2247 { 2248 template <> 2249 struct int_traits <rtx_mode_t> 2250 { 2251 static const enum precision_type precision_type = VAR_PRECISION; 2252 static const bool host_dependent_precision = false; 2253 /* This ought to be true, except for the special case that BImode 2254 is canonicalized to STORE_FLAG_VALUE, which might be 1. */ 2255 static const bool is_sign_extended = false; 2256 static unsigned int get_precision (const rtx_mode_t &); 2257 static wi::storage_ref decompose (HOST_WIDE_INT *, unsigned int, 2258 const rtx_mode_t &); 2259 }; 2260 } 2261 2262 inline unsigned int 2263 wi::int_traits <rtx_mode_t>::get_precision (const rtx_mode_t &x) 2264 { 2265 return GET_MODE_PRECISION (as_a <scalar_mode> (x.second)); 2266 } 2267 2268 inline wi::storage_ref 2269 wi::int_traits <rtx_mode_t>::decompose (HOST_WIDE_INT *, 2270 unsigned int precision, 2271 const rtx_mode_t &x) 2272 { 2273 gcc_checking_assert (precision == get_precision (x)); 2274 switch (GET_CODE (x.first)) 2275 { 2276 case CONST_INT: 2277 if (precision < HOST_BITS_PER_WIDE_INT) 2278 /* Nonzero BImodes are stored as STORE_FLAG_VALUE, which on many 2279 targets is 1 rather than -1. */ 2280 gcc_checking_assert (INTVAL (x.first) 2281 == sext_hwi (INTVAL (x.first), precision) 2282 || (x.second == BImode && INTVAL (x.first) == 1)); 2283 2284 return wi::storage_ref (&INTVAL (x.first), 1, precision); 2285 2286 case CONST_WIDE_INT: 2287 return wi::storage_ref (&CONST_WIDE_INT_ELT (x.first, 0), 2288 CONST_WIDE_INT_NUNITS (x.first), precision); 2289 2290 #if TARGET_SUPPORTS_WIDE_INT == 0 2291 case CONST_DOUBLE: 2292 return wi::storage_ref (&CONST_DOUBLE_LOW (x.first), 2, precision); 2293 #endif 2294 2295 default: 2296 gcc_unreachable (); 2297 } 2298 } 2299 2300 namespace wi 2301 { 2302 hwi_with_prec shwi (HOST_WIDE_INT, machine_mode mode); 2303 wide_int min_value (machine_mode, signop); 2304 wide_int max_value (machine_mode, signop); 2305 } 2306 2307 inline wi::hwi_with_prec 2308 wi::shwi (HOST_WIDE_INT val, machine_mode mode) 2309 { 2310 return shwi (val, GET_MODE_PRECISION (as_a <scalar_mode> (mode))); 2311 } 2312 2313 /* Produce the smallest number that is represented in MODE. The precision 2314 is taken from MODE and the sign from SGN. */ 2315 inline wide_int 2316 wi::min_value (machine_mode mode, signop sgn) 2317 { 2318 return min_value (GET_MODE_PRECISION (as_a <scalar_mode> (mode)), sgn); 2319 } 2320 2321 /* Produce the largest number that is represented in MODE. The precision 2322 is taken from MODE and the sign from SGN. */ 2323 inline wide_int 2324 wi::max_value (machine_mode mode, signop sgn) 2325 { 2326 return max_value (GET_MODE_PRECISION (as_a <scalar_mode> (mode)), sgn); 2327 } 2328 2329 namespace wi 2330 { 2331 typedef poly_int<NUM_POLY_INT_COEFFS, 2332 generic_wide_int <wide_int_ref_storage <false, false> > > 2333 rtx_to_poly_wide_ref; 2334 rtx_to_poly_wide_ref to_poly_wide (const_rtx, machine_mode); 2335 } 2336 2337 /* Return the value of a CONST_POLY_INT in its native precision. */ 2338 2339 inline wi::rtx_to_poly_wide_ref 2340 const_poly_int_value (const_rtx x) 2341 { 2342 poly_int<NUM_POLY_INT_COEFFS, WIDE_INT_REF_FOR (wide_int)> res; 2343 for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i) 2344 res.coeffs[i] = CONST_POLY_INT_COEFFS (x)[i]; 2345 return res; 2346 } 2347 2348 /* Return true if X is a scalar integer or a CONST_POLY_INT. The value 2349 can then be extracted using wi::to_poly_wide. */ 2350 2351 inline bool 2352 poly_int_rtx_p (const_rtx x) 2353 { 2354 return CONST_SCALAR_INT_P (x) || CONST_POLY_INT_P (x); 2355 } 2356 2357 /* Access X (which satisfies poly_int_rtx_p) as a poly_wide_int. 2358 MODE is the mode of X. */ 2359 2360 inline wi::rtx_to_poly_wide_ref 2361 wi::to_poly_wide (const_rtx x, machine_mode mode) 2362 { 2363 if (CONST_POLY_INT_P (x)) 2364 return const_poly_int_value (x); 2365 return rtx_mode_t (const_cast<rtx> (x), mode); 2366 } 2367 2368 /* Return the value of X as a poly_int64. */ 2369 2370 inline poly_int64 2371 rtx_to_poly_int64 (const_rtx x) 2372 { 2373 if (CONST_POLY_INT_P (x)) 2374 { 2375 poly_int64 res; 2376 for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i) 2377 res.coeffs[i] = CONST_POLY_INT_COEFFS (x)[i].to_shwi (); 2378 return res; 2379 } 2380 return INTVAL (x); 2381 } 2382 2383 /* Return true if arbitrary value X is an integer constant that can 2384 be represented as a poly_int64. Store the value in *RES if so, 2385 otherwise leave it unmodified. */ 2386 2387 inline bool 2388 poly_int_rtx_p (const_rtx x, poly_int64_pod *res) 2389 { 2390 if (CONST_INT_P (x)) 2391 { 2392 *res = INTVAL (x); 2393 return true; 2394 } 2395 if (CONST_POLY_INT_P (x)) 2396 { 2397 for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i) 2398 if (!wi::fits_shwi_p (CONST_POLY_INT_COEFFS (x)[i])) 2399 return false; 2400 for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i) 2401 res->coeffs[i] = CONST_POLY_INT_COEFFS (x)[i].to_shwi (); 2402 return true; 2403 } 2404 return false; 2405 } 2406 2407 extern void init_rtlanal (void); 2408 extern int rtx_cost (rtx, machine_mode, enum rtx_code, int, bool); 2409 extern int address_cost (rtx, machine_mode, addr_space_t, bool); 2410 extern void get_full_rtx_cost (rtx, machine_mode, enum rtx_code, int, 2411 struct full_rtx_costs *); 2412 extern bool native_encode_rtx (machine_mode, rtx, vec<target_unit> &, 2413 unsigned int, unsigned int); 2414 extern rtx native_decode_rtx (machine_mode, vec<target_unit>, 2415 unsigned int); 2416 extern rtx native_decode_vector_rtx (machine_mode, vec<target_unit>, 2417 unsigned int, unsigned int, unsigned int); 2418 extern poly_uint64 subreg_lsb (const_rtx); 2419 extern poly_uint64 subreg_size_lsb (poly_uint64, poly_uint64, poly_uint64); 2420 extern poly_uint64 subreg_size_offset_from_lsb (poly_uint64, poly_uint64, 2421 poly_uint64); 2422 extern bool read_modify_subreg_p (const_rtx); 2423 2424 /* Given a subreg's OUTER_MODE, INNER_MODE, and SUBREG_BYTE, return the 2425 bit offset at which the subreg begins (counting from the least significant 2426 bit of the operand). */ 2427 2428 inline poly_uint64 2429 subreg_lsb_1 (machine_mode outer_mode, machine_mode inner_mode, 2430 poly_uint64 subreg_byte) 2431 { 2432 return subreg_size_lsb (GET_MODE_SIZE (outer_mode), 2433 GET_MODE_SIZE (inner_mode), subreg_byte); 2434 } 2435 2436 /* Return the subreg byte offset for a subreg whose outer mode is 2437 OUTER_MODE, whose inner mode is INNER_MODE, and where there are 2438 LSB_SHIFT *bits* between the lsb of the outer value and the lsb of 2439 the inner value. This is the inverse of subreg_lsb_1 (which converts 2440 byte offsets to bit shifts). */ 2441 2442 inline poly_uint64 2443 subreg_offset_from_lsb (machine_mode outer_mode, 2444 machine_mode inner_mode, 2445 poly_uint64 lsb_shift) 2446 { 2447 return subreg_size_offset_from_lsb (GET_MODE_SIZE (outer_mode), 2448 GET_MODE_SIZE (inner_mode), lsb_shift); 2449 } 2450 2451 extern unsigned int subreg_regno_offset (unsigned int, machine_mode, 2452 poly_uint64, machine_mode); 2453 extern bool subreg_offset_representable_p (unsigned int, machine_mode, 2454 poly_uint64, machine_mode); 2455 extern unsigned int subreg_regno (const_rtx); 2456 extern int simplify_subreg_regno (unsigned int, machine_mode, 2457 poly_uint64, machine_mode); 2458 extern unsigned int subreg_nregs (const_rtx); 2459 extern unsigned int subreg_nregs_with_regno (unsigned int, const_rtx); 2460 extern unsigned HOST_WIDE_INT nonzero_bits (const_rtx, machine_mode); 2461 extern unsigned int num_sign_bit_copies (const_rtx, machine_mode); 2462 extern bool constant_pool_constant_p (rtx); 2463 extern bool truncated_to_mode (machine_mode, const_rtx); 2464 extern int low_bitmask_len (machine_mode, unsigned HOST_WIDE_INT); 2465 extern void split_double (rtx, rtx *, rtx *); 2466 extern rtx *strip_address_mutations (rtx *, enum rtx_code * = 0); 2467 extern void decompose_address (struct address_info *, rtx *, 2468 machine_mode, addr_space_t, enum rtx_code); 2469 extern void decompose_lea_address (struct address_info *, rtx *); 2470 extern void decompose_mem_address (struct address_info *, rtx); 2471 extern void update_address (struct address_info *); 2472 extern HOST_WIDE_INT get_index_scale (const struct address_info *); 2473 extern enum rtx_code get_index_code (const struct address_info *); 2474 2475 /* 1 if RTX is a subreg containing a reg that is already known to be 2476 sign- or zero-extended from the mode of the subreg to the mode of 2477 the reg. SUBREG_PROMOTED_UNSIGNED_P gives the signedness of the 2478 extension. 2479 2480 When used as a LHS, is means that this extension must be done 2481 when assigning to SUBREG_REG. */ 2482 2483 #define SUBREG_PROMOTED_VAR_P(RTX) \ 2484 (RTL_FLAG_CHECK1 ("SUBREG_PROMOTED", (RTX), SUBREG)->in_struct) 2485 2486 /* Valid for subregs which are SUBREG_PROMOTED_VAR_P(). In that case 2487 this gives the necessary extensions: 2488 0 - signed (SPR_SIGNED) 2489 1 - normal unsigned (SPR_UNSIGNED) 2490 2 - value is both sign and unsign extended for mode 2491 (SPR_SIGNED_AND_UNSIGNED). 2492 -1 - pointer unsigned, which most often can be handled like unsigned 2493 extension, except for generating instructions where we need to 2494 emit special code (ptr_extend insns) on some architectures 2495 (SPR_POINTER). */ 2496 2497 const int SRP_POINTER = -1; 2498 const int SRP_SIGNED = 0; 2499 const int SRP_UNSIGNED = 1; 2500 const int SRP_SIGNED_AND_UNSIGNED = 2; 2501 2502 /* Sets promoted mode for SUBREG_PROMOTED_VAR_P(). */ 2503 #define SUBREG_PROMOTED_SET(RTX, VAL) \ 2504 do { \ 2505 rtx const _rtx = RTL_FLAG_CHECK1 ("SUBREG_PROMOTED_SET", \ 2506 (RTX), SUBREG); \ 2507 switch (VAL) \ 2508 { \ 2509 case SRP_POINTER: \ 2510 _rtx->volatil = 0; \ 2511 _rtx->unchanging = 0; \ 2512 break; \ 2513 case SRP_SIGNED: \ 2514 _rtx->volatil = 0; \ 2515 _rtx->unchanging = 1; \ 2516 break; \ 2517 case SRP_UNSIGNED: \ 2518 _rtx->volatil = 1; \ 2519 _rtx->unchanging = 0; \ 2520 break; \ 2521 case SRP_SIGNED_AND_UNSIGNED: \ 2522 _rtx->volatil = 1; \ 2523 _rtx->unchanging = 1; \ 2524 break; \ 2525 } \ 2526 } while (0) 2527 2528 /* Gets the value stored in promoted mode for SUBREG_PROMOTED_VAR_P(), 2529 including SRP_SIGNED_AND_UNSIGNED if promoted for 2530 both signed and unsigned. */ 2531 #define SUBREG_PROMOTED_GET(RTX) \ 2532 (2 * (RTL_FLAG_CHECK1 ("SUBREG_PROMOTED_GET", (RTX), SUBREG)->volatil)\ 2533 + (RTX)->unchanging - 1) 2534 2535 /* Returns sign of promoted mode for SUBREG_PROMOTED_VAR_P(). */ 2536 #define SUBREG_PROMOTED_SIGN(RTX) \ 2537 ((RTL_FLAG_CHECK1 ("SUBREG_PROMOTED_SIGN", (RTX), SUBREG)->volatil) ? 1\ 2538 : (RTX)->unchanging - 1) 2539 2540 /* Predicate to check if RTX of SUBREG_PROMOTED_VAR_P() is promoted 2541 for SIGNED type. */ 2542 #define SUBREG_PROMOTED_SIGNED_P(RTX) \ 2543 (RTL_FLAG_CHECK1 ("SUBREG_PROMOTED_SIGNED_P", (RTX), SUBREG)->unchanging) 2544 2545 /* Predicate to check if RTX of SUBREG_PROMOTED_VAR_P() is promoted 2546 for UNSIGNED type. */ 2547 #define SUBREG_PROMOTED_UNSIGNED_P(RTX) \ 2548 (RTL_FLAG_CHECK1 ("SUBREG_PROMOTED_UNSIGNED_P", (RTX), SUBREG)->volatil) 2549 2550 /* Checks if RTX of SUBREG_PROMOTED_VAR_P() is promoted for given SIGN. */ 2551 #define SUBREG_CHECK_PROMOTED_SIGN(RTX, SIGN) \ 2552 ((SIGN) == SRP_POINTER ? SUBREG_PROMOTED_GET (RTX) == SRP_POINTER \ 2553 : (SIGN) == SRP_SIGNED ? SUBREG_PROMOTED_SIGNED_P (RTX) \ 2554 : SUBREG_PROMOTED_UNSIGNED_P (RTX)) 2555 2556 /* True if the REG is the static chain register for some CALL_INSN. */ 2557 #define STATIC_CHAIN_REG_P(RTX) \ 2558 (RTL_FLAG_CHECK1 ("STATIC_CHAIN_REG_P", (RTX), REG)->jump) 2559 2560 /* True if the subreg was generated by LRA for reload insns. Such 2561 subregs are valid only during LRA. */ 2562 #define LRA_SUBREG_P(RTX) \ 2563 (RTL_FLAG_CHECK1 ("LRA_SUBREG_P", (RTX), SUBREG)->jump) 2564 2565 /* Access various components of an ASM_OPERANDS rtx. */ 2566 2567 #define ASM_OPERANDS_TEMPLATE(RTX) XCSTR (RTX, 0, ASM_OPERANDS) 2568 #define ASM_OPERANDS_OUTPUT_CONSTRAINT(RTX) XCSTR (RTX, 1, ASM_OPERANDS) 2569 #define ASM_OPERANDS_OUTPUT_IDX(RTX) XCINT (RTX, 2, ASM_OPERANDS) 2570 #define ASM_OPERANDS_INPUT_VEC(RTX) XCVEC (RTX, 3, ASM_OPERANDS) 2571 #define ASM_OPERANDS_INPUT_CONSTRAINT_VEC(RTX) XCVEC (RTX, 4, ASM_OPERANDS) 2572 #define ASM_OPERANDS_INPUT(RTX, N) XCVECEXP (RTX, 3, N, ASM_OPERANDS) 2573 #define ASM_OPERANDS_INPUT_LENGTH(RTX) XCVECLEN (RTX, 3, ASM_OPERANDS) 2574 #define ASM_OPERANDS_INPUT_CONSTRAINT_EXP(RTX, N) \ 2575 XCVECEXP (RTX, 4, N, ASM_OPERANDS) 2576 #define ASM_OPERANDS_INPUT_CONSTRAINT(RTX, N) \ 2577 XSTR (XCVECEXP (RTX, 4, N, ASM_OPERANDS), 0) 2578 #define ASM_OPERANDS_INPUT_MODE(RTX, N) \ 2579 GET_MODE (XCVECEXP (RTX, 4, N, ASM_OPERANDS)) 2580 #define ASM_OPERANDS_LABEL_VEC(RTX) XCVEC (RTX, 5, ASM_OPERANDS) 2581 #define ASM_OPERANDS_LABEL_LENGTH(RTX) XCVECLEN (RTX, 5, ASM_OPERANDS) 2582 #define ASM_OPERANDS_LABEL(RTX, N) XCVECEXP (RTX, 5, N, ASM_OPERANDS) 2583 #define ASM_OPERANDS_SOURCE_LOCATION(RTX) XCUINT (RTX, 6, ASM_OPERANDS) 2584 #define ASM_INPUT_SOURCE_LOCATION(RTX) XCUINT (RTX, 1, ASM_INPUT) 2585 2586 /* 1 if RTX is a mem that is statically allocated in read-only memory. */ 2587 #define MEM_READONLY_P(RTX) \ 2588 (RTL_FLAG_CHECK1 ("MEM_READONLY_P", (RTX), MEM)->unchanging) 2589 2590 /* 1 if RTX is a mem and we should keep the alias set for this mem 2591 unchanged when we access a component. Set to 1, or example, when we 2592 are already in a non-addressable component of an aggregate. */ 2593 #define MEM_KEEP_ALIAS_SET_P(RTX) \ 2594 (RTL_FLAG_CHECK1 ("MEM_KEEP_ALIAS_SET_P", (RTX), MEM)->jump) 2595 2596 /* 1 if RTX is a mem or asm_operand for a volatile reference. */ 2597 #define MEM_VOLATILE_P(RTX) \ 2598 (RTL_FLAG_CHECK3 ("MEM_VOLATILE_P", (RTX), MEM, ASM_OPERANDS, \ 2599 ASM_INPUT)->volatil) 2600 2601 /* 1 if RTX is a mem that cannot trap. */ 2602 #define MEM_NOTRAP_P(RTX) \ 2603 (RTL_FLAG_CHECK1 ("MEM_NOTRAP_P", (RTX), MEM)->call) 2604 2605 /* The memory attribute block. We provide access macros for each value 2606 in the block and provide defaults if none specified. */ 2607 #define MEM_ATTRS(RTX) X0MEMATTR (RTX, 1) 2608 2609 /* The register attribute block. We provide access macros for each value 2610 in the block and provide defaults if none specified. */ 2611 #define REG_ATTRS(RTX) (REG_CHECK (RTX)->attrs) 2612 2613 #ifndef GENERATOR_FILE 2614 /* For a MEM rtx, the alias set. If 0, this MEM is not in any alias 2615 set, and may alias anything. Otherwise, the MEM can only alias 2616 MEMs in a conflicting alias set. This value is set in a 2617 language-dependent manner in the front-end, and should not be 2618 altered in the back-end. These set numbers are tested with 2619 alias_sets_conflict_p. */ 2620 #define MEM_ALIAS_SET(RTX) (get_mem_attrs (RTX)->alias) 2621 2622 /* For a MEM rtx, the decl it is known to refer to, if it is known to 2623 refer to part of a DECL. It may also be a COMPONENT_REF. */ 2624 #define MEM_EXPR(RTX) (get_mem_attrs (RTX)->expr) 2625 2626 /* For a MEM rtx, true if its MEM_OFFSET is known. */ 2627 #define MEM_OFFSET_KNOWN_P(RTX) (get_mem_attrs (RTX)->offset_known_p) 2628 2629 /* For a MEM rtx, the offset from the start of MEM_EXPR. */ 2630 #define MEM_OFFSET(RTX) (get_mem_attrs (RTX)->offset) 2631 2632 /* For a MEM rtx, the address space. */ 2633 #define MEM_ADDR_SPACE(RTX) (get_mem_attrs (RTX)->addrspace) 2634 2635 /* For a MEM rtx, true if its MEM_SIZE is known. */ 2636 #define MEM_SIZE_KNOWN_P(RTX) (get_mem_attrs (RTX)->size_known_p) 2637 2638 /* For a MEM rtx, the size in bytes of the MEM. */ 2639 #define MEM_SIZE(RTX) (get_mem_attrs (RTX)->size) 2640 2641 /* For a MEM rtx, the alignment in bits. We can use the alignment of the 2642 mode as a default when STRICT_ALIGNMENT, but not if not. */ 2643 #define MEM_ALIGN(RTX) (get_mem_attrs (RTX)->align) 2644 #else 2645 #define MEM_ADDR_SPACE(RTX) ADDR_SPACE_GENERIC 2646 #endif 2647 2648 /* For a REG rtx, the decl it is known to refer to, if it is known to 2649 refer to part of a DECL. */ 2650 #define REG_EXPR(RTX) (REG_ATTRS (RTX) == 0 ? 0 : REG_ATTRS (RTX)->decl) 2651 2652 /* For a REG rtx, the offset from the start of REG_EXPR, if known, as an 2653 HOST_WIDE_INT. */ 2654 #define REG_OFFSET(RTX) (REG_ATTRS (RTX) == 0 ? 0 : REG_ATTRS (RTX)->offset) 2655 2656 /* Copy the attributes that apply to memory locations from RHS to LHS. */ 2657 #define MEM_COPY_ATTRIBUTES(LHS, RHS) \ 2658 (MEM_VOLATILE_P (LHS) = MEM_VOLATILE_P (RHS), \ 2659 MEM_NOTRAP_P (LHS) = MEM_NOTRAP_P (RHS), \ 2660 MEM_READONLY_P (LHS) = MEM_READONLY_P (RHS), \ 2661 MEM_KEEP_ALIAS_SET_P (LHS) = MEM_KEEP_ALIAS_SET_P (RHS), \ 2662 MEM_POINTER (LHS) = MEM_POINTER (RHS), \ 2663 MEM_ATTRS (LHS) = MEM_ATTRS (RHS)) 2664 2665 /* 1 if RTX is a label_ref for a nonlocal label. */ 2666 /* Likewise in an expr_list for a REG_LABEL_OPERAND or 2667 REG_LABEL_TARGET note. */ 2668 #define LABEL_REF_NONLOCAL_P(RTX) \ 2669 (RTL_FLAG_CHECK1 ("LABEL_REF_NONLOCAL_P", (RTX), LABEL_REF)->volatil) 2670 2671 /* 1 if RTX is a code_label that should always be considered to be needed. */ 2672 #define LABEL_PRESERVE_P(RTX) \ 2673 (RTL_FLAG_CHECK2 ("LABEL_PRESERVE_P", (RTX), CODE_LABEL, NOTE)->in_struct) 2674 2675 /* During sched, 1 if RTX is an insn that must be scheduled together 2676 with the preceding insn. */ 2677 #define SCHED_GROUP_P(RTX) \ 2678 (RTL_FLAG_CHECK4 ("SCHED_GROUP_P", (RTX), DEBUG_INSN, INSN, \ 2679 JUMP_INSN, CALL_INSN)->in_struct) 2680 2681 /* For a SET rtx, SET_DEST is the place that is set 2682 and SET_SRC is the value it is set to. */ 2683 #define SET_DEST(RTX) XC2EXP (RTX, 0, SET, CLOBBER) 2684 #define SET_SRC(RTX) XCEXP (RTX, 1, SET) 2685 #define SET_IS_RETURN_P(RTX) \ 2686 (RTL_FLAG_CHECK1 ("SET_IS_RETURN_P", (RTX), SET)->jump) 2687 2688 /* For a TRAP_IF rtx, TRAP_CONDITION is an expression. */ 2689 #define TRAP_CONDITION(RTX) XCEXP (RTX, 0, TRAP_IF) 2690 #define TRAP_CODE(RTX) XCEXP (RTX, 1, TRAP_IF) 2691 2692 /* For a COND_EXEC rtx, COND_EXEC_TEST is the condition to base 2693 conditionally executing the code on, COND_EXEC_CODE is the code 2694 to execute if the condition is true. */ 2695 #define COND_EXEC_TEST(RTX) XCEXP (RTX, 0, COND_EXEC) 2696 #define COND_EXEC_CODE(RTX) XCEXP (RTX, 1, COND_EXEC) 2697 2698 /* 1 if RTX is a symbol_ref that addresses this function's rtl 2699 constants pool. */ 2700 #define CONSTANT_POOL_ADDRESS_P(RTX) \ 2701 (RTL_FLAG_CHECK1 ("CONSTANT_POOL_ADDRESS_P", (RTX), SYMBOL_REF)->unchanging) 2702 2703 /* 1 if RTX is a symbol_ref that addresses a value in the file's 2704 tree constant pool. This information is private to varasm.c. */ 2705 #define TREE_CONSTANT_POOL_ADDRESS_P(RTX) \ 2706 (RTL_FLAG_CHECK1 ("TREE_CONSTANT_POOL_ADDRESS_P", \ 2707 (RTX), SYMBOL_REF)->frame_related) 2708 2709 /* Used if RTX is a symbol_ref, for machine-specific purposes. */ 2710 #define SYMBOL_REF_FLAG(RTX) \ 2711 (RTL_FLAG_CHECK1 ("SYMBOL_REF_FLAG", (RTX), SYMBOL_REF)->volatil) 2712 2713 /* 1 if RTX is a symbol_ref that has been the library function in 2714 emit_library_call. */ 2715 #define SYMBOL_REF_USED(RTX) \ 2716 (RTL_FLAG_CHECK1 ("SYMBOL_REF_USED", (RTX), SYMBOL_REF)->used) 2717 2718 /* 1 if RTX is a symbol_ref for a weak symbol. */ 2719 #define SYMBOL_REF_WEAK(RTX) \ 2720 (RTL_FLAG_CHECK1 ("SYMBOL_REF_WEAK", (RTX), SYMBOL_REF)->return_val) 2721 2722 /* A pointer attached to the SYMBOL_REF; either SYMBOL_REF_DECL or 2723 SYMBOL_REF_CONSTANT. */ 2724 #define SYMBOL_REF_DATA(RTX) X0ANY ((RTX), 1) 2725 2726 /* Set RTX's SYMBOL_REF_DECL to DECL. RTX must not be a constant 2727 pool symbol. */ 2728 #define SET_SYMBOL_REF_DECL(RTX, DECL) \ 2729 (gcc_assert (!CONSTANT_POOL_ADDRESS_P (RTX)), X0TREE ((RTX), 1) = (DECL)) 2730 2731 /* The tree (decl or constant) associated with the symbol, or null. */ 2732 #define SYMBOL_REF_DECL(RTX) \ 2733 (CONSTANT_POOL_ADDRESS_P (RTX) ? NULL : X0TREE ((RTX), 1)) 2734 2735 /* Set RTX's SYMBOL_REF_CONSTANT to C. RTX must be a constant pool symbol. */ 2736 #define SET_SYMBOL_REF_CONSTANT(RTX, C) \ 2737 (gcc_assert (CONSTANT_POOL_ADDRESS_P (RTX)), X0CONSTANT ((RTX), 1) = (C)) 2738 2739 /* The rtx constant pool entry for a symbol, or null. */ 2740 #define SYMBOL_REF_CONSTANT(RTX) \ 2741 (CONSTANT_POOL_ADDRESS_P (RTX) ? X0CONSTANT ((RTX), 1) : NULL) 2742 2743 /* A set of flags on a symbol_ref that are, in some respects, redundant with 2744 information derivable from the tree decl associated with this symbol. 2745 Except that we build a *lot* of SYMBOL_REFs that aren't associated with a 2746 decl. In some cases this is a bug. But beyond that, it's nice to cache 2747 this information to avoid recomputing it. Finally, this allows space for 2748 the target to store more than one bit of information, as with 2749 SYMBOL_REF_FLAG. */ 2750 #define SYMBOL_REF_FLAGS(RTX) \ 2751 (RTL_FLAG_CHECK1 ("SYMBOL_REF_FLAGS", (RTX), SYMBOL_REF) \ 2752 ->u2.symbol_ref_flags) 2753 2754 /* These flags are common enough to be defined for all targets. They 2755 are computed by the default version of targetm.encode_section_info. */ 2756 2757 /* Set if this symbol is a function. */ 2758 #define SYMBOL_FLAG_FUNCTION (1 << 0) 2759 #define SYMBOL_REF_FUNCTION_P(RTX) \ 2760 ((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_FUNCTION) != 0) 2761 /* Set if targetm.binds_local_p is true. */ 2762 #define SYMBOL_FLAG_LOCAL (1 << 1) 2763 #define SYMBOL_REF_LOCAL_P(RTX) \ 2764 ((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_LOCAL) != 0) 2765 /* Set if targetm.in_small_data_p is true. */ 2766 #define SYMBOL_FLAG_SMALL (1 << 2) 2767 #define SYMBOL_REF_SMALL_P(RTX) \ 2768 ((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_SMALL) != 0) 2769 /* The three-bit field at [5:3] is true for TLS variables; use 2770 SYMBOL_REF_TLS_MODEL to extract the field as an enum tls_model. */ 2771 #define SYMBOL_FLAG_TLS_SHIFT 3 2772 #define SYMBOL_REF_TLS_MODEL(RTX) \ 2773 ((enum tls_model) ((SYMBOL_REF_FLAGS (RTX) >> SYMBOL_FLAG_TLS_SHIFT) & 7)) 2774 /* Set if this symbol is not defined in this translation unit. */ 2775 #define SYMBOL_FLAG_EXTERNAL (1 << 6) 2776 #define SYMBOL_REF_EXTERNAL_P(RTX) \ 2777 ((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_EXTERNAL) != 0) 2778 /* Set if this symbol has a block_symbol structure associated with it. */ 2779 #define SYMBOL_FLAG_HAS_BLOCK_INFO (1 << 7) 2780 #define SYMBOL_REF_HAS_BLOCK_INFO_P(RTX) \ 2781 ((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_HAS_BLOCK_INFO) != 0) 2782 /* Set if this symbol is a section anchor. SYMBOL_REF_ANCHOR_P implies 2783 SYMBOL_REF_HAS_BLOCK_INFO_P. */ 2784 #define SYMBOL_FLAG_ANCHOR (1 << 8) 2785 #define SYMBOL_REF_ANCHOR_P(RTX) \ 2786 ((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_ANCHOR) != 0) 2787 2788 /* Subsequent bits are available for the target to use. */ 2789 #define SYMBOL_FLAG_MACH_DEP_SHIFT 9 2790 #define SYMBOL_FLAG_MACH_DEP (1 << SYMBOL_FLAG_MACH_DEP_SHIFT) 2791 2792 /* If SYMBOL_REF_HAS_BLOCK_INFO_P (RTX), this is the object_block 2793 structure to which the symbol belongs, or NULL if it has not been 2794 assigned a block. */ 2795 #define SYMBOL_REF_BLOCK(RTX) (BLOCK_SYMBOL_CHECK (RTX)->block) 2796 2797 /* If SYMBOL_REF_HAS_BLOCK_INFO_P (RTX), this is the offset of RTX from 2798 the first object in SYMBOL_REF_BLOCK (RTX). The value is negative if 2799 RTX has not yet been assigned to a block, or it has not been given an 2800 offset within that block. */ 2801 #define SYMBOL_REF_BLOCK_OFFSET(RTX) (BLOCK_SYMBOL_CHECK (RTX)->offset) 2802 2803 /* True if RTX is flagged to be a scheduling barrier. */ 2804 #define PREFETCH_SCHEDULE_BARRIER_P(RTX) \ 2805 (RTL_FLAG_CHECK1 ("PREFETCH_SCHEDULE_BARRIER_P", (RTX), PREFETCH)->volatil) 2806 2807 /* Indicate whether the machine has any sort of auto increment addressing. 2808 If not, we can avoid checking for REG_INC notes. */ 2809 2810 #if (defined (HAVE_PRE_INCREMENT) || defined (HAVE_PRE_DECREMENT) \ 2811 || defined (HAVE_POST_INCREMENT) || defined (HAVE_POST_DECREMENT) \ 2812 || defined (HAVE_PRE_MODIFY_DISP) || defined (HAVE_POST_MODIFY_DISP) \ 2813 || defined (HAVE_PRE_MODIFY_REG) || defined (HAVE_POST_MODIFY_REG)) 2814 #define AUTO_INC_DEC 1 2815 #else 2816 #define AUTO_INC_DEC 0 2817 #endif 2818 2819 /* Define a macro to look for REG_INC notes, 2820 but save time on machines where they never exist. */ 2821 2822 #if AUTO_INC_DEC 2823 #define FIND_REG_INC_NOTE(INSN, REG) \ 2824 ((REG) != NULL_RTX && REG_P ((REG)) \ 2825 ? find_regno_note ((INSN), REG_INC, REGNO (REG)) \ 2826 : find_reg_note ((INSN), REG_INC, (REG))) 2827 #else 2828 #define FIND_REG_INC_NOTE(INSN, REG) 0 2829 #endif 2830 2831 #ifndef HAVE_PRE_INCREMENT 2832 #define HAVE_PRE_INCREMENT 0 2833 #endif 2834 2835 #ifndef HAVE_PRE_DECREMENT 2836 #define HAVE_PRE_DECREMENT 0 2837 #endif 2838 2839 #ifndef HAVE_POST_INCREMENT 2840 #define HAVE_POST_INCREMENT 0 2841 #endif 2842 2843 #ifndef HAVE_POST_DECREMENT 2844 #define HAVE_POST_DECREMENT 0 2845 #endif 2846 2847 #ifndef HAVE_POST_MODIFY_DISP 2848 #define HAVE_POST_MODIFY_DISP 0 2849 #endif 2850 2851 #ifndef HAVE_POST_MODIFY_REG 2852 #define HAVE_POST_MODIFY_REG 0 2853 #endif 2854 2855 #ifndef HAVE_PRE_MODIFY_DISP 2856 #define HAVE_PRE_MODIFY_DISP 0 2857 #endif 2858 2859 #ifndef HAVE_PRE_MODIFY_REG 2860 #define HAVE_PRE_MODIFY_REG 0 2861 #endif 2862 2863 2864 /* Some architectures do not have complete pre/post increment/decrement 2865 instruction sets, or only move some modes efficiently. These macros 2866 allow us to tune autoincrement generation. */ 2867 2868 #ifndef USE_LOAD_POST_INCREMENT 2869 #define USE_LOAD_POST_INCREMENT(MODE) HAVE_POST_INCREMENT 2870 #endif 2871 2872 #ifndef USE_LOAD_POST_DECREMENT 2873 #define USE_LOAD_POST_DECREMENT(MODE) HAVE_POST_DECREMENT 2874 #endif 2875 2876 #ifndef USE_LOAD_PRE_INCREMENT 2877 #define USE_LOAD_PRE_INCREMENT(MODE) HAVE_PRE_INCREMENT 2878 #endif 2879 2880 #ifndef USE_LOAD_PRE_DECREMENT 2881 #define USE_LOAD_PRE_DECREMENT(MODE) HAVE_PRE_DECREMENT 2882 #endif 2883 2884 #ifndef USE_STORE_POST_INCREMENT 2885 #define USE_STORE_POST_INCREMENT(MODE) HAVE_POST_INCREMENT 2886 #endif 2887 2888 #ifndef USE_STORE_POST_DECREMENT 2889 #define USE_STORE_POST_DECREMENT(MODE) HAVE_POST_DECREMENT 2890 #endif 2891 2892 #ifndef USE_STORE_PRE_INCREMENT 2893 #define USE_STORE_PRE_INCREMENT(MODE) HAVE_PRE_INCREMENT 2894 #endif 2895 2896 #ifndef USE_STORE_PRE_DECREMENT 2897 #define USE_STORE_PRE_DECREMENT(MODE) HAVE_PRE_DECREMENT 2898 #endif 2899 2900 /* Nonzero when we are generating CONCATs. */ 2901 extern int generating_concat_p; 2902 2903 /* Nonzero when we are expanding trees to RTL. */ 2904 extern int currently_expanding_to_rtl; 2905 2906 /* Generally useful functions. */ 2907 2908 #ifndef GENERATOR_FILE 2909 /* Return the cost of SET X. SPEED_P is true if optimizing for speed 2910 rather than size. */ 2911 2912 static inline int 2913 set_rtx_cost (rtx x, bool speed_p) 2914 { 2915 return rtx_cost (x, VOIDmode, INSN, 4, speed_p); 2916 } 2917 2918 /* Like set_rtx_cost, but return both the speed and size costs in C. */ 2919 2920 static inline void 2921 get_full_set_rtx_cost (rtx x, struct full_rtx_costs *c) 2922 { 2923 get_full_rtx_cost (x, VOIDmode, INSN, 4, c); 2924 } 2925 2926 /* Return the cost of moving X into a register, relative to the cost 2927 of a register move. SPEED_P is true if optimizing for speed rather 2928 than size. */ 2929 2930 static inline int 2931 set_src_cost (rtx x, machine_mode mode, bool speed_p) 2932 { 2933 return rtx_cost (x, mode, SET, 1, speed_p); 2934 } 2935 2936 /* Like set_src_cost, but return both the speed and size costs in C. */ 2937 2938 static inline void 2939 get_full_set_src_cost (rtx x, machine_mode mode, struct full_rtx_costs *c) 2940 { 2941 get_full_rtx_cost (x, mode, SET, 1, c); 2942 } 2943 #endif 2944 2945 /* A convenience macro to validate the arguments of a zero_extract 2946 expression. It determines whether SIZE lies inclusively within 2947 [1, RANGE], POS lies inclusively within between [0, RANGE - 1] 2948 and the sum lies inclusively within [1, RANGE]. RANGE must be 2949 >= 1, but SIZE and POS may be negative. */ 2950 #define EXTRACT_ARGS_IN_RANGE(SIZE, POS, RANGE) \ 2951 (IN_RANGE ((POS), 0, (unsigned HOST_WIDE_INT) (RANGE) - 1) \ 2952 && IN_RANGE ((SIZE), 1, (unsigned HOST_WIDE_INT) (RANGE) \ 2953 - (unsigned HOST_WIDE_INT)(POS))) 2954 2955 /* In explow.c */ 2956 extern HOST_WIDE_INT trunc_int_for_mode (HOST_WIDE_INT, machine_mode); 2957 extern poly_int64 trunc_int_for_mode (poly_int64, machine_mode); 2958 extern rtx plus_constant (machine_mode, rtx, poly_int64, bool = false); 2959 extern HOST_WIDE_INT get_stack_check_protect (void); 2960 2961 /* In rtl.c */ 2962 extern rtx rtx_alloc (RTX_CODE CXX_MEM_STAT_INFO); 2963 inline rtx 2964 rtx_init (rtx rt, RTX_CODE code) 2965 { 2966 memset (rt, 0, RTX_HDR_SIZE); 2967 PUT_CODE (rt, code); 2968 return rt; 2969 } 2970 #define rtx_alloca(code) \ 2971 rtx_init ((rtx) alloca (RTX_CODE_SIZE ((code))), (code)) 2972 extern rtx rtx_alloc_stat_v (RTX_CODE MEM_STAT_DECL, int); 2973 #define rtx_alloc_v(c, SZ) rtx_alloc_stat_v (c MEM_STAT_INFO, SZ) 2974 #define const_wide_int_alloc(NWORDS) \ 2975 rtx_alloc_v (CONST_WIDE_INT, \ 2976 (sizeof (struct hwivec_def) \ 2977 + ((NWORDS)-1) * sizeof (HOST_WIDE_INT))) \ 2978 2979 extern rtvec rtvec_alloc (int); 2980 extern rtvec shallow_copy_rtvec (rtvec); 2981 extern bool shared_const_p (const_rtx); 2982 extern rtx copy_rtx (rtx); 2983 extern enum rtx_code classify_insn (rtx); 2984 extern void dump_rtx_statistics (void); 2985 2986 /* In emit-rtl.c */ 2987 extern rtx copy_rtx_if_shared (rtx); 2988 2989 /* In rtl.c */ 2990 extern unsigned int rtx_size (const_rtx); 2991 extern rtx shallow_copy_rtx (const_rtx CXX_MEM_STAT_INFO); 2992 extern int rtx_equal_p (const_rtx, const_rtx); 2993 extern bool rtvec_all_equal_p (const_rtvec); 2994 2995 /* Return true if X is a vector constant with a duplicated element value. */ 2996 2997 inline bool 2998 const_vec_duplicate_p (const_rtx x) 2999 { 3000 return (GET_CODE (x) == CONST_VECTOR 3001 && CONST_VECTOR_NPATTERNS (x) == 1 3002 && CONST_VECTOR_DUPLICATE_P (x)); 3003 } 3004 3005 /* Return true if X is a vector constant with a duplicated element value. 3006 Store the duplicated element in *ELT if so. */ 3007 3008 template <typename T> 3009 inline bool 3010 const_vec_duplicate_p (T x, T *elt) 3011 { 3012 if (const_vec_duplicate_p (x)) 3013 { 3014 *elt = CONST_VECTOR_ENCODED_ELT (x, 0); 3015 return true; 3016 } 3017 return false; 3018 } 3019 3020 /* Return true if X is a vector with a duplicated element value, either 3021 constant or nonconstant. Store the duplicated element in *ELT if so. */ 3022 3023 template <typename T> 3024 inline bool 3025 vec_duplicate_p (T x, T *elt) 3026 { 3027 if (GET_CODE (x) == VEC_DUPLICATE 3028 && !VECTOR_MODE_P (GET_MODE (XEXP (x, 0)))) 3029 { 3030 *elt = XEXP (x, 0); 3031 return true; 3032 } 3033 return const_vec_duplicate_p (x, elt); 3034 } 3035 3036 /* If X is a vector constant with a duplicated element value, return that 3037 element value, otherwise return X. */ 3038 3039 template <typename T> 3040 inline T 3041 unwrap_const_vec_duplicate (T x) 3042 { 3043 if (const_vec_duplicate_p (x)) 3044 x = CONST_VECTOR_ELT (x, 0); 3045 return x; 3046 } 3047 3048 /* In emit-rtl.c. */ 3049 extern wide_int const_vector_int_elt (const_rtx, unsigned int); 3050 extern rtx const_vector_elt (const_rtx, unsigned int); 3051 extern bool const_vec_series_p_1 (const_rtx, rtx *, rtx *); 3052 3053 /* Return true if X is an integer constant vector that contains a linear 3054 series of the form: 3055 3056 { B, B + S, B + 2 * S, B + 3 * S, ... } 3057 3058 for a nonzero S. Store B and S in *BASE_OUT and *STEP_OUT on sucess. */ 3059 3060 inline bool 3061 const_vec_series_p (const_rtx x, rtx *base_out, rtx *step_out) 3062 { 3063 if (GET_CODE (x) == CONST_VECTOR 3064 && CONST_VECTOR_NPATTERNS (x) == 1 3065 && !CONST_VECTOR_DUPLICATE_P (x)) 3066 return const_vec_series_p_1 (x, base_out, step_out); 3067 return false; 3068 } 3069 3070 /* Return true if X is a vector that contains a linear series of the 3071 form: 3072 3073 { B, B + S, B + 2 * S, B + 3 * S, ... } 3074 3075 where B and S are constant or nonconstant. Store B and S in 3076 *BASE_OUT and *STEP_OUT on sucess. */ 3077 3078 inline bool 3079 vec_series_p (const_rtx x, rtx *base_out, rtx *step_out) 3080 { 3081 if (GET_CODE (x) == VEC_SERIES) 3082 { 3083 *base_out = XEXP (x, 0); 3084 *step_out = XEXP (x, 1); 3085 return true; 3086 } 3087 return const_vec_series_p (x, base_out, step_out); 3088 } 3089 3090 /* Return true if CONST_VECTORs X and Y, which are known to have the same mode, 3091 also have the same encoding. This means that they are equal whenever their 3092 operands are equal. */ 3093 3094 inline bool 3095 same_vector_encodings_p (const_rtx x, const_rtx y) 3096 { 3097 /* Don't be fussy about the encoding of constant-length vectors, 3098 since XVECEXP (X, 0) and XVECEXP (Y, 0) list all the elements anyway. */ 3099 if (poly_uint64 (CONST_VECTOR_NUNITS (x)).is_constant ()) 3100 return true; 3101 3102 return (CONST_VECTOR_NPATTERNS (x) == CONST_VECTOR_NPATTERNS (y) 3103 && (CONST_VECTOR_NELTS_PER_PATTERN (x) 3104 == CONST_VECTOR_NELTS_PER_PATTERN (y))); 3105 } 3106 3107 /* Return the unpromoted (outer) mode of SUBREG_PROMOTED_VAR_P subreg X. */ 3108 3109 inline scalar_int_mode 3110 subreg_unpromoted_mode (rtx x) 3111 { 3112 gcc_checking_assert (SUBREG_PROMOTED_VAR_P (x)); 3113 return as_a <scalar_int_mode> (GET_MODE (x)); 3114 } 3115 3116 /* Return the promoted (inner) mode of SUBREG_PROMOTED_VAR_P subreg X. */ 3117 3118 inline scalar_int_mode 3119 subreg_promoted_mode (rtx x) 3120 { 3121 gcc_checking_assert (SUBREG_PROMOTED_VAR_P (x)); 3122 return as_a <scalar_int_mode> (GET_MODE (SUBREG_REG (x))); 3123 } 3124 3125 /* In emit-rtl.c */ 3126 extern rtvec gen_rtvec_v (int, rtx *); 3127 extern rtvec gen_rtvec_v (int, rtx_insn **); 3128 extern rtx gen_reg_rtx (machine_mode); 3129 extern rtx gen_rtx_REG_offset (rtx, machine_mode, unsigned int, poly_int64); 3130 extern rtx gen_reg_rtx_offset (rtx, machine_mode, int); 3131 extern rtx gen_reg_rtx_and_attrs (rtx); 3132 extern rtx_code_label *gen_label_rtx (void); 3133 extern rtx gen_lowpart_common (machine_mode, rtx); 3134 3135 /* In cse.c */ 3136 extern rtx gen_lowpart_if_possible (machine_mode, rtx); 3137 3138 /* In emit-rtl.c */ 3139 extern rtx gen_highpart (machine_mode, rtx); 3140 extern rtx gen_highpart_mode (machine_mode, machine_mode, rtx); 3141 extern rtx operand_subword (rtx, poly_uint64, int, machine_mode); 3142 3143 /* In emit-rtl.c */ 3144 extern rtx operand_subword_force (rtx, poly_uint64, machine_mode); 3145 extern int subreg_lowpart_p (const_rtx); 3146 extern poly_uint64 subreg_size_lowpart_offset (poly_uint64, poly_uint64); 3147 3148 /* Return true if a subreg of mode OUTERMODE would only access part of 3149 an inner register with mode INNERMODE. The other bits of the inner 3150 register would then be "don't care" on read. The behavior for writes 3151 depends on REGMODE_NATURAL_SIZE; bits in the same REGMODE_NATURAL_SIZE-d 3152 chunk would be clobbered but other bits would be preserved. */ 3153 3154 inline bool 3155 partial_subreg_p (machine_mode outermode, machine_mode innermode) 3156 { 3157 /* Modes involved in a subreg must be ordered. In particular, we must 3158 always know at compile time whether the subreg is paradoxical. */ 3159 poly_int64 outer_prec = GET_MODE_PRECISION (outermode); 3160 poly_int64 inner_prec = GET_MODE_PRECISION (innermode); 3161 gcc_checking_assert (ordered_p (outer_prec, inner_prec)); 3162 return maybe_lt (outer_prec, inner_prec); 3163 } 3164 3165 /* Likewise return true if X is a subreg that is smaller than the inner 3166 register. Use read_modify_subreg_p to test whether writing to such 3167 a subreg preserves any part of the inner register. */ 3168 3169 inline bool 3170 partial_subreg_p (const_rtx x) 3171 { 3172 if (GET_CODE (x) != SUBREG) 3173 return false; 3174 return partial_subreg_p (GET_MODE (x), GET_MODE (SUBREG_REG (x))); 3175 } 3176 3177 /* Return true if a subreg with the given outer and inner modes is 3178 paradoxical. */ 3179 3180 inline bool 3181 paradoxical_subreg_p (machine_mode outermode, machine_mode innermode) 3182 { 3183 /* Modes involved in a subreg must be ordered. In particular, we must 3184 always know at compile time whether the subreg is paradoxical. */ 3185 poly_int64 outer_prec = GET_MODE_PRECISION (outermode); 3186 poly_int64 inner_prec = GET_MODE_PRECISION (innermode); 3187 gcc_checking_assert (ordered_p (outer_prec, inner_prec)); 3188 return maybe_gt (outer_prec, inner_prec); 3189 } 3190 3191 /* Return true if X is a paradoxical subreg, false otherwise. */ 3192 3193 inline bool 3194 paradoxical_subreg_p (const_rtx x) 3195 { 3196 if (GET_CODE (x) != SUBREG) 3197 return false; 3198 return paradoxical_subreg_p (GET_MODE (x), GET_MODE (SUBREG_REG (x))); 3199 } 3200 3201 /* Return the SUBREG_BYTE for an OUTERMODE lowpart of an INNERMODE value. */ 3202 3203 inline poly_uint64 3204 subreg_lowpart_offset (machine_mode outermode, machine_mode innermode) 3205 { 3206 return subreg_size_lowpart_offset (GET_MODE_SIZE (outermode), 3207 GET_MODE_SIZE (innermode)); 3208 } 3209 3210 /* Given that a subreg has outer mode OUTERMODE and inner mode INNERMODE, 3211 return the smaller of the two modes if they are different sizes, 3212 otherwise return the outer mode. */ 3213 3214 inline machine_mode 3215 narrower_subreg_mode (machine_mode outermode, machine_mode innermode) 3216 { 3217 return paradoxical_subreg_p (outermode, innermode) ? innermode : outermode; 3218 } 3219 3220 /* Given that a subreg has outer mode OUTERMODE and inner mode INNERMODE, 3221 return the mode that is big enough to hold both the outer and inner 3222 values. Prefer the outer mode in the event of a tie. */ 3223 3224 inline machine_mode 3225 wider_subreg_mode (machine_mode outermode, machine_mode innermode) 3226 { 3227 return partial_subreg_p (outermode, innermode) ? innermode : outermode; 3228 } 3229 3230 /* Likewise for subreg X. */ 3231 3232 inline machine_mode 3233 wider_subreg_mode (const_rtx x) 3234 { 3235 return wider_subreg_mode (GET_MODE (x), GET_MODE (SUBREG_REG (x))); 3236 } 3237 3238 extern poly_uint64 subreg_size_highpart_offset (poly_uint64, poly_uint64); 3239 3240 /* Return the SUBREG_BYTE for an OUTERMODE highpart of an INNERMODE value. */ 3241 3242 inline poly_uint64 3243 subreg_highpart_offset (machine_mode outermode, machine_mode innermode) 3244 { 3245 return subreg_size_highpart_offset (GET_MODE_SIZE (outermode), 3246 GET_MODE_SIZE (innermode)); 3247 } 3248 3249 extern poly_int64 byte_lowpart_offset (machine_mode, machine_mode); 3250 extern poly_int64 subreg_memory_offset (machine_mode, machine_mode, 3251 poly_uint64); 3252 extern poly_int64 subreg_memory_offset (const_rtx); 3253 extern rtx make_safe_from (rtx, rtx); 3254 extern rtx convert_memory_address_addr_space_1 (scalar_int_mode, rtx, 3255 addr_space_t, bool, bool); 3256 extern rtx convert_memory_address_addr_space (scalar_int_mode, rtx, 3257 addr_space_t); 3258 #define convert_memory_address(to_mode,x) \ 3259 convert_memory_address_addr_space ((to_mode), (x), ADDR_SPACE_GENERIC) 3260 extern const char *get_insn_name (int); 3261 extern rtx_insn *get_last_insn_anywhere (void); 3262 extern rtx_insn *get_first_nonnote_insn (void); 3263 extern rtx_insn *get_last_nonnote_insn (void); 3264 extern void start_sequence (void); 3265 extern void push_to_sequence (rtx_insn *); 3266 extern void push_to_sequence2 (rtx_insn *, rtx_insn *); 3267 extern void end_sequence (void); 3268 #if TARGET_SUPPORTS_WIDE_INT == 0 3269 extern double_int rtx_to_double_int (const_rtx); 3270 #endif 3271 extern void cwi_output_hex (FILE *, const_rtx); 3272 #if TARGET_SUPPORTS_WIDE_INT == 0 3273 extern rtx immed_double_const (HOST_WIDE_INT, HOST_WIDE_INT, 3274 machine_mode); 3275 #endif 3276 extern rtx immed_wide_int_const (const poly_wide_int_ref &, machine_mode); 3277 3278 /* In varasm.c */ 3279 extern rtx force_const_mem (machine_mode, rtx); 3280 3281 /* In varasm.c */ 3282 3283 struct function; 3284 extern rtx get_pool_constant (const_rtx); 3285 extern rtx get_pool_constant_mark (rtx, bool *); 3286 extern fixed_size_mode get_pool_mode (const_rtx); 3287 extern rtx simplify_subtraction (rtx); 3288 extern void decide_function_section (tree); 3289 3290 /* In emit-rtl.c */ 3291 extern rtx_insn *emit_insn_before (rtx, rtx_insn *); 3292 extern rtx_insn *emit_insn_before_noloc (rtx, rtx_insn *, basic_block); 3293 extern rtx_insn *emit_insn_before_setloc (rtx, rtx_insn *, location_t); 3294 extern rtx_jump_insn *emit_jump_insn_before (rtx, rtx_insn *); 3295 extern rtx_jump_insn *emit_jump_insn_before_noloc (rtx, rtx_insn *); 3296 extern rtx_jump_insn *emit_jump_insn_before_setloc (rtx, rtx_insn *, 3297 location_t); 3298 extern rtx_insn *emit_call_insn_before (rtx, rtx_insn *); 3299 extern rtx_insn *emit_call_insn_before_noloc (rtx, rtx_insn *); 3300 extern rtx_insn *emit_call_insn_before_setloc (rtx, rtx_insn *, location_t); 3301 extern rtx_insn *emit_debug_insn_before (rtx, rtx_insn *); 3302 extern rtx_insn *emit_debug_insn_before_noloc (rtx, rtx_insn *); 3303 extern rtx_insn *emit_debug_insn_before_setloc (rtx, rtx_insn *, location_t); 3304 extern rtx_barrier *emit_barrier_before (rtx_insn *); 3305 extern rtx_code_label *emit_label_before (rtx_code_label *, rtx_insn *); 3306 extern rtx_note *emit_note_before (enum insn_note, rtx_insn *); 3307 extern rtx_insn *emit_insn_after (rtx, rtx_insn *); 3308 extern rtx_insn *emit_insn_after_noloc (rtx, rtx_insn *, basic_block); 3309 extern rtx_insn *emit_insn_after_setloc (rtx, rtx_insn *, location_t); 3310 extern rtx_jump_insn *emit_jump_insn_after (rtx, rtx_insn *); 3311 extern rtx_jump_insn *emit_jump_insn_after_noloc (rtx, rtx_insn *); 3312 extern rtx_jump_insn *emit_jump_insn_after_setloc (rtx, rtx_insn *, location_t); 3313 extern rtx_insn *emit_call_insn_after (rtx, rtx_insn *); 3314 extern rtx_insn *emit_call_insn_after_noloc (rtx, rtx_insn *); 3315 extern rtx_insn *emit_call_insn_after_setloc (rtx, rtx_insn *, location_t); 3316 extern rtx_insn *emit_debug_insn_after (rtx, rtx_insn *); 3317 extern rtx_insn *emit_debug_insn_after_noloc (rtx, rtx_insn *); 3318 extern rtx_insn *emit_debug_insn_after_setloc (rtx, rtx_insn *, location_t); 3319 extern rtx_barrier *emit_barrier_after (rtx_insn *); 3320 extern rtx_insn *emit_label_after (rtx_insn *, rtx_insn *); 3321 extern rtx_note *emit_note_after (enum insn_note, rtx_insn *); 3322 extern rtx_insn *emit_insn (rtx); 3323 extern rtx_insn *emit_debug_insn (rtx); 3324 extern rtx_insn *emit_jump_insn (rtx); 3325 extern rtx_insn *emit_call_insn (rtx); 3326 extern rtx_code_label *emit_label (rtx); 3327 extern rtx_jump_table_data *emit_jump_table_data (rtx); 3328 extern rtx_barrier *emit_barrier (void); 3329 extern rtx_note *emit_note (enum insn_note); 3330 extern rtx_note *emit_note_copy (rtx_note *); 3331 extern rtx_insn *gen_clobber (rtx); 3332 extern rtx_insn *emit_clobber (rtx); 3333 extern rtx_insn *gen_use (rtx); 3334 extern rtx_insn *emit_use (rtx); 3335 extern rtx_insn *make_insn_raw (rtx); 3336 extern void add_function_usage_to (rtx, rtx); 3337 extern rtx_call_insn *last_call_insn (void); 3338 extern rtx_insn *previous_insn (rtx_insn *); 3339 extern rtx_insn *next_insn (rtx_insn *); 3340 extern rtx_insn *prev_nonnote_insn (rtx_insn *); 3341 extern rtx_insn *next_nonnote_insn (rtx_insn *); 3342 extern rtx_insn *prev_nondebug_insn (rtx_insn *); 3343 extern rtx_insn *next_nondebug_insn (rtx_insn *); 3344 extern rtx_insn *prev_nonnote_nondebug_insn (rtx_insn *); 3345 extern rtx_insn *prev_nonnote_nondebug_insn_bb (rtx_insn *); 3346 extern rtx_insn *next_nonnote_nondebug_insn (rtx_insn *); 3347 extern rtx_insn *next_nonnote_nondebug_insn_bb (rtx_insn *); 3348 extern rtx_insn *prev_real_insn (rtx_insn *); 3349 extern rtx_insn *next_real_insn (rtx_insn *); 3350 extern rtx_insn *prev_real_nondebug_insn (rtx_insn *); 3351 extern rtx_insn *next_real_nondebug_insn (rtx); 3352 extern rtx_insn *prev_active_insn (rtx_insn *); 3353 extern rtx_insn *next_active_insn (rtx_insn *); 3354 extern int active_insn_p (const rtx_insn *); 3355 extern rtx_insn *next_cc0_user (rtx_insn *); 3356 extern rtx_insn *prev_cc0_setter (rtx_insn *); 3357 3358 /* In emit-rtl.c */ 3359 extern int insn_line (const rtx_insn *); 3360 extern const char * insn_file (const rtx_insn *); 3361 extern tree insn_scope (const rtx_insn *); 3362 extern expanded_location insn_location (const rtx_insn *); 3363 extern location_t prologue_location, epilogue_location; 3364 3365 /* In jump.c */ 3366 extern enum rtx_code reverse_condition (enum rtx_code); 3367 extern enum rtx_code reverse_condition_maybe_unordered (enum rtx_code); 3368 extern enum rtx_code swap_condition (enum rtx_code); 3369 extern enum rtx_code unsigned_condition (enum rtx_code); 3370 extern enum rtx_code signed_condition (enum rtx_code); 3371 extern void mark_jump_label (rtx, rtx_insn *, int); 3372 3373 /* Return true if integer comparison operator CODE interprets its operands 3374 as unsigned. */ 3375 3376 inline bool 3377 unsigned_condition_p (enum rtx_code code) 3378 { 3379 return unsigned_condition (code) == code; 3380 } 3381 3382 /* In jump.c */ 3383 extern rtx_insn *delete_related_insns (rtx); 3384 3385 /* In recog.c */ 3386 extern rtx *find_constant_term_loc (rtx *); 3387 3388 /* In emit-rtl.c */ 3389 extern rtx_insn *try_split (rtx, rtx_insn *, int); 3390 3391 /* In insn-recog.c (generated by genrecog). */ 3392 extern rtx_insn *split_insns (rtx, rtx_insn *); 3393 3394 /* In simplify-rtx.c */ 3395 extern rtx simplify_const_unary_operation (enum rtx_code, machine_mode, 3396 rtx, machine_mode); 3397 extern rtx simplify_unary_operation (enum rtx_code, machine_mode, rtx, 3398 machine_mode); 3399 extern rtx simplify_const_binary_operation (enum rtx_code, machine_mode, 3400 rtx, rtx); 3401 extern rtx simplify_binary_operation (enum rtx_code, machine_mode, rtx, 3402 rtx); 3403 extern rtx simplify_ternary_operation (enum rtx_code, machine_mode, 3404 machine_mode, rtx, rtx, rtx); 3405 extern rtx simplify_const_relational_operation (enum rtx_code, 3406 machine_mode, rtx, rtx); 3407 extern rtx simplify_relational_operation (enum rtx_code, machine_mode, 3408 machine_mode, rtx, rtx); 3409 extern rtx simplify_gen_binary (enum rtx_code, machine_mode, rtx, rtx); 3410 extern rtx simplify_gen_unary (enum rtx_code, machine_mode, rtx, 3411 machine_mode); 3412 extern rtx simplify_gen_ternary (enum rtx_code, machine_mode, 3413 machine_mode, rtx, rtx, rtx); 3414 extern rtx simplify_gen_relational (enum rtx_code, machine_mode, 3415 machine_mode, rtx, rtx); 3416 extern rtx simplify_subreg (machine_mode, rtx, machine_mode, poly_uint64); 3417 extern rtx simplify_gen_subreg (machine_mode, rtx, machine_mode, poly_uint64); 3418 extern rtx lowpart_subreg (machine_mode, rtx, machine_mode); 3419 extern rtx simplify_replace_fn_rtx (rtx, const_rtx, 3420 rtx (*fn) (rtx, const_rtx, void *), void *); 3421 extern rtx simplify_replace_rtx (rtx, const_rtx, rtx); 3422 extern rtx simplify_rtx (const_rtx); 3423 extern rtx avoid_constant_pool_reference (rtx); 3424 extern rtx delegitimize_mem_from_attrs (rtx); 3425 extern bool mode_signbit_p (machine_mode, const_rtx); 3426 extern bool val_signbit_p (machine_mode, unsigned HOST_WIDE_INT); 3427 extern bool val_signbit_known_set_p (machine_mode, 3428 unsigned HOST_WIDE_INT); 3429 extern bool val_signbit_known_clear_p (machine_mode, 3430 unsigned HOST_WIDE_INT); 3431 3432 /* In reginfo.c */ 3433 extern machine_mode choose_hard_reg_mode (unsigned int, unsigned int, 3434 const predefined_function_abi *); 3435 extern const HARD_REG_SET &simplifiable_subregs (const subreg_shape &); 3436 3437 /* In emit-rtl.c */ 3438 extern rtx set_for_reg_notes (rtx); 3439 extern rtx set_unique_reg_note (rtx, enum reg_note, rtx); 3440 extern rtx set_dst_reg_note (rtx, enum reg_note, rtx, rtx); 3441 extern void set_insn_deleted (rtx_insn *); 3442 3443 /* Functions in rtlanal.c */ 3444 3445 extern rtx single_set_2 (const rtx_insn *, const_rtx); 3446 extern bool contains_symbol_ref_p (const_rtx); 3447 extern bool contains_symbolic_reference_p (const_rtx); 3448 extern bool contains_constant_pool_address_p (const_rtx); 3449 3450 /* Handle the cheap and common cases inline for performance. */ 3451 3452 inline rtx single_set (const rtx_insn *insn) 3453 { 3454 if (!INSN_P (insn)) 3455 return NULL_RTX; 3456 3457 if (GET_CODE (PATTERN (insn)) == SET) 3458 return PATTERN (insn); 3459 3460 /* Defer to the more expensive case. */ 3461 return single_set_2 (insn, PATTERN (insn)); 3462 } 3463 3464 extern scalar_int_mode get_address_mode (rtx mem); 3465 extern int rtx_addr_can_trap_p (const_rtx); 3466 extern bool nonzero_address_p (const_rtx); 3467 extern int rtx_unstable_p (const_rtx); 3468 extern bool rtx_varies_p (const_rtx, bool); 3469 extern bool rtx_addr_varies_p (const_rtx, bool); 3470 extern rtx get_call_rtx_from (const rtx_insn *); 3471 extern tree get_call_fndecl (const rtx_insn *); 3472 extern HOST_WIDE_INT get_integer_term (const_rtx); 3473 extern rtx get_related_value (const_rtx); 3474 extern bool offset_within_block_p (const_rtx, HOST_WIDE_INT); 3475 extern void split_const (rtx, rtx *, rtx *); 3476 extern rtx strip_offset (rtx, poly_int64_pod *); 3477 extern poly_int64 get_args_size (const_rtx); 3478 extern bool unsigned_reg_p (rtx); 3479 extern int reg_mentioned_p (const_rtx, const_rtx); 3480 extern int count_occurrences (const_rtx, const_rtx, int); 3481 extern int reg_referenced_p (const_rtx, const_rtx); 3482 extern int reg_used_between_p (const_rtx, const rtx_insn *, const rtx_insn *); 3483 extern int reg_set_between_p (const_rtx, const rtx_insn *, const rtx_insn *); 3484 extern int commutative_operand_precedence (rtx); 3485 extern bool swap_commutative_operands_p (rtx, rtx); 3486 extern int modified_between_p (const_rtx, const rtx_insn *, const rtx_insn *); 3487 extern int no_labels_between_p (const rtx_insn *, const rtx_insn *); 3488 extern int modified_in_p (const_rtx, const_rtx); 3489 extern int reg_set_p (const_rtx, const_rtx); 3490 extern int multiple_sets (const_rtx); 3491 extern int set_noop_p (const_rtx); 3492 extern int noop_move_p (const rtx_insn *); 3493 extern bool refers_to_regno_p (unsigned int, unsigned int, const_rtx, rtx *); 3494 extern int reg_overlap_mentioned_p (const_rtx, const_rtx); 3495 extern const_rtx set_of (const_rtx, const_rtx); 3496 extern void record_hard_reg_sets (rtx, const_rtx, void *); 3497 extern void record_hard_reg_uses (rtx *, void *); 3498 extern void find_all_hard_regs (const_rtx, HARD_REG_SET *); 3499 extern void find_all_hard_reg_sets (const rtx_insn *, HARD_REG_SET *, bool); 3500 extern void note_pattern_stores (const_rtx, 3501 void (*) (rtx, const_rtx, void *), void *); 3502 extern void note_stores (const rtx_insn *, 3503 void (*) (rtx, const_rtx, void *), void *); 3504 extern void note_uses (rtx *, void (*) (rtx *, void *), void *); 3505 extern int dead_or_set_p (const rtx_insn *, const_rtx); 3506 extern int dead_or_set_regno_p (const rtx_insn *, unsigned int); 3507 extern rtx find_reg_note (const_rtx, enum reg_note, const_rtx); 3508 extern rtx find_regno_note (const_rtx, enum reg_note, unsigned int); 3509 extern rtx find_reg_equal_equiv_note (const_rtx); 3510 extern rtx find_constant_src (const rtx_insn *); 3511 extern int find_reg_fusage (const_rtx, enum rtx_code, const_rtx); 3512 extern int find_regno_fusage (const_rtx, enum rtx_code, unsigned int); 3513 extern rtx alloc_reg_note (enum reg_note, rtx, rtx); 3514 extern void add_reg_note (rtx, enum reg_note, rtx); 3515 extern void add_int_reg_note (rtx_insn *, enum reg_note, int); 3516 extern void add_args_size_note (rtx_insn *, poly_int64); 3517 extern void add_shallow_copy_of_reg_note (rtx_insn *, rtx); 3518 extern rtx duplicate_reg_note (rtx); 3519 extern void remove_note (rtx_insn *, const_rtx); 3520 extern bool remove_reg_equal_equiv_notes (rtx_insn *); 3521 extern void remove_reg_equal_equiv_notes_for_regno (unsigned int); 3522 extern int side_effects_p (const_rtx); 3523 extern int volatile_refs_p (const_rtx); 3524 extern int volatile_insn_p (const_rtx); 3525 extern int may_trap_p_1 (const_rtx, unsigned); 3526 extern int may_trap_p (const_rtx); 3527 extern int may_trap_or_fault_p (const_rtx); 3528 extern bool can_throw_internal (const_rtx); 3529 extern bool can_throw_external (const_rtx); 3530 extern bool insn_could_throw_p (const_rtx); 3531 extern bool insn_nothrow_p (const_rtx); 3532 extern bool can_nonlocal_goto (const rtx_insn *); 3533 extern void copy_reg_eh_region_note_forward (rtx, rtx_insn *, rtx); 3534 extern void copy_reg_eh_region_note_backward (rtx, rtx_insn *, rtx); 3535 extern rtx replace_rtx (rtx, rtx, rtx, bool = false); 3536 extern void replace_label (rtx *, rtx, rtx, bool); 3537 extern void replace_label_in_insn (rtx_insn *, rtx_insn *, rtx_insn *, bool); 3538 extern bool rtx_referenced_p (const_rtx, const_rtx); 3539 extern bool tablejump_p (const rtx_insn *, rtx_insn **, rtx_jump_table_data **); 3540 extern rtx tablejump_casesi_pattern (const rtx_insn *insn); 3541 extern int computed_jump_p (const rtx_insn *); 3542 extern bool tls_referenced_p (const_rtx); 3543 extern bool contains_mem_rtx_p (rtx x); 3544 3545 /* Overload for refers_to_regno_p for checking a single register. */ 3546 inline bool 3547 refers_to_regno_p (unsigned int regnum, const_rtx x, rtx* loc = NULL) 3548 { 3549 return refers_to_regno_p (regnum, regnum + 1, x, loc); 3550 } 3551 3552 /* Callback for for_each_inc_dec, to process the autoinc operation OP 3553 within MEM that sets DEST to SRC + SRCOFF, or SRC if SRCOFF is 3554 NULL. The callback is passed the same opaque ARG passed to 3555 for_each_inc_dec. Return zero to continue looking for other 3556 autoinc operations or any other value to interrupt the traversal and 3557 return that value to the caller of for_each_inc_dec. */ 3558 typedef int (*for_each_inc_dec_fn) (rtx mem, rtx op, rtx dest, rtx src, 3559 rtx srcoff, void *arg); 3560 extern int for_each_inc_dec (rtx, for_each_inc_dec_fn, void *arg); 3561 3562 typedef int (*rtx_equal_p_callback_function) (const_rtx *, const_rtx *, 3563 rtx *, rtx *); 3564 extern int rtx_equal_p_cb (const_rtx, const_rtx, 3565 rtx_equal_p_callback_function); 3566 3567 typedef int (*hash_rtx_callback_function) (const_rtx, machine_mode, rtx *, 3568 machine_mode *); 3569 extern unsigned hash_rtx_cb (const_rtx, machine_mode, int *, int *, 3570 bool, hash_rtx_callback_function); 3571 3572 extern rtx regno_use_in (unsigned int, rtx); 3573 extern int auto_inc_p (const_rtx); 3574 extern bool in_insn_list_p (const rtx_insn_list *, const rtx_insn *); 3575 extern void remove_node_from_expr_list (const_rtx, rtx_expr_list **); 3576 extern void remove_node_from_insn_list (const rtx_insn *, rtx_insn_list **); 3577 extern int loc_mentioned_in_p (rtx *, const_rtx); 3578 extern rtx_insn *find_first_parameter_load (rtx_insn *, rtx_insn *); 3579 extern bool keep_with_call_p (const rtx_insn *); 3580 extern bool label_is_jump_target_p (const_rtx, const rtx_insn *); 3581 extern int pattern_cost (rtx, bool); 3582 extern int insn_cost (rtx_insn *, bool); 3583 extern unsigned seq_cost (const rtx_insn *, bool); 3584 3585 /* Given an insn and condition, return a canonical description of 3586 the test being made. */ 3587 extern rtx canonicalize_condition (rtx_insn *, rtx, int, rtx_insn **, rtx, 3588 int, int); 3589 3590 /* Given a JUMP_INSN, return a canonical description of the test 3591 being made. */ 3592 extern rtx get_condition (rtx_insn *, rtx_insn **, int, int); 3593 3594 /* Information about a subreg of a hard register. */ 3595 struct subreg_info 3596 { 3597 /* Offset of first hard register involved in the subreg. */ 3598 int offset; 3599 /* Number of hard registers involved in the subreg. In the case of 3600 a paradoxical subreg, this is the number of registers that would 3601 be modified by writing to the subreg; some of them may be don't-care 3602 when reading from the subreg. */ 3603 int nregs; 3604 /* Whether this subreg can be represented as a hard reg with the new 3605 mode (by adding OFFSET to the original hard register). */ 3606 bool representable_p; 3607 }; 3608 3609 extern void subreg_get_info (unsigned int, machine_mode, 3610 poly_uint64, machine_mode, 3611 struct subreg_info *); 3612 3613 /* lists.c */ 3614 3615 extern void free_EXPR_LIST_list (rtx_expr_list **); 3616 extern void free_INSN_LIST_list (rtx_insn_list **); 3617 extern void free_EXPR_LIST_node (rtx); 3618 extern void free_INSN_LIST_node (rtx); 3619 extern rtx_insn_list *alloc_INSN_LIST (rtx, rtx); 3620 extern rtx_insn_list *copy_INSN_LIST (rtx_insn_list *); 3621 extern rtx_insn_list *concat_INSN_LIST (rtx_insn_list *, rtx_insn_list *); 3622 extern rtx_expr_list *alloc_EXPR_LIST (int, rtx, rtx); 3623 extern void remove_free_INSN_LIST_elem (rtx_insn *, rtx_insn_list **); 3624 extern rtx remove_list_elem (rtx, rtx *); 3625 extern rtx_insn *remove_free_INSN_LIST_node (rtx_insn_list **); 3626 extern rtx remove_free_EXPR_LIST_node (rtx_expr_list **); 3627 3628 3629 /* reginfo.c */ 3630 3631 /* Resize reg info. */ 3632 extern bool resize_reg_info (void); 3633 /* Free up register info memory. */ 3634 extern void free_reg_info (void); 3635 extern void init_subregs_of_mode (void); 3636 extern void finish_subregs_of_mode (void); 3637 3638 /* recog.c */ 3639 extern rtx extract_asm_operands (rtx); 3640 extern int asm_noperands (const_rtx); 3641 extern const char *decode_asm_operands (rtx, rtx *, rtx **, const char **, 3642 machine_mode *, location_t *); 3643 extern void get_referenced_operands (const char *, bool *, unsigned int); 3644 3645 extern enum reg_class reg_preferred_class (int); 3646 extern enum reg_class reg_alternate_class (int); 3647 extern enum reg_class reg_allocno_class (int); 3648 extern void setup_reg_classes (int, enum reg_class, enum reg_class, 3649 enum reg_class); 3650 3651 extern void split_all_insns (void); 3652 extern unsigned int split_all_insns_noflow (void); 3653 3654 #define MAX_SAVED_CONST_INT 64 3655 extern GTY(()) rtx const_int_rtx[MAX_SAVED_CONST_INT * 2 + 1]; 3656 3657 #define const0_rtx (const_int_rtx[MAX_SAVED_CONST_INT]) 3658 #define const1_rtx (const_int_rtx[MAX_SAVED_CONST_INT+1]) 3659 #define const2_rtx (const_int_rtx[MAX_SAVED_CONST_INT+2]) 3660 #define constm1_rtx (const_int_rtx[MAX_SAVED_CONST_INT-1]) 3661 extern GTY(()) rtx const_true_rtx; 3662 3663 extern GTY(()) rtx const_tiny_rtx[4][(int) MAX_MACHINE_MODE]; 3664 3665 /* Returns a constant 0 rtx in mode MODE. Integer modes are treated the 3666 same as VOIDmode. */ 3667 3668 #define CONST0_RTX(MODE) (const_tiny_rtx[0][(int) (MODE)]) 3669 3670 /* Likewise, for the constants 1 and 2 and -1. */ 3671 3672 #define CONST1_RTX(MODE) (const_tiny_rtx[1][(int) (MODE)]) 3673 #define CONST2_RTX(MODE) (const_tiny_rtx[2][(int) (MODE)]) 3674 #define CONSTM1_RTX(MODE) (const_tiny_rtx[3][(int) (MODE)]) 3675 3676 extern GTY(()) rtx pc_rtx; 3677 extern GTY(()) rtx cc0_rtx; 3678 extern GTY(()) rtx ret_rtx; 3679 extern GTY(()) rtx simple_return_rtx; 3680 extern GTY(()) rtx_insn *invalid_insn_rtx; 3681 3682 /* If HARD_FRAME_POINTER_REGNUM is defined, then a special dummy reg 3683 is used to represent the frame pointer. This is because the 3684 hard frame pointer and the automatic variables are separated by an amount 3685 that cannot be determined until after register allocation. We can assume 3686 that in this case ELIMINABLE_REGS will be defined, one action of which 3687 will be to eliminate FRAME_POINTER_REGNUM into HARD_FRAME_POINTER_REGNUM. */ 3688 #ifndef HARD_FRAME_POINTER_REGNUM 3689 #define HARD_FRAME_POINTER_REGNUM FRAME_POINTER_REGNUM 3690 #endif 3691 3692 #ifndef HARD_FRAME_POINTER_IS_FRAME_POINTER 3693 #define HARD_FRAME_POINTER_IS_FRAME_POINTER \ 3694 (HARD_FRAME_POINTER_REGNUM == FRAME_POINTER_REGNUM) 3695 #endif 3696 3697 #ifndef HARD_FRAME_POINTER_IS_ARG_POINTER 3698 #define HARD_FRAME_POINTER_IS_ARG_POINTER \ 3699 (HARD_FRAME_POINTER_REGNUM == ARG_POINTER_REGNUM) 3700 #endif 3701 3702 /* Index labels for global_rtl. */ 3703 enum global_rtl_index 3704 { 3705 GR_STACK_POINTER, 3706 GR_FRAME_POINTER, 3707 /* For register elimination to work properly these hard_frame_pointer_rtx, 3708 frame_pointer_rtx, and arg_pointer_rtx must be the same if they refer to 3709 the same register. */ 3710 #if FRAME_POINTER_REGNUM == ARG_POINTER_REGNUM 3711 GR_ARG_POINTER = GR_FRAME_POINTER, 3712 #endif 3713 #if HARD_FRAME_POINTER_IS_FRAME_POINTER 3714 GR_HARD_FRAME_POINTER = GR_FRAME_POINTER, 3715 #else 3716 GR_HARD_FRAME_POINTER, 3717 #endif 3718 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM 3719 #if HARD_FRAME_POINTER_IS_ARG_POINTER 3720 GR_ARG_POINTER = GR_HARD_FRAME_POINTER, 3721 #else 3722 GR_ARG_POINTER, 3723 #endif 3724 #endif 3725 GR_VIRTUAL_INCOMING_ARGS, 3726 GR_VIRTUAL_STACK_ARGS, 3727 GR_VIRTUAL_STACK_DYNAMIC, 3728 GR_VIRTUAL_OUTGOING_ARGS, 3729 GR_VIRTUAL_CFA, 3730 GR_VIRTUAL_PREFERRED_STACK_BOUNDARY, 3731 3732 GR_MAX 3733 }; 3734 3735 /* Target-dependent globals. */ 3736 struct GTY(()) target_rtl { 3737 /* All references to the hard registers in global_rtl_index go through 3738 these unique rtl objects. On machines where the frame-pointer and 3739 arg-pointer are the same register, they use the same unique object. 3740 3741 After register allocation, other rtl objects which used to be pseudo-regs 3742 may be clobbered to refer to the frame-pointer register. 3743 But references that were originally to the frame-pointer can be 3744 distinguished from the others because they contain frame_pointer_rtx. 3745 3746 When to use frame_pointer_rtx and hard_frame_pointer_rtx is a little 3747 tricky: until register elimination has taken place hard_frame_pointer_rtx 3748 should be used if it is being set, and frame_pointer_rtx otherwise. After 3749 register elimination hard_frame_pointer_rtx should always be used. 3750 On machines where the two registers are same (most) then these are the 3751 same. */ 3752 rtx x_global_rtl[GR_MAX]; 3753 3754 /* A unique representation of (REG:Pmode PIC_OFFSET_TABLE_REGNUM). */ 3755 rtx x_pic_offset_table_rtx; 3756 3757 /* A unique representation of (REG:Pmode RETURN_ADDRESS_POINTER_REGNUM). 3758 This is used to implement __builtin_return_address for some machines; 3759 see for instance the MIPS port. */ 3760 rtx x_return_address_pointer_rtx; 3761 3762 /* Commonly used RTL for hard registers. These objects are not 3763 necessarily unique, so we allocate them separately from global_rtl. 3764 They are initialized once per compilation unit, then copied into 3765 regno_reg_rtx at the beginning of each function. */ 3766 rtx x_initial_regno_reg_rtx[FIRST_PSEUDO_REGISTER]; 3767 3768 /* A sample (mem:M stack_pointer_rtx) rtx for each mode M. */ 3769 rtx x_top_of_stack[MAX_MACHINE_MODE]; 3770 3771 /* Static hunks of RTL used by the aliasing code; these are treated 3772 as persistent to avoid unnecessary RTL allocations. */ 3773 rtx x_static_reg_base_value[FIRST_PSEUDO_REGISTER]; 3774 3775 /* The default memory attributes for each mode. */ 3776 class mem_attrs *x_mode_mem_attrs[(int) MAX_MACHINE_MODE]; 3777 3778 /* Track if RTL has been initialized. */ 3779 bool target_specific_initialized; 3780 }; 3781 3782 extern GTY(()) struct target_rtl default_target_rtl; 3783 #if SWITCHABLE_TARGET 3784 extern struct target_rtl *this_target_rtl; 3785 #else 3786 #define this_target_rtl (&default_target_rtl) 3787 #endif 3788 3789 #define global_rtl \ 3790 (this_target_rtl->x_global_rtl) 3791 #define pic_offset_table_rtx \ 3792 (this_target_rtl->x_pic_offset_table_rtx) 3793 #define return_address_pointer_rtx \ 3794 (this_target_rtl->x_return_address_pointer_rtx) 3795 #define top_of_stack \ 3796 (this_target_rtl->x_top_of_stack) 3797 #define mode_mem_attrs \ 3798 (this_target_rtl->x_mode_mem_attrs) 3799 3800 /* All references to certain hard regs, except those created 3801 by allocating pseudo regs into them (when that's possible), 3802 go through these unique rtx objects. */ 3803 #define stack_pointer_rtx (global_rtl[GR_STACK_POINTER]) 3804 #define frame_pointer_rtx (global_rtl[GR_FRAME_POINTER]) 3805 #define hard_frame_pointer_rtx (global_rtl[GR_HARD_FRAME_POINTER]) 3806 #define arg_pointer_rtx (global_rtl[GR_ARG_POINTER]) 3807 3808 #ifndef GENERATOR_FILE 3809 /* Return the attributes of a MEM rtx. */ 3810 static inline const class mem_attrs * 3811 get_mem_attrs (const_rtx x) 3812 { 3813 class mem_attrs *attrs; 3814 3815 attrs = MEM_ATTRS (x); 3816 if (!attrs) 3817 attrs = mode_mem_attrs[(int) GET_MODE (x)]; 3818 return attrs; 3819 } 3820 #endif 3821 3822 /* Include the RTL generation functions. */ 3823 3824 #ifndef GENERATOR_FILE 3825 #include "genrtl.h" 3826 #undef gen_rtx_ASM_INPUT 3827 #define gen_rtx_ASM_INPUT(MODE, ARG0) \ 3828 gen_rtx_fmt_si (ASM_INPUT, (MODE), (ARG0), 0) 3829 #define gen_rtx_ASM_INPUT_loc(MODE, ARG0, LOC) \ 3830 gen_rtx_fmt_si (ASM_INPUT, (MODE), (ARG0), (LOC)) 3831 #endif 3832 3833 /* There are some RTL codes that require special attention; the 3834 generation functions included above do the raw handling. If you 3835 add to this list, modify special_rtx in gengenrtl.c as well. */ 3836 3837 extern rtx_expr_list *gen_rtx_EXPR_LIST (machine_mode, rtx, rtx); 3838 extern rtx_insn_list *gen_rtx_INSN_LIST (machine_mode, rtx, rtx); 3839 extern rtx_insn * 3840 gen_rtx_INSN (machine_mode mode, rtx_insn *prev_insn, rtx_insn *next_insn, 3841 basic_block bb, rtx pattern, int location, int code, 3842 rtx reg_notes); 3843 extern rtx gen_rtx_CONST_INT (machine_mode, HOST_WIDE_INT); 3844 extern rtx gen_rtx_CONST_VECTOR (machine_mode, rtvec); 3845 extern void set_mode_and_regno (rtx, machine_mode, unsigned int); 3846 extern rtx init_raw_REG (rtx, machine_mode, unsigned int); 3847 extern rtx gen_raw_REG (machine_mode, unsigned int); 3848 #define alloca_raw_REG(mode, regno) \ 3849 init_raw_REG (rtx_alloca (REG), (mode), (regno)) 3850 extern rtx gen_rtx_REG (machine_mode, unsigned int); 3851 extern rtx gen_rtx_SUBREG (machine_mode, rtx, poly_uint64); 3852 extern rtx gen_rtx_MEM (machine_mode, rtx); 3853 extern rtx gen_rtx_VAR_LOCATION (machine_mode, tree, rtx, 3854 enum var_init_status); 3855 3856 #ifdef GENERATOR_FILE 3857 #define PUT_MODE(RTX, MODE) PUT_MODE_RAW (RTX, MODE) 3858 #else 3859 static inline void 3860 PUT_MODE (rtx x, machine_mode mode) 3861 { 3862 if (REG_P (x)) 3863 set_mode_and_regno (x, mode, REGNO (x)); 3864 else 3865 PUT_MODE_RAW (x, mode); 3866 } 3867 #endif 3868 3869 #define GEN_INT(N) gen_rtx_CONST_INT (VOIDmode, (N)) 3870 3871 /* Virtual registers are used during RTL generation to refer to locations into 3872 the stack frame when the actual location isn't known until RTL generation 3873 is complete. The routine instantiate_virtual_regs replaces these with 3874 the proper value, which is normally {frame,arg,stack}_pointer_rtx plus 3875 a constant. */ 3876 3877 #define FIRST_VIRTUAL_REGISTER (FIRST_PSEUDO_REGISTER) 3878 3879 /* This points to the first word of the incoming arguments passed on the stack, 3880 either by the caller or by the callee when pretending it was passed by the 3881 caller. */ 3882 3883 #define virtual_incoming_args_rtx (global_rtl[GR_VIRTUAL_INCOMING_ARGS]) 3884 3885 #define VIRTUAL_INCOMING_ARGS_REGNUM (FIRST_VIRTUAL_REGISTER) 3886 3887 /* If FRAME_GROWS_DOWNWARD, this points to immediately above the first 3888 variable on the stack. Otherwise, it points to the first variable on 3889 the stack. */ 3890 3891 #define virtual_stack_vars_rtx (global_rtl[GR_VIRTUAL_STACK_ARGS]) 3892 3893 #define VIRTUAL_STACK_VARS_REGNUM ((FIRST_VIRTUAL_REGISTER) + 1) 3894 3895 /* This points to the location of dynamically-allocated memory on the stack 3896 immediately after the stack pointer has been adjusted by the amount 3897 desired. */ 3898 3899 #define virtual_stack_dynamic_rtx (global_rtl[GR_VIRTUAL_STACK_DYNAMIC]) 3900 3901 #define VIRTUAL_STACK_DYNAMIC_REGNUM ((FIRST_VIRTUAL_REGISTER) + 2) 3902 3903 /* This points to the location in the stack at which outgoing arguments should 3904 be written when the stack is pre-pushed (arguments pushed using push 3905 insns always use sp). */ 3906 3907 #define virtual_outgoing_args_rtx (global_rtl[GR_VIRTUAL_OUTGOING_ARGS]) 3908 3909 #define VIRTUAL_OUTGOING_ARGS_REGNUM ((FIRST_VIRTUAL_REGISTER) + 3) 3910 3911 /* This points to the Canonical Frame Address of the function. This 3912 should correspond to the CFA produced by INCOMING_FRAME_SP_OFFSET, 3913 but is calculated relative to the arg pointer for simplicity; the 3914 frame pointer nor stack pointer are necessarily fixed relative to 3915 the CFA until after reload. */ 3916 3917 #define virtual_cfa_rtx (global_rtl[GR_VIRTUAL_CFA]) 3918 3919 #define VIRTUAL_CFA_REGNUM ((FIRST_VIRTUAL_REGISTER) + 4) 3920 3921 #define LAST_VIRTUAL_POINTER_REGISTER ((FIRST_VIRTUAL_REGISTER) + 4) 3922 3923 /* This is replaced by crtl->preferred_stack_boundary / BITS_PER_UNIT 3924 when finalized. */ 3925 3926 #define virtual_preferred_stack_boundary_rtx \ 3927 (global_rtl[GR_VIRTUAL_PREFERRED_STACK_BOUNDARY]) 3928 3929 #define VIRTUAL_PREFERRED_STACK_BOUNDARY_REGNUM \ 3930 ((FIRST_VIRTUAL_REGISTER) + 5) 3931 3932 #define LAST_VIRTUAL_REGISTER ((FIRST_VIRTUAL_REGISTER) + 5) 3933 3934 /* Nonzero if REGNUM is a pointer into the stack frame. */ 3935 #define REGNO_PTR_FRAME_P(REGNUM) \ 3936 ((REGNUM) == STACK_POINTER_REGNUM \ 3937 || (REGNUM) == FRAME_POINTER_REGNUM \ 3938 || (REGNUM) == HARD_FRAME_POINTER_REGNUM \ 3939 || (REGNUM) == ARG_POINTER_REGNUM \ 3940 || ((REGNUM) >= FIRST_VIRTUAL_REGISTER \ 3941 && (REGNUM) <= LAST_VIRTUAL_POINTER_REGISTER)) 3942 3943 /* REGNUM never really appearing in the INSN stream. */ 3944 #define INVALID_REGNUM (~(unsigned int) 0) 3945 3946 /* REGNUM for which no debug information can be generated. */ 3947 #define IGNORED_DWARF_REGNUM (INVALID_REGNUM - 1) 3948 3949 extern rtx output_constant_def (tree, int); 3950 extern rtx lookup_constant_def (tree); 3951 3952 /* Nonzero after end of reload pass. 3953 Set to 1 or 0 by reload1.c. */ 3954 3955 extern int reload_completed; 3956 3957 /* Nonzero after thread_prologue_and_epilogue_insns has run. */ 3958 extern int epilogue_completed; 3959 3960 /* Set to 1 while reload_as_needed is operating. 3961 Required by some machines to handle any generated moves differently. */ 3962 3963 extern int reload_in_progress; 3964 3965 /* Set to 1 while in lra. */ 3966 extern int lra_in_progress; 3967 3968 /* This macro indicates whether you may create a new 3969 pseudo-register. */ 3970 3971 #define can_create_pseudo_p() (!reload_in_progress && !reload_completed) 3972 3973 #ifdef STACK_REGS 3974 /* Nonzero after end of regstack pass. 3975 Set to 1 or 0 by reg-stack.c. */ 3976 extern int regstack_completed; 3977 #endif 3978 3979 /* If this is nonzero, we do not bother generating VOLATILE 3980 around volatile memory references, and we are willing to 3981 output indirect addresses. If cse is to follow, we reject 3982 indirect addresses so a useful potential cse is generated; 3983 if it is used only once, instruction combination will produce 3984 the same indirect address eventually. */ 3985 extern int cse_not_expected; 3986 3987 /* Translates rtx code to tree code, for those codes needed by 3988 real_arithmetic. The function returns an int because the caller may not 3989 know what `enum tree_code' means. */ 3990 3991 extern int rtx_to_tree_code (enum rtx_code); 3992 3993 /* In cse.c */ 3994 extern int delete_trivially_dead_insns (rtx_insn *, int); 3995 extern int exp_equiv_p (const_rtx, const_rtx, int, bool); 3996 extern unsigned hash_rtx (const_rtx x, machine_mode, int *, int *, bool); 3997 3998 /* In dse.c */ 3999 extern bool check_for_inc_dec (rtx_insn *insn); 4000 4001 /* In jump.c */ 4002 extern int comparison_dominates_p (enum rtx_code, enum rtx_code); 4003 extern bool jump_to_label_p (const rtx_insn *); 4004 extern int condjump_p (const rtx_insn *); 4005 extern int any_condjump_p (const rtx_insn *); 4006 extern int any_uncondjump_p (const rtx_insn *); 4007 extern rtx pc_set (const rtx_insn *); 4008 extern rtx condjump_label (const rtx_insn *); 4009 extern int simplejump_p (const rtx_insn *); 4010 extern int returnjump_p (const rtx_insn *); 4011 extern int eh_returnjump_p (rtx_insn *); 4012 extern int onlyjump_p (const rtx_insn *); 4013 extern int only_sets_cc0_p (const_rtx); 4014 extern int sets_cc0_p (const_rtx); 4015 extern int invert_jump_1 (rtx_jump_insn *, rtx); 4016 extern int invert_jump (rtx_jump_insn *, rtx, int); 4017 extern int rtx_renumbered_equal_p (const_rtx, const_rtx); 4018 extern int true_regnum (const_rtx); 4019 extern unsigned int reg_or_subregno (const_rtx); 4020 extern int redirect_jump_1 (rtx_insn *, rtx); 4021 extern void redirect_jump_2 (rtx_jump_insn *, rtx, rtx, int, int); 4022 extern int redirect_jump (rtx_jump_insn *, rtx, int); 4023 extern void rebuild_jump_labels (rtx_insn *); 4024 extern void rebuild_jump_labels_chain (rtx_insn *); 4025 extern rtx reversed_comparison (const_rtx, machine_mode); 4026 extern enum rtx_code reversed_comparison_code (const_rtx, const rtx_insn *); 4027 extern enum rtx_code reversed_comparison_code_parts (enum rtx_code, const_rtx, 4028 const_rtx, const rtx_insn *); 4029 extern void delete_for_peephole (rtx_insn *, rtx_insn *); 4030 extern int condjump_in_parallel_p (const rtx_insn *); 4031 4032 /* In emit-rtl.c. */ 4033 extern int max_reg_num (void); 4034 extern int max_label_num (void); 4035 extern int get_first_label_num (void); 4036 extern void maybe_set_first_label_num (rtx_code_label *); 4037 extern void delete_insns_since (rtx_insn *); 4038 extern void mark_reg_pointer (rtx, int); 4039 extern void mark_user_reg (rtx); 4040 extern void reset_used_flags (rtx); 4041 extern void set_used_flags (rtx); 4042 extern void reorder_insns (rtx_insn *, rtx_insn *, rtx_insn *); 4043 extern void reorder_insns_nobb (rtx_insn *, rtx_insn *, rtx_insn *); 4044 extern int get_max_insn_count (void); 4045 extern int in_sequence_p (void); 4046 extern void init_emit (void); 4047 extern void init_emit_regs (void); 4048 extern void init_derived_machine_modes (void); 4049 extern void init_emit_once (void); 4050 extern void push_topmost_sequence (void); 4051 extern void pop_topmost_sequence (void); 4052 extern void set_new_first_and_last_insn (rtx_insn *, rtx_insn *); 4053 extern unsigned int unshare_all_rtl (void); 4054 extern void unshare_all_rtl_again (rtx_insn *); 4055 extern void unshare_all_rtl_in_chain (rtx_insn *); 4056 extern void verify_rtl_sharing (void); 4057 extern void add_insn (rtx_insn *); 4058 extern void add_insn_before (rtx_insn *, rtx_insn *, basic_block); 4059 extern void add_insn_after (rtx_insn *, rtx_insn *, basic_block); 4060 extern void remove_insn (rtx_insn *); 4061 extern rtx_insn *emit (rtx, bool = true); 4062 extern void emit_insn_at_entry (rtx); 4063 extern rtx gen_lowpart_SUBREG (machine_mode, rtx); 4064 extern rtx gen_const_mem (machine_mode, rtx); 4065 extern rtx gen_frame_mem (machine_mode, rtx); 4066 extern rtx gen_tmp_stack_mem (machine_mode, rtx); 4067 extern bool validate_subreg (machine_mode, machine_mode, 4068 const_rtx, poly_uint64); 4069 4070 /* In combine.c */ 4071 extern unsigned int extended_count (const_rtx, machine_mode, int); 4072 extern rtx remove_death (unsigned int, rtx_insn *); 4073 extern void dump_combine_stats (FILE *); 4074 extern void dump_combine_total_stats (FILE *); 4075 extern rtx make_compound_operation (rtx, enum rtx_code); 4076 4077 /* In sched-rgn.c. */ 4078 extern void schedule_insns (void); 4079 4080 /* In sched-ebb.c. */ 4081 extern void schedule_ebbs (void); 4082 4083 /* In sel-sched-dump.c. */ 4084 extern void sel_sched_fix_param (const char *param, const char *val); 4085 4086 /* In print-rtl.c */ 4087 extern const char *print_rtx_head; 4088 extern void debug (const rtx_def &ref); 4089 extern void debug (const rtx_def *ptr); 4090 extern void debug_rtx (const_rtx); 4091 extern void debug_rtx_list (const rtx_insn *, int); 4092 extern void debug_rtx_range (const rtx_insn *, const rtx_insn *); 4093 extern const rtx_insn *debug_rtx_find (const rtx_insn *, int); 4094 extern void print_mem_expr (FILE *, const_tree); 4095 extern void print_rtl (FILE *, const_rtx); 4096 extern void print_simple_rtl (FILE *, const_rtx); 4097 extern int print_rtl_single (FILE *, const_rtx); 4098 extern int print_rtl_single_with_indent (FILE *, const_rtx, int); 4099 extern void print_inline_rtx (FILE *, const_rtx, int); 4100 4101 /* In stmt.c */ 4102 extern void expand_null_return (void); 4103 extern void expand_naked_return (void); 4104 extern void emit_jump (rtx); 4105 4106 /* Memory operation built-ins differ by return value. Mapping 4107 of the enum values is following: 4108 - RETURN_BEGIN - return destination, e.g. memcpy 4109 - RETURN_END - return destination + n, e.g. mempcpy 4110 - RETURN_END_MINUS_ONE - return a pointer to the terminating 4111 null byte of the string, e.g. strcpy 4112 */ 4113 4114 enum memop_ret 4115 { 4116 RETURN_BEGIN, 4117 RETURN_END, 4118 RETURN_END_MINUS_ONE 4119 }; 4120 4121 /* In expr.c */ 4122 extern rtx move_by_pieces (rtx, rtx, unsigned HOST_WIDE_INT, 4123 unsigned int, memop_ret); 4124 extern poly_int64 find_args_size_adjust (rtx_insn *); 4125 extern poly_int64 fixup_args_size_notes (rtx_insn *, rtx_insn *, poly_int64); 4126 4127 /* In expmed.c */ 4128 extern void init_expmed (void); 4129 extern void expand_inc (rtx, rtx); 4130 extern void expand_dec (rtx, rtx); 4131 4132 /* In lower-subreg.c */ 4133 extern void init_lower_subreg (void); 4134 4135 /* In gcse.c */ 4136 extern bool can_copy_p (machine_mode); 4137 extern bool can_assign_to_reg_without_clobbers_p (rtx, machine_mode); 4138 extern rtx_insn *prepare_copy_insn (rtx, rtx); 4139 4140 /* In cprop.c */ 4141 extern rtx fis_get_condition (rtx_insn *); 4142 4143 /* In ira.c */ 4144 extern HARD_REG_SET eliminable_regset; 4145 extern void mark_elimination (int, int); 4146 4147 /* In reginfo.c */ 4148 extern int reg_classes_intersect_p (reg_class_t, reg_class_t); 4149 extern int reg_class_subset_p (reg_class_t, reg_class_t); 4150 extern void globalize_reg (tree, int); 4151 extern void init_reg_modes_target (void); 4152 extern void init_regs (void); 4153 extern void reinit_regs (void); 4154 extern void init_fake_stack_mems (void); 4155 extern void save_register_info (void); 4156 extern void init_reg_sets (void); 4157 extern void regclass (rtx, int); 4158 extern void reg_scan (rtx_insn *, unsigned int); 4159 extern void fix_register (const char *, int, int); 4160 extern const HARD_REG_SET *valid_mode_changes_for_regno (unsigned int); 4161 4162 /* In reload1.c */ 4163 extern int function_invariant_p (const_rtx); 4164 4165 /* In calls.c */ 4166 enum libcall_type 4167 { 4168 LCT_NORMAL = 0, 4169 LCT_CONST = 1, 4170 LCT_PURE = 2, 4171 LCT_NORETURN = 3, 4172 LCT_THROW = 4, 4173 LCT_RETURNS_TWICE = 5 4174 }; 4175 4176 extern rtx emit_library_call_value_1 (int, rtx, rtx, enum libcall_type, 4177 machine_mode, int, rtx_mode_t *); 4178 4179 /* Output a library call and discard the returned value. FUN is the 4180 address of the function, as a SYMBOL_REF rtx, and OUTMODE is the mode 4181 of the (discarded) return value. FN_TYPE is LCT_NORMAL for `normal' 4182 calls, LCT_CONST for `const' calls, LCT_PURE for `pure' calls, or 4183 another LCT_ value for other types of library calls. 4184 4185 There are different overloads of this function for different numbers 4186 of arguments. In each case the argument value is followed by its mode. */ 4187 4188 inline void 4189 emit_library_call (rtx fun, libcall_type fn_type, machine_mode outmode) 4190 { 4191 emit_library_call_value_1 (0, fun, NULL_RTX, fn_type, outmode, 0, NULL); 4192 } 4193 4194 inline void 4195 emit_library_call (rtx fun, libcall_type fn_type, machine_mode outmode, 4196 rtx arg1, machine_mode arg1_mode) 4197 { 4198 rtx_mode_t args[] = { rtx_mode_t (arg1, arg1_mode) }; 4199 emit_library_call_value_1 (0, fun, NULL_RTX, fn_type, outmode, 1, args); 4200 } 4201 4202 inline void 4203 emit_library_call (rtx fun, libcall_type fn_type, machine_mode outmode, 4204 rtx arg1, machine_mode arg1_mode, 4205 rtx arg2, machine_mode arg2_mode) 4206 { 4207 rtx_mode_t args[] = { 4208 rtx_mode_t (arg1, arg1_mode), 4209 rtx_mode_t (arg2, arg2_mode) 4210 }; 4211 emit_library_call_value_1 (0, fun, NULL_RTX, fn_type, outmode, 2, args); 4212 } 4213 4214 inline void 4215 emit_library_call (rtx fun, libcall_type fn_type, machine_mode outmode, 4216 rtx arg1, machine_mode arg1_mode, 4217 rtx arg2, machine_mode arg2_mode, 4218 rtx arg3, machine_mode arg3_mode) 4219 { 4220 rtx_mode_t args[] = { 4221 rtx_mode_t (arg1, arg1_mode), 4222 rtx_mode_t (arg2, arg2_mode), 4223 rtx_mode_t (arg3, arg3_mode) 4224 }; 4225 emit_library_call_value_1 (0, fun, NULL_RTX, fn_type, outmode, 3, args); 4226 } 4227 4228 inline void 4229 emit_library_call (rtx fun, libcall_type fn_type, machine_mode outmode, 4230 rtx arg1, machine_mode arg1_mode, 4231 rtx arg2, machine_mode arg2_mode, 4232 rtx arg3, machine_mode arg3_mode, 4233 rtx arg4, machine_mode arg4_mode) 4234 { 4235 rtx_mode_t args[] = { 4236 rtx_mode_t (arg1, arg1_mode), 4237 rtx_mode_t (arg2, arg2_mode), 4238 rtx_mode_t (arg3, arg3_mode), 4239 rtx_mode_t (arg4, arg4_mode) 4240 }; 4241 emit_library_call_value_1 (0, fun, NULL_RTX, fn_type, outmode, 4, args); 4242 } 4243 4244 /* Like emit_library_call, but return the value produced by the call. 4245 Use VALUE to store the result if it is nonnull, otherwise pick a 4246 convenient location. */ 4247 4248 inline rtx 4249 emit_library_call_value (rtx fun, rtx value, libcall_type fn_type, 4250 machine_mode outmode) 4251 { 4252 return emit_library_call_value_1 (1, fun, value, fn_type, outmode, 0, NULL); 4253 } 4254 4255 inline rtx 4256 emit_library_call_value (rtx fun, rtx value, libcall_type fn_type, 4257 machine_mode outmode, 4258 rtx arg1, machine_mode arg1_mode) 4259 { 4260 rtx_mode_t args[] = { rtx_mode_t (arg1, arg1_mode) }; 4261 return emit_library_call_value_1 (1, fun, value, fn_type, outmode, 1, args); 4262 } 4263 4264 inline rtx 4265 emit_library_call_value (rtx fun, rtx value, libcall_type fn_type, 4266 machine_mode outmode, 4267 rtx arg1, machine_mode arg1_mode, 4268 rtx arg2, machine_mode arg2_mode) 4269 { 4270 rtx_mode_t args[] = { 4271 rtx_mode_t (arg1, arg1_mode), 4272 rtx_mode_t (arg2, arg2_mode) 4273 }; 4274 return emit_library_call_value_1 (1, fun, value, fn_type, outmode, 2, args); 4275 } 4276 4277 inline rtx 4278 emit_library_call_value (rtx fun, rtx value, libcall_type fn_type, 4279 machine_mode outmode, 4280 rtx arg1, machine_mode arg1_mode, 4281 rtx arg2, machine_mode arg2_mode, 4282 rtx arg3, machine_mode arg3_mode) 4283 { 4284 rtx_mode_t args[] = { 4285 rtx_mode_t (arg1, arg1_mode), 4286 rtx_mode_t (arg2, arg2_mode), 4287 rtx_mode_t (arg3, arg3_mode) 4288 }; 4289 return emit_library_call_value_1 (1, fun, value, fn_type, outmode, 3, args); 4290 } 4291 4292 inline rtx 4293 emit_library_call_value (rtx fun, rtx value, libcall_type fn_type, 4294 machine_mode outmode, 4295 rtx arg1, machine_mode arg1_mode, 4296 rtx arg2, machine_mode arg2_mode, 4297 rtx arg3, machine_mode arg3_mode, 4298 rtx arg4, machine_mode arg4_mode) 4299 { 4300 rtx_mode_t args[] = { 4301 rtx_mode_t (arg1, arg1_mode), 4302 rtx_mode_t (arg2, arg2_mode), 4303 rtx_mode_t (arg3, arg3_mode), 4304 rtx_mode_t (arg4, arg4_mode) 4305 }; 4306 return emit_library_call_value_1 (1, fun, value, fn_type, outmode, 4, args); 4307 } 4308 4309 /* In varasm.c */ 4310 extern void init_varasm_once (void); 4311 4312 extern rtx make_debug_expr_from_rtl (const_rtx); 4313 4314 /* In read-rtl.c */ 4315 #ifdef GENERATOR_FILE 4316 extern bool read_rtx (const char *, vec<rtx> *); 4317 #endif 4318 4319 /* In alias.c */ 4320 extern rtx canon_rtx (rtx); 4321 extern int true_dependence (const_rtx, machine_mode, const_rtx); 4322 extern rtx get_addr (rtx); 4323 extern int canon_true_dependence (const_rtx, machine_mode, rtx, 4324 const_rtx, rtx); 4325 extern int read_dependence (const_rtx, const_rtx); 4326 extern int anti_dependence (const_rtx, const_rtx); 4327 extern int canon_anti_dependence (const_rtx, bool, 4328 const_rtx, machine_mode, rtx); 4329 extern int output_dependence (const_rtx, const_rtx); 4330 extern int canon_output_dependence (const_rtx, bool, 4331 const_rtx, machine_mode, rtx); 4332 extern int may_alias_p (const_rtx, const_rtx); 4333 extern void init_alias_target (void); 4334 extern void init_alias_analysis (void); 4335 extern void end_alias_analysis (void); 4336 extern void vt_equate_reg_base_value (const_rtx, const_rtx); 4337 extern bool memory_modified_in_insn_p (const_rtx, const_rtx); 4338 extern bool may_be_sp_based_p (rtx); 4339 extern rtx gen_hard_reg_clobber (machine_mode, unsigned int); 4340 extern rtx get_reg_known_value (unsigned int); 4341 extern bool get_reg_known_equiv_p (unsigned int); 4342 extern rtx get_reg_base_value (unsigned int); 4343 4344 #ifdef STACK_REGS 4345 extern int stack_regs_mentioned (const_rtx insn); 4346 #endif 4347 4348 /* In toplev.c */ 4349 extern GTY(()) rtx stack_limit_rtx; 4350 4351 /* In var-tracking.c */ 4352 extern unsigned int variable_tracking_main (void); 4353 extern void delete_vta_debug_insns (bool); 4354 4355 /* In stor-layout.c. */ 4356 extern void get_mode_bounds (scalar_int_mode, int, 4357 scalar_int_mode, rtx *, rtx *); 4358 4359 /* In loop-iv.c */ 4360 extern rtx canon_condition (rtx); 4361 extern void simplify_using_condition (rtx, rtx *, bitmap); 4362 4363 /* In final.c */ 4364 extern unsigned int compute_alignments (void); 4365 extern void update_alignments (vec<rtx> &); 4366 extern int asm_str_count (const char *templ); 4367 4368 struct rtl_hooks 4369 { 4370 rtx (*gen_lowpart) (machine_mode, rtx); 4371 rtx (*gen_lowpart_no_emit) (machine_mode, rtx); 4372 rtx (*reg_nonzero_bits) (const_rtx, scalar_int_mode, scalar_int_mode, 4373 unsigned HOST_WIDE_INT *); 4374 rtx (*reg_num_sign_bit_copies) (const_rtx, scalar_int_mode, scalar_int_mode, 4375 unsigned int *); 4376 bool (*reg_truncated_to_mode) (machine_mode, const_rtx); 4377 4378 /* Whenever you add entries here, make sure you adjust rtlhooks-def.h. */ 4379 }; 4380 4381 /* Each pass can provide its own. */ 4382 extern struct rtl_hooks rtl_hooks; 4383 4384 /* ... but then it has to restore these. */ 4385 extern const struct rtl_hooks general_rtl_hooks; 4386 4387 /* Keep this for the nonce. */ 4388 #define gen_lowpart rtl_hooks.gen_lowpart 4389 4390 extern void insn_locations_init (void); 4391 extern void insn_locations_finalize (void); 4392 extern void set_curr_insn_location (location_t); 4393 extern location_t curr_insn_location (void); 4394 extern void set_insn_locations (rtx_insn *, location_t); 4395 4396 /* rtl-error.c */ 4397 extern void _fatal_insn_not_found (const_rtx, const char *, int, const char *) 4398 ATTRIBUTE_NORETURN ATTRIBUTE_COLD; 4399 extern void _fatal_insn (const char *, const_rtx, const char *, int, const char *) 4400 ATTRIBUTE_NORETURN ATTRIBUTE_COLD; 4401 4402 #define fatal_insn(msgid, insn) \ 4403 _fatal_insn (msgid, insn, __FILE__, __LINE__, __FUNCTION__) 4404 #define fatal_insn_not_found(insn) \ 4405 _fatal_insn_not_found (insn, __FILE__, __LINE__, __FUNCTION__) 4406 4407 /* reginfo.c */ 4408 extern tree GTY(()) global_regs_decl[FIRST_PSEUDO_REGISTER]; 4409 4410 /* Information about the function that is propagated by the RTL backend. 4411 Available only for functions that has been already assembled. */ 4412 4413 struct GTY(()) cgraph_rtl_info { 4414 unsigned int preferred_incoming_stack_boundary; 4415 4416 /* Which registers the function clobbers, either directly or by 4417 calling another function. */ 4418 HARD_REG_SET function_used_regs; 4419 }; 4420 4421 /* If loads from memories of mode MODE always sign or zero extend, 4422 return SIGN_EXTEND or ZERO_EXTEND as appropriate. Return UNKNOWN 4423 otherwise. */ 4424 4425 inline rtx_code 4426 load_extend_op (machine_mode mode) 4427 { 4428 scalar_int_mode int_mode; 4429 if (is_a <scalar_int_mode> (mode, &int_mode) 4430 && GET_MODE_PRECISION (int_mode) < BITS_PER_WORD) 4431 return LOAD_EXTEND_OP (int_mode); 4432 return UNKNOWN; 4433 } 4434 4435 /* If X is a PLUS of a base and a constant offset, add the constant to *OFFSET 4436 and return the base. Return X otherwise. */ 4437 4438 inline rtx 4439 strip_offset_and_add (rtx x, poly_int64_pod *offset) 4440 { 4441 if (GET_CODE (x) == PLUS) 4442 { 4443 poly_int64 suboffset; 4444 x = strip_offset (x, &suboffset); 4445 *offset = poly_uint64 (*offset) + suboffset; 4446 } 4447 return x; 4448 } 4449 4450 /* Return true if X is an operation that always operates on the full 4451 registers for WORD_REGISTER_OPERATIONS architectures. */ 4452 4453 inline bool 4454 word_register_operation_p (const_rtx x) 4455 { 4456 switch (GET_CODE (x)) 4457 { 4458 case CONST_INT: 4459 case ROTATE: 4460 case ROTATERT: 4461 case SIGN_EXTRACT: 4462 case ZERO_EXTRACT: 4463 return false; 4464 4465 default: 4466 return true; 4467 } 4468 } 4469 4470 /* gtype-desc.c. */ 4471 extern void gt_ggc_mx (rtx &); 4472 extern void gt_pch_nx (rtx &); 4473 extern void gt_pch_nx (rtx &, gt_pointer_operator, void *); 4474 4475 #endif /* ! GCC_RTL_H */ 4476