factor/basis/compiler/cfg/registers/registers.factor

38 lines
932 B
Factor
Raw Normal View History

2008-09-10 23:11:03 -04:00
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
2008-10-20 02:56:28 -04:00
USING: accessors namespaces kernel arrays
parser prettyprint.backend prettyprint.sections ;
2008-09-15 02:54:48 -04:00
IN: compiler.cfg.registers
2008-09-10 23:11:03 -04:00
2008-10-20 02:56:28 -04:00
! Virtual registers, used by CFG and machine IRs
2008-10-22 19:39:41 -04:00
TUPLE: vreg { reg-class read-only } { n read-only } ;
2008-09-10 23:11:03 -04:00
SYMBOL: vreg-counter
: next-vreg ( reg-class -- vreg ) \ vreg-counter counter vreg boa ;
! Stack locations
2008-10-22 19:39:41 -04:00
TUPLE: loc { n read-only } ;
2008-10-17 21:03:59 -04:00
2008-09-10 23:11:03 -04:00
TUPLE: ds-loc < loc ;
2008-10-20 02:56:28 -04:00
C: <ds-loc> ds-loc
2008-09-10 23:11:03 -04:00
TUPLE: rs-loc < loc ;
C: <rs-loc> rs-loc
2008-09-17 01:46:38 -04:00
2008-10-20 02:56:28 -04:00
! Prettyprinting
: V scan-word scan-word vreg boa parsed ; parsing
2008-09-10 23:11:03 -04:00
2008-10-20 02:56:28 -04:00
M: vreg pprint*
<block
\ V pprint-word [ reg-class>> pprint* ] [ n>> pprint* ] bi
block> ;
2008-09-17 01:46:38 -04:00
2008-10-20 02:56:28 -04:00
: pprint-loc ( loc word -- ) <block pprint-word n>> pprint* block> ;
2008-09-10 23:11:03 -04:00
2008-10-20 02:56:28 -04:00
: D scan-word <ds-loc> parsed ; parsing
2008-09-17 01:46:38 -04:00
2008-10-20 02:56:28 -04:00
M: ds-loc pprint* \ D pprint-loc ;
2008-09-10 23:11:03 -04:00
2008-10-20 02:56:28 -04:00
: R scan-word <rs-loc> parsed ; parsing
2008-09-17 01:46:38 -04:00
2008-10-20 02:56:28 -04:00
M: rs-loc pprint* \ R pprint-loc ;