ira.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /* Communication between the Integrated Register Allocator (IRA) and
  2. the rest of the compiler.
  3. Copyright (C) 2006-2015 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. /* True when we use LRA instead of reload pass for the current
  20. function. */
  21. extern bool ira_use_lra_p;
  22. /* True if we have allocno conflicts. It is false for non-optimized
  23. mode or when the conflict table is too big. */
  24. extern bool ira_conflicts_p;
  25. struct target_ira
  26. {
  27. /* Map: hard register number -> allocno class it belongs to. If the
  28. corresponding class is NO_REGS, the hard register is not available
  29. for allocation. */
  30. enum reg_class x_ira_hard_regno_allocno_class[FIRST_PSEUDO_REGISTER];
  31. /* Number of allocno classes. Allocno classes are register classes
  32. which can be used for allocations of allocnos. */
  33. int x_ira_allocno_classes_num;
  34. /* The array containing allocno classes. Only first
  35. IRA_ALLOCNO_CLASSES_NUM elements are used for this. */
  36. enum reg_class x_ira_allocno_classes[N_REG_CLASSES];
  37. /* Map of all register classes to corresponding allocno classes
  38. containing the given class. If given class is not a subset of an
  39. allocno class, we translate it into the cheapest allocno class. */
  40. enum reg_class x_ira_allocno_class_translate[N_REG_CLASSES];
  41. /* Number of pressure classes. Pressure classes are register
  42. classes for which we calculate register pressure. */
  43. int x_ira_pressure_classes_num;
  44. /* The array containing pressure classes. Only first
  45. IRA_PRESSURE_CLASSES_NUM elements are used for this. */
  46. enum reg_class x_ira_pressure_classes[N_REG_CLASSES];
  47. /* Map of all register classes to corresponding pressure classes
  48. containing the given class. If given class is not a subset of an
  49. pressure class, we translate it into the cheapest pressure
  50. class. */
  51. enum reg_class x_ira_pressure_class_translate[N_REG_CLASSES];
  52. /* Biggest pressure register class containing stack registers.
  53. NO_REGS if there are no stack registers. */
  54. enum reg_class x_ira_stack_reg_pressure_class;
  55. /* Maps: register class x machine mode -> maximal/minimal number of
  56. hard registers of given class needed to store value of given
  57. mode. */
  58. unsigned char x_ira_reg_class_max_nregs[N_REG_CLASSES][MAX_MACHINE_MODE];
  59. unsigned char x_ira_reg_class_min_nregs[N_REG_CLASSES][MAX_MACHINE_MODE];
  60. /* Array analogous to target hook TARGET_MEMORY_MOVE_COST. */
  61. short x_ira_memory_move_cost[MAX_MACHINE_MODE][N_REG_CLASSES][2];
  62. /* Array of number of hard registers of given class which are
  63. available for the allocation. The order is defined by the
  64. allocation order. */
  65. short x_ira_class_hard_regs[N_REG_CLASSES][FIRST_PSEUDO_REGISTER];
  66. /* The number of elements of the above array for given register
  67. class. */
  68. int x_ira_class_hard_regs_num[N_REG_CLASSES];
  69. /* Register class subset relation: TRUE if the first class is a subset
  70. of the second one considering only hard registers available for the
  71. allocation. */
  72. int x_ira_class_subset_p[N_REG_CLASSES][N_REG_CLASSES];
  73. /* The biggest class inside of intersection of the two classes (that
  74. is calculated taking only hard registers available for allocation
  75. into account. If the both classes contain no hard registers
  76. available for allocation, the value is calculated with taking all
  77. hard-registers including fixed ones into account. */
  78. enum reg_class x_ira_reg_class_subset[N_REG_CLASSES][N_REG_CLASSES];
  79. /* True if the two classes (that is calculated taking only hard
  80. registers available for allocation into account; are
  81. intersected. */
  82. bool x_ira_reg_classes_intersect_p[N_REG_CLASSES][N_REG_CLASSES];
  83. /* If class CL has a single allocatable register of mode M,
  84. index [CL][M] gives the number of that register, otherwise it is -1. */
  85. short x_ira_class_singleton[N_REG_CLASSES][MAX_MACHINE_MODE];
  86. /* Function specific hard registers can not be used for the register
  87. allocation. */
  88. HARD_REG_SET x_ira_no_alloc_regs;
  89. /* Array whose values are hard regset of hard registers available for
  90. the allocation of given register class whose HARD_REGNO_MODE_OK
  91. values for given mode are zero. */
  92. HARD_REG_SET x_ira_prohibited_class_mode_regs[N_REG_CLASSES][NUM_MACHINE_MODES];
  93. };
  94. extern struct target_ira default_target_ira;
  95. #if SWITCHABLE_TARGET
  96. extern struct target_ira *this_target_ira;
  97. #else
  98. #define this_target_ira (&default_target_ira)
  99. #endif
  100. #define ira_hard_regno_allocno_class \
  101. (this_target_ira->x_ira_hard_regno_allocno_class)
  102. #define ira_allocno_classes_num \
  103. (this_target_ira->x_ira_allocno_classes_num)
  104. #define ira_allocno_classes \
  105. (this_target_ira->x_ira_allocno_classes)
  106. #define ira_allocno_class_translate \
  107. (this_target_ira->x_ira_allocno_class_translate)
  108. #define ira_pressure_classes_num \
  109. (this_target_ira->x_ira_pressure_classes_num)
  110. #define ira_pressure_classes \
  111. (this_target_ira->x_ira_pressure_classes)
  112. #define ira_pressure_class_translate \
  113. (this_target_ira->x_ira_pressure_class_translate)
  114. #define ira_stack_reg_pressure_class \
  115. (this_target_ira->x_ira_stack_reg_pressure_class)
  116. #define ira_reg_class_max_nregs \
  117. (this_target_ira->x_ira_reg_class_max_nregs)
  118. #define ira_reg_class_min_nregs \
  119. (this_target_ira->x_ira_reg_class_min_nregs)
  120. #define ira_memory_move_cost \
  121. (this_target_ira->x_ira_memory_move_cost)
  122. #define ira_class_hard_regs \
  123. (this_target_ira->x_ira_class_hard_regs)
  124. #define ira_class_hard_regs_num \
  125. (this_target_ira->x_ira_class_hard_regs_num)
  126. #define ira_class_subset_p \
  127. (this_target_ira->x_ira_class_subset_p)
  128. #define ira_reg_class_subset \
  129. (this_target_ira->x_ira_reg_class_subset)
  130. #define ira_reg_classes_intersect_p \
  131. (this_target_ira->x_ira_reg_classes_intersect_p)
  132. #define ira_class_singleton \
  133. (this_target_ira->x_ira_class_singleton)
  134. #define ira_no_alloc_regs \
  135. (this_target_ira->x_ira_no_alloc_regs)
  136. #define ira_prohibited_class_mode_regs \
  137. (this_target_ira->x_ira_prohibited_class_mode_regs)
  138. /* Major structure describing equivalence info for a pseudo. */
  139. struct ira_reg_equiv_s
  140. {
  141. /* True if we can use this equivalence. */
  142. bool defined_p;
  143. /* True if the usage of the equivalence is profitable. */
  144. bool profitable_p;
  145. /* Equiv. memory, constant, invariant, and initializing insns of
  146. given pseudo-register or NULL_RTX. */
  147. rtx memory;
  148. rtx constant;
  149. rtx invariant;
  150. /* Always NULL_RTX if defined_p is false. */
  151. rtx_insn_list *init_insns;
  152. };
  153. /* The length of the following array. */
  154. extern int ira_reg_equiv_len;
  155. /* Info about equiv. info for each register. */
  156. extern struct ira_reg_equiv_s *ira_reg_equiv;
  157. extern void ira_init_once (void);
  158. extern void ira_init (void);
  159. extern void ira_setup_eliminable_regset (void);
  160. extern rtx ira_eliminate_regs (rtx, machine_mode);
  161. extern void ira_set_pseudo_classes (bool, FILE *);
  162. extern void ira_expand_reg_equiv (void);
  163. extern void ira_update_equiv_info_by_shuffle_insn (int, int, rtx_insn *);
  164. extern void ira_sort_regnos_for_alter_reg (int *, int, unsigned int *);
  165. extern void ira_mark_allocation_change (int);
  166. extern void ira_mark_memory_move_deletion (int, int);
  167. extern bool ira_reassign_pseudos (int *, int, HARD_REG_SET, HARD_REG_SET *,
  168. HARD_REG_SET *, bitmap);
  169. extern rtx ira_reuse_stack_slot (int, unsigned int, unsigned int);
  170. extern void ira_mark_new_stack_slot (rtx, int, unsigned int);
  171. extern bool ira_better_spill_reload_regno_p (int *, int *, rtx, rtx, rtx);
  172. extern bool ira_bad_reload_regno (int, rtx, rtx);
  173. extern void ira_adjust_equiv_reg_cost (unsigned, int);
  174. /* ira-costs.c */
  175. extern void ira_costs_c_finalize (void);
  176. #endif /* GCC_IRA_H */