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