]> gitweb.factorcode.org Git - factor.git/blob - basis/compiler/cfg/stacks/global/global.factor
Merge branch 'master' of git://factorcode.org/git/factor
[factor.git] / basis / compiler / cfg / stacks / global / global.factor
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
6
7 ! Peek analysis. Peek-in is the set of all locations anticipated at
8 ! the start of a basic block.
9 BACKWARD-ANALYSIS: peek
10
11 M: peek-analysis transfer-set drop [ replace-set assoc-diff ] keep peek-set assoc-union ;
12
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
16
17 M: replace-analysis transfer-set drop replace-set assoc-union ;
18
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
22
23 M: avail-analysis transfer-set drop [ peek-set ] [ replace-set ] bi assoc-union assoc-union ;
24
25 ! Kill analysis. Kill-in is the set of all locations
26 ! which are going to be overwritten.
27 BACKWARD-ANALYSIS: kill
28
29 M: kill-analysis transfer-set drop replace-set assoc-union ;
30
31 ! Main word
32 : compute-global-sets ( cfg -- cfg' )
33     {
34         [ compute-peek-sets ]
35         [ compute-replace-sets ]
36         [ compute-avail-sets ]
37         [ compute-kill-sets ]
38         [ ]
39     } cleave ;