ira.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. /* Communication between the Integrated Register Allocator (IRA) and
  2. the rest of the compiler.
  3. Copyright (C) 2006-2019 Free Software Foundation, Inc.
  4. Contributed by Vladimir Makarov <vmakarov@redhat.com>.
  5. This file is part of GCC.
  6. GCC is free software; you can redistribute it and/or modify it under
  7. the terms of the GNU General Public License as published by the Free
  8. Software Foundation; either version 3, or (at your option) any later
  9. version.
  10. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  13. for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with GCC; see the file COPYING3. If not see
  16. <http://www.gnu.org/licenses/>. */
  17. #ifndef GCC_IRA_H
  18. #define GCC_IRA_H
  19. #include "emit-rtl.h"
  20. /* True when we use LRA instead of reload pass for the current
  21. function. */
  22. extern bool ira_use_lra_p;
  23. /* True if we have allocno conflicts. It is false for non-optimized
  24. mode or when the conflict table is too big. */
  25. extern bool ira_conflicts_p;
  26. struct target_ira
  27. {
  28. /* Map: hard register number -> allocno class it belongs to. If the
  29. corresponding class is NO_REGS, the hard register is not available
  30. for allocation. */
  31. enum reg_class x_ira_hard_regno_allocno_class[FIRST_PSEUDO_REGISTER];
  32. /* Number of allocno classes. Allocno classes are register classes
  33. which can be used for allocations of allocnos. */
  34. int x_ira_allocno_classes_num;
  35. /* The array containing allocno classes. Only first
  36. IRA_ALLOCNO_CLASSES_NUM elements are used for this. */
  37. enum reg_class x_ira_allocno_classes[N_REG_CLASSES];
  38. /* Map of all register classes to corresponding allocno classes
  39. containing the given class. If given class is not a subset of an
  40. allocno class, we translate it into the cheapest allocno class. */
  41. enum reg_class x_ira_allocno_class_translate[N_REG_CLASSES];
  42. /* Number of pressure classes. Pressure classes are register
  43. classes for which we calculate register pressure. */
  44. int x_ira_pressure_classes_num;
  45. /* The array containing pressure classes. Only first
  46. IRA_PRESSURE_CLASSES_NUM elements are used for this. */
  47. enum reg_class x_ira_pressure_classes[N_REG_CLASSES];
  48. /* Map of all register classes to corresponding pressure classes
  49. containing the given class. If given class is not a subset of an
  50. pressure class, we translate it into the cheapest pressure
  51. class. */
  52. enum reg_class x_ira_pressure_class_translate[N_REG_CLASSES];
  53. /* Biggest pressure register class containing stack registers.
  54. NO_REGS if there are no stack registers. */
  55. enum reg_class x_ira_stack_reg_pressure_class;
  56. /* Maps: register class x machine mode -> maximal/minimal number of
  57. hard registers of given class needed to store value of given
  58. mode. */
  59. unsigned char x_ira_reg_class_max_nregs[N_REG_CLASSES][MAX_MACHINE_MODE];
  60. unsigned char x_ira_reg_class_min_nregs[N_REG_CLASSES][MAX_MACHINE_MODE];
  61. /* Array analogous to target hook TARGET_MEMORY_MOVE_COST. */
  62. short x_ira_memory_move_cost[MAX_MACHINE_MODE][N_REG_CLASSES][2];
  63. /* Array of number of hard registers of given class which are
  64. available for the allocation. The order is defined by the
  65. allocation order. */
  66. short x_ira_class_hard_regs[N_REG_CLASSES][FIRST_PSEUDO_REGISTER];
  67. /* The number of elements of the above array for given register
  68. class. */
  69. int x_ira_class_hard_regs_num[N_REG_CLASSES];
  70. /* Register class subset relation: TRUE if the first class is a subset
  71. of the second one considering only hard registers available for the
  72. allocation. */
  73. int x_ira_class_subset_p[N_REG_CLASSES][N_REG_CLASSES];
  74. /* The biggest class inside of intersection of the two classes (that
  75. is calculated taking only hard registers available for allocation
  76. into account. If the both classes contain no hard registers
  77. available for allocation, the value is calculated with taking all
  78. hard-registers including fixed ones into account. */
  79. enum reg_class x_ira_reg_class_subset[N_REG_CLASSES][N_REG_CLASSES];
  80. /* True if the two classes (that is calculated taking only hard
  81. registers available for allocation into account; are
  82. intersected. */
  83. bool x_ira_reg_classes_intersect_p[N_REG_CLASSES][N_REG_CLASSES];
  84. /* If class CL has a single allocatable register of mode M,
  85. index [CL][M] gives the number of that register, otherwise it is -1. */
  86. short x_ira_class_singleton[N_REG_CLASSES][MAX_MACHINE_MODE];
  87. /* Function specific hard registers cannot be used for the register
  88. allocation. */
  89. HARD_REG_SET x_ira_no_alloc_regs;
  90. /* Array whose values are hard regset of hard registers available for
  91. the allocation of given register class whose targetm.hard_regno_mode_ok
  92. values for given mode are false. */
  93. HARD_REG_SET x_ira_prohibited_class_mode_regs[N_REG_CLASSES][NUM_MACHINE_MODES];
  94. };
  95. extern struct target_ira default_target_ira;
  96. #if SWITCHABLE_TARGET
  97. extern struct target_ira *this_target_ira;
  98. #else
  99. #define this_target_ira (&default_target_ira)
  100. #endif
  101. #define ira_hard_regno_allocno_class \
  102. (this_target_ira->x_ira_hard_regno_allocno_class)
  103. #define ira_allocno_classes_num \
  104. (this_target_ira->x_ira_allocno_classes_num)
  105. #define ira_allocno_classes \
  106. (this_target_ira->x_ira_allocno_classes)
  107. #define ira_allocno_class_translate \
  108. (this_target_ira->x_ira_allocno_class_translate)
  109. #define ira_pressure_classes_num \
  110. (this_target_ira->x_ira_pressure_classes_num)
  111. #define ira_pressure_classes \
  112. (this_target_ira->x_ira_pressure_classes)
  113. #define ira_pressure_class_translate \
  114. (this_target_ira->x_ira_pressure_class_translate)
  115. #define ira_stack_reg_pressure_class \
  116. (this_target_ira->x_ira_stack_reg_pressure_class)
  117. #define ira_reg_class_max_nregs \
  118. (this_target_ira->x_ira_reg_class_max_nregs)
  119. #define ira_reg_class_min_nregs \
  120. (this_target_ira->x_ira_reg_class_min_nregs)
  121. #define ira_memory_move_cost \
  122. (this_target_ira->x_ira_memory_move_cost)
  123. #define ira_class_hard_regs \
  124. (this_target_ira->x_ira_class_hard_regs)
  125. #define ira_class_hard_regs_num \
  126. (this_target_ira->x_ira_class_hard_regs_num)
  127. #define ira_class_subset_p \
  128. (this_target_ira->x_ira_class_subset_p)
  129. #define ira_reg_class_subset \
  130. (this_target_ira->x_ira_reg_class_subset)
  131. #define ira_reg_classes_intersect_p \
  132. (this_target_ira->x_ira_reg_classes_intersect_p)
  133. #define ira_class_singleton \
  134. (this_target_ira->x_ira_class_singleton)
  135. #define ira_no_alloc_regs \
  136. (this_target_ira->x_ira_no_alloc_regs)
  137. #define ira_prohibited_class_mode_regs \
  138. (this_target_ira->x_ira_prohibited_class_mode_regs)
  139. /* Major structure describing equivalence info for a pseudo. */
  140. struct ira_reg_equiv_s
  141. {
  142. /* True if we can use this equivalence. */
  143. bool defined_p;
  144. /* True if the usage of the equivalence is profitable. */
  145. bool profitable_p;
  146. /* Equiv. memory, constant, invariant, and initializing insns of
  147. given pseudo-register or NULL_RTX. */
  148. rtx memory;
  149. rtx constant;
  150. rtx invariant;
  151. /* Always NULL_RTX if defined_p is false. */
  152. rtx_insn_list *init_insns;
  153. };
  154. /* The length of the following array. */
  155. extern int ira_reg_equiv_len;
  156. /* Info about equiv. info for each register. */
  157. extern struct ira_reg_equiv_s *ira_reg_equiv;
  158. extern void ira_init_once (void);
  159. extern void ira_init (void);
  160. extern void ira_setup_eliminable_regset (void);
  161. extern rtx ira_eliminate_regs (rtx, machine_mode);
  162. extern void ira_set_pseudo_classes (bool, FILE *);
  163. extern void ira_expand_reg_equiv (void);
  164. extern void ira_update_equiv_info_by_shuffle_insn (int, int, rtx_insn *);
  165. extern void ira_sort_regnos_for_alter_reg (int *, int, machine_mode *);
  166. extern void ira_mark_allocation_change (int);
  167. extern void ira_mark_memory_move_deletion (int, int);
  168. extern bool ira_reassign_pseudos (int *, int, HARD_REG_SET, HARD_REG_SET *,
  169. HARD_REG_SET *, bitmap);
  170. extern rtx ira_reuse_stack_slot (int, poly_uint64, poly_uint64);
  171. extern void ira_mark_new_stack_slot (rtx, int, poly_uint64);
  172. extern bool ira_better_spill_reload_regno_p (int *, int *, rtx, rtx, rtx_insn *);
  173. extern bool ira_bad_reload_regno (int, rtx, rtx);
  174. extern void ira_adjust_equiv_reg_cost (unsigned, int);
  175. /* ira-costs.c */
  176. extern void ira_costs_c_finalize (void);
  177. /* ira-lives.c */
  178. extern rtx non_conflicting_reg_copy_p (rtx_insn *);
  179. /* Spilling static chain pseudo may result in generation of wrong
  180. non-local goto code using frame-pointer to address saved stack
  181. pointer value after restoring old frame pointer value. The
  182. function returns TRUE if REGNO is such a static chain pseudo. */
  183. static inline bool
  184. non_spilled_static_chain_regno_p (int regno)
  185. {
  186. return (cfun->static_chain_decl && crtl->has_nonlocal_goto
  187. && REG_EXPR (regno_reg_rtx[regno]) == cfun->static_chain_decl);
  188. }
  189. #endif /* GCC_IRA_H */