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