2009-07-26 22:11:26 -04:00
|
|
|
! Copyright (C) 2009 Slava Pestov.
|
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
|
|
|
|
USING: accessors assocs fry kernel locals math math.order
|
|
|
|
|
sequences
|
|
|
|
|
compiler.cfg.rpo
|
2009-07-27 01:31:21 -04:00
|
|
|
compiler.cfg.utilities
|
2009-07-26 22:11:26 -04:00
|
|
|
compiler.cfg.dominance
|
2009-07-27 01:31:21 -04:00
|
|
|
compiler.cfg.instructions
|
2009-07-26 22:11:26 -04:00
|
|
|
compiler.cfg.coalescing.state
|
|
|
|
|
compiler.cfg.coalescing.forest
|
2009-07-27 01:31:21 -04:00
|
|
|
compiler.cfg.coalescing.copies
|
|
|
|
|
compiler.cfg.coalescing.renaming
|
2009-07-26 22:11:26 -04:00
|
|
|
compiler.cfg.coalescing.process-blocks ;
|
|
|
|
|
IN: compiler.cfg.coalescing
|
|
|
|
|
|
|
|
|
|
! Fast Copy Coalescing and Live-Range Identification
|
|
|
|
|
! http://www.cs.ucsd.edu/classes/sp02/cse231/kenpldi.pdf
|
|
|
|
|
|
|
|
|
|
! Dominance, liveness and def-use need to be computed
|
|
|
|
|
|
|
|
|
|
: process-blocks ( cfg -- )
|
|
|
|
|
[ [ process-block ] if-has-phis ] each-basic-block ;
|
|
|
|
|
|
|
|
|
|
: break-interferences ( -- ) ;
|
|
|
|
|
|
|
|
|
|
: remove-phis-from-block ( bb -- )
|
|
|
|
|
instructions>> [ ##phi? not ] filter-here ;
|
|
|
|
|
|
|
|
|
|
: remove-phis ( cfg -- )
|
|
|
|
|
[ [ remove-phis-from-block ] if-has-phis ] each-basic-block ;
|
|
|
|
|
|
|
|
|
|
: coalesce ( cfg -- cfg' )
|
|
|
|
|
init-coalescing
|
|
|
|
|
dup compute-dfs
|
|
|
|
|
dup process-blocks
|
|
|
|
|
break-interferences
|
|
|
|
|
dup insert-copies
|
2009-07-27 01:31:21 -04:00
|
|
|
perform-renaming
|
2009-07-26 22:11:26 -04:00
|
|
|
dup remove-phis ;
|