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.
|
2014-12-13 19:10:21 -05:00
|
|
|
USING: assocs kernel math namespaces parser sequences ;
|
2008-09-15 02:54:48 -04:00
|
|
|
IN: compiler.cfg.registers
|
2008-09-10 23:11:03 -04:00
|
|
|
|
2009-08-08 05:02:18 -04:00
|
|
|
! Virtual registers, used by CFG and machine IRs, are just integers
|
|
|
|
SYMBOL: vreg-counter
|
2009-07-21 18:49:44 -04:00
|
|
|
|
2009-08-08 05:02:18 -04:00
|
|
|
: next-vreg ( -- vreg )
|
2012-08-02 18:14:42 -04:00
|
|
|
vreg-counter counter ;
|
2009-07-21 18:49:44 -04:00
|
|
|
|
2009-08-08 05:02:18 -04:00
|
|
|
SYMBOL: representations
|
2009-07-21 18:49:44 -04:00
|
|
|
|
2009-08-08 05:02:18 -04:00
|
|
|
ERROR: bad-vreg vreg ;
|
|
|
|
|
|
|
|
: rep-of ( vreg -- rep )
|
|
|
|
representations get ?at [ bad-vreg ] unless ;
|
|
|
|
|
|
|
|
: set-rep-of ( rep vreg -- )
|
|
|
|
representations get set-at ;
|
2009-07-21 18:49:44 -04:00
|
|
|
|
2009-08-08 05:02:18 -04:00
|
|
|
: next-vreg-rep ( rep -- vreg )
|
|
|
|
next-vreg [ set-rep-of ] keep ;
|
2008-09-10 23:11:03 -04:00
|
|
|
|
2009-06-26 18:29:55 -04:00
|
|
|
! ##inc-d and ##inc-r affect locations as follows. Location D 0 before
|
|
|
|
! an ##inc-d 1 becomes D 1 after ##inc-d 1.
|
2010-05-03 22:11:29 -04:00
|
|
|
TUPLE: loc { n integer 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
|
|
|
|
2011-10-01 19:42:37 -04:00
|
|
|
SYNTAX: D scan-number <ds-loc> suffix! ;
|
|
|
|
SYNTAX: R scan-number <rs-loc> suffix! ;
|