| 1 |
(* |
| 2 |
* Region-based register allocator. |
| 3 |
* This register allocation takes a cluster of large size and partitions |
| 4 |
* it into manageable pieces to be allocated. |
| 5 |
*) |
| 6 |
functor RegionBasedRA |
| 7 |
(structure RA : RA |
| 8 |
structure FlowgraphPartitioner : RA_FLOWGRAPH_PARTITIONER |
| 9 |
where type flowgraph = RA.F.flowgraph |
| 10 |
(* where C = RA.C *) |
| 11 |
) : RA = |
| 12 |
struct |
| 13 |
|
| 14 |
structure F = RA.F |
| 15 |
structure FP = FlowgraphPartitioner |
| 16 |
structure I = F.I |
| 17 |
structure C = I.C |
| 18 |
structure Core = RACore |
| 19 |
structure G = Core.G |
| 20 |
|
| 21 |
open RA |
| 22 |
|
| 23 |
val maxBlocks = MLRiscControl.mkInt ("ra-max-blocks", "max block count for region-based RA") |
| 24 |
|
| 25 |
(* Main entry point. |
| 26 |
* All the magic is actually done in the FlowgraphPartitioner module |
| 27 |
*) |
| 28 |
fun ra (params:raClient list) flowgraph = |
| 29 |
if FP.numberOfBlocks flowgraph > !maxBlocks then |
| 30 |
let fun ra (param as {cellkind, ...}) = |
| 31 |
FP.partition flowgraph cellkind (RA.ra [param]) |
| 32 |
in app ra params; |
| 33 |
flowgraph |
| 34 |
end |
| 35 |
else RA.ra params flowgraph |
| 36 |
|
| 37 |
end |