Merge branch 'master' of git://factorcode.org/git/factor

db4
Slava Pestov 2009-07-17 00:03:13 -05:00
commit e88e7f70be
5 changed files with 49 additions and 26 deletions

View File

@ -1 +1,2 @@
Slava Pestov
Slava Pestov
Daniel Ehrenberg

View File

@ -1,8 +1,10 @@
IN: compiler.cfg.phi-elimination.tests
! Copyright (C) 2009 Slava Pestov, Daniel Ehrenberg.
! See http://factorcode.org/license.txt for BSD license.
USING: compiler.cfg.instructions compiler.cfg compiler.cfg.registers
compiler.cfg.comparisons compiler.cfg.debugger
compiler.cfg.comparisons compiler.cfg.debugger locals
compiler.cfg.phi-elimination kernel accessors sequences classes
namespaces tools.test cpu.architecture arrays ;
IN: compiler.cfg.phi-elimination.tests
V{ T{ ##branch } } 0 test-bb
@ -36,12 +38,25 @@ test-diamond
[ ] [ cfg new 0 get >>entry eliminate-phis drop ] unit-test
[ T{ ##copy f V int-regs 3 V int-regs 1 } ]
[ 2 get successors>> first instructions>> first ]
unit-test
[let | n! [ f ] |
[ T{ ##copy f V int-regs 3 V int-regs 2 } ]
[ 3 get successors>> first instructions>> first ]
unit-test
[ ] [ 2 get successors>> first instructions>> first dst>> n>> n! ] unit-test
[ 2 ] [ 4 get instructions>> length ] unit-test
[ t ] [
T{ ##copy f V int-regs n V int-regs 1 }
2 get successors>> first instructions>> first =
] unit-test
[ t ] [
T{ ##copy f V int-regs n V int-regs 2 }
3 get successors>> first instructions>> first =
] unit-test
[ t ] [
T{ ##copy f V int-regs 3 V int-regs n }
4 get instructions>> first =
] unit-test
]
[ 3 ] [ 4 get instructions>> length ] unit-test

View File

@ -1,22 +1,26 @@
! Copyright (C) 2009 Slava Pestov.
! Copyright (C) 2009 Slava Pestov, Daniel Ehrenberg.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs fry kernel sequences namespaces
compiler.cfg compiler.cfg.instructions compiler.cfg.rpo
compiler.cfg.utilities ;
compiler.cfg.utilities compiler.cfg.hats make
locals ;
IN: compiler.cfg.phi-elimination
: insert-copy ( predecessor input output -- )
'[ _ _ swap ##copy ] add-instructions ;
: eliminate-phi ( ##phi -- )
[ inputs>> ] [ dst>> ] bi '[ _ insert-copy ] assoc-each ;
: eliminate-phi ( ##phi -- ##copy )
i
[ [ inputs>> ] dip '[ _ insert-copy ] assoc-each ]
[ [ dst>> ] dip \ ##copy new-insn ]
2bi ;
: eliminate-phi-step ( bb -- )
H{ } clone added-instructions set
[ instructions>> [ dup ##phi? [ eliminate-phi f ] [ drop t ] if ] filter-here ]
[ instructions>> [ dup ##phi? [ eliminate-phi ] when ] change-each ]
[ insert-basic-blocks ]
bi ;
: eliminate-phis ( cfg -- cfg' )
dup [ eliminate-phi-step ] each-basic-block
cfg-changed ;
cfg-changed ;

View File

@ -11,10 +11,6 @@ IN: compiler.cfg.two-operand
! since x86 has LEA and IMUL instructions which are effectively
! three-operand addition and multiplication, respectively.
: make-copy ( dst src -- insn ) \ ##copy new-insn ; inline
: make-copy/float ( dst src -- insn ) \ ##copy-float new-insn ; inline
: convert-two-operand/integer ( insn -- )
[ [ dst>> ] [ src1>> ] bi ##copy ]
[ dup dst>> >>src1 , ]

View File

@ -2,7 +2,7 @@ IN: compiler.cfg.value-numbering.tests
USING: compiler.cfg.value-numbering compiler.cfg.instructions
compiler.cfg.registers compiler.cfg.debugger compiler.cfg.comparisons
cpu.architecture tools.test kernel math combinators.short-circuit
accessors sequences compiler.cfg.predecessors
accessors sequences compiler.cfg.predecessors locals
compiler.cfg.phi-elimination compiler.cfg.dce compiler.cfg.liveness
compiler.cfg assocs vectors arrays layouts namespaces ;
@ -1218,11 +1218,18 @@ test-diamond
[ t ] [ 1 get successors>> first 3 get eq? ] unit-test
[ T{ ##copy f V int-regs 3 V int-regs 2 } ]
[ 3 get successors>> first instructions>> first ]
unit-test
[let | n! [ f ] |
[ 2 ] [ 4 get instructions>> length ] unit-test
[ ] [ 2 get successors>> first instructions>> first src>> n>> n! ] unit-test
[ t ] [
T{ ##copy f V int-regs n V int-regs 2 }
3 get successors>> first instructions>> first =
] unit-test
]
[ 3 ] [ 4 get instructions>> length ] unit-test
V{
T{ ##peek f V int-regs 0 D 0 }
@ -1331,4 +1338,4 @@ V{
compute-liveness value-numbering eliminate-dead-code drop
] unit-test
[ f ] [ 1 get instructions>> [ ##peek? ] any? ] unit-test
[ f ] [ 1 get instructions>> [ ##peek? ] any? ] unit-test