2009-07-21 18:49:44 -04:00
|
|
|
! Copyright (C) 2008, 2009 Slava Pestov.
|
2008-09-10 23:11:03 -04:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2009-07-21 18:49:44 -04:00
|
|
|
USING: accessors namespaces kernel arrays parser math math.order ;
|
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
|
2009-08-07 18:44:50 -04:00
|
|
|
TUPLE: vreg { rep read-only } { n fixnum read-only } ;
|
2009-07-21 18:49:44 -04:00
|
|
|
|
|
|
|
|
M: vreg equal? over vreg? [ [ n>> ] bi@ eq? ] [ 2drop f ] if ;
|
|
|
|
|
|
|
|
|
|
M: vreg hashcode* nip n>> ;
|
|
|
|
|
|
2008-09-10 23:11:03 -04:00
|
|
|
SYMBOL: vreg-counter
|
2009-07-21 18:49:44 -04:00
|
|
|
|
2009-08-07 18:44:50 -04:00
|
|
|
: next-vreg ( rep -- vreg ) \ vreg-counter counter vreg boa ;
|
2008-09-10 23:11:03 -04:00
|
|
|
|
2009-06-26 18:29:55 -04:00
|
|
|
! Stack locations -- 'n' is an index starting from the top of the stack
|
|
|
|
|
! going down. So 0 is the top of the stack, 1 is what would be the top
|
|
|
|
|
! of the stack after a 'drop', and so on.
|
|
|
|
|
|
|
|
|
|
! ##inc-d and ##inc-r affect locations as follows. Location D 0 before
|
|
|
|
|
! an ##inc-d 1 becomes D 1 after ##inc-d 1.
|
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 ;
|
2008-10-21 04:20:48 -04:00
|
|
|
C: <rs-loc> rs-loc
|
2008-09-17 01:46:38 -04:00
|
|
|
|
2009-03-21 02:27:50 -04:00
|
|
|
SYNTAX: V scan-word scan-word vreg boa parsed ;
|
|
|
|
|
SYNTAX: D scan-word <ds-loc> parsed ;
|
|
|
|
|
SYNTAX: R scan-word <rs-loc> parsed ;
|