您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

4459 行
151KB

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