1 (* Pasted from Pottier's PP compiler *)
3 (* This module offers functions that count how many times each
4 pseudo-register is used within a piece of [ERTL] code. This
5 is used in [Coloring] to drive the spilling heuristics. *)
11 Register.Map.find r uses
15 let count r uses = Register.Map.add r (lookup uses r + 1) uses
17 let examine_statement _ stmt uses =
30 | St_get_hdw (r, _, _)
31 | St_set_hdw (_, r, _)
38 | St_cond (r, _, _) ->
41 | St_op1 (_, r1, r2, _)
42 | St_call_ptr (r1, r2, _, _) ->
43 count r1 (count r2 uses)
44 | St_opaccsA (_, r1, r2, r3, _)
45 | St_opaccsB (_, r1, r2, r3, _)
46 | St_op2 (_, r1, r2, r3, _)
47 | St_load (r1, r2, r3, _)
48 | St_store (r1, r2, r3, _) ->
49 count r1 (count r2 (count r3 uses))
51 let examine_internal int_fun =
53 Label.Map.fold examine_statement int_fun.f_graph Register.Map.empty