1 ! Copyright (C) 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: assocs compiler.cfg.hats compiler.cfg.instructions
4 deques dlists fry kernel locals namespaces sequences
6 IN: compiler.cfg.parallel-copy
8 ! Revisiting Out-of-SSA Translation for Correctness, Code Quality, and Efficiency
9 ! http://hal.archives-ouvertes.fr/docs/00/34/99/25/PDF/OutSSA-RR.pdf,
14 SYMBOLS: temp locs preds to-do ready ;
16 : init-to-do ( bs -- )
17 to-do get push-all-back ;
19 : init-ready ( bs -- )
20 locs get '[ _ key? not ] filter ready get push-all-front ;
22 : init ( mapping temp -- )
27 [ [ nip dup ] H{ } assoc-map-as locs set ]
28 [ keys [ init-to-do ] [ init-ready ] bi ] tri ;
30 :: process-ready ( b quot -- )
35 a c = a preds get at and [ a ready get push-front ] when ; inline
37 :: process-to-do ( b quot -- )
38 ! Note that we check if b = loc(b), not b = loc(pred(b)) as the
39 ! paper suggests. Confirmed by one of the authors at
40 ! http://www.reddit.com/comments/93253/some_lecture_notes_on_ssa_form/c0bco4f
43 temp get b locs get set-at
44 b ready get push-front
49 :: parallel-mapping ( mapping temp quot -- )
60 : parallel-copy ( mapping -- ) i [ ##copy ] parallel-mapping ;