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