]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/rtl.h
Use rtx_expr_list in various places
[thirdparty/gcc.git] / gcc / rtl.h
CommitLineData
bccafa26 1/* Register Transfer Language (RTL) definitions for GCC
3aea1f79 2 Copyright (C) 1987-2014 Free Software Foundation, Inc.
759bebca 3
f12b58b3 4This file is part of GCC.
759bebca 5
f12b58b3 6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
8c4c00c1 8Software Foundation; either version 3, or (at your option) any later
f12b58b3 9version.
759bebca 10
f12b58b3 11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
759bebca 15
16You should have received a copy of the GNU General Public License
8c4c00c1 17along with GCC; see the file COPYING3. If not see
18<http://www.gnu.org/licenses/>. */
759bebca 19
2a281353 20#ifndef GCC_RTL_H
21#define GCC_RTL_H
605f66ec 22
e913b5cd 23#include <utility>
fdef3332 24#include "statistics.h"
759bebca 25#include "machmode.h"
0a3b3d88 26#include "input.h"
e8aaae4e 27#include "real.h"
f2d0e9f1 28#include "vec.h"
e397ad8e 29#include "fixed-value.h"
32c2fdea 30#include "alias.h"
09279218 31#include "hashtab.h"
e913b5cd 32#include "wide-int.h"
4a020a8c 33#include "flags.h"
a0416db5 34#include "is-a.h"
759bebca 35
c6259b83 36/* Value used by some passes to "recognize" noop moves as valid
a7dce381 37 instructions. */
1805c35c 38#define NOOP_MOVE_INSN_CODE INT_MAX
39
759bebca 40/* Register Transfer Language EXPRESSIONS CODES */
41
42#define RTX_CODE enum rtx_code
43enum rtx_code {
44
45#define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) ENUM ,
46#include "rtl.def" /* rtl expressions are documented here */
47#undef DEF_RTL_EXPR
48
4bbea254 49 LAST_AND_UNUSED_RTX_CODE}; /* A convenient way to get a value for
759bebca 50 NUM_RTX_CODE.
4bbea254 51 Assumes default enum value assignment. */
759bebca 52
ee65118b 53/* The cast here, saves many elsewhere. */
47c251e5 54#define NUM_RTX_CODE ((int) LAST_AND_UNUSED_RTX_CODE)
ee65118b 55
56/* Similar, but since generator files get more entries... */
57#ifdef GENERATOR_FILE
58# define NON_GENERATOR_NUM_RTX_CODE ((int) MATCH_OPERAND)
59#endif
759bebca 60
6720e96c 61/* Register Transfer Language EXPRESSIONS CODE CLASSES */
62
63enum rtx_class {
64 /* We check bit 0-1 of some rtx class codes in the predicates below. */
65
66 /* Bit 0 = comparison if 0, arithmetic is 1
67 Bit 1 = 1 if commutative. */
68 RTX_COMPARE, /* 0 */
69 RTX_COMM_COMPARE,
70 RTX_BIN_ARITH,
71 RTX_COMM_ARITH,
72
73 /* Must follow the four preceding values. */
74 RTX_UNARY, /* 4 */
75
76 RTX_EXTRA,
77 RTX_MATCH,
78 RTX_INSN,
79
80 /* Bit 0 = 1 if constant. */
81 RTX_OBJ, /* 8 */
82 RTX_CONST_OBJ,
83
84 RTX_TERNARY,
85 RTX_BITFIELD_OPS,
86 RTX_AUTOINC
87};
88
89#define RTX_OBJ_MASK (~1)
90#define RTX_OBJ_RESULT (RTX_OBJ & RTX_OBJ_MASK)
91#define RTX_COMPARE_MASK (~1)
92#define RTX_COMPARE_RESULT (RTX_COMPARE & RTX_COMPARE_MASK)
93#define RTX_ARITHMETIC_MASK (~1)
94#define RTX_ARITHMETIC_RESULT (RTX_COMM_ARITH & RTX_ARITHMETIC_MASK)
95#define RTX_BINARY_MASK (~3)
96#define RTX_BINARY_RESULT (RTX_COMPARE & RTX_BINARY_MASK)
97#define RTX_COMMUTATIVE_MASK (~2)
98#define RTX_COMMUTATIVE_RESULT (RTX_COMM_COMPARE & RTX_COMMUTATIVE_MASK)
99#define RTX_NON_COMMUTATIVE_RESULT (RTX_COMPARE & RTX_COMMUTATIVE_MASK)
6720e96c 100
1af5f160 101extern const unsigned char rtx_length[NUM_RTX_CODE];
a92771b8 102#define GET_RTX_LENGTH(CODE) (rtx_length[(int) (CODE)])
759bebca 103
1af5f160 104extern const char * const rtx_name[NUM_RTX_CODE];
a92771b8 105#define GET_RTX_NAME(CODE) (rtx_name[(int) (CODE)])
759bebca 106
1af5f160 107extern const char * const rtx_format[NUM_RTX_CODE];
a92771b8 108#define GET_RTX_FORMAT(CODE) (rtx_format[(int) (CODE)])
759bebca 109
6720e96c 110extern const enum rtx_class rtx_class[NUM_RTX_CODE];
a92771b8 111#define GET_RTX_CLASS(CODE) (rtx_class[(int) (CODE)])
c849df63 112
5cda2bd0 113/* True if CODE is part of the insn chain (i.e. has INSN_UID, PREV_INSN
114 and NEXT_INSN fields). */
115#define INSN_CHAIN_CODE_P(CODE) IN_RANGE (CODE, DEBUG_INSN, NOTE)
116
f2d0e9f1 117extern const unsigned char rtx_code_size[NUM_RTX_CODE];
c849df63 118extern const unsigned char rtx_next[NUM_RTX_CODE];
759bebca 119\f
9eaab178 120/* The flags and bitfields of an ADDR_DIFF_VEC. BASE is the base label
121 relative to which the offsets are calculated, as explained in rtl.def. */
b3e7c666 122struct addr_diff_vec_flags
9eaab178 123{
124 /* Set at the start of shorten_branches - ONLY WHEN OPTIMIZING - : */
125 unsigned min_align: 8;
126 /* Flags: */
127 unsigned base_after_vec: 1; /* BASE is after the ADDR_DIFF_VEC. */
c6259b83 128 unsigned min_after_vec: 1; /* minimum address target label is
129 after the ADDR_DIFF_VEC. */
130 unsigned max_after_vec: 1; /* maximum address target label is
131 after the ADDR_DIFF_VEC. */
132 unsigned min_after_base: 1; /* minimum address target label is
133 after BASE. */
134 unsigned max_after_base: 1; /* maximum address target label is
135 after BASE. */
9eaab178 136 /* Set by the actual branch shortening process - ONLY WHEN OPTIMIZING - : */
137 unsigned offset_unsigned: 1; /* offsets have to be treated as unsigned. */
138 unsigned : 2;
139 unsigned scale : 8;
b3e7c666 140};
9eaab178 141
c6259b83 142/* Structure used to describe the attributes of a MEM. These are hashed
143 so MEMs that the same attributes share a data structure. This means
6d58bcba 144 they cannot be modified in place. */
b3e7c666 145struct GTY(()) mem_attrs
c6259b83 146{
6d58bcba 147 /* The expression that the MEM accesses, or null if not known.
148 This expression might be larger than the memory reference itself.
149 (In other words, the MEM might access only part of the object.) */
150 tree expr;
151
152 /* The offset of the memory reference from the start of EXPR.
153 Only valid if OFFSET_KNOWN_P. */
154 HOST_WIDE_INT offset;
155
156 /* The size of the memory reference in bytes. Only valid if
157 SIZE_KNOWN_P. */
158 HOST_WIDE_INT size;
159
160 /* The alias set of the memory reference. */
161 alias_set_type alias;
162
163 /* The alignment of the reference in bits. Always a multiple of
164 BITS_PER_UNIT. Note that EXPR may have a stricter alignment
165 than the memory reference itself. */
166 unsigned int align;
167
168 /* The address space that the memory reference uses. */
169 unsigned char addrspace;
170
171 /* True if OFFSET is known. */
172 bool offset_known_p;
173
174 /* True if SIZE is known. */
175 bool size_known_p;
b3e7c666 176};
c6259b83 177
ca74b940 178/* Structure used to describe the attributes of a REG in similar way as
80c70e76 179 mem_attrs does for MEM above. Note that the OFFSET field is calculated
180 in the same way as for mem_attrs, rather than in the same way as a
181 SUBREG_BYTE. For example, if a big-endian target stores a byte
182 object in the low part of a 4-byte register, the OFFSET field
183 will be -3 rather than 0. */
ca74b940 184
b3e7c666 185struct GTY(()) reg_attrs {
ca74b940 186 tree decl; /* decl corresponding to REG. */
187 HOST_WIDE_INT offset; /* Offset from start of DECL. */
b3e7c666 188};
ca74b940 189
759bebca 190/* Common union for an element of an rtx. */
191
b3e7c666 192union rtunion
759bebca 193{
993d9e55 194 int rt_int;
195 unsigned int rt_uint;
196 const char *rt_str;
197 rtx rt_rtx;
198 rtvec rt_rtvec;
199 enum machine_mode rt_type;
9eaab178 200 addr_diff_vec_flags rt_addr_diff_vec_flags;
b3e7c666 201 struct cselib_val *rt_cselib;
993d9e55 202 tree rt_tree;
161dfa6e 203 basic_block rt_bb;
993d9e55 204 mem_attrs *rt_mem;
205 reg_attrs *rt_reg;
7c266bb1 206 struct constant_descriptor_rtx *rt_constant;
b3e7c666 207 struct dw_cfi_node *rt_cfi;
c849df63 208};
759bebca 209
f2d0e9f1 210/* This structure remembers the position of a SYMBOL_REF within an
211 object_block structure. A SYMBOL_REF only provides this information
6617cbc1 212 if SYMBOL_REF_HAS_BLOCK_INFO_P is true. */
fb1e4f4a 213struct GTY(()) block_symbol {
f2d0e9f1 214 /* The usual SYMBOL_REF fields. */
8854855c 215 rtunion GTY ((skip)) fld[2];
f2d0e9f1 216
217 /* The block that contains this object. */
218 struct object_block *block;
219
220 /* The offset of this object from the start of its block. It is negative
221 if the symbol has not yet been assigned an offset. */
222 HOST_WIDE_INT offset;
223};
224
f2d0e9f1 225/* Describes a group of objects that are to be placed together in such
226 a way that their relative positions are known. */
fb1e4f4a 227struct GTY(()) object_block {
f2d0e9f1 228 /* The section in which these objects should be placed. */
229 section *sect;
230
231 /* The alignment of the first object, measured in bits. */
232 unsigned int alignment;
233
234 /* The total size of the objects, measured in bytes. */
235 HOST_WIDE_INT size;
236
237 /* The SYMBOL_REFs for each object. The vector is sorted in
238 order of increasing offset and the following conditions will
239 hold for each element X:
240
6617cbc1 241 SYMBOL_REF_HAS_BLOCK_INFO_P (X)
f2d0e9f1 242 !SYMBOL_REF_ANCHOR_P (X)
243 SYMBOL_REF_BLOCK (X) == [address of this structure]
244 SYMBOL_REF_BLOCK_OFFSET (X) >= 0. */
f1f41a6c 245 vec<rtx, va_gc> *objects;
f2d0e9f1 246
247 /* All the anchor SYMBOL_REFs used to address these objects, sorted
248 in order of increasing offset, and then increasing TLS model.
249 The following conditions will hold for each element X in this vector:
250
6617cbc1 251 SYMBOL_REF_HAS_BLOCK_INFO_P (X)
f2d0e9f1 252 SYMBOL_REF_ANCHOR_P (X)
253 SYMBOL_REF_BLOCK (X) == [address of this structure]
254 SYMBOL_REF_BLOCK_OFFSET (X) >= 0. */
f1f41a6c 255 vec<rtx, va_gc> *anchors;
f2d0e9f1 256};
257
e913b5cd 258struct GTY((variable_size)) hwivec_def {
e913b5cd 259 HOST_WIDE_INT elem[1];
260};
261
05c25ee6 262/* Number of elements of the HWIVEC if RTX is a CONST_WIDE_INT. */
263#define CWI_GET_NUM_ELEM(RTX) \
264 ((int)RTL_FLAG_CHECK1("CWI_GET_NUM_ELEM", (RTX), CONST_WIDE_INT)->u2.num_elem)
265#define CWI_PUT_NUM_ELEM(RTX, NUM) \
266 (RTL_FLAG_CHECK1("CWI_PUT_NUM_ELEM", (RTX), CONST_WIDE_INT)->u2.num_elem = (NUM))
e913b5cd 267
759bebca 268/* RTL expression ("rtx"). */
269
a0416db5 270/* The GTY "desc" and "tag" options below are a kludge: we need a desc
271 field for for gengtype to recognize that inheritance is occurring,
272 so that all subclasses are redirected to the traversal hook for the
273 base class.
274 However, all of the fields are in the base class, and special-casing
275 is at work. Hence we use desc and tag of 0, generating a switch
276 statement of the form:
277 switch (0)
278 {
279 case 0: // all the work happens here
280 }
281 in order to work with the existing special-casing in gengtype. */
282
283struct GTY((desc("0"), tag("0"),
284 chain_next ("RTX_NEXT (&%h)"),
25a27413 285 chain_prev ("RTX_PREV (&%h)"))) rtx_def {
759bebca 286 /* The kind of expression this is. */
488c4206 287 ENUM_BITFIELD(rtx_code) code: 16;
bfec6070 288
759bebca 289 /* The kind of value the expression has. */
488c4206 290 ENUM_BITFIELD(machine_mode) mode : 8;
291
e7f75e15 292 /* 1 in a MEM if we should keep the alias set for this mem unchanged
293 when we access a component.
8f869004 294 1 in a JUMP_INSN if it is a crossing jump.
e7f75e15 295 1 in a CALL_INSN if it is a sibling call.
a7ae1e59 296 1 in a SET that is for a return.
72fdb379 297 In a CODE_LABEL, part of the two-bit alternate entry field.
bb75e83f 298 1 in a CONCAT is VAL_EXPR_IS_COPIED in var-tracking.c.
ea99c7a1 299 1 in a VALUE is SP_BASED_VALUE_P in cselib.c.
bbc26dcc 300 1 in a SUBREG generated by LRA for reload insns. */
759bebca 301 unsigned int jump : 1;
1ed8ccdb 302 /* In a CODE_LABEL, part of the two-bit alternate entry field.
48e1416a 303 1 in a MEM if it cannot trap.
9c2a0c05 304 1 in a CALL_INSN logically equivalent to
305 ECF_LOOPING_CONST_OR_PURE and DECL_LOOPING_CONST_OR_PURE_P. */
759bebca 306 unsigned int call : 1;
e7f75e15 307 /* 1 in a REG, MEM, or CONCAT if the value is set at most once, anywhere.
088c4b7b 308 1 in a SUBREG used for SUBREG_PROMOTED_UNSIGNED_P.
759bebca 309 1 in a SYMBOL_REF if it addresses something in the per-function
310 constants pool.
48e1416a 311 1 in a CALL_INSN logically equivalent to ECF_CONST and TREE_READONLY.
9c2a0c05 312 1 in a NOTE, or EXPR_LIST for a const call.
72fdb379 313 1 in a JUMP_INSN of an annulling branch.
314 1 in a CONCAT is VAL_EXPR_IS_CLOBBERED in var-tracking.c.
ae72d5b2 315 1 in a preserved VALUE is PRESERVED_VALUE_P in cselib.c.
316 1 in a clobber temporarily created for LRA. */
759bebca 317 unsigned int unchanging : 1;
e7f75e15 318 /* 1 in a MEM or ASM_OPERANDS expression if the memory reference is volatile.
319 1 in an INSN, CALL_INSN, JUMP_INSN, CODE_LABEL, BARRIER, or NOTE
320 if it has been deleted.
321 1 in a REG expression if corresponds to a variable declared by the user,
759bebca 322 0 for an internally generated temporary.
088c4b7b 323 1 in a SUBREG used for SUBREG_PROMOTED_UNSIGNED_P.
19d2fe05 324 1 in a LABEL_REF, REG_LABEL_TARGET or REG_LABEL_OPERAND note for a
325 non-local label.
6540132c 326 In a SYMBOL_REF, this flag is used for machine-specific purposes.
327 In a PREFETCH, this flag indicates that it should be considered a scheduling
72fdb379 328 barrier.
329 1 in a CONCAT is VAL_NEEDS_RESOLUTION in var-tracking.c. */
759bebca 330 unsigned int volatil : 1;
402f6a9e 331 /* 1 in a REG if the register is used only in exit code a loop.
f220c8f0 332 1 in a SUBREG expression if was generated from a variable with a
3e8eba79 333 promoted mode.
759bebca 334 1 in a CODE_LABEL if the label is used for nonlocal gotos
335 and must not be deleted even if its count is zero.
f372955c 336 1 in an INSN, JUMP_INSN or CALL_INSN if this insn must be scheduled
337 together with the preceding insn. Valid only within sched.
759bebca 338 1 in an INSN, JUMP_INSN, or CALL_INSN if insn is in a delay slot and
339 from the target of a branch. Valid from reorg until end of compilation;
402f6a9e 340 cleared before used.
341
342 The name of the field is historical. It used to be used in MEMs
343 to record whether the MEM accessed part of a structure. */
759bebca 344 unsigned int in_struct : 1;
e7f75e15 345 /* At the end of RTL generation, 1 if this rtx is used. This is used for
346 copying shared structure. See `unshare_all_rtl'.
f220c8f0 347 In a REG, this is not needed for that purpose, and used instead
759bebca 348 in `leaf_renumber_regs_insn'.
e7f75e15 349 1 in a SYMBOL_REF, means that emit_library_call
72fdb379 350 has used it as the function.
351 1 in a CONCAT is VAL_HOLDS_TRACK_EXPR in var-tracking.c.
352 1 in a VALUE or DEBUG_EXPR is VALUE_RECURSED_INTO in var-tracking.c. */
759bebca 353 unsigned int used : 1;
fa19b467 354 /* 1 in an INSN or a SET if this rtx is related to the call frame,
6a0934dd 355 either changing how we compute the frame address or saving and
f220c8f0 356 restoring registers in the prologue and epilogue.
8d350e69 357 1 in a REG or MEM if it is a pointer.
abf74c5b 358 1 in a SYMBOL_REF if it addresses something in the per-function
72fdb379 359 constant string pool.
360 1 in a VALUE is VALUE_CHANGED in var-tracking.c. */
df78b73b 361 unsigned frame_related : 1;
4ee9c684 362 /* 1 in a REG or PARALLEL that is the current function's return value.
48e1416a 363 1 in a SYMBOL_REF for a weak symbol.
72fdb379 364 1 in a CALL_INSN logically equivalent to ECF_PURE and DECL_PURE_P.
365 1 in a CONCAT is VAL_EXPR_HAS_REVERSE in var-tracking.c.
366 1 in a VALUE or DEBUG_EXPR is NO_LOC_P in var-tracking.c. */
4ee9c684 367 unsigned return_val : 1;
05513b45 368
05c25ee6 369 union {
c4050ce7 370 /* The final union field is aligned to 64 bits on LP64 hosts,
b3fba3cd 371 giving a 32-bit gap after the fields above. We optimize the
c4050ce7 372 layout for that case and use the gap for extra code-specific
373 information. */
05c25ee6 374
4db4d2a2 375 /* The ORIGINAL_REGNO of a REG. */
376 unsigned int original_regno;
377
5cda2bd0 378 /* The INSN_UID of an RTX_INSN-class code. */
379 int insn_uid;
380
8854855c 381 /* The SYMBOL_REF_FLAGS of a SYMBOL_REF. */
382 unsigned int symbol_ref_flags;
383
e1398578 384 /* The PAT_VAR_LOCATION_STATUS of a VAR_LOCATION. */
385 enum var_init_status var_location_status;
386
3a54beaf 387 /* In a CONST_WIDE_INT (aka hwivec_def), this is the number of
388 HOST_WIDE_INTs in the hwivec_def. */
b4d2ccf4 389 unsigned int num_elem;
390 } GTY ((skip)) u2;
05c25ee6 391
759bebca 392 /* The first element of the operands of this rtx.
393 The number of operands and their types are controlled
394 by the `code' field, according to rtl.def. */
bf6b5685 395 union u {
396 rtunion fld[1];
397 HOST_WIDE_INT hwint[1];
f2d0e9f1 398 struct block_symbol block_sym;
e8aaae4e 399 struct real_value rv;
e397ad8e 400 struct fixed_value fv;
e913b5cd 401 struct hwivec_def hwiv;
bf6b5685 402 } GTY ((special ("rtx_def"), desc ("GET_CODE (&%0)"))) u;
6a3e3d6d 403};
759bebca 404
ede4900a 405/* A node for constructing singly-linked lists of rtx. */
406
407class GTY(()) rtx_expr_list : public rtx_def
408{
409 /* No extra fields, but adds invariant: (GET_CODE (X) == EXPR_LIST). */
410
411public:
412 /* Get next in list. */
413 rtx_expr_list *next () const;
414
415 /* Get at the underlying rtx. */
416 rtx element () const;
417};
418
419template <>
420template <>
421inline bool
422is_a_helper <rtx_expr_list *>::test (rtx rt)
423{
424 return rt->code == EXPR_LIST;
425}
426
13be9dc6 427class GTY(()) rtx_insn_list : public rtx_def
428{
429 /* No extra fields, but adds invariant: (GET_CODE (X) == INSN_LIST).
430
431 This is an instance of:
432
433 DEF_RTL_EXPR(INSN_LIST, "insn_list", "ue", RTX_EXTRA)
434
435 i.e. a node for constructing singly-linked lists of rtx_insn *, where
436 the list is "external" to the insn (as opposed to the doubly-linked
437 list embedded within rtx_insn itself). */
438
439public:
440 /* Get next in list. */
441 rtx_insn_list *next () const;
442
443 /* Get at the underlying instruction. */
444 rtx_insn *insn () const;
445
446};
447
448template <>
449template <>
450inline bool
451is_a_helper <rtx_insn_list *>::test (rtx rt)
452{
453 return rt->code == INSN_LIST;
454}
455
4aa21596 456/* A node with invariant GET_CODE (X) == SEQUENCE i.e. a vector of rtx,
457 typically (but not always) of rtx_insn *, used in the late passes. */
458
459class GTY(()) rtx_sequence : public rtx_def
460{
461 /* No extra fields, but adds invariant: (GET_CODE (X) == SEQUENCE). */
462
463public:
464 /* Get number of elements in sequence. */
465 int len () const;
466
467 /* Get i-th element of the sequence. */
468 rtx element (int index) const;
469
470 /* Get i-th element of the sequence, with a checked cast to
471 rtx_insn *. */
472 rtx_insn *insn (int index) const;
473};
474
475template <>
476template <>
477inline bool
478is_a_helper <rtx_sequence *>::test (rtx rt)
479{
480 return rt->code == SEQUENCE;
481}
482
483template <>
484template <>
485inline bool
486is_a_helper <const rtx_sequence *>::test (const_rtx rt)
487{
488 return rt->code == SEQUENCE;
489}
490
a0416db5 491class GTY(()) rtx_insn : public rtx_def
492{
493 /* No extra fields, but adds the invariant:
494
495 (INSN_P (X)
496 || NOTE_P (X)
497 || JUMP_TABLE_DATA_P (X)
498 || BARRIER_P (X)
499 || LABEL_P (X))
500
501 i.e. that we must be able to use the following:
502 INSN_UID ()
503 NEXT_INSN ()
504 PREV_INSN ()
505 i.e. we have an rtx that has an INSN_UID field and can be part of
506 a linked list of insns.
507 */
508};
509
e1d13ab6 510/* Subclasses of rtx_insn. */
511
512class GTY(()) rtx_debug_insn : public rtx_insn
513{
514 /* No extra fields, but adds the invariant:
515 DEBUG_INSN_P (X) aka (GET_CODE (X) == DEBUG_INSN)
516 i.e. an annotation for tracking variable assignments.
517
518 This is an instance of:
519 DEF_RTL_EXPR(DEBUG_INSN, "debug_insn", "uuBeiie", RTX_INSN)
520 from rtl.def. */
521};
522
523class GTY(()) rtx_nonjump_insn : public rtx_insn
524{
525 /* No extra fields, but adds the invariant:
526 NONJUMP_INSN_P (X) aka (GET_CODE (X) == INSN)
527 i.e an instruction that cannot jump.
528
529 This is an instance of:
530 DEF_RTL_EXPR(INSN, "insn", "uuBeiie", RTX_INSN)
531 from rtl.def. */
532};
533
534class GTY(()) rtx_jump_insn : public rtx_insn
535{
536 /* No extra fields, but adds the invariant:
537 JUMP_P (X) aka (GET_CODE (X) == JUMP_INSN)
538 i.e. an instruction that can possibly jump.
539
540 This is an instance of:
541 DEF_RTL_EXPR(JUMP_INSN, "jump_insn", "uuBeiie0", RTX_INSN)
542 from rtl.def. */
543};
544
545class GTY(()) rtx_call_insn : public rtx_insn
546{
547 /* No extra fields, but adds the invariant:
548 CALL_P (X) aka (GET_CODE (X) == CALL_INSN)
549 i.e. an instruction that can possibly call a subroutine
550 but which will not change which instruction comes next
551 in the current function.
552
553 This is an instance of:
554 DEF_RTL_EXPR(CALL_INSN, "call_insn", "uuBeiiee", RTX_INSN)
555 from rtl.def. */
556};
557
558class GTY(()) rtx_jump_table_data : public rtx_insn
559{
560 /* No extra fields, but adds the invariant:
561 JUMP_TABLE_DATA_P (X) aka (GET_CODE (INSN) == JUMP_TABLE_DATA)
562 i.e. a data for a jump table, considered an instruction for
563 historical reasons.
564
565 This is an instance of:
566 DEF_RTL_EXPR(JUMP_TABLE_DATA, "jump_table_data", "uuBe0000", RTX_INSN)
567 from rtl.def. */
b77639be 568
569public:
570
571 /* This can be either:
572
573 (a) a table of absolute jumps, in which case PATTERN (this) is an
574 ADDR_VEC with arg 0 a vector of labels, or
575
576 (b) a table of relative jumps (e.g. for -fPIC), in which case
577 PATTERN (this) is an ADDR_DIFF_VEC, with arg 0 a LABEL_REF and
578 arg 1 the vector of labels.
579
580 This method gets the underlying vec. */
581
582 inline rtvec get_labels () const;
e1d13ab6 583};
584
585class GTY(()) rtx_barrier : public rtx_insn
586{
587 /* No extra fields, but adds the invariant:
588 BARRIER_P (X) aka (GET_CODE (X) == BARRIER)
589 i.e. a marker that indicates that control will not flow through.
590
591 This is an instance of:
592 DEF_RTL_EXPR(BARRIER, "barrier", "uu00000", RTX_EXTRA)
593 from rtl.def. */
594};
595
596class GTY(()) rtx_code_label : public rtx_insn
597{
598 /* No extra fields, but adds the invariant:
599 LABEL_P (X) aka (GET_CODE (X) == CODE_LABEL)
600 i.e. a label in the assembler.
601
602 This is an instance of:
603 DEF_RTL_EXPR(CODE_LABEL, "code_label", "uuB00is", RTX_EXTRA)
604 from rtl.def. */
605};
606
607class GTY(()) rtx_note : public rtx_insn
608{
609 /* No extra fields, but adds the invariant:
610 NOTE_P(X) aka (GET_CODE (X) == NOTE)
611 i.e. a note about the corresponding source code.
612
613 This is an instance of:
614 DEF_RTL_EXPR(NOTE, "note", "uuB0ni", RTX_EXTRA)
615 from rtl.def. */
616};
617
bf6b5685 618/* The size in bytes of an rtx header (code, mode and flags). */
619#define RTX_HDR_SIZE offsetof (struct rtx_def, u)
620
621/* The size in bytes of an rtx with code CODE. */
f2d0e9f1 622#define RTX_CODE_SIZE(CODE) rtx_code_size[CODE]
bf6b5685 623
759bebca 624#define NULL_RTX (rtx) 0
625
c849df63 626/* The "next" and "previous" RTX, relative to this one. */
627
628#define RTX_NEXT(X) (rtx_next[GET_CODE (X)] == 0 ? NULL \
629 : *(rtx *)(((char *)X) + rtx_next[GET_CODE (X)]))
630
631/* FIXME: the "NEXT_INSN (PREV_INSN (X)) == X" condition shouldn't be needed.
632 */
6d7dc5b9 633#define RTX_PREV(X) ((INSN_P (X) \
634 || NOTE_P (X) \
91f71fa3 635 || JUMP_TABLE_DATA_P (X) \
6d7dc5b9 636 || BARRIER_P (X) \
637 || LABEL_P (X)) \
c849df63 638 && PREV_INSN (X) != NULL \
639 && NEXT_INSN (PREV_INSN (X)) == X \
640 ? PREV_INSN (X) : NULL)
641
759bebca 642/* Define macros to access the `code' field of the rtx. */
643
0fd4500a 644#define GET_CODE(RTX) ((enum rtx_code) (RTX)->code)
2aea9e36 645#define PUT_CODE(RTX, CODE) ((RTX)->code = (CODE))
759bebca 646
0fd4500a 647#define GET_MODE(RTX) ((enum machine_mode) (RTX)->mode)
2aea9e36 648#define PUT_MODE(RTX, MODE) ((RTX)->mode = (MODE))
759bebca 649
759bebca 650/* RTL vector. These appear inside RTX's when there is a need
651 for a variable number of things. The principle use is inside
652 PARALLEL expressions. */
653
25a27413 654struct GTY(()) rtvec_def {
0dbd1c74 655 int num_elem; /* number of elements */
1f3233d1 656 rtx GTY ((length ("%h.num_elem"))) elem[1];
6a3e3d6d 657};
759bebca 658
3a54beaf 659#define NULL_RTVEC (rtvec) 0
660
759bebca 661#define GET_NUM_ELEM(RTVEC) ((RTVEC)->num_elem)
0dbd1c74 662#define PUT_NUM_ELEM(RTVEC, NUM) ((RTVEC)->num_elem = (NUM))
759bebca 663
e75781d3 664/* Predicate yielding nonzero iff X is an rtx for a register. */
759bebca 665#define REG_P(X) (GET_CODE (X) == REG)
666
e75781d3 667/* Predicate yielding nonzero iff X is an rtx for a memory location. */
668#define MEM_P(X) (GET_CODE (X) == MEM)
669
e913b5cd 670#if TARGET_SUPPORTS_WIDE_INT
671
672/* Match CONST_*s that can represent compile-time constant integers. */
673#define CASE_CONST_SCALAR_INT \
674 case CONST_INT: \
675 case CONST_WIDE_INT
676
ddb1be65 677/* Match CONST_*s for which pointer equality corresponds to value
e913b5cd 678 equality. */
679#define CASE_CONST_UNIQUE \
680 case CONST_INT: \
681 case CONST_WIDE_INT: \
682 case CONST_DOUBLE: \
683 case CONST_FIXED
684
685/* Match all CONST_* rtxes. */
686#define CASE_CONST_ANY \
687 case CONST_INT: \
688 case CONST_WIDE_INT: \
689 case CONST_DOUBLE: \
690 case CONST_FIXED: \
691 case CONST_VECTOR
692
693#else
694
0349edce 695/* Match CONST_*s that can represent compile-time constant integers. */
696#define CASE_CONST_SCALAR_INT \
697 case CONST_INT: \
698 case CONST_DOUBLE
699
ab2c1de8 700/* Match CONST_*s for which pointer equality corresponds to value
701 equality. */
0349edce 702#define CASE_CONST_UNIQUE \
703 case CONST_INT: \
704 case CONST_DOUBLE: \
705 case CONST_FIXED
706
707/* Match all CONST_* rtxes. */
708#define CASE_CONST_ANY \
709 case CONST_INT: \
710 case CONST_DOUBLE: \
711 case CONST_FIXED: \
712 case CONST_VECTOR
e913b5cd 713#endif
714
9ca2c29a 715/* Predicate yielding nonzero iff X is an rtx for a constant integer. */
97590808 716#define CONST_INT_P(X) (GET_CODE (X) == CONST_INT)
717
e913b5cd 718/* Predicate yielding nonzero iff X is an rtx for a constant integer. */
719#define CONST_WIDE_INT_P(X) (GET_CODE (X) == CONST_WIDE_INT)
720
fdbe20f6 721/* Predicate yielding nonzero iff X is an rtx for a constant fixed-point. */
722#define CONST_FIXED_P(X) (GET_CODE (X) == CONST_FIXED)
723
33274180 724/* Predicate yielding true iff X is an rtx for a double-int
725 or floating point constant. */
726#define CONST_DOUBLE_P(X) (GET_CODE (X) == CONST_DOUBLE)
727
78f1962f 728/* Predicate yielding true iff X is an rtx for a double-int. */
729#define CONST_DOUBLE_AS_INT_P(X) \
730 (GET_CODE (X) == CONST_DOUBLE && GET_MODE (X) == VOIDmode)
731
efa08fc2 732/* Predicate yielding true iff X is an rtx for a integer const. */
e913b5cd 733#if TARGET_SUPPORTS_WIDE_INT
734#define CONST_SCALAR_INT_P(X) \
735 (CONST_INT_P (X) || CONST_WIDE_INT_P (X))
736#else
efa08fc2 737#define CONST_SCALAR_INT_P(X) \
738 (CONST_INT_P (X) || CONST_DOUBLE_AS_INT_P (X))
e913b5cd 739#endif
efa08fc2 740
78f1962f 741/* Predicate yielding true iff X is an rtx for a double-int. */
742#define CONST_DOUBLE_AS_FLOAT_P(X) \
743 (GET_CODE (X) == CONST_DOUBLE && GET_MODE (X) != VOIDmode)
744
1deb248e 745/* Predicate yielding nonzero iff X is a label insn. */
746#define LABEL_P(X) (GET_CODE (X) == CODE_LABEL)
747
748/* Predicate yielding nonzero iff X is a jump insn. */
749#define JUMP_P(X) (GET_CODE (X) == JUMP_INSN)
750
e75781d3 751/* Predicate yielding nonzero iff X is a call insn. */
752#define CALL_P(X) (GET_CODE (X) == CALL_INSN)
753
754/* Predicate yielding nonzero iff X is an insn that cannot jump. */
755#define NONJUMP_INSN_P(X) (GET_CODE (X) == INSN)
756
9845d120 757/* Predicate yielding nonzero iff X is a debug note/insn. */
758#define DEBUG_INSN_P(X) (GET_CODE (X) == DEBUG_INSN)
759
760/* Predicate yielding nonzero iff X is an insn that is not a debug insn. */
761#define NONDEBUG_INSN_P(X) (INSN_P (X) && !DEBUG_INSN_P (X))
762
763/* Nonzero if DEBUG_INSN_P may possibly hold. */
4a020a8c 764#define MAY_HAVE_DEBUG_INSNS (flag_var_tracking_assignments)
9845d120 765
e75781d3 766/* Predicate yielding nonzero iff X is a real insn. */
767#define INSN_P(X) \
9845d120 768 (NONJUMP_INSN_P (X) || DEBUG_INSN_P (X) || JUMP_P (X) || CALL_P (X))
e75781d3 769
1deb248e 770/* Predicate yielding nonzero iff X is a note insn. */
771#define NOTE_P(X) (GET_CODE (X) == NOTE)
772
773/* Predicate yielding nonzero iff X is a barrier insn. */
774#define BARRIER_P(X) (GET_CODE (X) == BARRIER)
775
776/* Predicate yielding nonzero iff X is a data for a jump table. */
91f71fa3 777#define JUMP_TABLE_DATA_P(INSN) (GET_CODE (INSN) == JUMP_TABLE_DATA)
1deb248e 778
a0416db5 779template <>
780template <>
781inline bool
782is_a_helper <rtx_insn *>::test (rtx rt)
783{
784 return (INSN_P (rt)
785 || NOTE_P (rt)
786 || JUMP_TABLE_DATA_P (rt)
787 || BARRIER_P (rt)
788 || LABEL_P (rt));
789}
790
791template <>
792template <>
793inline bool
794is_a_helper <const rtx_insn *>::test (const_rtx rt)
795{
796 return (INSN_P (rt)
797 || NOTE_P (rt)
798 || JUMP_TABLE_DATA_P (rt)
799 || BARRIER_P (rt)
800 || LABEL_P (rt));
801}
802
e1d13ab6 803template <>
804template <>
805inline bool
806is_a_helper <rtx_debug_insn *>::test (rtx rt)
807{
808 return DEBUG_INSN_P (rt);
809}
810
811template <>
812template <>
813inline bool
814is_a_helper <rtx_nonjump_insn *>::test (rtx rt)
815{
816 return NONJUMP_INSN_P (rt);
817}
818
819template <>
820template <>
821inline bool
822is_a_helper <rtx_jump_insn *>::test (rtx rt)
823{
824 return JUMP_P (rt);
825}
826
827template <>
828template <>
829inline bool
830is_a_helper <rtx_call_insn *>::test (rtx rt)
831{
832 return CALL_P (rt);
833}
834
ec22da62 835template <>
836template <>
837inline bool
838is_a_helper <rtx_call_insn *>::test (rtx_insn *insn)
839{
840 return CALL_P (insn);
841}
842
e1d13ab6 843template <>
844template <>
845inline bool
846is_a_helper <rtx_jump_table_data *>::test (rtx rt)
847{
848 return JUMP_TABLE_DATA_P (rt);
849}
850
851template <>
852template <>
853inline bool
854is_a_helper <rtx_jump_table_data *>::test (rtx_insn *insn)
855{
856 return JUMP_TABLE_DATA_P (insn);
857}
858
859template <>
860template <>
861inline bool
862is_a_helper <rtx_barrier *>::test (rtx rt)
863{
864 return BARRIER_P (rt);
865}
866
867template <>
868template <>
869inline bool
870is_a_helper <rtx_code_label *>::test (rtx rt)
871{
872 return LABEL_P (rt);
873}
874
875template <>
876template <>
877inline bool
878is_a_helper <rtx_code_label *>::test (rtx_insn *insn)
879{
880 return LABEL_P (insn);
881}
882
883template <>
884template <>
885inline bool
886is_a_helper <rtx_note *>::test (rtx rt)
887{
888 return NOTE_P (rt);
889}
890
891template <>
892template <>
893inline bool
894is_a_helper <rtx_note *>::test (rtx_insn *insn)
895{
896 return NOTE_P (insn);
897}
898
9cb2517e 899/* Predicate yielding nonzero iff X is a return or simple_return. */
900#define ANY_RETURN_P(X) \
901 (GET_CODE (X) == RETURN || GET_CODE (X) == SIMPLE_RETURN)
4115ac36 902
6720e96c 903/* 1 if X is a unary operator. */
904
905#define UNARY_P(X) \
906 (GET_RTX_CLASS (GET_CODE (X)) == RTX_UNARY)
907
908/* 1 if X is a binary operator. */
909
910#define BINARY_P(X) \
911 ((GET_RTX_CLASS (GET_CODE (X)) & RTX_BINARY_MASK) == RTX_BINARY_RESULT)
912
913/* 1 if X is an arithmetic operator. */
914
915#define ARITHMETIC_P(X) \
916 ((GET_RTX_CLASS (GET_CODE (X)) & RTX_ARITHMETIC_MASK) \
917 == RTX_ARITHMETIC_RESULT)
918
919/* 1 if X is an arithmetic operator. */
920
921#define COMMUTATIVE_ARITH_P(X) \
922 (GET_RTX_CLASS (GET_CODE (X)) == RTX_COMM_ARITH)
923
924/* 1 if X is a commutative arithmetic operator or a comparison operator.
925 These two are sometimes selected together because it is possible to
926 swap the two operands. */
927
928#define SWAPPABLE_OPERANDS_P(X) \
929 ((1 << GET_RTX_CLASS (GET_CODE (X))) \
930 & ((1 << RTX_COMM_ARITH) | (1 << RTX_COMM_COMPARE) \
931 | (1 << RTX_COMPARE)))
932
933/* 1 if X is a non-commutative operator. */
934
935#define NON_COMMUTATIVE_P(X) \
936 ((GET_RTX_CLASS (GET_CODE (X)) & RTX_COMMUTATIVE_MASK) \
937 == RTX_NON_COMMUTATIVE_RESULT)
938
939/* 1 if X is a commutative operator on integers. */
940
941#define COMMUTATIVE_P(X) \
942 ((GET_RTX_CLASS (GET_CODE (X)) & RTX_COMMUTATIVE_MASK) \
943 == RTX_COMMUTATIVE_RESULT)
944
945/* 1 if X is a relational operator. */
946
947#define COMPARISON_P(X) \
948 ((GET_RTX_CLASS (GET_CODE (X)) & RTX_COMPARE_MASK) == RTX_COMPARE_RESULT)
949
759bebca 950/* 1 if X is a constant value that is an integer. */
951
952#define CONSTANT_P(X) \
0824c0d2 953 (GET_RTX_CLASS (GET_CODE (X)) == RTX_CONST_OBJ)
759bebca 954
6720e96c 955/* 1 if X can be used to represent an object. */
956#define OBJECT_P(X) \
957 ((GET_RTX_CLASS (GET_CODE (X)) & RTX_OBJ_MASK) == RTX_OBJ_RESULT)
958
759bebca 959/* General accessor macros for accessing the fields of an rtx. */
960
0c4e40c5 961#if defined ENABLE_RTL_CHECKING && (GCC_VERSION >= 2007)
25999090 962/* The bit with a star outside the statement expr and an & inside is
963 so that N can be evaluated only once. */
db7e2f59 964#define RTL_CHECK1(RTX, N, C1) __extension__ \
0c16c31b 965(*({ __typeof (RTX) const _rtx = (RTX); const int _n = (N); \
861589fe 966 const enum rtx_code _code = GET_CODE (_rtx); \
25999090 967 if (_n < 0 || _n >= GET_RTX_LENGTH (_code)) \
017c31d6 968 rtl_check_failed_bounds (_rtx, _n, __FILE__, __LINE__, \
969 __FUNCTION__); \
9af5ce0c 970 if (GET_RTX_FORMAT (_code)[_n] != C1) \
017c31d6 971 rtl_check_failed_type1 (_rtx, _n, C1, __FILE__, __LINE__, \
972 __FUNCTION__); \
bf6b5685 973 &_rtx->u.fld[_n]; }))
25999090 974
db7e2f59 975#define RTL_CHECK2(RTX, N, C1, C2) __extension__ \
0c16c31b 976(*({ __typeof (RTX) const _rtx = (RTX); const int _n = (N); \
861589fe 977 const enum rtx_code _code = GET_CODE (_rtx); \
25999090 978 if (_n < 0 || _n >= GET_RTX_LENGTH (_code)) \
017c31d6 979 rtl_check_failed_bounds (_rtx, _n, __FILE__, __LINE__, \
980 __FUNCTION__); \
9af5ce0c 981 if (GET_RTX_FORMAT (_code)[_n] != C1 \
982 && GET_RTX_FORMAT (_code)[_n] != C2) \
25999090 983 rtl_check_failed_type2 (_rtx, _n, C1, C2, __FILE__, __LINE__, \
19fafbd3 984 __FUNCTION__); \
bf6b5685 985 &_rtx->u.fld[_n]; }))
25999090 986
db7e2f59 987#define RTL_CHECKC1(RTX, N, C) __extension__ \
0c16c31b 988(*({ __typeof (RTX) const _rtx = (RTX); const int _n = (N); \
017c31d6 989 if (GET_CODE (_rtx) != (C)) \
990 rtl_check_failed_code1 (_rtx, (C), __FILE__, __LINE__, \
991 __FUNCTION__); \
bf6b5685 992 &_rtx->u.fld[_n]; }))
005d995b 993
db7e2f59 994#define RTL_CHECKC2(RTX, N, C1, C2) __extension__ \
0c16c31b 995(*({ __typeof (RTX) const _rtx = (RTX); const int _n = (N); \
861589fe 996 const enum rtx_code _code = GET_CODE (_rtx); \
017c31d6 997 if (_code != (C1) && _code != (C2)) \
998 rtl_check_failed_code2 (_rtx, (C1), (C2), __FILE__, __LINE__, \
999 __FUNCTION__); \
bf6b5685 1000 &_rtx->u.fld[_n]; }))
005d995b 1001
db7e2f59 1002#define RTVEC_ELT(RTVEC, I) __extension__ \
0c16c31b 1003(*({ __typeof (RTVEC) const _rtvec = (RTVEC); const int _i = (I); \
25999090 1004 if (_i < 0 || _i >= GET_NUM_ELEM (_rtvec)) \
1005 rtvec_check_failed_bounds (_rtvec, _i, __FILE__, __LINE__, \
19fafbd3 1006 __FUNCTION__); \
25999090 1007 &_rtvec->elem[_i]; }))
1008
bf6b5685 1009#define XWINT(RTX, N) __extension__ \
0c16c31b 1010(*({ __typeof (RTX) const _rtx = (RTX); const int _n = (N); \
bf6b5685 1011 const enum rtx_code _code = GET_CODE (_rtx); \
1012 if (_n < 0 || _n >= GET_RTX_LENGTH (_code)) \
1013 rtl_check_failed_bounds (_rtx, _n, __FILE__, __LINE__, \
1014 __FUNCTION__); \
9af5ce0c 1015 if (GET_RTX_FORMAT (_code)[_n] != 'w') \
bf6b5685 1016 rtl_check_failed_type1 (_rtx, _n, 'w', __FILE__, __LINE__, \
1017 __FUNCTION__); \
1018 &_rtx->u.hwint[_n]; }))
1019
05c25ee6 1020#define CWI_ELT(RTX, I) __extension__ \
8e5ec000 1021(*({ __typeof (RTX) const _cwi = (RTX); \
1022 int _max = CWI_GET_NUM_ELEM (_cwi); \
05c25ee6 1023 const int _i = (I); \
1024 if (_i < 0 || _i >= _max) \
8e5ec000 1025 cwi_check_failed_bounds (_cwi, _i, __FILE__, __LINE__, \
05c25ee6 1026 __FUNCTION__); \
8e5ec000 1027 &_cwi->u.hwiv.elem[_i]; }))
e913b5cd 1028
bf6b5685 1029#define XCWINT(RTX, N, C) __extension__ \
0c16c31b 1030(*({ __typeof (RTX) const _rtx = (RTX); \
bf6b5685 1031 if (GET_CODE (_rtx) != (C)) \
1032 rtl_check_failed_code1 (_rtx, (C), __FILE__, __LINE__, \
1033 __FUNCTION__); \
1034 &_rtx->u.hwint[N]; }))
1035
e8aaae4e 1036#define XCMWINT(RTX, N, C, M) __extension__ \
0c16c31b 1037(*({ __typeof (RTX) const _rtx = (RTX); \
e8aaae4e 1038 if (GET_CODE (_rtx) != (C) || GET_MODE (_rtx) != (M)) \
1039 rtl_check_failed_code_mode (_rtx, (C), (M), false, __FILE__, \
1040 __LINE__, __FUNCTION__); \
1041 &_rtx->u.hwint[N]; }))
1042
1043#define XCNMPRV(RTX, C, M) __extension__ \
0c16c31b 1044({ __typeof (RTX) const _rtx = (RTX); \
e8aaae4e 1045 if (GET_CODE (_rtx) != (C) || GET_MODE (_rtx) == (M)) \
1046 rtl_check_failed_code_mode (_rtx, (C), (M), true, __FILE__, \
1047 __LINE__, __FUNCTION__); \
1048 &_rtx->u.rv; })
1049
e397ad8e 1050#define XCNMPFV(RTX, C, M) __extension__ \
6463c271 1051({ __typeof (RTX) const _rtx = (RTX); \
e397ad8e 1052 if (GET_CODE (_rtx) != (C) || GET_MODE (_rtx) == (M)) \
1053 rtl_check_failed_code_mode (_rtx, (C), (M), true, __FILE__, \
1054 __LINE__, __FUNCTION__); \
1055 &_rtx->u.fv; })
1056
f2d0e9f1 1057#define BLOCK_SYMBOL_CHECK(RTX) __extension__ \
0c16c31b 1058({ __typeof (RTX) const _symbol = (RTX); \
dd9571fd 1059 const unsigned int flags = SYMBOL_REF_FLAGS (_symbol); \
6617cbc1 1060 if ((flags & SYMBOL_FLAG_HAS_BLOCK_INFO) == 0) \
f2d0e9f1 1061 rtl_check_failed_block_symbol (__FILE__, __LINE__, \
1062 __FUNCTION__); \
1063 &_symbol->u.block_sym; })
1064
e913b5cd 1065#define HWIVEC_CHECK(RTX,C) __extension__ \
1066({ __typeof (RTX) const _symbol = (RTX); \
1067 RTL_CHECKC1 (_symbol, 0, C); \
1068 &_symbol->u.hwiv; })
1069
dd9b9fc5 1070extern void rtl_check_failed_bounds (const_rtx, int, const char *, int,
3ad4992f 1071 const char *)
25999090 1072 ATTRIBUTE_NORETURN;
dd9b9fc5 1073extern void rtl_check_failed_type1 (const_rtx, int, int, const char *, int,
3ad4992f 1074 const char *)
25999090 1075 ATTRIBUTE_NORETURN;
dd9b9fc5 1076extern void rtl_check_failed_type2 (const_rtx, int, int, int, const char *,
3ad4992f 1077 int, const char *)
25999090 1078 ATTRIBUTE_NORETURN;
dd9b9fc5 1079extern void rtl_check_failed_code1 (const_rtx, enum rtx_code, const char *,
3ad4992f 1080 int, const char *)
005d995b 1081 ATTRIBUTE_NORETURN;
dd9b9fc5 1082extern void rtl_check_failed_code2 (const_rtx, enum rtx_code, enum rtx_code,
3ad4992f 1083 const char *, int, const char *)
005d995b 1084 ATTRIBUTE_NORETURN;
dd9b9fc5 1085extern void rtl_check_failed_code_mode (const_rtx, enum rtx_code, enum machine_mode,
e8aaae4e 1086 bool, const char *, int, const char *)
1087 ATTRIBUTE_NORETURN;
f2d0e9f1 1088extern void rtl_check_failed_block_symbol (const char *, int, const char *)
1089 ATTRIBUTE_NORETURN;
05c25ee6 1090extern void cwi_check_failed_bounds (const_rtx, int, const char *, int,
1091 const char *)
e913b5cd 1092 ATTRIBUTE_NORETURN;
dd9b9fc5 1093extern void rtvec_check_failed_bounds (const_rtvec, int, const char *, int,
3ad4992f 1094 const char *)
25999090 1095 ATTRIBUTE_NORETURN;
1096
0c4e40c5 1097#else /* not ENABLE_RTL_CHECKING */
25999090 1098
bf6b5685 1099#define RTL_CHECK1(RTX, N, C1) ((RTX)->u.fld[N])
1100#define RTL_CHECK2(RTX, N, C1, C2) ((RTX)->u.fld[N])
1101#define RTL_CHECKC1(RTX, N, C) ((RTX)->u.fld[N])
1102#define RTL_CHECKC2(RTX, N, C1, C2) ((RTX)->u.fld[N])
005d995b 1103#define RTVEC_ELT(RTVEC, I) ((RTVEC)->elem[I])
bf6b5685 1104#define XWINT(RTX, N) ((RTX)->u.hwint[N])
05c25ee6 1105#define CWI_ELT(RTX, I) ((RTX)->u.hwiv.elem[I])
bf6b5685 1106#define XCWINT(RTX, N, C) ((RTX)->u.hwint[N])
e8aaae4e 1107#define XCMWINT(RTX, N, C, M) ((RTX)->u.hwint[N])
1108#define XCNMWINT(RTX, N, C, M) ((RTX)->u.hwint[N])
1109#define XCNMPRV(RTX, C, M) (&(RTX)->u.rv)
e397ad8e 1110#define XCNMPFV(RTX, C, M) (&(RTX)->u.fv)
f2d0e9f1 1111#define BLOCK_SYMBOL_CHECK(RTX) (&(RTX)->u.block_sym)
e913b5cd 1112#define HWIVEC_CHECK(RTX,C) (&(RTX)->u.hwiv)
25999090 1113
1114#endif
1115
e7f75e15 1116/* General accessor macros for accessing the flags of an rtx. */
1117
1118/* Access an individual rtx flag, with no checking of any kind. */
1119#define RTX_FLAG(RTX, FLAG) ((RTX)->FLAG)
1120
9b535aa8 1121#if defined ENABLE_RTL_FLAG_CHECKING && (GCC_VERSION >= 2007)
3c6858c6 1122#define RTL_FLAG_CHECK1(NAME, RTX, C1) __extension__ \
0c16c31b 1123({ __typeof (RTX) const _rtx = (RTX); \
9af5ce0c 1124 if (GET_CODE (_rtx) != C1) \
3c6858c6 1125 rtl_check_failed_flag (NAME, _rtx, __FILE__, __LINE__, \
1a97be37 1126 __FUNCTION__); \
e7f75e15 1127 _rtx; })
1128
3c6858c6 1129#define RTL_FLAG_CHECK2(NAME, RTX, C1, C2) __extension__ \
0c16c31b 1130({ __typeof (RTX) const _rtx = (RTX); \
9af5ce0c 1131 if (GET_CODE (_rtx) != C1 && GET_CODE(_rtx) != C2) \
3c6858c6 1132 rtl_check_failed_flag (NAME,_rtx, __FILE__, __LINE__, \
1a97be37 1133 __FUNCTION__); \
e7f75e15 1134 _rtx; })
1135
3c6858c6 1136#define RTL_FLAG_CHECK3(NAME, RTX, C1, C2, C3) __extension__ \
0c16c31b 1137({ __typeof (RTX) const _rtx = (RTX); \
9af5ce0c 1138 if (GET_CODE (_rtx) != C1 && GET_CODE(_rtx) != C2 \
1139 && GET_CODE (_rtx) != C3) \
3c6858c6 1140 rtl_check_failed_flag (NAME, _rtx, __FILE__, __LINE__, \
1a97be37 1141 __FUNCTION__); \
e7f75e15 1142 _rtx; })
1143
3c6858c6 1144#define RTL_FLAG_CHECK4(NAME, RTX, C1, C2, C3, C4) __extension__ \
0c16c31b 1145({ __typeof (RTX) const _rtx = (RTX); \
9af5ce0c 1146 if (GET_CODE (_rtx) != C1 && GET_CODE(_rtx) != C2 \
1147 && GET_CODE (_rtx) != C3 && GET_CODE(_rtx) != C4) \
3c6858c6 1148 rtl_check_failed_flag (NAME, _rtx, __FILE__, __LINE__, \
1a97be37 1149 __FUNCTION__); \
e7f75e15 1150 _rtx; })
1151
3c6858c6 1152#define RTL_FLAG_CHECK5(NAME, RTX, C1, C2, C3, C4, C5) __extension__ \
0c16c31b 1153({ __typeof (RTX) const _rtx = (RTX); \
9af5ce0c 1154 if (GET_CODE (_rtx) != C1 && GET_CODE (_rtx) != C2 \
1155 && GET_CODE (_rtx) != C3 && GET_CODE (_rtx) != C4 \
1156 && GET_CODE (_rtx) != C5) \
3c6858c6 1157 rtl_check_failed_flag (NAME, _rtx, __FILE__, __LINE__, \
1a97be37 1158 __FUNCTION__); \
e7f75e15 1159 _rtx; })
1160
3c6858c6 1161#define RTL_FLAG_CHECK6(NAME, RTX, C1, C2, C3, C4, C5, C6) \
1162 __extension__ \
0c16c31b 1163({ __typeof (RTX) const _rtx = (RTX); \
9af5ce0c 1164 if (GET_CODE (_rtx) != C1 && GET_CODE (_rtx) != C2 \
1165 && GET_CODE (_rtx) != C3 && GET_CODE (_rtx) != C4 \
1166 && GET_CODE (_rtx) != C5 && GET_CODE (_rtx) != C6) \
3c6858c6 1167 rtl_check_failed_flag (NAME,_rtx, __FILE__, __LINE__, \
1a97be37 1168 __FUNCTION__); \
e7f75e15 1169 _rtx; })
1170
3c6858c6 1171#define RTL_FLAG_CHECK7(NAME, RTX, C1, C2, C3, C4, C5, C6, C7) \
1172 __extension__ \
0c16c31b 1173({ __typeof (RTX) const _rtx = (RTX); \
9af5ce0c 1174 if (GET_CODE (_rtx) != C1 && GET_CODE (_rtx) != C2 \
1175 && GET_CODE (_rtx) != C3 && GET_CODE (_rtx) != C4 \
1176 && GET_CODE (_rtx) != C5 && GET_CODE (_rtx) != C6 \
1177 && GET_CODE (_rtx) != C7) \
3c6858c6 1178 rtl_check_failed_flag (NAME, _rtx, __FILE__, __LINE__, \
1a97be37 1179 __FUNCTION__); \
e7f75e15 1180 _rtx; })
1181
5cda2bd0 1182#define RTL_INSN_CHAIN_FLAG_CHECK(NAME, RTX) \
3c6858c6 1183 __extension__ \
0c16c31b 1184({ __typeof (RTX) const _rtx = (RTX); \
5cda2bd0 1185 if (!INSN_CHAIN_CODE_P (GET_CODE (_rtx))) \
1186 rtl_check_failed_flag (NAME, _rtx, __FILE__, __LINE__, \
1187 __FUNCTION__); \
e7f75e15 1188 _rtx; })
1189
dd9b9fc5 1190extern void rtl_check_failed_flag (const char *, const_rtx, const char *,
3ad4992f 1191 int, const char *)
e7f75e15 1192 ATTRIBUTE_NORETURN
1193 ;
1194
1195#else /* not ENABLE_RTL_FLAG_CHECKING */
1196
3c6858c6 1197#define RTL_FLAG_CHECK1(NAME, RTX, C1) (RTX)
1198#define RTL_FLAG_CHECK2(NAME, RTX, C1, C2) (RTX)
1199#define RTL_FLAG_CHECK3(NAME, RTX, C1, C2, C3) (RTX)
1200#define RTL_FLAG_CHECK4(NAME, RTX, C1, C2, C3, C4) (RTX)
5cda2bd0 1201#define RTL_FLAG_CHECK5(NAME, RTX, C1, C2, C3, C4, C5) (RTX)
3c6858c6 1202#define RTL_FLAG_CHECK6(NAME, RTX, C1, C2, C3, C4, C5, C6) (RTX)
1203#define RTL_FLAG_CHECK7(NAME, RTX, C1, C2, C3, C4, C5, C6, C7) (RTX)
5cda2bd0 1204#define RTL_INSN_CHAIN_FLAG_CHECK(NAME, RTX) (RTX)
e7f75e15 1205#endif
1206
993d9e55 1207#define XINT(RTX, N) (RTL_CHECK2 (RTX, N, 'i', 'n').rt_int)
5169661d 1208#define XUINT(RTX, N) (RTL_CHECK2 (RTX, N, 'i', 'n').rt_uint)
993d9e55 1209#define XSTR(RTX, N) (RTL_CHECK2 (RTX, N, 's', 'S').rt_str)
1210#define XEXP(RTX, N) (RTL_CHECK2 (RTX, N, 'e', 'u').rt_rtx)
1211#define XVEC(RTX, N) (RTL_CHECK2 (RTX, N, 'E', 'V').rt_rtvec)
1212#define XMODE(RTX, N) (RTL_CHECK1 (RTX, N, 'M').rt_type)
993d9e55 1213#define XTREE(RTX, N) (RTL_CHECK1 (RTX, N, 't').rt_tree)
1214#define XBBDEF(RTX, N) (RTL_CHECK1 (RTX, N, 'B').rt_bb)
1215#define XTMPL(RTX, N) (RTL_CHECK1 (RTX, N, 'T').rt_str)
46346a52 1216#define XCFI(RTX, N) (RTL_CHECK1 (RTX, N, 'C').rt_cfi)
25999090 1217
1218#define XVECEXP(RTX, N, M) RTVEC_ELT (XVEC (RTX, N), M)
1219#define XVECLEN(RTX, N) GET_NUM_ELEM (XVEC (RTX, N))
1220
bf6b5685 1221/* These are like XINT, etc. except that they expect a '0' field instead
25999090 1222 of the normal type code. */
1223
993d9e55 1224#define X0INT(RTX, N) (RTL_CHECK1 (RTX, N, '0').rt_int)
1225#define X0UINT(RTX, N) (RTL_CHECK1 (RTX, N, '0').rt_uint)
1226#define X0STR(RTX, N) (RTL_CHECK1 (RTX, N, '0').rt_str)
1227#define X0EXP(RTX, N) (RTL_CHECK1 (RTX, N, '0').rt_rtx)
1228#define X0VEC(RTX, N) (RTL_CHECK1 (RTX, N, '0').rt_rtvec)
1229#define X0MODE(RTX, N) (RTL_CHECK1 (RTX, N, '0').rt_type)
993d9e55 1230#define X0TREE(RTX, N) (RTL_CHECK1 (RTX, N, '0').rt_tree)
1231#define X0BBDEF(RTX, N) (RTL_CHECK1 (RTX, N, '0').rt_bb)
017c31d6 1232#define X0ADVFLAGS(RTX, N) (RTL_CHECK1 (RTX, N, '0').rt_addr_diff_vec_flags)
1233#define X0CSELIB(RTX, N) (RTL_CHECK1 (RTX, N, '0').rt_cselib)
993d9e55 1234#define X0MEMATTR(RTX, N) (RTL_CHECKC1 (RTX, N, MEM).rt_mem)
1235#define X0REGATTR(RTX, N) (RTL_CHECKC1 (RTX, N, REG).rt_reg)
7c266bb1 1236#define X0CONSTANT(RTX, N) (RTL_CHECK1 (RTX, N, '0').rt_constant)
017c31d6 1237
bf6b5685 1238/* Access a '0' field with any type. */
1239#define X0ANY(RTX, N) RTL_CHECK1 (RTX, N, '0')
1240
993d9e55 1241#define XCINT(RTX, N, C) (RTL_CHECKC1 (RTX, N, C).rt_int)
1242#define XCUINT(RTX, N, C) (RTL_CHECKC1 (RTX, N, C).rt_uint)
1243#define XCSTR(RTX, N, C) (RTL_CHECKC1 (RTX, N, C).rt_str)
1244#define XCEXP(RTX, N, C) (RTL_CHECKC1 (RTX, N, C).rt_rtx)
1245#define XCVEC(RTX, N, C) (RTL_CHECKC1 (RTX, N, C).rt_rtvec)
1246#define XCMODE(RTX, N, C) (RTL_CHECKC1 (RTX, N, C).rt_type)
993d9e55 1247#define XCTREE(RTX, N, C) (RTL_CHECKC1 (RTX, N, C).rt_tree)
1248#define XCBBDEF(RTX, N, C) (RTL_CHECKC1 (RTX, N, C).rt_bb)
46346a52 1249#define XCCFI(RTX, N, C) (RTL_CHECKC1 (RTX, N, C).rt_cfi)
017c31d6 1250#define XCCSELIB(RTX, N, C) (RTL_CHECKC1 (RTX, N, C).rt_cselib)
005d995b 1251
6421ab11 1252#define XCVECEXP(RTX, N, M, C) RTVEC_ELT (XCVEC (RTX, N, C), M)
1253#define XCVECLEN(RTX, N, C) GET_NUM_ELEM (XCVEC (RTX, N, C))
005d995b 1254
993d9e55 1255#define XC2EXP(RTX, N, C1, C2) (RTL_CHECKC2 (RTX, N, C1, C2).rt_rtx)
759bebca 1256\f
13be9dc6 1257
ede4900a 1258/* Methods of rtx_expr_list. */
1259
1260inline rtx_expr_list *rtx_expr_list::next () const
1261{
1262 rtx tmp = XEXP (this, 1);
1263 return safe_as_a <rtx_expr_list *> (tmp);
1264}
1265
1266inline rtx rtx_expr_list::element () const
1267{
1268 return XEXP (this, 0);
1269}
1270
13be9dc6 1271/* Methods of rtx_insn_list. */
1272
1273inline rtx_insn_list *rtx_insn_list::next () const
1274{
1275 rtx tmp = XEXP (this, 1);
1276 return safe_as_a <rtx_insn_list *> (tmp);
1277}
1278
1279inline rtx_insn *rtx_insn_list::insn () const
1280{
1281 rtx tmp = XEXP (this, 0);
1282 return safe_as_a <rtx_insn *> (tmp);
1283}
1284
4aa21596 1285/* Methods of rtx_sequence. */
1286
1287inline int rtx_sequence::len () const
1288{
1289 return XVECLEN (this, 0);
1290}
1291
1292inline rtx rtx_sequence::element (int index) const
1293{
1294 return XVECEXP (this, 0, index);
1295}
1296
1297inline rtx_insn *rtx_sequence::insn (int index) const
1298{
1299 return as_a <rtx_insn *> (XVECEXP (this, 0, index));
1300}
1301
759bebca 1302/* ACCESS MACROS for particular fields of insns. */
1303
1304/* Holds a unique number for each insn.
1305 These are not necessarily sequentially increasing. */
f70c1788 1306inline int INSN_UID (const_rtx insn)
1307{
1308 return RTL_INSN_CHAIN_FLAG_CHECK ("INSN_UID",
1309 (insn))->u2.insn_uid;
1310}
1311inline int& INSN_UID (rtx insn)
1312{
1313 return RTL_INSN_CHAIN_FLAG_CHECK ("INSN_UID",
1314 (insn))->u2.insn_uid;
1315}
759bebca 1316
1317/* Chain insns together in sequence. */
9a38ecd7 1318
4a57a2e8 1319/* For now these are split in two: an rvalue form:
1320 PREV_INSN/NEXT_INSN
1321 and an lvalue form:
1322 SET_NEXT_INSN/SET_PREV_INSN. */
1323
9a38ecd7 1324inline rtx_insn *PREV_INSN (const_rtx insn)
1325{
1326 rtx prev = XEXP (insn, 0);
1327 return safe_as_a <rtx_insn *> (prev);
1328}
1329
1330inline rtx& SET_PREV_INSN (rtx insn)
1331{
1332 return XEXP (insn, 0);
1333}
1334
1335inline rtx_insn *NEXT_INSN (const_rtx insn)
1336{
1337 rtx next = XEXP (insn, 1);
1338 return safe_as_a <rtx_insn *> (next);
1339}
1340
1341inline rtx& SET_NEXT_INSN (rtx insn)
1342{
1343 return XEXP (insn, 1);
1344}
759bebca 1345
f70c1788 1346inline basic_block BLOCK_FOR_INSN (const_rtx insn)
1347{
1348 return XBBDEF (insn, 2);
1349}
1350
1351inline basic_block& BLOCK_FOR_INSN (rtx insn)
1352{
1353 return XBBDEF (insn, 2);
1354}
3a55c112 1355
1356/* The body of an insn. */
80ff6944 1357inline rtx PATTERN (const_rtx insn)
1358{
1359 return XEXP (insn, 3);
1360}
1361
1362inline rtx& PATTERN (rtx insn)
1363{
1364 return XEXP (insn, 3);
1365}
3a55c112 1366
f70c1788 1367inline unsigned int INSN_LOCATION (const_rtx insn)
1368{
1369 return XUINT (insn, 4);
1370}
1371
1372inline unsigned int& INSN_LOCATION (rtx insn)
1373{
1374 return XUINT (insn, 4);
1375}
5169661d 1376
f70c1788 1377inline bool INSN_HAS_LOCATION (const_rtx insn)
1378{
1379 return LOCATION_LOCUS (INSN_LOCATION (insn)) != UNKNOWN_LOCATION;
1380}
5169661d 1381
e60a6f7b 1382/* LOCATION of an RTX if relevant. */
1383#define RTL_LOCATION(X) (INSN_P (X) ? \
5169661d 1384 INSN_LOCATION (X) : UNKNOWN_LOCATION)
759bebca 1385
1386/* Code number of instruction, from when it was recognized.
1387 -1 means this instruction has not been recognized yet. */
5cda2bd0 1388#define INSN_CODE(INSN) XINT (INSN, 5)
759bebca 1389
b77639be 1390inline rtvec rtx_jump_table_data::get_labels () const
1391{
1392 rtx pat = PATTERN (this);
1393 if (GET_CODE (pat) == ADDR_VEC)
1394 return XVEC (pat, 0);
1395 else
1396 return XVEC (pat, 1); /* presumably an ADDR_DIFF_VEC */
1397}
1398
3c6858c6 1399#define RTX_FRAME_RELATED_P(RTX) \
9af5ce0c 1400 (RTL_FLAG_CHECK6 ("RTX_FRAME_RELATED_P", (RTX), DEBUG_INSN, INSN, \
1401 CALL_INSN, JUMP_INSN, BARRIER, SET)->frame_related)
3c6858c6 1402
1403/* 1 if RTX is an insn that has been deleted. */
1404#define INSN_DELETED_P(RTX) \
5cda2bd0 1405 (RTL_INSN_CHAIN_FLAG_CHECK ("INSN_DELETED_P", (RTX))->volatil)
3c6858c6 1406
8f869004 1407/* 1 if JUMP RTX is a crossing jump. */
1408#define CROSSING_JUMP_P(RTX) \
1409 (RTL_FLAG_CHECK1 ("CROSSING_JUMP_P", (RTX), JUMP_INSN)->jump)
1410
9c2a0c05 1411/* 1 if RTX is a call to a const function. Built from ECF_CONST and
1412 TREE_READONLY. */
1413#define RTL_CONST_CALL_P(RTX) \
9af5ce0c 1414 (RTL_FLAG_CHECK1 ("RTL_CONST_CALL_P", (RTX), CALL_INSN)->unchanging)
9c2a0c05 1415
1416/* 1 if RTX is a call to a pure function. Built from ECF_PURE and
1417 DECL_PURE_P. */
1418#define RTL_PURE_CALL_P(RTX) \
9af5ce0c 1419 (RTL_FLAG_CHECK1 ("RTL_PURE_CALL_P", (RTX), CALL_INSN)->return_val)
9c2a0c05 1420
3c6858c6 1421/* 1 if RTX is a call to a const or pure function. */
9c2a0c05 1422#define RTL_CONST_OR_PURE_CALL_P(RTX) \
9af5ce0c 1423 (RTL_CONST_CALL_P (RTX) || RTL_PURE_CALL_P (RTX))
9c2a0c05 1424
1425/* 1 if RTX is a call to a looping const or pure function. Built from
1426 ECF_LOOPING_CONST_OR_PURE and DECL_LOOPING_CONST_OR_PURE_P. */
91f71fa3 1427#define RTL_LOOPING_CONST_OR_PURE_CALL_P(RTX) \
9af5ce0c 1428 (RTL_FLAG_CHECK1 ("CONST_OR_PURE_CALL_P", (RTX), CALL_INSN)->call)
3c6858c6 1429
1430/* 1 if RTX is a call_insn for a sibling call. */
1431#define SIBLING_CALL_P(RTX) \
9af5ce0c 1432 (RTL_FLAG_CHECK1 ("SIBLING_CALL_P", (RTX), CALL_INSN)->jump)
3c6858c6 1433
5fdf542c 1434/* 1 if RTX is a jump_insn, call_insn, or insn that is an annulling branch. */
3c6858c6 1435#define INSN_ANNULLED_BRANCH_P(RTX) \
9af5ce0c 1436 (RTL_FLAG_CHECK1 ("INSN_ANNULLED_BRANCH_P", (RTX), JUMP_INSN)->unchanging)
3c6858c6 1437
3c6858c6 1438/* 1 if RTX is an insn in a delay slot and is from the target of the branch.
1439 If the branch insn has INSN_ANNULLED_BRANCH_P set, this insn should only be
759bebca 1440 executed if the branch is taken. For annulled branches with this bit
1441 clear, the insn should be executed only if the branch is not taken. */
3c6858c6 1442#define INSN_FROM_TARGET_P(RTX) \
9af5ce0c 1443 (RTL_FLAG_CHECK3 ("INSN_FROM_TARGET_P", (RTX), INSN, JUMP_INSN, \
1444 CALL_INSN)->in_struct)
759bebca 1445
5bbaf5ca 1446/* In an ADDR_DIFF_VEC, the flags for RTX for use by branch shortening.
1447 See the comments for ADDR_DIFF_VEC in rtl.def. */
9af5ce0c 1448#define ADDR_DIFF_VEC_FLAGS(RTX) X0ADVFLAGS (RTX, 4)
f220c8f0 1449
5bbaf5ca 1450/* In a VALUE, the value cselib has assigned to RTX.
b3e7c666 1451 This is a "struct cselib_val", see cselib.h. */
9af5ce0c 1452#define CSELIB_VAL_PTR(RTX) X0CSELIB (RTX, 0)
f220c8f0 1453
759bebca 1454/* Holds a list of notes on what this insn does to various REGs.
f220c8f0 1455 It is a chain of EXPR_LIST rtx's, where the second operand is the
1456 chain pointer and the first operand is the REG being described.
759bebca 1457 The mode field of the EXPR_LIST contains not a real machine mode
f220c8f0 1458 but a value from enum reg_note. */
5cda2bd0 1459#define REG_NOTES(INSN) XEXP(INSN, 6)
759bebca 1460
a5701bde 1461/* In an ENTRY_VALUE this is the DECL_INCOMING_RTL of the argument in
1462 question. */
1463#define ENTRY_VALUE_EXP(RTX) (RTL_CHECKC1 (RTX, 0, ENTRY_VALUE).rt_rtx)
1464
f220c8f0 1465enum reg_note
1466{
30f4db0d 1467#define DEF_REG_NOTE(NAME) NAME,
1468#include "reg-notes.def"
1469#undef DEF_REG_NOTE
1470 REG_NOTE_MAX
f220c8f0 1471};
1472
759bebca 1473/* Define macros to extract and insert the reg-note kind in an EXPR_LIST. */
1474#define REG_NOTE_KIND(LINK) ((enum reg_note) GET_MODE (LINK))
017c31d6 1475#define PUT_REG_NOTE_KIND(LINK, KIND) \
1476 PUT_MODE (LINK, (enum machine_mode) (KIND))
759bebca 1477
1478/* Names for REG_NOTE's in EXPR_LIST insn's. */
1479
66e6c350 1480extern const char * const reg_note_name[];
a92771b8 1481#define GET_REG_NOTE_NAME(MODE) (reg_note_name[(int) (MODE)])
759bebca 1482
ff18c271 1483/* This field is only present on CALL_INSNs. It holds a chain of EXPR_LIST of
1484 USE and CLOBBER expressions.
1485 USE expressions list the registers filled with arguments that
1486 are passed to the function.
1487 CLOBBER expressions document the registers explicitly clobbered
1488 by this CALL_INSN.
1489 Pseudo registers can not be mentioned in this list. */
5cda2bd0 1490#define CALL_INSN_FUNCTION_USAGE(INSN) XEXP(INSN, 7)
ff18c271 1491
759bebca 1492/* The label-number of a code-label. The assembler label
1493 is made from `L' and the label-number printed in decimal.
1494 Label numbers are unique in a compilation. */
5cda2bd0 1495#define CODE_LABEL_NUMBER(INSN) XINT (INSN, 5)
759bebca 1496
a3426c4c 1497/* In a NOTE that is a line number, this is a string for the file name that the
1498 line is in. We use the same field to record block numbers temporarily in
1499 NOTE_INSN_BLOCK_BEG and NOTE_INSN_BLOCK_END notes. (We avoid lots of casts
1500 between ints and pointers if we use a different macro for the block number.)
f16b6102 1501 */
759bebca 1502
0a3b3d88 1503/* Opaque data. */
5cda2bd0 1504#define NOTE_DATA(INSN) RTL_CHECKC1 (INSN, 3, NOTE)
1505#define NOTE_DELETED_LABEL_NAME(INSN) XCSTR (INSN, 3, NOTE)
3072d30e 1506#define SET_INSN_DELETED(INSN) set_insn_deleted (INSN);
5cda2bd0 1507#define NOTE_BLOCK(INSN) XCTREE (INSN, 3, NOTE)
1508#define NOTE_EH_HANDLER(INSN) XCINT (INSN, 3, NOTE)
1509#define NOTE_BASIC_BLOCK(INSN) XCBBDEF (INSN, 3, NOTE)
1510#define NOTE_VAR_LOCATION(INSN) XCEXP (INSN, 3, NOTE)
1511#define NOTE_CFI(INSN) XCCFI (INSN, 3, NOTE)
1512#define NOTE_LABEL_NUMBER(INSN) XCINT (INSN, 3, NOTE)
a3426c4c 1513
759bebca 1514/* In a NOTE that is a line number, this is the line number.
1515 Other kinds of NOTEs are identified by negative numbers here. */
5cda2bd0 1516#define NOTE_KIND(INSN) XCINT (INSN, 4, NOTE)
759bebca 1517
83458610 1518/* Nonzero if INSN is a note marking the beginning of a basic block. */
aa90bb35 1519#define NOTE_INSN_BASIC_BLOCK_P(INSN) \
1520 (NOTE_P (INSN) && NOTE_KIND (INSN) == NOTE_INSN_BASIC_BLOCK)
83458610 1521
5923a5e7 1522/* Variable declaration and the location of a variable. */
9845d120 1523#define PAT_VAR_LOCATION_DECL(PAT) (XCTREE ((PAT), 0, VAR_LOCATION))
1524#define PAT_VAR_LOCATION_LOC(PAT) (XCEXP ((PAT), 1, VAR_LOCATION))
759bebca 1525
d53bb226 1526/* Initialization status of the variable in the location. Status
1527 can be unknown, uninitialized or initialized. See enumeration
1528 type below. */
9845d120 1529#define PAT_VAR_LOCATION_STATUS(PAT) \
e1398578 1530 (RTL_FLAG_CHECK1 ("PAT_VAR_LOCATION_STATUS", PAT, VAR_LOCATION) \
1531 ->u2.var_location_status)
9845d120 1532
1533/* Accessors for a NOTE_INSN_VAR_LOCATION. */
1534#define NOTE_VAR_LOCATION_DECL(NOTE) \
1535 PAT_VAR_LOCATION_DECL (NOTE_VAR_LOCATION (NOTE))
1536#define NOTE_VAR_LOCATION_LOC(NOTE) \
1537 PAT_VAR_LOCATION_LOC (NOTE_VAR_LOCATION (NOTE))
1538#define NOTE_VAR_LOCATION_STATUS(NOTE) \
1539 PAT_VAR_LOCATION_STATUS (NOTE_VAR_LOCATION (NOTE))
1540
1541/* The VAR_LOCATION rtx in a DEBUG_INSN. */
1542#define INSN_VAR_LOCATION(INSN) PATTERN (INSN)
1543
1544/* Accessors for a tree-expanded var location debug insn. */
1545#define INSN_VAR_LOCATION_DECL(INSN) \
1546 PAT_VAR_LOCATION_DECL (INSN_VAR_LOCATION (INSN))
1547#define INSN_VAR_LOCATION_LOC(INSN) \
1548 PAT_VAR_LOCATION_LOC (INSN_VAR_LOCATION (INSN))
1549#define INSN_VAR_LOCATION_STATUS(INSN) \
1550 PAT_VAR_LOCATION_STATUS (INSN_VAR_LOCATION (INSN))
1551
1552/* Expand to the RTL that denotes an unknown variable location in a
1553 DEBUG_INSN. */
1554#define gen_rtx_UNKNOWN_VAR_LOC() (gen_rtx_CLOBBER (VOIDmode, const0_rtx))
1555
1556/* Determine whether X is such an unknown location. */
1557#define VAR_LOC_UNKNOWN_P(X) \
1558 (GET_CODE (X) == CLOBBER && XEXP ((X), 0) == const0_rtx)
1559
1560/* 1 if RTX is emitted after a call, but it should take effect before
1561 the call returns. */
1562#define NOTE_DURING_CALL_P(RTX) \
9af5ce0c 1563 (RTL_FLAG_CHECK1 ("NOTE_VAR_LOCATION_DURING_CALL_P", (RTX), NOTE)->call)
d53bb226 1564
23dd51cb 1565/* DEBUG_EXPR_DECL corresponding to a DEBUG_EXPR RTX. */
1566#define DEBUG_EXPR_TREE_DECL(RTX) XCTREE (RTX, 0, DEBUG_EXPR)
1567
f9c61ef7 1568/* VAR_DECL/PARM_DECL DEBUG_IMPLICIT_PTR takes address of. */
1569#define DEBUG_IMPLICIT_PTR_DECL(RTX) XCTREE (RTX, 0, DEBUG_IMPLICIT_PTR)
1570
841424cc 1571/* PARM_DECL DEBUG_PARAMETER_REF references. */
1572#define DEBUG_PARAMETER_REF_DECL(RTX) XCTREE (RTX, 0, DEBUG_PARAMETER_REF)
1573
ad4583d9 1574/* Codes that appear in the NOTE_KIND field for kinds of notes
30f4db0d 1575 that are not line numbers. These codes are all negative.
48e1416a 1576
94c7f239 1577 Notice that we do not try to use zero here for any of
1578 the special note codes because sometimes the source line
1579 actually can be zero! This happens (for example) when we
1580 are generating code for the per-translation-unit constructor
30f4db0d 1581 and destructor routines for some C++ translation unit. */
759bebca 1582
0c981e42 1583enum insn_note
1584{
30f4db0d 1585#define DEF_INSN_NOTE(NAME) NAME,
1586#include "insn-notes.def"
1587#undef DEF_INSN_NOTE
5923a5e7 1588
0c981e42 1589 NOTE_INSN_MAX
1590};
64fdc3d4 1591
759bebca 1592/* Names for NOTE insn's other than line numbers. */
1593
ad4583d9 1594extern const char * const note_insn_name[NOTE_INSN_MAX];
0c981e42 1595#define GET_NOTE_INSN_NAME(NOTE_CODE) \
ad4583d9 1596 (note_insn_name[(NOTE_CODE)])
759bebca 1597
1598/* The name of a label, in case it corresponds to an explicit label
1599 in the input source code. */
5cda2bd0 1600#define LABEL_NAME(RTX) XCSTR (RTX, 6, CODE_LABEL)
759bebca 1601
1602/* In jump.c, each label contains a count of the number
1603 of LABEL_REFs that point at it, so unused labels can be deleted. */
5cda2bd0 1604#define LABEL_NUSES(RTX) XCINT (RTX, 4, CODE_LABEL)
759bebca 1605
a7ae1e59 1606/* Labels carry a two-bit field composed of the ->jump and ->call
1607 bits. This field indicates whether the label is an alternate
1608 entry point, and if so, what kind. */
1609enum label_kind
1610{
1611 LABEL_NORMAL = 0, /* ordinary label */
1612 LABEL_STATIC_ENTRY, /* alternate entry point, not exported */
1613 LABEL_GLOBAL_ENTRY, /* alternate entry point, exported */
1614 LABEL_WEAK_ENTRY /* alternate entry point, exported as weak symbol */
1615};
1616
1617#if defined ENABLE_RTL_FLAG_CHECKING && (GCC_VERSION > 2007)
1618
1619/* Retrieve the kind of LABEL. */
1620#define LABEL_KIND(LABEL) __extension__ \
dd9b9fc5 1621({ __typeof (LABEL) const _label = (LABEL); \
aa90bb35 1622 if (! LABEL_P (_label)) \
a7ae1e59 1623 rtl_check_failed_flag ("LABEL_KIND", _label, __FILE__, __LINE__, \
1624 __FUNCTION__); \
1625 (enum label_kind) ((_label->jump << 1) | _label->call); })
1626
1627/* Set the kind of LABEL. */
1628#define SET_LABEL_KIND(LABEL, KIND) do { \
dd9b9fc5 1629 __typeof (LABEL) const _label = (LABEL); \
0c16c31b 1630 const unsigned int _kind = (KIND); \
aa90bb35 1631 if (! LABEL_P (_label)) \
a7ae1e59 1632 rtl_check_failed_flag ("SET_LABEL_KIND", _label, __FILE__, __LINE__, \
1633 __FUNCTION__); \
1634 _label->jump = ((_kind >> 1) & 1); \
1635 _label->call = (_kind & 1); \
1636} while (0)
1637
1638#else
1639
1640/* Retrieve the kind of LABEL. */
1641#define LABEL_KIND(LABEL) \
1642 ((enum label_kind) (((LABEL)->jump << 1) | (LABEL)->call))
1643
1644/* Set the kind of LABEL. */
1645#define SET_LABEL_KIND(LABEL, KIND) do { \
0c16c31b 1646 rtx const _label = (LABEL); \
1647 const unsigned int _kind = (KIND); \
a7ae1e59 1648 _label->jump = ((_kind >> 1) & 1); \
1649 _label->call = (_kind & 1); \
1650} while (0)
1651
1652#endif /* rtl flag checking */
1653
1654#define LABEL_ALT_ENTRY_P(LABEL) (LABEL_KIND (LABEL) != LABEL_NORMAL)
bfee5366 1655
759bebca 1656/* In jump.c, each JUMP_INSN can point to a label that it can jump to,
1657 so that if the JUMP_INSN is deleted, the label's LABEL_NUSES can
1658 be decremented and possibly the label can be deleted. */
5cda2bd0 1659#define JUMP_LABEL(INSN) XCEXP (INSN, 7, JUMP_INSN)
759bebca 1660
3072d30e 1661/* Once basic blocks are found, each CODE_LABEL starts a chain that
1662 goes through all the LABEL_REFs that jump to that label. The chain
1663 eventually winds up at the CODE_LABEL: it is circular. */
5cda2bd0 1664#define LABEL_REFS(LABEL) XCEXP (LABEL, 3, CODE_LABEL)
759bebca 1665\f
3072d30e 1666/* For a REG rtx, REGNO extracts the register number. REGNO can only
1667 be used on RHS. Use SET_REGNO to change the value. */
1668#define REGNO(RTX) (rhs_regno(RTX))
9af5ce0c 1669#define SET_REGNO(RTX,N) \
1670 (df_ref_change_reg_with_loc (REGNO (RTX), N, RTX), XCUINT (RTX, 0, REG) = N)
7f1819d3 1671#define SET_REGNO_RAW(RTX,N) (XCUINT (RTX, 0, REG) = N)
3072d30e 1672
1673/* ORIGINAL_REGNO holds the number the register originally had; for a
1674 pseudo register turned into a hard reg this will hold the old pseudo
1675 register number. */
4db4d2a2 1676#define ORIGINAL_REGNO(RTX) \
1677 (RTL_FLAG_CHECK1 ("ORIGINAL_REGNO", (RTX), REG)->u2.original_regno)
759bebca 1678
3072d30e 1679/* Force the REGNO macro to only be used on the lhs. */
1680static inline unsigned int
dd9b9fc5 1681rhs_regno (const_rtx x)
3072d30e 1682{
1683 return XCUINT (x, 0, REG);
1684}
1685
1686
b566e2e5 1687/* 1 if RTX is a reg or parallel that is the current function's return
1688 value. */
3c6858c6 1689#define REG_FUNCTION_VALUE_P(RTX) \
9af5ce0c 1690 (RTL_FLAG_CHECK2 ("REG_FUNCTION_VALUE_P", (RTX), REG, PARALLEL)->return_val)
759bebca 1691
3c6858c6 1692/* 1 if RTX is a reg that corresponds to a variable declared by the user. */
1693#define REG_USERVAR_P(RTX) \
9af5ce0c 1694 (RTL_FLAG_CHECK1 ("REG_USERVAR_P", (RTX), REG)->volatil)
759bebca 1695
3c6858c6 1696/* 1 if RTX is a reg that holds a pointer value. */
1697#define REG_POINTER(RTX) \
9af5ce0c 1698 (RTL_FLAG_CHECK1 ("REG_POINTER", (RTX), REG)->frame_related)
e61a0a7f 1699
8d350e69 1700/* 1 if RTX is a mem that holds a pointer value. */
1701#define MEM_POINTER(RTX) \
9af5ce0c 1702 (RTL_FLAG_CHECK1 ("MEM_POINTER", (RTX), MEM)->frame_related)
8d350e69 1703
baaa5be9 1704/* 1 if the given register REG corresponds to a hard register. */
1705#define HARD_REGISTER_P(REG) (HARD_REGISTER_NUM_P (REGNO (REG)))
1706
1707/* 1 if the given register number REG_NO corresponds to a hard register. */
017c31d6 1708#define HARD_REGISTER_NUM_P(REG_NO) ((REG_NO) < FIRST_PSEUDO_REGISTER)
baaa5be9 1709
759bebca 1710/* For a CONST_INT rtx, INTVAL extracts the integer. */
9af5ce0c 1711#define INTVAL(RTX) XCWINT (RTX, 0, CONST_INT)
02fd0f2d 1712#define UINTVAL(RTX) ((unsigned HOST_WIDE_INT) INTVAL (RTX))
759bebca 1713
e913b5cd 1714/* For a CONST_WIDE_INT, CONST_WIDE_INT_NUNITS is the number of
1715 elements actually needed to represent the constant.
1716 CONST_WIDE_INT_ELT gets one of the elements. 0 is the least
1717 significant HOST_WIDE_INT. */
1718#define CONST_WIDE_INT_VEC(RTX) HWIVEC_CHECK (RTX, CONST_WIDE_INT)
05c25ee6 1719#define CONST_WIDE_INT_NUNITS(RTX) CWI_GET_NUM_ELEM (RTX)
1720#define CONST_WIDE_INT_ELT(RTX, N) CWI_ELT (RTX, N)
e913b5cd 1721
0f221fb7 1722/* For a CONST_DOUBLE:
e913b5cd 1723#if TARGET_SUPPORTS_WIDE_INT == 0
0b2730a7 1724 For a VOIDmode, there are two integers CONST_DOUBLE_LOW is the
3393215f 1725 low-order word and ..._HIGH the high-order.
e913b5cd 1726#endif
1a97be37 1727 For a float, there is a REAL_VALUE_TYPE structure, and
3393215f 1728 CONST_DOUBLE_REAL_VALUE(r) is a pointer to it. */
e8aaae4e 1729#define CONST_DOUBLE_LOW(r) XCMWINT (r, 0, CONST_DOUBLE, VOIDmode)
1730#define CONST_DOUBLE_HIGH(r) XCMWINT (r, 1, CONST_DOUBLE, VOIDmode)
1731#define CONST_DOUBLE_REAL_VALUE(r) \
1732 ((const struct real_value *) XCNMPRV (r, CONST_DOUBLE, VOIDmode))
0f221fb7 1733
e397ad8e 1734#define CONST_FIXED_VALUE(r) \
1735 ((const struct fixed_value *) XCNMPFV (r, CONST_FIXED, VOIDmode))
1736#define CONST_FIXED_VALUE_HIGH(r) \
9af5ce0c 1737 ((HOST_WIDE_INT) (CONST_FIXED_VALUE (r)->data.high))
e397ad8e 1738#define CONST_FIXED_VALUE_LOW(r) \
9af5ce0c 1739 ((HOST_WIDE_INT) (CONST_FIXED_VALUE (r)->data.low))
e397ad8e 1740
886cfd4f 1741/* For a CONST_VECTOR, return element #n. */
1742#define CONST_VECTOR_ELT(RTX, N) XCVECEXP (RTX, 0, N, CONST_VECTOR)
1743
1744/* For a CONST_VECTOR, return the number of elements in a vector. */
1745#define CONST_VECTOR_NUNITS(RTX) XCVECLEN (RTX, 0, CONST_VECTOR)
1746
759bebca 1747/* For a SUBREG rtx, SUBREG_REG extracts the value we want a subreg of.
701e46d0 1748 SUBREG_BYTE extracts the byte-number. */
759bebca 1749
017c31d6 1750#define SUBREG_REG(RTX) XCEXP (RTX, 0, SUBREG)
1751#define SUBREG_BYTE(RTX) XCUINT (RTX, 1, SUBREG)
701e46d0 1752
1753/* in rtlanal.c */
26619827 1754/* Return the right cost to give to an operation
1755 to make the cost of the corresponding register-to-register instruction
1756 N times that of a fast register-to-register instruction. */
1757#define COSTS_N_INSNS(N) ((N) * 4)
1758
1759/* Maximum cost of an rtl expression. This value has the special meaning
1760 not to use an rtx with this cost under any circumstances. */
1761#define MAX_COST INT_MAX
1762
c9a03487 1763/* A structure to hold all available cost information about an rtl
1764 expression. */
1765struct full_rtx_costs
1766{
1767 int speed;
1768 int size;
1769};
1770
1771/* Initialize a full_rtx_costs structure C to the maximum cost. */
1772static inline void
1773init_costs_to_max (struct full_rtx_costs *c)
1774{
1775 c->speed = MAX_COST;
1776 c->size = MAX_COST;
1777}
1778
1779/* Initialize a full_rtx_costs structure C to zero cost. */
1780static inline void
1781init_costs_to_zero (struct full_rtx_costs *c)
1782{
1783 c->speed = 0;
1784 c->size = 0;
1785}
1786
1787/* Compare two full_rtx_costs structures A and B, returning true
1788 if A < B when optimizing for speed. */
1789static inline bool
1790costs_lt_p (struct full_rtx_costs *a, struct full_rtx_costs *b,
1791 bool speed)
1792{
1793 if (speed)
1794 return (a->speed < b->speed
1795 || (a->speed == b->speed && a->size < b->size));
1796 else
1797 return (a->size < b->size
1798 || (a->size == b->size && a->speed < b->speed));
1799}
1800
1801/* Increase both members of the full_rtx_costs structure C by the
1802 cost of N insns. */
1803static inline void
1804costs_add_n_insns (struct full_rtx_costs *c, int n)
1805{
1806 c->speed += COSTS_N_INSNS (n);
1807 c->size += COSTS_N_INSNS (n);
1808}
1809
1efe9e9d 1810/* Information about an address. This structure is supposed to be able
1811 to represent all supported target addresses. Please extend it if it
1812 is not yet general enough. */
1813struct address_info {
1814 /* The mode of the value being addressed, or VOIDmode if this is
1815 a load-address operation with no known address mode. */
1816 enum machine_mode mode;
1817
1818 /* The address space. */
1819 addr_space_t as;
1820
1821 /* A pointer to the top-level address. */
1822 rtx *outer;
1823
1824 /* A pointer to the inner address, after all address mutations
1825 have been stripped from the top-level address. It can be one
1826 of the following:
1827
1828 - A {PRE,POST}_{INC,DEC} of *BASE. SEGMENT, INDEX and DISP are null.
1829
1830 - A {PRE,POST}_MODIFY of *BASE. In this case either INDEX or DISP
1831 points to the step value, depending on whether the step is variable
1832 or constant respectively. SEGMENT is null.
1833
1834 - A plain sum of the form SEGMENT + BASE + INDEX + DISP,
1835 with null fields evaluating to 0. */
1836 rtx *inner;
1837
1838 /* Components that make up *INNER. Each one may be null or nonnull.
1839 When nonnull, their meanings are as follows:
1840
1841 - *SEGMENT is the "segment" of memory to which the address refers.
1842 This value is entirely target-specific and is only called a "segment"
1843 because that's its most typical use. It contains exactly one UNSPEC,
1844 pointed to by SEGMENT_TERM. The contents of *SEGMENT do not need
1845 reloading.
1846
1847 - *BASE is a variable expression representing a base address.
1848 It contains exactly one REG, SUBREG or MEM, pointed to by BASE_TERM.
1849
1850 - *INDEX is a variable expression representing an index value.
1851 It may be a scaled expression, such as a MULT. It has exactly
1852 one REG, SUBREG or MEM, pointed to by INDEX_TERM.
1853
1854 - *DISP is a constant, possibly mutated. DISP_TERM points to the
1855 unmutated RTX_CONST_OBJ. */
1856 rtx *segment;
1857 rtx *base;
1858 rtx *index;
1859 rtx *disp;
1860
1861 rtx *segment_term;
1862 rtx *base_term;
1863 rtx *index_term;
1864 rtx *disp_term;
1865
1866 /* In a {PRE,POST}_MODIFY address, this points to a second copy
1867 of BASE_TERM, otherwise it is null. */
1868 rtx *base_term2;
1869
1870 /* ADDRESS if this structure describes an address operand, MEM if
1871 it describes a MEM address. */
1872 enum rtx_code addr_outer_code;
1873
1874 /* If BASE is nonnull, this is the code of the rtx that contains it. */
1875 enum rtx_code base_outer_code;
1876
1877 /* True if this is an RTX_AUTOINC address. */
1878 bool autoinc_p;
1879};
1880
796b6678 1881/* This is used to bundle an rtx and a mode together so that the pair
ab2c1de8 1882 can be used with the wi:: routines. If we ever put modes into rtx
1883 integer constants, this should go away and then just pass an rtx in. */
796b6678 1884typedef std::pair <rtx, enum machine_mode> rtx_mode_t;
e913b5cd 1885
796b6678 1886namespace wi
e913b5cd 1887{
796b6678 1888 template <>
1889 struct int_traits <rtx_mode_t>
1890 {
1891 static const enum precision_type precision_type = VAR_PRECISION;
1892 static const bool host_dependent_precision = false;
2e2f3be8 1893 /* This ought to be true, except for the special case that BImode
1894 is canonicalized to STORE_FLAG_VALUE, which might be 1. */
1895 static const bool is_sign_extended = false;
796b6678 1896 static unsigned int get_precision (const rtx_mode_t &);
1897 static wi::storage_ref decompose (HOST_WIDE_INT *, unsigned int,
1898 const rtx_mode_t &);
1899 };
e913b5cd 1900}
1901
796b6678 1902inline unsigned int
1903wi::int_traits <rtx_mode_t>::get_precision (const rtx_mode_t &x)
e913b5cd 1904{
796b6678 1905 return GET_MODE_PRECISION (x.second);
e913b5cd 1906}
1907
796b6678 1908inline wi::storage_ref
1909wi::int_traits <rtx_mode_t>::decompose (HOST_WIDE_INT *,
1910 unsigned int precision,
1911 const rtx_mode_t &x)
e913b5cd 1912{
796b6678 1913 gcc_checking_assert (precision == get_precision (x));
1914 switch (GET_CODE (x.first))
e913b5cd 1915 {
1916 case CONST_INT:
05363b4a 1917 if (precision < HOST_BITS_PER_WIDE_INT)
dfee1d0f 1918 /* Nonzero BImodes are stored as STORE_FLAG_VALUE, which on many
1919 targets is 1 rather than -1. */
ab2c1de8 1920 gcc_checking_assert (INTVAL (x.first)
2e2f3be8 1921 == sext_hwi (INTVAL (x.first), precision)
dfee1d0f 1922 || (x.second == BImode && INTVAL (x.first) == 1));
05363b4a 1923
796b6678 1924 return wi::storage_ref (&INTVAL (x.first), 1, precision);
ddb1be65 1925
e913b5cd 1926 case CONST_WIDE_INT:
796b6678 1927 return wi::storage_ref (&CONST_WIDE_INT_ELT (x.first, 0),
1928 CONST_WIDE_INT_NUNITS (x.first), precision);
ddb1be65 1929
05363b4a 1930#if TARGET_SUPPORTS_WIDE_INT == 0
e913b5cd 1931 case CONST_DOUBLE:
796b6678 1932 return wi::storage_ref (&CONST_DOUBLE_LOW (x.first), 2, precision);
05363b4a 1933#endif
ddb1be65 1934
e913b5cd 1935 default:
1936 gcc_unreachable ();
1937 }
1938}
1939
796b6678 1940namespace wi
e913b5cd 1941{
796b6678 1942 hwi_with_prec shwi (HOST_WIDE_INT, enum machine_mode mode);
1943 wide_int min_value (enum machine_mode, signop);
1944 wide_int max_value (enum machine_mode, signop);
1945}
e913b5cd 1946
796b6678 1947inline wi::hwi_with_prec
1948wi::shwi (HOST_WIDE_INT val, enum machine_mode mode)
1949{
1950 return shwi (val, GET_MODE_PRECISION (mode));
e913b5cd 1951}
1952
796b6678 1953/* Produce the smallest number that is represented in MODE. The precision
1954 is taken from MODE and the sign from SGN. */
1955inline wide_int
1956wi::min_value (enum machine_mode mode, signop sgn)
1957{
1958 return min_value (GET_MODE_PRECISION (mode), sgn);
1959}
e913b5cd 1960
796b6678 1961/* Produce the largest number that is represented in MODE. The precision
1962 is taken from MODE and the sign from SGN. */
1963inline wide_int
1964wi::max_value (enum machine_mode mode, signop sgn)
1965{
1966 return max_value (GET_MODE_PRECISION (mode), sgn);
1967}
e913b5cd 1968
a87cf6e5 1969extern void init_rtlanal (void);
20d892d1 1970extern int rtx_cost (rtx, enum rtx_code, int, bool);
bd1a81f7 1971extern int address_cost (rtx, enum machine_mode, addr_space_t, bool);
20d892d1 1972extern void get_full_rtx_cost (rtx, enum rtx_code, int,
1973 struct full_rtx_costs *);
dd9b9fc5 1974extern unsigned int subreg_lsb (const_rtx);
f36eb1e9 1975extern unsigned int subreg_lsb_1 (enum machine_mode, enum machine_mode,
1976 unsigned int);
3ad4992f 1977extern unsigned int subreg_regno_offset (unsigned int, enum machine_mode,
1978 unsigned int, enum machine_mode);
1979extern bool subreg_offset_representable_p (unsigned int, enum machine_mode,
1980 unsigned int, enum machine_mode);
dd9b9fc5 1981extern unsigned int subreg_regno (const_rtx);
5992d16a 1982extern int simplify_subreg_regno (unsigned int, enum machine_mode,
1983 unsigned int, enum machine_mode);
dd9b9fc5 1984extern unsigned int subreg_nregs (const_rtx);
dea7b504 1985extern unsigned int subreg_nregs_with_regno (unsigned int, const_rtx);
b7bf20db 1986extern unsigned HOST_WIDE_INT nonzero_bits (const_rtx, enum machine_mode);
1987extern unsigned int num_sign_bit_copies (const_rtx, enum machine_mode);
e207fd7a 1988extern bool constant_pool_constant_p (rtx);
b7bf20db 1989extern bool truncated_to_mode (enum machine_mode, const_rtx);
d16b48d5 1990extern int low_bitmask_len (enum machine_mode, unsigned HOST_WIDE_INT);
21eb4639 1991extern void split_double (rtx, rtx *, rtx *);
1efe9e9d 1992extern rtx *strip_address_mutations (rtx *, enum rtx_code * = 0);
1993extern void decompose_address (struct address_info *, rtx *,
1994 enum machine_mode, addr_space_t, enum rtx_code);
1995extern void decompose_lea_address (struct address_info *, rtx *);
1996extern void decompose_mem_address (struct address_info *, rtx);
1997extern void update_address (struct address_info *);
1998extern HOST_WIDE_INT get_index_scale (const struct address_info *);
1999extern enum rtx_code get_index_code (const struct address_info *);
d263732c 2000
b72d459f 2001#ifndef GENERATOR_FILE
2002/* Return the cost of SET X. SPEED_P is true if optimizing for speed
2003 rather than size. */
2004
2005static inline int
2006set_rtx_cost (rtx x, bool speed_p)
2007{
20d892d1 2008 return rtx_cost (x, INSN, 4, speed_p);
b72d459f 2009}
2010
2011/* Like set_rtx_cost, but return both the speed and size costs in C. */
2012
2013static inline void
2014get_full_set_rtx_cost (rtx x, struct full_rtx_costs *c)
2015{
20d892d1 2016 get_full_rtx_cost (x, INSN, 4, c);
b72d459f 2017}
7013e87c 2018
2019/* Return the cost of moving X into a register, relative to the cost
2020 of a register move. SPEED_P is true if optimizing for speed rather
2021 than size. */
2022
2023static inline int
2024set_src_cost (rtx x, bool speed_p)
2025{
20d892d1 2026 return rtx_cost (x, SET, 1, speed_p);
7013e87c 2027}
2028
2029/* Like set_src_cost, but return both the speed and size costs in C. */
2030
2031static inline void
2032get_full_set_src_cost (rtx x, struct full_rtx_costs *c)
2033{
20d892d1 2034 get_full_rtx_cost (x, SET, 1, c);
7013e87c 2035}
b72d459f 2036#endif
759bebca 2037
3c6858c6 2038/* 1 if RTX is a subreg containing a reg that is already known to be
2039 sign- or zero-extended from the mode of the subreg to the mode of
3e8eba79 2040 the reg. SUBREG_PROMOTED_UNSIGNED_P gives the signedness of the
f220c8f0 2041 extension.
3e8eba79 2042
2043 When used as a LHS, is means that this extension must be done
2044 when assigning to SUBREG_REG. */
2045
3c6858c6 2046#define SUBREG_PROMOTED_VAR_P(RTX) \
9af5ce0c 2047 (RTL_FLAG_CHECK1 ("SUBREG_PROMOTED", (RTX), SUBREG)->in_struct)
3c6858c6 2048
088c4b7b 2049/* Valid for subregs which are SUBREG_PROMOTED_VAR_P(). In that case
2050 this gives the necessary extensions:
e8629f9e 2051 0 - signed (SPR_SIGNED)
2052 1 - normal unsigned (SPR_UNSIGNED)
2053 2 - value is both sign and unsign extended for mode
2054 (SPR_SIGNED_AND_UNSIGNED).
088c4b7b 2055 -1 - pointer unsigned, which most often can be handled like unsigned
2056 extension, except for generating instructions where we need to
e8629f9e 2057 emit special code (ptr_extend insns) on some architectures
2058 (SPR_POINTER). */
2059
2060const int SRP_POINTER = -1;
2061const int SRP_SIGNED = 0;
2062const int SRP_UNSIGNED = 1;
2063const int SRP_SIGNED_AND_UNSIGNED = 2;
2064
2065/* Sets promoted mode for SUBREG_PROMOTED_VAR_P(). */
2066#define SUBREG_PROMOTED_SET(RTX, VAL) \
2067do { \
2068 rtx const _rtx = RTL_FLAG_CHECK1 ("SUBREG_PROMOTED_SET", \
2069 (RTX), SUBREG); \
2070 switch (VAL) \
2071 { \
2072 case SRP_POINTER: \
2073 _rtx->volatil = 0; \
2074 _rtx->unchanging = 0; \
2075 break; \
2076 case SRP_SIGNED: \
2077 _rtx->volatil = 0; \
2078 _rtx->unchanging = 1; \
2079 break; \
2080 case SRP_UNSIGNED: \
2081 _rtx->volatil = 1; \
2082 _rtx->unchanging = 0; \
2083 break; \
2084 case SRP_SIGNED_AND_UNSIGNED: \
2085 _rtx->volatil = 1; \
2086 _rtx->unchanging = 1; \
2087 break; \
2088 } \
2089} while (0)
088c4b7b 2090
e8629f9e 2091/* Gets the value stored in promoted mode for SUBREG_PROMOTED_VAR_P(),
2092 including SRP_SIGNED_AND_UNSIGNED if promoted for
2093 both signed and unsigned. */
2094#define SUBREG_PROMOTED_GET(RTX) \
2095 (2 * (RTL_FLAG_CHECK1 ("SUBREG_PROMOTED_GET", (RTX), SUBREG)->volatil)\
2096 + (RTX)->unchanging - 1)
2097
2098/* Returns sign of promoted mode for SUBREG_PROMOTED_VAR_P(). */
2099#define SUBREG_PROMOTED_SIGN(RTX) \
2100 ((RTL_FLAG_CHECK1 ("SUBREG_PROMOTED_SIGN", (RTX), SUBREG)->volatil) ? 1\
2101 : (RTX)->unchanging - 1)
2102
2103/* Predicate to check if RTX of SUBREG_PROMOTED_VAR_P() is promoted
2104 for SIGNED type. */
2105#define SUBREG_PROMOTED_SIGNED_P(RTX) \
2106 (RTL_FLAG_CHECK1 ("SUBREG_PROMOTED_SIGNED_P", (RTX), SUBREG)->unchanging)
2107
2108/* Predicate to check if RTX of SUBREG_PROMOTED_VAR_P() is promoted
2109 for UNSIGNED type. */
e7f75e15 2110#define SUBREG_PROMOTED_UNSIGNED_P(RTX) \
e8629f9e 2111 (RTL_FLAG_CHECK1 ("SUBREG_PROMOTED_UNSIGNED_P", (RTX), SUBREG)->volatil)
2112
2113/* Checks if RTX of SUBREG_PROMOTED_VAR_P() is promoted for given SIGN. */
2114#define SUBREG_CHECK_PROMOTED_SIGN(RTX, SIGN) \
2115((SIGN) == SRP_POINTER ? SUBREG_PROMOTED_GET (RTX) == SRP_POINTER \
2116 : (SIGN) == SRP_SIGNED ? SUBREG_PROMOTED_SIGNED_P (RTX) \
2117 : SUBREG_PROMOTED_UNSIGNED_P (RTX))
3e8eba79 2118
ea99c7a1 2119/* True if the subreg was generated by LRA for reload insns. Such
2120 subregs are valid only during LRA. */
2121#define LRA_SUBREG_P(RTX) \
9af5ce0c 2122 (RTL_FLAG_CHECK1 ("LRA_SUBREG_P", (RTX), SUBREG)->jump)
ea99c7a1 2123
759bebca 2124/* Access various components of an ASM_OPERANDS rtx. */
2125
017c31d6 2126#define ASM_OPERANDS_TEMPLATE(RTX) XCSTR (RTX, 0, ASM_OPERANDS)
2127#define ASM_OPERANDS_OUTPUT_CONSTRAINT(RTX) XCSTR (RTX, 1, ASM_OPERANDS)
2128#define ASM_OPERANDS_OUTPUT_IDX(RTX) XCINT (RTX, 2, ASM_OPERANDS)
2129#define ASM_OPERANDS_INPUT_VEC(RTX) XCVEC (RTX, 3, ASM_OPERANDS)
2130#define ASM_OPERANDS_INPUT_CONSTRAINT_VEC(RTX) XCVEC (RTX, 4, ASM_OPERANDS)
2131#define ASM_OPERANDS_INPUT(RTX, N) XCVECEXP (RTX, 3, N, ASM_OPERANDS)
2132#define ASM_OPERANDS_INPUT_LENGTH(RTX) XCVECLEN (RTX, 3, ASM_OPERANDS)
d91f2122 2133#define ASM_OPERANDS_INPUT_CONSTRAINT_EXP(RTX, N) \
017c31d6 2134 XCVECEXP (RTX, 4, N, ASM_OPERANDS)
f7c44134 2135#define ASM_OPERANDS_INPUT_CONSTRAINT(RTX, N) \
017c31d6 2136 XSTR (XCVECEXP (RTX, 4, N, ASM_OPERANDS), 0)
f7c44134 2137#define ASM_OPERANDS_INPUT_MODE(RTX, N) \
017c31d6 2138 GET_MODE (XCVECEXP (RTX, 4, N, ASM_OPERANDS))
78f55ca8 2139#define ASM_OPERANDS_LABEL_VEC(RTX) XCVEC (RTX, 5, ASM_OPERANDS)
2140#define ASM_OPERANDS_LABEL_LENGTH(RTX) XCVECLEN (RTX, 5, ASM_OPERANDS)
2141#define ASM_OPERANDS_LABEL(RTX, N) XCVECEXP (RTX, 5, N, ASM_OPERANDS)
2142#define ASM_OPERANDS_SOURCE_LOCATION(RTX) XCUINT (RTX, 6, ASM_OPERANDS)
09fb10e8 2143#define ASM_INPUT_SOURCE_LOCATION(RTX) XCUINT (RTX, 1, ASM_INPUT)
759bebca 2144
b04fab2a 2145/* 1 if RTX is a mem that is statically allocated in read-only memory. */
2146#define MEM_READONLY_P(RTX) \
9af5ce0c 2147 (RTL_FLAG_CHECK1 ("MEM_READONLY_P", (RTX), MEM)->unchanging)
b04fab2a 2148
3c6858c6 2149/* 1 if RTX is a mem and we should keep the alias set for this mem
5cc193e7 2150 unchanged when we access a component. Set to 1, or example, when we
2151 are already in a non-addressable component of an aggregate. */
3c6858c6 2152#define MEM_KEEP_ALIAS_SET_P(RTX) \
9af5ce0c 2153 (RTL_FLAG_CHECK1 ("MEM_KEEP_ALIAS_SET_P", (RTX), MEM)->jump)
5cc193e7 2154
3c6858c6 2155/* 1 if RTX is a mem or asm_operand for a volatile reference. */
2156#define MEM_VOLATILE_P(RTX) \
9af5ce0c 2157 (RTL_FLAG_CHECK3 ("MEM_VOLATILE_P", (RTX), MEM, ASM_OPERANDS, \
2158 ASM_INPUT)->volatil)
759bebca 2159
1ed8ccdb 2160/* 1 if RTX is a mem that cannot trap. */
2161#define MEM_NOTRAP_P(RTX) \
9af5ce0c 2162 (RTL_FLAG_CHECK1 ("MEM_NOTRAP_P", (RTX), MEM)->call)
1ed8ccdb 2163
c6259b83 2164/* The memory attribute block. We provide access macros for each value
2165 in the block and provide defaults if none specified. */
2166#define MEM_ATTRS(RTX) X0MEMATTR (RTX, 1)
2167
ca74b940 2168/* The register attribute block. We provide access macros for each value
2169 in the block and provide defaults if none specified. */
4db4d2a2 2170#define REG_ATTRS(RTX) X0REGATTR (RTX, 1)
ca74b940 2171
d83fcaa1 2172#ifndef GENERATOR_FILE
b5ba9f3a 2173/* For a MEM rtx, the alias set. If 0, this MEM is not in any alias
2174 set, and may alias anything. Otherwise, the MEM can only alias
650e773f 2175 MEMs in a conflicting alias set. This value is set in a
b5ba9f3a 2176 language-dependent manner in the front-end, and should not be
650e773f 2177 altered in the back-end. These set numbers are tested with
2178 alias_sets_conflict_p. */
d83fcaa1 2179#define MEM_ALIAS_SET(RTX) (get_mem_attrs (RTX)->alias)
c6259b83 2180
2181/* For a MEM rtx, the decl it is known to refer to, if it is known to
b10dbbca 2182 refer to part of a DECL. It may also be a COMPONENT_REF. */
d83fcaa1 2183#define MEM_EXPR(RTX) (get_mem_attrs (RTX)->expr)
c6259b83 2184
da443c27 2185/* For a MEM rtx, true if its MEM_OFFSET is known. */
6d58bcba 2186#define MEM_OFFSET_KNOWN_P(RTX) (get_mem_attrs (RTX)->offset_known_p)
da443c27 2187
2188/* For a MEM rtx, the offset from the start of MEM_EXPR. */
6d58bcba 2189#define MEM_OFFSET(RTX) (get_mem_attrs (RTX)->offset)
c6259b83 2190
bd1a81f7 2191/* For a MEM rtx, the address space. */
d83fcaa1 2192#define MEM_ADDR_SPACE(RTX) (get_mem_attrs (RTX)->addrspace)
bd1a81f7 2193
5b2a69fa 2194/* For a MEM rtx, true if its MEM_SIZE is known. */
6d58bcba 2195#define MEM_SIZE_KNOWN_P(RTX) (get_mem_attrs (RTX)->size_known_p)
5b2a69fa 2196
2197/* For a MEM rtx, the size in bytes of the MEM. */
6d58bcba 2198#define MEM_SIZE(RTX) (get_mem_attrs (RTX)->size)
c6259b83 2199
981336a3 2200/* For a MEM rtx, the alignment in bits. We can use the alignment of the
2201 mode as a default when STRICT_ALIGNMENT, but not if not. */
d83fcaa1 2202#define MEM_ALIGN(RTX) (get_mem_attrs (RTX)->align)
2203#else
2204#define MEM_ADDR_SPACE(RTX) ADDR_SPACE_GENERIC
2205#endif
f7c44134 2206
ca74b940 2207/* For a REG rtx, the decl it is known to refer to, if it is known to
2208 refer to part of a DECL. */
2209#define REG_EXPR(RTX) (REG_ATTRS (RTX) == 0 ? 0 : REG_ATTRS (RTX)->decl)
2210
eeb0ae23 2211/* For a REG rtx, the offset from the start of REG_EXPR, if known, as an
2212 HOST_WIDE_INT. */
ca74b940 2213#define REG_OFFSET(RTX) (REG_ATTRS (RTX) == 0 ? 0 : REG_ATTRS (RTX)->offset)
2214
f7c44134 2215/* Copy the attributes that apply to memory locations from RHS to LHS. */
5cc193e7 2216#define MEM_COPY_ATTRIBUTES(LHS, RHS) \
2217 (MEM_VOLATILE_P (LHS) = MEM_VOLATILE_P (RHS), \
1ed8ccdb 2218 MEM_NOTRAP_P (LHS) = MEM_NOTRAP_P (RHS), \
b04fab2a 2219 MEM_READONLY_P (LHS) = MEM_READONLY_P (RHS), \
5cc193e7 2220 MEM_KEEP_ALIAS_SET_P (LHS) = MEM_KEEP_ALIAS_SET_P (RHS), \
c23c6f48 2221 MEM_POINTER (LHS) = MEM_POINTER (RHS), \
c6259b83 2222 MEM_ATTRS (LHS) = MEM_ATTRS (RHS))
b5ba9f3a 2223
3c6858c6 2224/* 1 if RTX is a label_ref for a nonlocal label. */
19d2fe05 2225/* Likewise in an expr_list for a REG_LABEL_OPERAND or
2226 REG_LABEL_TARGET note. */
3c6858c6 2227#define LABEL_REF_NONLOCAL_P(RTX) \
9af5ce0c 2228 (RTL_FLAG_CHECK1 ("LABEL_REF_NONLOCAL_P", (RTX), LABEL_REF)->volatil)
9a293e97 2229
3c6858c6 2230/* 1 if RTX is a code_label that should always be considered to be needed. */
2231#define LABEL_PRESERVE_P(RTX) \
9af5ce0c 2232 (RTL_FLAG_CHECK2 ("LABEL_PRESERVE_P", (RTX), CODE_LABEL, NOTE)->in_struct)
759bebca 2233
3c6858c6 2234/* During sched, 1 if RTX is an insn that must be scheduled together
f9e15121 2235 with the preceding insn. */
3c6858c6 2236#define SCHED_GROUP_P(RTX) \
9af5ce0c 2237 (RTL_FLAG_CHECK4 ("SCHED_GROUP_P", (RTX), DEBUG_INSN, INSN, \
2238 JUMP_INSN, CALL_INSN)->in_struct)
759bebca 2239
2240/* For a SET rtx, SET_DEST is the place that is set
2241 and SET_SRC is the value it is set to. */
9af5ce0c 2242#define SET_DEST(RTX) XC2EXP (RTX, 0, SET, CLOBBER)
2243#define SET_SRC(RTX) XCEXP (RTX, 1, SET)
3c6858c6 2244#define SET_IS_RETURN_P(RTX) \
9af5ce0c 2245 (RTL_FLAG_CHECK1 ("SET_IS_RETURN_P", (RTX), SET)->jump)
759bebca 2246
2247/* For a TRAP_IF rtx, TRAP_CONDITION is an expression. */
017c31d6 2248#define TRAP_CONDITION(RTX) XCEXP (RTX, 0, TRAP_IF)
2249#define TRAP_CODE(RTX) XCEXP (RTX, 1, TRAP_IF)
759bebca 2250
406034fa 2251/* For a COND_EXEC rtx, COND_EXEC_TEST is the condition to base
2252 conditionally executing the code on, COND_EXEC_CODE is the code
2253 to execute if the condition is true. */
017c31d6 2254#define COND_EXEC_TEST(RTX) XCEXP (RTX, 0, COND_EXEC)
2255#define COND_EXEC_CODE(RTX) XCEXP (RTX, 1, COND_EXEC)
406034fa 2256
658782a5 2257/* 1 if RTX is a symbol_ref that addresses this function's rtl
2258 constants pool. */
3c6858c6 2259#define CONSTANT_POOL_ADDRESS_P(RTX) \
9af5ce0c 2260 (RTL_FLAG_CHECK1 ("CONSTANT_POOL_ADDRESS_P", (RTX), SYMBOL_REF)->unchanging)
759bebca 2261
658782a5 2262/* 1 if RTX is a symbol_ref that addresses a value in the file's
2263 tree constant pool. This information is private to varasm.c. */
2264#define TREE_CONSTANT_POOL_ADDRESS_P(RTX) \
9af5ce0c 2265 (RTL_FLAG_CHECK1 ("TREE_CONSTANT_POOL_ADDRESS_P", \
2266 (RTX), SYMBOL_REF)->frame_related)
abf74c5b 2267
3c6858c6 2268/* Used if RTX is a symbol_ref, for machine-specific purposes. */
2269#define SYMBOL_REF_FLAG(RTX) \
9af5ce0c 2270 (RTL_FLAG_CHECK1 ("SYMBOL_REF_FLAG", (RTX), SYMBOL_REF)->volatil)
759bebca 2271
3c6858c6 2272/* 1 if RTX is a symbol_ref that has been the library function in
2273 emit_library_call. */
2274#define SYMBOL_REF_USED(RTX) \
9af5ce0c 2275 (RTL_FLAG_CHECK1 ("SYMBOL_REF_USED", (RTX), SYMBOL_REF)->used)
759bebca 2276
3c6858c6 2277/* 1 if RTX is a symbol_ref for a weak symbol. */
2278#define SYMBOL_REF_WEAK(RTX) \
9af5ce0c 2279 (RTL_FLAG_CHECK1 ("SYMBOL_REF_WEAK", (RTX), SYMBOL_REF)->return_val)
67f79732 2280
7c266bb1 2281/* A pointer attached to the SYMBOL_REF; either SYMBOL_REF_DECL or
2282 SYMBOL_REF_CONSTANT. */
8854855c 2283#define SYMBOL_REF_DATA(RTX) X0ANY ((RTX), 1)
b864739b 2284
2285/* Set RTX's SYMBOL_REF_DECL to DECL. RTX must not be a constant
2286 pool symbol. */
2287#define SET_SYMBOL_REF_DECL(RTX, DECL) \
8854855c 2288 (gcc_assert (!CONSTANT_POOL_ADDRESS_P (RTX)), X0TREE ((RTX), 1) = (DECL))
7c266bb1 2289
b2fd8d52 2290/* The tree (decl or constant) associated with the symbol, or null. */
7c266bb1 2291#define SYMBOL_REF_DECL(RTX) \
8854855c 2292 (CONSTANT_POOL_ADDRESS_P (RTX) ? NULL : X0TREE ((RTX), 1))
7c266bb1 2293
b864739b 2294/* Set RTX's SYMBOL_REF_CONSTANT to C. RTX must be a constant pool symbol. */
2295#define SET_SYMBOL_REF_CONSTANT(RTX, C) \
8854855c 2296 (gcc_assert (CONSTANT_POOL_ADDRESS_P (RTX)), X0CONSTANT ((RTX), 1) = (C))
b864739b 2297
7c266bb1 2298/* The rtx constant pool entry for a symbol, or null. */
2299#define SYMBOL_REF_CONSTANT(RTX) \
8854855c 2300 (CONSTANT_POOL_ADDRESS_P (RTX) ? X0CONSTANT ((RTX), 1) : NULL)
001be062 2301
2302/* A set of flags on a symbol_ref that are, in some respects, redundant with
2303 information derivable from the tree decl associated with this symbol.
2304 Except that we build a *lot* of SYMBOL_REFs that aren't associated with a
2305 decl. In some cases this is a bug. But beyond that, it's nice to cache
2306 this information to avoid recomputing it. Finally, this allows space for
2307 the target to store more than one bit of information, as with
2308 SYMBOL_REF_FLAG. */
8854855c 2309#define SYMBOL_REF_FLAGS(RTX) \
2310 (RTL_FLAG_CHECK1 ("SYMBOL_REF_FLAGS", (RTX), SYMBOL_REF) \
2311 ->u2.symbol_ref_flags)
001be062 2312
2313/* These flags are common enough to be defined for all targets. They
2314 are computed by the default version of targetm.encode_section_info. */
2315
2316/* Set if this symbol is a function. */
2317#define SYMBOL_FLAG_FUNCTION (1 << 0)
2318#define SYMBOL_REF_FUNCTION_P(RTX) \
2319 ((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_FUNCTION) != 0)
2320/* Set if targetm.binds_local_p is true. */
2321#define SYMBOL_FLAG_LOCAL (1 << 1)
2322#define SYMBOL_REF_LOCAL_P(RTX) \
2323 ((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_LOCAL) != 0)
2324/* Set if targetm.in_small_data_p is true. */
2325#define SYMBOL_FLAG_SMALL (1 << 2)
2326#define SYMBOL_REF_SMALL_P(RTX) \
2327 ((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_SMALL) != 0)
2328/* The three-bit field at [5:3] is true for TLS variables; use
2329 SYMBOL_REF_TLS_MODEL to extract the field as an enum tls_model. */
2330#define SYMBOL_FLAG_TLS_SHIFT 3
2331#define SYMBOL_REF_TLS_MODEL(RTX) \
9763286f 2332 ((enum tls_model) ((SYMBOL_REF_FLAGS (RTX) >> SYMBOL_FLAG_TLS_SHIFT) & 7))
001be062 2333/* Set if this symbol is not defined in this translation unit. */
2334#define SYMBOL_FLAG_EXTERNAL (1 << 6)
2335#define SYMBOL_REF_EXTERNAL_P(RTX) \
2336 ((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_EXTERNAL) != 0)
f2d0e9f1 2337/* Set if this symbol has a block_symbol structure associated with it. */
6617cbc1 2338#define SYMBOL_FLAG_HAS_BLOCK_INFO (1 << 7)
2339#define SYMBOL_REF_HAS_BLOCK_INFO_P(RTX) \
2340 ((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_HAS_BLOCK_INFO) != 0)
f2d0e9f1 2341/* Set if this symbol is a section anchor. SYMBOL_REF_ANCHOR_P implies
6617cbc1 2342 SYMBOL_REF_HAS_BLOCK_INFO_P. */
f2d0e9f1 2343#define SYMBOL_FLAG_ANCHOR (1 << 8)
2344#define SYMBOL_REF_ANCHOR_P(RTX) \
2345 ((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_ANCHOR) != 0)
001be062 2346
2347/* Subsequent bits are available for the target to use. */
f2d0e9f1 2348#define SYMBOL_FLAG_MACH_DEP_SHIFT 9
5c5d0ae9 2349#define SYMBOL_FLAG_MACH_DEP (1 << SYMBOL_FLAG_MACH_DEP_SHIFT)
001be062 2350
6617cbc1 2351/* If SYMBOL_REF_HAS_BLOCK_INFO_P (RTX), this is the object_block
2352 structure to which the symbol belongs, or NULL if it has not been
2353 assigned a block. */
f2d0e9f1 2354#define SYMBOL_REF_BLOCK(RTX) (BLOCK_SYMBOL_CHECK (RTX)->block)
2355
6617cbc1 2356/* If SYMBOL_REF_HAS_BLOCK_INFO_P (RTX), this is the offset of RTX from
2357 the first object in SYMBOL_REF_BLOCK (RTX). The value is negative if
2358 RTX has not yet been assigned to a block, or it has not been given an
2359 offset within that block. */
f2d0e9f1 2360#define SYMBOL_REF_BLOCK_OFFSET(RTX) (BLOCK_SYMBOL_CHECK (RTX)->offset)
2361
6540132c 2362/* True if RTX is flagged to be a scheduling barrier. */
2363#define PREFETCH_SCHEDULE_BARRIER_P(RTX) \
9af5ce0c 2364 (RTL_FLAG_CHECK1 ("PREFETCH_SCHEDULE_BARRIER_P", (RTX), PREFETCH)->volatil)
6540132c 2365
3072d30e 2366/* Indicate whether the machine has any sort of auto increment addressing.
2367 If not, we can avoid checking for REG_INC notes. */
2368
2369#if (defined (HAVE_PRE_INCREMENT) || defined (HAVE_PRE_DECREMENT) \
2370 || defined (HAVE_POST_INCREMENT) || defined (HAVE_POST_DECREMENT) \
bb760dac 2371 || defined (HAVE_PRE_MODIFY_DISP) || defined (HAVE_POST_MODIFY_DISP) \
3072d30e 2372 || defined (HAVE_PRE_MODIFY_REG) || defined (HAVE_POST_MODIFY_REG))
2373#define AUTO_INC_DEC
2374#endif
2375
759bebca 2376/* Define a macro to look for REG_INC notes,
2377 but save time on machines where they never exist. */
2378
3072d30e 2379#ifdef AUTO_INC_DEC
017c31d6 2380#define FIND_REG_INC_NOTE(INSN, REG) \
2381 ((REG) != NULL_RTX && REG_P ((REG)) \
2382 ? find_regno_note ((INSN), REG_INC, REGNO (REG)) \
2383 : find_reg_note ((INSN), REG_INC, (REG)))
759bebca 2384#else
017c31d6 2385#define FIND_REG_INC_NOTE(INSN, REG) 0
759bebca 2386#endif
2387
e4e498cf 2388#ifndef HAVE_PRE_INCREMENT
2389#define HAVE_PRE_INCREMENT 0
2390#endif
2391
2392#ifndef HAVE_PRE_DECREMENT
2393#define HAVE_PRE_DECREMENT 0
2394#endif
2395
2396#ifndef HAVE_POST_INCREMENT
2397#define HAVE_POST_INCREMENT 0
2398#endif
2399
2400#ifndef HAVE_POST_DECREMENT
2401#define HAVE_POST_DECREMENT 0
2402#endif
2403
40988080 2404#ifndef HAVE_POST_MODIFY_DISP
2405#define HAVE_POST_MODIFY_DISP 0
2406#endif
2407
2408#ifndef HAVE_POST_MODIFY_REG
2409#define HAVE_POST_MODIFY_REG 0
2410#endif
2411
2412#ifndef HAVE_PRE_MODIFY_DISP
2413#define HAVE_PRE_MODIFY_DISP 0
2414#endif
2415
2416#ifndef HAVE_PRE_MODIFY_REG
2417#define HAVE_PRE_MODIFY_REG 0
2418#endif
2419
c14ad648 2420
2421/* Some architectures do not have complete pre/post increment/decrement
2422 instruction sets, or only move some modes efficiently. These macros
2423 allow us to tune autoincrement generation. */
2424
2425#ifndef USE_LOAD_POST_INCREMENT
2426#define USE_LOAD_POST_INCREMENT(MODE) HAVE_POST_INCREMENT
2427#endif
2428
2429#ifndef USE_LOAD_POST_DECREMENT
2430#define USE_LOAD_POST_DECREMENT(MODE) HAVE_POST_DECREMENT
2431#endif
2432
2433#ifndef USE_LOAD_PRE_INCREMENT
2434#define USE_LOAD_PRE_INCREMENT(MODE) HAVE_PRE_INCREMENT
2435#endif
2436
2437#ifndef USE_LOAD_PRE_DECREMENT
2438#define USE_LOAD_PRE_DECREMENT(MODE) HAVE_PRE_DECREMENT
2439#endif
2440
2441#ifndef USE_STORE_POST_INCREMENT
2442#define USE_STORE_POST_INCREMENT(MODE) HAVE_POST_INCREMENT
2443#endif
2444
2445#ifndef USE_STORE_POST_DECREMENT
2446#define USE_STORE_POST_DECREMENT(MODE) HAVE_POST_DECREMENT
2447#endif
2448
2449#ifndef USE_STORE_PRE_INCREMENT
2450#define USE_STORE_PRE_INCREMENT(MODE) HAVE_PRE_INCREMENT
2451#endif
2452
2453#ifndef USE_STORE_PRE_DECREMENT
2454#define USE_STORE_PRE_DECREMENT(MODE) HAVE_PRE_DECREMENT
2455#endif
759bebca 2456\f
316bc009 2457/* Nonzero when we are generating CONCATs. */
2458extern int generating_concat_p;
2459
723c0ee7 2460/* Nonzero when we are expanding trees to RTL. */
2461extern int currently_expanding_to_rtl;
2462
759bebca 2463/* Generally useful functions. */
2464
ebd9163c 2465/* In explow.c */
3ad4992f 2466extern HOST_WIDE_INT trunc_int_for_mode (HOST_WIDE_INT, enum machine_mode);
5cc04e45 2467extern rtx plus_constant (enum machine_mode, rtx, HOST_WIDE_INT, bool = false);
1bb04728 2468
9588521d 2469/* In rtl.c */
674b05f5 2470extern rtx rtx_alloc_stat (RTX_CODE MEM_STAT_DECL);
2471#define rtx_alloc(c) rtx_alloc_stat (c MEM_STAT_INFO)
e913b5cd 2472extern rtx rtx_alloc_stat_v (RTX_CODE MEM_STAT_DECL, int);
2473#define rtx_alloc_v(c, SZ) rtx_alloc_stat_v (c MEM_STAT_INFO, SZ)
2474#define const_wide_int_alloc(NWORDS) \
2475 rtx_alloc_v (CONST_WIDE_INT, \
2476 (sizeof (struct hwivec_def) \
2477 + ((NWORDS)-1) * sizeof (HOST_WIDE_INT))) \
674b05f5 2478
3ad4992f 2479extern rtvec rtvec_alloc (int);
b447ca78 2480extern rtvec shallow_copy_rtvec (rtvec);
dd9b9fc5 2481extern bool shared_const_p (const_rtx);
3ad4992f 2482extern rtx copy_rtx (rtx);
86736f9e 2483extern void dump_rtx_statistics (void);
9588521d 2484
2485/* In emit-rtl.c */
3ad4992f 2486extern rtx copy_rtx_if_shared (rtx);
9588521d 2487
2488/* In rtl.c */
dd9b9fc5 2489extern unsigned int rtx_size (const_rtx);
2490extern rtx shallow_copy_rtx_stat (const_rtx MEM_STAT_DECL);
674b05f5 2491#define shallow_copy_rtx(a) shallow_copy_rtx_stat (a MEM_STAT_INFO)
dd9b9fc5 2492extern int rtx_equal_p (const_rtx, const_rtx);
9588521d 2493
2494/* In emit-rtl.c */
3ad4992f 2495extern rtvec gen_rtvec_v (int, rtx *);
2496extern rtx gen_reg_rtx (enum machine_mode);
2497extern rtx gen_rtx_REG_offset (rtx, enum machine_mode, unsigned int, int);
1a6a0f2a 2498extern rtx gen_reg_rtx_offset (rtx, enum machine_mode, int);
ae12ddda 2499extern rtx gen_reg_rtx_and_attrs (rtx);
be95c7c7 2500extern rtx_code_label *gen_label_rtx (void);
3ad4992f 2501extern rtx gen_lowpart_common (enum machine_mode, rtx);
9588521d 2502
2503/* In cse.c */
3ad4992f 2504extern rtx gen_lowpart_if_possible (enum machine_mode, rtx);
9588521d 2505
2506/* In emit-rtl.c */
3ad4992f 2507extern rtx gen_highpart (enum machine_mode, rtx);
2508extern rtx gen_highpart_mode (enum machine_mode, enum machine_mode, rtx);
3ad4992f 2509extern rtx operand_subword (rtx, unsigned int, int, enum machine_mode);
9588521d 2510
2511/* In emit-rtl.c */
3ad4992f 2512extern rtx operand_subword_force (rtx, unsigned int, enum machine_mode);
b537bfdb 2513extern bool paradoxical_subreg_p (const_rtx);
b7bf20db 2514extern int subreg_lowpart_p (const_rtx);
3ad4992f 2515extern unsigned int subreg_lowpart_offset (enum machine_mode,
2516 enum machine_mode);
2517extern unsigned int subreg_highpart_offset (enum machine_mode,
2518 enum machine_mode);
80c70e76 2519extern int byte_lowpart_offset (enum machine_mode, enum machine_mode);
3ad4992f 2520extern rtx make_safe_from (rtx, rtx);
98155838 2521extern rtx convert_memory_address_addr_space (enum machine_mode, rtx,
2522 addr_space_t);
2523#define convert_memory_address(to_mode,x) \
2524 convert_memory_address_addr_space ((to_mode), (x), ADDR_SPACE_GENERIC)
3ad4992f 2525extern const char *get_insn_name (int);
447ab0fc 2526extern rtx_insn *get_last_insn_anywhere (void);
3ad4992f 2527extern rtx get_first_nonnote_insn (void);
2528extern rtx get_last_nonnote_insn (void);
2529extern void start_sequence (void);
57c26b3a 2530extern void push_to_sequence (rtx_insn *);
2531extern void push_to_sequence2 (rtx_insn *, rtx_insn *);
3ad4992f 2532extern void end_sequence (void);
e913b5cd 2533#if TARGET_SUPPORTS_WIDE_INT == 0
33274180 2534extern double_int rtx_to_double_int (const_rtx);
e913b5cd 2535#endif
05c25ee6 2536extern void cwi_output_hex (FILE *, const_rtx);
e913b5cd 2537#ifndef GENERATOR_FILE
28e557ef 2538extern rtx immed_wide_int_const (const wide_int_ref &, enum machine_mode);
e913b5cd 2539#endif
2540#if TARGET_SUPPORTS_WIDE_INT == 0
3ad4992f 2541extern rtx immed_double_const (HOST_WIDE_INT, HOST_WIDE_INT,
2542 enum machine_mode);
e913b5cd 2543#endif
791172c5 2544
cde5a3a0 2545/* In loop-iv.c */
2546
2547extern rtx lowpart_subreg (enum machine_mode, rtx, enum machine_mode);
2548
791172c5 2549/* In varasm.c */
3ad4992f 2550extern rtx force_const_mem (enum machine_mode, rtx);
9588521d 2551
9588521d 2552/* In varasm.c */
fdef3332 2553
2554struct function;
3ad4992f 2555extern rtx get_pool_constant (rtx);
2556extern rtx get_pool_constant_mark (rtx, bool *);
dd9b9fc5 2557extern enum machine_mode get_pool_mode (const_rtx);
3ad4992f 2558extern rtx simplify_subtraction (rtx);
756dcd13 2559extern void decide_function_section (tree);
9588521d 2560
2561/* In function.c */
3ad4992f 2562extern rtx assign_stack_local (enum machine_mode, HOST_WIDE_INT, int);
943d8723 2563#define ASLK_REDUCE_ALIGN 1
2564#define ASLK_RECORD_PAD 2
2565extern rtx assign_stack_local_1 (enum machine_mode, HOST_WIDE_INT, int, int);
0ab48139 2566extern rtx assign_stack_temp (enum machine_mode, HOST_WIDE_INT);
2567extern rtx assign_stack_temp_for_type (enum machine_mode, HOST_WIDE_INT, tree);
2568extern rtx assign_temp (tree, int, int);
0a3b3d88 2569
9588521d 2570/* In emit-rtl.c */
722334ea 2571extern rtx_insn *emit_insn_before (rtx, rtx);
2572extern rtx_insn *emit_insn_before_noloc (rtx, rtx, basic_block);
2573extern rtx_insn *emit_insn_before_setloc (rtx, rtx, int);
2574extern rtx_insn *emit_jump_insn_before (rtx, rtx);
2575extern rtx_insn *emit_jump_insn_before_noloc (rtx, rtx);
2576extern rtx_insn *emit_jump_insn_before_setloc (rtx, rtx, int);
2577extern rtx_insn *emit_call_insn_before (rtx, rtx);
2578extern rtx_insn *emit_call_insn_before_noloc (rtx, rtx);
2579extern rtx_insn *emit_call_insn_before_setloc (rtx, rtx, int);
2580extern rtx_insn *emit_debug_insn_before (rtx, rtx);
2581extern rtx_insn *emit_debug_insn_before_noloc (rtx, rtx);
2582extern rtx_insn *emit_debug_insn_before_setloc (rtx, rtx, int);
2583extern rtx_barrier *emit_barrier_before (rtx);
2584extern rtx_insn *emit_label_before (rtx, rtx);
cef3d8ad 2585extern rtx_note *emit_note_before (enum insn_note, rtx);
722334ea 2586extern rtx_insn *emit_insn_after (rtx, rtx);
2587extern rtx_insn *emit_insn_after_noloc (rtx, rtx, basic_block);
2588extern rtx_insn *emit_insn_after_setloc (rtx, rtx, int);
2589extern rtx_insn *emit_jump_insn_after (rtx, rtx);
2590extern rtx_insn *emit_jump_insn_after_noloc (rtx, rtx);
2591extern rtx_insn *emit_jump_insn_after_setloc (rtx, rtx, int);
2592extern rtx_insn *emit_call_insn_after (rtx, rtx);
2593extern rtx_insn *emit_call_insn_after_noloc (rtx, rtx);
2594extern rtx_insn *emit_call_insn_after_setloc (rtx, rtx, int);
2595extern rtx_insn *emit_debug_insn_after (rtx, rtx);
2596extern rtx_insn *emit_debug_insn_after_noloc (rtx, rtx);
2597extern rtx_insn *emit_debug_insn_after_setloc (rtx, rtx, int);
2598extern rtx_barrier *emit_barrier_after (rtx);
2599extern rtx_insn *emit_label_after (rtx, rtx);
cef3d8ad 2600extern rtx_note *emit_note_after (enum insn_note, rtx);
722334ea 2601extern rtx_insn *emit_insn (rtx);
2602extern rtx_insn *emit_debug_insn (rtx);
2603extern rtx_insn *emit_jump_insn (rtx);
2604extern rtx_insn *emit_call_insn (rtx);
2605extern rtx_insn *emit_label (rtx);
e41badc0 2606extern rtx_jump_table_data *emit_jump_table_data (rtx);
722334ea 2607extern rtx_barrier *emit_barrier (void);
cef3d8ad 2608extern rtx_note *emit_note (enum insn_note);
2609extern rtx_note *emit_note_copy (rtx_note *);
722334ea 2610extern rtx_insn *gen_clobber (rtx);
2611extern rtx_insn *emit_clobber (rtx);
2612extern rtx_insn *gen_use (rtx);
2613extern rtx_insn *emit_use (rtx);
2c57d586 2614extern rtx_insn *make_insn_raw (rtx);
3ad4992f 2615extern void add_function_usage_to (rtx, rtx);
ec22da62 2616extern rtx_call_insn *last_call_insn (void);
7bac25b3 2617extern rtx_insn *previous_insn (rtx);
2618extern rtx_insn *next_insn (rtx);
2619extern rtx_insn *prev_nonnote_insn (rtx);
2620extern rtx_insn *prev_nonnote_insn_bb (rtx);
2621extern rtx_insn *next_nonnote_insn (rtx);
2622extern rtx_insn *next_nonnote_insn_bb (rtx);
2623extern rtx_insn *prev_nondebug_insn (rtx);
2624extern rtx_insn *next_nondebug_insn (rtx);
2625extern rtx_insn *prev_nonnote_nondebug_insn (rtx);
2626extern rtx_insn *next_nonnote_nondebug_insn (rtx);
2627extern rtx_insn *prev_real_insn (rtx);
2628extern rtx_insn *next_real_insn (rtx);
2629extern rtx_insn *prev_active_insn (rtx);
2630extern rtx_insn *next_active_insn (rtx);
52d07779 2631extern int active_insn_p (const_rtx);
0be88abd 2632extern rtx_insn *next_cc0_user (rtx);
2633extern rtx_insn *prev_cc0_setter (rtx);
9588521d 2634
23a070f3 2635/* In emit-rtl.c */
dd9b9fc5 2636extern int insn_line (const_rtx);
2637extern const char * insn_file (const_rtx);
23a070f3 2638extern tree insn_scope (const_rtx);
0e7ae557 2639extern expanded_location insn_location (const_rtx);
5169661d 2640extern location_t prologue_location, epilogue_location;
84c71503 2641
9588521d 2642/* In jump.c */
3ad4992f 2643extern enum rtx_code reverse_condition (enum rtx_code);
2644extern enum rtx_code reverse_condition_maybe_unordered (enum rtx_code);
2645extern enum rtx_code swap_condition (enum rtx_code);
2646extern enum rtx_code unsigned_condition (enum rtx_code);
2647extern enum rtx_code signed_condition (enum rtx_code);
2648extern void mark_jump_label (rtx, rtx, int);
9588521d 2649
9588521d 2650/* In jump.c */
f68c5086 2651extern rtx_insn *delete_related_insns (rtx);
9588521d 2652
2653/* In recog.c */
3ad4992f 2654extern rtx *find_constant_term_loc (rtx *);
9588521d 2655
2656/* In emit-rtl.c */
bffa1357 2657extern rtx_insn *try_split (rtx, rtx, int);
3cd757b1 2658extern int split_branch_probability;
9588521d 2659
2660/* In unknown file */
3ad4992f 2661extern rtx split_insns (rtx, rtx);
9588521d 2662
2663/* In simplify-rtx.c */
3b723a04 2664extern rtx simplify_const_unary_operation (enum rtx_code, enum machine_mode,
2665 rtx, enum machine_mode);
3ad4992f 2666extern rtx simplify_unary_operation (enum rtx_code, enum machine_mode, rtx,
2667 enum machine_mode);
3b723a04 2668extern rtx simplify_const_binary_operation (enum rtx_code, enum machine_mode,
2669 rtx, rtx);
3ad4992f 2670extern rtx simplify_binary_operation (enum rtx_code, enum machine_mode, rtx,
2671 rtx);
2672extern rtx simplify_ternary_operation (enum rtx_code, enum machine_mode,
2673 enum machine_mode, rtx, rtx, rtx);
089b4730 2674extern rtx simplify_const_relational_operation (enum rtx_code,
2675 enum machine_mode, rtx, rtx);
3ad4992f 2676extern rtx simplify_relational_operation (enum rtx_code, enum machine_mode,
089b4730 2677 enum machine_mode, rtx, rtx);
3ad4992f 2678extern rtx simplify_gen_binary (enum rtx_code, enum machine_mode, rtx, rtx);
2679extern rtx simplify_gen_unary (enum rtx_code, enum machine_mode, rtx,
2680 enum machine_mode);
2681extern rtx simplify_gen_ternary (enum rtx_code, enum machine_mode,
2682 enum machine_mode, rtx, rtx, rtx);
2683extern rtx simplify_gen_relational (enum rtx_code, enum machine_mode,
2684 enum machine_mode, rtx, rtx);
2685extern rtx simplify_subreg (enum machine_mode, rtx, enum machine_mode,
2686 unsigned int);
2687extern rtx simplify_gen_subreg (enum machine_mode, rtx, enum machine_mode,
2688 unsigned int);
bf4652ac 2689extern rtx simplify_replace_fn_rtx (rtx, const_rtx,
35af0188 2690 rtx (*fn) (rtx, const_rtx, void *), void *);
dd9b9fc5 2691extern rtx simplify_replace_rtx (rtx, const_rtx, rtx);
9f627b1a 2692extern rtx simplify_rtx (const_rtx);
3ad4992f 2693extern rtx avoid_constant_pool_reference (rtx);
9845d120 2694extern rtx delegitimize_mem_from_attrs (rtx);
dd9b9fc5 2695extern bool mode_signbit_p (enum machine_mode, const_rtx);
f92430e0 2696extern bool val_signbit_p (enum machine_mode, unsigned HOST_WIDE_INT);
2697extern bool val_signbit_known_set_p (enum machine_mode,
2698 unsigned HOST_WIDE_INT);
2699extern bool val_signbit_known_clear_p (enum machine_mode,
2700 unsigned HOST_WIDE_INT);
9588521d 2701
ac502adf 2702/* In reginfo.c */
b805295e 2703extern enum machine_mode choose_hard_reg_mode (unsigned int, unsigned int,
2704 bool);
9588521d 2705
2706/* In emit-rtl.c */
3a286419 2707extern rtx set_for_reg_notes (rtx);
3ad4992f 2708extern rtx set_unique_reg_note (rtx, enum reg_note, rtx);
41cf444a 2709extern rtx set_dst_reg_note (rtx, enum reg_note, rtx, rtx);
3072d30e 2710extern void set_insn_deleted (rtx);
ea0cb7ae 2711
0dbd1c74 2712/* Functions in rtlanal.c */
2713
6531eca9 2714/* Single set is implemented as macro for performance reasons. */
2715#define single_set(I) (INSN_P (I) \
2716 ? (GET_CODE (PATTERN (I)) == SET \
2717 ? PATTERN (I) : single_set_1 (I)) \
2718 : NULL_RTX)
a0bb0d20 2719#define single_set_1(I) single_set_2 (I, PATTERN (I))
6531eca9 2720
f2756aab 2721/* Structure used for passing data to REPLACE_LABEL. */
b3e7c666 2722struct replace_label_data
f2756aab 2723{
2724 rtx r1;
2725 rtx r2;
cda612f5 2726 bool update_label_nuses;
b3e7c666 2727};
f2756aab 2728
87cf5753 2729extern enum machine_mode get_address_mode (rtx mem);
dd9b9fc5 2730extern int rtx_addr_can_trap_p (const_rtx);
2731extern bool nonzero_address_p (const_rtx);
2732extern int rtx_unstable_p (const_rtx);
52d07779 2733extern bool rtx_varies_p (const_rtx, bool);
2734extern bool rtx_addr_varies_p (const_rtx, bool);
cf7fb72d 2735extern rtx get_call_rtx_from (rtx);
dd9b9fc5 2736extern HOST_WIDE_INT get_integer_term (const_rtx);
2737extern rtx get_related_value (const_rtx);
2738extern bool offset_within_block_p (const_rtx, HOST_WIDE_INT);
e0ab7256 2739extern void split_const (rtx, rtx *, rtx *);
0a98b6d9 2740extern bool unsigned_reg_p (rtx);
dd9b9fc5 2741extern int reg_mentioned_p (const_rtx, const_rtx);
2742extern int count_occurrences (const_rtx, const_rtx, int);
2743extern int reg_referenced_p (const_rtx, const_rtx);
2744extern int reg_used_between_p (const_rtx, const_rtx, const_rtx);
7ecb5bb2 2745extern int reg_set_between_p (const_rtx, const_rtx, const_rtx);
3ad4992f 2746extern int commutative_operand_precedence (rtx);
1f3b83af 2747extern bool swap_commutative_operands_p (rtx, rtx);
5493cb9a 2748extern int modified_between_p (const_rtx, const_rtx, const_rtx);
dd9b9fc5 2749extern int no_labels_between_p (const_rtx, const_rtx);
5493cb9a 2750extern int modified_in_p (const_rtx, const_rtx);
7ecb5bb2 2751extern int reg_set_p (const_rtx, const_rtx);
dd9b9fc5 2752extern rtx single_set_2 (const_rtx, const_rtx);
2753extern int multiple_sets (const_rtx);
2754extern int set_noop_p (const_rtx);
b7bf20db 2755extern int noop_move_p (const_rtx);
3ad4992f 2756extern rtx find_last_value (rtx, rtx *, rtx, int);
dd9b9fc5 2757extern int refers_to_regno_p (unsigned int, unsigned int, const_rtx, rtx *);
2758extern int reg_overlap_mentioned_p (const_rtx, const_rtx);
81a410b1 2759extern const_rtx set_of (const_rtx, const_rtx);
effd1640 2760extern void record_hard_reg_sets (rtx, const_rtx, void *);
2761extern void record_hard_reg_uses (rtx *, void *);
2762#ifdef HARD_CONST
1630ba6e 2763extern void find_all_hard_reg_sets (const_rtx, HARD_REG_SET *, bool);
effd1640 2764#endif
81a410b1 2765extern void note_stores (const_rtx, void (*) (rtx, const_rtx, void *), void *);
3ad4992f 2766extern void note_uses (rtx *, void (*) (rtx *, void *), void *);
dd9b9fc5 2767extern int dead_or_set_p (const_rtx, const_rtx);
2768extern int dead_or_set_regno_p (const_rtx, unsigned int);
2769extern rtx find_reg_note (const_rtx, enum reg_note, const_rtx);
2770extern rtx find_regno_note (const_rtx, enum reg_note, unsigned int);
2771extern rtx find_reg_equal_equiv_note (const_rtx);
2772extern rtx find_constant_src (const_rtx);
2773extern int find_reg_fusage (const_rtx, enum rtx_code, const_rtx);
2774extern int find_regno_fusage (const_rtx, enum rtx_code, unsigned int);
5859ee98 2775extern rtx alloc_reg_note (enum reg_note, rtx, rtx);
a1ddb869 2776extern void add_reg_note (rtx, enum reg_note, rtx);
9eb946de 2777extern void add_int_reg_note (rtx, enum reg_note, int);
2778extern void add_shallow_copy_of_reg_note (rtx, rtx);
dd9b9fc5 2779extern void remove_note (rtx, const_rtx);
f16feee2 2780extern void remove_reg_equal_equiv_notes (rtx);
09669349 2781extern void remove_reg_equal_equiv_notes_for_regno (unsigned int);
dd9b9fc5 2782extern int side_effects_p (const_rtx);
2783extern int volatile_refs_p (const_rtx);
2784extern int volatile_insn_p (const_rtx);
77ad8e5a 2785extern int may_trap_p_1 (const_rtx, unsigned);
dd9b9fc5 2786extern int may_trap_p (const_rtx);
dd9b9fc5 2787extern int may_trap_or_fault_p (const_rtx);
e38def9c 2788extern bool can_throw_internal (const_rtx);
2789extern bool can_throw_external (const_rtx);
2790extern bool insn_could_throw_p (const_rtx);
2791extern bool insn_nothrow_p (const_rtx);
2792extern bool can_nonlocal_goto (const_rtx);
2793extern void copy_reg_eh_region_note_forward (rtx, rtx, rtx);
9af5ce0c 2794extern void copy_reg_eh_region_note_backward (rtx, rtx, rtx);
dd9b9fc5 2795extern int inequality_comparisons_p (const_rtx);
3ad4992f 2796extern rtx replace_rtx (rtx, rtx, rtx);
3ad4992f 2797extern int replace_label (rtx *, void *);
2798extern int rtx_referenced_p (rtx, rtx);
c86d86ff 2799extern bool tablejump_p (const_rtx, rtx *, rtx_jump_table_data **);
dd9b9fc5 2800extern int computed_jump_p (const_rtx);
53ea4c57 2801extern bool tls_referenced_p (rtx);
e1ab7874 2802
3ad4992f 2803typedef int (*rtx_function) (rtx *, void *);
2804extern int for_each_rtx (rtx *, rtx_function, void *);
3190f8ed 2805extern int for_each_rtx_in_insn (rtx_insn **, rtx_function, void *);
e1ab7874 2806
1f864115 2807/* Callback for for_each_inc_dec, to process the autoinc operation OP
2808 within MEM that sets DEST to SRC + SRCOFF, or SRC if SRCOFF is
2809 NULL. The callback is passed the same opaque ARG passed to
2810 for_each_inc_dec. Return zero to continue looking for other
2811 autoinc operations, -1 to skip OP's operands, and any other value
2812 to interrupt the traversal and return that value to the caller of
2813 for_each_inc_dec. */
2814typedef int (*for_each_inc_dec_fn) (rtx mem, rtx op, rtx dest, rtx src,
2815 rtx srcoff, void *arg);
ebabb7a3 2816extern int for_each_inc_dec (rtx_insn **, for_each_inc_dec_fn, void *arg);
1f864115 2817
e1ab7874 2818typedef int (*rtx_equal_p_callback_function) (const_rtx *, const_rtx *,
2819 rtx *, rtx *);
2820extern int rtx_equal_p_cb (const_rtx, const_rtx,
2821 rtx_equal_p_callback_function);
2822
2823typedef int (*hash_rtx_callback_function) (const_rtx, enum machine_mode, rtx *,
2824 enum machine_mode *);
2825extern unsigned hash_rtx_cb (const_rtx, enum machine_mode, int *, int *,
2826 bool, hash_rtx_callback_function);
2827
3ad4992f 2828extern rtx regno_use_in (unsigned int, rtx);
dd9b9fc5 2829extern int auto_inc_p (const_rtx);
2830extern int in_expr_list_p (const_rtx, const_rtx);
6e16e157 2831extern void remove_node_from_expr_list (const_rtx, rtx_expr_list **);
dd9b9fc5 2832extern int loc_mentioned_in_p (rtx *, const_rtx);
3ccd8550 2833extern rtx_insn *find_first_parameter_load (rtx, rtx);
5493cb9a 2834extern bool keep_with_call_p (const_rtx);
dd9b9fc5 2835extern bool label_is_jump_target_p (const_rtx, const_rtx);
f529eb25 2836extern int insn_rtx_cost (rtx, bool);
759bebca 2837
ea92ba80 2838/* Given an insn and condition, return a canonical description of
2839 the test being made. */
2d650f54 2840extern rtx canonicalize_condition (rtx_insn *, rtx, int, rtx_insn **, rtx,
2841 int, int);
ea92ba80 2842
2843/* Given a JUMP_INSN, return a canonical description of the test
2844 being made. */
2d650f54 2845extern rtx get_condition (rtx_insn *, rtx_insn **, int, int);
ea92ba80 2846
9680c846 2847/* Information about a subreg of a hard register. */
2848struct subreg_info
2849{
2850 /* Offset of first hard register involved in the subreg. */
2851 int offset;
2852 /* Number of hard registers involved in the subreg. */
2853 int nregs;
2854 /* Whether this subreg can be represented as a hard reg with the new
2855 mode. */
2856 bool representable_p;
2857};
2858
2859extern void subreg_get_info (unsigned int, enum machine_mode,
2860 unsigned int, enum machine_mode,
2861 struct subreg_info *);
2862
1f3233d1 2863/* lists.c */
2864
8e56831f 2865extern void free_EXPR_LIST_list (rtx_expr_list **);
54267fdf 2866extern void free_INSN_LIST_list (rtx_insn_list **);
effd1640 2867extern void free_EXPR_LIST_node (rtx);
2868extern void free_INSN_LIST_node (rtx);
54267fdf 2869extern rtx_insn_list *alloc_INSN_LIST (rtx, rtx);
2870extern rtx_insn_list *copy_INSN_LIST (rtx_insn_list *);
2871extern rtx_insn_list *concat_INSN_LIST (rtx_insn_list *, rtx_insn_list *);
8e56831f 2872extern rtx_expr_list *alloc_EXPR_LIST (int, rtx, rtx);
54267fdf 2873extern void remove_free_INSN_LIST_elem (rtx_insn *, rtx_insn_list **);
e1ab7874 2874extern rtx remove_list_elem (rtx, rtx *);
54267fdf 2875extern rtx_insn *remove_free_INSN_LIST_node (rtx_insn_list **);
8e56831f 2876extern rtx remove_free_EXPR_LIST_node (rtx_expr_list **);
e1ab7874 2877
7cc785dd 2878
ac502adf 2879/* reginfo.c */
7cc785dd 2880
47dd2e78 2881/* Resize reg info. */
a7dcf969 2882extern bool resize_reg_info (void);
b6c8b728 2883/* Free up register info memory. */
3ad4992f 2884extern void free_reg_info (void);
e8eed2f8 2885extern void init_subregs_of_mode (void);
2886extern void finish_subregs_of_mode (void);
b6c8b728 2887
7cc785dd 2888/* recog.c */
78f55ca8 2889extern rtx extract_asm_operands (rtx);
52d07779 2890extern int asm_noperands (const_rtx);
3ad4992f 2891extern const char *decode_asm_operands (rtx, rtx *, rtx **, const char **,
09fb10e8 2892 enum machine_mode *, location_t *);
431cd7a8 2893extern void get_referenced_operands (const char *, bool *, unsigned int);
759bebca 2894
3ad4992f 2895extern enum reg_class reg_preferred_class (int);
2896extern enum reg_class reg_alternate_class (int);
66d9a7b9 2897extern enum reg_class reg_allocno_class (int);
a7dcf969 2898extern void setup_reg_classes (int, enum reg_class, enum reg_class,
2899 enum reg_class);
759bebca 2900
3072d30e 2901extern void split_all_insns (void);
2a1990e9 2902extern unsigned int split_all_insns_noflow (void);
14d66741 2903
1a60f06a 2904#define MAX_SAVED_CONST_INT 64
1f3233d1 2905extern GTY(()) rtx const_int_rtx[MAX_SAVED_CONST_INT * 2 + 1];
1a60f06a 2906
57c097d5 2907#define const0_rtx (const_int_rtx[MAX_SAVED_CONST_INT])
2908#define const1_rtx (const_int_rtx[MAX_SAVED_CONST_INT+1])
2909#define const2_rtx (const_int_rtx[MAX_SAVED_CONST_INT+2])
2910#define constm1_rtx (const_int_rtx[MAX_SAVED_CONST_INT-1])
1f3233d1 2911extern GTY(()) rtx const_true_rtx;
ca9902fc 2912
ba8dfb08 2913extern GTY(()) rtx const_tiny_rtx[4][(int) MAX_MACHINE_MODE];
ca9902fc 2914
f220c8f0 2915/* Returns a constant 0 rtx in mode MODE. Integer modes are treated the
ca9902fc 2916 same as VOIDmode. */
2917
2918#define CONST0_RTX(MODE) (const_tiny_rtx[0][(int) (MODE)])
2919
ba8dfb08 2920/* Likewise, for the constants 1 and 2 and -1. */
ca9902fc 2921
2922#define CONST1_RTX(MODE) (const_tiny_rtx[1][(int) (MODE)])
2923#define CONST2_RTX(MODE) (const_tiny_rtx[2][(int) (MODE)])
ba8dfb08 2924#define CONSTM1_RTX(MODE) (const_tiny_rtx[3][(int) (MODE)])
759bebca 2925
9737dd95 2926extern GTY(()) rtx pc_rtx;
2927extern GTY(()) rtx cc0_rtx;
2928extern GTY(()) rtx ret_rtx;
2929extern GTY(()) rtx simple_return_rtx;
7d7b0bac 2930
57c097d5 2931/* If HARD_FRAME_POINTER_REGNUM is defined, then a special dummy reg
2932 is used to represent the frame pointer. This is because the
2933 hard frame pointer and the automatic variables are separated by an amount
2934 that cannot be determined until after register allocation. We can assume
2935 that in this case ELIMINABLE_REGS will be defined, one action of which
a7dce381 2936 will be to eliminate FRAME_POINTER_REGNUM into HARD_FRAME_POINTER_REGNUM. */
57c097d5 2937#ifndef HARD_FRAME_POINTER_REGNUM
2938#define HARD_FRAME_POINTER_REGNUM FRAME_POINTER_REGNUM
2939#endif
2940
5ae82d58 2941#ifndef HARD_FRAME_POINTER_IS_FRAME_POINTER
2942#define HARD_FRAME_POINTER_IS_FRAME_POINTER \
2943 (HARD_FRAME_POINTER_REGNUM == FRAME_POINTER_REGNUM)
2944#endif
2945
2946#ifndef HARD_FRAME_POINTER_IS_ARG_POINTER
2947#define HARD_FRAME_POINTER_IS_ARG_POINTER \
2948 (HARD_FRAME_POINTER_REGNUM == ARG_POINTER_REGNUM)
2949#endif
2950
57c097d5 2951/* Index labels for global_rtl. */
2952enum global_rtl_index
1a60f06a 2953{
57c097d5 2954 GR_STACK_POINTER,
2955 GR_FRAME_POINTER,
2956/* For register elimination to work properly these hard_frame_pointer_rtx,
2957 frame_pointer_rtx, and arg_pointer_rtx must be the same if they refer to
2958 the same register. */
2959#if FRAME_POINTER_REGNUM == ARG_POINTER_REGNUM
2960 GR_ARG_POINTER = GR_FRAME_POINTER,
2961#endif
5ae82d58 2962#if HARD_FRAME_POINTER_IS_FRAME_POINTER
57c097d5 2963 GR_HARD_FRAME_POINTER = GR_FRAME_POINTER,
2964#else
2965 GR_HARD_FRAME_POINTER,
2966#endif
2967#if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
5ae82d58 2968#if HARD_FRAME_POINTER_IS_ARG_POINTER
57c097d5 2969 GR_ARG_POINTER = GR_HARD_FRAME_POINTER,
2970#else
2971 GR_ARG_POINTER,
2972#endif
2973#endif
2974 GR_VIRTUAL_INCOMING_ARGS,
2975 GR_VIRTUAL_STACK_ARGS,
2976 GR_VIRTUAL_STACK_DYNAMIC,
2977 GR_VIRTUAL_OUTGOING_ARGS,
2978 GR_VIRTUAL_CFA,
60778e62 2979 GR_VIRTUAL_PREFERRED_STACK_BOUNDARY,
57c097d5 2980
2981 GR_MAX
2982};
2983
679bcc8d 2984/* Target-dependent globals. */
2985struct GTY(()) target_rtl {
2986 /* All references to the hard registers in global_rtl_index go through
2987 these unique rtl objects. On machines where the frame-pointer and
2988 arg-pointer are the same register, they use the same unique object.
2989
2990 After register allocation, other rtl objects which used to be pseudo-regs
2991 may be clobbered to refer to the frame-pointer register.
2992 But references that were originally to the frame-pointer can be
2993 distinguished from the others because they contain frame_pointer_rtx.
2994
2995 When to use frame_pointer_rtx and hard_frame_pointer_rtx is a little
2996 tricky: until register elimination has taken place hard_frame_pointer_rtx
2997 should be used if it is being set, and frame_pointer_rtx otherwise. After
2998 register elimination hard_frame_pointer_rtx should always be used.
2999 On machines where the two registers are same (most) then these are the
3000 same. */
3001 rtx x_global_rtl[GR_MAX];
3002
3003 /* A unique representation of (REG:Pmode PIC_OFFSET_TABLE_REGNUM). */
3004 rtx x_pic_offset_table_rtx;
3005
3006 /* A unique representation of (REG:Pmode RETURN_ADDRESS_POINTER_REGNUM).
3007 This is used to implement __builtin_return_address for some machines;
3008 see for instance the MIPS port. */
3009 rtx x_return_address_pointer_rtx;
3010
3011 /* Commonly used RTL for hard registers. These objects are not
3012 necessarily unique, so we allocate them separately from global_rtl.
3013 They are initialized once per compilation unit, then copied into
3014 regno_reg_rtx at the beginning of each function. */
3015 rtx x_initial_regno_reg_rtx[FIRST_PSEUDO_REGISTER];
75f8637a 3016
3017 /* A sample (mem:M stack_pointer_rtx) rtx for each mode M. */
3018 rtx x_top_of_stack[MAX_MACHINE_MODE];
eb2c25b5 3019
3020 /* Static hunks of RTL used by the aliasing code; these are treated
3021 as persistent to avoid unnecessary RTL allocations. */
3022 rtx x_static_reg_base_value[FIRST_PSEUDO_REGISTER];
d83fcaa1 3023
3024 /* The default memory attributes for each mode. */
3025 struct mem_attrs *x_mode_mem_attrs[(int) MAX_MACHINE_MODE];
e0ff5636 3026
3027 /* Track if RTL has been initialized. */
3028 bool target_specific_initialized;
679bcc8d 3029};
3030
3031extern GTY(()) struct target_rtl default_target_rtl;
3032#if SWITCHABLE_TARGET
3033extern struct target_rtl *this_target_rtl;
3034#else
3035#define this_target_rtl (&default_target_rtl)
3036#endif
3037
3038#define global_rtl \
3039 (this_target_rtl->x_global_rtl)
3040#define pic_offset_table_rtx \
3041 (this_target_rtl->x_pic_offset_table_rtx)
3042#define return_address_pointer_rtx \
3043 (this_target_rtl->x_return_address_pointer_rtx)
75f8637a 3044#define top_of_stack \
3045 (this_target_rtl->x_top_of_stack)
d83fcaa1 3046#define mode_mem_attrs \
3047 (this_target_rtl->x_mode_mem_attrs)
57c097d5 3048
759bebca 3049/* All references to certain hard regs, except those created
3050 by allocating pseudo regs into them (when that's possible),
3051 go through these unique rtx objects. */
57c097d5 3052#define stack_pointer_rtx (global_rtl[GR_STACK_POINTER])
3053#define frame_pointer_rtx (global_rtl[GR_FRAME_POINTER])
3054#define hard_frame_pointer_rtx (global_rtl[GR_HARD_FRAME_POINTER])
3055#define arg_pointer_rtx (global_rtl[GR_ARG_POINTER])
1a60f06a 3056
d83fcaa1 3057#ifndef GENERATOR_FILE
3058/* Return the attributes of a MEM rtx. */
3059static inline struct mem_attrs *
3060get_mem_attrs (const_rtx x)
3061{
3062 struct mem_attrs *attrs;
3063
3064 attrs = MEM_ATTRS (x);
3065 if (!attrs)
3066 attrs = mode_mem_attrs[(int) GET_MODE (x)];
3067 return attrs;
3068}
3069#endif
3070
3ad7bb1c 3071/* Include the RTL generation functions. */
3072
fdef3332 3073#ifndef GENERATOR_FILE
3ad7bb1c 3074#include "genrtl.h"
09fb10e8 3075#undef gen_rtx_ASM_INPUT
09fb10e8 3076#define gen_rtx_ASM_INPUT(MODE, ARG0) \
3077 gen_rtx_fmt_si (ASM_INPUT, (MODE), (ARG0), 0)
3078#define gen_rtx_ASM_INPUT_loc(MODE, ARG0, LOC) \
3079 gen_rtx_fmt_si (ASM_INPUT, (MODE), (ARG0), (LOC))
3ad7bb1c 3080#endif
3081
b5ba9f3a 3082/* There are some RTL codes that require special attention; the
3083 generation functions included above do the raw handling. If you
8fd5918e 3084 add to this list, modify special_rtx in gengenrtl.c as well. */
3ad7bb1c 3085
ede4900a 3086extern rtx_expr_list *gen_rtx_EXPR_LIST (enum machine_mode, rtx, rtx);
13be9dc6 3087extern rtx_insn_list *gen_rtx_INSN_LIST (enum machine_mode, rtx, rtx);
3ad4992f 3088extern rtx gen_rtx_CONST_INT (enum machine_mode, HOST_WIDE_INT);
3089extern rtx gen_rtx_CONST_VECTOR (enum machine_mode, rtvec);
3090extern rtx gen_raw_REG (enum machine_mode, int);
3091extern rtx gen_rtx_REG (enum machine_mode, unsigned);
3092extern rtx gen_rtx_SUBREG (enum machine_mode, rtx, int);
3093extern rtx gen_rtx_MEM (enum machine_mode, rtx);
e1398578 3094extern rtx gen_rtx_VAR_LOCATION (enum machine_mode, tree, rtx,
3095 enum var_init_status);
3ad7bb1c 3096
1e9d55d7 3097#define GEN_INT(N) gen_rtx_CONST_INT (VOIDmode, (N))
3ad7bb1c 3098
759bebca 3099/* Virtual registers are used during RTL generation to refer to locations into
3100 the stack frame when the actual location isn't known until RTL generation
3101 is complete. The routine instantiate_virtual_regs replaces these with
3102 the proper value, which is normally {frame,arg,stack}_pointer_rtx plus
3103 a constant. */
3104
3105#define FIRST_VIRTUAL_REGISTER (FIRST_PSEUDO_REGISTER)
3106
3107/* This points to the first word of the incoming arguments passed on the stack,
3108 either by the caller or by the callee when pretending it was passed by the
3109 caller. */
3110
57c097d5 3111#define virtual_incoming_args_rtx (global_rtl[GR_VIRTUAL_INCOMING_ARGS])
759bebca 3112
3113#define VIRTUAL_INCOMING_ARGS_REGNUM (FIRST_VIRTUAL_REGISTER)
3114
511d786c 3115/* If FRAME_GROWS_DOWNWARD, this points to immediately above the first
759bebca 3116 variable on the stack. Otherwise, it points to the first variable on
3117 the stack. */
3118
57c097d5 3119#define virtual_stack_vars_rtx (global_rtl[GR_VIRTUAL_STACK_ARGS])
759bebca 3120
3121#define VIRTUAL_STACK_VARS_REGNUM ((FIRST_VIRTUAL_REGISTER) + 1)
3122
3123/* This points to the location of dynamically-allocated memory on the stack
3124 immediately after the stack pointer has been adjusted by the amount
3125 desired. */
3126
57c097d5 3127#define virtual_stack_dynamic_rtx (global_rtl[GR_VIRTUAL_STACK_DYNAMIC])
759bebca 3128
3129#define VIRTUAL_STACK_DYNAMIC_REGNUM ((FIRST_VIRTUAL_REGISTER) + 2)
3130
3131/* This points to the location in the stack at which outgoing arguments should
3132 be written when the stack is pre-pushed (arguments pushed using push
3133 insns always use sp). */
3134
57c097d5 3135#define virtual_outgoing_args_rtx (global_rtl[GR_VIRTUAL_OUTGOING_ARGS])
759bebca 3136
3137#define VIRTUAL_OUTGOING_ARGS_REGNUM ((FIRST_VIRTUAL_REGISTER) + 3)
3138
ec37ccb4 3139/* This points to the Canonical Frame Address of the function. This
de132707 3140 should correspond to the CFA produced by INCOMING_FRAME_SP_OFFSET,
ec37ccb4 3141 but is calculated relative to the arg pointer for simplicity; the
f220c8f0 3142 frame pointer nor stack pointer are necessarily fixed relative to
ec37ccb4 3143 the CFA until after reload. */
3144
57c097d5 3145#define virtual_cfa_rtx (global_rtl[GR_VIRTUAL_CFA])
ec37ccb4 3146
3147#define VIRTUAL_CFA_REGNUM ((FIRST_VIRTUAL_REGISTER) + 4)
3148
60778e62 3149#define LAST_VIRTUAL_POINTER_REGISTER ((FIRST_VIRTUAL_REGISTER) + 4)
3150
3151/* This is replaced by crtl->preferred_stack_boundary / BITS_PER_UNIT
3152 when finalized. */
3153
3154#define virtual_preferred_stack_boundary_rtx \
3155 (global_rtl[GR_VIRTUAL_PREFERRED_STACK_BOUNDARY])
3156
3157#define VIRTUAL_PREFERRED_STACK_BOUNDARY_REGNUM \
3158 ((FIRST_VIRTUAL_REGISTER) + 5)
3159
3160#define LAST_VIRTUAL_REGISTER ((FIRST_VIRTUAL_REGISTER) + 5)
759bebca 3161
2b96c5f6 3162/* Nonzero if REGNUM is a pointer into the stack frame. */
1a97be37 3163#define REGNO_PTR_FRAME_P(REGNUM) \
2b96c5f6 3164 ((REGNUM) == STACK_POINTER_REGNUM \
3165 || (REGNUM) == FRAME_POINTER_REGNUM \
3166 || (REGNUM) == HARD_FRAME_POINTER_REGNUM \
3167 || (REGNUM) == ARG_POINTER_REGNUM \
3168 || ((REGNUM) >= FIRST_VIRTUAL_REGISTER \
60778e62 3169 && (REGNUM) <= LAST_VIRTUAL_POINTER_REGISTER))
2b96c5f6 3170
14e6e4d4 3171/* REGNUM never really appearing in the INSN stream. */
47c251e5 3172#define INVALID_REGNUM (~(unsigned int) 0)
14e6e4d4 3173
2df386e3 3174/* REGNUM for which no debug information can be generated. */
3175#define IGNORED_DWARF_REGNUM (INVALID_REGNUM - 1)
3176
3ad4992f 3177extern rtx output_constant_def (tree, int);
6e326506 3178extern rtx lookup_constant_def (tree);
759bebca 3179
759bebca 3180/* Nonzero after end of reload pass.
b0a37f5c 3181 Set to 1 or 0 by reload1.c. */
759bebca 3182
3183extern int reload_completed;
3184
8af3db02 3185/* Nonzero after thread_prologue_and_epilogue_insns has run. */
3186extern int epilogue_completed;
3187
759bebca 3188/* Set to 1 while reload_as_needed is operating.
3189 Required by some machines to handle any generated moves differently. */
3190
3191extern int reload_in_progress;
3192
c6a6cdaa 3193/* Set to 1 while in lra. */
3194extern int lra_in_progress;
3195
e1ba4a27 3196/* This macro indicates whether you may create a new
3197 pseudo-register. */
3198
3199#define can_create_pseudo_p() (!reload_in_progress && !reload_completed)
3200
3e6933a8 3201#ifdef STACK_REGS
3202/* Nonzero after end of regstack pass.
3203 Set to 1 or 0 by reg-stack.c. */
3204extern int regstack_completed;
3205#endif
3206
759bebca 3207/* If this is nonzero, we do not bother generating VOLATILE
3208 around volatile memory references, and we are willing to
3209 output indirect addresses. If cse is to follow, we reject
3210 indirect addresses so a useful potential cse is generated;
3211 if it is used only once, instruction combination will produce
3212 the same indirect address eventually. */
3213extern int cse_not_expected;
3214
dd901a13 3215/* Translates rtx code to tree code, for those codes needed by
283f631a 3216 REAL_ARITHMETIC. The function returns an int because the caller may not
3217 know what `enum tree_code' means. */
3218
3ad4992f 3219extern int rtx_to_tree_code (enum rtx_code);
ea0cb7ae 3220
bc33205e 3221/* In cse.c */
f2f648a3 3222extern int delete_trivially_dead_insns (rtx_insn *, int);
52d07779 3223extern int exp_equiv_p (const_rtx, const_rtx, int, bool);
3224extern unsigned hash_rtx (const_rtx x, enum machine_mode, int *, int *, bool);
bc33205e 3225
017b7047 3226/* In dse.c */
ebabb7a3 3227extern bool check_for_inc_dec (rtx_insn *insn);
017b7047 3228
bc33205e 3229/* In jump.c */
3ad4992f 3230extern int comparison_dominates_p (enum rtx_code, enum rtx_code);
4115ac36 3231extern bool jump_to_label_p (rtx);
52d07779 3232extern int condjump_p (const_rtx);
3233extern int any_condjump_p (const_rtx);
3234extern int any_uncondjump_p (const_rtx);
3235extern rtx pc_set (const_rtx);
5493cb9a 3236extern rtx condjump_label (const_rtx);
52d07779 3237extern int simplejump_p (const_rtx);
3ad4992f 3238extern int returnjump_p (rtx);
25e880b1 3239extern int eh_returnjump_p (rtx);
52d07779 3240extern int onlyjump_p (const_rtx);
3241extern int only_sets_cc0_p (const_rtx);
3242extern int sets_cc0_p (const_rtx);
3ad4992f 3243extern int invert_jump_1 (rtx, rtx);
3244extern int invert_jump (rtx, rtx, int);
a9f1838b 3245extern int rtx_renumbered_equal_p (const_rtx, const_rtx);
52d07779 3246extern int true_regnum (const_rtx);
3247extern unsigned int reg_or_subregno (const_rtx);
3ad4992f 3248extern int redirect_jump_1 (rtx, rtx);
82880dfd 3249extern void redirect_jump_2 (rtx, rtx, rtx, int, int);
3ad4992f 3250extern int redirect_jump (rtx, rtx, int);
960a7046 3251extern void rebuild_jump_labels (rtx_insn *);
3252extern void rebuild_jump_labels_chain (rtx_insn *);
5493cb9a 3253extern rtx reversed_comparison (const_rtx, enum machine_mode);
3254extern enum rtx_code reversed_comparison_code (const_rtx, const_rtx);
3255extern enum rtx_code reversed_comparison_code_parts (enum rtx_code, const_rtx,
3256 const_rtx, const_rtx);
2db825a4 3257extern void delete_for_peephole (rtx_insn *, rtx_insn *);
52d07779 3258extern int condjump_in_parallel_p (const_rtx);
f5e86f05 3259
a7dce381 3260/* In emit-rtl.c. */
3ad4992f 3261extern int max_reg_num (void);
3262extern int max_label_num (void);
3263extern int get_first_label_num (void);
4ee9c684 3264extern void maybe_set_first_label_num (rtx);
57c26b3a 3265extern void delete_insns_since (rtx_insn *);
3ad4992f 3266extern void mark_reg_pointer (rtx, int);
3267extern void mark_user_reg (rtx);
3268extern void reset_used_flags (rtx);
1cd4cfea 3269extern void set_used_flags (rtx);
4a3fb716 3270extern void reorder_insns (rtx_insn *, rtx_insn *, rtx_insn *);
57c26b3a 3271extern void reorder_insns_nobb (rtx_insn *, rtx_insn *, rtx_insn *);
9845d120 3272extern int get_max_insn_count (void);
3ad4992f 3273extern int in_sequence_p (void);
3ad4992f 3274extern void init_emit (void);
6d8b68a3 3275extern void init_emit_regs (void);
8059b95a 3276extern void init_derived_machine_modes (void);
01703575 3277extern void init_emit_once (void);
3ad4992f 3278extern void push_topmost_sequence (void);
3279extern void pop_topmost_sequence (void);
57c26b3a 3280extern void set_new_first_and_last_insn (rtx_insn *, rtx_insn *);
2a1990e9 3281extern unsigned int unshare_all_rtl (void);
58945f46 3282extern void unshare_all_rtl_again (rtx_insn *);
1cd4cfea 3283extern void unshare_all_rtl_in_chain (rtx);
3284extern void verify_rtl_sharing (void);
3e75e92b 3285extern void add_insn (rtx_insn *);
161dfa6e 3286extern void add_insn_before (rtx, rtx, basic_block);
3287extern void add_insn_after (rtx, rtx, basic_block);
3ad4992f 3288extern void remove_insn (rtx);
722334ea 3289extern rtx_insn *emit (rtx);
a2b85e40 3290extern void delete_insn (rtx);
dec0d4e1 3291extern rtx_insn *entry_of_function (void);
aa02fa19 3292extern void emit_insn_at_entry (rtx);
39257eb5 3293extern void delete_insn_chain (rtx, rtx, bool);
3e75e92b 3294extern rtx_insn *unlink_insn_chain (rtx_insn *, rtx_insn *);
0c4d52cf 3295extern void delete_insn_and_edges (rtx_insn *);
fd00232c 3296extern rtx gen_lowpart_SUBREG (enum machine_mode, rtx);
e265a6da 3297extern rtx gen_const_mem (enum machine_mode, rtx);
00060fc2 3298extern rtx gen_frame_mem (enum machine_mode, rtx);
3299extern rtx gen_tmp_stack_mem (enum machine_mode, rtx);
2166bbaa 3300extern bool validate_subreg (enum machine_mode, enum machine_mode,
7ecb5bb2 3301 const_rtx, unsigned int);
bc33205e 3302
3072d30e 3303/* In combine.c */
8bbbe2b5 3304extern unsigned int extended_count (const_rtx, enum machine_mode, int);
e149ca56 3305extern rtx remove_death (unsigned int, rtx_insn *);
d598ad0d 3306extern void dump_combine_stats (FILE *);
3307extern void dump_combine_total_stats (FILE *);
e6637753 3308extern rtx make_compound_operation (rtx, enum rtx_code);
bc33205e 3309
3072d30e 3310/* In cfgcleanup.c */
3311extern void delete_dead_jumptables (void);
3312
fd00232c 3313/* In sched-rgn.c. */
3f5be5f4 3314extern void schedule_insns (void);
fd00232c 3315
3316/* In sched-ebb.c. */
3f5be5f4 3317extern void schedule_ebbs (void);
fd00232c 3318
e1ab7874 3319/* In sel-sched-dump.c. */
3320extern void sel_sched_fix_param (const char *param, const char *val);
3321
bc33205e 3322/* In print-rtl.c */
52fd6db3 3323extern const char *print_rtx_head;
c7d89805 3324extern void debug (const rtx_def &ref);
3325extern void debug (const rtx_def *ptr);
dd9b9fc5 3326extern void debug_rtx (const_rtx);
831e913e 3327extern void debug_rtx_list (const rtx_insn *, int);
3328extern void debug_rtx_range (const rtx_insn *, const rtx_insn *);
3329extern const_rtx debug_rtx_find (const rtx_insn *, int);
dd9b9fc5 3330extern void print_mem_expr (FILE *, const_tree);
3331extern void print_rtl (FILE *, const_rtx);
3332extern void print_simple_rtl (FILE *, const_rtx);
3333extern int print_rtl_single (FILE *, const_rtx);
9631926a 3334extern int print_rtl_single_with_indent (FILE *, const_rtx, int);
dd9b9fc5 3335extern void print_inline_rtx (FILE *, const_rtx, int);
bc33205e 3336
3d9a4504 3337/* Functions in sched-vis.c. FIXME: Ideally these functions would
f4b3647a 3338 not be in sched-vis.c but in rtl.c, because they are not only used
3339 by the scheduler anymore but for all "slim" RTL dumping. */
6dde9719 3340extern void dump_value_slim (FILE *, const_rtx, int);
3341extern void dump_insn_slim (FILE *, const_rtx);
3342extern void dump_rtl_slim (FILE *, const_rtx, const_rtx, int, int);
3d9a4504 3343extern void print_value (pretty_printer *, const_rtx, int);
3344extern void print_pattern (pretty_printer *, const_rtx, int);
3345extern void print_insn (pretty_printer *, const_rtx, int);
e079344a 3346extern void rtl_dump_bb_for_graph (pretty_printer *, basic_block);
3d9a4504 3347extern const char *str_pattern_slim (const_rtx);
f4b3647a 3348
bc33205e 3349/* In function.c */
3072d30e 3350extern void reposition_prologue_and_epilogue_notes (void);
52d07779 3351extern int prologue_epilogue_contains (const_rtx);
3352extern int sibcall_epilogue_contains (const_rtx);
3ad4992f 3353extern void update_temp_slot_address (rtx, rtx);
1eefcaee 3354extern void maybe_copy_prologue_epilogue_insn (rtx, rtx);
31a53363 3355extern void set_return_jump_label (rtx);
bc33205e 3356
bc33205e 3357/* In stmt.c */
3ad4992f 3358extern void expand_null_return (void);
62380d2d 3359extern void expand_naked_return (void);
3ad4992f 3360extern void emit_jump (rtx);
bc33205e 3361
3362/* In expr.c */
3ad4992f 3363extern rtx move_by_pieces (rtx, rtx, unsigned HOST_WIDE_INT,
3364 unsigned int, int);
40125f1c 3365extern HOST_WIDE_INT find_args_size_adjust (rtx);
dfe00a8f 3366extern int fixup_args_size_notes (rtx, rtx, int);
9d7facc8 3367
3072d30e 3368/* In cfgrtl.c */
e149ca56 3369extern void print_rtl_with_bb (FILE *, const rtx_insn *, int);
baa294b4 3370extern rtx_insn *duplicate_insn_chain (rtx_insn *, rtx_insn *);
3072d30e 3371
bc33205e 3372/* In expmed.c */
3ad4992f 3373extern void init_expmed (void);
3374extern void expand_inc (rtx, rtx);
3375extern void expand_dec (rtx, rtx);
bc33205e 3376
c7944dce 3377/* In lower-subreg.c */
3378extern void init_lower_subreg (void);
3379
ebd9163c 3380/* In gcse.c */
3ad4992f 3381extern bool can_copy_p (enum machine_mode);
4b673aa1 3382extern bool can_assign_to_reg_without_clobbers_p (rtx);
3aeaa53f 3383extern rtx fis_get_condition (rtx_insn *);
78d140c9 3384
cf709bf6 3385/* In ira.c */
47dd2e78 3386#ifdef HARD_CONST
3387extern HARD_REG_SET eliminable_regset;
3388#endif
3ad4992f 3389extern void mark_elimination (int, int);
bc33205e 3390
ac502adf 3391/* In reginfo.c */
fbd79b7a 3392extern int reg_classes_intersect_p (reg_class_t, reg_class_t);
2dfa2c74 3393extern int reg_class_subset_p (reg_class_t, reg_class_t);
ca2d5ca1 3394extern void globalize_reg (tree, int);
6d8b68a3 3395extern void init_reg_modes_target (void);
3ad4992f 3396extern void init_regs (void);
c950adc6 3397extern void reinit_regs (void);
3ad4992f 3398extern void init_fake_stack_mems (void);
7fecc8b3 3399extern void save_register_info (void);
3ad4992f 3400extern void init_reg_sets (void);
3f5be5f4 3401extern void regclass (rtx, int);
c72f6e47 3402extern void reg_scan (rtx_insn *, unsigned int);
3ad4992f 3403extern void fix_register (const char *, int, int);
63dae96b 3404extern bool invalid_mode_change_p (unsigned int, enum reg_class);
0019492d 3405
dfc4de0a 3406/* In reload1.c */
52d07779 3407extern int function_invariant_p (const_rtx);
dfc4de0a 3408
bc33205e 3409/* In calls.c */
2c5d421b 3410enum libcall_type
3411{
3412 LCT_NORMAL = 0,
3413 LCT_CONST = 1,
3414 LCT_PURE = 2,
2dd6f9ed 3415 LCT_NORETURN = 3,
3416 LCT_THROW = 4,
3417 LCT_RETURNS_TWICE = 5
2c5d421b 3418};
3419
3ad4992f 3420extern void emit_library_call (rtx, enum libcall_type, enum machine_mode, int,
3421 ...);
3422extern rtx emit_library_call_value (rtx, rtx, enum libcall_type,
3423 enum machine_mode, int, ...);
bc33205e 3424
bc33205e 3425/* In varasm.c */
3ad4992f 3426extern void init_varasm_once (void);
48e1416a 3427
a2f58a79 3428extern rtx make_debug_expr_from_rtl (const_rtx);
3429
fdef3332 3430/* In read-rtl.c */
77ba95d0 3431extern bool read_rtx (const char *, rtx *);
0922b1b8 3432
bc33205e 3433/* In alias.c */
aecda0d6 3434extern rtx canon_rtx (rtx);
376a287d 3435extern int true_dependence (const_rtx, enum machine_mode, const_rtx);
aecda0d6 3436extern rtx get_addr (rtx);
376a287d 3437extern int canon_true_dependence (const_rtx, enum machine_mode, rtx,
3438 const_rtx, rtx);
52d07779 3439extern int read_dependence (const_rtx, const_rtx);
3440extern int anti_dependence (const_rtx, const_rtx);
cb456db5 3441extern int canon_anti_dependence (const_rtx, bool,
3442 const_rtx, enum machine_mode, rtx);
52d07779 3443extern int output_dependence (const_rtx, const_rtx);
a84256aa 3444extern int may_alias_p (const_rtx, const_rtx);
6d8b68a3 3445extern void init_alias_target (void);
aecda0d6 3446extern void init_alias_analysis (void);
3447extern void end_alias_analysis (void);
1837e966 3448extern void vt_equate_reg_base_value (const_rtx, const_rtx);
5493cb9a 3449extern bool memory_modified_in_insn_p (const_rtx, const_rtx);
43b6ba45 3450extern bool memory_must_be_modified_in_insn_p (const_rtx, const_rtx);
86e87ef6 3451extern bool may_be_sp_based_p (rtx);
c09425a0 3452extern rtx gen_hard_reg_clobber (enum machine_mode, unsigned int);
12cb06ad 3453extern rtx get_reg_known_value (unsigned int);
3454extern bool get_reg_known_equiv_p (unsigned int);
0cfef6c5 3455extern rtx get_reg_base_value (unsigned int);
23f5e759 3456
b67ec609 3457#ifdef STACK_REGS
5493cb9a 3458extern int stack_regs_mentioned (const_rtx insn);
b67ec609 3459#endif
3460
8f8ac140 3461/* In toplev.c */
1f3233d1 3462extern GTY(()) rtx stack_limit_rtx;
120911d5 3463
13488c51 3464/* In predict.c */
3ad4992f 3465extern void invert_br_probabilities (rtx);
3466extern bool expensive_function_p (int);
897118e8 3467
5923a5e7 3468/* In var-tracking.c */
2a1990e9 3469extern unsigned int variable_tracking_main (void);
5923a5e7 3470
f9cce2dc 3471/* In stor-layout.c. */
a6629703 3472extern void get_mode_bounds (enum machine_mode, int, enum machine_mode,
3473 rtx *, rtx *);
f9cce2dc 3474
f9cce2dc 3475/* In loop-iv.c */
3476extern rtx canon_condition (rtx);
2391ba8e 3477extern void simplify_using_condition (rtx, rtx *, bitmap);
e1ab7874 3478
3479/* In final.c */
3480extern unsigned int compute_alignments (void);
14e08599 3481extern void update_alignments (vec<rtx> &);
1ca8efe4 3482extern int asm_str_count (const char *templ);
d263732c 3483\f
3484struct rtl_hooks
3485{
3486 rtx (*gen_lowpart) (enum machine_mode, rtx);
8666c391 3487 rtx (*gen_lowpart_no_emit) (enum machine_mode, rtx);
b7bf20db 3488 rtx (*reg_nonzero_bits) (const_rtx, enum machine_mode, const_rtx, enum machine_mode,
d263732c 3489 unsigned HOST_WIDE_INT, unsigned HOST_WIDE_INT *);
b7bf20db 3490 rtx (*reg_num_sign_bit_copies) (const_rtx, enum machine_mode, const_rtx, enum machine_mode,
d263732c 3491 unsigned int, unsigned int *);
b7bf20db 3492 bool (*reg_truncated_to_mode) (enum machine_mode, const_rtx);
d263732c 3493
fd95fba4 3494 /* Whenever you add entries here, make sure you adjust rtlhooks-def.h. */
d263732c 3495};
3496
3497/* Each pass can provide its own. */
3498extern struct rtl_hooks rtl_hooks;
3499
3500/* ... but then it has to restore these. */
3501extern const struct rtl_hooks general_rtl_hooks;
3502
3503/* Keep this for the nonce. */
3504#define gen_lowpart rtl_hooks.gen_lowpart
3505
5169661d 3506extern void insn_locations_init (void);
3507extern void insn_locations_finalize (void);
3508extern void set_curr_insn_location (location_t);
3509extern location_t curr_insn_location (void);
f529eb25 3510extern bool optimize_insn_for_size_p (void);
3511extern bool optimize_insn_for_speed_p (void);
375c1c8a 3512
d7091a76 3513/* rtl-error.c */
3514extern void _fatal_insn_not_found (const_rtx, const char *, int, const char *)
3515 ATTRIBUTE_NORETURN;
3516extern void _fatal_insn (const char *, const_rtx, const char *, int, const char *)
3517 ATTRIBUTE_NORETURN;
3518
3519#define fatal_insn(msgid, insn) \
3520 _fatal_insn (msgid, insn, __FILE__, __LINE__, __FUNCTION__)
3521#define fatal_insn_not_found(insn) \
3522 _fatal_insn_not_found (insn, __FILE__, __LINE__, __FUNCTION__)
3523
e52beba9 3524/* reginfo.c */
3525extern tree GTY(()) global_regs_decl[FIRST_PSEUDO_REGISTER];
d7091a76 3526
3527
2a281353 3528#endif /* ! GCC_RTL_H */