| 1 |
(* |
| 2 |
* Tarjan et als. idef/iuse sets. |
| 3 |
* |
| 4 |
* -- Allen |
| 5 |
*) |
| 6 |
|
| 7 |
functor IDefs |
| 8 |
(structure Dom : DOMINATOR_TREE |
| 9 |
structure CFG : CONTROL_FLOW_GRAPH |
| 10 |
) : MLRISC_IDEFS = |
| 11 |
struct |
| 12 |
|
| 13 |
structure Dom = Dom |
| 14 |
structure CFG = CFG |
| 15 |
structure I = CFG.I |
| 16 |
structure C = I.C |
| 17 |
structure G = Graph |
| 18 |
structure IDefs = ComputeIDefs(I.C) |
| 19 |
|
| 20 |
fun idefs defUse cfg = |
| 21 |
let fun compute_def_use(b,CFG.BLOCK{insns,...}) = |
| 22 |
let fun du([],D,U) = (List.concat D,List.concat U) |
| 23 |
| du(i::is,D,U) = |
| 24 |
let val (d,u) = defUse i |
| 25 |
in du(is,d::D,u::U) end |
| 26 |
in du(!insns,[],[]) |
| 27 |
end |
| 28 |
in |
| 29 |
IDefs.compute_idefs {cfg=cfg,def_use=compute_def_use} |
| 30 |
end |
| 31 |
|
| 32 |
end |
| 33 |
|