Phi elimination doesn't have the swap problem now
							parent
							
								
									062e33f8fb
								
							
						
					
					
						commit
						8477cf8e91
					
				|  | @ -1 +1,2 @@ | ||||||
| Slava Pestov | Slava Pestov | ||||||
|  | Daniel Ehrenberg | ||||||
|  |  | ||||||
|  | @ -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 | 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 | compiler.cfg.phi-elimination kernel accessors sequences classes | ||||||
| namespaces tools.test cpu.architecture arrays ; | namespaces tools.test cpu.architecture arrays ; | ||||||
|  | IN: compiler.cfg.phi-elimination.tests | ||||||
| 
 | 
 | ||||||
| V{ T{ ##branch } } 0 test-bb | V{ T{ ##branch } } 0 test-bb | ||||||
| 
 | 
 | ||||||
|  | @ -36,12 +38,25 @@ test-diamond | ||||||
| 
 | 
 | ||||||
| [ ] [ cfg new 0 get >>entry eliminate-phis drop ] unit-test | [ ] [ cfg new 0 get >>entry eliminate-phis drop ] unit-test | ||||||
| 
 | 
 | ||||||
| [ T{ ##copy f V int-regs 3 V int-regs 1 } ] | [let | n! [ f ] | | ||||||
| [ 2 get successors>> first instructions>> first ] |  | ||||||
| unit-test |  | ||||||
| 
 | 
 | ||||||
| [ T{ ##copy f V int-regs 3 V int-regs 2 } ] | [ ] [ 2 get successors>> first instructions>> first dst>> n>> n! ] unit-test | ||||||
| [ 3 get successors>> first instructions>> first ] |  | ||||||
| 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 | ||||||
|  |  | ||||||
|  | @ -1,19 +1,23 @@ | ||||||
| ! Copyright (C) 2009 Slava Pestov. | ! Copyright (C) 2009 Slava Pestov, Daniel Ehrenberg. | ||||||
| ! See http://factorcode.org/license.txt for BSD license. | ! See http://factorcode.org/license.txt for BSD license. | ||||||
| USING: accessors assocs fry kernel sequences namespaces | USING: accessors assocs fry kernel sequences namespaces | ||||||
| compiler.cfg compiler.cfg.instructions compiler.cfg.rpo | compiler.cfg compiler.cfg.instructions compiler.cfg.rpo | ||||||
| compiler.cfg.utilities ; | compiler.cfg.utilities compiler.cfg.hats make | ||||||
|  | locals ; | ||||||
| IN: compiler.cfg.phi-elimination | IN: compiler.cfg.phi-elimination | ||||||
| 
 | 
 | ||||||
| : insert-copy ( predecessor input output -- ) | : insert-copy ( predecessor input output -- ) | ||||||
|     '[ _ _ swap ##copy ] add-instructions ; |     '[ _ _ swap ##copy ] add-instructions ; | ||||||
| 
 | 
 | ||||||
| : eliminate-phi ( ##phi -- ) | : eliminate-phi ( ##phi -- ##copy ) | ||||||
|     [ inputs>> ] [ dst>> ] bi '[ _ insert-copy ] assoc-each ; |     i | ||||||
|  |     [ [ inputs>> ] dip '[ _ insert-copy ] assoc-each ] | ||||||
|  |     [ [ dst>> ] dip \ ##copy new-insn ] | ||||||
|  |     2bi ; | ||||||
| 
 | 
 | ||||||
| : eliminate-phi-step ( bb -- ) | : eliminate-phi-step ( bb -- ) | ||||||
|     H{ } clone added-instructions set |     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 ] |     [ insert-basic-blocks ] | ||||||
|     bi ; |     bi ; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -2,7 +2,7 @@ IN: compiler.cfg.value-numbering.tests | ||||||
| USING: compiler.cfg.value-numbering compiler.cfg.instructions | USING: compiler.cfg.value-numbering compiler.cfg.instructions | ||||||
| compiler.cfg.registers compiler.cfg.debugger compiler.cfg.comparisons | compiler.cfg.registers compiler.cfg.debugger compiler.cfg.comparisons | ||||||
| cpu.architecture tools.test kernel math combinators.short-circuit | 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.phi-elimination compiler.cfg.dce compiler.cfg.liveness | ||||||
| compiler.cfg assocs vectors arrays layouts namespaces ; | compiler.cfg assocs vectors arrays layouts namespaces ; | ||||||
| 
 | 
 | ||||||
|  | @ -1218,11 +1218,18 @@ test-diamond | ||||||
| 
 | 
 | ||||||
| [ t ] [ 1 get successors>> first 3 get eq? ] unit-test | [ t ] [ 1 get successors>> first 3 get eq? ] unit-test | ||||||
| 
 | 
 | ||||||
| [ T{ ##copy f V int-regs 3 V int-regs 2 } ] | [let | n! [ f ] | | ||||||
| [ 3 get successors>> first instructions>> first ] |  | ||||||
| unit-test |  | ||||||
| 
 | 
 | ||||||
| [ 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{ | V{ | ||||||
|     T{ ##peek f V int-regs 0 D 0 } |     T{ ##peek f V int-regs 0 D 0 } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue