1 |
(* copyright 1998 YALE FLINT PROJECT *) |
(* copyright 1998 YALE FLINT PROJECT *) |
2 |
|
(* monnier@cs.yale.edu *) |
3 |
|
|
4 |
signature COLLECT = |
signature COLLECT = |
5 |
sig |
sig |
6 |
|
|
7 |
(* Collect information about variables and function uses |
(* Collect information about variables and function uses. |
8 |
* the info is accumulated in the map `m' *) |
* The info is accumulated in the map `m' *) |
9 |
val collect : FLINT.fundec -> unit |
val collect : FLINT.fundec -> unit |
10 |
|
|
11 |
(* query functions *) |
(* query functions *) |
30 |
(* when creating a new var. Used when alpha-renaming *) |
(* when creating a new var. Used when alpha-renaming *) |
31 |
(* val copy : FLINT.lvar * FLINT.lvar -> unit *) |
(* val copy : FLINT.lvar * FLINT.lvar -> unit *) |
32 |
|
|
33 |
(* fix up function to keep counts up-to-date when getting rid of a function. |
(* fix up function to keep counts up-to-date when getting rid of code. |
34 |
* the fun arg is only called for free variables becoming dead. *) |
* the arg is only called for *free* variables becoming dead. |
35 |
val unusefdec : (FLINT.lvar -> unit) -> (FLINT.lvar * FLINT.lvar list * FLINT.lexp) -> unit |
* the first function returned just unuses an exp, while the |
36 |
|
* second unuses a function declaration (f,args,body) *) |
37 |
|
val unuselexp : (FLINT.lvar -> unit) -> |
38 |
|
((FLINT.lexp -> unit) * |
39 |
|
((FLINT.lvar * FLINT.lvar list * FLINT.lexp) -> unit)) |
40 |
(* function to collect info about a newly created lexp *) |
(* function to collect info about a newly created lexp *) |
41 |
val uselexp : FLINT.lexp -> unit |
val uselexp : FLINT.lexp -> unit |
42 |
|
|
67 |
fun ASSERT (true,_) = () |
fun ASSERT (true,_) = () |
68 |
| ASSERT (FALSE,msg) = bug ("assertion "^msg^" failed") |
| ASSERT (FALSE,msg) = bug ("assertion "^msg^" failed") |
69 |
|
|
|
|
|
70 |
datatype info |
datatype info |
71 |
(* for functions we keep track of calls and escaping uses |
(* for functions we keep track of calls and escaping uses |
72 |
* and separately for external and internal (recursive) references *) |
* and separately for external and internal (recursive) references *) |
274 |
* Once its scope has been processed, we can completely get rid of |
* Once its scope has been processed, we can completely get rid of |
275 |
* the variable and corresponding info (after verifying that the count |
* the variable and corresponding info (after verifying that the count |
276 |
* is indeed exactly 1 (accomplished by the "kill" calls) *) |
* is indeed exactly 1 (accomplished by the "kill" calls) *) |
277 |
fun unusefdec undertaker = let |
fun unuselexp undertaker = let |
278 |
(* val use = if inc then use else unuse *) |
(* val use = if inc then use else unuse *) |
279 |
fun uncall lv = unuse undertaker true lv |
fun uncall lv = unuse undertaker true lv |
280 |
val unuse = fn F.VAR lv => unuse undertaker false lv | _ => () |
val unuse = fn F.VAR lv => unuse undertaker false lv | _ => () |
351 |
|
|
352 |
| le => buglexp("unexpected lexp", le) |
| le => buglexp("unexpected lexp", le) |
353 |
in |
in |
354 |
cfun |
(cexp, cfun) |
355 |
end |
end |
356 |
|
|
357 |
val uselexp = census new use NONE |
val uselexp = census new use NONE |