1 ! Copyright (C) 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: assocs kernel combinators compiler.cfg.dataflow-analysis
4 compiler.cfg.stacks.local ;
5 IN: compiler.cfg.stacks.global
7 ! Peek analysis. Peek-in is the set of all locations anticipated at
8 ! the start of a basic block.
9 BACKWARD-ANALYSIS: peek
11 M: peek-analysis transfer-set drop [ replace-set assoc-diff ] keep peek-set assoc-union ;
13 ! Replace analysis. Replace-in is the set of all locations which
14 ! will be overwritten at some point after the start of a basic block.
15 FORWARD-ANALYSIS: replace
17 M: replace-analysis transfer-set drop replace-set assoc-union ;
19 ! Availability analysis. Avail-out is the set of all locations
20 ! in registers at the end of a basic block.
21 FORWARD-ANALYSIS: avail
23 M: avail-analysis transfer-set drop [ peek-set ] [ replace-set ] bi assoc-union assoc-union ;
25 ! Kill analysis. Kill-in is the set of all locations
26 ! which are going to be overwritten.
27 BACKWARD-ANALYSIS: kill
29 M: kill-analysis transfer-set drop replace-set assoc-union ;
32 : compute-global-sets ( cfg -- cfg' )
35 [ compute-replace-sets ]
36 [ compute-avail-sets ]