emit-rtl.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /* Exported functions from emit-rtl.c
  2. Copyright (C) 2004-2015 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_EMIT_RTL_H
  16. #define GCC_EMIT_RTL_H
  17. /* Return whether two MEM_ATTRs are equal. */
  18. bool mem_attrs_eq_p (const struct mem_attrs *, const struct mem_attrs *);
  19. /* Set the alias set of MEM to SET. */
  20. extern void set_mem_alias_set (rtx, alias_set_type);
  21. /* Set the alignment of MEM to ALIGN bits. */
  22. extern void set_mem_align (rtx, unsigned int);
  23. /* Set the address space of MEM to ADDRSPACE. */
  24. extern void set_mem_addr_space (rtx, addr_space_t);
  25. /* Set the expr for MEM to EXPR. */
  26. extern void set_mem_expr (rtx, tree);
  27. /* Set the offset for MEM to OFFSET. */
  28. extern void set_mem_offset (rtx, HOST_WIDE_INT);
  29. /* Clear the offset recorded for MEM. */
  30. extern void clear_mem_offset (rtx);
  31. /* Set the size for MEM to SIZE. */
  32. extern void set_mem_size (rtx, HOST_WIDE_INT);
  33. /* Clear the size recorded for MEM. */
  34. extern void clear_mem_size (rtx);
  35. /* Set the attributes for MEM appropriate for a spill slot. */
  36. extern void set_mem_attrs_for_spill (rtx);
  37. extern tree get_spill_slot_decl (bool);
  38. /* Return a memory reference like MEMREF, but with its address changed to
  39. ADDR. The caller is asserting that the actual piece of memory pointed
  40. to is the same, just the form of the address is being changed, such as
  41. by putting something into a register. */
  42. extern rtx replace_equiv_address (rtx, rtx, bool = false);
  43. /* Likewise, but the reference is not required to be valid. */
  44. extern rtx replace_equiv_address_nv (rtx, rtx, bool = false);
  45. extern rtx gen_blockage (void);
  46. extern rtvec gen_rtvec (int, ...);
  47. extern rtx copy_insn_1 (rtx);
  48. extern rtx copy_insn (rtx);
  49. extern rtx_insn *copy_delay_slot_insn (rtx_insn *);
  50. extern rtx gen_int_mode (HOST_WIDE_INT, machine_mode);
  51. extern rtx_insn *emit_copy_of_insn_after (rtx_insn *, rtx_insn *);
  52. extern void set_reg_attrs_from_value (rtx, rtx);
  53. extern void set_reg_attrs_for_parm (rtx, rtx);
  54. extern void set_reg_attrs_for_decl_rtl (tree t, rtx x);
  55. extern void adjust_reg_mode (rtx, machine_mode);
  56. extern int mem_expr_equal_p (const_tree, const_tree);
  57. extern bool need_atomic_barrier_p (enum memmodel, bool);
  58. /* Return the first insn of the current sequence or current function. */
  59. static inline rtx_insn *
  60. get_insns (void)
  61. {
  62. return crtl->emit.x_first_insn;
  63. }
  64. /* Specify a new insn as the first in the chain. */
  65. static inline void
  66. set_first_insn (rtx_insn *insn)
  67. {
  68. gcc_checking_assert (!insn || !PREV_INSN (insn));
  69. crtl->emit.x_first_insn = insn;
  70. }
  71. /* Return the last insn emitted in current sequence or current function. */
  72. static inline rtx_insn *
  73. get_last_insn (void)
  74. {
  75. return crtl->emit.x_last_insn;
  76. }
  77. /* Specify a new insn as the last in the chain. */
  78. static inline void
  79. set_last_insn (rtx_insn *insn)
  80. {
  81. gcc_checking_assert (!insn || !NEXT_INSN (insn));
  82. crtl->emit.x_last_insn = insn;
  83. }
  84. /* Return a number larger than any instruction's uid in this function. */
  85. static inline int
  86. get_max_uid (void)
  87. {
  88. return crtl->emit.x_cur_insn_uid;
  89. }
  90. extern void set_decl_incoming_rtl (tree, rtx, bool);
  91. /* Return a memory reference like MEMREF, but with its mode changed
  92. to MODE and its address changed to ADDR.
  93. (VOIDmode means don't change the mode.
  94. NULL for ADDR means don't change the address.) */
  95. extern rtx change_address (rtx, machine_mode, rtx);
  96. /* Return a memory reference like MEMREF, but with its mode changed
  97. to MODE and its address offset by OFFSET bytes. */
  98. #define adjust_address(MEMREF, MODE, OFFSET) \
  99. adjust_address_1 (MEMREF, MODE, OFFSET, 1, 1, 0, 0)
  100. /* Likewise, but the reference is not required to be valid. */
  101. #define adjust_address_nv(MEMREF, MODE, OFFSET) \
  102. adjust_address_1 (MEMREF, MODE, OFFSET, 0, 1, 0, 0)
  103. /* Return a memory reference like MEMREF, but with its mode changed
  104. to MODE and its address offset by OFFSET bytes. Assume that it's
  105. for a bitfield and conservatively drop the underlying object if we
  106. cannot be sure to stay within its bounds. */
  107. #define adjust_bitfield_address(MEMREF, MODE, OFFSET) \
  108. adjust_address_1 (MEMREF, MODE, OFFSET, 1, 1, 1, 0)
  109. /* As for adjust_bitfield_address, but specify that the width of
  110. BLKmode accesses is SIZE bytes. */
  111. #define adjust_bitfield_address_size(MEMREF, MODE, OFFSET, SIZE) \
  112. adjust_address_1 (MEMREF, MODE, OFFSET, 1, 1, 1, SIZE)
  113. /* Likewise, but the reference is not required to be valid. */
  114. #define adjust_bitfield_address_nv(MEMREF, MODE, OFFSET) \
  115. adjust_address_1 (MEMREF, MODE, OFFSET, 0, 1, 1, 0)
  116. /* Return a memory reference like MEMREF, but with its mode changed
  117. to MODE and its address changed to ADDR, which is assumed to be
  118. increased by OFFSET bytes from MEMREF. */
  119. #define adjust_automodify_address(MEMREF, MODE, ADDR, OFFSET) \
  120. adjust_automodify_address_1 (MEMREF, MODE, ADDR, OFFSET, 1)
  121. /* Likewise, but the reference is not required to be valid. */
  122. #define adjust_automodify_address_nv(MEMREF, MODE, ADDR, OFFSET) \
  123. adjust_automodify_address_1 (MEMREF, MODE, ADDR, OFFSET, 0)
  124. extern rtx adjust_address_1 (rtx, machine_mode, HOST_WIDE_INT, int, int,
  125. int, HOST_WIDE_INT);
  126. extern rtx adjust_automodify_address_1 (rtx, machine_mode, rtx,
  127. HOST_WIDE_INT, int);
  128. /* Return a memory reference like MEMREF, but whose address is changed by
  129. adding OFFSET, an RTX, to it. POW2 is the highest power of two factor
  130. known to be in OFFSET (possibly 1). */
  131. extern rtx offset_address (rtx, rtx, unsigned HOST_WIDE_INT);
  132. /* Given REF, a MEM, and T, either the type of X or the expression
  133. corresponding to REF, set the memory attributes. OBJECTP is nonzero
  134. if we are making a new object of this type. */
  135. extern void set_mem_attributes (rtx, tree, int);
  136. /* Similar, except that BITPOS has not yet been applied to REF, so if
  137. we alter MEM_OFFSET according to T then we should subtract BITPOS
  138. expecting that it'll be added back in later. */
  139. extern void set_mem_attributes_minus_bitpos (rtx, tree, int, HOST_WIDE_INT);
  140. /* Return OFFSET if XEXP (MEM, 0) - OFFSET is known to be ALIGN
  141. bits aligned for 0 <= OFFSET < ALIGN / BITS_PER_UNIT, or
  142. -1 if not known. */
  143. extern int get_mem_align_offset (rtx, unsigned int);
  144. /* Return a memory reference like MEMREF, but with its mode widened to
  145. MODE and adjusted by OFFSET. */
  146. extern rtx widen_memory_access (rtx, machine_mode, HOST_WIDE_INT);
  147. #endif /* GCC_EMIT_RTL_H */