| 1 |
(* |
| 2 |
* The interface to the new register allocator. |
| 3 |
* |
| 4 |
* -- Allen |
| 5 |
*) |
| 6 |
signature RA = |
| 7 |
sig |
| 8 |
|
| 9 |
structure I : INSTRUCTIONS |
| 10 |
structure C : CELLS |
| 11 |
structure F : RA_FLOWGRAPH |
| 12 |
(* sharing F.I = I *) |
| 13 |
where type I.addressing_mode = I.addressing_mode |
| 14 |
and type I.ea = I.ea |
| 15 |
and type I.instr = I.instr |
| 16 |
and type I.instruction = I.instruction |
| 17 |
and type I.operand = I.operand |
| 18 |
(* sharing I.C = C *) |
| 19 |
structure CB : CELLS_BASIS (* = CellsBasis *) |
| 20 |
where type CellSet.cellset = CellsBasis.CellSet.cellset |
| 21 |
and type 'a ColorTable.hash_table = 'a CellsBasis.ColorTable.hash_table |
| 22 |
and type 'a HashTable.hash_table = 'a CellsBasis.HashTable.hash_table |
| 23 |
and type SortedCells.sorted_cells = CellsBasis.SortedCells.sorted_cells |
| 24 |
and type cell = CellsBasis.cell |
| 25 |
and type cellColor = CellsBasis.cellColor |
| 26 |
and type cellkind = CellsBasis.cellkind |
| 27 |
and type cellkindDesc = CellsBasis.cellkindDesc |
| 28 |
and type cellkindInfo = CellsBasis.cellkindInfo |
| 29 |
|
| 30 |
type getreg = { pref : CB.cell_id list, |
| 31 |
stamp : int, |
| 32 |
proh : int Array.array |
| 33 |
} -> CB.cell_id |
| 34 |
|
| 35 |
type mode = word |
| 36 |
|
| 37 |
datatype spillLoc = datatype RAGraph.spillLoc |
| 38 |
|
| 39 |
(* |
| 40 |
* Optimizations/options: |
| 41 |
* Or them together |
| 42 |
*) |
| 43 |
val NO_OPTIMIZATION : mode |
| 44 |
val DEAD_COPY_ELIM : mode |
| 45 |
val BIASED_SELECTION : mode |
| 46 |
val SPILL_COLORING : mode |
| 47 |
val SPILL_COALESCING : mode |
| 48 |
val SPILL_PROPAGATION : mode |
| 49 |
val HAS_PARALLEL_COPIES : mode |
| 50 |
(* The above MUST be used when spill coloring is used and |
| 51 |
* you have parallel copies in the program. Otherwise, phathom |
| 52 |
* problems involving copy temporaries may appear. |
| 53 |
*) |
| 54 |
|
| 55 |
(* |
| 56 |
* Perform register allocation. |
| 57 |
* |
| 58 |
* spillProh is a list of register ranges (inclusive) that cannot be spilled. |
| 59 |
* |
| 60 |
*) |
| 61 |
type raClient = |
| 62 |
{ cellkind : CB.cellkind, (* kind of register *) |
| 63 |
spillProh : CB.cell list, (* don't spill these *) |
| 64 |
memRegs : CB.cell list, (* memory registers *) |
| 65 |
K : int, (* number of colors *) |
| 66 |
dedicated : int -> bool, (* dedicated registers *) |
| 67 |
getreg : getreg, (* how to find a color *) |
| 68 |
copyInstr : F.Spill.copyInstr, (* how to make a copy *) |
| 69 |
spill : F.Spill.spill, (* spill callback *) |
| 70 |
spillSrc : F.Spill.spillSrc, (* spill callback *) |
| 71 |
spillCopyTmp : F.Spill.spillCopyTmp, (* spill callback *) |
| 72 |
reload : F.Spill.reload, (* reload callback *) |
| 73 |
reloadDst : F.Spill.reloadDst, (* reload callback *) |
| 74 |
renameSrc : F.Spill.renameSrc, (* rename callback *) |
| 75 |
mode : mode (* mode *) |
| 76 |
} |
| 77 |
|
| 78 |
val ra : raClient list -> F.flowgraph -> F.flowgraph |
| 79 |
|
| 80 |
end |