aboutsummaryrefslogtreecommitdiff
path: root/gcc/ra.h
blob: 91f7af6aa715e0d93f3e15c152aaf76a51b08624 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
/* Graph coloring register allocator
   Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
   Contributed by Michael Matz <matz@suse.de>
   and Daniel Berlin <dan@cgsoftware.com>.

   This file is part of GCC.

   GCC is free software; you can redistribute it and/or modify it under the
   terms of the GNU General Public License as published by the Free Software
   Foundation; either version 2, or (at your option) any later version.

   GCC is distributed in the hope that it will be useful, but WITHOUT ANY
   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
   details.

   You should have received a copy of the GNU General Public License along
   with GCC; see the file COPYING.  If not, write to the Free Software
   Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */

/* Double linked list to implement the per-type lists of webs
   and moves.  */
struct dlist
{
  struct dlist *prev;
  struct dlist *next;
  union
    {
      struct web *web;
      struct move *move;
    } value;
};
/* Simple helper macros for ease of misuse.  */
#define DLIST_WEB(l) ((l)->value.web)
#define DLIST_MOVE(l) ((l)->value.move)

/* Classification of a given node (i.e. what state it's in).  */
enum node_type
{
  INITIAL = 0, FREE,
  PRECOLORED,
  SIMPLIFY, SIMPLIFY_SPILL, SIMPLIFY_FAT, FREEZE, SPILL,
  SELECT,
  SPILLED, COALESCED, COLORED,
  LAST_NODE_TYPE
};

/* A list of conflict bitmaps, factorized on the exact part of
   the source, which conflicts with the DEFs, whose ID are noted in
   the bitmap.  This is used while building web-parts with conflicts.  */
struct tagged_conflict
{
  struct tagged_conflict *next;
  bitmap conflicts;

  /* If the part of source identified by size S, byteoffset O conflicts,
     then size_word == S | (O << 16).  */
  unsigned int size_word;
};

/* Such a structure is allocated initially for each def and use.
   In the process of building the interference graph web parts are
   connected together, if they have common instructions and reference the
   same register.  That way live ranges are build (by connecting defs and
   uses) and implicitly complete webs (by connecting web parts in common
   uses).  */
struct web_part
{
  /* The def or use for this web part.  */
  struct ref *ref;
  /* The uplink implementing the disjoint set.  */
  struct web_part *uplink;

  /* Here dynamic information associated with each def/use is saved.
     This all is only valid for root web parts (uplink==NULL).
     That's the information we need to merge, if web parts are unioned.  */

  /* Number of spanned insns containing any deaths.  */
  unsigned int spanned_deaths;
  /* The list of bitmaps of DEF ID's with which this part conflicts.  */
  struct tagged_conflict *sub_conflicts;
  unsigned char num_calls;
  /* If there's any call_insn, while this part is live.  */
  unsigned int crosses_call : 1;
  /* If this part is live over an basic block edge.  */
  unsigned int crosses_bb : 1;
  /* If this part is live over an insn changing memory.  */
  unsigned int crosses_memset : 1;
};

/* The `costs' struct records the cost of using a hard register of each class
   and of using memory for each pseudo.  We use this data to set up
   register class preferences.  */

struct costs
{
  int cost[N_REG_CLASSES];
  int mem_cost;
};

/* Web structure used to store info about connected live ranges.
   This represents the nodes of the interference graph, which gets
   colored.  It can also hold subwebs, which are contained in webs
   and represent subregs.  */
struct web
{
  /* Unique web ID.  */
  unsigned int id;

  /* Register number of the live range's variable.  */
  unsigned int regno;

  /* How many insns containing deaths do we span?  */
  unsigned int span_deaths;

  /* Spill_temp indicates if this web was part of a web spilled in the
     last iteration, or or reasons why this shouldn't be spilled again.
     1 spill web, can't be spilled.
     2 big spill web (live over some deaths).  Discouraged, but not
       impossible to spill again.
     3 short web (spans no deaths), can't be spilled.  */
  unsigned int spill_temp;

  /* When coalescing we might change spill_temp.  If breaking aliases we
     need to restore it.  */
  unsigned int orig_spill_temp;

  /* Cost of spilling.  */
  unsigned HOST_WIDE_INT spill_cost;
  unsigned HOST_WIDE_INT orig_spill_cost;

  /* How many webs are aliased to us?  */
  unsigned int num_aliased;

  /* The color we got.  This is a hardreg number.  */
  int color;
  /* 1 + the color this web got in the last pass.  If it hadn't got a color,
     or we are in the first pass, or this web is a new one, this is zero.  */
  int old_color;

  unsigned char num_calls;

  /* Now follow some flags characterizing the web.  */

  /* Nonzero, if we should use usable_regs for this web, instead of
     preferred_class() or alternate_class().  */
  unsigned int use_my_regs:1;

  /* Nonzero if we selected this web as possible spill candidate in
     select_spill().  */
  unsigned int was_spilled:1;

  /* We need to distinguish also webs which are targets of coalescing
     (all x with some y, so that x==alias(y)), but the alias field is
     only set for sources of coalescing.  This flag is set for all webs
     involved in coalescing in some way.  */
  unsigned int is_coalesced:1;

  /* Nonzero, if this web (or subweb) doesn't correspond with any of
     the current functions actual use of reg rtx.  Happens e.g. with
     conflicts to a web, of which only a part was still undefined at the
     point of that conflict.  In this case we construct a subweb
     representing these yet undefined bits to have a target for the
     conflict.  Suppose e.g. this sequence:
     (set (reg:DI x) ...)
     (set (reg:SI y) ...)
     (set (subreg:SI (reg:DI x) 0) ...)
     (use (reg:DI x))
     Here x only partly conflicts with y.  Namely only (subreg:SI (reg:DI x)
     1) conflicts with it, but this rtx doesn't show up in the program.  For
     such things an "artificial" subweb is built, and this flag is true for
     them.  */
  unsigned int artificial:1;

  /* Nonzero if we span a call_insn.  */
  unsigned int crosses_call:1;

  /* Nonzero if we span a basic block edge.  */
  unsigned int crosses_bb:1;

  /* Wether the web is involved in a move insn.  */
  unsigned int move_related:1;

  /* 1 when this web (or parts thereof) are live over an abnormal edge.  */
  unsigned int live_over_abnormal:1;

  /* Wether the web is live over insns which change memory in any way.  */
  unsigned int crosses_memset:1;

  /* Nonzero if this web is used in subregs where the mode change
     was illegal for hardregs in CLASS_CANNOT_CHANGE_MODE.  */
  unsigned int mode_changed:1;

  /* Nonzero if some references of this web, where in subreg context,
     but the actual subreg is already stripped (i.e. we don't know the
     outer mode of the actual reference).  */
  unsigned int subreg_stripped:1;

  /* Nonzero, when this web stems from the last pass of the allocator,
     and all info is still valid (i.e. it wasn't spilled).  */
  unsigned int old_web:1;

  /* Used in rewrite_program2() to remember webs, which
     are already marked for (re)loading.  */
  unsigned int in_load:1;

  /* If in_load is != 0, then this is nonzero, if only one use was seen
     since insertion in loadlist.  Zero if more uses currently need a
     reload.  Used to differentiate between inserting register loads or
     directly substituting the stackref.  */
  unsigned int one_load:1;

  /* When using rewrite_program2() this flag gets set if some insns
     were inserted on behalf of this web.  IR spilling might ignore some
     deaths up to the def, so no code might be emitted and we need not to
     spill such a web again.  */
  unsigned int changed:1;

  /* With interference region spilling it's sometimes the case, that a
     bb border is also an IR border for webs, which were targets of moves,
     which are already removed due to coalescing.  All webs, which are
     a destination of such a removed move, have this flag set.  */
  unsigned int target_of_spilled_move:1;

  /* For optimistic coalescing we need to be able to break aliases, which
     includes restoring conflicts to those before coalescing.  This flag
     is set, if we have a list of conflicts before coalescing.  It's needed
     because that list is lazily constructed only when actually needed.  */
  unsigned int have_orig_conflicts:1;

  /* Current state of the node.  */
  ENUM_BITFIELD(node_type) type:5;

  /* A regclass, combined from preferred and alternate class, or calculated
     from usable_regs.  Used only for debugging, and to determine
     add_hardregs.  */
  ENUM_BITFIELD(reg_class) regclass:10;

  /* Additional consecutive hardregs needed for this web.  */
  int add_hardregs;

  /* Number of conflicts currently.  */
  int num_conflicts;

  /* Numbers of uses and defs, which belong to this web.  */
  unsigned int num_uses;
  unsigned int num_defs;

  /* The (reg:M a) or (subreg:M1 (reg:M2 a) x) rtx which this
     web is based on.  This is used to distinguish subreg webs
     from it's reg parents, and to get hold of the mode.  */
  rtx orig_x;

  /* If this web is a subweb, this point to the super web.  Otherwise
     it's NULL.  */
  struct web *parent_web;

  /* If this web is a subweb, but not the last one, this points to the
     next subweb of the same super web.  Otherwise it's NULL.  */
  struct web *subreg_next;

  /* The set of webs (or subwebs), this web conflicts with.  */
  struct conflict_link *conflict_list;

  /* If have_orig_conflicts is set this contains a copy of conflict_list,
     as it was right after building the interference graph.
     It's used for incremental i-graph building and for breaking
     coalescings again.  */
  struct conflict_link *orig_conflict_list;

  /* Bitmap of all conflicts which don't count this pass, because of
     non-intersecting hardregs of the conflicting webs.  See also
     record_conflict().  */
  bitmap useless_conflicts;

  /* Different sets of hard registers, for all usable registers, ...  */
  HARD_REG_SET usable_regs;
  /* ... the same before coalescing, ...  */
  HARD_REG_SET orig_usable_regs;
  /* ... colors of all already colored neighbors (used when biased coloring
     is active), and ...  */
  HARD_REG_SET bias_colors;
  /* ... colors of PRECOLORED webs this web is connected to by a move.  */
  HARD_REG_SET prefer_colors;

  /* Number of usable colors in usable_regs.  */
  int num_freedom;

  /* After successful coloring the graph each web gets a new reg rtx,
     with which the original uses and defs are replaced.  This is it.  */
  rtx reg_rtx;

  /* While spilling this is the rtx of the home of spilled webs.
     It can be a mem ref (a stack slot), or a pseudo register.  */
  rtx stack_slot;

  /* Used in rewrite_program2() to remember the using
     insn last seen for webs needing (re)loads.  */
  rtx last_use_insn;
  struct ref *last_use;

  /* If this web is rematerializable, this contains the RTL pattern
     usable as source for that.  Otherwise it's NULL.  */
  rtx pattern;

  /* All the defs and uses.  There are num_defs, resp.
     num_uses elements.  */
  struct ref **defs; /* [0..num_defs-1] */
  struct ref **uses; /* [0..num_uses-1] */

  /* The web to which this web is aliased (coalesced).  If NULL, this
     web is not coalesced into some other (but might still be a target
     for other webs).  */
  struct web *alias;

  /* With iterated coalescing this is a list of active moves this web
     is involved in.  */
  struct move_list *moves;

  /* The list implementation.  */
  struct dlist *dlink;

  /* While building webs, out of web-parts, this holds a (partial)
     list of all refs for this web seen so far.  */
  struct df_link *temp_refs;
};

/* For implementing a single linked list.  */
struct web_link
{
  struct web_link *next;
  struct web *web;
};

/* A subconflict is part of a conflict edge to track precisely,
   which parts of two webs conflict, in case not all of both webs do.  */
struct sub_conflict
{
  /* The next partial conflict.  For one such list the parent-web of
     all the S webs, resp. the parent of all the T webs are constant.  */
  struct sub_conflict *next;
  struct web *s;
  struct web *t;
};

/* This represents an edge in the conflict graph.  */
struct conflict_link
{
  struct conflict_link *next;

  /* The web we conflict with (the Target of the edge).  */
  struct web *t;

  /* If not the complete source web and T conflict, this points to
     the list of parts which really conflict.  */
  struct sub_conflict *sub;
};

/* For iterated coalescing the moves can be in these states.  */
enum move_type
{
  WORKLIST, MV_COALESCED, CONSTRAINED, FROZEN, ACTIVE,
  LAST_MOVE_TYPE
};

/* Structure of a move we are considering coalescing.  */
struct move
{
  rtx insn;
  struct web *source_web;
  struct web *target_web;
  enum move_type type;
  struct dlist *dlink;
};

/* List of moves.  */
struct move_list
{
  struct move_list *next;
  struct move *move;
};

/* To have fast access to the defs and uses per insn, we have one such
   structure per insn.  The difference to the normal df.c structures is,
   that it doesn't contain any NULL refs, which df.c produces in case
   an insn was modified and it only contains refs to pseudo regs, or to
   hardregs which matter for allocation, i.e. those not in
   never_use_colors.  */
struct ra_insn_info
{
  unsigned int num_defs, num_uses;
  struct ref **defs, **uses;
};

/* The above structures are stored in this array, indexed by UID...  */
extern struct ra_insn_info *insn_df;
/* ... and the size of that array, as we add insn after setting it up.  */
extern int insn_df_max_uid;

/* The interference graph.  */
extern sbitmap igraph;
/* And how to access it.  I and J are web indices.  If the bit
   igraph_index(I, J) is set, then they conflict.  Note, that
   if only parts of webs conflict, then also only those parts
   are noted in the I-graph (i.e. the parent webs not).  */
#define igraph_index(i, j) ((i) < (j) ? ((j)*((j)-1)/2)+(i) : ((i)*((i)-1)/2)+(j))
/* This is the bitmap of all (even partly) conflicting super webs.
   If bit I*num_webs+J or J*num_webs+I is set, then I and J (both being
   super web indices) conflict, maybe only partially.  Note the
   asymmetry.  */
extern sbitmap sup_igraph;

/* After the first pass, and when interference region spilling is
   activated, bit I is set, when the insn with UID I contains some
   refs to pseudos which die at the insn.  */
extern sbitmap insns_with_deaths;
/* The size of that sbitmap.  */
extern int death_insns_max_uid;

/* All the web-parts.  There are exactly as many web-parts as there
   are register refs in the insn stream.  */
extern struct web_part *web_parts;

/* The number of all webs, including subwebs.  */
extern unsigned int num_webs;
/* The number of just the subwebs.  */
extern unsigned int num_subwebs;
/* The number of all webs, including subwebs.  */
extern unsigned int num_allwebs;

/* For easy access when given a web ID: id2web[W->id] == W.  */
extern struct web **id2web;
/* For each hardreg, the web which represents it.  */
extern struct web *hardreg2web[FIRST_PSEUDO_REGISTER];

/* Given the ID of a df_ref, which represent a DEF, def2web[ID] is
   the web, to which this def belongs.  */
extern struct web **def2web;
/* The same as def2web, just for uses.  */
extern struct web **use2web;

/* The list of all recognized and coalescable move insns.  */
extern struct move_list *wl_moves;


/* Some parts of the compiler which we run after colorizing
   clean reg_renumber[], so we need another place for the colors.
   This is copied to reg_renumber[] just before returning to toplev.  */
extern short *ra_reg_renumber;
/* The size of that array.  Some passes after coloring might have created
   new pseudos, which will get no color.  */
extern int ra_max_regno;

/* The dataflow structure of the current function, while regalloc
   runs.  */
extern struct df *df;

/* For each basic block B we have a bitmap of DF_REF_ID's of uses,
   which backward reach the end of B.  */
extern bitmap *live_at_end;

/* One pass is: collecting registers refs, building I-graph, spilling.
   And this is how often we already ran that for the current function.  */
extern int ra_pass;

/* One of the fixed colors.  It must be < FIRST_PSEUDO_REGISTER, because
   we sometimes want to check the color against a HARD_REG_SET.  It must
   be >= 0, because negative values mean "no color".
   This color is used for the above stackwebs, when they can't be colored.
   I.e. normally they would be spilled, but they already represent
   stackslots.  So they are colored with an invalid color.  It has
   the property that even webs which conflict can have that color at the
   same time.  I.e. a stackweb with that color really represents a
   stackslot.  */
extern int an_unusable_color;

/* While building the I-graph, every time insn UID is looked at,
   number_seen[UID] is incremented.  For debugging.  */
extern int *number_seen;

/* The different lists on which a web can be (based on the type).  */
extern struct dlist *web_lists[(int) LAST_NODE_TYPE];
#define WEBS(type) (web_lists[(int)(type)])

/* The largest DF_REF_ID of defs resp. uses, as it was in the
   last pass.  In the first pass this is zero.  Used to distinguish new
   from old references.  */
extern unsigned int last_def_id;
extern unsigned int last_use_id;

/* Similar for UIDs and number of webs.  */
extern int last_max_uid;
extern unsigned int last_num_webs;

extern bitmap last_changed_insns;

/* If I is the ID of an old use, and last_check_uses[I] is set,
   then we must reevaluate it's flow while building the new I-graph.  */
extern sbitmap last_check_uses;

/* If nonzero, record_conflict() saves the current conflict list of
   webs in orig_conflict_list, when not already done so, and the conflict
   list is going to be changed.  It is set, after initially building the
   I-graph.  I.e. new conflicts due to coalescing trigger that copying.  */
extern unsigned int remember_conflicts;

/* Used to detect spill instructions inserted by me.  */
extern bitmap emitted_by_spill;

/* Insns which must be rescanned by pre_reload.  */
extern bitmap ra_modified_insns;

/* This pseudos represents stack slots allocated by ra-rewrite.  */
extern bitmap spill_slot_regs;

/* A HARD_REG_SET of those color, which can't be used for coalescing.
   Includes e.g. fixed_regs.  */
extern HARD_REG_SET never_use_colors;
/* For each class C this is reg_class_contents[C] \ never_use_colors.  */
extern HARD_REG_SET usable_regs[N_REG_CLASSES];
/* For each class C the count of hardregs in usable_regs[C].  */
extern unsigned int num_free_regs[N_REG_CLASSES];
/* For each mode M the hardregs, which are MODE_OK for M, and have
   enough space behind them to hold an M value.  Additionally
   if reg R is OK for mode M, but it needs two hardregs, then R+1 will
   also be set here, even if R+1 itself is not OK for M.  I.e. this
   represent the possible resources which could be taken away be a value
   in mode M.  */
extern HARD_REG_SET hardregs_for_mode[NUM_MACHINE_MODES];
/* The set of hardregs, for which _any_ mode change is invalid.  */
extern HARD_REG_SET invalid_mode_change_regs;
/* For 0 <= I <= 255, the number of bits set in I.  Used to calculate
   the number of set bits in a HARD_REG_SET.  */
extern unsigned char byte2bitcount[256];

/* Expressive helper macros.  */
#define ID2WEB(I) id2web[I]
#define NUM_REGS(W) (((W)->type == PRECOLORED) ? 1 : (W)->num_freedom)
#define SUBWEB_P(W) (GET_CODE ((W)->orig_x) == SUBREG)

/* Constant usable as debug area to ra_debug_msg.  */
#define DUMP_COSTS		0x0001
#define DUMP_WEBS		0x0002
#define DUMP_IGRAPH		0x0004
#define DUMP_PROCESS		0x0008
#define DUMP_COLORIZE		0x0010
#define DUMP_ASM		0x0020
#define DUMP_CONSTRAINTS	0x0040
#define DUMP_RESULTS		0x0080
#define DUMP_DF			0x0100
#define DUMP_RTL		0x0200
#define DUMP_FINAL_RTL		0x0400
#define DUMP_REGCLASS		0x0800
#define DUMP_SM			0x1000
#define DUMP_LAST_FLOW		0x2000
#define DUMP_LAST_RTL		0x4000
#define DUMP_REBUILD		0x8000
#define DUMP_IGRAPH_M		0x10000
#define DUMP_VALIDIFY		0x20000
#define DUMP_EVER		((unsigned int)-1)
#define DUMP_NEARLY_EVER	(DUMP_EVER - DUMP_COSTS - DUMP_IGRAPH_M)

/* All the wanted debug levels as ORing of the various DUMP_xxx
   constants.  */
extern unsigned int debug_new_regalloc;

/* Nonzero means we want biased coloring.  */
extern int flag_ra_biased;

/* Nonzero if we want to use improved (and slow) spilling.  This
   includes also interference region spilling (see below).  */
extern int flag_ra_improved_spilling;

/* Nonzero for using interference region spilling.  Zero for improved
   Chaintin style spilling (only at deaths).  */
extern int flag_ra_ir_spilling;

extern int flag_ra_split_webs;

/* Nonzero if we use optimistic coalescing, zero for iterated
   coalescing.  */
extern int flag_ra_optimistic_coalescing;

/* Nonzero if we want to break aliases of spilled webs.  Forced to
   nonzero, when flag_ra_optimistic_coalescing is.  */
extern int flag_ra_break_aliases;

/* Nonzero if we want to merge the spill costs of webs which
   are coalesced.  */
extern int flag_ra_merge_spill_costs;

/* Nonzero if we want to spill at every use, instead of at deaths,
   or interference region borders.  */
extern int flag_ra_spill_every_use;

/* Nonzero to output all notes in the debug dumps.  */
extern int flag_ra_dump_notes;

/* If nonzero, use pre-reload and web-class in new register allocator.  */
extern int flag_ra_pre_reload;

/* If nonzero, use separate passs for calculation web deaths in new
   register allocator.  */
extern int flag_ra_spanned_deaths_from_scratch;

extern inline void * ra_alloc (size_t);
extern inline void * ra_calloc (size_t);
extern int hard_regs_count (HARD_REG_SET);
extern rtx ra_emit_move_insn (rtx, rtx);
extern void ra_debug_msg (unsigned int, const char *, ...) ATTRIBUTE_PRINTF_2;
extern int hard_regs_intersect_p (HARD_REG_SET *, HARD_REG_SET *);
extern int hard_regs_same_p (HARD_REG_SET, HARD_REG_SET);
extern unsigned int rtx_to_bits (rtx);
extern struct web * find_subweb (struct web *, rtx);
extern struct web * find_subweb_2 (struct web *, unsigned int);
extern struct web * find_web_for_subweb_1 (struct web *);

#define find_web_for_subweb(w) (((w)->parent_web) \
				? find_web_for_subweb_1 ((w)->parent_web) \
				: (w))

extern void ra_build_realloc (struct df *);
extern void ra_build_free (void);
extern void ra_build_free_all (struct df *);
extern void ra_colorize_init (void);
extern void ra_colorize_free_all (void);
extern void ra_rewrite_init (void);

extern void ra_print_rtx (FILE *, rtx, int);
extern void ra_print_rtx_top (FILE *, rtx, int);
extern void ra_debug_rtx (rtx);
extern void ra_debug_insns (rtx, int);
extern void ra_debug_bbi (int);
extern void ra_print_rtl_with_bb (FILE *, rtx);
extern void dump_igraph (struct df *);
extern void dump_igraph_machine (void);
extern void dump_constraints (void);
extern void dump_cost (unsigned int);
extern void dump_graph_cost (unsigned int, const char *);
extern void dump_ra (struct df *);
extern void dump_number_seen (void);
extern void dump_static_insn_cost (FILE *, const char *, const char *);
extern void dump_web_conflicts (struct web *);
extern void dump_web_insns (struct web*);
extern int non_conflicting_for_combine (struct web *, struct web *);
extern int web_conflicts_p (struct web *, struct web *);
extern void debug_hard_reg_set (HARD_REG_SET);
extern void debug_web_insns (struct web *);
extern void debug_web_conflicts (struct web *web);

extern int comp_webs_maxcost (const void *, const void *);

extern void remove_list (struct dlist *, struct dlist **);
extern struct dlist * pop_list (struct dlist **);
extern void record_conflict (struct web *, struct web *);
extern int memref_is_stack_slot (rtx);
extern void build_i_graph (struct df *);
extern void put_web (struct web *, enum node_type);
extern void remove_web_from_list (struct web *);
extern void reset_lists (void);
extern struct web * alias (struct web *);
extern void merge_moves (struct web *, struct web *);
extern void ra_colorize_graph (struct df *);

extern int actual_spill (int);
extern void emit_colors (struct df *);
extern void delete_moves (void);
extern void setup_renumber (int);
extern void remove_suspicious_death_notes (void);

extern void create_flow_barriers (void);
extern int is_partly_dead (sbitmap, struct web *);
extern void set_web_live (sbitmap, struct web *);
extern void reset_web_live (sbitmap, struct web *);
extern int count_long_blocks (HARD_REG_SET, int);
extern void detect_web_parts_to_rebuild (void);
extern void web_class_spill_ref (struct web *, struct ref *);
extern int subst_to_stack_p (void);
extern int copy_insn_p (rtx ,rtx *,rtx *);
extern int hard_regs_combinable_p (struct web *,struct web *);
extern void debug_colorized_spills (void);
extern void init_long_blocks_for_classes (void);

#define SPILL_SLOT_P(REGNO) bitmap_bit_p (spill_slot_regs, (REGNO))

/* #define SPILLING_STATISTICS */
#define DENIS
/* #define MICHAEL */

#ifdef SPILLING_STATISTICS
/* Registers generated for spill slots by rewrite_program[2].  */
extern bitmap rewrite_spill_slots;
/* rewrite_program[2] spill registers which was placed to stack.  */
extern bitmap rewrite_stack_slots;
/* Number of generated stack slots for spilled webs.  */
extern int stack_spill_slots_num;
#endif