OSDN Git Service

f656cf16737a422864d86530901b46066fde7159
[pf3gnuchains/gcc-fork.git] / gcc / ira-int.h
1 /* Integrated Register Allocator (IRA) intercommunication header file.
2    Copyright (C) 2006, 2007, 2008
3    Free Software Foundation, Inc.
4    Contributed by Vladimir Makarov <vmakarov@redhat.com>.
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
12
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3.  If not see
20 <http://www.gnu.org/licenses/>.  */
21
22 #include "cfgloop.h"
23 #include "ira.h"
24 #include "alloc-pool.h"
25
26 /* To provide consistency in naming, all IRA external variables,
27    functions, common typedefs start with prefix ira_.  */
28
29 #ifdef ENABLE_CHECKING
30 #define ENABLE_IRA_CHECKING
31 #endif
32
33 #ifdef ENABLE_IRA_CHECKING
34 #define ira_assert(c) gcc_assert (c)
35 #else
36 #define ira_assert(c)
37 #endif
38
39 /* Compute register frequency from edge frequency FREQ.  It is
40    analogous to REG_FREQ_FROM_BB.  When optimizing for size, or
41    profile driven feedback is available and the function is never
42    executed, frequency is always equivalent.  Otherwise rescale the
43    edge frequency.  */
44 #define REG_FREQ_FROM_EDGE_FREQ(freq)                                         \
45   (optimize_size || (flag_branch_probabilities && !ENTRY_BLOCK_PTR->count)    \
46    ? REG_FREQ_MAX : (freq * REG_FREQ_MAX / BB_FREQ_MAX)                       \
47    ? (freq * REG_FREQ_MAX / BB_FREQ_MAX) : 1)
48
49 /* All natural loops.  */
50 extern struct loops ira_loops;
51
52 /* A modified value of flag `-fira-verbose' used internally.  */
53 extern int internal_flag_ira_verbose;
54
55 /* Dump file of the allocator if it is not NULL.  */
56 extern FILE *ira_dump_file;
57
58 /* Typedefs for pointers to allocno live range, allocno, and copy of
59    allocnos.  */
60 typedef struct ira_allocno_live_range *allocno_live_range_t;
61 typedef struct ira_allocno *ira_allocno_t;
62 typedef struct ira_allocno_copy *ira_copy_t;
63
64 /* Definition of vector of allocnos and copies.  */
65 DEF_VEC_P(ira_allocno_t);
66 DEF_VEC_ALLOC_P(ira_allocno_t, heap);
67 DEF_VEC_P(ira_copy_t);
68 DEF_VEC_ALLOC_P(ira_copy_t, heap);
69
70 /* Typedef for pointer to the subsequent structure.  */
71 typedef struct ira_loop_tree_node *ira_loop_tree_node_t;
72
73 /* In general case, IRA is a regional allocator.  The regions are
74    nested and form a tree.  Currently regions are natural loops.  The
75    following structure describes loop tree node (representing basic
76    block or loop).  We need such tree because the loop tree from
77    cfgloop.h is not convenient for the optimization: basic blocks are
78    not a part of the tree from cfgloop.h.  We also use the nodes for
79    storing additional information about basic blocks/loops for the
80    register allocation purposes.  */
81 struct ira_loop_tree_node
82 {
83   /* The node represents basic block if children == NULL.  */
84   basic_block bb;    /* NULL for loop.  */
85   struct loop *loop; /* NULL for BB.  */
86   /* The next (loop) node of with the same parent.  SUBLOOP_NEXT is
87      always NULL for BBs. */
88   ira_loop_tree_node_t subloop_next, next;
89   /* The first (loop) node immediately inside the node.  SUBLOOPS is
90      always NULL for BBs.  */
91   ira_loop_tree_node_t subloops, children;
92   /* The node immediately containing given node.  */
93   ira_loop_tree_node_t parent;
94
95   /* Loop level in range [0, ira_loop_tree_height).  */
96   int level;
97
98   /* All the following members are defined only for nodes representing
99      loops.  */
100
101   /* Allocnos in the loop corresponding to their regnos.  If it is
102      NULL the loop does not form a separate register allocation region
103      (e.g. because it has abnormal enter/exit edges and we can not put
104      code for register shuffling on the edges if a different
105      allocation is used for a pseudo-register on different sides of
106      the edges).  Caps are not in the map (remember we can have more
107      one cap with the same regno in a region).  */
108   ira_allocno_t *regno_allocno_map;
109
110   /* Maximal register pressure inside loop for given register class
111      (defined only for the cover classes).  */
112   int reg_pressure[N_REG_CLASSES];
113
114   /* Numbers of allocnos referred in the loop node.  */
115   bitmap mentioned_allocnos;
116
117   /* Regnos of pseudos modified in the loop node (including its
118      subloops).  */
119   bitmap modified_regnos;
120
121   /* Numbers of allocnos living at the loop borders.  */
122   bitmap border_allocnos;
123
124   /* Numbers of copies referred in the corresponding loop.  */
125   bitmap local_copies;
126 };
127
128 /* The root of the loop tree corresponding to the all function.  */
129 extern ira_loop_tree_node_t ira_loop_tree_root;
130
131 /* Height of the loop tree.  */
132 extern int ira_loop_tree_height;
133
134 /* All nodes representing basic blocks are referred through the
135    following array.  We can not use basic block member `aux' for this
136    because it is used for insertion of insns on edges.  */
137 extern ira_loop_tree_node_t ira_bb_nodes;
138
139 /* Two access macros to the nodes representing basic blocks.  */
140 #if defined ENABLE_IRA_CHECKING && (GCC_VERSION >= 2007)
141 #define IRA_BB_NODE_BY_INDEX(index) __extension__                       \
142 (({ ira_loop_tree_node_t _node = (&ira_bb_nodes[index]);        \
143      if (_node->children != NULL || _node->loop != NULL || _node->bb == NULL)\
144        {                                                                \
145          fprintf (stderr,                                               \
146                   "\n%s: %d: error in %s: it is not a block node\n",    \
147                   __FILE__, __LINE__, __FUNCTION__);                    \
148          gcc_unreachable ();                                            \
149        }                                                                \
150      _node; }))
151 #else
152 #define IRA_BB_NODE_BY_INDEX(index) (&ira_bb_nodes[index])
153 #endif
154
155 #define IRA_BB_NODE(bb) IRA_BB_NODE_BY_INDEX ((bb)->index)
156
157 /* All nodes representing loops are referred through the following
158    array.  */
159 extern ira_loop_tree_node_t ira_loop_nodes;
160
161 /* Two access macros to the nodes representing loops.  */
162 #if defined ENABLE_IRA_CHECKING && (GCC_VERSION >= 2007)
163 #define IRA_LOOP_NODE_BY_INDEX(index) __extension__                     \
164 (({ ira_loop_tree_node_t const _node = (&ira_loop_nodes[index]);\
165      if (_node->children == NULL || _node->bb != NULL || _node->loop == NULL)\
166        {                                                                \
167          fprintf (stderr,                                               \
168                   "\n%s: %d: error in %s: it is not a loop node\n",     \
169                   __FILE__, __LINE__, __FUNCTION__);                    \
170          gcc_unreachable ();                                            \
171        }                                                                \
172      _node; }))
173 #else
174 #define IRA_LOOP_NODE_BY_INDEX(index) (&ira_loop_nodes[index])
175 #endif
176
177 #define IRA_LOOP_NODE(loop) IRA_LOOP_NODE_BY_INDEX ((loop)->num)
178
179 \f
180
181 /* The structure describes program points where a given allocno lives.
182    To save memory we store allocno conflicts only for the same cover
183    class allocnos which is enough to assign hard registers.  To find
184    conflicts for other allocnos (e.g. to assign stack memory slot) we
185    use the live ranges.  If the live ranges of two allocnos are
186    intersected, the allocnos are in conflict.  */
187 struct ira_allocno_live_range
188 {
189   /* Allocno whose live range is described by given structure.  */
190   ira_allocno_t allocno;
191   /* Program point range.  */
192   int start, finish;
193   /* Next structure describing program points where the allocno
194      lives.  */
195   allocno_live_range_t next;
196   /* Pointer to structures with the same start/finish.  */
197   allocno_live_range_t start_next, finish_next;
198 };
199
200 /* Program points are enumerated by numbers from range
201    0..IRA_MAX_POINT-1.  There are approximately two times more program
202    points than insns.  Program points are places in the program where
203    liveness info can be changed.  In most general case (there are more
204    complicated cases too) some program points correspond to places
205    where input operand dies and other ones correspond to places where
206    output operands are born.  */
207 extern int ira_max_point;
208
209 /* Arrays of size IRA_MAX_POINT mapping a program point to the allocno
210    live ranges with given start/finish point.  */
211 extern allocno_live_range_t *ira_start_point_ranges, *ira_finish_point_ranges;
212
213 /* A structure representing an allocno (allocation entity).  Allocno
214    represents a pseudo-register in an allocation region.  If
215    pseudo-register does not live in a region but it lives in the
216    nested regions, it is represented in the region by special allocno
217    called *cap*.  There may be more one cap representing the same
218    pseudo-register in region.  It means that the corresponding
219    pseudo-register lives in more one non-intersected subregion.  */
220 struct ira_allocno
221 {
222   /* The allocno order number starting with 0.  Each allocno has an
223      unique number and the number is never changed for the
224      allocno.  */
225   int num;
226   /* Regno for allocno or cap.  */
227   int regno;
228   /* Mode of the allocno which is the mode of the corresponding
229      pseudo-register.  */
230   enum machine_mode mode;
231   /* Final rtx representation of the allocno.  */
232   rtx reg;
233   /* Hard register assigned to given allocno.  Negative value means
234      that memory was allocated to the allocno.  During the reload,
235      spilled allocno has value equal to the corresponding stack slot
236      number (0, ...) - 2.  Value -1 is used for allocnos spilled by the
237      reload (at this point pseudo-register has only one allocno) which
238      did not get stack slot yet.  */
239   int hard_regno;
240   /* Allocnos with the same regno are linked by the following member.
241      Allocnos corresponding to inner loops are first in the list (it
242      corresponds to depth-first traverse of the loops).  */
243   ira_allocno_t next_regno_allocno;
244   /* There may be different allocnos with the same regno in different
245      regions.  Allocnos are bound to the corresponding loop tree node.
246      Pseudo-register may have only one regular allocno with given loop
247      tree node but more than one cap (see comments above).  */
248   ira_loop_tree_node_t loop_tree_node;
249   /* Accumulated usage references of the allocno.  Here and below,
250      word 'accumulated' means info for given region and all nested
251      subregions.  In this case, 'accumulated' means sum of references
252      of the corresponding pseudo-register in this region and in all
253      nested subregions recursively. */
254   int nrefs;
255   /* Accumulated frequency of usage of the allocno.  */
256   int freq;
257   /* Register class which should be used for allocation for given
258      allocno.  NO_REGS means that we should use memory.  */
259   enum reg_class cover_class;
260   /* Minimal accumulated cost of usage register of the cover class for
261      the allocno.  */
262   int cover_class_cost;
263   /* Minimal accumulated, and updated costs of memory for the allocno.
264      At the allocation start, the original and updated costs are
265      equal.  The updated cost may be changed after finishing
266      allocation in a region and starting allocation in a subregion.
267      The change reflects the cost of spill/restore code on the
268      subregion border if we assign memory to the pseudo in the
269      subregion.  */
270   int memory_cost, updated_memory_cost;
271   /* Accumulated number of points where the allocno lives and there is
272      excess pressure for its class.  Excess pressure for a register
273      class at some point means that there are more allocnos of given
274      register class living at the point than number of hard-registers
275      of the class available for the allocation.  */
276   int excess_pressure_points_num;
277   /* Copies to other non-conflicting allocnos.  The copies can
278      represent move insn or potential move insn usually because of two
279      operand insn constraints.  */
280   ira_copy_t allocno_copies;
281   /* It is a allocno (cap) representing given allocno on upper loop tree
282      level.  */
283   ira_allocno_t cap;
284   /* It is a link to allocno (cap) on lower loop level represented by
285      given cap.  Null if given allocno is not a cap.  */
286   ira_allocno_t cap_member;
287   /* Coalesced allocnos form a cyclic list.  One allocno given by
288      FIRST_COALESCED_ALLOCNO represents all coalesced allocnos.  The
289      list is chained by NEXT_COALESCED_ALLOCNO.  */
290   ira_allocno_t first_coalesced_allocno;
291   ira_allocno_t next_coalesced_allocno;
292   /* Pointer to structures describing at what program point the
293      allocno lives.  We always maintain the list in such way that *the
294      ranges in the list are not intersected and ordered by decreasing
295      their program points*.  */
296   allocno_live_range_t live_ranges;
297   /* Before building conflicts the two member values are
298      correspondingly minimal and maximal points of the accumulated
299      allocno live ranges.  After building conflicts the values are
300      correspondingly minimal and maximal conflict ids of allocnos with
301      which given allocno can conflict.  */
302   int min, max;
303   /* The unique member value represents given allocno in conflict bit
304      vectors.  */
305   int conflict_id;
306   /* Vector of accumulated conflicting allocnos with NULL end marker
307      (if CONFLICT_VEC_P is true) or conflict bit vector otherwise.
308      Only allocnos with the same cover class are in the vector or in
309      the bit vector.  */
310   void *conflict_allocno_array;
311   /* Allocated size of the previous array.  */
312   unsigned int conflict_allocno_array_size;
313   /* Number of accumulated conflicts in the vector of conflicting
314      allocnos.  */
315   int conflict_allocnos_num;
316   /* Initial and accumulated hard registers conflicting with this
317      allocno and as a consequences can not be assigned to the allocno.
318      All non-allocatable hard regs and hard regs of cover classes
319      different from given allocno one are included in the sets.  */
320   HARD_REG_SET conflict_hard_regs, total_conflict_hard_regs;
321   /* Accumulated frequency of calls which given allocno
322      intersects.  */
323   int call_freq;
324   /* Length of the previous array (number of the intersected calls).  */
325   int calls_crossed_num;
326   /* Non NULL if we remove restoring value from given allocno to
327      MEM_OPTIMIZED_DEST at loop exit (see ira-emit.c) because the
328      allocno value is not changed inside the loop.  */
329   ira_allocno_t mem_optimized_dest;
330   /* TRUE if the allocno assigned to memory was a destination of
331      removed move (see ira-emit.c) at loop exit because the value of
332      the corresponding pseudo-register is not changed inside the
333      loop.  */
334   unsigned int mem_optimized_dest_p : 1;
335   /* TRUE if the corresponding pseudo-register has disjoint live
336      ranges and the other allocnos of the pseudo-register except this
337      one changed REG.  */
338   unsigned int somewhere_renamed_p : 1;
339   /* TRUE if allocno with the same REGNO in a subregion has been
340      renamed, in other words, got a new pseudo-register.  */
341   unsigned int child_renamed_p : 1;
342   /* During the reload, value TRUE means that we should not reassign a
343      hard register to the allocno got memory earlier.  It is set up
344      when we removed memory-memory move insn before each iteration of
345      the reload.  */
346   unsigned int dont_reassign_p : 1;
347 #ifdef STACK_REGS
348   /* Set to TRUE if allocno can't be assigned to the stack hard
349      register correspondingly in this region and area including the
350      region and all its subregions recursively.  */
351   unsigned int no_stack_reg_p : 1, total_no_stack_reg_p : 1;
352 #endif
353   /* TRUE value means that the allocno was not removed yet from the
354      conflicting graph during colouring.  */
355   unsigned int in_graph_p : 1;
356   /* TRUE if a hard register or memory has been assigned to the
357      allocno.  */
358   unsigned int assigned_p : 1;
359   /* TRUE if it is put on the stack to make other allocnos
360      colorable.  */
361   unsigned int may_be_spilled_p : 1;
362   /* TRUE if the allocno was removed from the splay tree used to
363      choose allocn for spilling (see ira-color.c::.  */
364   unsigned int splay_removed_p : 1;
365   /* TRUE if conflicts for given allocno are represented by vector of
366      pointers to the conflicting allocnos.  Otherwise, we use a bit
367      vector where a bit with given index represents allocno with the
368      same number.  */
369   unsigned int conflict_vec_p : 1;
370   /* Array of usage costs (accumulated and the one updated during
371      coloring) for each hard register of the allocno cover class.  The
372      member value can be NULL if all costs are the same and equal to
373      COVER_CLASS_COST.  For example, the costs of two different hard
374      registers can be different if one hard register is callee-saved
375      and another one is callee-used and the allocno lives through
376      calls.  Another example can be case when for some insn the
377      corresponding pseudo-register value should be put in specific
378      register class (e.g. AREG for x86) which is a strict subset of
379      the allocno cover class (GENERAL_REGS for x86).  We have updated
380      costs to reflect the situation when the usage cost of a hard
381      register is decreased because the allocno is connected to another
382      allocno by a copy and the another allocno has been assigned to
383      the hard register.  */
384   int *hard_reg_costs, *updated_hard_reg_costs;
385   /* Array of decreasing costs (accumulated and the one updated during
386      coloring) for allocnos conflicting with given allocno for hard
387      regno of the allocno cover class.  The member value can be NULL
388      if all costs are the same.  These costs are used to reflect
389      preferences of other allocnos not assigned yet during assigning
390      to given allocno.  */
391   int *conflict_hard_reg_costs, *updated_conflict_hard_reg_costs;
392   /* Number of the same cover class allocnos with TRUE in_graph_p
393      value and conflicting with given allocno during each point of
394      graph coloring.  */
395   int left_conflicts_num;
396   /* Number of hard registers of the allocno cover class really
397      available for the allocno allocation.  */
398   int available_regs_num;
399   /* Allocnos in a bucket (used in coloring) chained by the following
400      two members.  */
401   ira_allocno_t next_bucket_allocno;
402   ira_allocno_t prev_bucket_allocno;
403   /* Used for temporary purposes.  */
404   int temp;
405 };
406
407 /* All members of the allocno structures should be accessed only
408    through the following macros.  */
409 #define ALLOCNO_NUM(A) ((A)->num)
410 #define ALLOCNO_REGNO(A) ((A)->regno)
411 #define ALLOCNO_REG(A) ((A)->reg)
412 #define ALLOCNO_NEXT_REGNO_ALLOCNO(A) ((A)->next_regno_allocno)
413 #define ALLOCNO_LOOP_TREE_NODE(A) ((A)->loop_tree_node)
414 #define ALLOCNO_CAP(A) ((A)->cap)
415 #define ALLOCNO_CAP_MEMBER(A) ((A)->cap_member)
416 #define ALLOCNO_CONFLICT_ALLOCNO_ARRAY(A) ((A)->conflict_allocno_array)
417 #define ALLOCNO_CONFLICT_ALLOCNO_ARRAY_SIZE(A) \
418   ((A)->conflict_allocno_array_size)
419 #define ALLOCNO_CONFLICT_ALLOCNOS_NUM(A) \
420   ((A)->conflict_allocnos_num)
421 #define ALLOCNO_CONFLICT_HARD_REGS(A) ((A)->conflict_hard_regs)
422 #define ALLOCNO_TOTAL_CONFLICT_HARD_REGS(A) ((A)->total_conflict_hard_regs)
423 #define ALLOCNO_NREFS(A) ((A)->nrefs)
424 #define ALLOCNO_FREQ(A) ((A)->freq)
425 #define ALLOCNO_HARD_REGNO(A) ((A)->hard_regno)
426 #define ALLOCNO_CALL_FREQ(A) ((A)->call_freq)
427 #define ALLOCNO_CALLS_CROSSED_NUM(A) ((A)->calls_crossed_num)
428 #define ALLOCNO_MEM_OPTIMIZED_DEST(A) ((A)->mem_optimized_dest)
429 #define ALLOCNO_MEM_OPTIMIZED_DEST_P(A) ((A)->mem_optimized_dest_p)
430 #define ALLOCNO_SOMEWHERE_RENAMED_P(A) ((A)->somewhere_renamed_p)
431 #define ALLOCNO_CHILD_RENAMED_P(A) ((A)->child_renamed_p)
432 #define ALLOCNO_DONT_REASSIGN_P(A) ((A)->dont_reassign_p)
433 #ifdef STACK_REGS
434 #define ALLOCNO_NO_STACK_REG_P(A) ((A)->no_stack_reg_p)
435 #define ALLOCNO_TOTAL_NO_STACK_REG_P(A) ((A)->total_no_stack_reg_p)
436 #endif
437 #define ALLOCNO_IN_GRAPH_P(A) ((A)->in_graph_p)
438 #define ALLOCNO_ASSIGNED_P(A) ((A)->assigned_p)
439 #define ALLOCNO_MAY_BE_SPILLED_P(A) ((A)->may_be_spilled_p)
440 #define ALLOCNO_SPLAY_REMOVED_P(A) ((A)->splay_removed_p)
441 #define ALLOCNO_CONFLICT_VEC_P(A) ((A)->conflict_vec_p)
442 #define ALLOCNO_MODE(A) ((A)->mode)
443 #define ALLOCNO_COPIES(A) ((A)->allocno_copies)
444 #define ALLOCNO_HARD_REG_COSTS(A) ((A)->hard_reg_costs)
445 #define ALLOCNO_UPDATED_HARD_REG_COSTS(A) ((A)->updated_hard_reg_costs)
446 #define ALLOCNO_CONFLICT_HARD_REG_COSTS(A) \
447   ((A)->conflict_hard_reg_costs)
448 #define ALLOCNO_UPDATED_CONFLICT_HARD_REG_COSTS(A) \
449   ((A)->updated_conflict_hard_reg_costs)
450 #define ALLOCNO_LEFT_CONFLICTS_NUM(A) ((A)->left_conflicts_num)
451 #define ALLOCNO_COVER_CLASS(A) ((A)->cover_class)
452 #define ALLOCNO_COVER_CLASS_COST(A) ((A)->cover_class_cost)
453 #define ALLOCNO_MEMORY_COST(A) ((A)->memory_cost)
454 #define ALLOCNO_UPDATED_MEMORY_COST(A) ((A)->updated_memory_cost)
455 #define ALLOCNO_EXCESS_PRESSURE_POINTS_NUM(A) ((A)->excess_pressure_points_num)
456 #define ALLOCNO_AVAILABLE_REGS_NUM(A) ((A)->available_regs_num)
457 #define ALLOCNO_NEXT_BUCKET_ALLOCNO(A) ((A)->next_bucket_allocno)
458 #define ALLOCNO_PREV_BUCKET_ALLOCNO(A) ((A)->prev_bucket_allocno)
459 #define IRA_ALLOCNO_TEMP(A) ((A)->temp)
460 #define ALLOCNO_FIRST_COALESCED_ALLOCNO(A) ((A)->first_coalesced_allocno)
461 #define ALLOCNO_NEXT_COALESCED_ALLOCNO(A) ((A)->next_coalesced_allocno)
462 #define ALLOCNO_LIVE_RANGES(A) ((A)->live_ranges)
463 #define ALLOCNO_MIN(A) ((A)->min)
464 #define ALLOCNO_MAX(A) ((A)->max)
465 #define ALLOCNO_CONFLICT_ID(A) ((A)->conflict_id)
466
467 /* Map regno -> allocnos with given regno (see comments for 
468    allocno member `next_regno_allocno').  */
469 extern ira_allocno_t *ira_regno_allocno_map;
470
471 /* Array of references to all allocnos.  The order number of the
472    allocno corresponds to the index in the array.  Removed allocnos
473    have NULL element value.  */
474 extern ira_allocno_t *ira_allocnos;
475
476 /* Sizes of the previous array.  */
477 extern int ira_allocnos_num;
478
479 /* Map conflict id -> allocno with given conflict id (see comments for
480    allocno member `conflict_id').  */
481 extern ira_allocno_t *ira_conflict_id_allocno_map;
482
483 /* The following structure represents a copy of two allocnos.  The
484    copies represent move insns or potential move insns usually because
485    of two operand insn constraints.  To remove register shuffle, we
486    also create copies between allocno which is output of an insn and
487    allocno becoming dead in the insn.  */
488 struct ira_allocno_copy
489 {
490   /* The unique order number of the copy node starting with 0.  */
491   int num;
492   /* Allocnos connected by the copy.  The first allocno should have
493      smaller order number than the second one.  */
494   ira_allocno_t first, second;
495   /* Execution frequency of the copy.  */
496   int freq;
497   /* It is a move insn which is an origin of the copy.  The member
498      value for the copy representing two operand insn constraints or
499      for the copy created to remove register shuffle is NULL.  In last
500      case the copy frequency is smaller than the corresponding insn
501      execution frequency.  */
502   rtx insn;
503   /* All copies with the same allocno as FIRST are linked by the two
504      following members.  */
505   ira_copy_t prev_first_allocno_copy, next_first_allocno_copy;
506   /* All copies with the same allocno as SECOND are linked by the two
507      following members.  */
508   ira_copy_t prev_second_allocno_copy, next_second_allocno_copy;
509   /* Region from which given copy is originated.  */
510   ira_loop_tree_node_t loop_tree_node;
511 };
512
513 /* Array of references to all copies.  The order number of the copy
514    corresponds to the index in the array.  Removed copies have NULL
515    element value.  */
516 extern ira_copy_t *ira_copies;
517
518 /* Size of the previous array.  */
519 extern int ira_copies_num;
520
521 /* The following structure describes a stack slot used for spilled
522    pseudo-registers.  */
523 struct ira_spilled_reg_stack_slot
524 {
525   /* pseudo-registers assigned to the stack slot.  */
526   regset_head spilled_regs;
527   /* RTL representation of the stack slot.  */
528   rtx mem;
529   /* Size of the stack slot.  */
530   unsigned int width;
531 };
532
533 /* The number of elements in the following array.  */
534 extern int ira_spilled_reg_stack_slots_num;
535
536 /* The following array contains info about spilled pseudo-registers
537    stack slots used in current function so far.  */
538 extern struct ira_spilled_reg_stack_slot *ira_spilled_reg_stack_slots;
539
540 /* Correspondingly overall cost of the allocation, cost of the
541    allocnos assigned to hard-registers, cost of the allocnos assigned
542    to memory, cost of loads, stores and register move insns generated
543    for pseudo-register live range splitting (see ira-emit.c).  */
544 extern int ira_overall_cost;
545 extern int ira_reg_cost, ira_mem_cost;
546 extern int ira_load_cost, ira_store_cost, ira_shuffle_cost;
547 extern int ira_move_loops_num, ira_additional_jumps_num;
548
549 /* Map: register class x machine mode -> number of hard registers of
550    given class needed to store value of given mode.  If the number for
551    some hard-registers of the register class is different, the size
552    will be negative.  */
553 extern int ira_reg_class_nregs[N_REG_CLASSES][MAX_MACHINE_MODE];
554
555 /* Maximal value of the previous array elements.  */
556 extern int ira_max_nregs;
557
558 /* The number of bits in each element of array used to implement a bit
559    vector of allocnos and what type that element has.  We use the
560    largest integer format on the host machine.  */
561 #define IRA_INT_BITS HOST_BITS_PER_WIDE_INT
562 #define IRA_INT_TYPE HOST_WIDE_INT
563
564 /* Set, clear or test bit number I in R, a bit vector of elements with
565    minimal index and maximal index equal correspondingly to MIN and
566    MAX.  */
567 #if defined ENABLE_IRA_CHECKING && (GCC_VERSION >= 2007)
568
569 #define SET_ALLOCNO_SET_BIT(R, I, MIN, MAX) __extension__               \
570   (({ int _min = (MIN), _max = (MAX), _i = (I);                         \
571      if (_i < _min || _i > _max)                                        \
572        {                                                                \
573          fprintf (stderr,                                               \
574                   "\n%s: %d: error in %s: %d not in range [%d,%d]\n",   \
575                   __FILE__, __LINE__, __FUNCTION__, _i, _min, _max);    \
576          gcc_unreachable ();                                            \
577        }                                                                \
578      ((R)[(unsigned) (_i - _min) / IRA_INT_BITS]                        \
579       |= ((IRA_INT_TYPE) 1 << ((unsigned) (_i - _min) % IRA_INT_BITS))); }))
580   
581
582 #define CLEAR_ALLOCNO_SET_BIT(R, I, MIN, MAX) __extension__             \
583   (({ int _min = (MIN), _max = (MAX), _i = (I);                         \
584      if (_i < _min || _i > _max)                                        \
585        {                                                                \
586          fprintf (stderr,                                               \
587                   "\n%s: %d: error in %s: %d not in range [%d,%d]\n",   \
588                   __FILE__, __LINE__, __FUNCTION__, _i, _min, _max);    \
589          gcc_unreachable ();                                            \
590        }                                                                \
591      ((R)[(unsigned) (_i - _min) / IRA_INT_BITS]                        \
592       &= ~((IRA_INT_TYPE) 1 << ((unsigned) (_i - _min) % IRA_INT_BITS))); }))
593
594 #define TEST_ALLOCNO_SET_BIT(R, I, MIN, MAX) __extension__              \
595   (({ int _min = (MIN), _max = (MAX), _i = (I);                         \
596      if (_i < _min || _i > _max)                                        \
597        {                                                                \
598          fprintf (stderr,                                               \
599                   "\n%s: %d: error in %s: %d not in range [%d,%d]\n",   \
600                   __FILE__, __LINE__, __FUNCTION__, _i, _min, _max);    \
601          gcc_unreachable ();                                            \
602        }                                                                \
603      ((R)[(unsigned) (_i - _min) / IRA_INT_BITS]                        \
604       & ((IRA_INT_TYPE) 1 << ((unsigned) (_i - _min) % IRA_INT_BITS))); }))
605
606 #else
607
608 #define SET_ALLOCNO_SET_BIT(R, I, MIN, MAX)                     \
609   ((R)[(unsigned) ((I) - (MIN)) / IRA_INT_BITS]                 \
610    |= ((IRA_INT_TYPE) 1 << ((unsigned) ((I) - (MIN)) % IRA_INT_BITS)))
611
612 #define CLEAR_ALLOCNO_SET_BIT(R, I, MIN, MAX)                   \
613   ((R)[(unsigned) ((I) - (MIN)) / IRA_INT_BITS]                 \
614    &= ~((IRA_INT_TYPE) 1 << ((unsigned) ((I) - (MIN)) % IRA_INT_BITS)))
615
616 #define TEST_ALLOCNO_SET_BIT(R, I, MIN, MAX)                    \
617   ((R)[(unsigned) ((I) - (MIN)) / IRA_INT_BITS]                 \
618    & ((IRA_INT_TYPE) 1 << ((unsigned) ((I) - (MIN)) % IRA_INT_BITS)))
619
620 #endif
621
622 /* The iterator for allocno set implemented ed as allocno bit
623    vector.  */
624 typedef struct {
625
626   /* Array containing the allocno bit vector.  */
627   IRA_INT_TYPE *vec;
628
629   /* The number of the current element in the vector.  */
630   unsigned int word_num;
631
632   /* The number of bits in the bit vector.  */
633   unsigned int nel;
634
635   /* The current bit index of the bit vector.  */
636   unsigned int bit_num;
637
638   /* Index corresponding to the 1st bit of the bit vector.   */
639   int start_val;
640
641   /* The word of the bit vector currently visited.  */
642   unsigned IRA_INT_TYPE word;
643 } ira_allocno_set_iterator;
644
645 /* Initialize the iterator I for allocnos bit vector VEC containing
646    minimal and maximal values MIN and MAX.  */
647 static inline void
648 ira_allocno_set_iter_init (ira_allocno_set_iterator *i,
649                            IRA_INT_TYPE *vec, int min, int max)
650 {
651   i->vec = vec;
652   i->word_num = 0;
653   i->nel = max < min ? 0 : max - min + 1;
654   i->start_val = min;
655   i->bit_num = 0;
656   i->word = i->nel == 0 ? 0 : vec[0];
657 }
658
659 /* Return TRUE if we have more allocnos to visit, in which case *N is
660    set to the allocno number to be visited.  Otherwise, return
661    FALSE.  */
662 static inline bool
663 ira_allocno_set_iter_cond (ira_allocno_set_iterator *i, int *n)
664 {
665   /* Skip words that are zeros.  */
666   for (; i->word == 0; i->word = i->vec[i->word_num])
667     {
668       i->word_num++;
669       i->bit_num = i->word_num * IRA_INT_BITS;
670       
671       /* If we have reached the end, break.  */
672       if (i->bit_num >= i->nel)
673         return false;
674     }
675   
676   /* Skip bits that are zero.  */
677   for (; (i->word & 1) == 0; i->word >>= 1)
678     i->bit_num++;
679   
680   *n = (int) i->bit_num + i->start_val;
681   
682   return true;
683 }
684
685 /* Advance to the next allocno in the set.  */
686 static inline void
687 ira_allocno_set_iter_next (ira_allocno_set_iterator *i)
688 {
689   i->word >>= 1;
690   i->bit_num++;
691 }
692
693 /* Loop over all elements of allocno set given by bit vector VEC and
694    their minimal and maximal values MIN and MAX.  In each iteration, N
695    is set to the number of next allocno.  ITER is an instance of
696    ira_allocno_set_iterator used to iterate the allocnos in the set.  */
697 #define FOR_EACH_ALLOCNO_IN_SET(VEC, MIN, MAX, N, ITER)         \
698   for (ira_allocno_set_iter_init (&(ITER), (VEC), (MIN), (MAX));        \
699        ira_allocno_set_iter_cond (&(ITER), &(N));                       \
700        ira_allocno_set_iter_next (&(ITER)))
701
702 /* ira.c: */
703
704 /* Hard regsets whose all bits are correspondingly zero or one.  */
705 extern HARD_REG_SET ira_zero_hard_reg_set;
706 extern HARD_REG_SET ira_one_hard_reg_set;
707
708 /* Map: hard regs X modes -> set of hard registers for storing value
709    of given mode starting with given hard register.  */
710 extern HARD_REG_SET ira_reg_mode_hard_regset
711                     [FIRST_PSEUDO_REGISTER][NUM_MACHINE_MODES];
712
713 /* Arrays analogous to macros MEMORY_MOVE_COST and
714    REGISTER_MOVE_COST.  */
715 extern short ira_memory_move_cost[MAX_MACHINE_MODE][N_REG_CLASSES][2];
716 extern move_table *ira_register_move_cost[MAX_MACHINE_MODE];
717
718 /* Similar to may_move_in_cost but it is calculated in IRA instead of
719    regclass.  Another difference we take only available hard registers
720    into account to figure out that one register class is a subset of
721    the another one.  */
722 extern move_table *ira_may_move_in_cost[MAX_MACHINE_MODE];
723
724 /* Similar to may_move_out_cost but it is calculated in IRA instead of
725    regclass.  Another difference we take only available hard registers
726    into account to figure out that one register class is a subset of
727    the another one.  */
728 extern move_table *ira_may_move_out_cost[MAX_MACHINE_MODE];
729
730 /* Register class subset relation: TRUE if the first class is a subset
731    of the second one considering only hard registers available for the
732    allocation.  */
733 extern int ira_class_subset_p[N_REG_CLASSES][N_REG_CLASSES];
734
735 /* Array of number of hard registers of given class which are
736    available for the allocation.  The order is defined by the
737    allocation order.  */
738 extern short ira_class_hard_regs[N_REG_CLASSES][FIRST_PSEUDO_REGISTER];
739
740 /* The number of elements of the above array for given register
741    class.  */
742 extern int ira_class_hard_regs_num[N_REG_CLASSES];
743
744 /* Index (in ira_class_hard_regs) for given register class and hard
745    register (in general case a hard register can belong to several
746    register classes).  The index is negative for hard registers
747    unavailable for the allocation. */
748 extern short ira_class_hard_reg_index[N_REG_CLASSES][FIRST_PSEUDO_REGISTER];
749
750 /* Function specific hard registers can not be used for the register
751    allocation.  */
752 extern HARD_REG_SET ira_no_alloc_regs;
753
754 /* Number of given class hard registers available for the register
755    allocation for given classes.  */
756 extern int ira_available_class_regs[N_REG_CLASSES];
757
758 /* Array whose values are hard regset of hard registers available for
759    the allocation of given register class whose HARD_REGNO_MODE_OK
760    values for given mode are zero.  */
761 extern HARD_REG_SET prohibited_class_mode_regs
762                     [N_REG_CLASSES][NUM_MACHINE_MODES];
763
764 /* Array whose values are hard regset of hard registers for which
765    move of the hard register in given mode into itself is
766    prohibited.  */
767 extern HARD_REG_SET ira_prohibited_mode_move_regs[NUM_MACHINE_MODES];
768
769 /* Number of cover classes.  Cover classes is non-intersected register
770    classes containing all hard-registers available for the
771    allocation.  */
772 extern int ira_reg_class_cover_size;
773
774 /* The array containing cover classes (see also comments for macro
775    IRA_COVER_CLASSES).  Only first IRA_REG_CLASS_COVER_SIZE elements are
776    used for this.  */
777 extern enum reg_class ira_reg_class_cover[N_REG_CLASSES];
778
779 /* The value is number of elements in the subsequent array.  */
780 extern int ira_important_classes_num;
781
782 /* The array containing non-empty classes (including non-empty cover
783    classes) which are subclasses of cover classes.  Such classes is
784    important for calculation of the hard register usage costs.  */
785 extern enum reg_class ira_important_classes[N_REG_CLASSES];
786
787 /* The array containing indexes of important classes in the previous
788    array.  The array elements are defined only for important
789    classes.  */
790 extern int ira_important_class_nums[N_REG_CLASSES];
791
792 /* Map of all register classes to corresponding cover class containing
793    the given class.  If given class is not a subset of a cover class,
794    we translate it into the cheapest cover class.  */
795 extern enum reg_class ira_class_translate[N_REG_CLASSES];
796
797 /* The biggest important class inside of intersection of the two
798    classes (that is calculated taking only hard registers available
799    for allocation into account).  If the both classes contain no hard
800    registers available for allocation, the value is calculated with
801    taking all hard-registers including fixed ones into account.  */
802 extern enum reg_class ira_reg_class_intersect[N_REG_CLASSES][N_REG_CLASSES];
803
804 /* The biggest important class inside of union of the two classes
805    (that is calculated taking only hard registers available for
806    allocation into account).  If the both classes contain no hard
807    registers available for allocation, the value is calculated with
808    taking all hard-registers including fixed ones into account.  In
809    other words, the value is the corresponding reg_class_subunion
810    value.  */
811 extern enum reg_class ira_reg_class_union[N_REG_CLASSES][N_REG_CLASSES];
812
813 extern void *ira_allocate (size_t);
814 extern void *ira_reallocate (void *, size_t);
815 extern void ira_free (void *addr);
816 extern bitmap ira_allocate_bitmap (void);
817 extern void ira_free_bitmap (bitmap);
818 extern void ira_print_disposition (FILE *);
819 extern void ira_debug_disposition (void);
820 extern void ira_debug_class_cover (void);
821 extern void ira_init_register_move_cost (enum machine_mode);
822
823 /* The length of the two following arrays.  */
824 extern int ira_reg_equiv_len;
825
826 /* The element value is TRUE if the corresponding regno value is
827    invariant.  */
828 extern bool *ira_reg_equiv_invariant_p;
829
830 /* The element value is equiv constant of given pseudo-register or
831    NULL_RTX.  */
832 extern rtx *ira_reg_equiv_const;
833
834 /* ira-build.c */
835
836 /* The current loop tree node and its regno allocno map.  */
837 extern ira_loop_tree_node_t ira_curr_loop_tree_node;
838 extern ira_allocno_t *ira_curr_regno_allocno_map;
839
840 extern void ira_debug_allocno_copies (ira_allocno_t);
841
842 extern void ira_traverse_loop_tree (bool, ira_loop_tree_node_t,
843                                     void (*) (ira_loop_tree_node_t),
844                                     void (*) (ira_loop_tree_node_t));
845 extern ira_allocno_t ira_create_allocno (int, bool, ira_loop_tree_node_t);
846 extern void ira_set_allocno_cover_class (ira_allocno_t, enum reg_class);
847 extern bool ira_conflict_vector_profitable_p (ira_allocno_t, int);
848 extern void ira_allocate_allocno_conflict_vec (ira_allocno_t, int);
849 extern void ira_allocate_allocno_conflicts (ira_allocno_t, int);
850 extern void ira_add_allocno_conflict (ira_allocno_t, ira_allocno_t);
851 extern void ira_print_expanded_allocno (ira_allocno_t);
852 extern allocno_live_range_t ira_create_allocno_live_range
853                             (ira_allocno_t, int, int, allocno_live_range_t);
854 extern void ira_finish_allocno_live_range (allocno_live_range_t);
855 extern void ira_free_allocno_updated_costs (ira_allocno_t);
856 extern ira_copy_t ira_create_copy (ira_allocno_t, ira_allocno_t,
857                                    int, rtx, ira_loop_tree_node_t);
858 extern void ira_add_allocno_copy_to_list (ira_copy_t);
859 extern void ira_swap_allocno_copy_ends_if_necessary (ira_copy_t);
860 extern void ira_remove_allocno_copy_from_list (ira_copy_t);
861 extern ira_copy_t ira_add_allocno_copy (ira_allocno_t, ira_allocno_t, int, rtx,
862                                         ira_loop_tree_node_t);
863
864 extern int *ira_allocate_cost_vector (enum reg_class);
865 extern void ira_free_cost_vector (int *, enum reg_class);
866
867 extern void ira_flattening (int, int);
868 extern bool ira_build (bool);
869 extern void ira_destroy (void);
870
871 /* ira-costs.c */
872 extern void ira_init_costs_once (void);
873 extern void ira_init_costs (void);
874 extern void ira_finish_costs_once (void);
875 extern void ira_costs (void);
876 extern void ira_tune_allocno_costs_and_cover_classes (void);
877
878 /* ira-lives.c */
879
880 extern void ira_rebuild_start_finish_chains (void);
881 extern void ira_print_live_range_list (FILE *, allocno_live_range_t);
882 extern void ira_debug_live_range_list (allocno_live_range_t);
883 extern void ira_debug_allocno_live_ranges (ira_allocno_t);
884 extern void ira_debug_live_ranges (void);
885 extern void ira_create_allocno_live_ranges (void);
886 extern void ira_finish_allocno_live_ranges (void);
887
888 /* ira-conflicts.c */
889 extern bool ira_allocno_live_ranges_intersect_p (ira_allocno_t, ira_allocno_t);
890 extern bool ira_pseudo_live_ranges_intersect_p (int, int);
891 extern void ira_debug_conflicts (bool);
892 extern void ira_build_conflicts (void);
893
894 /* ira-color.c */
895 extern int ira_loop_edge_freq (ira_loop_tree_node_t, int, bool);
896 extern void ira_reassign_conflict_allocnos (int);
897 extern void ira_initiate_assign (void);
898 extern void ira_finish_assign (void);
899 extern void ira_color (void);
900 extern void ira_fast_allocation (void);
901
902 /* ira-emit.c */
903 extern void ira_emit (bool);
904
905 \f
906
907 /* The iterator for all allocnos.  */
908 typedef struct {
909   /* The number of the current element in IRA_ALLOCNOS.  */
910   int n;
911 } ira_allocno_iterator;
912
913 /* Initialize the iterator I.  */
914 static inline void
915 ira_allocno_iter_init (ira_allocno_iterator *i)
916 {
917   i->n = 0;
918 }
919
920 /* Return TRUE if we have more allocnos to visit, in which case *A is
921    set to the allocno to be visited.  Otherwise, return FALSE.  */
922 static inline bool
923 ira_allocno_iter_cond (ira_allocno_iterator *i, ira_allocno_t *a)
924 {
925   int n;
926
927   for (n = i->n; n < ira_allocnos_num; n++)
928     if (ira_allocnos[n] != NULL)
929       {
930         *a = ira_allocnos[n];
931         i->n = n + 1;
932         return true;
933       }
934   return false;
935 }
936
937 /* Loop over all allocnos.  In each iteration, A is set to the next
938    allocno.  ITER is an instance of ira_allocno_iterator used to iterate
939    the allocnos.  */
940 #define FOR_EACH_ALLOCNO(A, ITER)                       \
941   for (ira_allocno_iter_init (&(ITER));                 \
942        ira_allocno_iter_cond (&(ITER), &(A));)
943
944
945 \f
946
947 /* The iterator for copies.  */
948 typedef struct {
949   /* The number of the current element in IRA_COPIES.  */
950   int n;
951 } ira_copy_iterator;
952
953 /* Initialize the iterator I.  */
954 static inline void
955 ira_copy_iter_init (ira_copy_iterator *i)
956 {
957   i->n = 0;
958 }
959
960 /* Return TRUE if we have more copies to visit, in which case *CP is
961    set to the copy to be visited.  Otherwise, return FALSE.  */
962 static inline bool
963 ira_copy_iter_cond (ira_copy_iterator *i, ira_copy_t *cp)
964 {
965   int n;
966
967   for (n = i->n; n < ira_copies_num; n++)
968     if (ira_copies[n] != NULL)
969       {
970         *cp = ira_copies[n];
971         i->n = n + 1;
972         return true;
973       }
974   return false;
975 }
976
977 /* Loop over all copies.  In each iteration, C is set to the next
978    copy.  ITER is an instance of ira_copy_iterator used to iterate
979    the copies.  */
980 #define FOR_EACH_COPY(C, ITER)                          \
981   for (ira_copy_iter_init (&(ITER));                    \
982        ira_copy_iter_cond (&(ITER), &(C));)
983
984
985 \f
986
987 /* The iterator for allocno conflicts.  */
988 typedef struct {
989
990   /* TRUE if the conflicts are represented by vector of allocnos.  */
991   bool allocno_conflict_vec_p;
992
993   /* The conflict vector or conflict bit vector.  */
994   void *vec;
995
996   /* The number of the current element in the vector (of type
997      ira_allocno_t or IRA_INT_TYPE).  */
998   unsigned int word_num;
999
1000   /* The bit vector size.  It is defined only if
1001      ALLOCNO_CONFLICT_VEC_P is FALSE.  */
1002   unsigned int size;
1003
1004   /* The current bit index of bit vector.  It is defined only if
1005      ALLOCNO_CONFLICT_VEC_P is FALSE.  */
1006   unsigned int bit_num;
1007
1008   /* Allocno conflict id corresponding to the 1st bit of the bit
1009      vector.  It is defined only if ALLOCNO_CONFLICT_VEC_P is
1010      FALSE.  */
1011   int base_conflict_id;
1012
1013   /* The word of bit vector currently visited.  It is defined only if
1014      ALLOCNO_CONFLICT_VEC_P is FALSE.  */
1015   unsigned IRA_INT_TYPE word;
1016 } ira_allocno_conflict_iterator;
1017
1018 /* Initialize the iterator I with ALLOCNO conflicts.  */
1019 static inline void
1020 ira_allocno_conflict_iter_init (ira_allocno_conflict_iterator *i,
1021                                 ira_allocno_t allocno)
1022 {
1023   i->allocno_conflict_vec_p = ALLOCNO_CONFLICT_VEC_P (allocno);
1024   i->vec = ALLOCNO_CONFLICT_ALLOCNO_ARRAY (allocno);
1025   i->word_num = 0;
1026   if (i->allocno_conflict_vec_p)
1027     i->size = i->bit_num = i->base_conflict_id = i->word = 0;
1028   else
1029     {
1030       if (ALLOCNO_MIN (allocno) > ALLOCNO_MAX (allocno))
1031         i->size = 0;
1032       else
1033         i->size = ((ALLOCNO_MAX (allocno) - ALLOCNO_MIN (allocno)
1034                     + IRA_INT_BITS)
1035                    / IRA_INT_BITS) * sizeof (IRA_INT_TYPE);
1036       i->bit_num = 0;
1037       i->base_conflict_id = ALLOCNO_MIN (allocno);
1038       i->word = (i->size == 0 ? 0 : ((IRA_INT_TYPE *) i->vec)[0]);
1039     }
1040 }
1041
1042 /* Return TRUE if we have more conflicting allocnos to visit, in which
1043    case *A is set to the allocno to be visited.  Otherwise, return
1044    FALSE.  */
1045 static inline bool
1046 ira_allocno_conflict_iter_cond (ira_allocno_conflict_iterator *i,
1047                                 ira_allocno_t *a)
1048 {
1049   ira_allocno_t conflict_allocno;
1050
1051   if (i->allocno_conflict_vec_p)
1052     {
1053       conflict_allocno = ((ira_allocno_t *) i->vec)[i->word_num];
1054       if (conflict_allocno == NULL)
1055         return false;
1056       *a = conflict_allocno;
1057       return true;
1058     }
1059   else
1060     {
1061       /* Skip words that are zeros.  */
1062       for (; i->word == 0; i->word = ((IRA_INT_TYPE *) i->vec)[i->word_num])
1063         {
1064           i->word_num++;
1065           
1066           /* If we have reached the end, break.  */
1067           if (i->word_num * sizeof (IRA_INT_TYPE) >= i->size)
1068             return false;
1069           
1070           i->bit_num = i->word_num * IRA_INT_BITS;
1071         }
1072       
1073       /* Skip bits that are zero.  */
1074       for (; (i->word & 1) == 0; i->word >>= 1)
1075         i->bit_num++;
1076       
1077       *a = ira_conflict_id_allocno_map[i->bit_num + i->base_conflict_id];
1078       
1079       return true;
1080     }
1081 }
1082
1083 /* Advance to the next conflicting allocno.  */
1084 static inline void
1085 ira_allocno_conflict_iter_next (ira_allocno_conflict_iterator *i)
1086 {
1087   if (i->allocno_conflict_vec_p)
1088     i->word_num++;
1089   else
1090     {
1091       i->word >>= 1;
1092       i->bit_num++;
1093     }
1094 }
1095
1096 /* Loop over all allocnos conflicting with ALLOCNO.  In each
1097    iteration, A is set to the next conflicting allocno.  ITER is an
1098    instance of ira_allocno_conflict_iterator used to iterate the
1099    conflicts.  */
1100 #define FOR_EACH_ALLOCNO_CONFLICT(ALLOCNO, A, ITER)                     \
1101   for (ira_allocno_conflict_iter_init (&(ITER), (ALLOCNO));             \
1102        ira_allocno_conflict_iter_cond (&(ITER), &(A));                  \
1103        ira_allocno_conflict_iter_next (&(ITER)))
1104
1105 \f
1106
1107 /* The function returns TRUE if hard registers starting with
1108    HARD_REGNO and containing value of MODE are not in set
1109    HARD_REGSET.  */
1110 static inline bool
1111 ira_hard_reg_not_in_set_p (int hard_regno, enum machine_mode mode,
1112                            HARD_REG_SET hard_regset)
1113 {
1114   int i;
1115
1116   ira_assert (hard_regno >= 0);
1117   for (i = hard_regno_nregs[hard_regno][mode] - 1; i >= 0; i--)
1118     if (TEST_HARD_REG_BIT (hard_regset, hard_regno + i))
1119       return false;
1120   return true;
1121 }
1122
1123 \f
1124
1125 /* To save memory we use a lazy approach for allocation and
1126    initialization of the cost vectors.  We do this only when it is
1127    really necessary.  */
1128
1129 /* Allocate cost vector *VEC for hard registers of COVER_CLASS and
1130    initialize the elements by VAL if it is necessary */
1131 static inline void
1132 ira_allocate_and_set_costs (int **vec, enum reg_class cover_class, int val)
1133 {
1134   int i, *reg_costs;
1135   int len;
1136
1137   if (*vec != NULL)
1138     return;
1139   *vec = reg_costs = ira_allocate_cost_vector (cover_class);
1140   len = ira_class_hard_regs_num[cover_class];
1141   for (i = 0; i < len; i++)
1142     reg_costs[i] = val;
1143 }
1144
1145 /* Allocate cost vector *VEC for hard registers of COVER_CLASS and
1146    copy values of vector SRC into the vector if it is necessary */
1147 static inline void
1148 ira_allocate_and_copy_costs (int **vec, enum reg_class cover_class, int *src)
1149 {
1150   int len;
1151
1152   if (*vec != NULL || src == NULL)
1153     return;
1154   *vec = ira_allocate_cost_vector (cover_class);
1155   len = ira_class_hard_regs_num[cover_class];
1156   memcpy (*vec, src, sizeof (int) * len);
1157 }
1158
1159 /* Allocate cost vector *VEC for hard registers of COVER_CLASS and
1160    add values of vector SRC into the vector if it is necessary */
1161 static inline void
1162 ira_allocate_and_accumulate_costs (int **vec, enum reg_class cover_class,
1163                                    int *src)
1164 {
1165   int i, len;
1166
1167   if (src == NULL)
1168     return;
1169   len = ira_class_hard_regs_num[cover_class];
1170   if (*vec == NULL)
1171     {
1172       *vec = ira_allocate_cost_vector (cover_class);
1173       memset (*vec, 0, sizeof (int) * len);
1174     }
1175   for (i = 0; i < len; i++)
1176     (*vec)[i] += src[i];
1177 }
1178
1179 /* Allocate cost vector *VEC for hard registers of COVER_CLASS and
1180    copy values of vector SRC into the vector or initialize it by VAL
1181    (if SRC is null).  */
1182 static inline void
1183 ira_allocate_and_set_or_copy_costs (int **vec, enum reg_class cover_class,
1184                                     int val, int *src)
1185 {
1186   int i, *reg_costs;
1187   int len;
1188
1189   if (*vec != NULL)
1190     return;
1191   *vec = reg_costs = ira_allocate_cost_vector (cover_class);
1192   len = ira_class_hard_regs_num[cover_class];
1193   if (src != NULL)
1194     memcpy (reg_costs, src, sizeof (int) * len);
1195   else
1196     {
1197       for (i = 0; i < len; i++)
1198         reg_costs[i] = val;
1199     }
1200 }