xref: /dragonfly/contrib/gcc-4.7/gcc/rtl.h (revision 95d28233)
1e4b17023SJohn Marino /* Register Transfer Language (RTL) definitions for GCC
2e4b17023SJohn Marino    Copyright (C) 1987, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3e4b17023SJohn Marino    2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
4e4b17023SJohn Marino    Free Software Foundation, Inc.
5e4b17023SJohn Marino 
6e4b17023SJohn Marino This file is part of GCC.
7e4b17023SJohn Marino 
8e4b17023SJohn Marino GCC is free software; you can redistribute it and/or modify it under
9e4b17023SJohn Marino the terms of the GNU General Public License as published by the Free
10e4b17023SJohn Marino Software Foundation; either version 3, or (at your option) any later
11e4b17023SJohn Marino version.
12e4b17023SJohn Marino 
13e4b17023SJohn Marino GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14e4b17023SJohn Marino WARRANTY; without even the implied warranty of MERCHANTABILITY or
15e4b17023SJohn Marino FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16e4b17023SJohn Marino for more details.
17e4b17023SJohn Marino 
18e4b17023SJohn Marino You should have received a copy of the GNU General Public License
19e4b17023SJohn Marino along with GCC; see the file COPYING3.  If not see
20e4b17023SJohn Marino <http://www.gnu.org/licenses/>.  */
21e4b17023SJohn Marino 
22e4b17023SJohn Marino #ifndef GCC_RTL_H
23e4b17023SJohn Marino #define GCC_RTL_H
24e4b17023SJohn Marino 
25e4b17023SJohn Marino #include "statistics.h"
26e4b17023SJohn Marino #include "machmode.h"
27e4b17023SJohn Marino #include "input.h"
28e4b17023SJohn Marino #include "real.h"
29e4b17023SJohn Marino #include "vec.h"
30e4b17023SJohn Marino #include "vecir.h"
31e4b17023SJohn Marino #include "fixed-value.h"
32e4b17023SJohn Marino #include "alias.h"
33e4b17023SJohn Marino #include "hashtab.h"
34e4b17023SJohn Marino 
35e4b17023SJohn Marino #undef FFS  /* Some systems predefine this symbol; don't let it interfere.  */
36e4b17023SJohn Marino #undef FLOAT /* Likewise.  */
37e4b17023SJohn Marino #undef ABS /* Likewise.  */
38e4b17023SJohn Marino #undef PC /* Likewise.  */
39e4b17023SJohn Marino 
40e4b17023SJohn Marino /* Value used by some passes to "recognize" noop moves as valid
41e4b17023SJohn Marino  instructions.  */
42e4b17023SJohn Marino #define NOOP_MOVE_INSN_CODE	INT_MAX
43e4b17023SJohn Marino 
44e4b17023SJohn Marino /* Register Transfer Language EXPRESSIONS CODES */
45e4b17023SJohn Marino 
46e4b17023SJohn Marino #define RTX_CODE	enum rtx_code
47e4b17023SJohn Marino enum rtx_code  {
48e4b17023SJohn Marino 
49e4b17023SJohn Marino #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS)   ENUM ,
50e4b17023SJohn Marino #include "rtl.def"		/* rtl expressions are documented here */
51e4b17023SJohn Marino #undef DEF_RTL_EXPR
52e4b17023SJohn Marino 
53e4b17023SJohn Marino   LAST_AND_UNUSED_RTX_CODE};	/* A convenient way to get a value for
54e4b17023SJohn Marino 				   NUM_RTX_CODE.
55e4b17023SJohn Marino 				   Assumes default enum value assignment.  */
56e4b17023SJohn Marino 
57e4b17023SJohn Marino #define NUM_RTX_CODE ((int) LAST_AND_UNUSED_RTX_CODE)
58e4b17023SJohn Marino 				/* The cast here, saves many elsewhere.  */
59e4b17023SJohn Marino 
60e4b17023SJohn Marino /* Register Transfer Language EXPRESSIONS CODE CLASSES */
61e4b17023SJohn Marino 
62e4b17023SJohn Marino enum rtx_class  {
63e4b17023SJohn Marino   /* We check bit 0-1 of some rtx class codes in the predicates below.  */
64e4b17023SJohn Marino 
65e4b17023SJohn Marino   /* Bit 0 = comparison if 0, arithmetic is 1
66e4b17023SJohn Marino      Bit 1 = 1 if commutative.  */
67e4b17023SJohn Marino   RTX_COMPARE,		/* 0 */
68e4b17023SJohn Marino   RTX_COMM_COMPARE,
69e4b17023SJohn Marino   RTX_BIN_ARITH,
70e4b17023SJohn Marino   RTX_COMM_ARITH,
71e4b17023SJohn Marino 
72e4b17023SJohn Marino   /* Must follow the four preceding values.  */
73e4b17023SJohn Marino   RTX_UNARY,		/* 4 */
74e4b17023SJohn Marino 
75e4b17023SJohn Marino   RTX_EXTRA,
76e4b17023SJohn Marino   RTX_MATCH,
77e4b17023SJohn Marino   RTX_INSN,
78e4b17023SJohn Marino 
79e4b17023SJohn Marino   /* Bit 0 = 1 if constant.  */
80e4b17023SJohn Marino   RTX_OBJ,		/* 8 */
81e4b17023SJohn Marino   RTX_CONST_OBJ,
82e4b17023SJohn Marino 
83e4b17023SJohn Marino   RTX_TERNARY,
84e4b17023SJohn Marino   RTX_BITFIELD_OPS,
85e4b17023SJohn Marino   RTX_AUTOINC
86e4b17023SJohn Marino };
87e4b17023SJohn Marino 
88e4b17023SJohn Marino #define RTX_OBJ_MASK (~1)
89e4b17023SJohn Marino #define RTX_OBJ_RESULT (RTX_OBJ & RTX_OBJ_MASK)
90e4b17023SJohn Marino #define RTX_COMPARE_MASK (~1)
91e4b17023SJohn Marino #define RTX_COMPARE_RESULT (RTX_COMPARE & RTX_COMPARE_MASK)
92e4b17023SJohn Marino #define RTX_ARITHMETIC_MASK (~1)
93e4b17023SJohn Marino #define RTX_ARITHMETIC_RESULT (RTX_COMM_ARITH & RTX_ARITHMETIC_MASK)
94e4b17023SJohn Marino #define RTX_BINARY_MASK (~3)
95e4b17023SJohn Marino #define RTX_BINARY_RESULT (RTX_COMPARE & RTX_BINARY_MASK)
96e4b17023SJohn Marino #define RTX_COMMUTATIVE_MASK (~2)
97e4b17023SJohn Marino #define RTX_COMMUTATIVE_RESULT (RTX_COMM_COMPARE & RTX_COMMUTATIVE_MASK)
98e4b17023SJohn Marino #define RTX_NON_COMMUTATIVE_RESULT (RTX_COMPARE & RTX_COMMUTATIVE_MASK)
99e4b17023SJohn Marino 
100e4b17023SJohn Marino extern const unsigned char rtx_length[NUM_RTX_CODE];
101e4b17023SJohn Marino #define GET_RTX_LENGTH(CODE)		(rtx_length[(int) (CODE)])
102e4b17023SJohn Marino 
103e4b17023SJohn Marino extern const char * const rtx_name[NUM_RTX_CODE];
104e4b17023SJohn Marino #define GET_RTX_NAME(CODE)		(rtx_name[(int) (CODE)])
105e4b17023SJohn Marino 
106e4b17023SJohn Marino extern const char * const rtx_format[NUM_RTX_CODE];
107e4b17023SJohn Marino #define GET_RTX_FORMAT(CODE)		(rtx_format[(int) (CODE)])
108e4b17023SJohn Marino 
109e4b17023SJohn Marino extern const enum rtx_class rtx_class[NUM_RTX_CODE];
110e4b17023SJohn Marino #define GET_RTX_CLASS(CODE)		(rtx_class[(int) (CODE)])
111e4b17023SJohn Marino 
112e4b17023SJohn Marino extern const unsigned char rtx_code_size[NUM_RTX_CODE];
113e4b17023SJohn Marino extern const unsigned char rtx_next[NUM_RTX_CODE];
114e4b17023SJohn Marino 
115e4b17023SJohn Marino /* The flags and bitfields of an ADDR_DIFF_VEC.  BASE is the base label
116e4b17023SJohn Marino    relative to which the offsets are calculated, as explained in rtl.def.  */
117e4b17023SJohn Marino typedef struct
118e4b17023SJohn Marino {
119e4b17023SJohn Marino   /* Set at the start of shorten_branches - ONLY WHEN OPTIMIZING - : */
120e4b17023SJohn Marino   unsigned min_align: 8;
121e4b17023SJohn Marino   /* Flags: */
122e4b17023SJohn Marino   unsigned base_after_vec: 1; /* BASE is after the ADDR_DIFF_VEC.  */
123e4b17023SJohn Marino   unsigned min_after_vec: 1;  /* minimum address target label is
124e4b17023SJohn Marino 				 after the ADDR_DIFF_VEC.  */
125e4b17023SJohn Marino   unsigned max_after_vec: 1;  /* maximum address target label is
126e4b17023SJohn Marino 				 after the ADDR_DIFF_VEC.  */
127e4b17023SJohn Marino   unsigned min_after_base: 1; /* minimum address target label is
128e4b17023SJohn Marino 				 after BASE.  */
129e4b17023SJohn Marino   unsigned max_after_base: 1; /* maximum address target label is
130e4b17023SJohn Marino 				 after BASE.  */
131e4b17023SJohn Marino   /* Set by the actual branch shortening process - ONLY WHEN OPTIMIZING - : */
132e4b17023SJohn Marino   unsigned offset_unsigned: 1; /* offsets have to be treated as unsigned.  */
133e4b17023SJohn Marino   unsigned : 2;
134e4b17023SJohn Marino   unsigned scale : 8;
135e4b17023SJohn Marino } addr_diff_vec_flags;
136e4b17023SJohn Marino 
137e4b17023SJohn Marino /* Structure used to describe the attributes of a MEM.  These are hashed
138e4b17023SJohn Marino    so MEMs that the same attributes share a data structure.  This means
139e4b17023SJohn Marino    they cannot be modified in place.  */
140e4b17023SJohn Marino typedef struct GTY(()) mem_attrs
141e4b17023SJohn Marino {
142e4b17023SJohn Marino   /* The expression that the MEM accesses, or null if not known.
143e4b17023SJohn Marino      This expression might be larger than the memory reference itself.
144e4b17023SJohn Marino      (In other words, the MEM might access only part of the object.)  */
145e4b17023SJohn Marino   tree expr;
146e4b17023SJohn Marino 
147e4b17023SJohn Marino   /* The offset of the memory reference from the start of EXPR.
148e4b17023SJohn Marino      Only valid if OFFSET_KNOWN_P.  */
149e4b17023SJohn Marino   HOST_WIDE_INT offset;
150e4b17023SJohn Marino 
151e4b17023SJohn Marino   /* The size of the memory reference in bytes.  Only valid if
152e4b17023SJohn Marino      SIZE_KNOWN_P.  */
153e4b17023SJohn Marino   HOST_WIDE_INT size;
154e4b17023SJohn Marino 
155e4b17023SJohn Marino   /* The alias set of the memory reference.  */
156e4b17023SJohn Marino   alias_set_type alias;
157e4b17023SJohn Marino 
158e4b17023SJohn Marino   /* The alignment of the reference in bits.  Always a multiple of
159e4b17023SJohn Marino      BITS_PER_UNIT.  Note that EXPR may have a stricter alignment
160e4b17023SJohn Marino      than the memory reference itself.  */
161e4b17023SJohn Marino   unsigned int align;
162e4b17023SJohn Marino 
163e4b17023SJohn Marino   /* The address space that the memory reference uses.  */
164e4b17023SJohn Marino   unsigned char addrspace;
165e4b17023SJohn Marino 
166e4b17023SJohn Marino   /* True if OFFSET is known.  */
167e4b17023SJohn Marino   bool offset_known_p;
168e4b17023SJohn Marino 
169e4b17023SJohn Marino   /* True if SIZE is known.  */
170e4b17023SJohn Marino   bool size_known_p;
171e4b17023SJohn Marino } mem_attrs;
172e4b17023SJohn Marino 
173e4b17023SJohn Marino /* Structure used to describe the attributes of a REG in similar way as
174e4b17023SJohn Marino    mem_attrs does for MEM above.  Note that the OFFSET field is calculated
175e4b17023SJohn Marino    in the same way as for mem_attrs, rather than in the same way as a
176e4b17023SJohn Marino    SUBREG_BYTE.  For example, if a big-endian target stores a byte
177e4b17023SJohn Marino    object in the low part of a 4-byte register, the OFFSET field
178e4b17023SJohn Marino    will be -3 rather than 0.  */
179e4b17023SJohn Marino 
180e4b17023SJohn Marino typedef struct GTY(()) reg_attrs {
181e4b17023SJohn Marino   tree decl;			/* decl corresponding to REG.  */
182e4b17023SJohn Marino   HOST_WIDE_INT offset;		/* Offset from start of DECL.  */
183e4b17023SJohn Marino } reg_attrs;
184e4b17023SJohn Marino 
185e4b17023SJohn Marino /* Common union for an element of an rtx.  */
186e4b17023SJohn Marino 
187e4b17023SJohn Marino union rtunion_def
188e4b17023SJohn Marino {
189e4b17023SJohn Marino   int rt_int;
190e4b17023SJohn Marino   unsigned int rt_uint;
191e4b17023SJohn Marino   const char *rt_str;
192e4b17023SJohn Marino   rtx rt_rtx;
193e4b17023SJohn Marino   rtvec rt_rtvec;
194e4b17023SJohn Marino   enum machine_mode rt_type;
195e4b17023SJohn Marino   addr_diff_vec_flags rt_addr_diff_vec_flags;
196e4b17023SJohn Marino   struct cselib_val_struct *rt_cselib;
197e4b17023SJohn Marino   tree rt_tree;
198e4b17023SJohn Marino   struct basic_block_def *rt_bb;
199e4b17023SJohn Marino   mem_attrs *rt_mem;
200e4b17023SJohn Marino   reg_attrs *rt_reg;
201e4b17023SJohn Marino   struct constant_descriptor_rtx *rt_constant;
202e4b17023SJohn Marino   struct dw_cfi_struct *rt_cfi;
203e4b17023SJohn Marino };
204e4b17023SJohn Marino typedef union rtunion_def rtunion;
205e4b17023SJohn Marino 
206e4b17023SJohn Marino /* This structure remembers the position of a SYMBOL_REF within an
207e4b17023SJohn Marino    object_block structure.  A SYMBOL_REF only provides this information
208e4b17023SJohn Marino    if SYMBOL_REF_HAS_BLOCK_INFO_P is true.  */
209e4b17023SJohn Marino struct GTY(()) block_symbol {
210e4b17023SJohn Marino   /* The usual SYMBOL_REF fields.  */
211e4b17023SJohn Marino   rtunion GTY ((skip)) fld[3];
212e4b17023SJohn Marino 
213e4b17023SJohn Marino   /* The block that contains this object.  */
214e4b17023SJohn Marino   struct object_block *block;
215e4b17023SJohn Marino 
216e4b17023SJohn Marino   /* The offset of this object from the start of its block.  It is negative
217e4b17023SJohn Marino      if the symbol has not yet been assigned an offset.  */
218e4b17023SJohn Marino   HOST_WIDE_INT offset;
219e4b17023SJohn Marino };
220e4b17023SJohn Marino 
221e4b17023SJohn Marino /* Describes a group of objects that are to be placed together in such
222e4b17023SJohn Marino    a way that their relative positions are known.  */
223e4b17023SJohn Marino struct GTY(()) object_block {
224e4b17023SJohn Marino   /* The section in which these objects should be placed.  */
225e4b17023SJohn Marino   section *sect;
226e4b17023SJohn Marino 
227e4b17023SJohn Marino   /* The alignment of the first object, measured in bits.  */
228e4b17023SJohn Marino   unsigned int alignment;
229e4b17023SJohn Marino 
230e4b17023SJohn Marino   /* The total size of the objects, measured in bytes.  */
231e4b17023SJohn Marino   HOST_WIDE_INT size;
232e4b17023SJohn Marino 
233e4b17023SJohn Marino   /* The SYMBOL_REFs for each object.  The vector is sorted in
234e4b17023SJohn Marino      order of increasing offset and the following conditions will
235e4b17023SJohn Marino      hold for each element X:
236e4b17023SJohn Marino 
237e4b17023SJohn Marino 	 SYMBOL_REF_HAS_BLOCK_INFO_P (X)
238e4b17023SJohn Marino 	 !SYMBOL_REF_ANCHOR_P (X)
239e4b17023SJohn Marino 	 SYMBOL_REF_BLOCK (X) == [address of this structure]
240e4b17023SJohn Marino 	 SYMBOL_REF_BLOCK_OFFSET (X) >= 0.  */
241e4b17023SJohn Marino   VEC(rtx,gc) *objects;
242e4b17023SJohn Marino 
243e4b17023SJohn Marino   /* All the anchor SYMBOL_REFs used to address these objects, sorted
244e4b17023SJohn Marino      in order of increasing offset, and then increasing TLS model.
245e4b17023SJohn Marino      The following conditions will hold for each element X in this vector:
246e4b17023SJohn Marino 
247e4b17023SJohn Marino 	 SYMBOL_REF_HAS_BLOCK_INFO_P (X)
248e4b17023SJohn Marino 	 SYMBOL_REF_ANCHOR_P (X)
249e4b17023SJohn Marino 	 SYMBOL_REF_BLOCK (X) == [address of this structure]
250e4b17023SJohn Marino 	 SYMBOL_REF_BLOCK_OFFSET (X) >= 0.  */
251e4b17023SJohn Marino   VEC(rtx,gc) *anchors;
252e4b17023SJohn Marino };
253e4b17023SJohn Marino 
254e4b17023SJohn Marino /* RTL expression ("rtx").  */
255e4b17023SJohn Marino 
256e4b17023SJohn Marino struct GTY((chain_next ("RTX_NEXT (&%h)"),
257e4b17023SJohn Marino 	    chain_prev ("RTX_PREV (&%h)"), variable_size)) rtx_def {
258e4b17023SJohn Marino   /* The kind of expression this is.  */
259e4b17023SJohn Marino   ENUM_BITFIELD(rtx_code) code: 16;
260e4b17023SJohn Marino 
261e4b17023SJohn Marino   /* The kind of value the expression has.  */
262e4b17023SJohn Marino   ENUM_BITFIELD(machine_mode) mode : 8;
263e4b17023SJohn Marino 
264e4b17023SJohn Marino   /* 1 in a MEM if we should keep the alias set for this mem unchanged
265e4b17023SJohn Marino      when we access a component.
266e4b17023SJohn Marino      1 in a CALL_INSN if it is a sibling call.
267e4b17023SJohn Marino      1 in a SET that is for a return.
268e4b17023SJohn Marino      In a CODE_LABEL, part of the two-bit alternate entry field.
269e4b17023SJohn Marino      1 in a CONCAT is VAL_EXPR_IS_COPIED in var-tracking.c.  */
270e4b17023SJohn Marino   unsigned int jump : 1;
271e4b17023SJohn Marino   /* In a CODE_LABEL, part of the two-bit alternate entry field.
272e4b17023SJohn Marino      1 in a MEM if it cannot trap.
273e4b17023SJohn Marino      1 in a CALL_INSN logically equivalent to
274e4b17023SJohn Marino        ECF_LOOPING_CONST_OR_PURE and DECL_LOOPING_CONST_OR_PURE_P. */
275e4b17023SJohn Marino   unsigned int call : 1;
276e4b17023SJohn Marino   /* 1 in a REG, MEM, or CONCAT if the value is set at most once, anywhere.
277e4b17023SJohn Marino      1 in a SUBREG used for SUBREG_PROMOTED_UNSIGNED_P.
278e4b17023SJohn Marino      1 in a SYMBOL_REF if it addresses something in the per-function
279e4b17023SJohn Marino      constants pool.
280e4b17023SJohn Marino      1 in a CALL_INSN logically equivalent to ECF_CONST and TREE_READONLY.
281e4b17023SJohn Marino      1 in a NOTE, or EXPR_LIST for a const call.
282e4b17023SJohn Marino      1 in a JUMP_INSN of an annulling branch.
283e4b17023SJohn Marino      1 in a CONCAT is VAL_EXPR_IS_CLOBBERED in var-tracking.c.
284e4b17023SJohn Marino      1 in a preserved VALUE is PRESERVED_VALUE_P in cselib.c.  */
285e4b17023SJohn Marino   unsigned int unchanging : 1;
286e4b17023SJohn Marino   /* 1 in a MEM or ASM_OPERANDS expression if the memory reference is volatile.
287e4b17023SJohn Marino      1 in an INSN, CALL_INSN, JUMP_INSN, CODE_LABEL, BARRIER, or NOTE
288e4b17023SJohn Marino      if it has been deleted.
289e4b17023SJohn Marino      1 in a REG expression if corresponds to a variable declared by the user,
290e4b17023SJohn Marino      0 for an internally generated temporary.
291e4b17023SJohn Marino      1 in a SUBREG used for SUBREG_PROMOTED_UNSIGNED_P.
292e4b17023SJohn Marino      1 in a LABEL_REF, REG_LABEL_TARGET or REG_LABEL_OPERAND note for a
293e4b17023SJohn Marino      non-local label.
294e4b17023SJohn Marino      In a SYMBOL_REF, this flag is used for machine-specific purposes.
295e4b17023SJohn Marino      In a PREFETCH, this flag indicates that it should be considered a scheduling
296e4b17023SJohn Marino      barrier.
297e4b17023SJohn Marino      1 in a CONCAT is VAL_NEEDS_RESOLUTION in var-tracking.c.  */
298e4b17023SJohn Marino   unsigned int volatil : 1;
299e4b17023SJohn Marino   /* 1 in a REG if the register is used only in exit code a loop.
300e4b17023SJohn Marino      1 in a SUBREG expression if was generated from a variable with a
301e4b17023SJohn Marino      promoted mode.
302e4b17023SJohn Marino      1 in a CODE_LABEL if the label is used for nonlocal gotos
303e4b17023SJohn Marino      and must not be deleted even if its count is zero.
304e4b17023SJohn Marino      1 in an INSN, JUMP_INSN or CALL_INSN if this insn must be scheduled
305e4b17023SJohn Marino      together with the preceding insn.  Valid only within sched.
306e4b17023SJohn Marino      1 in an INSN, JUMP_INSN, or CALL_INSN if insn is in a delay slot and
307e4b17023SJohn Marino      from the target of a branch.  Valid from reorg until end of compilation;
308e4b17023SJohn Marino      cleared before used.
309e4b17023SJohn Marino 
310e4b17023SJohn Marino      The name of the field is historical.  It used to be used in MEMs
311e4b17023SJohn Marino      to record whether the MEM accessed part of a structure.  */
312e4b17023SJohn Marino   unsigned int in_struct : 1;
313e4b17023SJohn Marino   /* At the end of RTL generation, 1 if this rtx is used.  This is used for
314e4b17023SJohn Marino      copying shared structure.  See `unshare_all_rtl'.
315e4b17023SJohn Marino      In a REG, this is not needed for that purpose, and used instead
316e4b17023SJohn Marino      in `leaf_renumber_regs_insn'.
317e4b17023SJohn Marino      1 in a SYMBOL_REF, means that emit_library_call
318e4b17023SJohn Marino      has used it as the function.
319e4b17023SJohn Marino      1 in a CONCAT is VAL_HOLDS_TRACK_EXPR in var-tracking.c.
320e4b17023SJohn Marino      1 in a VALUE or DEBUG_EXPR is VALUE_RECURSED_INTO in var-tracking.c.  */
321e4b17023SJohn Marino   unsigned int used : 1;
322e4b17023SJohn Marino   /* 1 in an INSN or a SET if this rtx is related to the call frame,
323e4b17023SJohn Marino      either changing how we compute the frame address or saving and
324e4b17023SJohn Marino      restoring registers in the prologue and epilogue.
325e4b17023SJohn Marino      1 in a REG or MEM if it is a pointer.
326e4b17023SJohn Marino      1 in a SYMBOL_REF if it addresses something in the per-function
327e4b17023SJohn Marino      constant string pool.
328e4b17023SJohn Marino      1 in a VALUE is VALUE_CHANGED in var-tracking.c.  */
329e4b17023SJohn Marino   unsigned frame_related : 1;
330e4b17023SJohn Marino   /* 1 in a REG or PARALLEL that is the current function's return value.
331e4b17023SJohn Marino      1 in a SYMBOL_REF for a weak symbol.
332e4b17023SJohn Marino      1 in a CALL_INSN logically equivalent to ECF_PURE and DECL_PURE_P.
333e4b17023SJohn Marino      1 in a CONCAT is VAL_EXPR_HAS_REVERSE in var-tracking.c.
334e4b17023SJohn Marino      1 in a VALUE or DEBUG_EXPR is NO_LOC_P in var-tracking.c.  */
335e4b17023SJohn Marino   unsigned return_val : 1;
336e4b17023SJohn Marino 
337e4b17023SJohn Marino   /* The first element of the operands of this rtx.
338e4b17023SJohn Marino      The number of operands and their types are controlled
339e4b17023SJohn Marino      by the `code' field, according to rtl.def.  */
340e4b17023SJohn Marino   union u {
341e4b17023SJohn Marino     rtunion fld[1];
342e4b17023SJohn Marino     HOST_WIDE_INT hwint[1];
343e4b17023SJohn Marino     struct block_symbol block_sym;
344e4b17023SJohn Marino     struct real_value rv;
345e4b17023SJohn Marino     struct fixed_value fv;
346e4b17023SJohn Marino   } GTY ((special ("rtx_def"), desc ("GET_CODE (&%0)"))) u;
347e4b17023SJohn Marino };
348e4b17023SJohn Marino 
349e4b17023SJohn Marino /* The size in bytes of an rtx header (code, mode and flags).  */
350e4b17023SJohn Marino #define RTX_HDR_SIZE offsetof (struct rtx_def, u)
351e4b17023SJohn Marino 
352e4b17023SJohn Marino /* The size in bytes of an rtx with code CODE.  */
353e4b17023SJohn Marino #define RTX_CODE_SIZE(CODE) rtx_code_size[CODE]
354e4b17023SJohn Marino 
355e4b17023SJohn Marino #define NULL_RTX (rtx) 0
356e4b17023SJohn Marino 
357e4b17023SJohn Marino /* The "next" and "previous" RTX, relative to this one.  */
358e4b17023SJohn Marino 
359e4b17023SJohn Marino #define RTX_NEXT(X) (rtx_next[GET_CODE (X)] == 0 ? NULL			\
360e4b17023SJohn Marino 		     : *(rtx *)(((char *)X) + rtx_next[GET_CODE (X)]))
361e4b17023SJohn Marino 
362e4b17023SJohn Marino /* FIXME: the "NEXT_INSN (PREV_INSN (X)) == X" condition shouldn't be needed.
363e4b17023SJohn Marino  */
364e4b17023SJohn Marino #define RTX_PREV(X) ((INSN_P (X)       			\
365e4b17023SJohn Marino                       || NOTE_P (X)       		\
366e4b17023SJohn Marino                       || BARRIER_P (X)        		\
367e4b17023SJohn Marino                       || LABEL_P (X))    		\
368e4b17023SJohn Marino                      && PREV_INSN (X) != NULL           \
369e4b17023SJohn Marino                      && NEXT_INSN (PREV_INSN (X)) == X  \
370e4b17023SJohn Marino                      ? PREV_INSN (X) : NULL)
371e4b17023SJohn Marino 
372e4b17023SJohn Marino /* Define macros to access the `code' field of the rtx.  */
373e4b17023SJohn Marino 
374e4b17023SJohn Marino #define GET_CODE(RTX)	    ((enum rtx_code) (RTX)->code)
375e4b17023SJohn Marino #define PUT_CODE(RTX, CODE) ((RTX)->code = (CODE))
376e4b17023SJohn Marino 
377e4b17023SJohn Marino #define GET_MODE(RTX)	    ((enum machine_mode) (RTX)->mode)
378e4b17023SJohn Marino #define PUT_MODE(RTX, MODE) ((RTX)->mode = (MODE))
379e4b17023SJohn Marino 
380e4b17023SJohn Marino /* RTL vector.  These appear inside RTX's when there is a need
381e4b17023SJohn Marino    for a variable number of things.  The principle use is inside
382e4b17023SJohn Marino    PARALLEL expressions.  */
383e4b17023SJohn Marino 
384e4b17023SJohn Marino struct GTY((variable_size)) rtvec_def {
385e4b17023SJohn Marino   int num_elem;		/* number of elements */
386e4b17023SJohn Marino   rtx GTY ((length ("%h.num_elem"))) elem[1];
387e4b17023SJohn Marino };
388e4b17023SJohn Marino 
389e4b17023SJohn Marino #define NULL_RTVEC (rtvec) 0
390e4b17023SJohn Marino 
391e4b17023SJohn Marino #define GET_NUM_ELEM(RTVEC)		((RTVEC)->num_elem)
392e4b17023SJohn Marino #define PUT_NUM_ELEM(RTVEC, NUM)	((RTVEC)->num_elem = (NUM))
393e4b17023SJohn Marino 
394e4b17023SJohn Marino /* Predicate yielding nonzero iff X is an rtx for a register.  */
395e4b17023SJohn Marino #define REG_P(X) (GET_CODE (X) == REG)
396e4b17023SJohn Marino 
397e4b17023SJohn Marino /* Predicate yielding nonzero iff X is an rtx for a memory location.  */
398e4b17023SJohn Marino #define MEM_P(X) (GET_CODE (X) == MEM)
399e4b17023SJohn Marino 
400e4b17023SJohn Marino /* Predicate yielding nonzero iff X is an rtx for a constant integer.  */
401e4b17023SJohn Marino #define CONST_INT_P(X) (GET_CODE (X) == CONST_INT)
402e4b17023SJohn Marino 
403e4b17023SJohn Marino /* Predicate yielding true iff X is an rtx for a double-int
404e4b17023SJohn Marino    or floating point constant.  */
405e4b17023SJohn Marino #define CONST_DOUBLE_P(X) (GET_CODE (X) == CONST_DOUBLE)
406e4b17023SJohn Marino 
407e4b17023SJohn Marino /* Predicate yielding nonzero iff X is a label insn.  */
408e4b17023SJohn Marino #define LABEL_P(X) (GET_CODE (X) == CODE_LABEL)
409e4b17023SJohn Marino 
410e4b17023SJohn Marino /* Predicate yielding nonzero iff X is a jump insn.  */
411e4b17023SJohn Marino #define JUMP_P(X) (GET_CODE (X) == JUMP_INSN)
412e4b17023SJohn Marino 
413e4b17023SJohn Marino /* Predicate yielding nonzero iff X is a call insn.  */
414e4b17023SJohn Marino #define CALL_P(X) (GET_CODE (X) == CALL_INSN)
415e4b17023SJohn Marino 
416e4b17023SJohn Marino /* Predicate yielding nonzero iff X is an insn that cannot jump.  */
417e4b17023SJohn Marino #define NONJUMP_INSN_P(X) (GET_CODE (X) == INSN)
418e4b17023SJohn Marino 
419e4b17023SJohn Marino /* Predicate yielding nonzero iff X is a debug note/insn.  */
420e4b17023SJohn Marino #define DEBUG_INSN_P(X) (GET_CODE (X) == DEBUG_INSN)
421e4b17023SJohn Marino 
422e4b17023SJohn Marino /* Predicate yielding nonzero iff X is an insn that is not a debug insn.  */
423e4b17023SJohn Marino #define NONDEBUG_INSN_P(X) (INSN_P (X) && !DEBUG_INSN_P (X))
424e4b17023SJohn Marino 
425e4b17023SJohn Marino /* Nonzero if DEBUG_INSN_P may possibly hold.  */
426e4b17023SJohn Marino #define MAY_HAVE_DEBUG_INSNS MAY_HAVE_DEBUG_STMTS
427e4b17023SJohn Marino 
428e4b17023SJohn Marino /* Predicate yielding nonzero iff X is a real insn.  */
429e4b17023SJohn Marino #define INSN_P(X) \
430e4b17023SJohn Marino   (NONJUMP_INSN_P (X) || DEBUG_INSN_P (X) || JUMP_P (X) || CALL_P (X))
431e4b17023SJohn Marino 
432e4b17023SJohn Marino /* Predicate yielding nonzero iff X is a note insn.  */
433e4b17023SJohn Marino #define NOTE_P(X) (GET_CODE (X) == NOTE)
434e4b17023SJohn Marino 
435e4b17023SJohn Marino /* Predicate yielding nonzero iff X is a barrier insn.  */
436e4b17023SJohn Marino #define BARRIER_P(X) (GET_CODE (X) == BARRIER)
437e4b17023SJohn Marino 
438e4b17023SJohn Marino /* Predicate yielding nonzero iff X is a data for a jump table.  */
439e4b17023SJohn Marino #define JUMP_TABLE_DATA_P(INSN) \
440e4b17023SJohn Marino   (JUMP_P (INSN) && (GET_CODE (PATTERN (INSN)) == ADDR_VEC || \
441e4b17023SJohn Marino 		     GET_CODE (PATTERN (INSN)) == ADDR_DIFF_VEC))
442e4b17023SJohn Marino 
443e4b17023SJohn Marino /* Predicate yielding nonzero iff X is a return or simple_return.  */
444e4b17023SJohn Marino #define ANY_RETURN_P(X) \
445e4b17023SJohn Marino   (GET_CODE (X) == RETURN || GET_CODE (X) == SIMPLE_RETURN)
446e4b17023SJohn Marino 
447e4b17023SJohn Marino /* 1 if X is a unary operator.  */
448e4b17023SJohn Marino 
449e4b17023SJohn Marino #define UNARY_P(X)   \
450e4b17023SJohn Marino   (GET_RTX_CLASS (GET_CODE (X)) == RTX_UNARY)
451e4b17023SJohn Marino 
452e4b17023SJohn Marino /* 1 if X is a binary operator.  */
453e4b17023SJohn Marino 
454e4b17023SJohn Marino #define BINARY_P(X)   \
455e4b17023SJohn Marino   ((GET_RTX_CLASS (GET_CODE (X)) & RTX_BINARY_MASK) == RTX_BINARY_RESULT)
456e4b17023SJohn Marino 
457e4b17023SJohn Marino /* 1 if X is an arithmetic operator.  */
458e4b17023SJohn Marino 
459e4b17023SJohn Marino #define ARITHMETIC_P(X)   \
460e4b17023SJohn Marino   ((GET_RTX_CLASS (GET_CODE (X)) & RTX_ARITHMETIC_MASK)			\
461e4b17023SJohn Marino     == RTX_ARITHMETIC_RESULT)
462e4b17023SJohn Marino 
463e4b17023SJohn Marino /* 1 if X is an arithmetic operator.  */
464e4b17023SJohn Marino 
465e4b17023SJohn Marino #define COMMUTATIVE_ARITH_P(X)   \
466e4b17023SJohn Marino   (GET_RTX_CLASS (GET_CODE (X)) == RTX_COMM_ARITH)
467e4b17023SJohn Marino 
468e4b17023SJohn Marino /* 1 if X is a commutative arithmetic operator or a comparison operator.
469e4b17023SJohn Marino    These two are sometimes selected together because it is possible to
470e4b17023SJohn Marino    swap the two operands.  */
471e4b17023SJohn Marino 
472e4b17023SJohn Marino #define SWAPPABLE_OPERANDS_P(X)   \
473e4b17023SJohn Marino   ((1 << GET_RTX_CLASS (GET_CODE (X)))					\
474e4b17023SJohn Marino     & ((1 << RTX_COMM_ARITH) | (1 << RTX_COMM_COMPARE)			\
475e4b17023SJohn Marino        | (1 << RTX_COMPARE)))
476e4b17023SJohn Marino 
477e4b17023SJohn Marino /* 1 if X is a non-commutative operator.  */
478e4b17023SJohn Marino 
479e4b17023SJohn Marino #define NON_COMMUTATIVE_P(X)   \
480e4b17023SJohn Marino   ((GET_RTX_CLASS (GET_CODE (X)) & RTX_COMMUTATIVE_MASK)		\
481e4b17023SJohn Marino     == RTX_NON_COMMUTATIVE_RESULT)
482e4b17023SJohn Marino 
483e4b17023SJohn Marino /* 1 if X is a commutative operator on integers.  */
484e4b17023SJohn Marino 
485e4b17023SJohn Marino #define COMMUTATIVE_P(X)   \
486e4b17023SJohn Marino   ((GET_RTX_CLASS (GET_CODE (X)) & RTX_COMMUTATIVE_MASK)		\
487e4b17023SJohn Marino     == RTX_COMMUTATIVE_RESULT)
488e4b17023SJohn Marino 
489e4b17023SJohn Marino /* 1 if X is a relational operator.  */
490e4b17023SJohn Marino 
491e4b17023SJohn Marino #define COMPARISON_P(X)   \
492e4b17023SJohn Marino   ((GET_RTX_CLASS (GET_CODE (X)) & RTX_COMPARE_MASK) == RTX_COMPARE_RESULT)
493e4b17023SJohn Marino 
494e4b17023SJohn Marino /* 1 if X is a constant value that is an integer.  */
495e4b17023SJohn Marino 
496e4b17023SJohn Marino #define CONSTANT_P(X)   \
497e4b17023SJohn Marino   (GET_RTX_CLASS (GET_CODE (X)) == RTX_CONST_OBJ)
498e4b17023SJohn Marino 
499e4b17023SJohn Marino /* 1 if X can be used to represent an object.  */
500e4b17023SJohn Marino #define OBJECT_P(X)							\
501e4b17023SJohn Marino   ((GET_RTX_CLASS (GET_CODE (X)) & RTX_OBJ_MASK) == RTX_OBJ_RESULT)
502e4b17023SJohn Marino 
503e4b17023SJohn Marino /* General accessor macros for accessing the fields of an rtx.  */
504e4b17023SJohn Marino 
505e4b17023SJohn Marino #if defined ENABLE_RTL_CHECKING && (GCC_VERSION >= 2007)
506e4b17023SJohn Marino /* The bit with a star outside the statement expr and an & inside is
507e4b17023SJohn Marino    so that N can be evaluated only once.  */
508e4b17023SJohn Marino #define RTL_CHECK1(RTX, N, C1) __extension__				\
509e4b17023SJohn Marino (*({ __typeof (RTX) const _rtx = (RTX); const int _n = (N);		\
510e4b17023SJohn Marino      const enum rtx_code _code = GET_CODE (_rtx);			\
511e4b17023SJohn Marino      if (_n < 0 || _n >= GET_RTX_LENGTH (_code))			\
512e4b17023SJohn Marino        rtl_check_failed_bounds (_rtx, _n, __FILE__, __LINE__,		\
513e4b17023SJohn Marino 				__FUNCTION__);				\
514e4b17023SJohn Marino      if (GET_RTX_FORMAT(_code)[_n] != C1)				\
515e4b17023SJohn Marino        rtl_check_failed_type1 (_rtx, _n, C1, __FILE__, __LINE__,	\
516e4b17023SJohn Marino 			       __FUNCTION__);				\
517e4b17023SJohn Marino      &_rtx->u.fld[_n]; }))
518e4b17023SJohn Marino 
519e4b17023SJohn Marino #define RTL_CHECK2(RTX, N, C1, C2) __extension__			\
520e4b17023SJohn Marino (*({ __typeof (RTX) const _rtx = (RTX); const int _n = (N);		\
521e4b17023SJohn Marino      const enum rtx_code _code = GET_CODE (_rtx);			\
522e4b17023SJohn Marino      if (_n < 0 || _n >= GET_RTX_LENGTH (_code))			\
523e4b17023SJohn Marino        rtl_check_failed_bounds (_rtx, _n, __FILE__, __LINE__,		\
524e4b17023SJohn Marino 				__FUNCTION__);				\
525e4b17023SJohn Marino      if (GET_RTX_FORMAT(_code)[_n] != C1				\
526e4b17023SJohn Marino 	 && GET_RTX_FORMAT(_code)[_n] != C2)				\
527e4b17023SJohn Marino        rtl_check_failed_type2 (_rtx, _n, C1, C2, __FILE__, __LINE__,	\
528e4b17023SJohn Marino 			       __FUNCTION__);				\
529e4b17023SJohn Marino      &_rtx->u.fld[_n]; }))
530e4b17023SJohn Marino 
531e4b17023SJohn Marino #define RTL_CHECKC1(RTX, N, C) __extension__				\
532e4b17023SJohn Marino (*({ __typeof (RTX) const _rtx = (RTX); const int _n = (N);		\
533e4b17023SJohn Marino      if (GET_CODE (_rtx) != (C))					\
534e4b17023SJohn Marino        rtl_check_failed_code1 (_rtx, (C), __FILE__, __LINE__,		\
535e4b17023SJohn Marino 			       __FUNCTION__);				\
536e4b17023SJohn Marino      &_rtx->u.fld[_n]; }))
537e4b17023SJohn Marino 
538e4b17023SJohn Marino #define RTL_CHECKC2(RTX, N, C1, C2) __extension__			\
539e4b17023SJohn Marino (*({ __typeof (RTX) const _rtx = (RTX); const int _n = (N);		\
540e4b17023SJohn Marino      const enum rtx_code _code = GET_CODE (_rtx);			\
541e4b17023SJohn Marino      if (_code != (C1) && _code != (C2))				\
542e4b17023SJohn Marino        rtl_check_failed_code2 (_rtx, (C1), (C2), __FILE__, __LINE__,	\
543e4b17023SJohn Marino 			       __FUNCTION__); \
544e4b17023SJohn Marino      &_rtx->u.fld[_n]; }))
545e4b17023SJohn Marino 
546e4b17023SJohn Marino #define RTVEC_ELT(RTVEC, I) __extension__				\
547e4b17023SJohn Marino (*({ __typeof (RTVEC) const _rtvec = (RTVEC); const int _i = (I);	\
548e4b17023SJohn Marino      if (_i < 0 || _i >= GET_NUM_ELEM (_rtvec))				\
549e4b17023SJohn Marino        rtvec_check_failed_bounds (_rtvec, _i, __FILE__, __LINE__,	\
550e4b17023SJohn Marino 				  __FUNCTION__);			\
551e4b17023SJohn Marino      &_rtvec->elem[_i]; }))
552e4b17023SJohn Marino 
553e4b17023SJohn Marino #define XWINT(RTX, N) __extension__					\
554e4b17023SJohn Marino (*({ __typeof (RTX) const _rtx = (RTX); const int _n = (N);		\
555e4b17023SJohn Marino      const enum rtx_code _code = GET_CODE (_rtx);			\
556e4b17023SJohn Marino      if (_n < 0 || _n >= GET_RTX_LENGTH (_code))			\
557e4b17023SJohn Marino        rtl_check_failed_bounds (_rtx, _n, __FILE__, __LINE__,		\
558e4b17023SJohn Marino 				__FUNCTION__);				\
559e4b17023SJohn Marino      if (GET_RTX_FORMAT(_code)[_n] != 'w')				\
560e4b17023SJohn Marino        rtl_check_failed_type1 (_rtx, _n, 'w', __FILE__, __LINE__,	\
561e4b17023SJohn Marino 			       __FUNCTION__);				\
562e4b17023SJohn Marino      &_rtx->u.hwint[_n]; }))
563e4b17023SJohn Marino 
564e4b17023SJohn Marino #define XCWINT(RTX, N, C) __extension__					\
565e4b17023SJohn Marino (*({ __typeof (RTX) const _rtx = (RTX);					\
566e4b17023SJohn Marino      if (GET_CODE (_rtx) != (C))					\
567e4b17023SJohn Marino        rtl_check_failed_code1 (_rtx, (C), __FILE__, __LINE__,		\
568e4b17023SJohn Marino 			       __FUNCTION__);				\
569e4b17023SJohn Marino      &_rtx->u.hwint[N]; }))
570e4b17023SJohn Marino 
571e4b17023SJohn Marino #define XCMWINT(RTX, N, C, M) __extension__				\
572e4b17023SJohn Marino (*({ __typeof (RTX) const _rtx = (RTX);					\
573e4b17023SJohn Marino      if (GET_CODE (_rtx) != (C) || GET_MODE (_rtx) != (M))		\
574e4b17023SJohn Marino        rtl_check_failed_code_mode (_rtx, (C), (M), false, __FILE__,	\
575e4b17023SJohn Marino 				   __LINE__, __FUNCTION__);		\
576e4b17023SJohn Marino      &_rtx->u.hwint[N]; }))
577e4b17023SJohn Marino 
578e4b17023SJohn Marino #define XCNMPRV(RTX, C, M) __extension__				\
579e4b17023SJohn Marino ({ __typeof (RTX) const _rtx = (RTX);					\
580e4b17023SJohn Marino    if (GET_CODE (_rtx) != (C) || GET_MODE (_rtx) == (M))		\
581e4b17023SJohn Marino      rtl_check_failed_code_mode (_rtx, (C), (M), true, __FILE__,	\
582e4b17023SJohn Marino 				 __LINE__, __FUNCTION__);		\
583e4b17023SJohn Marino    &_rtx->u.rv; })
584e4b17023SJohn Marino 
585e4b17023SJohn Marino #define XCNMPFV(RTX, C, M) __extension__				\
586e4b17023SJohn Marino ({ __typeof (RTX) const _rtx = (RTX);					\
587e4b17023SJohn Marino    if (GET_CODE (_rtx) != (C) || GET_MODE (_rtx) == (M))		\
588e4b17023SJohn Marino      rtl_check_failed_code_mode (_rtx, (C), (M), true, __FILE__,	\
589e4b17023SJohn Marino 				 __LINE__, __FUNCTION__);		\
590e4b17023SJohn Marino    &_rtx->u.fv; })
591e4b17023SJohn Marino 
592e4b17023SJohn Marino #define BLOCK_SYMBOL_CHECK(RTX) __extension__				\
593e4b17023SJohn Marino ({ __typeof (RTX) const _symbol = (RTX);				\
594e4b17023SJohn Marino    const unsigned int flags = RTL_CHECKC1 (_symbol, 1, SYMBOL_REF).rt_int; \
595e4b17023SJohn Marino    if ((flags & SYMBOL_FLAG_HAS_BLOCK_INFO) == 0)			\
596e4b17023SJohn Marino      rtl_check_failed_block_symbol (__FILE__, __LINE__,			\
597e4b17023SJohn Marino 				    __FUNCTION__);			\
598e4b17023SJohn Marino    &_symbol->u.block_sym; })
599e4b17023SJohn Marino 
600e4b17023SJohn Marino extern void rtl_check_failed_bounds (const_rtx, int, const char *, int,
601e4b17023SJohn Marino 				     const char *)
602e4b17023SJohn Marino     ATTRIBUTE_NORETURN;
603e4b17023SJohn Marino extern void rtl_check_failed_type1 (const_rtx, int, int, const char *, int,
604e4b17023SJohn Marino 				    const char *)
605e4b17023SJohn Marino     ATTRIBUTE_NORETURN;
606e4b17023SJohn Marino extern void rtl_check_failed_type2 (const_rtx, int, int, int, const char *,
607e4b17023SJohn Marino 				    int, const char *)
608e4b17023SJohn Marino     ATTRIBUTE_NORETURN;
609e4b17023SJohn Marino extern void rtl_check_failed_code1 (const_rtx, enum rtx_code, const char *,
610e4b17023SJohn Marino 				    int, const char *)
611e4b17023SJohn Marino     ATTRIBUTE_NORETURN;
612e4b17023SJohn Marino extern void rtl_check_failed_code2 (const_rtx, enum rtx_code, enum rtx_code,
613e4b17023SJohn Marino 				    const char *, int, const char *)
614e4b17023SJohn Marino     ATTRIBUTE_NORETURN;
615e4b17023SJohn Marino extern void rtl_check_failed_code_mode (const_rtx, enum rtx_code, enum machine_mode,
616e4b17023SJohn Marino 					bool, const char *, int, const char *)
617e4b17023SJohn Marino     ATTRIBUTE_NORETURN;
618e4b17023SJohn Marino extern void rtl_check_failed_block_symbol (const char *, int, const char *)
619e4b17023SJohn Marino     ATTRIBUTE_NORETURN;
620e4b17023SJohn Marino extern void rtvec_check_failed_bounds (const_rtvec, int, const char *, int,
621e4b17023SJohn Marino 				       const char *)
622e4b17023SJohn Marino     ATTRIBUTE_NORETURN;
623e4b17023SJohn Marino 
624e4b17023SJohn Marino #else   /* not ENABLE_RTL_CHECKING */
625e4b17023SJohn Marino 
626e4b17023SJohn Marino #define RTL_CHECK1(RTX, N, C1)      ((RTX)->u.fld[N])
627e4b17023SJohn Marino #define RTL_CHECK2(RTX, N, C1, C2)  ((RTX)->u.fld[N])
628e4b17023SJohn Marino #define RTL_CHECKC1(RTX, N, C)	    ((RTX)->u.fld[N])
629e4b17023SJohn Marino #define RTL_CHECKC2(RTX, N, C1, C2) ((RTX)->u.fld[N])
630e4b17023SJohn Marino #define RTVEC_ELT(RTVEC, I)	    ((RTVEC)->elem[I])
631e4b17023SJohn Marino #define XWINT(RTX, N)		    ((RTX)->u.hwint[N])
632e4b17023SJohn Marino #define XCWINT(RTX, N, C)	    ((RTX)->u.hwint[N])
633e4b17023SJohn Marino #define XCMWINT(RTX, N, C, M)	    ((RTX)->u.hwint[N])
634e4b17023SJohn Marino #define XCNMWINT(RTX, N, C, M)	    ((RTX)->u.hwint[N])
635e4b17023SJohn Marino #define XCNMPRV(RTX, C, M)	    (&(RTX)->u.rv)
636e4b17023SJohn Marino #define XCNMPFV(RTX, C, M)	    (&(RTX)->u.fv)
637e4b17023SJohn Marino #define BLOCK_SYMBOL_CHECK(RTX)	    (&(RTX)->u.block_sym)
638e4b17023SJohn Marino 
639e4b17023SJohn Marino #endif
640e4b17023SJohn Marino 
641e4b17023SJohn Marino /* General accessor macros for accessing the flags of an rtx.  */
642e4b17023SJohn Marino 
643e4b17023SJohn Marino /* Access an individual rtx flag, with no checking of any kind.  */
644e4b17023SJohn Marino #define RTX_FLAG(RTX, FLAG)	((RTX)->FLAG)
645e4b17023SJohn Marino 
646e4b17023SJohn Marino #if defined ENABLE_RTL_FLAG_CHECKING && (GCC_VERSION >= 2007)
647e4b17023SJohn Marino #define RTL_FLAG_CHECK1(NAME, RTX, C1) __extension__			\
648e4b17023SJohn Marino ({ __typeof (RTX) const _rtx = (RTX);					\
649e4b17023SJohn Marino    if (GET_CODE(_rtx) != C1)						\
650e4b17023SJohn Marino      rtl_check_failed_flag  (NAME, _rtx, __FILE__, __LINE__,		\
651e4b17023SJohn Marino 			     __FUNCTION__);				\
652e4b17023SJohn Marino    _rtx; })
653e4b17023SJohn Marino 
654e4b17023SJohn Marino #define RTL_FLAG_CHECK2(NAME, RTX, C1, C2) __extension__		\
655e4b17023SJohn Marino ({ __typeof (RTX) const _rtx = (RTX);					\
656e4b17023SJohn Marino    if (GET_CODE(_rtx) != C1 && GET_CODE(_rtx) != C2)			\
657e4b17023SJohn Marino      rtl_check_failed_flag  (NAME,_rtx, __FILE__, __LINE__,		\
658e4b17023SJohn Marino 			      __FUNCTION__);				\
659e4b17023SJohn Marino    _rtx; })
660e4b17023SJohn Marino 
661e4b17023SJohn Marino #define RTL_FLAG_CHECK3(NAME, RTX, C1, C2, C3) __extension__		\
662e4b17023SJohn Marino ({ __typeof (RTX) const _rtx = (RTX);					\
663e4b17023SJohn Marino    if (GET_CODE(_rtx) != C1 && GET_CODE(_rtx) != C2			\
664e4b17023SJohn Marino        && GET_CODE(_rtx) != C3)						\
665e4b17023SJohn Marino      rtl_check_failed_flag  (NAME, _rtx, __FILE__, __LINE__,		\
666e4b17023SJohn Marino 			     __FUNCTION__);				\
667e4b17023SJohn Marino    _rtx; })
668e4b17023SJohn Marino 
669e4b17023SJohn Marino #define RTL_FLAG_CHECK4(NAME, RTX, C1, C2, C3, C4) __extension__	\
670e4b17023SJohn Marino ({ __typeof (RTX) const _rtx = (RTX);					\
671e4b17023SJohn Marino    if (GET_CODE(_rtx) != C1 && GET_CODE(_rtx) != C2			\
672e4b17023SJohn Marino        && GET_CODE(_rtx) != C3 && GET_CODE(_rtx) != C4)			\
673e4b17023SJohn Marino      rtl_check_failed_flag  (NAME, _rtx, __FILE__, __LINE__,		\
674e4b17023SJohn Marino 			      __FUNCTION__);				\
675e4b17023SJohn Marino    _rtx; })
676e4b17023SJohn Marino 
677e4b17023SJohn Marino #define RTL_FLAG_CHECK5(NAME, RTX, C1, C2, C3, C4, C5) __extension__	\
678e4b17023SJohn Marino ({ __typeof (RTX) const _rtx = (RTX);					\
679e4b17023SJohn Marino    if (GET_CODE(_rtx) != C1 && GET_CODE(_rtx) != C2			\
680e4b17023SJohn Marino        && GET_CODE(_rtx) != C3 && GET_CODE(_rtx) != C4			\
681e4b17023SJohn Marino        && GET_CODE(_rtx) != C5)						\
682e4b17023SJohn Marino      rtl_check_failed_flag  (NAME, _rtx, __FILE__, __LINE__,		\
683e4b17023SJohn Marino 			     __FUNCTION__);				\
684e4b17023SJohn Marino    _rtx; })
685e4b17023SJohn Marino 
686e4b17023SJohn Marino #define RTL_FLAG_CHECK6(NAME, RTX, C1, C2, C3, C4, C5, C6)		\
687e4b17023SJohn Marino   __extension__								\
688e4b17023SJohn Marino ({ __typeof (RTX) const _rtx = (RTX);					\
689e4b17023SJohn Marino    if (GET_CODE(_rtx) != C1 && GET_CODE(_rtx) != C2			\
690e4b17023SJohn Marino        && GET_CODE(_rtx) != C3 && GET_CODE(_rtx) != C4			\
691e4b17023SJohn Marino        && GET_CODE(_rtx) != C5 && GET_CODE(_rtx) != C6)			\
692e4b17023SJohn Marino      rtl_check_failed_flag  (NAME,_rtx, __FILE__, __LINE__,		\
693e4b17023SJohn Marino 			     __FUNCTION__);				\
694e4b17023SJohn Marino    _rtx; })
695e4b17023SJohn Marino 
696e4b17023SJohn Marino #define RTL_FLAG_CHECK7(NAME, RTX, C1, C2, C3, C4, C5, C6, C7)		\
697e4b17023SJohn Marino   __extension__								\
698e4b17023SJohn Marino ({ __typeof (RTX) const _rtx = (RTX);					\
699e4b17023SJohn Marino    if (GET_CODE(_rtx) != C1 && GET_CODE(_rtx) != C2			\
700e4b17023SJohn Marino        && GET_CODE(_rtx) != C3 && GET_CODE(_rtx) != C4			\
701e4b17023SJohn Marino        && GET_CODE(_rtx) != C5 && GET_CODE(_rtx) != C6			\
702e4b17023SJohn Marino        && GET_CODE(_rtx) != C7)						\
703e4b17023SJohn Marino      rtl_check_failed_flag  (NAME, _rtx, __FILE__, __LINE__,		\
704e4b17023SJohn Marino 			     __FUNCTION__);				\
705e4b17023SJohn Marino    _rtx; })
706e4b17023SJohn Marino 
707e4b17023SJohn Marino #define RTL_FLAG_CHECK8(NAME, RTX, C1, C2, C3, C4, C5, C6, C7, C8)	\
708e4b17023SJohn Marino   __extension__								\
709e4b17023SJohn Marino ({ __typeof (RTX) const _rtx = (RTX);					\
710e4b17023SJohn Marino    if (GET_CODE(_rtx) != C1 && GET_CODE(_rtx) != C2			\
711e4b17023SJohn Marino        && GET_CODE(_rtx) != C3 && GET_CODE(_rtx) != C4			\
712e4b17023SJohn Marino        && GET_CODE(_rtx) != C5 && GET_CODE(_rtx) != C6			\
713e4b17023SJohn Marino        && GET_CODE(_rtx) != C7 && GET_CODE(_rtx) != C8)			\
714e4b17023SJohn Marino      rtl_check_failed_flag  (NAME, _rtx, __FILE__, __LINE__,		\
715e4b17023SJohn Marino 			     __FUNCTION__);				\
716e4b17023SJohn Marino    _rtx; })
717e4b17023SJohn Marino 
718e4b17023SJohn Marino extern void rtl_check_failed_flag (const char *, const_rtx, const char *,
719e4b17023SJohn Marino 				   int, const char *)
720e4b17023SJohn Marino     ATTRIBUTE_NORETURN
721e4b17023SJohn Marino     ;
722e4b17023SJohn Marino 
723e4b17023SJohn Marino #else	/* not ENABLE_RTL_FLAG_CHECKING */
724e4b17023SJohn Marino 
725e4b17023SJohn Marino #define RTL_FLAG_CHECK1(NAME, RTX, C1)					(RTX)
726e4b17023SJohn Marino #define RTL_FLAG_CHECK2(NAME, RTX, C1, C2)				(RTX)
727e4b17023SJohn Marino #define RTL_FLAG_CHECK3(NAME, RTX, C1, C2, C3)				(RTX)
728e4b17023SJohn Marino #define RTL_FLAG_CHECK4(NAME, RTX, C1, C2, C3, C4)			(RTX)
729e4b17023SJohn Marino #define RTL_FLAG_CHECK5(NAME, RTX, C1, C2, C3, C4, C5)		(RTX)
730e4b17023SJohn Marino #define RTL_FLAG_CHECK6(NAME, RTX, C1, C2, C3, C4, C5, C6)		(RTX)
731e4b17023SJohn Marino #define RTL_FLAG_CHECK7(NAME, RTX, C1, C2, C3, C4, C5, C6, C7)		(RTX)
732e4b17023SJohn Marino #define RTL_FLAG_CHECK8(NAME, RTX, C1, C2, C3, C4, C5, C6, C7, C8)	(RTX)
733e4b17023SJohn Marino #endif
734e4b17023SJohn Marino 
735e4b17023SJohn Marino #define XINT(RTX, N)	(RTL_CHECK2 (RTX, N, 'i', 'n').rt_int)
736e4b17023SJohn Marino #define XSTR(RTX, N)	(RTL_CHECK2 (RTX, N, 's', 'S').rt_str)
737e4b17023SJohn Marino #define XEXP(RTX, N)	(RTL_CHECK2 (RTX, N, 'e', 'u').rt_rtx)
738e4b17023SJohn Marino #define XVEC(RTX, N)	(RTL_CHECK2 (RTX, N, 'E', 'V').rt_rtvec)
739e4b17023SJohn Marino #define XMODE(RTX, N)	(RTL_CHECK1 (RTX, N, 'M').rt_type)
740e4b17023SJohn Marino #define XTREE(RTX, N)   (RTL_CHECK1 (RTX, N, 't').rt_tree)
741e4b17023SJohn Marino #define XBBDEF(RTX, N)	(RTL_CHECK1 (RTX, N, 'B').rt_bb)
742e4b17023SJohn Marino #define XTMPL(RTX, N)	(RTL_CHECK1 (RTX, N, 'T').rt_str)
743e4b17023SJohn Marino #define XCFI(RTX, N)	(RTL_CHECK1 (RTX, N, 'C').rt_cfi)
744e4b17023SJohn Marino 
745e4b17023SJohn Marino #define XVECEXP(RTX, N, M)	RTVEC_ELT (XVEC (RTX, N), M)
746e4b17023SJohn Marino #define XVECLEN(RTX, N)		GET_NUM_ELEM (XVEC (RTX, N))
747e4b17023SJohn Marino 
748e4b17023SJohn Marino /* These are like XINT, etc. except that they expect a '0' field instead
749e4b17023SJohn Marino    of the normal type code.  */
750e4b17023SJohn Marino 
751e4b17023SJohn Marino #define X0INT(RTX, N)	   (RTL_CHECK1 (RTX, N, '0').rt_int)
752e4b17023SJohn Marino #define X0UINT(RTX, N)	   (RTL_CHECK1 (RTX, N, '0').rt_uint)
753e4b17023SJohn Marino #define X0STR(RTX, N)	   (RTL_CHECK1 (RTX, N, '0').rt_str)
754e4b17023SJohn Marino #define X0EXP(RTX, N)	   (RTL_CHECK1 (RTX, N, '0').rt_rtx)
755e4b17023SJohn Marino #define X0VEC(RTX, N)	   (RTL_CHECK1 (RTX, N, '0').rt_rtvec)
756e4b17023SJohn Marino #define X0MODE(RTX, N)	   (RTL_CHECK1 (RTX, N, '0').rt_type)
757e4b17023SJohn Marino #define X0TREE(RTX, N)	   (RTL_CHECK1 (RTX, N, '0').rt_tree)
758e4b17023SJohn Marino #define X0BBDEF(RTX, N)	   (RTL_CHECK1 (RTX, N, '0').rt_bb)
759e4b17023SJohn Marino #define X0ADVFLAGS(RTX, N) (RTL_CHECK1 (RTX, N, '0').rt_addr_diff_vec_flags)
760e4b17023SJohn Marino #define X0CSELIB(RTX, N)   (RTL_CHECK1 (RTX, N, '0').rt_cselib)
761e4b17023SJohn Marino #define X0MEMATTR(RTX, N)  (RTL_CHECKC1 (RTX, N, MEM).rt_mem)
762e4b17023SJohn Marino #define X0REGATTR(RTX, N)  (RTL_CHECKC1 (RTX, N, REG).rt_reg)
763e4b17023SJohn Marino #define X0CONSTANT(RTX, N) (RTL_CHECK1 (RTX, N, '0').rt_constant)
764e4b17023SJohn Marino 
765e4b17023SJohn Marino /* Access a '0' field with any type.  */
766e4b17023SJohn Marino #define X0ANY(RTX, N)	   RTL_CHECK1 (RTX, N, '0')
767e4b17023SJohn Marino 
768e4b17023SJohn Marino #define XCINT(RTX, N, C)      (RTL_CHECKC1 (RTX, N, C).rt_int)
769e4b17023SJohn Marino #define XCUINT(RTX, N, C)     (RTL_CHECKC1 (RTX, N, C).rt_uint)
770e4b17023SJohn Marino #define XCSTR(RTX, N, C)      (RTL_CHECKC1 (RTX, N, C).rt_str)
771e4b17023SJohn Marino #define XCEXP(RTX, N, C)      (RTL_CHECKC1 (RTX, N, C).rt_rtx)
772e4b17023SJohn Marino #define XCVEC(RTX, N, C)      (RTL_CHECKC1 (RTX, N, C).rt_rtvec)
773e4b17023SJohn Marino #define XCMODE(RTX, N, C)     (RTL_CHECKC1 (RTX, N, C).rt_type)
774e4b17023SJohn Marino #define XCTREE(RTX, N, C)     (RTL_CHECKC1 (RTX, N, C).rt_tree)
775e4b17023SJohn Marino #define XCBBDEF(RTX, N, C)    (RTL_CHECKC1 (RTX, N, C).rt_bb)
776e4b17023SJohn Marino #define XCCFI(RTX, N, C)      (RTL_CHECKC1 (RTX, N, C).rt_cfi)
777e4b17023SJohn Marino #define XCCSELIB(RTX, N, C)   (RTL_CHECKC1 (RTX, N, C).rt_cselib)
778e4b17023SJohn Marino 
779e4b17023SJohn Marino #define XCVECEXP(RTX, N, M, C)	RTVEC_ELT (XCVEC (RTX, N, C), M)
780e4b17023SJohn Marino #define XCVECLEN(RTX, N, C)	GET_NUM_ELEM (XCVEC (RTX, N, C))
781e4b17023SJohn Marino 
782e4b17023SJohn Marino #define XC2EXP(RTX, N, C1, C2)      (RTL_CHECKC2 (RTX, N, C1, C2).rt_rtx)
783e4b17023SJohn Marino 
784e4b17023SJohn Marino /* ACCESS MACROS for particular fields of insns.  */
785e4b17023SJohn Marino 
786e4b17023SJohn Marino /* Holds a unique number for each insn.
787e4b17023SJohn Marino    These are not necessarily sequentially increasing.  */
788e4b17023SJohn Marino #define INSN_UID(INSN)  XINT (INSN, 0)
789e4b17023SJohn Marino 
790e4b17023SJohn Marino /* Chain insns together in sequence.  */
791e4b17023SJohn Marino #define PREV_INSN(INSN)	XEXP (INSN, 1)
792e4b17023SJohn Marino #define NEXT_INSN(INSN)	XEXP (INSN, 2)
793e4b17023SJohn Marino 
794e4b17023SJohn Marino #define BLOCK_FOR_INSN(INSN) XBBDEF (INSN, 3)
795e4b17023SJohn Marino 
796e4b17023SJohn Marino /* The body of an insn.  */
797e4b17023SJohn Marino #define PATTERN(INSN)	XEXP (INSN, 4)
798e4b17023SJohn Marino 
799e4b17023SJohn Marino #define INSN_LOCATOR(INSN) XINT (INSN, 5)
800e4b17023SJohn Marino /* LOCATION of an RTX if relevant.  */
801e4b17023SJohn Marino #define RTL_LOCATION(X) (INSN_P (X) ? \
802e4b17023SJohn Marino 			 locator_location (INSN_LOCATOR (X)) \
803e4b17023SJohn Marino 			 : UNKNOWN_LOCATION)
804e4b17023SJohn Marino /* LOCATION of current INSN.  */
805e4b17023SJohn Marino #define CURR_INSN_LOCATION (locator_location (curr_insn_locator ()))
806e4b17023SJohn Marino 
807e4b17023SJohn Marino /* Code number of instruction, from when it was recognized.
808e4b17023SJohn Marino    -1 means this instruction has not been recognized yet.  */
809e4b17023SJohn Marino #define INSN_CODE(INSN) XINT (INSN, 6)
810e4b17023SJohn Marino 
811e4b17023SJohn Marino #define RTX_FRAME_RELATED_P(RTX)					\
812e4b17023SJohn Marino   (RTL_FLAG_CHECK6("RTX_FRAME_RELATED_P", (RTX), DEBUG_INSN, INSN,	\
813e4b17023SJohn Marino 		   CALL_INSN, JUMP_INSN, BARRIER, SET)->frame_related)
814e4b17023SJohn Marino 
815e4b17023SJohn Marino /* 1 if RTX is an insn that has been deleted.  */
816e4b17023SJohn Marino #define INSN_DELETED_P(RTX)						\
817e4b17023SJohn Marino   (RTL_FLAG_CHECK7("INSN_DELETED_P", (RTX), DEBUG_INSN, INSN,		\
818e4b17023SJohn Marino 		   CALL_INSN, JUMP_INSN,				\
819e4b17023SJohn Marino 		   CODE_LABEL, BARRIER, NOTE)->volatil)
820e4b17023SJohn Marino 
821e4b17023SJohn Marino /* 1 if RTX is a call to a const function.  Built from ECF_CONST and
822e4b17023SJohn Marino    TREE_READONLY.  */
823e4b17023SJohn Marino #define RTL_CONST_CALL_P(RTX)					\
824e4b17023SJohn Marino   (RTL_FLAG_CHECK1("RTL_CONST_CALL_P", (RTX), CALL_INSN)->unchanging)
825e4b17023SJohn Marino 
826e4b17023SJohn Marino /* 1 if RTX is a call to a pure function.  Built from ECF_PURE and
827e4b17023SJohn Marino    DECL_PURE_P.  */
828e4b17023SJohn Marino #define RTL_PURE_CALL_P(RTX)					\
829e4b17023SJohn Marino   (RTL_FLAG_CHECK1("RTL_PURE_CALL_P", (RTX), CALL_INSN)->return_val)
830e4b17023SJohn Marino 
831e4b17023SJohn Marino /* 1 if RTX is a call to a const or pure function.  */
832e4b17023SJohn Marino #define RTL_CONST_OR_PURE_CALL_P(RTX) \
833e4b17023SJohn Marino   (RTL_CONST_CALL_P(RTX) || RTL_PURE_CALL_P(RTX))
834e4b17023SJohn Marino 
835e4b17023SJohn Marino /* 1 if RTX is a call to a looping const or pure function.  Built from
836e4b17023SJohn Marino    ECF_LOOPING_CONST_OR_PURE and DECL_LOOPING_CONST_OR_PURE_P.  */
837e4b17023SJohn Marino #define RTL_LOOPING_CONST_OR_PURE_CALL_P(RTX)					\
838e4b17023SJohn Marino   (RTL_FLAG_CHECK1("CONST_OR_PURE_CALL_P", (RTX), CALL_INSN)->call)
839e4b17023SJohn Marino 
840e4b17023SJohn Marino /* 1 if RTX is a call_insn for a sibling call.  */
841e4b17023SJohn Marino #define SIBLING_CALL_P(RTX)						\
842e4b17023SJohn Marino   (RTL_FLAG_CHECK1("SIBLING_CALL_P", (RTX), CALL_INSN)->jump)
843e4b17023SJohn Marino 
844e4b17023SJohn Marino /* 1 if RTX is a jump_insn, call_insn, or insn that is an annulling branch.  */
845e4b17023SJohn Marino #define INSN_ANNULLED_BRANCH_P(RTX)					\
846e4b17023SJohn Marino   (RTL_FLAG_CHECK1("INSN_ANNULLED_BRANCH_P", (RTX), JUMP_INSN)->unchanging)
847e4b17023SJohn Marino 
848e4b17023SJohn Marino /* 1 if RTX is an insn in a delay slot and is from the target of the branch.
849e4b17023SJohn Marino    If the branch insn has INSN_ANNULLED_BRANCH_P set, this insn should only be
850e4b17023SJohn Marino    executed if the branch is taken.  For annulled branches with this bit
851e4b17023SJohn Marino    clear, the insn should be executed only if the branch is not taken.  */
852e4b17023SJohn Marino #define INSN_FROM_TARGET_P(RTX)						\
853e4b17023SJohn Marino   (RTL_FLAG_CHECK3("INSN_FROM_TARGET_P", (RTX), INSN, JUMP_INSN, CALL_INSN)->in_struct)
854e4b17023SJohn Marino 
855e4b17023SJohn Marino /* In an ADDR_DIFF_VEC, the flags for RTX for use by branch shortening.
856e4b17023SJohn Marino    See the comments for ADDR_DIFF_VEC in rtl.def.  */
857e4b17023SJohn Marino #define ADDR_DIFF_VEC_FLAGS(RTX) X0ADVFLAGS(RTX, 4)
858e4b17023SJohn Marino 
859e4b17023SJohn Marino /* In a VALUE, the value cselib has assigned to RTX.
860e4b17023SJohn Marino    This is a "struct cselib_val_struct", see cselib.h.  */
861e4b17023SJohn Marino #define CSELIB_VAL_PTR(RTX) X0CSELIB(RTX, 0)
862e4b17023SJohn Marino 
863e4b17023SJohn Marino /* Holds a list of notes on what this insn does to various REGs.
864e4b17023SJohn Marino    It is a chain of EXPR_LIST rtx's, where the second operand is the
865e4b17023SJohn Marino    chain pointer and the first operand is the REG being described.
866e4b17023SJohn Marino    The mode field of the EXPR_LIST contains not a real machine mode
867e4b17023SJohn Marino    but a value from enum reg_note.  */
868e4b17023SJohn Marino #define REG_NOTES(INSN)	XEXP(INSN, 7)
869e4b17023SJohn Marino 
870e4b17023SJohn Marino /* In an ENTRY_VALUE this is the DECL_INCOMING_RTL of the argument in
871e4b17023SJohn Marino    question.  */
872e4b17023SJohn Marino #define ENTRY_VALUE_EXP(RTX) (RTL_CHECKC1 (RTX, 0, ENTRY_VALUE).rt_rtx)
873e4b17023SJohn Marino 
874e4b17023SJohn Marino enum reg_note
875e4b17023SJohn Marino {
876e4b17023SJohn Marino #define DEF_REG_NOTE(NAME) NAME,
877e4b17023SJohn Marino #include "reg-notes.def"
878e4b17023SJohn Marino #undef DEF_REG_NOTE
879e4b17023SJohn Marino   REG_NOTE_MAX
880e4b17023SJohn Marino };
881e4b17023SJohn Marino 
882e4b17023SJohn Marino /* Define macros to extract and insert the reg-note kind in an EXPR_LIST.  */
883e4b17023SJohn Marino #define REG_NOTE_KIND(LINK) ((enum reg_note) GET_MODE (LINK))
884e4b17023SJohn Marino #define PUT_REG_NOTE_KIND(LINK, KIND) \
885e4b17023SJohn Marino   PUT_MODE (LINK, (enum machine_mode) (KIND))
886e4b17023SJohn Marino 
887e4b17023SJohn Marino /* Names for REG_NOTE's in EXPR_LIST insn's.  */
888e4b17023SJohn Marino 
889e4b17023SJohn Marino extern const char * const reg_note_name[];
890e4b17023SJohn Marino #define GET_REG_NOTE_NAME(MODE) (reg_note_name[(int) (MODE)])
891e4b17023SJohn Marino 
892e4b17023SJohn Marino /* This field is only present on CALL_INSNs.  It holds a chain of EXPR_LIST of
893e4b17023SJohn Marino    USE and CLOBBER expressions.
894e4b17023SJohn Marino      USE expressions list the registers filled with arguments that
895e4b17023SJohn Marino    are passed to the function.
896e4b17023SJohn Marino      CLOBBER expressions document the registers explicitly clobbered
897e4b17023SJohn Marino    by this CALL_INSN.
898e4b17023SJohn Marino      Pseudo registers can not be mentioned in this list.  */
899e4b17023SJohn Marino #define CALL_INSN_FUNCTION_USAGE(INSN)	XEXP(INSN, 8)
900e4b17023SJohn Marino 
901e4b17023SJohn Marino /* The label-number of a code-label.  The assembler label
902e4b17023SJohn Marino    is made from `L' and the label-number printed in decimal.
903e4b17023SJohn Marino    Label numbers are unique in a compilation.  */
904e4b17023SJohn Marino #define CODE_LABEL_NUMBER(INSN)	XINT (INSN, 6)
905e4b17023SJohn Marino 
906e4b17023SJohn Marino /* In a NOTE that is a line number, this is a string for the file name that the
907e4b17023SJohn Marino    line is in.  We use the same field to record block numbers temporarily in
908e4b17023SJohn Marino    NOTE_INSN_BLOCK_BEG and NOTE_INSN_BLOCK_END notes.  (We avoid lots of casts
909e4b17023SJohn Marino    between ints and pointers if we use a different macro for the block number.)
910e4b17023SJohn Marino    */
911e4b17023SJohn Marino 
912e4b17023SJohn Marino /* Opaque data.  */
913e4b17023SJohn Marino #define NOTE_DATA(INSN)	        RTL_CHECKC1 (INSN, 4, NOTE)
914e4b17023SJohn Marino #define NOTE_DELETED_LABEL_NAME(INSN) XCSTR (INSN, 4, NOTE)
915e4b17023SJohn Marino #define SET_INSN_DELETED(INSN) set_insn_deleted (INSN);
916e4b17023SJohn Marino #define NOTE_BLOCK(INSN)	XCTREE (INSN, 4, NOTE)
917e4b17023SJohn Marino #define NOTE_EH_HANDLER(INSN)	XCINT (INSN, 4, NOTE)
918e4b17023SJohn Marino #define NOTE_BASIC_BLOCK(INSN)	XCBBDEF (INSN, 4, NOTE)
919e4b17023SJohn Marino #define NOTE_VAR_LOCATION(INSN)	XCEXP (INSN, 4, NOTE)
920e4b17023SJohn Marino #define NOTE_CFI(INSN)		XCCFI (INSN, 4, NOTE)
921e4b17023SJohn Marino #define NOTE_LABEL_NUMBER(INSN)	XCINT (INSN, 4, NOTE)
922e4b17023SJohn Marino 
923e4b17023SJohn Marino /* In a NOTE that is a line number, this is the line number.
924e4b17023SJohn Marino    Other kinds of NOTEs are identified by negative numbers here.  */
925e4b17023SJohn Marino #define NOTE_KIND(INSN) XCINT (INSN, 5, NOTE)
926e4b17023SJohn Marino 
927e4b17023SJohn Marino /* Nonzero if INSN is a note marking the beginning of a basic block.  */
928e4b17023SJohn Marino #define NOTE_INSN_BASIC_BLOCK_P(INSN)			\
929e4b17023SJohn Marino   (GET_CODE (INSN) == NOTE				\
930e4b17023SJohn Marino    && NOTE_KIND (INSN) == NOTE_INSN_BASIC_BLOCK)
931e4b17023SJohn Marino 
932e4b17023SJohn Marino /* Variable declaration and the location of a variable.  */
933e4b17023SJohn Marino #define PAT_VAR_LOCATION_DECL(PAT) (XCTREE ((PAT), 0, VAR_LOCATION))
934e4b17023SJohn Marino #define PAT_VAR_LOCATION_LOC(PAT) (XCEXP ((PAT), 1, VAR_LOCATION))
935e4b17023SJohn Marino 
936e4b17023SJohn Marino /* Initialization status of the variable in the location.  Status
937e4b17023SJohn Marino    can be unknown, uninitialized or initialized.  See enumeration
938e4b17023SJohn Marino    type below.  */
939e4b17023SJohn Marino #define PAT_VAR_LOCATION_STATUS(PAT) \
940e4b17023SJohn Marino   ((enum var_init_status) (XCINT ((PAT), 2, VAR_LOCATION)))
941e4b17023SJohn Marino 
942e4b17023SJohn Marino /* Accessors for a NOTE_INSN_VAR_LOCATION.  */
943e4b17023SJohn Marino #define NOTE_VAR_LOCATION_DECL(NOTE) \
944e4b17023SJohn Marino   PAT_VAR_LOCATION_DECL (NOTE_VAR_LOCATION (NOTE))
945e4b17023SJohn Marino #define NOTE_VAR_LOCATION_LOC(NOTE) \
946e4b17023SJohn Marino   PAT_VAR_LOCATION_LOC (NOTE_VAR_LOCATION (NOTE))
947e4b17023SJohn Marino #define NOTE_VAR_LOCATION_STATUS(NOTE) \
948e4b17023SJohn Marino   PAT_VAR_LOCATION_STATUS (NOTE_VAR_LOCATION (NOTE))
949e4b17023SJohn Marino 
950e4b17023SJohn Marino /* The VAR_LOCATION rtx in a DEBUG_INSN.  */
951e4b17023SJohn Marino #define INSN_VAR_LOCATION(INSN) PATTERN (INSN)
952e4b17023SJohn Marino 
953e4b17023SJohn Marino /* Accessors for a tree-expanded var location debug insn.  */
954e4b17023SJohn Marino #define INSN_VAR_LOCATION_DECL(INSN) \
955e4b17023SJohn Marino   PAT_VAR_LOCATION_DECL (INSN_VAR_LOCATION (INSN))
956e4b17023SJohn Marino #define INSN_VAR_LOCATION_LOC(INSN) \
957e4b17023SJohn Marino   PAT_VAR_LOCATION_LOC (INSN_VAR_LOCATION (INSN))
958e4b17023SJohn Marino #define INSN_VAR_LOCATION_STATUS(INSN) \
959e4b17023SJohn Marino   PAT_VAR_LOCATION_STATUS (INSN_VAR_LOCATION (INSN))
960e4b17023SJohn Marino 
961e4b17023SJohn Marino /* Expand to the RTL that denotes an unknown variable location in a
962e4b17023SJohn Marino    DEBUG_INSN.  */
963e4b17023SJohn Marino #define gen_rtx_UNKNOWN_VAR_LOC() (gen_rtx_CLOBBER (VOIDmode, const0_rtx))
964e4b17023SJohn Marino 
965e4b17023SJohn Marino /* Determine whether X is such an unknown location.  */
966e4b17023SJohn Marino #define VAR_LOC_UNKNOWN_P(X) \
967e4b17023SJohn Marino   (GET_CODE (X) == CLOBBER && XEXP ((X), 0) == const0_rtx)
968e4b17023SJohn Marino 
969e4b17023SJohn Marino /* 1 if RTX is emitted after a call, but it should take effect before
970e4b17023SJohn Marino    the call returns.  */
971e4b17023SJohn Marino #define NOTE_DURING_CALL_P(RTX)				\
972e4b17023SJohn Marino   (RTL_FLAG_CHECK1("NOTE_VAR_LOCATION_DURING_CALL_P", (RTX), NOTE)->call)
973e4b17023SJohn Marino 
974e4b17023SJohn Marino /* DEBUG_EXPR_DECL corresponding to a DEBUG_EXPR RTX.  */
975e4b17023SJohn Marino #define DEBUG_EXPR_TREE_DECL(RTX) XCTREE (RTX, 0, DEBUG_EXPR)
976e4b17023SJohn Marino 
977e4b17023SJohn Marino /* VAR_DECL/PARM_DECL DEBUG_IMPLICIT_PTR takes address of.  */
978e4b17023SJohn Marino #define DEBUG_IMPLICIT_PTR_DECL(RTX) XCTREE (RTX, 0, DEBUG_IMPLICIT_PTR)
979e4b17023SJohn Marino 
980e4b17023SJohn Marino /* PARM_DECL DEBUG_PARAMETER_REF references.  */
981e4b17023SJohn Marino #define DEBUG_PARAMETER_REF_DECL(RTX) XCTREE (RTX, 0, DEBUG_PARAMETER_REF)
982e4b17023SJohn Marino 
983e4b17023SJohn Marino /* Codes that appear in the NOTE_KIND field for kinds of notes
984e4b17023SJohn Marino    that are not line numbers.  These codes are all negative.
985e4b17023SJohn Marino 
986e4b17023SJohn Marino    Notice that we do not try to use zero here for any of
987e4b17023SJohn Marino    the special note codes because sometimes the source line
988e4b17023SJohn Marino    actually can be zero!  This happens (for example) when we
989e4b17023SJohn Marino    are generating code for the per-translation-unit constructor
990e4b17023SJohn Marino    and destructor routines for some C++ translation unit.  */
991e4b17023SJohn Marino 
992e4b17023SJohn Marino enum insn_note
993e4b17023SJohn Marino {
994e4b17023SJohn Marino #define DEF_INSN_NOTE(NAME) NAME,
995e4b17023SJohn Marino #include "insn-notes.def"
996e4b17023SJohn Marino #undef DEF_INSN_NOTE
997e4b17023SJohn Marino 
998e4b17023SJohn Marino   NOTE_INSN_MAX
999e4b17023SJohn Marino };
1000e4b17023SJohn Marino 
1001e4b17023SJohn Marino /* Names for NOTE insn's other than line numbers.  */
1002e4b17023SJohn Marino 
1003e4b17023SJohn Marino extern const char * const note_insn_name[NOTE_INSN_MAX];
1004e4b17023SJohn Marino #define GET_NOTE_INSN_NAME(NOTE_CODE) \
1005e4b17023SJohn Marino   (note_insn_name[(NOTE_CODE)])
1006e4b17023SJohn Marino 
1007e4b17023SJohn Marino /* The name of a label, in case it corresponds to an explicit label
1008e4b17023SJohn Marino    in the input source code.  */
1009e4b17023SJohn Marino #define LABEL_NAME(RTX) XCSTR (RTX, 7, CODE_LABEL)
1010e4b17023SJohn Marino 
1011e4b17023SJohn Marino /* In jump.c, each label contains a count of the number
1012e4b17023SJohn Marino    of LABEL_REFs that point at it, so unused labels can be deleted.  */
1013e4b17023SJohn Marino #define LABEL_NUSES(RTX) XCINT (RTX, 5, CODE_LABEL)
1014e4b17023SJohn Marino 
1015e4b17023SJohn Marino /* Labels carry a two-bit field composed of the ->jump and ->call
1016e4b17023SJohn Marino    bits.  This field indicates whether the label is an alternate
1017e4b17023SJohn Marino    entry point, and if so, what kind.  */
1018e4b17023SJohn Marino enum label_kind
1019e4b17023SJohn Marino {
1020e4b17023SJohn Marino   LABEL_NORMAL = 0,	/* ordinary label */
1021e4b17023SJohn Marino   LABEL_STATIC_ENTRY,	/* alternate entry point, not exported */
1022e4b17023SJohn Marino   LABEL_GLOBAL_ENTRY,	/* alternate entry point, exported */
1023e4b17023SJohn Marino   LABEL_WEAK_ENTRY	/* alternate entry point, exported as weak symbol */
1024e4b17023SJohn Marino };
1025e4b17023SJohn Marino 
1026e4b17023SJohn Marino #if defined ENABLE_RTL_FLAG_CHECKING && (GCC_VERSION > 2007)
1027e4b17023SJohn Marino 
1028e4b17023SJohn Marino /* Retrieve the kind of LABEL.  */
1029e4b17023SJohn Marino #define LABEL_KIND(LABEL) __extension__					\
1030e4b17023SJohn Marino ({ __typeof (LABEL) const _label = (LABEL);				\
1031e4b17023SJohn Marino    if (GET_CODE (_label) != CODE_LABEL)					\
1032e4b17023SJohn Marino      rtl_check_failed_flag ("LABEL_KIND", _label, __FILE__, __LINE__,	\
1033e4b17023SJohn Marino 			    __FUNCTION__);				\
1034e4b17023SJohn Marino    (enum label_kind) ((_label->jump << 1) | _label->call); })
1035e4b17023SJohn Marino 
1036e4b17023SJohn Marino /* Set the kind of LABEL.  */
1037e4b17023SJohn Marino #define SET_LABEL_KIND(LABEL, KIND) do {				\
1038e4b17023SJohn Marino    __typeof (LABEL) const _label = (LABEL);				\
1039e4b17023SJohn Marino    const unsigned int _kind = (KIND);					\
1040e4b17023SJohn Marino    if (GET_CODE (_label) != CODE_LABEL)					\
1041e4b17023SJohn Marino      rtl_check_failed_flag ("SET_LABEL_KIND", _label, __FILE__, __LINE__, \
1042e4b17023SJohn Marino 			    __FUNCTION__);				\
1043e4b17023SJohn Marino    _label->jump = ((_kind >> 1) & 1);					\
1044e4b17023SJohn Marino    _label->call = (_kind & 1);						\
1045e4b17023SJohn Marino } while (0)
1046e4b17023SJohn Marino 
1047e4b17023SJohn Marino #else
1048e4b17023SJohn Marino 
1049e4b17023SJohn Marino /* Retrieve the kind of LABEL.  */
1050e4b17023SJohn Marino #define LABEL_KIND(LABEL) \
1051e4b17023SJohn Marino    ((enum label_kind) (((LABEL)->jump << 1) | (LABEL)->call))
1052e4b17023SJohn Marino 
1053e4b17023SJohn Marino /* Set the kind of LABEL.  */
1054e4b17023SJohn Marino #define SET_LABEL_KIND(LABEL, KIND) do {				\
1055e4b17023SJohn Marino    rtx const _label = (LABEL);						\
1056e4b17023SJohn Marino    const unsigned int _kind = (KIND);					\
1057e4b17023SJohn Marino    _label->jump = ((_kind >> 1) & 1);					\
1058e4b17023SJohn Marino    _label->call = (_kind & 1);						\
1059e4b17023SJohn Marino } while (0)
1060e4b17023SJohn Marino 
1061e4b17023SJohn Marino #endif /* rtl flag checking */
1062e4b17023SJohn Marino 
1063e4b17023SJohn Marino #define LABEL_ALT_ENTRY_P(LABEL) (LABEL_KIND (LABEL) != LABEL_NORMAL)
1064e4b17023SJohn Marino 
1065e4b17023SJohn Marino /* In jump.c, each JUMP_INSN can point to a label that it can jump to,
1066e4b17023SJohn Marino    so that if the JUMP_INSN is deleted, the label's LABEL_NUSES can
1067e4b17023SJohn Marino    be decremented and possibly the label can be deleted.  */
1068e4b17023SJohn Marino #define JUMP_LABEL(INSN)   XCEXP (INSN, 8, JUMP_INSN)
1069e4b17023SJohn Marino 
1070e4b17023SJohn Marino /* Once basic blocks are found, each CODE_LABEL starts a chain that
1071e4b17023SJohn Marino    goes through all the LABEL_REFs that jump to that label.  The chain
1072e4b17023SJohn Marino    eventually winds up at the CODE_LABEL: it is circular.  */
1073e4b17023SJohn Marino #define LABEL_REFS(LABEL) XCEXP (LABEL, 4, CODE_LABEL)
1074e4b17023SJohn Marino 
1075e4b17023SJohn Marino /* For a REG rtx, REGNO extracts the register number.  REGNO can only
1076e4b17023SJohn Marino    be used on RHS.  Use SET_REGNO to change the value.  */
1077e4b17023SJohn Marino #define REGNO(RTX) (rhs_regno(RTX))
1078e4b17023SJohn Marino #define SET_REGNO(RTX,N) (df_ref_change_reg_with_loc (REGNO(RTX), N, RTX), XCUINT (RTX, 0, REG) = N)
1079e4b17023SJohn Marino #define SET_REGNO_RAW(RTX,N) (XCUINT (RTX, 0, REG) = N)
1080e4b17023SJohn Marino 
1081e4b17023SJohn Marino /* ORIGINAL_REGNO holds the number the register originally had; for a
1082e4b17023SJohn Marino    pseudo register turned into a hard reg this will hold the old pseudo
1083e4b17023SJohn Marino    register number.  */
1084e4b17023SJohn Marino #define ORIGINAL_REGNO(RTX) X0UINT (RTX, 1)
1085e4b17023SJohn Marino 
1086e4b17023SJohn Marino /* Force the REGNO macro to only be used on the lhs.  */
1087e4b17023SJohn Marino static inline unsigned int
rhs_regno(const_rtx x)1088e4b17023SJohn Marino rhs_regno (const_rtx x)
1089e4b17023SJohn Marino {
1090e4b17023SJohn Marino   return XCUINT (x, 0, REG);
1091e4b17023SJohn Marino }
1092e4b17023SJohn Marino 
1093e4b17023SJohn Marino 
1094e4b17023SJohn Marino /* 1 if RTX is a reg or parallel that is the current function's return
1095e4b17023SJohn Marino    value.  */
1096e4b17023SJohn Marino #define REG_FUNCTION_VALUE_P(RTX)					\
1097e4b17023SJohn Marino   (RTL_FLAG_CHECK2("REG_FUNCTION_VALUE_P", (RTX), REG, PARALLEL)->return_val)
1098e4b17023SJohn Marino 
1099e4b17023SJohn Marino /* 1 if RTX is a reg that corresponds to a variable declared by the user.  */
1100e4b17023SJohn Marino #define REG_USERVAR_P(RTX)						\
1101e4b17023SJohn Marino   (RTL_FLAG_CHECK1("REG_USERVAR_P", (RTX), REG)->volatil)
1102e4b17023SJohn Marino 
1103e4b17023SJohn Marino /* 1 if RTX is a reg that holds a pointer value.  */
1104e4b17023SJohn Marino #define REG_POINTER(RTX)						\
1105e4b17023SJohn Marino   (RTL_FLAG_CHECK1("REG_POINTER", (RTX), REG)->frame_related)
1106e4b17023SJohn Marino 
1107e4b17023SJohn Marino /* 1 if RTX is a mem that holds a pointer value.  */
1108e4b17023SJohn Marino #define MEM_POINTER(RTX)						\
1109e4b17023SJohn Marino   (RTL_FLAG_CHECK1("MEM_POINTER", (RTX), MEM)->frame_related)
1110e4b17023SJohn Marino 
1111e4b17023SJohn Marino /* 1 if the given register REG corresponds to a hard register.  */
1112e4b17023SJohn Marino #define HARD_REGISTER_P(REG) (HARD_REGISTER_NUM_P (REGNO (REG)))
1113e4b17023SJohn Marino 
1114e4b17023SJohn Marino /* 1 if the given register number REG_NO corresponds to a hard register.  */
1115e4b17023SJohn Marino #define HARD_REGISTER_NUM_P(REG_NO) ((REG_NO) < FIRST_PSEUDO_REGISTER)
1116e4b17023SJohn Marino 
1117e4b17023SJohn Marino /* For a CONST_INT rtx, INTVAL extracts the integer.  */
1118e4b17023SJohn Marino #define INTVAL(RTX) XCWINT(RTX, 0, CONST_INT)
1119e4b17023SJohn Marino #define UINTVAL(RTX) ((unsigned HOST_WIDE_INT) INTVAL (RTX))
1120e4b17023SJohn Marino 
1121e4b17023SJohn Marino /* For a CONST_DOUBLE:
1122e4b17023SJohn Marino    For a VOIDmode, there are two integers CONST_DOUBLE_LOW is the
1123e4b17023SJohn Marino      low-order word and ..._HIGH the high-order.
1124e4b17023SJohn Marino    For a float, there is a REAL_VALUE_TYPE structure, and
1125e4b17023SJohn Marino      CONST_DOUBLE_REAL_VALUE(r) is a pointer to it.  */
1126e4b17023SJohn Marino #define CONST_DOUBLE_LOW(r) XCMWINT (r, 0, CONST_DOUBLE, VOIDmode)
1127e4b17023SJohn Marino #define CONST_DOUBLE_HIGH(r) XCMWINT (r, 1, CONST_DOUBLE, VOIDmode)
1128e4b17023SJohn Marino #define CONST_DOUBLE_REAL_VALUE(r) \
1129e4b17023SJohn Marino   ((const struct real_value *) XCNMPRV (r, CONST_DOUBLE, VOIDmode))
1130e4b17023SJohn Marino 
1131e4b17023SJohn Marino #define CONST_FIXED_VALUE(r) \
1132e4b17023SJohn Marino   ((const struct fixed_value *) XCNMPFV (r, CONST_FIXED, VOIDmode))
1133e4b17023SJohn Marino #define CONST_FIXED_VALUE_HIGH(r) \
1134e4b17023SJohn Marino   ((HOST_WIDE_INT) (CONST_FIXED_VALUE(r)->data.high))
1135e4b17023SJohn Marino #define CONST_FIXED_VALUE_LOW(r) \
1136e4b17023SJohn Marino   ((HOST_WIDE_INT) (CONST_FIXED_VALUE(r)->data.low))
1137e4b17023SJohn Marino 
1138e4b17023SJohn Marino /* For a CONST_VECTOR, return element #n.  */
1139e4b17023SJohn Marino #define CONST_VECTOR_ELT(RTX, N) XCVECEXP (RTX, 0, N, CONST_VECTOR)
1140e4b17023SJohn Marino 
1141e4b17023SJohn Marino /* For a CONST_VECTOR, return the number of elements in a vector.  */
1142e4b17023SJohn Marino #define CONST_VECTOR_NUNITS(RTX) XCVECLEN (RTX, 0, CONST_VECTOR)
1143e4b17023SJohn Marino 
1144e4b17023SJohn Marino /* For a SUBREG rtx, SUBREG_REG extracts the value we want a subreg of.
1145e4b17023SJohn Marino    SUBREG_BYTE extracts the byte-number.  */
1146e4b17023SJohn Marino 
1147e4b17023SJohn Marino #define SUBREG_REG(RTX) XCEXP (RTX, 0, SUBREG)
1148e4b17023SJohn Marino #define SUBREG_BYTE(RTX) XCUINT (RTX, 1, SUBREG)
1149e4b17023SJohn Marino 
1150e4b17023SJohn Marino /* in rtlanal.c */
1151e4b17023SJohn Marino /* Return the right cost to give to an operation
1152e4b17023SJohn Marino    to make the cost of the corresponding register-to-register instruction
1153e4b17023SJohn Marino    N times that of a fast register-to-register instruction.  */
1154e4b17023SJohn Marino #define COSTS_N_INSNS(N) ((N) * 4)
1155e4b17023SJohn Marino 
1156e4b17023SJohn Marino /* Maximum cost of an rtl expression.  This value has the special meaning
1157e4b17023SJohn Marino    not to use an rtx with this cost under any circumstances.  */
1158e4b17023SJohn Marino #define MAX_COST INT_MAX
1159e4b17023SJohn Marino 
1160e4b17023SJohn Marino /* A structure to hold all available cost information about an rtl
1161e4b17023SJohn Marino    expression.  */
1162e4b17023SJohn Marino struct full_rtx_costs
1163e4b17023SJohn Marino {
1164e4b17023SJohn Marino   int speed;
1165e4b17023SJohn Marino   int size;
1166e4b17023SJohn Marino };
1167e4b17023SJohn Marino 
1168e4b17023SJohn Marino /* Initialize a full_rtx_costs structure C to the maximum cost.  */
1169e4b17023SJohn Marino static inline void
init_costs_to_max(struct full_rtx_costs * c)1170e4b17023SJohn Marino init_costs_to_max (struct full_rtx_costs *c)
1171e4b17023SJohn Marino {
1172e4b17023SJohn Marino   c->speed = MAX_COST;
1173e4b17023SJohn Marino   c->size = MAX_COST;
1174e4b17023SJohn Marino }
1175e4b17023SJohn Marino 
1176e4b17023SJohn Marino /* Initialize a full_rtx_costs structure C to zero cost.  */
1177e4b17023SJohn Marino static inline void
init_costs_to_zero(struct full_rtx_costs * c)1178e4b17023SJohn Marino init_costs_to_zero (struct full_rtx_costs *c)
1179e4b17023SJohn Marino {
1180e4b17023SJohn Marino   c->speed = 0;
1181e4b17023SJohn Marino   c->size = 0;
1182e4b17023SJohn Marino }
1183e4b17023SJohn Marino 
1184e4b17023SJohn Marino /* Compare two full_rtx_costs structures A and B, returning true
1185e4b17023SJohn Marino    if A < B when optimizing for speed.  */
1186e4b17023SJohn Marino static inline bool
costs_lt_p(struct full_rtx_costs * a,struct full_rtx_costs * b,bool speed)1187e4b17023SJohn Marino costs_lt_p (struct full_rtx_costs *a, struct full_rtx_costs *b,
1188e4b17023SJohn Marino 	    bool speed)
1189e4b17023SJohn Marino {
1190e4b17023SJohn Marino   if (speed)
1191e4b17023SJohn Marino     return (a->speed < b->speed
1192e4b17023SJohn Marino 	    || (a->speed == b->speed && a->size < b->size));
1193e4b17023SJohn Marino   else
1194e4b17023SJohn Marino     return (a->size < b->size
1195e4b17023SJohn Marino 	    || (a->size == b->size && a->speed < b->speed));
1196e4b17023SJohn Marino }
1197e4b17023SJohn Marino 
1198e4b17023SJohn Marino /* Increase both members of the full_rtx_costs structure C by the
1199e4b17023SJohn Marino    cost of N insns.  */
1200e4b17023SJohn Marino static inline void
costs_add_n_insns(struct full_rtx_costs * c,int n)1201e4b17023SJohn Marino costs_add_n_insns (struct full_rtx_costs *c, int n)
1202e4b17023SJohn Marino {
1203e4b17023SJohn Marino   c->speed += COSTS_N_INSNS (n);
1204e4b17023SJohn Marino   c->size += COSTS_N_INSNS (n);
1205e4b17023SJohn Marino }
1206e4b17023SJohn Marino 
1207e4b17023SJohn Marino extern void init_rtlanal (void);
1208e4b17023SJohn Marino extern int rtx_cost (rtx, enum rtx_code, int, bool);
1209e4b17023SJohn Marino extern int address_cost (rtx, enum machine_mode, addr_space_t, bool);
1210e4b17023SJohn Marino extern void get_full_rtx_cost (rtx, enum rtx_code, int,
1211e4b17023SJohn Marino 			       struct full_rtx_costs *);
1212e4b17023SJohn Marino extern unsigned int subreg_lsb (const_rtx);
1213e4b17023SJohn Marino extern unsigned int subreg_lsb_1 (enum machine_mode, enum machine_mode,
1214e4b17023SJohn Marino 				  unsigned int);
1215e4b17023SJohn Marino extern unsigned int subreg_regno_offset	(unsigned int, enum machine_mode,
1216e4b17023SJohn Marino 					 unsigned int, enum machine_mode);
1217e4b17023SJohn Marino extern bool subreg_offset_representable_p (unsigned int, enum machine_mode,
1218e4b17023SJohn Marino 					   unsigned int, enum machine_mode);
1219e4b17023SJohn Marino extern unsigned int subreg_regno (const_rtx);
1220e4b17023SJohn Marino extern int simplify_subreg_regno (unsigned int, enum machine_mode,
1221e4b17023SJohn Marino 				  unsigned int, enum machine_mode);
1222e4b17023SJohn Marino extern unsigned int subreg_nregs (const_rtx);
1223e4b17023SJohn Marino extern unsigned int subreg_nregs_with_regno (unsigned int, const_rtx);
1224e4b17023SJohn Marino extern unsigned HOST_WIDE_INT nonzero_bits (const_rtx, enum machine_mode);
1225e4b17023SJohn Marino extern unsigned int num_sign_bit_copies (const_rtx, enum machine_mode);
1226e4b17023SJohn Marino extern bool constant_pool_constant_p (rtx);
1227e4b17023SJohn Marino extern bool truncated_to_mode (enum machine_mode, const_rtx);
1228e4b17023SJohn Marino extern int low_bitmask_len (enum machine_mode, unsigned HOST_WIDE_INT);
1229e4b17023SJohn Marino 
1230e4b17023SJohn Marino #ifndef GENERATOR_FILE
1231e4b17023SJohn Marino /* Return the cost of SET X.  SPEED_P is true if optimizing for speed
1232e4b17023SJohn Marino    rather than size.  */
1233e4b17023SJohn Marino 
1234e4b17023SJohn Marino static inline int
set_rtx_cost(rtx x,bool speed_p)1235e4b17023SJohn Marino set_rtx_cost (rtx x, bool speed_p)
1236e4b17023SJohn Marino {
1237e4b17023SJohn Marino   return rtx_cost (x, INSN, 4, speed_p);
1238e4b17023SJohn Marino }
1239e4b17023SJohn Marino 
1240e4b17023SJohn Marino /* Like set_rtx_cost, but return both the speed and size costs in C.  */
1241e4b17023SJohn Marino 
1242e4b17023SJohn Marino static inline void
get_full_set_rtx_cost(rtx x,struct full_rtx_costs * c)1243e4b17023SJohn Marino get_full_set_rtx_cost (rtx x, struct full_rtx_costs *c)
1244e4b17023SJohn Marino {
1245e4b17023SJohn Marino   get_full_rtx_cost (x, INSN, 4, c);
1246e4b17023SJohn Marino }
1247e4b17023SJohn Marino 
1248e4b17023SJohn Marino /* Return the cost of moving X into a register, relative to the cost
1249e4b17023SJohn Marino    of a register move.  SPEED_P is true if optimizing for speed rather
1250e4b17023SJohn Marino    than size.  */
1251e4b17023SJohn Marino 
1252e4b17023SJohn Marino static inline int
set_src_cost(rtx x,bool speed_p)1253e4b17023SJohn Marino set_src_cost (rtx x, bool speed_p)
1254e4b17023SJohn Marino {
1255e4b17023SJohn Marino   return rtx_cost (x, SET, 1, speed_p);
1256e4b17023SJohn Marino }
1257e4b17023SJohn Marino 
1258e4b17023SJohn Marino /* Like set_src_cost, but return both the speed and size costs in C.  */
1259e4b17023SJohn Marino 
1260e4b17023SJohn Marino static inline void
get_full_set_src_cost(rtx x,struct full_rtx_costs * c)1261e4b17023SJohn Marino get_full_set_src_cost (rtx x, struct full_rtx_costs *c)
1262e4b17023SJohn Marino {
1263e4b17023SJohn Marino   get_full_rtx_cost (x, SET, 1, c);
1264e4b17023SJohn Marino }
1265e4b17023SJohn Marino #endif
1266e4b17023SJohn Marino 
1267e4b17023SJohn Marino /* 1 if RTX is a subreg containing a reg that is already known to be
1268e4b17023SJohn Marino    sign- or zero-extended from the mode of the subreg to the mode of
1269e4b17023SJohn Marino    the reg.  SUBREG_PROMOTED_UNSIGNED_P gives the signedness of the
1270e4b17023SJohn Marino    extension.
1271e4b17023SJohn Marino 
1272e4b17023SJohn Marino    When used as a LHS, is means that this extension must be done
1273e4b17023SJohn Marino    when assigning to SUBREG_REG.  */
1274e4b17023SJohn Marino 
1275e4b17023SJohn Marino #define SUBREG_PROMOTED_VAR_P(RTX)					\
1276e4b17023SJohn Marino   (RTL_FLAG_CHECK1("SUBREG_PROMOTED", (RTX), SUBREG)->in_struct)
1277e4b17023SJohn Marino 
1278e4b17023SJohn Marino #define SUBREG_PROMOTED_UNSIGNED_SET(RTX, VAL)				\
1279e4b17023SJohn Marino do {									\
1280e4b17023SJohn Marino   rtx const _rtx = RTL_FLAG_CHECK1("SUBREG_PROMOTED_UNSIGNED_SET", (RTX), SUBREG); \
1281e4b17023SJohn Marino   if ((VAL) < 0)							\
1282e4b17023SJohn Marino     _rtx->volatil = 1;							\
1283e4b17023SJohn Marino   else {								\
1284e4b17023SJohn Marino     _rtx->volatil = 0;							\
1285e4b17023SJohn Marino     _rtx->unchanging = (VAL);						\
1286e4b17023SJohn Marino   }									\
1287e4b17023SJohn Marino } while (0)
1288e4b17023SJohn Marino 
1289e4b17023SJohn Marino /* Valid for subregs which are SUBREG_PROMOTED_VAR_P().  In that case
1290e4b17023SJohn Marino    this gives the necessary extensions:
1291e4b17023SJohn Marino    0  - signed
1292e4b17023SJohn Marino    1  - normal unsigned
1293e4b17023SJohn Marino    -1 - pointer unsigned, which most often can be handled like unsigned
1294e4b17023SJohn Marino         extension, except for generating instructions where we need to
1295e4b17023SJohn Marino 	emit special code (ptr_extend insns) on some architectures.  */
1296e4b17023SJohn Marino 
1297e4b17023SJohn Marino #define SUBREG_PROMOTED_UNSIGNED_P(RTX)	\
1298e4b17023SJohn Marino   ((RTL_FLAG_CHECK1("SUBREG_PROMOTED_UNSIGNED_P", (RTX), SUBREG)->volatil) \
1299e4b17023SJohn Marino    ? -1 : (int) (RTX)->unchanging)
1300e4b17023SJohn Marino 
1301e4b17023SJohn Marino /* Access various components of an ASM_OPERANDS rtx.  */
1302e4b17023SJohn Marino 
1303e4b17023SJohn Marino #define ASM_OPERANDS_TEMPLATE(RTX) XCSTR (RTX, 0, ASM_OPERANDS)
1304e4b17023SJohn Marino #define ASM_OPERANDS_OUTPUT_CONSTRAINT(RTX) XCSTR (RTX, 1, ASM_OPERANDS)
1305e4b17023SJohn Marino #define ASM_OPERANDS_OUTPUT_IDX(RTX) XCINT (RTX, 2, ASM_OPERANDS)
1306e4b17023SJohn Marino #define ASM_OPERANDS_INPUT_VEC(RTX) XCVEC (RTX, 3, ASM_OPERANDS)
1307e4b17023SJohn Marino #define ASM_OPERANDS_INPUT_CONSTRAINT_VEC(RTX) XCVEC (RTX, 4, ASM_OPERANDS)
1308e4b17023SJohn Marino #define ASM_OPERANDS_INPUT(RTX, N) XCVECEXP (RTX, 3, N, ASM_OPERANDS)
1309e4b17023SJohn Marino #define ASM_OPERANDS_INPUT_LENGTH(RTX) XCVECLEN (RTX, 3, ASM_OPERANDS)
1310e4b17023SJohn Marino #define ASM_OPERANDS_INPUT_CONSTRAINT_EXP(RTX, N) \
1311e4b17023SJohn Marino   XCVECEXP (RTX, 4, N, ASM_OPERANDS)
1312e4b17023SJohn Marino #define ASM_OPERANDS_INPUT_CONSTRAINT(RTX, N) \
1313e4b17023SJohn Marino   XSTR (XCVECEXP (RTX, 4, N, ASM_OPERANDS), 0)
1314e4b17023SJohn Marino #define ASM_OPERANDS_INPUT_MODE(RTX, N)  \
1315e4b17023SJohn Marino   GET_MODE (XCVECEXP (RTX, 4, N, ASM_OPERANDS))
1316e4b17023SJohn Marino #define ASM_OPERANDS_LABEL_VEC(RTX) XCVEC (RTX, 5, ASM_OPERANDS)
1317e4b17023SJohn Marino #define ASM_OPERANDS_LABEL_LENGTH(RTX) XCVECLEN (RTX, 5, ASM_OPERANDS)
1318e4b17023SJohn Marino #define ASM_OPERANDS_LABEL(RTX, N) XCVECEXP (RTX, 5, N, ASM_OPERANDS)
1319e4b17023SJohn Marino #define ASM_OPERANDS_SOURCE_LOCATION(RTX) XCUINT (RTX, 6, ASM_OPERANDS)
1320e4b17023SJohn Marino #define ASM_INPUT_SOURCE_LOCATION(RTX) XCUINT (RTX, 1, ASM_INPUT)
1321e4b17023SJohn Marino 
1322e4b17023SJohn Marino /* 1 if RTX is a mem that is statically allocated in read-only memory.  */
1323e4b17023SJohn Marino #define MEM_READONLY_P(RTX) \
1324e4b17023SJohn Marino   (RTL_FLAG_CHECK1("MEM_READONLY_P", (RTX), MEM)->unchanging)
1325e4b17023SJohn Marino 
1326e4b17023SJohn Marino /* 1 if RTX is a mem and we should keep the alias set for this mem
1327e4b17023SJohn Marino    unchanged when we access a component.  Set to 1, or example, when we
1328e4b17023SJohn Marino    are already in a non-addressable component of an aggregate.  */
1329e4b17023SJohn Marino #define MEM_KEEP_ALIAS_SET_P(RTX)					\
1330e4b17023SJohn Marino   (RTL_FLAG_CHECK1("MEM_KEEP_ALIAS_SET_P", (RTX), MEM)->jump)
1331e4b17023SJohn Marino 
1332e4b17023SJohn Marino /* 1 if RTX is a mem or asm_operand for a volatile reference.  */
1333e4b17023SJohn Marino #define MEM_VOLATILE_P(RTX)						\
1334e4b17023SJohn Marino   (RTL_FLAG_CHECK3("MEM_VOLATILE_P", (RTX), MEM, ASM_OPERANDS,		\
1335e4b17023SJohn Marino 		   ASM_INPUT)->volatil)
1336e4b17023SJohn Marino 
1337e4b17023SJohn Marino /* 1 if RTX is a mem that cannot trap.  */
1338e4b17023SJohn Marino #define MEM_NOTRAP_P(RTX) \
1339e4b17023SJohn Marino   (RTL_FLAG_CHECK1("MEM_NOTRAP_P", (RTX), MEM)->call)
1340e4b17023SJohn Marino 
1341e4b17023SJohn Marino /* The memory attribute block.  We provide access macros for each value
1342e4b17023SJohn Marino    in the block and provide defaults if none specified.  */
1343e4b17023SJohn Marino #define MEM_ATTRS(RTX) X0MEMATTR (RTX, 1)
1344e4b17023SJohn Marino 
1345e4b17023SJohn Marino /* The register attribute block.  We provide access macros for each value
1346e4b17023SJohn Marino    in the block and provide defaults if none specified.  */
1347e4b17023SJohn Marino #define REG_ATTRS(RTX) X0REGATTR (RTX, 2)
1348e4b17023SJohn Marino 
1349e4b17023SJohn Marino #ifndef GENERATOR_FILE
1350e4b17023SJohn Marino /* For a MEM rtx, the alias set.  If 0, this MEM is not in any alias
1351e4b17023SJohn Marino    set, and may alias anything.  Otherwise, the MEM can only alias
1352e4b17023SJohn Marino    MEMs in a conflicting alias set.  This value is set in a
1353e4b17023SJohn Marino    language-dependent manner in the front-end, and should not be
1354e4b17023SJohn Marino    altered in the back-end.  These set numbers are tested with
1355e4b17023SJohn Marino    alias_sets_conflict_p.  */
1356e4b17023SJohn Marino #define MEM_ALIAS_SET(RTX) (get_mem_attrs (RTX)->alias)
1357e4b17023SJohn Marino 
1358e4b17023SJohn Marino /* For a MEM rtx, the decl it is known to refer to, if it is known to
1359e4b17023SJohn Marino    refer to part of a DECL.  It may also be a COMPONENT_REF.  */
1360e4b17023SJohn Marino #define MEM_EXPR(RTX) (get_mem_attrs (RTX)->expr)
1361e4b17023SJohn Marino 
1362e4b17023SJohn Marino /* For a MEM rtx, true if its MEM_OFFSET is known.  */
1363e4b17023SJohn Marino #define MEM_OFFSET_KNOWN_P(RTX) (get_mem_attrs (RTX)->offset_known_p)
1364e4b17023SJohn Marino 
1365e4b17023SJohn Marino /* For a MEM rtx, the offset from the start of MEM_EXPR.  */
1366e4b17023SJohn Marino #define MEM_OFFSET(RTX) (get_mem_attrs (RTX)->offset)
1367e4b17023SJohn Marino 
1368e4b17023SJohn Marino /* For a MEM rtx, the address space.  */
1369e4b17023SJohn Marino #define MEM_ADDR_SPACE(RTX) (get_mem_attrs (RTX)->addrspace)
1370e4b17023SJohn Marino 
1371e4b17023SJohn Marino /* For a MEM rtx, true if its MEM_SIZE is known.  */
1372e4b17023SJohn Marino #define MEM_SIZE_KNOWN_P(RTX) (get_mem_attrs (RTX)->size_known_p)
1373e4b17023SJohn Marino 
1374e4b17023SJohn Marino /* For a MEM rtx, the size in bytes of the MEM.  */
1375e4b17023SJohn Marino #define MEM_SIZE(RTX) (get_mem_attrs (RTX)->size)
1376e4b17023SJohn Marino 
1377e4b17023SJohn Marino /* For a MEM rtx, the alignment in bits.  We can use the alignment of the
1378e4b17023SJohn Marino    mode as a default when STRICT_ALIGNMENT, but not if not.  */
1379e4b17023SJohn Marino #define MEM_ALIGN(RTX) (get_mem_attrs (RTX)->align)
1380e4b17023SJohn Marino #else
1381e4b17023SJohn Marino #define MEM_ADDR_SPACE(RTX) ADDR_SPACE_GENERIC
1382e4b17023SJohn Marino #endif
1383e4b17023SJohn Marino 
1384e4b17023SJohn Marino /* For a REG rtx, the decl it is known to refer to, if it is known to
1385e4b17023SJohn Marino    refer to part of a DECL.  */
1386e4b17023SJohn Marino #define REG_EXPR(RTX) (REG_ATTRS (RTX) == 0 ? 0 : REG_ATTRS (RTX)->decl)
1387e4b17023SJohn Marino 
1388e4b17023SJohn Marino /* For a REG rtx, the offset from the start of REG_EXPR, if known, as an
1389e4b17023SJohn Marino    HOST_WIDE_INT.  */
1390e4b17023SJohn Marino #define REG_OFFSET(RTX) (REG_ATTRS (RTX) == 0 ? 0 : REG_ATTRS (RTX)->offset)
1391e4b17023SJohn Marino 
1392e4b17023SJohn Marino /* Copy the attributes that apply to memory locations from RHS to LHS.  */
1393e4b17023SJohn Marino #define MEM_COPY_ATTRIBUTES(LHS, RHS)				\
1394e4b17023SJohn Marino   (MEM_VOLATILE_P (LHS) = MEM_VOLATILE_P (RHS),			\
1395e4b17023SJohn Marino    MEM_NOTRAP_P (LHS) = MEM_NOTRAP_P (RHS),			\
1396e4b17023SJohn Marino    MEM_READONLY_P (LHS) = MEM_READONLY_P (RHS),			\
1397e4b17023SJohn Marino    MEM_KEEP_ALIAS_SET_P (LHS) = MEM_KEEP_ALIAS_SET_P (RHS),	\
1398e4b17023SJohn Marino    MEM_POINTER (LHS) = MEM_POINTER (RHS),			\
1399e4b17023SJohn Marino    MEM_ATTRS (LHS) = MEM_ATTRS (RHS))
1400e4b17023SJohn Marino 
1401e4b17023SJohn Marino /* 1 if RTX is a label_ref for a nonlocal label.  */
1402e4b17023SJohn Marino /* Likewise in an expr_list for a REG_LABEL_OPERAND or
1403e4b17023SJohn Marino    REG_LABEL_TARGET note.  */
1404e4b17023SJohn Marino #define LABEL_REF_NONLOCAL_P(RTX)					\
1405e4b17023SJohn Marino   (RTL_FLAG_CHECK1("LABEL_REF_NONLOCAL_P", (RTX), LABEL_REF)->volatil)
1406e4b17023SJohn Marino 
1407e4b17023SJohn Marino /* 1 if RTX is a code_label that should always be considered to be needed.  */
1408e4b17023SJohn Marino #define LABEL_PRESERVE_P(RTX)						\
1409e4b17023SJohn Marino   (RTL_FLAG_CHECK2("LABEL_PRESERVE_P", (RTX), CODE_LABEL, NOTE)->in_struct)
1410e4b17023SJohn Marino 
1411e4b17023SJohn Marino /* During sched, 1 if RTX is an insn that must be scheduled together
1412e4b17023SJohn Marino    with the preceding insn.  */
1413e4b17023SJohn Marino #define SCHED_GROUP_P(RTX)						\
1414e4b17023SJohn Marino   (RTL_FLAG_CHECK4("SCHED_GROUP_P", (RTX), DEBUG_INSN, INSN,		\
1415e4b17023SJohn Marino 		   JUMP_INSN, CALL_INSN					\
1416e4b17023SJohn Marino 		   )->in_struct)
1417e4b17023SJohn Marino 
1418e4b17023SJohn Marino /* For a SET rtx, SET_DEST is the place that is set
1419e4b17023SJohn Marino    and SET_SRC is the value it is set to.  */
1420e4b17023SJohn Marino #define SET_DEST(RTX) XC2EXP(RTX, 0, SET, CLOBBER)
1421e4b17023SJohn Marino #define SET_SRC(RTX) XCEXP(RTX, 1, SET)
1422e4b17023SJohn Marino #define SET_IS_RETURN_P(RTX)						\
1423e4b17023SJohn Marino   (RTL_FLAG_CHECK1("SET_IS_RETURN_P", (RTX), SET)->jump)
1424e4b17023SJohn Marino 
1425e4b17023SJohn Marino /* For a TRAP_IF rtx, TRAP_CONDITION is an expression.  */
1426e4b17023SJohn Marino #define TRAP_CONDITION(RTX) XCEXP (RTX, 0, TRAP_IF)
1427e4b17023SJohn Marino #define TRAP_CODE(RTX) XCEXP (RTX, 1, TRAP_IF)
1428e4b17023SJohn Marino 
1429e4b17023SJohn Marino /* For a COND_EXEC rtx, COND_EXEC_TEST is the condition to base
1430e4b17023SJohn Marino    conditionally executing the code on, COND_EXEC_CODE is the code
1431e4b17023SJohn Marino    to execute if the condition is true.  */
1432e4b17023SJohn Marino #define COND_EXEC_TEST(RTX) XCEXP (RTX, 0, COND_EXEC)
1433e4b17023SJohn Marino #define COND_EXEC_CODE(RTX) XCEXP (RTX, 1, COND_EXEC)
1434e4b17023SJohn Marino 
1435e4b17023SJohn Marino /* 1 if RTX is a symbol_ref that addresses this function's rtl
1436e4b17023SJohn Marino    constants pool.  */
1437e4b17023SJohn Marino #define CONSTANT_POOL_ADDRESS_P(RTX)					\
1438e4b17023SJohn Marino   (RTL_FLAG_CHECK1("CONSTANT_POOL_ADDRESS_P", (RTX), SYMBOL_REF)->unchanging)
1439e4b17023SJohn Marino 
1440e4b17023SJohn Marino /* 1 if RTX is a symbol_ref that addresses a value in the file's
1441e4b17023SJohn Marino    tree constant pool.  This information is private to varasm.c.  */
1442e4b17023SJohn Marino #define TREE_CONSTANT_POOL_ADDRESS_P(RTX)				\
1443e4b17023SJohn Marino   (RTL_FLAG_CHECK1("TREE_CONSTANT_POOL_ADDRESS_P",			\
1444e4b17023SJohn Marino 		   (RTX), SYMBOL_REF)->frame_related)
1445e4b17023SJohn Marino 
1446e4b17023SJohn Marino /* Used if RTX is a symbol_ref, for machine-specific purposes.  */
1447e4b17023SJohn Marino #define SYMBOL_REF_FLAG(RTX)						\
1448e4b17023SJohn Marino   (RTL_FLAG_CHECK1("SYMBOL_REF_FLAG", (RTX), SYMBOL_REF)->volatil)
1449e4b17023SJohn Marino 
1450e4b17023SJohn Marino /* 1 if RTX is a symbol_ref that has been the library function in
1451e4b17023SJohn Marino    emit_library_call.  */
1452e4b17023SJohn Marino #define SYMBOL_REF_USED(RTX)						\
1453e4b17023SJohn Marino   (RTL_FLAG_CHECK1("SYMBOL_REF_USED", (RTX), SYMBOL_REF)->used)
1454e4b17023SJohn Marino 
1455e4b17023SJohn Marino /* 1 if RTX is a symbol_ref for a weak symbol.  */
1456e4b17023SJohn Marino #define SYMBOL_REF_WEAK(RTX)						\
1457e4b17023SJohn Marino   (RTL_FLAG_CHECK1("SYMBOL_REF_WEAK", (RTX), SYMBOL_REF)->return_val)
1458e4b17023SJohn Marino 
1459e4b17023SJohn Marino /* A pointer attached to the SYMBOL_REF; either SYMBOL_REF_DECL or
1460e4b17023SJohn Marino    SYMBOL_REF_CONSTANT.  */
1461e4b17023SJohn Marino #define SYMBOL_REF_DATA(RTX) X0ANY ((RTX), 2)
1462e4b17023SJohn Marino 
1463e4b17023SJohn Marino /* Set RTX's SYMBOL_REF_DECL to DECL.  RTX must not be a constant
1464e4b17023SJohn Marino    pool symbol.  */
1465e4b17023SJohn Marino #define SET_SYMBOL_REF_DECL(RTX, DECL) \
1466e4b17023SJohn Marino   (gcc_assert (!CONSTANT_POOL_ADDRESS_P (RTX)), X0TREE ((RTX), 2) = (DECL))
1467e4b17023SJohn Marino 
1468e4b17023SJohn Marino /* The tree (decl or constant) associated with the symbol, or null.  */
1469e4b17023SJohn Marino #define SYMBOL_REF_DECL(RTX) \
1470e4b17023SJohn Marino   (CONSTANT_POOL_ADDRESS_P (RTX) ? NULL : X0TREE ((RTX), 2))
1471e4b17023SJohn Marino 
1472e4b17023SJohn Marino /* Set RTX's SYMBOL_REF_CONSTANT to C.  RTX must be a constant pool symbol.  */
1473e4b17023SJohn Marino #define SET_SYMBOL_REF_CONSTANT(RTX, C) \
1474e4b17023SJohn Marino   (gcc_assert (CONSTANT_POOL_ADDRESS_P (RTX)), X0CONSTANT ((RTX), 2) = (C))
1475e4b17023SJohn Marino 
1476e4b17023SJohn Marino /* The rtx constant pool entry for a symbol, or null.  */
1477e4b17023SJohn Marino #define SYMBOL_REF_CONSTANT(RTX) \
1478e4b17023SJohn Marino   (CONSTANT_POOL_ADDRESS_P (RTX) ? X0CONSTANT ((RTX), 2) : NULL)
1479e4b17023SJohn Marino 
1480e4b17023SJohn Marino /* A set of flags on a symbol_ref that are, in some respects, redundant with
1481e4b17023SJohn Marino    information derivable from the tree decl associated with this symbol.
1482e4b17023SJohn Marino    Except that we build a *lot* of SYMBOL_REFs that aren't associated with a
1483e4b17023SJohn Marino    decl.  In some cases this is a bug.  But beyond that, it's nice to cache
1484e4b17023SJohn Marino    this information to avoid recomputing it.  Finally, this allows space for
1485e4b17023SJohn Marino    the target to store more than one bit of information, as with
1486e4b17023SJohn Marino    SYMBOL_REF_FLAG.  */
1487e4b17023SJohn Marino #define SYMBOL_REF_FLAGS(RTX)	X0INT ((RTX), 1)
1488e4b17023SJohn Marino 
1489e4b17023SJohn Marino /* These flags are common enough to be defined for all targets.  They
1490e4b17023SJohn Marino    are computed by the default version of targetm.encode_section_info.  */
1491e4b17023SJohn Marino 
1492e4b17023SJohn Marino /* Set if this symbol is a function.  */
1493e4b17023SJohn Marino #define SYMBOL_FLAG_FUNCTION	(1 << 0)
1494e4b17023SJohn Marino #define SYMBOL_REF_FUNCTION_P(RTX) \
1495e4b17023SJohn Marino   ((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_FUNCTION) != 0)
1496e4b17023SJohn Marino /* Set if targetm.binds_local_p is true.  */
1497e4b17023SJohn Marino #define SYMBOL_FLAG_LOCAL	(1 << 1)
1498e4b17023SJohn Marino #define SYMBOL_REF_LOCAL_P(RTX) \
1499e4b17023SJohn Marino   ((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_LOCAL) != 0)
1500e4b17023SJohn Marino /* Set if targetm.in_small_data_p is true.  */
1501e4b17023SJohn Marino #define SYMBOL_FLAG_SMALL	(1 << 2)
1502e4b17023SJohn Marino #define SYMBOL_REF_SMALL_P(RTX) \
1503e4b17023SJohn Marino   ((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_SMALL) != 0)
1504e4b17023SJohn Marino /* The three-bit field at [5:3] is true for TLS variables; use
1505e4b17023SJohn Marino    SYMBOL_REF_TLS_MODEL to extract the field as an enum tls_model.  */
1506e4b17023SJohn Marino #define SYMBOL_FLAG_TLS_SHIFT	3
1507e4b17023SJohn Marino #define SYMBOL_REF_TLS_MODEL(RTX) \
1508e4b17023SJohn Marino   ((enum tls_model) ((SYMBOL_REF_FLAGS (RTX) >> SYMBOL_FLAG_TLS_SHIFT) & 7))
1509e4b17023SJohn Marino /* Set if this symbol is not defined in this translation unit.  */
1510e4b17023SJohn Marino #define SYMBOL_FLAG_EXTERNAL	(1 << 6)
1511e4b17023SJohn Marino #define SYMBOL_REF_EXTERNAL_P(RTX) \
1512e4b17023SJohn Marino   ((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_EXTERNAL) != 0)
1513e4b17023SJohn Marino /* Set if this symbol has a block_symbol structure associated with it.  */
1514e4b17023SJohn Marino #define SYMBOL_FLAG_HAS_BLOCK_INFO (1 << 7)
1515e4b17023SJohn Marino #define SYMBOL_REF_HAS_BLOCK_INFO_P(RTX) \
1516e4b17023SJohn Marino   ((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_HAS_BLOCK_INFO) != 0)
1517e4b17023SJohn Marino /* Set if this symbol is a section anchor.  SYMBOL_REF_ANCHOR_P implies
1518e4b17023SJohn Marino    SYMBOL_REF_HAS_BLOCK_INFO_P.  */
1519e4b17023SJohn Marino #define SYMBOL_FLAG_ANCHOR	(1 << 8)
1520e4b17023SJohn Marino #define SYMBOL_REF_ANCHOR_P(RTX) \
1521e4b17023SJohn Marino   ((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_ANCHOR) != 0)
1522e4b17023SJohn Marino 
1523e4b17023SJohn Marino /* Subsequent bits are available for the target to use.  */
1524e4b17023SJohn Marino #define SYMBOL_FLAG_MACH_DEP_SHIFT	9
1525e4b17023SJohn Marino #define SYMBOL_FLAG_MACH_DEP		(1 << SYMBOL_FLAG_MACH_DEP_SHIFT)
1526e4b17023SJohn Marino 
1527e4b17023SJohn Marino /* If SYMBOL_REF_HAS_BLOCK_INFO_P (RTX), this is the object_block
1528e4b17023SJohn Marino    structure to which the symbol belongs, or NULL if it has not been
1529e4b17023SJohn Marino    assigned a block.  */
1530e4b17023SJohn Marino #define SYMBOL_REF_BLOCK(RTX) (BLOCK_SYMBOL_CHECK (RTX)->block)
1531e4b17023SJohn Marino 
1532e4b17023SJohn Marino /* If SYMBOL_REF_HAS_BLOCK_INFO_P (RTX), this is the offset of RTX from
1533e4b17023SJohn Marino    the first object in SYMBOL_REF_BLOCK (RTX).  The value is negative if
1534e4b17023SJohn Marino    RTX has not yet been assigned to a block, or it has not been given an
1535e4b17023SJohn Marino    offset within that block.  */
1536e4b17023SJohn Marino #define SYMBOL_REF_BLOCK_OFFSET(RTX) (BLOCK_SYMBOL_CHECK (RTX)->offset)
1537e4b17023SJohn Marino 
1538e4b17023SJohn Marino /* True if RTX is flagged to be a scheduling barrier.  */
1539e4b17023SJohn Marino #define PREFETCH_SCHEDULE_BARRIER_P(RTX)					\
1540e4b17023SJohn Marino   (RTL_FLAG_CHECK1("PREFETCH_SCHEDULE_BARRIER_P", (RTX), PREFETCH)->volatil)
1541e4b17023SJohn Marino 
1542e4b17023SJohn Marino /* Indicate whether the machine has any sort of auto increment addressing.
1543e4b17023SJohn Marino    If not, we can avoid checking for REG_INC notes.  */
1544e4b17023SJohn Marino 
1545e4b17023SJohn Marino #if (defined (HAVE_PRE_INCREMENT) || defined (HAVE_PRE_DECREMENT) \
1546e4b17023SJohn Marino      || defined (HAVE_POST_INCREMENT) || defined (HAVE_POST_DECREMENT) \
1547e4b17023SJohn Marino      || defined (HAVE_PRE_MODIFY_DISP) || defined (HAVE_PRE_MODIFY_DISP) \
1548e4b17023SJohn Marino      || defined (HAVE_PRE_MODIFY_REG) || defined (HAVE_POST_MODIFY_REG))
1549e4b17023SJohn Marino #define AUTO_INC_DEC
1550e4b17023SJohn Marino #endif
1551e4b17023SJohn Marino 
1552e4b17023SJohn Marino /* Define a macro to look for REG_INC notes,
1553e4b17023SJohn Marino    but save time on machines where they never exist.  */
1554e4b17023SJohn Marino 
1555e4b17023SJohn Marino #ifdef AUTO_INC_DEC
1556e4b17023SJohn Marino #define FIND_REG_INC_NOTE(INSN, REG)			\
1557e4b17023SJohn Marino   ((REG) != NULL_RTX && REG_P ((REG))			\
1558e4b17023SJohn Marino    ? find_regno_note ((INSN), REG_INC, REGNO (REG))	\
1559e4b17023SJohn Marino    : find_reg_note ((INSN), REG_INC, (REG)))
1560e4b17023SJohn Marino #else
1561e4b17023SJohn Marino #define FIND_REG_INC_NOTE(INSN, REG) 0
1562e4b17023SJohn Marino #endif
1563e4b17023SJohn Marino 
1564e4b17023SJohn Marino #ifndef HAVE_PRE_INCREMENT
1565e4b17023SJohn Marino #define HAVE_PRE_INCREMENT 0
1566e4b17023SJohn Marino #endif
1567e4b17023SJohn Marino 
1568e4b17023SJohn Marino #ifndef HAVE_PRE_DECREMENT
1569e4b17023SJohn Marino #define HAVE_PRE_DECREMENT 0
1570e4b17023SJohn Marino #endif
1571e4b17023SJohn Marino 
1572e4b17023SJohn Marino #ifndef HAVE_POST_INCREMENT
1573e4b17023SJohn Marino #define HAVE_POST_INCREMENT 0
1574e4b17023SJohn Marino #endif
1575e4b17023SJohn Marino 
1576e4b17023SJohn Marino #ifndef HAVE_POST_DECREMENT
1577e4b17023SJohn Marino #define HAVE_POST_DECREMENT 0
1578e4b17023SJohn Marino #endif
1579e4b17023SJohn Marino 
1580e4b17023SJohn Marino #ifndef HAVE_POST_MODIFY_DISP
1581e4b17023SJohn Marino #define HAVE_POST_MODIFY_DISP 0
1582e4b17023SJohn Marino #endif
1583e4b17023SJohn Marino 
1584e4b17023SJohn Marino #ifndef HAVE_POST_MODIFY_REG
1585e4b17023SJohn Marino #define HAVE_POST_MODIFY_REG 0
1586e4b17023SJohn Marino #endif
1587e4b17023SJohn Marino 
1588e4b17023SJohn Marino #ifndef HAVE_PRE_MODIFY_DISP
1589e4b17023SJohn Marino #define HAVE_PRE_MODIFY_DISP 0
1590e4b17023SJohn Marino #endif
1591e4b17023SJohn Marino 
1592e4b17023SJohn Marino #ifndef HAVE_PRE_MODIFY_REG
1593e4b17023SJohn Marino #define HAVE_PRE_MODIFY_REG 0
1594e4b17023SJohn Marino #endif
1595e4b17023SJohn Marino 
1596e4b17023SJohn Marino 
1597e4b17023SJohn Marino /* Some architectures do not have complete pre/post increment/decrement
1598e4b17023SJohn Marino    instruction sets, or only move some modes efficiently.  These macros
1599e4b17023SJohn Marino    allow us to tune autoincrement generation.  */
1600e4b17023SJohn Marino 
1601e4b17023SJohn Marino #ifndef USE_LOAD_POST_INCREMENT
1602e4b17023SJohn Marino #define USE_LOAD_POST_INCREMENT(MODE)   HAVE_POST_INCREMENT
1603e4b17023SJohn Marino #endif
1604e4b17023SJohn Marino 
1605e4b17023SJohn Marino #ifndef USE_LOAD_POST_DECREMENT
1606e4b17023SJohn Marino #define USE_LOAD_POST_DECREMENT(MODE)   HAVE_POST_DECREMENT
1607e4b17023SJohn Marino #endif
1608e4b17023SJohn Marino 
1609e4b17023SJohn Marino #ifndef USE_LOAD_PRE_INCREMENT
1610e4b17023SJohn Marino #define USE_LOAD_PRE_INCREMENT(MODE)    HAVE_PRE_INCREMENT
1611e4b17023SJohn Marino #endif
1612e4b17023SJohn Marino 
1613e4b17023SJohn Marino #ifndef USE_LOAD_PRE_DECREMENT
1614e4b17023SJohn Marino #define USE_LOAD_PRE_DECREMENT(MODE)    HAVE_PRE_DECREMENT
1615e4b17023SJohn Marino #endif
1616e4b17023SJohn Marino 
1617e4b17023SJohn Marino #ifndef USE_STORE_POST_INCREMENT
1618e4b17023SJohn Marino #define USE_STORE_POST_INCREMENT(MODE)  HAVE_POST_INCREMENT
1619e4b17023SJohn Marino #endif
1620e4b17023SJohn Marino 
1621e4b17023SJohn Marino #ifndef USE_STORE_POST_DECREMENT
1622e4b17023SJohn Marino #define USE_STORE_POST_DECREMENT(MODE)  HAVE_POST_DECREMENT
1623e4b17023SJohn Marino #endif
1624e4b17023SJohn Marino 
1625e4b17023SJohn Marino #ifndef USE_STORE_PRE_INCREMENT
1626e4b17023SJohn Marino #define USE_STORE_PRE_INCREMENT(MODE)   HAVE_PRE_INCREMENT
1627e4b17023SJohn Marino #endif
1628e4b17023SJohn Marino 
1629e4b17023SJohn Marino #ifndef USE_STORE_PRE_DECREMENT
1630e4b17023SJohn Marino #define USE_STORE_PRE_DECREMENT(MODE)   HAVE_PRE_DECREMENT
1631e4b17023SJohn Marino #endif
1632e4b17023SJohn Marino 
1633e4b17023SJohn Marino /* Nonzero when we are generating CONCATs.  */
1634e4b17023SJohn Marino extern int generating_concat_p;
1635e4b17023SJohn Marino 
1636e4b17023SJohn Marino /* Nonzero when we are expanding trees to RTL.  */
1637e4b17023SJohn Marino extern int currently_expanding_to_rtl;
1638e4b17023SJohn Marino 
1639e4b17023SJohn Marino /* Generally useful functions.  */
1640e4b17023SJohn Marino 
1641e4b17023SJohn Marino /* In expmed.c */
1642e4b17023SJohn Marino extern int ceil_log2 (unsigned HOST_WIDE_INT);
1643e4b17023SJohn Marino 
1644e4b17023SJohn Marino /* In explow.c */
1645e4b17023SJohn Marino extern HOST_WIDE_INT trunc_int_for_mode	(HOST_WIDE_INT, enum machine_mode);
1646e4b17023SJohn Marino extern rtx plus_constant (rtx, HOST_WIDE_INT);
1647e4b17023SJohn Marino 
1648e4b17023SJohn Marino /* In rtl.c */
1649e4b17023SJohn Marino extern rtx rtx_alloc_stat (RTX_CODE MEM_STAT_DECL);
1650e4b17023SJohn Marino #define rtx_alloc(c) rtx_alloc_stat (c MEM_STAT_INFO)
1651e4b17023SJohn Marino 
1652e4b17023SJohn Marino extern rtvec rtvec_alloc (int);
1653e4b17023SJohn Marino extern rtvec shallow_copy_rtvec (rtvec);
1654e4b17023SJohn Marino extern bool shared_const_p (const_rtx);
1655e4b17023SJohn Marino extern rtx copy_rtx (rtx);
1656e4b17023SJohn Marino extern void dump_rtx_statistics (void);
1657e4b17023SJohn Marino 
1658e4b17023SJohn Marino /* In emit-rtl.c */
1659e4b17023SJohn Marino extern rtx copy_rtx_if_shared (rtx);
1660e4b17023SJohn Marino 
1661e4b17023SJohn Marino /* In rtl.c */
1662e4b17023SJohn Marino extern unsigned int rtx_size (const_rtx);
1663e4b17023SJohn Marino extern rtx shallow_copy_rtx_stat (const_rtx MEM_STAT_DECL);
1664e4b17023SJohn Marino #define shallow_copy_rtx(a) shallow_copy_rtx_stat (a MEM_STAT_INFO)
1665e4b17023SJohn Marino extern int rtx_equal_p (const_rtx, const_rtx);
1666e4b17023SJohn Marino extern hashval_t iterative_hash_rtx (const_rtx, hashval_t);
1667e4b17023SJohn Marino 
1668e4b17023SJohn Marino /* In emit-rtl.c */
1669e4b17023SJohn Marino extern rtvec gen_rtvec_v (int, rtx *);
1670e4b17023SJohn Marino extern rtx gen_reg_rtx (enum machine_mode);
1671e4b17023SJohn Marino extern rtx gen_rtx_REG_offset (rtx, enum machine_mode, unsigned int, int);
1672e4b17023SJohn Marino extern rtx gen_reg_rtx_offset (rtx, enum machine_mode, int);
1673e4b17023SJohn Marino extern rtx gen_reg_rtx_and_attrs (rtx);
1674e4b17023SJohn Marino extern rtx gen_label_rtx (void);
1675e4b17023SJohn Marino extern rtx gen_lowpart_common (enum machine_mode, rtx);
1676e4b17023SJohn Marino 
1677e4b17023SJohn Marino /* In cse.c */
1678e4b17023SJohn Marino extern rtx gen_lowpart_if_possible (enum machine_mode, rtx);
1679e4b17023SJohn Marino 
1680e4b17023SJohn Marino /* In emit-rtl.c */
1681e4b17023SJohn Marino extern rtx gen_highpart (enum machine_mode, rtx);
1682e4b17023SJohn Marino extern rtx gen_highpart_mode (enum machine_mode, enum machine_mode, rtx);
1683e4b17023SJohn Marino extern rtx operand_subword (rtx, unsigned int, int, enum machine_mode);
1684e4b17023SJohn Marino 
1685e4b17023SJohn Marino /* In emit-rtl.c */
1686e4b17023SJohn Marino extern rtx operand_subword_force (rtx, unsigned int, enum machine_mode);
1687e4b17023SJohn Marino extern bool paradoxical_subreg_p (const_rtx);
1688e4b17023SJohn Marino extern int subreg_lowpart_p (const_rtx);
1689e4b17023SJohn Marino extern unsigned int subreg_lowpart_offset (enum machine_mode,
1690e4b17023SJohn Marino 					   enum machine_mode);
1691e4b17023SJohn Marino extern unsigned int subreg_highpart_offset (enum machine_mode,
1692e4b17023SJohn Marino 					    enum machine_mode);
1693e4b17023SJohn Marino extern int byte_lowpart_offset (enum machine_mode, enum machine_mode);
1694e4b17023SJohn Marino extern rtx make_safe_from (rtx, rtx);
1695e4b17023SJohn Marino extern rtx convert_memory_address_addr_space (enum machine_mode, rtx,
1696e4b17023SJohn Marino 					      addr_space_t);
1697e4b17023SJohn Marino #define convert_memory_address(to_mode,x) \
1698e4b17023SJohn Marino 	convert_memory_address_addr_space ((to_mode), (x), ADDR_SPACE_GENERIC)
1699e4b17023SJohn Marino extern const char *get_insn_name (int);
1700e4b17023SJohn Marino extern rtx get_last_insn_anywhere (void);
1701e4b17023SJohn Marino extern rtx get_first_nonnote_insn (void);
1702e4b17023SJohn Marino extern rtx get_last_nonnote_insn (void);
1703e4b17023SJohn Marino extern void start_sequence (void);
1704e4b17023SJohn Marino extern void push_to_sequence (rtx);
1705e4b17023SJohn Marino extern void push_to_sequence2 (rtx, rtx);
1706e4b17023SJohn Marino extern void end_sequence (void);
1707e4b17023SJohn Marino extern double_int rtx_to_double_int (const_rtx);
1708e4b17023SJohn Marino extern rtx immed_double_int_const (double_int, enum machine_mode);
1709e4b17023SJohn Marino extern rtx immed_double_const (HOST_WIDE_INT, HOST_WIDE_INT,
1710e4b17023SJohn Marino 			       enum machine_mode);
1711e4b17023SJohn Marino 
1712e4b17023SJohn Marino /* In loop-iv.c  */
1713e4b17023SJohn Marino 
1714e4b17023SJohn Marino extern rtx lowpart_subreg (enum machine_mode, rtx, enum machine_mode);
1715e4b17023SJohn Marino 
1716e4b17023SJohn Marino /* In varasm.c  */
1717e4b17023SJohn Marino extern rtx force_const_mem (enum machine_mode, rtx);
1718e4b17023SJohn Marino 
1719e4b17023SJohn Marino /* In varasm.c  */
1720e4b17023SJohn Marino 
1721e4b17023SJohn Marino struct function;
1722e4b17023SJohn Marino extern rtx get_pool_constant (rtx);
1723e4b17023SJohn Marino extern rtx get_pool_constant_mark (rtx, bool *);
1724e4b17023SJohn Marino extern enum machine_mode get_pool_mode (const_rtx);
1725e4b17023SJohn Marino extern rtx simplify_subtraction (rtx);
1726e4b17023SJohn Marino extern void decide_function_section (tree);
1727e4b17023SJohn Marino 
1728e4b17023SJohn Marino /* In function.c  */
1729e4b17023SJohn Marino extern rtx assign_stack_local (enum machine_mode, HOST_WIDE_INT, int);
1730e4b17023SJohn Marino #define ASLK_REDUCE_ALIGN 1
1731e4b17023SJohn Marino #define ASLK_RECORD_PAD 2
1732e4b17023SJohn Marino extern rtx assign_stack_local_1 (enum machine_mode, HOST_WIDE_INT, int, int);
1733e4b17023SJohn Marino extern rtx assign_stack_temp (enum machine_mode, HOST_WIDE_INT, int);
1734e4b17023SJohn Marino extern rtx assign_stack_temp_for_type (enum machine_mode,
1735e4b17023SJohn Marino 				       HOST_WIDE_INT, int, tree);
1736e4b17023SJohn Marino extern rtx assign_temp (tree, int, int, int);
1737e4b17023SJohn Marino 
1738e4b17023SJohn Marino /* In emit-rtl.c */
1739e4b17023SJohn Marino extern rtx emit_insn_before (rtx, rtx);
1740e4b17023SJohn Marino extern rtx emit_insn_before_noloc (rtx, rtx, struct basic_block_def *);
1741e4b17023SJohn Marino extern rtx emit_insn_before_setloc (rtx, rtx, int);
1742e4b17023SJohn Marino extern rtx emit_jump_insn_before (rtx, rtx);
1743e4b17023SJohn Marino extern rtx emit_jump_insn_before_noloc (rtx, rtx);
1744e4b17023SJohn Marino extern rtx emit_jump_insn_before_setloc (rtx, rtx, int);
1745e4b17023SJohn Marino extern rtx emit_call_insn_before (rtx, rtx);
1746e4b17023SJohn Marino extern rtx emit_call_insn_before_noloc (rtx, rtx);
1747e4b17023SJohn Marino extern rtx emit_call_insn_before_setloc (rtx, rtx, int);
1748e4b17023SJohn Marino extern rtx emit_debug_insn_before (rtx, rtx);
1749e4b17023SJohn Marino extern rtx emit_debug_insn_before_noloc (rtx, rtx);
1750e4b17023SJohn Marino extern rtx emit_debug_insn_before_setloc (rtx, rtx, int);
1751e4b17023SJohn Marino extern rtx emit_barrier_before (rtx);
1752e4b17023SJohn Marino extern rtx emit_label_before (rtx, rtx);
1753e4b17023SJohn Marino extern rtx emit_note_before (enum insn_note, rtx);
1754e4b17023SJohn Marino extern rtx emit_insn_after (rtx, rtx);
1755e4b17023SJohn Marino extern rtx emit_insn_after_noloc (rtx, rtx, struct basic_block_def *);
1756e4b17023SJohn Marino extern rtx emit_insn_after_setloc (rtx, rtx, int);
1757e4b17023SJohn Marino extern rtx emit_jump_insn_after (rtx, rtx);
1758e4b17023SJohn Marino extern rtx emit_jump_insn_after_noloc (rtx, rtx);
1759e4b17023SJohn Marino extern rtx emit_jump_insn_after_setloc (rtx, rtx, int);
1760e4b17023SJohn Marino extern rtx emit_call_insn_after (rtx, rtx);
1761e4b17023SJohn Marino extern rtx emit_call_insn_after_noloc (rtx, rtx);
1762e4b17023SJohn Marino extern rtx emit_call_insn_after_setloc (rtx, rtx, int);
1763e4b17023SJohn Marino extern rtx emit_debug_insn_after (rtx, rtx);
1764e4b17023SJohn Marino extern rtx emit_debug_insn_after_noloc (rtx, rtx);
1765e4b17023SJohn Marino extern rtx emit_debug_insn_after_setloc (rtx, rtx, int);
1766e4b17023SJohn Marino extern rtx emit_barrier_after (rtx);
1767e4b17023SJohn Marino extern rtx emit_label_after (rtx, rtx);
1768e4b17023SJohn Marino extern rtx emit_note_after (enum insn_note, rtx);
1769e4b17023SJohn Marino extern rtx emit_insn (rtx);
1770e4b17023SJohn Marino extern rtx emit_debug_insn (rtx);
1771e4b17023SJohn Marino extern rtx emit_jump_insn (rtx);
1772e4b17023SJohn Marino extern rtx emit_call_insn (rtx);
1773e4b17023SJohn Marino extern rtx emit_label (rtx);
1774e4b17023SJohn Marino extern rtx emit_barrier (void);
1775e4b17023SJohn Marino extern rtx emit_note (enum insn_note);
1776e4b17023SJohn Marino extern rtx emit_note_copy (rtx);
1777e4b17023SJohn Marino extern rtx gen_clobber (rtx);
1778e4b17023SJohn Marino extern rtx emit_clobber (rtx);
1779e4b17023SJohn Marino extern rtx gen_use (rtx);
1780e4b17023SJohn Marino extern rtx emit_use (rtx);
1781e4b17023SJohn Marino extern rtx make_insn_raw (rtx);
1782e4b17023SJohn Marino extern rtx make_debug_insn_raw (rtx);
1783e4b17023SJohn Marino extern rtx make_jump_insn_raw (rtx);
1784e4b17023SJohn Marino extern void add_function_usage_to (rtx, rtx);
1785e4b17023SJohn Marino extern rtx last_call_insn (void);
1786e4b17023SJohn Marino extern rtx previous_insn (rtx);
1787e4b17023SJohn Marino extern rtx next_insn (rtx);
1788e4b17023SJohn Marino extern rtx prev_nonnote_insn (rtx);
1789e4b17023SJohn Marino extern rtx prev_nonnote_insn_bb (rtx);
1790e4b17023SJohn Marino extern rtx next_nonnote_insn (rtx);
1791e4b17023SJohn Marino extern rtx next_nonnote_insn_bb (rtx);
1792e4b17023SJohn Marino extern rtx prev_nondebug_insn (rtx);
1793e4b17023SJohn Marino extern rtx next_nondebug_insn (rtx);
1794e4b17023SJohn Marino extern rtx prev_nonnote_nondebug_insn (rtx);
1795e4b17023SJohn Marino extern rtx next_nonnote_nondebug_insn (rtx);
1796e4b17023SJohn Marino extern rtx prev_real_insn (rtx);
1797e4b17023SJohn Marino extern rtx next_real_insn (rtx);
1798e4b17023SJohn Marino extern rtx prev_active_insn (rtx);
1799e4b17023SJohn Marino extern rtx next_active_insn (rtx);
1800e4b17023SJohn Marino extern int active_insn_p (const_rtx);
1801e4b17023SJohn Marino extern rtx next_label (rtx);
1802e4b17023SJohn Marino extern rtx skip_consecutive_labels (rtx);
1803e4b17023SJohn Marino extern rtx next_cc0_user (rtx);
1804e4b17023SJohn Marino extern rtx prev_cc0_setter (rtx);
1805e4b17023SJohn Marino 
1806e4b17023SJohn Marino /* In cfglayout.c  */
1807e4b17023SJohn Marino extern int insn_line (const_rtx);
1808e4b17023SJohn Marino extern const char * insn_file (const_rtx);
1809e4b17023SJohn Marino extern location_t locator_location (int);
1810e4b17023SJohn Marino extern int locator_line (int);
1811e4b17023SJohn Marino extern const char * locator_file (int);
1812e4b17023SJohn Marino extern bool locator_eq (int, int);
1813e4b17023SJohn Marino extern int prologue_locator, epilogue_locator;
1814e4b17023SJohn Marino 
1815e4b17023SJohn Marino /* In jump.c */
1816e4b17023SJohn Marino extern enum rtx_code reverse_condition (enum rtx_code);
1817e4b17023SJohn Marino extern enum rtx_code reverse_condition_maybe_unordered (enum rtx_code);
1818e4b17023SJohn Marino extern enum rtx_code swap_condition (enum rtx_code);
1819e4b17023SJohn Marino extern enum rtx_code unsigned_condition (enum rtx_code);
1820e4b17023SJohn Marino extern enum rtx_code signed_condition (enum rtx_code);
1821e4b17023SJohn Marino extern void mark_jump_label (rtx, rtx, int);
1822e4b17023SJohn Marino extern unsigned int cleanup_barriers (void);
1823e4b17023SJohn Marino 
1824e4b17023SJohn Marino /* In jump.c */
1825e4b17023SJohn Marino extern rtx delete_related_insns (rtx);
1826e4b17023SJohn Marino 
1827e4b17023SJohn Marino /* In recog.c  */
1828e4b17023SJohn Marino extern rtx *find_constant_term_loc (rtx *);
1829e4b17023SJohn Marino 
1830e4b17023SJohn Marino /* In emit-rtl.c  */
1831e4b17023SJohn Marino extern rtx try_split (rtx, rtx, int);
1832e4b17023SJohn Marino extern int split_branch_probability;
1833e4b17023SJohn Marino 
1834e4b17023SJohn Marino /* In unknown file  */
1835e4b17023SJohn Marino extern rtx split_insns (rtx, rtx);
1836e4b17023SJohn Marino 
1837e4b17023SJohn Marino /* In simplify-rtx.c  */
1838e4b17023SJohn Marino extern rtx simplify_const_unary_operation (enum rtx_code, enum machine_mode,
1839e4b17023SJohn Marino 					   rtx, enum machine_mode);
1840e4b17023SJohn Marino extern rtx simplify_unary_operation (enum rtx_code, enum machine_mode, rtx,
1841e4b17023SJohn Marino 				     enum machine_mode);
1842e4b17023SJohn Marino extern rtx simplify_const_binary_operation (enum rtx_code, enum machine_mode,
1843e4b17023SJohn Marino 					    rtx, rtx);
1844e4b17023SJohn Marino extern rtx simplify_binary_operation (enum rtx_code, enum machine_mode, rtx,
1845e4b17023SJohn Marino 				      rtx);
1846e4b17023SJohn Marino extern rtx simplify_ternary_operation (enum rtx_code, enum machine_mode,
1847e4b17023SJohn Marino 				       enum machine_mode, rtx, rtx, rtx);
1848e4b17023SJohn Marino extern rtx simplify_const_relational_operation (enum rtx_code,
1849e4b17023SJohn Marino 						enum machine_mode, rtx, rtx);
1850e4b17023SJohn Marino extern rtx simplify_relational_operation (enum rtx_code, enum machine_mode,
1851e4b17023SJohn Marino 					  enum machine_mode, rtx, rtx);
1852e4b17023SJohn Marino extern rtx simplify_gen_binary (enum rtx_code, enum machine_mode, rtx, rtx);
1853e4b17023SJohn Marino extern rtx simplify_gen_unary (enum rtx_code, enum machine_mode, rtx,
1854e4b17023SJohn Marino 			       enum machine_mode);
1855e4b17023SJohn Marino extern rtx simplify_gen_ternary (enum rtx_code, enum machine_mode,
1856e4b17023SJohn Marino 				 enum machine_mode, rtx, rtx, rtx);
1857e4b17023SJohn Marino extern rtx simplify_gen_relational (enum rtx_code, enum machine_mode,
1858e4b17023SJohn Marino 				    enum machine_mode, rtx, rtx);
1859e4b17023SJohn Marino extern rtx simplify_subreg (enum machine_mode, rtx, enum machine_mode,
1860e4b17023SJohn Marino 			    unsigned int);
1861e4b17023SJohn Marino extern rtx simplify_gen_subreg (enum machine_mode, rtx, enum machine_mode,
1862e4b17023SJohn Marino 				unsigned int);
1863e4b17023SJohn Marino extern rtx simplify_replace_fn_rtx (rtx, const_rtx,
1864e4b17023SJohn Marino 				    rtx (*fn) (rtx, const_rtx, void *), void *);
1865e4b17023SJohn Marino extern rtx simplify_replace_rtx (rtx, const_rtx, rtx);
1866e4b17023SJohn Marino extern rtx simplify_rtx (const_rtx);
1867e4b17023SJohn Marino extern rtx avoid_constant_pool_reference (rtx);
1868e4b17023SJohn Marino extern rtx delegitimize_mem_from_attrs (rtx);
1869e4b17023SJohn Marino extern bool mode_signbit_p (enum machine_mode, const_rtx);
1870e4b17023SJohn Marino extern bool val_signbit_p (enum machine_mode, unsigned HOST_WIDE_INT);
1871e4b17023SJohn Marino extern bool val_signbit_known_set_p (enum machine_mode,
1872e4b17023SJohn Marino 				     unsigned HOST_WIDE_INT);
1873e4b17023SJohn Marino extern bool val_signbit_known_clear_p (enum machine_mode,
1874e4b17023SJohn Marino 				       unsigned HOST_WIDE_INT);
1875e4b17023SJohn Marino 
1876e4b17023SJohn Marino /* In reginfo.c  */
1877e4b17023SJohn Marino extern enum machine_mode choose_hard_reg_mode (unsigned int, unsigned int,
1878e4b17023SJohn Marino 					       bool);
1879e4b17023SJohn Marino 
1880e4b17023SJohn Marino /* In emit-rtl.c  */
1881e4b17023SJohn Marino extern rtx set_unique_reg_note (rtx, enum reg_note, rtx);
1882e4b17023SJohn Marino extern rtx set_dst_reg_note (rtx, enum reg_note, rtx, rtx);
1883e4b17023SJohn Marino extern void set_insn_deleted (rtx);
1884e4b17023SJohn Marino 
1885e4b17023SJohn Marino /* Functions in rtlanal.c */
1886e4b17023SJohn Marino 
1887e4b17023SJohn Marino /* Single set is implemented as macro for performance reasons.  */
1888e4b17023SJohn Marino #define single_set(I) (INSN_P (I) \
1889e4b17023SJohn Marino 		       ? (GET_CODE (PATTERN (I)) == SET \
1890e4b17023SJohn Marino 			  ? PATTERN (I) : single_set_1 (I)) \
1891e4b17023SJohn Marino 		       : NULL_RTX)
1892e4b17023SJohn Marino #define single_set_1(I) single_set_2 (I, PATTERN (I))
1893e4b17023SJohn Marino 
1894e4b17023SJohn Marino /* Structure used for passing data to REPLACE_LABEL.  */
1895e4b17023SJohn Marino typedef struct replace_label_data
1896e4b17023SJohn Marino {
1897e4b17023SJohn Marino   rtx r1;
1898e4b17023SJohn Marino   rtx r2;
1899e4b17023SJohn Marino   bool update_label_nuses;
1900e4b17023SJohn Marino } replace_label_data;
1901e4b17023SJohn Marino 
1902e4b17023SJohn Marino extern int rtx_addr_can_trap_p (const_rtx);
1903e4b17023SJohn Marino extern bool nonzero_address_p (const_rtx);
1904e4b17023SJohn Marino extern int rtx_unstable_p (const_rtx);
1905e4b17023SJohn Marino extern bool rtx_varies_p (const_rtx, bool);
1906e4b17023SJohn Marino extern bool rtx_addr_varies_p (const_rtx, bool);
1907e4b17023SJohn Marino extern HOST_WIDE_INT get_integer_term (const_rtx);
1908e4b17023SJohn Marino extern rtx get_related_value (const_rtx);
1909e4b17023SJohn Marino extern bool offset_within_block_p (const_rtx, HOST_WIDE_INT);
1910e4b17023SJohn Marino extern void split_const (rtx, rtx *, rtx *);
1911e4b17023SJohn Marino extern int reg_mentioned_p (const_rtx, const_rtx);
1912e4b17023SJohn Marino extern int count_occurrences (const_rtx, const_rtx, int);
1913e4b17023SJohn Marino extern int reg_referenced_p (const_rtx, const_rtx);
1914e4b17023SJohn Marino extern int reg_used_between_p (const_rtx, const_rtx, const_rtx);
1915e4b17023SJohn Marino extern int reg_set_between_p (const_rtx, const_rtx, const_rtx);
1916e4b17023SJohn Marino extern int commutative_operand_precedence (rtx);
1917e4b17023SJohn Marino extern bool swap_commutative_operands_p (rtx, rtx);
1918e4b17023SJohn Marino extern int modified_between_p (const_rtx, const_rtx, const_rtx);
1919e4b17023SJohn Marino extern int no_labels_between_p (const_rtx, const_rtx);
1920e4b17023SJohn Marino extern int modified_in_p (const_rtx, const_rtx);
1921e4b17023SJohn Marino extern int reg_set_p (const_rtx, const_rtx);
1922e4b17023SJohn Marino extern rtx single_set_2 (const_rtx, const_rtx);
1923e4b17023SJohn Marino extern int multiple_sets (const_rtx);
1924e4b17023SJohn Marino extern int set_noop_p (const_rtx);
1925e4b17023SJohn Marino extern int noop_move_p (const_rtx);
1926e4b17023SJohn Marino extern rtx find_last_value (rtx, rtx *, rtx, int);
1927e4b17023SJohn Marino extern int refers_to_regno_p (unsigned int, unsigned int, const_rtx, rtx *);
1928e4b17023SJohn Marino extern int reg_overlap_mentioned_p (const_rtx, const_rtx);
1929e4b17023SJohn Marino extern const_rtx set_of (const_rtx, const_rtx);
1930e4b17023SJohn Marino extern void record_hard_reg_sets (rtx, const_rtx, void *);
1931e4b17023SJohn Marino extern void record_hard_reg_uses (rtx *, void *);
1932e4b17023SJohn Marino #ifdef HARD_CONST
1933e4b17023SJohn Marino extern void find_all_hard_reg_sets (const_rtx, HARD_REG_SET *);
1934e4b17023SJohn Marino #endif
1935e4b17023SJohn Marino extern void note_stores (const_rtx, void (*) (rtx, const_rtx, void *), void *);
1936e4b17023SJohn Marino extern void note_uses (rtx *, void (*) (rtx *, void *), void *);
1937e4b17023SJohn Marino extern int dead_or_set_p (const_rtx, const_rtx);
1938e4b17023SJohn Marino extern int dead_or_set_regno_p (const_rtx, unsigned int);
1939e4b17023SJohn Marino extern rtx find_reg_note (const_rtx, enum reg_note, const_rtx);
1940e4b17023SJohn Marino extern rtx find_regno_note (const_rtx, enum reg_note, unsigned int);
1941e4b17023SJohn Marino extern rtx find_reg_equal_equiv_note (const_rtx);
1942e4b17023SJohn Marino extern rtx find_constant_src (const_rtx);
1943e4b17023SJohn Marino extern int find_reg_fusage (const_rtx, enum rtx_code, const_rtx);
1944e4b17023SJohn Marino extern int find_regno_fusage (const_rtx, enum rtx_code, unsigned int);
1945e4b17023SJohn Marino extern rtx alloc_reg_note (enum reg_note, rtx, rtx);
1946e4b17023SJohn Marino extern void add_reg_note (rtx, enum reg_note, rtx);
1947e4b17023SJohn Marino extern void remove_note (rtx, const_rtx);
1948e4b17023SJohn Marino extern void remove_reg_equal_equiv_notes (rtx);
1949e4b17023SJohn Marino extern void remove_reg_equal_equiv_notes_for_regno (unsigned int);
1950e4b17023SJohn Marino extern int side_effects_p (const_rtx);
1951e4b17023SJohn Marino extern int volatile_refs_p (const_rtx);
1952e4b17023SJohn Marino extern int volatile_insn_p (const_rtx);
1953e4b17023SJohn Marino extern int may_trap_p_1 (const_rtx, unsigned);
1954e4b17023SJohn Marino extern int may_trap_p (const_rtx);
1955e4b17023SJohn Marino extern int may_trap_or_fault_p (const_rtx);
1956e4b17023SJohn Marino extern bool can_throw_internal (const_rtx);
1957e4b17023SJohn Marino extern bool can_throw_external (const_rtx);
1958e4b17023SJohn Marino extern bool insn_could_throw_p (const_rtx);
1959e4b17023SJohn Marino extern bool insn_nothrow_p (const_rtx);
1960e4b17023SJohn Marino extern bool can_nonlocal_goto (const_rtx);
1961e4b17023SJohn Marino extern void copy_reg_eh_region_note_forward (rtx, rtx, rtx);
1962e4b17023SJohn Marino extern void copy_reg_eh_region_note_backward(rtx, rtx, rtx);
1963e4b17023SJohn Marino extern int inequality_comparisons_p (const_rtx);
1964e4b17023SJohn Marino extern rtx replace_rtx (rtx, rtx, rtx);
1965e4b17023SJohn Marino extern int replace_label (rtx *, void *);
1966e4b17023SJohn Marino extern int rtx_referenced_p (rtx, rtx);
1967e4b17023SJohn Marino extern bool tablejump_p (const_rtx, rtx *, rtx *);
1968e4b17023SJohn Marino extern int computed_jump_p (const_rtx);
1969e4b17023SJohn Marino 
1970e4b17023SJohn Marino typedef int (*rtx_function) (rtx *, void *);
1971e4b17023SJohn Marino extern int for_each_rtx (rtx *, rtx_function, void *);
1972e4b17023SJohn Marino 
1973e4b17023SJohn Marino /* Callback for for_each_inc_dec, to process the autoinc operation OP
1974e4b17023SJohn Marino    within MEM that sets DEST to SRC + SRCOFF, or SRC if SRCOFF is
1975e4b17023SJohn Marino    NULL.  The callback is passed the same opaque ARG passed to
1976e4b17023SJohn Marino    for_each_inc_dec.  Return zero to continue looking for other
1977e4b17023SJohn Marino    autoinc operations, -1 to skip OP's operands, and any other value
1978e4b17023SJohn Marino    to interrupt the traversal and return that value to the caller of
1979e4b17023SJohn Marino    for_each_inc_dec.  */
1980e4b17023SJohn Marino typedef int (*for_each_inc_dec_fn) (rtx mem, rtx op, rtx dest, rtx src,
1981e4b17023SJohn Marino 				    rtx srcoff, void *arg);
1982e4b17023SJohn Marino extern int for_each_inc_dec (rtx *, for_each_inc_dec_fn, void *arg);
1983e4b17023SJohn Marino 
1984e4b17023SJohn Marino typedef int (*rtx_equal_p_callback_function) (const_rtx *, const_rtx *,
1985e4b17023SJohn Marino                                               rtx *, rtx *);
1986e4b17023SJohn Marino extern int rtx_equal_p_cb (const_rtx, const_rtx,
1987e4b17023SJohn Marino                            rtx_equal_p_callback_function);
1988e4b17023SJohn Marino 
1989e4b17023SJohn Marino typedef int (*hash_rtx_callback_function) (const_rtx, enum machine_mode, rtx *,
1990e4b17023SJohn Marino                                            enum machine_mode *);
1991e4b17023SJohn Marino extern unsigned hash_rtx_cb (const_rtx, enum machine_mode, int *, int *,
1992e4b17023SJohn Marino                              bool, hash_rtx_callback_function);
1993e4b17023SJohn Marino 
1994e4b17023SJohn Marino extern rtx regno_use_in (unsigned int, rtx);
1995e4b17023SJohn Marino extern int auto_inc_p (const_rtx);
1996e4b17023SJohn Marino extern int in_expr_list_p (const_rtx, const_rtx);
1997e4b17023SJohn Marino extern void remove_node_from_expr_list (const_rtx, rtx *);
1998e4b17023SJohn Marino extern int loc_mentioned_in_p (rtx *, const_rtx);
1999e4b17023SJohn Marino extern rtx find_first_parameter_load (rtx, rtx);
2000e4b17023SJohn Marino extern bool keep_with_call_p (const_rtx);
2001e4b17023SJohn Marino extern bool label_is_jump_target_p (const_rtx, const_rtx);
2002e4b17023SJohn Marino extern int insn_rtx_cost (rtx, bool);
2003e4b17023SJohn Marino 
2004e4b17023SJohn Marino /* Given an insn and condition, return a canonical description of
2005e4b17023SJohn Marino    the test being made.  */
2006e4b17023SJohn Marino extern rtx canonicalize_condition (rtx, rtx, int, rtx *, rtx, int, int);
2007e4b17023SJohn Marino 
2008e4b17023SJohn Marino /* Given a JUMP_INSN, return a canonical description of the test
2009e4b17023SJohn Marino    being made.  */
2010e4b17023SJohn Marino extern rtx get_condition (rtx, rtx *, int, int);
2011e4b17023SJohn Marino 
2012e4b17023SJohn Marino /* Information about a subreg of a hard register.  */
2013e4b17023SJohn Marino struct subreg_info
2014e4b17023SJohn Marino {
2015e4b17023SJohn Marino   /* Offset of first hard register involved in the subreg.  */
2016e4b17023SJohn Marino   int offset;
2017e4b17023SJohn Marino   /* Number of hard registers involved in the subreg.  */
2018e4b17023SJohn Marino   int nregs;
2019e4b17023SJohn Marino   /* Whether this subreg can be represented as a hard reg with the new
2020e4b17023SJohn Marino      mode.  */
2021e4b17023SJohn Marino   bool representable_p;
2022e4b17023SJohn Marino };
2023e4b17023SJohn Marino 
2024e4b17023SJohn Marino extern void subreg_get_info (unsigned int, enum machine_mode,
2025e4b17023SJohn Marino 			     unsigned int, enum machine_mode,
2026e4b17023SJohn Marino 			     struct subreg_info *);
2027e4b17023SJohn Marino 
2028e4b17023SJohn Marino /* lists.c */
2029e4b17023SJohn Marino 
2030e4b17023SJohn Marino extern void free_EXPR_LIST_list (rtx *);
2031e4b17023SJohn Marino extern void free_INSN_LIST_list (rtx *);
2032e4b17023SJohn Marino extern void free_EXPR_LIST_node (rtx);
2033e4b17023SJohn Marino extern void free_INSN_LIST_node (rtx);
2034e4b17023SJohn Marino extern rtx alloc_INSN_LIST (rtx, rtx);
2035e4b17023SJohn Marino extern rtx copy_INSN_LIST (rtx);
2036e4b17023SJohn Marino extern rtx concat_INSN_LIST (rtx, rtx);
2037e4b17023SJohn Marino extern rtx alloc_EXPR_LIST (int, rtx, rtx);
2038e4b17023SJohn Marino extern void remove_free_INSN_LIST_elem (rtx, rtx *);
2039e4b17023SJohn Marino extern rtx remove_list_elem (rtx, rtx *);
2040e4b17023SJohn Marino extern rtx remove_free_INSN_LIST_node (rtx *);
2041e4b17023SJohn Marino extern rtx remove_free_EXPR_LIST_node (rtx *);
2042e4b17023SJohn Marino 
2043e4b17023SJohn Marino 
2044e4b17023SJohn Marino /* reginfo.c */
2045e4b17023SJohn Marino 
2046e4b17023SJohn Marino /* Initialize may_move_cost and friends for mode M.  */
2047e4b17023SJohn Marino extern void init_move_cost (enum machine_mode);
2048e4b17023SJohn Marino /* Resize reg info.  */
2049e4b17023SJohn Marino extern bool resize_reg_info (void);
2050e4b17023SJohn Marino /* Free up register info memory.  */
2051e4b17023SJohn Marino extern void free_reg_info (void);
2052e4b17023SJohn Marino extern void init_subregs_of_mode (void);
2053e4b17023SJohn Marino extern void finish_subregs_of_mode (void);
2054e4b17023SJohn Marino 
2055e4b17023SJohn Marino /* recog.c */
2056e4b17023SJohn Marino extern rtx extract_asm_operands (rtx);
2057e4b17023SJohn Marino extern int asm_noperands (const_rtx);
2058e4b17023SJohn Marino extern const char *decode_asm_operands (rtx, rtx *, rtx **, const char **,
2059e4b17023SJohn Marino 					enum machine_mode *, location_t *);
2060e4b17023SJohn Marino 
2061e4b17023SJohn Marino extern enum reg_class reg_preferred_class (int);
2062e4b17023SJohn Marino extern enum reg_class reg_alternate_class (int);
2063e4b17023SJohn Marino extern enum reg_class reg_allocno_class (int);
2064e4b17023SJohn Marino extern void setup_reg_classes (int, enum reg_class, enum reg_class,
2065e4b17023SJohn Marino 			       enum reg_class);
2066e4b17023SJohn Marino 
2067e4b17023SJohn Marino extern void split_all_insns (void);
2068e4b17023SJohn Marino extern unsigned int split_all_insns_noflow (void);
2069e4b17023SJohn Marino 
2070e4b17023SJohn Marino #define MAX_SAVED_CONST_INT 64
2071e4b17023SJohn Marino extern GTY(()) rtx const_int_rtx[MAX_SAVED_CONST_INT * 2 + 1];
2072e4b17023SJohn Marino 
2073e4b17023SJohn Marino #define const0_rtx	(const_int_rtx[MAX_SAVED_CONST_INT])
2074e4b17023SJohn Marino #define const1_rtx	(const_int_rtx[MAX_SAVED_CONST_INT+1])
2075e4b17023SJohn Marino #define const2_rtx	(const_int_rtx[MAX_SAVED_CONST_INT+2])
2076e4b17023SJohn Marino #define constm1_rtx	(const_int_rtx[MAX_SAVED_CONST_INT-1])
2077e4b17023SJohn Marino extern GTY(()) rtx const_true_rtx;
2078e4b17023SJohn Marino 
2079e4b17023SJohn Marino extern GTY(()) rtx const_tiny_rtx[4][(int) MAX_MACHINE_MODE];
2080e4b17023SJohn Marino 
2081e4b17023SJohn Marino /* Returns a constant 0 rtx in mode MODE.  Integer modes are treated the
2082e4b17023SJohn Marino    same as VOIDmode.  */
2083e4b17023SJohn Marino 
2084e4b17023SJohn Marino #define CONST0_RTX(MODE) (const_tiny_rtx[0][(int) (MODE)])
2085e4b17023SJohn Marino 
2086e4b17023SJohn Marino /* Likewise, for the constants 1 and 2 and -1.  */
2087e4b17023SJohn Marino 
2088e4b17023SJohn Marino #define CONST1_RTX(MODE) (const_tiny_rtx[1][(int) (MODE)])
2089e4b17023SJohn Marino #define CONST2_RTX(MODE) (const_tiny_rtx[2][(int) (MODE)])
2090e4b17023SJohn Marino #define CONSTM1_RTX(MODE) (const_tiny_rtx[3][(int) (MODE)])
2091e4b17023SJohn Marino 
2092e4b17023SJohn Marino /* If HARD_FRAME_POINTER_REGNUM is defined, then a special dummy reg
2093e4b17023SJohn Marino    is used to represent the frame pointer.  This is because the
2094e4b17023SJohn Marino    hard frame pointer and the automatic variables are separated by an amount
2095e4b17023SJohn Marino    that cannot be determined until after register allocation.  We can assume
2096e4b17023SJohn Marino    that in this case ELIMINABLE_REGS will be defined, one action of which
2097e4b17023SJohn Marino    will be to eliminate FRAME_POINTER_REGNUM into HARD_FRAME_POINTER_REGNUM.  */
2098e4b17023SJohn Marino #ifndef HARD_FRAME_POINTER_REGNUM
2099e4b17023SJohn Marino #define HARD_FRAME_POINTER_REGNUM FRAME_POINTER_REGNUM
2100e4b17023SJohn Marino #endif
2101e4b17023SJohn Marino 
2102e4b17023SJohn Marino #ifndef HARD_FRAME_POINTER_IS_FRAME_POINTER
2103e4b17023SJohn Marino #define HARD_FRAME_POINTER_IS_FRAME_POINTER \
2104e4b17023SJohn Marino   (HARD_FRAME_POINTER_REGNUM == FRAME_POINTER_REGNUM)
2105e4b17023SJohn Marino #endif
2106e4b17023SJohn Marino 
2107e4b17023SJohn Marino #ifndef HARD_FRAME_POINTER_IS_ARG_POINTER
2108e4b17023SJohn Marino #define HARD_FRAME_POINTER_IS_ARG_POINTER \
2109e4b17023SJohn Marino   (HARD_FRAME_POINTER_REGNUM == ARG_POINTER_REGNUM)
2110e4b17023SJohn Marino #endif
2111e4b17023SJohn Marino 
2112e4b17023SJohn Marino /* Index labels for global_rtl.  */
2113e4b17023SJohn Marino enum global_rtl_index
2114e4b17023SJohn Marino {
2115e4b17023SJohn Marino   GR_PC,
2116e4b17023SJohn Marino   GR_CC0,
2117e4b17023SJohn Marino   GR_RETURN,
2118e4b17023SJohn Marino   GR_SIMPLE_RETURN,
2119e4b17023SJohn Marino   GR_STACK_POINTER,
2120e4b17023SJohn Marino   GR_FRAME_POINTER,
2121e4b17023SJohn Marino /* For register elimination to work properly these hard_frame_pointer_rtx,
2122e4b17023SJohn Marino    frame_pointer_rtx, and arg_pointer_rtx must be the same if they refer to
2123e4b17023SJohn Marino    the same register.  */
2124e4b17023SJohn Marino #if FRAME_POINTER_REGNUM == ARG_POINTER_REGNUM
2125e4b17023SJohn Marino   GR_ARG_POINTER = GR_FRAME_POINTER,
2126e4b17023SJohn Marino #endif
2127e4b17023SJohn Marino #if HARD_FRAME_POINTER_IS_FRAME_POINTER
2128e4b17023SJohn Marino   GR_HARD_FRAME_POINTER = GR_FRAME_POINTER,
2129e4b17023SJohn Marino #else
2130e4b17023SJohn Marino   GR_HARD_FRAME_POINTER,
2131e4b17023SJohn Marino #endif
2132e4b17023SJohn Marino #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
2133e4b17023SJohn Marino #if HARD_FRAME_POINTER_IS_ARG_POINTER
2134e4b17023SJohn Marino   GR_ARG_POINTER = GR_HARD_FRAME_POINTER,
2135e4b17023SJohn Marino #else
2136e4b17023SJohn Marino   GR_ARG_POINTER,
2137e4b17023SJohn Marino #endif
2138e4b17023SJohn Marino #endif
2139e4b17023SJohn Marino   GR_VIRTUAL_INCOMING_ARGS,
2140e4b17023SJohn Marino   GR_VIRTUAL_STACK_ARGS,
2141e4b17023SJohn Marino   GR_VIRTUAL_STACK_DYNAMIC,
2142e4b17023SJohn Marino   GR_VIRTUAL_OUTGOING_ARGS,
2143e4b17023SJohn Marino   GR_VIRTUAL_CFA,
2144e4b17023SJohn Marino   GR_VIRTUAL_PREFERRED_STACK_BOUNDARY,
2145e4b17023SJohn Marino 
2146e4b17023SJohn Marino   GR_MAX
2147e4b17023SJohn Marino };
2148e4b17023SJohn Marino 
2149e4b17023SJohn Marino /* Target-dependent globals.  */
2150e4b17023SJohn Marino struct GTY(()) target_rtl {
2151e4b17023SJohn Marino   /* All references to the hard registers in global_rtl_index go through
2152e4b17023SJohn Marino      these unique rtl objects.  On machines where the frame-pointer and
2153e4b17023SJohn Marino      arg-pointer are the same register, they use the same unique object.
2154e4b17023SJohn Marino 
2155e4b17023SJohn Marino      After register allocation, other rtl objects which used to be pseudo-regs
2156e4b17023SJohn Marino      may be clobbered to refer to the frame-pointer register.
2157e4b17023SJohn Marino      But references that were originally to the frame-pointer can be
2158e4b17023SJohn Marino      distinguished from the others because they contain frame_pointer_rtx.
2159e4b17023SJohn Marino 
2160e4b17023SJohn Marino      When to use frame_pointer_rtx and hard_frame_pointer_rtx is a little
2161e4b17023SJohn Marino      tricky: until register elimination has taken place hard_frame_pointer_rtx
2162e4b17023SJohn Marino      should be used if it is being set, and frame_pointer_rtx otherwise.  After
2163e4b17023SJohn Marino      register elimination hard_frame_pointer_rtx should always be used.
2164e4b17023SJohn Marino      On machines where the two registers are same (most) then these are the
2165e4b17023SJohn Marino      same.  */
2166e4b17023SJohn Marino   rtx x_global_rtl[GR_MAX];
2167e4b17023SJohn Marino 
2168e4b17023SJohn Marino   /* A unique representation of (REG:Pmode PIC_OFFSET_TABLE_REGNUM).  */
2169e4b17023SJohn Marino   rtx x_pic_offset_table_rtx;
2170e4b17023SJohn Marino 
2171e4b17023SJohn Marino   /* A unique representation of (REG:Pmode RETURN_ADDRESS_POINTER_REGNUM).
2172e4b17023SJohn Marino      This is used to implement __builtin_return_address for some machines;
2173e4b17023SJohn Marino      see for instance the MIPS port.  */
2174e4b17023SJohn Marino   rtx x_return_address_pointer_rtx;
2175e4b17023SJohn Marino 
2176e4b17023SJohn Marino   /* Commonly used RTL for hard registers.  These objects are not
2177e4b17023SJohn Marino      necessarily unique, so we allocate them separately from global_rtl.
2178e4b17023SJohn Marino      They are initialized once per compilation unit, then copied into
2179e4b17023SJohn Marino      regno_reg_rtx at the beginning of each function.  */
2180e4b17023SJohn Marino   rtx x_initial_regno_reg_rtx[FIRST_PSEUDO_REGISTER];
2181e4b17023SJohn Marino 
2182e4b17023SJohn Marino   /* A sample (mem:M stack_pointer_rtx) rtx for each mode M.  */
2183e4b17023SJohn Marino   rtx x_top_of_stack[MAX_MACHINE_MODE];
2184e4b17023SJohn Marino 
2185e4b17023SJohn Marino   /* Static hunks of RTL used by the aliasing code; these are treated
2186e4b17023SJohn Marino      as persistent to avoid unnecessary RTL allocations.  */
2187e4b17023SJohn Marino   rtx x_static_reg_base_value[FIRST_PSEUDO_REGISTER];
2188e4b17023SJohn Marino 
2189e4b17023SJohn Marino   /* The default memory attributes for each mode.  */
2190e4b17023SJohn Marino   struct mem_attrs *x_mode_mem_attrs[(int) MAX_MACHINE_MODE];
2191e4b17023SJohn Marino };
2192e4b17023SJohn Marino 
2193e4b17023SJohn Marino extern GTY(()) struct target_rtl default_target_rtl;
2194e4b17023SJohn Marino #if SWITCHABLE_TARGET
2195e4b17023SJohn Marino extern struct target_rtl *this_target_rtl;
2196e4b17023SJohn Marino #else
2197e4b17023SJohn Marino #define this_target_rtl (&default_target_rtl)
2198e4b17023SJohn Marino #endif
2199e4b17023SJohn Marino 
2200e4b17023SJohn Marino #define global_rtl				\
2201e4b17023SJohn Marino   (this_target_rtl->x_global_rtl)
2202e4b17023SJohn Marino #define pic_offset_table_rtx \
2203e4b17023SJohn Marino   (this_target_rtl->x_pic_offset_table_rtx)
2204e4b17023SJohn Marino #define return_address_pointer_rtx \
2205e4b17023SJohn Marino   (this_target_rtl->x_return_address_pointer_rtx)
2206e4b17023SJohn Marino #define top_of_stack \
2207e4b17023SJohn Marino   (this_target_rtl->x_top_of_stack)
2208e4b17023SJohn Marino #define mode_mem_attrs \
2209e4b17023SJohn Marino   (this_target_rtl->x_mode_mem_attrs)
2210e4b17023SJohn Marino 
2211e4b17023SJohn Marino /* Standard pieces of rtx, to be substituted directly into things.  */
2212e4b17023SJohn Marino #define pc_rtx                  (global_rtl[GR_PC])
2213e4b17023SJohn Marino #define ret_rtx                 (global_rtl[GR_RETURN])
2214e4b17023SJohn Marino #define simple_return_rtx       (global_rtl[GR_SIMPLE_RETURN])
2215e4b17023SJohn Marino #define cc0_rtx                 (global_rtl[GR_CC0])
2216e4b17023SJohn Marino 
2217e4b17023SJohn Marino /* All references to certain hard regs, except those created
2218e4b17023SJohn Marino    by allocating pseudo regs into them (when that's possible),
2219e4b17023SJohn Marino    go through these unique rtx objects.  */
2220e4b17023SJohn Marino #define stack_pointer_rtx       (global_rtl[GR_STACK_POINTER])
2221e4b17023SJohn Marino #define frame_pointer_rtx       (global_rtl[GR_FRAME_POINTER])
2222e4b17023SJohn Marino #define hard_frame_pointer_rtx	(global_rtl[GR_HARD_FRAME_POINTER])
2223e4b17023SJohn Marino #define arg_pointer_rtx		(global_rtl[GR_ARG_POINTER])
2224e4b17023SJohn Marino 
2225e4b17023SJohn Marino #ifndef GENERATOR_FILE
2226e4b17023SJohn Marino /* Return the attributes of a MEM rtx.  */
2227e4b17023SJohn Marino static inline struct mem_attrs *
get_mem_attrs(const_rtx x)2228e4b17023SJohn Marino get_mem_attrs (const_rtx x)
2229e4b17023SJohn Marino {
2230e4b17023SJohn Marino   struct mem_attrs *attrs;
2231e4b17023SJohn Marino 
2232e4b17023SJohn Marino   attrs = MEM_ATTRS (x);
2233e4b17023SJohn Marino   if (!attrs)
2234e4b17023SJohn Marino     attrs = mode_mem_attrs[(int) GET_MODE (x)];
2235e4b17023SJohn Marino   return attrs;
2236e4b17023SJohn Marino }
2237e4b17023SJohn Marino #endif
2238e4b17023SJohn Marino 
2239e4b17023SJohn Marino /* Include the RTL generation functions.  */
2240e4b17023SJohn Marino 
2241e4b17023SJohn Marino #ifndef GENERATOR_FILE
2242e4b17023SJohn Marino #include "genrtl.h"
2243e4b17023SJohn Marino #undef gen_rtx_ASM_INPUT
2244e4b17023SJohn Marino #define gen_rtx_ASM_INPUT(MODE, ARG0)				\
2245e4b17023SJohn Marino   gen_rtx_fmt_si (ASM_INPUT, (MODE), (ARG0), 0)
2246e4b17023SJohn Marino #define gen_rtx_ASM_INPUT_loc(MODE, ARG0, LOC)			\
2247e4b17023SJohn Marino   gen_rtx_fmt_si (ASM_INPUT, (MODE), (ARG0), (LOC))
2248e4b17023SJohn Marino #endif
2249e4b17023SJohn Marino 
2250e4b17023SJohn Marino /* There are some RTL codes that require special attention; the
2251e4b17023SJohn Marino    generation functions included above do the raw handling.  If you
2252e4b17023SJohn Marino    add to this list, modify special_rtx in gengenrtl.c as well.  */
2253e4b17023SJohn Marino 
2254e4b17023SJohn Marino extern rtx gen_rtx_CONST_INT (enum machine_mode, HOST_WIDE_INT);
2255e4b17023SJohn Marino extern rtx gen_rtx_CONST_VECTOR (enum machine_mode, rtvec);
2256e4b17023SJohn Marino extern rtx gen_raw_REG (enum machine_mode, int);
2257e4b17023SJohn Marino extern rtx gen_rtx_REG (enum machine_mode, unsigned);
2258e4b17023SJohn Marino extern rtx gen_rtx_SUBREG (enum machine_mode, rtx, int);
2259e4b17023SJohn Marino extern rtx gen_rtx_MEM (enum machine_mode, rtx);
2260e4b17023SJohn Marino 
2261e4b17023SJohn Marino #define GEN_INT(N)  gen_rtx_CONST_INT (VOIDmode, (N))
2262e4b17023SJohn Marino 
2263e4b17023SJohn Marino /* Virtual registers are used during RTL generation to refer to locations into
2264e4b17023SJohn Marino    the stack frame when the actual location isn't known until RTL generation
2265e4b17023SJohn Marino    is complete.  The routine instantiate_virtual_regs replaces these with
2266e4b17023SJohn Marino    the proper value, which is normally {frame,arg,stack}_pointer_rtx plus
2267e4b17023SJohn Marino    a constant.  */
2268e4b17023SJohn Marino 
2269e4b17023SJohn Marino #define FIRST_VIRTUAL_REGISTER	(FIRST_PSEUDO_REGISTER)
2270e4b17023SJohn Marino 
2271e4b17023SJohn Marino /* This points to the first word of the incoming arguments passed on the stack,
2272e4b17023SJohn Marino    either by the caller or by the callee when pretending it was passed by the
2273e4b17023SJohn Marino    caller.  */
2274e4b17023SJohn Marino 
2275e4b17023SJohn Marino #define virtual_incoming_args_rtx       (global_rtl[GR_VIRTUAL_INCOMING_ARGS])
2276e4b17023SJohn Marino 
2277e4b17023SJohn Marino #define VIRTUAL_INCOMING_ARGS_REGNUM	(FIRST_VIRTUAL_REGISTER)
2278e4b17023SJohn Marino 
2279e4b17023SJohn Marino /* If FRAME_GROWS_DOWNWARD, this points to immediately above the first
2280e4b17023SJohn Marino    variable on the stack.  Otherwise, it points to the first variable on
2281e4b17023SJohn Marino    the stack.  */
2282e4b17023SJohn Marino 
2283e4b17023SJohn Marino #define virtual_stack_vars_rtx	        (global_rtl[GR_VIRTUAL_STACK_ARGS])
2284e4b17023SJohn Marino 
2285e4b17023SJohn Marino #define VIRTUAL_STACK_VARS_REGNUM	((FIRST_VIRTUAL_REGISTER) + 1)
2286e4b17023SJohn Marino 
2287e4b17023SJohn Marino /* This points to the location of dynamically-allocated memory on the stack
2288e4b17023SJohn Marino    immediately after the stack pointer has been adjusted by the amount
2289e4b17023SJohn Marino    desired.  */
2290e4b17023SJohn Marino 
2291e4b17023SJohn Marino #define virtual_stack_dynamic_rtx	(global_rtl[GR_VIRTUAL_STACK_DYNAMIC])
2292e4b17023SJohn Marino 
2293e4b17023SJohn Marino #define VIRTUAL_STACK_DYNAMIC_REGNUM	((FIRST_VIRTUAL_REGISTER) + 2)
2294e4b17023SJohn Marino 
2295e4b17023SJohn Marino /* This points to the location in the stack at which outgoing arguments should
2296e4b17023SJohn Marino    be written when the stack is pre-pushed (arguments pushed using push
2297e4b17023SJohn Marino    insns always use sp).  */
2298e4b17023SJohn Marino 
2299e4b17023SJohn Marino #define virtual_outgoing_args_rtx	(global_rtl[GR_VIRTUAL_OUTGOING_ARGS])
2300e4b17023SJohn Marino 
2301e4b17023SJohn Marino #define VIRTUAL_OUTGOING_ARGS_REGNUM	((FIRST_VIRTUAL_REGISTER) + 3)
2302e4b17023SJohn Marino 
2303e4b17023SJohn Marino /* This points to the Canonical Frame Address of the function.  This
2304e4b17023SJohn Marino    should correspond to the CFA produced by INCOMING_FRAME_SP_OFFSET,
2305e4b17023SJohn Marino    but is calculated relative to the arg pointer for simplicity; the
2306e4b17023SJohn Marino    frame pointer nor stack pointer are necessarily fixed relative to
2307e4b17023SJohn Marino    the CFA until after reload.  */
2308e4b17023SJohn Marino 
2309e4b17023SJohn Marino #define virtual_cfa_rtx			(global_rtl[GR_VIRTUAL_CFA])
2310e4b17023SJohn Marino 
2311e4b17023SJohn Marino #define VIRTUAL_CFA_REGNUM		((FIRST_VIRTUAL_REGISTER) + 4)
2312e4b17023SJohn Marino 
2313e4b17023SJohn Marino #define LAST_VIRTUAL_POINTER_REGISTER	((FIRST_VIRTUAL_REGISTER) + 4)
2314e4b17023SJohn Marino 
2315e4b17023SJohn Marino /* This is replaced by crtl->preferred_stack_boundary / BITS_PER_UNIT
2316e4b17023SJohn Marino    when finalized.  */
2317e4b17023SJohn Marino 
2318e4b17023SJohn Marino #define virtual_preferred_stack_boundary_rtx \
2319e4b17023SJohn Marino 	(global_rtl[GR_VIRTUAL_PREFERRED_STACK_BOUNDARY])
2320e4b17023SJohn Marino 
2321e4b17023SJohn Marino #define VIRTUAL_PREFERRED_STACK_BOUNDARY_REGNUM \
2322e4b17023SJohn Marino 					((FIRST_VIRTUAL_REGISTER) + 5)
2323e4b17023SJohn Marino 
2324e4b17023SJohn Marino #define LAST_VIRTUAL_REGISTER		((FIRST_VIRTUAL_REGISTER) + 5)
2325e4b17023SJohn Marino 
2326e4b17023SJohn Marino /* Nonzero if REGNUM is a pointer into the stack frame.  */
2327e4b17023SJohn Marino #define REGNO_PTR_FRAME_P(REGNUM)		\
2328e4b17023SJohn Marino   ((REGNUM) == STACK_POINTER_REGNUM		\
2329e4b17023SJohn Marino    || (REGNUM) == FRAME_POINTER_REGNUM		\
2330e4b17023SJohn Marino    || (REGNUM) == HARD_FRAME_POINTER_REGNUM	\
2331e4b17023SJohn Marino    || (REGNUM) == ARG_POINTER_REGNUM		\
2332e4b17023SJohn Marino    || ((REGNUM) >= FIRST_VIRTUAL_REGISTER	\
2333e4b17023SJohn Marino        && (REGNUM) <= LAST_VIRTUAL_POINTER_REGISTER))
2334e4b17023SJohn Marino 
2335e4b17023SJohn Marino /* REGNUM never really appearing in the INSN stream.  */
2336e4b17023SJohn Marino #define INVALID_REGNUM			(~(unsigned int) 0)
2337e4b17023SJohn Marino 
2338e4b17023SJohn Marino extern rtx output_constant_def (tree, int);
2339e4b17023SJohn Marino extern rtx lookup_constant_def (tree);
2340e4b17023SJohn Marino 
2341e4b17023SJohn Marino /* Nonzero after end of reload pass.
2342e4b17023SJohn Marino    Set to 1 or 0 by reload1.c.  */
2343e4b17023SJohn Marino 
2344e4b17023SJohn Marino extern int reload_completed;
2345e4b17023SJohn Marino 
2346e4b17023SJohn Marino /* Nonzero after thread_prologue_and_epilogue_insns has run.  */
2347e4b17023SJohn Marino extern int epilogue_completed;
2348e4b17023SJohn Marino 
2349e4b17023SJohn Marino /* Set to 1 while reload_as_needed is operating.
2350e4b17023SJohn Marino    Required by some machines to handle any generated moves differently.  */
2351e4b17023SJohn Marino 
2352e4b17023SJohn Marino extern int reload_in_progress;
2353e4b17023SJohn Marino 
2354e4b17023SJohn Marino /* This macro indicates whether you may create a new
2355e4b17023SJohn Marino    pseudo-register.  */
2356e4b17023SJohn Marino 
2357e4b17023SJohn Marino #define can_create_pseudo_p() (!reload_in_progress && !reload_completed)
2358e4b17023SJohn Marino 
2359e4b17023SJohn Marino #ifdef STACK_REGS
2360e4b17023SJohn Marino /* Nonzero after end of regstack pass.
2361e4b17023SJohn Marino    Set to 1 or 0 by reg-stack.c.  */
2362e4b17023SJohn Marino extern int regstack_completed;
2363e4b17023SJohn Marino #endif
2364e4b17023SJohn Marino 
2365e4b17023SJohn Marino /* If this is nonzero, we do not bother generating VOLATILE
2366e4b17023SJohn Marino    around volatile memory references, and we are willing to
2367e4b17023SJohn Marino    output indirect addresses.  If cse is to follow, we reject
2368e4b17023SJohn Marino    indirect addresses so a useful potential cse is generated;
2369e4b17023SJohn Marino    if it is used only once, instruction combination will produce
2370e4b17023SJohn Marino    the same indirect address eventually.  */
2371e4b17023SJohn Marino extern int cse_not_expected;
2372e4b17023SJohn Marino 
2373e4b17023SJohn Marino /* Translates rtx code to tree code, for those codes needed by
2374e4b17023SJohn Marino    REAL_ARITHMETIC.  The function returns an int because the caller may not
2375e4b17023SJohn Marino    know what `enum tree_code' means.  */
2376e4b17023SJohn Marino 
2377e4b17023SJohn Marino extern int rtx_to_tree_code (enum rtx_code);
2378e4b17023SJohn Marino 
2379e4b17023SJohn Marino /* In cse.c */
2380e4b17023SJohn Marino extern int delete_trivially_dead_insns (rtx, int);
2381e4b17023SJohn Marino extern int cse_main (rtx, int);
2382e4b17023SJohn Marino extern int exp_equiv_p (const_rtx, const_rtx, int, bool);
2383e4b17023SJohn Marino extern unsigned hash_rtx (const_rtx x, enum machine_mode, int *, int *, bool);
2384e4b17023SJohn Marino 
2385e4b17023SJohn Marino /* In dse.c */
2386e4b17023SJohn Marino extern bool check_for_inc_dec (rtx insn);
2387e4b17023SJohn Marino 
2388e4b17023SJohn Marino /* In jump.c */
2389e4b17023SJohn Marino extern int comparison_dominates_p (enum rtx_code, enum rtx_code);
2390e4b17023SJohn Marino extern bool jump_to_label_p (rtx);
2391e4b17023SJohn Marino extern int condjump_p (const_rtx);
2392e4b17023SJohn Marino extern int any_condjump_p (const_rtx);
2393e4b17023SJohn Marino extern int any_uncondjump_p (const_rtx);
2394e4b17023SJohn Marino extern rtx pc_set (const_rtx);
2395e4b17023SJohn Marino extern rtx condjump_label (const_rtx);
2396e4b17023SJohn Marino extern int simplejump_p (const_rtx);
2397e4b17023SJohn Marino extern int returnjump_p (rtx);
2398e4b17023SJohn Marino extern int eh_returnjump_p (rtx);
2399e4b17023SJohn Marino extern int onlyjump_p (const_rtx);
2400e4b17023SJohn Marino extern int only_sets_cc0_p (const_rtx);
2401e4b17023SJohn Marino extern int sets_cc0_p (const_rtx);
2402e4b17023SJohn Marino extern int invert_jump_1 (rtx, rtx);
2403e4b17023SJohn Marino extern int invert_jump (rtx, rtx, int);
2404e4b17023SJohn Marino extern int rtx_renumbered_equal_p (const_rtx, const_rtx);
2405e4b17023SJohn Marino extern int true_regnum (const_rtx);
2406e4b17023SJohn Marino extern unsigned int reg_or_subregno (const_rtx);
2407e4b17023SJohn Marino extern int redirect_jump_1 (rtx, rtx);
2408e4b17023SJohn Marino extern void redirect_jump_2 (rtx, rtx, rtx, int, int);
2409e4b17023SJohn Marino extern int redirect_jump (rtx, rtx, int);
2410e4b17023SJohn Marino extern void rebuild_jump_labels (rtx);
2411e4b17023SJohn Marino extern void rebuild_jump_labels_chain (rtx);
2412e4b17023SJohn Marino extern rtx reversed_comparison (const_rtx, enum machine_mode);
2413e4b17023SJohn Marino extern enum rtx_code reversed_comparison_code (const_rtx, const_rtx);
2414e4b17023SJohn Marino extern enum rtx_code reversed_comparison_code_parts (enum rtx_code, const_rtx,
2415e4b17023SJohn Marino 						     const_rtx, const_rtx);
2416e4b17023SJohn Marino extern void delete_for_peephole (rtx, rtx);
2417e4b17023SJohn Marino extern int condjump_in_parallel_p (const_rtx);
2418e4b17023SJohn Marino 
2419e4b17023SJohn Marino /* In emit-rtl.c.  */
2420e4b17023SJohn Marino extern int max_reg_num (void);
2421e4b17023SJohn Marino extern int max_label_num (void);
2422e4b17023SJohn Marino extern int get_first_label_num (void);
2423e4b17023SJohn Marino extern void maybe_set_first_label_num (rtx);
2424e4b17023SJohn Marino extern void delete_insns_since (rtx);
2425e4b17023SJohn Marino extern void mark_reg_pointer (rtx, int);
2426e4b17023SJohn Marino extern void mark_user_reg (rtx);
2427e4b17023SJohn Marino extern void reset_used_flags (rtx);
2428e4b17023SJohn Marino extern void set_used_flags (rtx);
2429e4b17023SJohn Marino extern void reorder_insns (rtx, rtx, rtx);
2430e4b17023SJohn Marino extern void reorder_insns_nobb (rtx, rtx, rtx);
2431e4b17023SJohn Marino extern int get_max_insn_count (void);
2432e4b17023SJohn Marino extern int in_sequence_p (void);
2433e4b17023SJohn Marino extern void force_next_line_note (void);
2434e4b17023SJohn Marino extern void init_emit (void);
2435e4b17023SJohn Marino extern void init_emit_regs (void);
2436e4b17023SJohn Marino extern void init_emit_once (void);
2437e4b17023SJohn Marino extern void push_topmost_sequence (void);
2438e4b17023SJohn Marino extern void pop_topmost_sequence (void);
2439e4b17023SJohn Marino extern void set_new_first_and_last_insn (rtx, rtx);
2440e4b17023SJohn Marino extern unsigned int unshare_all_rtl (void);
2441e4b17023SJohn Marino extern void unshare_all_rtl_again (rtx);
2442e4b17023SJohn Marino extern void unshare_all_rtl_in_chain (rtx);
2443e4b17023SJohn Marino extern void verify_rtl_sharing (void);
2444e4b17023SJohn Marino extern void link_cc0_insns (rtx);
2445e4b17023SJohn Marino extern void add_insn (rtx);
2446e4b17023SJohn Marino extern void add_insn_before (rtx, rtx, struct basic_block_def *);
2447e4b17023SJohn Marino extern void add_insn_after (rtx, rtx, struct basic_block_def *);
2448e4b17023SJohn Marino extern void remove_insn (rtx);
2449e4b17023SJohn Marino extern rtx emit (rtx);
2450e4b17023SJohn Marino extern rtx delete_insn (rtx);
2451e4b17023SJohn Marino extern rtx entry_of_function (void);
2452e4b17023SJohn Marino extern void emit_insn_at_entry (rtx);
2453e4b17023SJohn Marino extern void delete_insn_chain (rtx, rtx, bool);
2454e4b17023SJohn Marino extern rtx unlink_insn_chain (rtx, rtx);
2455e4b17023SJohn Marino extern rtx delete_insn_and_edges (rtx);
2456e4b17023SJohn Marino extern rtx gen_lowpart_SUBREG (enum machine_mode, rtx);
2457e4b17023SJohn Marino extern rtx gen_const_mem (enum machine_mode, rtx);
2458e4b17023SJohn Marino extern rtx gen_frame_mem (enum machine_mode, rtx);
2459e4b17023SJohn Marino extern rtx gen_tmp_stack_mem (enum machine_mode, rtx);
2460e4b17023SJohn Marino extern bool validate_subreg (enum machine_mode, enum machine_mode,
2461e4b17023SJohn Marino 			     const_rtx, unsigned int);
2462e4b17023SJohn Marino 
2463e4b17023SJohn Marino /* In combine.c  */
2464e4b17023SJohn Marino extern unsigned int extended_count (const_rtx, enum machine_mode, int);
2465e4b17023SJohn Marino extern rtx remove_death (unsigned int, rtx);
2466e4b17023SJohn Marino extern void dump_combine_stats (FILE *);
2467e4b17023SJohn Marino extern void dump_combine_total_stats (FILE *);
2468e4b17023SJohn Marino 
2469e4b17023SJohn Marino /* In cfgcleanup.c  */
2470e4b17023SJohn Marino extern void delete_dead_jumptables (void);
2471e4b17023SJohn Marino 
2472e4b17023SJohn Marino /* In sched-vis.c.  */
2473e4b17023SJohn Marino extern void debug_bb_n_slim (int);
2474e4b17023SJohn Marino extern void debug_bb_slim (struct basic_block_def *);
2475e4b17023SJohn Marino extern void print_rtl_slim (FILE *, rtx, rtx, int, int);
2476e4b17023SJohn Marino extern void print_rtl_slim_with_bb (FILE *, rtx, int);
2477e4b17023SJohn Marino extern void dump_insn_slim (FILE *f, rtx x);
2478e4b17023SJohn Marino extern void debug_insn_slim (rtx x);
2479e4b17023SJohn Marino 
2480e4b17023SJohn Marino /* In sched-rgn.c.  */
2481e4b17023SJohn Marino extern void schedule_insns (void);
2482e4b17023SJohn Marino 
2483e4b17023SJohn Marino /* In sched-ebb.c.  */
2484e4b17023SJohn Marino extern void schedule_ebbs (void);
2485e4b17023SJohn Marino 
2486e4b17023SJohn Marino /* In sel-sched-dump.c.  */
2487e4b17023SJohn Marino extern void sel_sched_fix_param (const char *param, const char *val);
2488e4b17023SJohn Marino 
2489e4b17023SJohn Marino /* In print-rtl.c */
2490e4b17023SJohn Marino extern const char *print_rtx_head;
2491e4b17023SJohn Marino extern void debug_rtx (const_rtx);
2492e4b17023SJohn Marino extern void debug_rtx_list (const_rtx, int);
2493e4b17023SJohn Marino extern void debug_rtx_range (const_rtx, const_rtx);
2494e4b17023SJohn Marino extern const_rtx debug_rtx_find (const_rtx, int);
2495e4b17023SJohn Marino extern void print_mem_expr (FILE *, const_tree);
2496e4b17023SJohn Marino extern void print_rtl (FILE *, const_rtx);
2497e4b17023SJohn Marino extern void print_simple_rtl (FILE *, const_rtx);
2498e4b17023SJohn Marino extern int print_rtl_single (FILE *, const_rtx);
2499e4b17023SJohn Marino extern void print_inline_rtx (FILE *, const_rtx, int);
2500e4b17023SJohn Marino 
2501e4b17023SJohn Marino /* In function.c */
2502e4b17023SJohn Marino extern void reposition_prologue_and_epilogue_notes (void);
2503e4b17023SJohn Marino extern int prologue_epilogue_contains (const_rtx);
2504e4b17023SJohn Marino extern int sibcall_epilogue_contains (const_rtx);
2505e4b17023SJohn Marino extern void mark_temp_addr_taken (rtx);
2506e4b17023SJohn Marino extern void update_temp_slot_address (rtx, rtx);
2507e4b17023SJohn Marino extern void maybe_copy_prologue_epilogue_insn (rtx, rtx);
2508e4b17023SJohn Marino extern void set_return_jump_label (rtx);
2509e4b17023SJohn Marino 
2510e4b17023SJohn Marino /* In stmt.c */
2511e4b17023SJohn Marino extern void expand_null_return (void);
2512e4b17023SJohn Marino extern void expand_naked_return (void);
2513e4b17023SJohn Marino extern void emit_jump (rtx);
2514e4b17023SJohn Marino 
2515e4b17023SJohn Marino /* In expr.c */
2516e4b17023SJohn Marino extern rtx move_by_pieces (rtx, rtx, unsigned HOST_WIDE_INT,
2517e4b17023SJohn Marino 			   unsigned int, int);
2518e4b17023SJohn Marino extern HOST_WIDE_INT find_args_size_adjust (rtx);
2519e4b17023SJohn Marino extern int fixup_args_size_notes (rtx, rtx, int);
2520e4b17023SJohn Marino 
2521e4b17023SJohn Marino /* In cfgrtl.c */
2522e4b17023SJohn Marino extern void print_rtl_with_bb (FILE *, const_rtx);
2523e4b17023SJohn Marino 
2524e4b17023SJohn Marino /* In cfg.c.  */
2525e4b17023SJohn Marino extern void dump_reg_info (FILE *);
2526e4b17023SJohn Marino extern void dump_flow_info (FILE *, int);
2527e4b17023SJohn Marino 
2528e4b17023SJohn Marino /* In expmed.c */
2529e4b17023SJohn Marino extern void init_expmed (void);
2530e4b17023SJohn Marino extern void expand_inc (rtx, rtx);
2531e4b17023SJohn Marino extern void expand_dec (rtx, rtx);
2532e4b17023SJohn Marino 
2533e4b17023SJohn Marino /* In gcse.c */
2534e4b17023SJohn Marino extern bool can_copy_p (enum machine_mode);
2535e4b17023SJohn Marino extern bool can_assign_to_reg_without_clobbers_p (rtx);
2536e4b17023SJohn Marino extern rtx fis_get_condition (rtx);
2537e4b17023SJohn Marino 
2538e4b17023SJohn Marino /* In ira.c */
2539e4b17023SJohn Marino #ifdef HARD_CONST
2540e4b17023SJohn Marino extern HARD_REG_SET eliminable_regset;
2541e4b17023SJohn Marino #endif
2542e4b17023SJohn Marino extern void mark_elimination (int, int);
2543e4b17023SJohn Marino 
2544e4b17023SJohn Marino /* In reginfo.c */
2545e4b17023SJohn Marino extern int reg_classes_intersect_p (reg_class_t, reg_class_t);
2546e4b17023SJohn Marino extern int reg_class_subset_p (reg_class_t, reg_class_t);
2547e4b17023SJohn Marino extern void globalize_reg (tree, int);
2548e4b17023SJohn Marino extern void init_reg_modes_target (void);
2549e4b17023SJohn Marino extern void init_regs (void);
2550e4b17023SJohn Marino extern void reinit_regs (void);
2551e4b17023SJohn Marino extern void init_fake_stack_mems (void);
2552e4b17023SJohn Marino extern void save_register_info (void);
2553e4b17023SJohn Marino extern void init_reg_sets (void);
2554e4b17023SJohn Marino extern void regclass (rtx, int);
2555e4b17023SJohn Marino extern void reg_scan (rtx, unsigned int);
2556e4b17023SJohn Marino extern void fix_register (const char *, int, int);
2557e4b17023SJohn Marino extern bool invalid_mode_change_p (unsigned int, enum reg_class);
2558e4b17023SJohn Marino 
2559e4b17023SJohn Marino /* In reorg.c */
2560e4b17023SJohn Marino extern void dbr_schedule (rtx);
2561e4b17023SJohn Marino 
2562e4b17023SJohn Marino /* In reload1.c */
2563e4b17023SJohn Marino extern int function_invariant_p (const_rtx);
2564e4b17023SJohn Marino 
2565e4b17023SJohn Marino /* In calls.c */
2566e4b17023SJohn Marino enum libcall_type
2567e4b17023SJohn Marino {
2568e4b17023SJohn Marino   LCT_NORMAL = 0,
2569e4b17023SJohn Marino   LCT_CONST = 1,
2570e4b17023SJohn Marino   LCT_PURE = 2,
2571e4b17023SJohn Marino   LCT_NORETURN = 3,
2572e4b17023SJohn Marino   LCT_THROW = 4,
2573e4b17023SJohn Marino   LCT_RETURNS_TWICE = 5
2574e4b17023SJohn Marino };
2575e4b17023SJohn Marino 
2576e4b17023SJohn Marino extern void emit_library_call (rtx, enum libcall_type, enum machine_mode, int,
2577e4b17023SJohn Marino 			       ...);
2578e4b17023SJohn Marino extern rtx emit_library_call_value (rtx, rtx, enum libcall_type,
2579e4b17023SJohn Marino 				    enum machine_mode, int, ...);
2580e4b17023SJohn Marino 
2581e4b17023SJohn Marino /* In varasm.c */
2582e4b17023SJohn Marino extern void init_varasm_once (void);
2583e4b17023SJohn Marino 
2584e4b17023SJohn Marino extern rtx make_debug_expr_from_rtl (const_rtx);
2585e4b17023SJohn Marino 
2586e4b17023SJohn Marino /* In read-rtl.c */
2587e4b17023SJohn Marino extern bool read_rtx (const char *, rtx *);
2588e4b17023SJohn Marino 
2589e4b17023SJohn Marino /* In alias.c */
2590e4b17023SJohn Marino extern rtx canon_rtx (rtx);
2591e4b17023SJohn Marino extern int true_dependence (const_rtx, enum machine_mode, const_rtx);
2592e4b17023SJohn Marino extern rtx get_addr (rtx);
2593e4b17023SJohn Marino extern int canon_true_dependence (const_rtx, enum machine_mode, rtx,
2594e4b17023SJohn Marino 				  const_rtx, rtx);
2595e4b17023SJohn Marino extern int read_dependence (const_rtx, const_rtx);
2596e4b17023SJohn Marino extern int anti_dependence (const_rtx, const_rtx);
2597e4b17023SJohn Marino extern int output_dependence (const_rtx, const_rtx);
2598e4b17023SJohn Marino extern int may_alias_p (const_rtx, const_rtx);
2599e4b17023SJohn Marino extern void init_alias_target (void);
2600e4b17023SJohn Marino extern void init_alias_analysis (void);
2601e4b17023SJohn Marino extern void end_alias_analysis (void);
2602e4b17023SJohn Marino extern void vt_equate_reg_base_value (const_rtx, const_rtx);
2603e4b17023SJohn Marino extern bool memory_modified_in_insn_p (const_rtx, const_rtx);
2604e4b17023SJohn Marino extern rtx find_base_term (rtx);
2605e4b17023SJohn Marino extern rtx gen_hard_reg_clobber (enum machine_mode, unsigned int);
2606e4b17023SJohn Marino extern rtx get_reg_known_value (unsigned int);
2607e4b17023SJohn Marino extern bool get_reg_known_equiv_p (unsigned int);
2608e4b17023SJohn Marino extern rtx get_reg_base_value (unsigned int);
2609e4b17023SJohn Marino 
2610e4b17023SJohn Marino #ifdef STACK_REGS
2611e4b17023SJohn Marino extern int stack_regs_mentioned (const_rtx insn);
2612e4b17023SJohn Marino #endif
2613e4b17023SJohn Marino 
2614e4b17023SJohn Marino /* In toplev.c */
2615e4b17023SJohn Marino extern GTY(()) rtx stack_limit_rtx;
2616e4b17023SJohn Marino 
2617e4b17023SJohn Marino /* In predict.c */
2618e4b17023SJohn Marino extern void invert_br_probabilities (rtx);
2619e4b17023SJohn Marino extern bool expensive_function_p (int);
2620e4b17023SJohn Marino 
2621e4b17023SJohn Marino /* In var-tracking.c */
2622e4b17023SJohn Marino extern unsigned int variable_tracking_main (void);
2623e4b17023SJohn Marino 
2624e4b17023SJohn Marino /* In stor-layout.c.  */
2625e4b17023SJohn Marino extern void get_mode_bounds (enum machine_mode, int, enum machine_mode,
2626e4b17023SJohn Marino 			     rtx *, rtx *);
2627e4b17023SJohn Marino 
2628e4b17023SJohn Marino /* In loop-unswitch.c  */
2629e4b17023SJohn Marino extern rtx reversed_condition (rtx);
2630e4b17023SJohn Marino extern rtx compare_and_jump_seq (rtx, rtx, enum rtx_code, rtx, int, rtx);
2631e4b17023SJohn Marino 
2632e4b17023SJohn Marino /* In loop-iv.c  */
2633e4b17023SJohn Marino extern rtx canon_condition (rtx);
2634e4b17023SJohn Marino extern void simplify_using_condition (rtx, rtx *, struct bitmap_head_def *);
2635e4b17023SJohn Marino 
2636e4b17023SJohn Marino /* In final.c  */
2637e4b17023SJohn Marino extern unsigned int compute_alignments (void);
2638e4b17023SJohn Marino extern int asm_str_count (const char *templ);
2639e4b17023SJohn Marino 
2640e4b17023SJohn Marino struct rtl_hooks
2641e4b17023SJohn Marino {
2642e4b17023SJohn Marino   rtx (*gen_lowpart) (enum machine_mode, rtx);
2643e4b17023SJohn Marino   rtx (*gen_lowpart_no_emit) (enum machine_mode, rtx);
2644e4b17023SJohn Marino   rtx (*reg_nonzero_bits) (const_rtx, enum machine_mode, const_rtx, enum machine_mode,
2645e4b17023SJohn Marino 			   unsigned HOST_WIDE_INT, unsigned HOST_WIDE_INT *);
2646e4b17023SJohn Marino   rtx (*reg_num_sign_bit_copies) (const_rtx, enum machine_mode, const_rtx, enum machine_mode,
2647e4b17023SJohn Marino 				  unsigned int, unsigned int *);
2648e4b17023SJohn Marino   bool (*reg_truncated_to_mode) (enum machine_mode, const_rtx);
2649e4b17023SJohn Marino 
2650e4b17023SJohn Marino   /* Whenever you add entries here, make sure you adjust rtlhooks-def.h.  */
2651e4b17023SJohn Marino };
2652e4b17023SJohn Marino 
2653e4b17023SJohn Marino /* Each pass can provide its own.  */
2654e4b17023SJohn Marino extern struct rtl_hooks rtl_hooks;
2655e4b17023SJohn Marino 
2656e4b17023SJohn Marino /* ... but then it has to restore these.  */
2657e4b17023SJohn Marino extern const struct rtl_hooks general_rtl_hooks;
2658e4b17023SJohn Marino 
2659e4b17023SJohn Marino /* Keep this for the nonce.  */
2660e4b17023SJohn Marino #define gen_lowpart rtl_hooks.gen_lowpart
2661e4b17023SJohn Marino 
2662e4b17023SJohn Marino extern void insn_locators_alloc (void);
2663e4b17023SJohn Marino extern void insn_locators_free (void);
2664e4b17023SJohn Marino extern void insn_locators_finalize (void);
2665e4b17023SJohn Marino extern void set_curr_insn_source_location (location_t);
2666e4b17023SJohn Marino extern location_t get_curr_insn_source_location (void);
2667e4b17023SJohn Marino extern void set_curr_insn_block (tree);
2668e4b17023SJohn Marino extern tree get_curr_insn_block (void);
2669e4b17023SJohn Marino extern int curr_insn_locator (void);
2670e4b17023SJohn Marino extern bool optimize_insn_for_size_p (void);
2671e4b17023SJohn Marino extern bool optimize_insn_for_speed_p (void);
2672e4b17023SJohn Marino 
2673e4b17023SJohn Marino /* rtl-error.c */
2674e4b17023SJohn Marino extern void _fatal_insn_not_found (const_rtx, const char *, int, const char *)
2675e4b17023SJohn Marino      ATTRIBUTE_NORETURN;
2676e4b17023SJohn Marino extern void _fatal_insn (const char *, const_rtx, const char *, int, const char *)
2677e4b17023SJohn Marino      ATTRIBUTE_NORETURN;
2678e4b17023SJohn Marino 
2679e4b17023SJohn Marino #define fatal_insn(msgid, insn) \
2680e4b17023SJohn Marino 	_fatal_insn (msgid, insn, __FILE__, __LINE__, __FUNCTION__)
2681e4b17023SJohn Marino #define fatal_insn_not_found(insn) \
2682e4b17023SJohn Marino 	_fatal_insn_not_found (insn, __FILE__, __LINE__, __FUNCTION__)
2683e4b17023SJohn Marino 
2684*95d28233SJohn Marino /* reginfo.c */
2685*95d28233SJohn Marino extern tree GTY(()) global_regs_decl[FIRST_PSEUDO_REGISTER];
2686e4b17023SJohn Marino 
2687e4b17023SJohn Marino 
2688e4b17023SJohn Marino #endif /* ! GCC_RTL_H */
2689