| 1 |
(* |
| 2 |
* This module performs critical path reduction. |
| 3 |
* Jobs include: |
| 4 |
* 1. Transform conditional branches into conditional moves. |
| 5 |
* 2. Migrate branches out of loops |
| 6 |
* |
| 7 |
* -- Allen ([email protected]) |
| 8 |
*) |
| 9 |
functor SSACPR(SSA : SSA) : SSA_OPTIMIZATION = |
| 10 |
struct |
| 11 |
|
| 12 |
structure SSA = SSA |
| 13 |
structure CFG = SSA.CFG |
| 14 |
structure RTL = SSA.RTL |
| 15 |
structure T = RTL.T |
| 16 |
structure G = Graph |
| 17 |
structure A = Array |
| 18 |
|
| 19 |
type flowgraph = SSA.ssa |
| 20 |
|
| 21 |
val name = "Critical Path Reduction" |
| 22 |
|
| 23 |
infix ||- |
| 24 |
|
| 25 |
fun run(SSA as G.GRAPH ssa) = |
| 26 |
let val Dom as G.GRAPH dom = SSA.dom SSA |
| 27 |
val CFG as G.GRAPH cfg = SSA.cfg SSA |
| 28 |
val [ENTRY] = #entries dom () |
| 29 |
val {sources, phis, ops, sinks, ...} = SSA.nodes SSA |
| 30 |
|
| 31 |
fun walk X = |
| 32 |
let |
| 33 |
in app walk (#succ dom X) |
| 34 |
end |
| 35 |
|
| 36 |
in walk ENTRY; |
| 37 |
SSA |
| 38 |
end |
| 39 |
|
| 40 |
end |