1*e4b17023SJohn Marino /* Communication between the Integrated Register Allocator (IRA) and 2*e4b17023SJohn Marino the rest of the compiler. 3*e4b17023SJohn Marino Copyright (C) 2006, 2007, 2008, 2009, 2010 4*e4b17023SJohn Marino Free Software Foundation, Inc. 5*e4b17023SJohn Marino Contributed by Vladimir Makarov <vmakarov@redhat.com>. 6*e4b17023SJohn Marino 7*e4b17023SJohn Marino This file is part of GCC. 8*e4b17023SJohn Marino 9*e4b17023SJohn Marino GCC is free software; you can redistribute it and/or modify it under 10*e4b17023SJohn Marino the terms of the GNU General Public License as published by the Free 11*e4b17023SJohn Marino Software Foundation; either version 3, or (at your option) any later 12*e4b17023SJohn Marino version. 13*e4b17023SJohn Marino 14*e4b17023SJohn Marino GCC is distributed in the hope that it will be useful, but WITHOUT ANY 15*e4b17023SJohn Marino WARRANTY; without even the implied warranty of MERCHANTABILITY or 16*e4b17023SJohn Marino FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 17*e4b17023SJohn Marino for more details. 18*e4b17023SJohn Marino 19*e4b17023SJohn Marino You should have received a copy of the GNU General Public License 20*e4b17023SJohn Marino along with GCC; see the file COPYING3. If not see 21*e4b17023SJohn Marino <http://www.gnu.org/licenses/>. */ 22*e4b17023SJohn Marino 23*e4b17023SJohn Marino /* True if we have allocno conflicts. It is false for non-optimized 24*e4b17023SJohn Marino mode or when the conflict table is too big. */ 25*e4b17023SJohn Marino extern bool ira_conflicts_p; 26*e4b17023SJohn Marino 27*e4b17023SJohn Marino struct target_ira { 28*e4b17023SJohn Marino /* Number of given class hard registers available for the register 29*e4b17023SJohn Marino allocation for given classes. */ 30*e4b17023SJohn Marino int x_ira_available_class_regs[N_REG_CLASSES]; 31*e4b17023SJohn Marino 32*e4b17023SJohn Marino /* Map: hard register number -> allocno class it belongs to. If the 33*e4b17023SJohn Marino corresponding class is NO_REGS, the hard register is not available 34*e4b17023SJohn Marino for allocation. */ 35*e4b17023SJohn Marino enum reg_class x_ira_hard_regno_allocno_class[FIRST_PSEUDO_REGISTER]; 36*e4b17023SJohn Marino 37*e4b17023SJohn Marino /* Number of allocno classes. Allocno classes are register classes 38*e4b17023SJohn Marino which can be used for allocations of allocnos. */ 39*e4b17023SJohn Marino int x_ira_allocno_classes_num; 40*e4b17023SJohn Marino 41*e4b17023SJohn Marino /* The array containing allocno classes. Only first 42*e4b17023SJohn Marino IRA_ALLOCNO_CLASSES_NUM elements are used for this. */ 43*e4b17023SJohn Marino enum reg_class x_ira_allocno_classes[N_REG_CLASSES]; 44*e4b17023SJohn Marino 45*e4b17023SJohn Marino /* Map of all register classes to corresponding allocno classes 46*e4b17023SJohn Marino containing the given class. If given class is not a subset of an 47*e4b17023SJohn Marino allocno class, we translate it into the cheapest allocno class. */ 48*e4b17023SJohn Marino enum reg_class x_ira_allocno_class_translate[N_REG_CLASSES]; 49*e4b17023SJohn Marino 50*e4b17023SJohn Marino /* Number of pressure classes. Pressure classes are register 51*e4b17023SJohn Marino classes for which we calculate register pressure. */ 52*e4b17023SJohn Marino int x_ira_pressure_classes_num; 53*e4b17023SJohn Marino 54*e4b17023SJohn Marino /* The array containing pressure classes. Only first 55*e4b17023SJohn Marino IRA_PRESSURE_CLASSES_NUM elements are used for this. */ 56*e4b17023SJohn Marino enum reg_class x_ira_pressure_classes[N_REG_CLASSES]; 57*e4b17023SJohn Marino 58*e4b17023SJohn Marino /* Map of all register classes to corresponding pressure classes 59*e4b17023SJohn Marino containing the given class. If given class is not a subset of an 60*e4b17023SJohn Marino pressure class, we translate it into the cheapest pressure 61*e4b17023SJohn Marino class. */ 62*e4b17023SJohn Marino enum reg_class x_ira_pressure_class_translate[N_REG_CLASSES]; 63*e4b17023SJohn Marino 64*e4b17023SJohn Marino /* Bigest pressure register class containing stack registers. 65*e4b17023SJohn Marino NO_REGS if there are no stack registers. */ 66*e4b17023SJohn Marino enum reg_class x_ira_stack_reg_pressure_class; 67*e4b17023SJohn Marino 68*e4b17023SJohn Marino /* Maps: register class x machine mode -> maximal/minimal number of 69*e4b17023SJohn Marino hard registers of given class needed to store value of given 70*e4b17023SJohn Marino mode. */ 71*e4b17023SJohn Marino unsigned char x_ira_reg_class_max_nregs[N_REG_CLASSES][MAX_MACHINE_MODE]; 72*e4b17023SJohn Marino unsigned char x_ira_reg_class_min_nregs[N_REG_CLASSES][MAX_MACHINE_MODE]; 73*e4b17023SJohn Marino 74*e4b17023SJohn Marino /* Array analogous to target hook TARGET_MEMORY_MOVE_COST. */ 75*e4b17023SJohn Marino short x_ira_memory_move_cost[MAX_MACHINE_MODE][N_REG_CLASSES][2]; 76*e4b17023SJohn Marino 77*e4b17023SJohn Marino /* Array of number of hard registers of given class which are 78*e4b17023SJohn Marino available for the allocation. The order is defined by the 79*e4b17023SJohn Marino allocation order. */ 80*e4b17023SJohn Marino short x_ira_class_hard_regs[N_REG_CLASSES][FIRST_PSEUDO_REGISTER]; 81*e4b17023SJohn Marino 82*e4b17023SJohn Marino /* The number of elements of the above array for given register 83*e4b17023SJohn Marino class. */ 84*e4b17023SJohn Marino int x_ira_class_hard_regs_num[N_REG_CLASSES]; 85*e4b17023SJohn Marino 86*e4b17023SJohn Marino /* Function specific hard registers can not be used for the register 87*e4b17023SJohn Marino allocation. */ 88*e4b17023SJohn Marino HARD_REG_SET x_ira_no_alloc_regs; 89*e4b17023SJohn Marino }; 90*e4b17023SJohn Marino 91*e4b17023SJohn Marino extern struct target_ira default_target_ira; 92*e4b17023SJohn Marino #if SWITCHABLE_TARGET 93*e4b17023SJohn Marino extern struct target_ira *this_target_ira; 94*e4b17023SJohn Marino #else 95*e4b17023SJohn Marino #define this_target_ira (&default_target_ira) 96*e4b17023SJohn Marino #endif 97*e4b17023SJohn Marino 98*e4b17023SJohn Marino #define ira_available_class_regs \ 99*e4b17023SJohn Marino (this_target_ira->x_ira_available_class_regs) 100*e4b17023SJohn Marino #define ira_hard_regno_allocno_class \ 101*e4b17023SJohn Marino (this_target_ira->x_ira_hard_regno_allocno_class) 102*e4b17023SJohn Marino #define ira_allocno_classes_num \ 103*e4b17023SJohn Marino (this_target_ira->x_ira_allocno_classes_num) 104*e4b17023SJohn Marino #define ira_allocno_classes \ 105*e4b17023SJohn Marino (this_target_ira->x_ira_allocno_classes) 106*e4b17023SJohn Marino #define ira_allocno_class_translate \ 107*e4b17023SJohn Marino (this_target_ira->x_ira_allocno_class_translate) 108*e4b17023SJohn Marino #define ira_pressure_classes_num \ 109*e4b17023SJohn Marino (this_target_ira->x_ira_pressure_classes_num) 110*e4b17023SJohn Marino #define ira_pressure_classes \ 111*e4b17023SJohn Marino (this_target_ira->x_ira_pressure_classes) 112*e4b17023SJohn Marino #define ira_pressure_class_translate \ 113*e4b17023SJohn Marino (this_target_ira->x_ira_pressure_class_translate) 114*e4b17023SJohn Marino #define ira_stack_reg_pressure_class \ 115*e4b17023SJohn Marino (this_target_ira->x_ira_stack_reg_pressure_class) 116*e4b17023SJohn Marino #define ira_reg_class_max_nregs \ 117*e4b17023SJohn Marino (this_target_ira->x_ira_reg_class_max_nregs) 118*e4b17023SJohn Marino #define ira_reg_class_min_nregs \ 119*e4b17023SJohn Marino (this_target_ira->x_ira_reg_class_min_nregs) 120*e4b17023SJohn Marino #define ira_memory_move_cost \ 121*e4b17023SJohn Marino (this_target_ira->x_ira_memory_move_cost) 122*e4b17023SJohn Marino #define ira_class_hard_regs \ 123*e4b17023SJohn Marino (this_target_ira->x_ira_class_hard_regs) 124*e4b17023SJohn Marino #define ira_class_hard_regs_num \ 125*e4b17023SJohn Marino (this_target_ira->x_ira_class_hard_regs_num) 126*e4b17023SJohn Marino #define ira_no_alloc_regs \ 127*e4b17023SJohn Marino (this_target_ira->x_ira_no_alloc_regs) 128*e4b17023SJohn Marino 129*e4b17023SJohn Marino extern void ira_init_once (void); 130*e4b17023SJohn Marino extern void ira_init (void); 131*e4b17023SJohn Marino extern void ira_finish_once (void); 132*e4b17023SJohn Marino extern void ira_setup_eliminable_regset (void); 133*e4b17023SJohn Marino extern rtx ira_eliminate_regs (rtx, enum machine_mode); 134*e4b17023SJohn Marino extern void ira_set_pseudo_classes (FILE *); 135*e4b17023SJohn Marino extern void ira_implicitly_set_insn_hard_regs (HARD_REG_SET *); 136*e4b17023SJohn Marino 137*e4b17023SJohn Marino extern void ira_sort_regnos_for_alter_reg (int *, int, unsigned int *); 138*e4b17023SJohn Marino extern void ira_mark_allocation_change (int); 139*e4b17023SJohn Marino extern void ira_mark_memory_move_deletion (int, int); 140*e4b17023SJohn Marino extern bool ira_reassign_pseudos (int *, int, HARD_REG_SET, HARD_REG_SET *, 141*e4b17023SJohn Marino HARD_REG_SET *, bitmap); 142*e4b17023SJohn Marino extern rtx ira_reuse_stack_slot (int, unsigned int, unsigned int); 143*e4b17023SJohn Marino extern void ira_mark_new_stack_slot (rtx, int, unsigned int); 144*e4b17023SJohn Marino extern bool ira_better_spill_reload_regno_p (int *, int *, rtx, rtx, rtx); 145*e4b17023SJohn Marino extern bool ira_bad_reload_regno (int, rtx, rtx); 146*e4b17023SJohn Marino 147*e4b17023SJohn Marino extern void ira_adjust_equiv_reg_cost (unsigned, int); 148