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