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