compiler.cfg.copy-prop: Global copy propagation
parent
e0f6d89ff1
commit
7068de6cd3
|
@ -1,8 +1,10 @@
|
|||
! Copyright (C) 2008 Slava Pestov.
|
||||
! Copyright (C) 2008, 2009 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: kernel namespaces assocs accessors ;
|
||||
USING: kernel namespaces assocs accessors sequences
|
||||
compiler.cfg.rpo compiler.cfg.renaming compiler.cfg.instructions ;
|
||||
IN: compiler.cfg.copy-prop
|
||||
|
||||
! The first three definitions are also used in compiler.cfg.alias-analysis.
|
||||
SYMBOL: copies
|
||||
|
||||
: resolve ( vreg -- vreg )
|
||||
|
@ -10,3 +12,25 @@ SYMBOL: copies
|
|||
|
||||
: record-copy ( insn -- )
|
||||
[ src>> resolve ] [ dst>> ] bi copies get set-at ; inline
|
||||
|
||||
: collect-copies ( cfg -- )
|
||||
H{ } clone copies set
|
||||
[
|
||||
instructions>>
|
||||
[ dup ##copy? [ record-copy ] [ drop ] if ] each
|
||||
] each-basic-block ;
|
||||
|
||||
: rename-copies ( cfg -- )
|
||||
copies get dup assoc-empty? [ 2drop ] [
|
||||
renamings set
|
||||
[
|
||||
instructions>>
|
||||
[ dup ##copy? [ drop f ] [ rename-insn-uses t ] if ] filter-here
|
||||
] each-basic-block
|
||||
] if ;
|
||||
|
||||
: copy-propagation ( cfg -- cfg' )
|
||||
[ collect-copies ]
|
||||
[ rename-copies ]
|
||||
[ ]
|
||||
tri ;
|
||||
|
|
|
@ -2,18 +2,19 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: kernel sequences accessors combinators namespaces
|
||||
compiler.cfg.tco
|
||||
compiler.cfg.predecessors
|
||||
compiler.cfg.useless-conditionals
|
||||
compiler.cfg.ssa
|
||||
compiler.cfg.branch-splitting
|
||||
compiler.cfg.block-joining
|
||||
compiler.cfg.ssa
|
||||
compiler.cfg.alias-analysis
|
||||
compiler.cfg.value-numbering
|
||||
compiler.cfg.copy-prop
|
||||
compiler.cfg.dce
|
||||
compiler.cfg.write-barrier
|
||||
compiler.cfg.rpo
|
||||
compiler.cfg.phi-elimination
|
||||
compiler.cfg.empty-blocks
|
||||
compiler.cfg.predecessors
|
||||
compiler.cfg.rpo
|
||||
compiler.cfg.checker ;
|
||||
IN: compiler.cfg.optimizer
|
||||
|
||||
|
@ -38,6 +39,7 @@ SYMBOL: check-optimizer?
|
|||
alias-analysis
|
||||
value-numbering
|
||||
compute-predecessors
|
||||
copy-propagation
|
||||
eliminate-dead-code
|
||||
eliminate-write-barriers
|
||||
eliminate-phis
|
||||
|
|
|
@ -102,6 +102,10 @@ M: ##fixnum-overflow rename-insn-uses
|
|||
[ rename-value ] change-src2
|
||||
drop ;
|
||||
|
||||
M: ##phi rename-insn-uses
|
||||
[ [ rename-value ] assoc-map ] change-inputs
|
||||
drop ;
|
||||
|
||||
M: insn rename-insn-uses drop ;
|
||||
|
||||
: fresh-vreg ( vreg -- vreg' )
|
||||
|
|
Loading…
Reference in New Issue