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