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