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