factor/basis/compiler/cfg/cfg.factor

30 lines
643 B
Factor
Raw Normal View History

2008-07-20 05:24:37 -04:00
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
2008-10-19 02:10:21 -04:00
USING: kernel arrays accessors namespaces assocs sequences sets fry ;
2008-07-20 05:24:37 -04:00
IN: compiler.cfg
2008-09-11 03:05:22 -04:00
TUPLE: cfg entry word label ;
2008-09-10 23:11:03 -04:00
2008-09-11 03:05:22 -04:00
C: <cfg> cfg
2008-09-10 23:11:03 -04:00
2008-07-20 05:24:37 -04:00
TUPLE: basic-block < identity-tuple
id
2008-07-20 05:24:37 -04:00
number
instructions
successors
gc ;
2008-07-20 05:24:37 -04:00
: <basic-block> ( -- basic-block )
basic-block new
V{ } clone >>instructions
V{ } clone >>successors
\ basic-block counter >>id ;
2008-07-20 05:24:37 -04:00
2008-10-19 02:10:21 -04:00
TUPLE: mr { instructions array } word label spill-counts ;
2008-07-20 05:24:37 -04:00
: <mr> ( instructions word label -- mr )
mr new
swap >>label
swap >>word
swap >>instructions ;