2009-07-18 23:27:42 -04:00
|
|
|
! Copyright (C) 2009 Slava Pestov.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2009-07-22 03:05:40 -04:00
|
|
|
USING: assocs kernel combinators compiler.cfg.dataflow-analysis
|
2009-07-23 21:54:38 -04:00
|
|
|
compiler.cfg.stacks.local ;
|
|
|
|
IN: compiler.cfg.stacks.global
|
2009-07-18 23:27:42 -04:00
|
|
|
|
|
|
|
! Peek analysis. Peek-in is the set of all locations anticipated at
|
|
|
|
! the start of a basic block.
|
2009-07-22 03:05:40 -04:00
|
|
|
BACKWARD-ANALYSIS: peek
|
2009-07-18 23:27:42 -04:00
|
|
|
|
2009-07-23 21:54:38 -04:00
|
|
|
M: peek-analysis transfer-set drop [ replace-set assoc-diff ] keep peek-set assoc-union ;
|
2009-07-18 23:27:42 -04:00
|
|
|
|
|
|
|
! Replace analysis. Replace-in is the set of all locations which
|
|
|
|
! will be overwritten at some point after the start of a basic block.
|
2009-07-22 03:05:40 -04:00
|
|
|
FORWARD-ANALYSIS: replace
|
2009-07-18 23:27:42 -04:00
|
|
|
|
2009-07-23 21:54:38 -04:00
|
|
|
M: replace-analysis transfer-set drop replace-set assoc-union ;
|
2009-07-18 23:27:42 -04:00
|
|
|
|
|
|
|
! Availability analysis. Avail-out is the set of all locations
|
|
|
|
! in registers at the end of a basic block.
|
2009-07-22 03:05:40 -04:00
|
|
|
FORWARD-ANALYSIS: avail
|
2009-07-18 23:27:42 -04:00
|
|
|
|
2009-07-23 21:54:38 -04:00
|
|
|
M: avail-analysis transfer-set drop [ peek-set ] [ replace-set ] bi assoc-union assoc-union ;
|
2009-07-18 23:27:42 -04:00
|
|
|
|
|
|
|
! Kill analysis. Kill-in is the set of all locations
|
|
|
|
! which are going to be overwritten.
|
2009-07-22 03:05:40 -04:00
|
|
|
BACKWARD-ANALYSIS: kill
|
2009-07-18 23:27:42 -04:00
|
|
|
|
2009-08-01 07:12:43 -04:00
|
|
|
M: kill-analysis transfer-set drop kill-set assoc-union ;
|
2009-07-18 23:27:42 -04:00
|
|
|
|
|
|
|
! Main word
|
2009-07-23 21:54:38 -04:00
|
|
|
: compute-global-sets ( cfg -- cfg' )
|
2009-07-18 23:27:42 -04:00
|
|
|
{
|
|
|
|
[ compute-peek-sets ]
|
|
|
|
[ compute-replace-sets ]
|
|
|
|
[ compute-avail-sets ]
|
|
|
|
[ compute-kill-sets ]
|
2009-07-23 21:54:38 -04:00
|
|
|
[ ]
|
2009-07-18 23:27:42 -04:00
|
|
|
} cleave ;
|