1 ! Copyright (C) 2008, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors namespaces kernel parser assocs ;
4 IN: compiler.cfg.registers
6 ! Virtual registers, used by CFG and machine IRs, are just integers
9 : next-vreg ( -- vreg )
10 ! This word cannot be called AFTER representation selection has run;
11 ! use next-vreg-rep in that case
12 \ vreg-counter counter ;
14 SYMBOL: representations
16 ERROR: bad-vreg vreg ;
18 : rep-of ( vreg -- rep )
19 ! This word cannot be called BEFORE representation selection has run;
20 ! use any-rep for ##copy instructions and so on
21 representations get ?at [ bad-vreg ] unless ;
23 : set-rep-of ( rep vreg -- )
24 representations get set-at ;
26 : next-vreg-rep ( rep -- vreg )
27 ! This word cannot be called BEFORE representation selection has run;
28 ! use next-vreg in that case
29 next-vreg [ set-rep-of ] keep ;
31 ! Stack locations -- 'n' is an index starting from the top of the stack
32 ! going down. So 0 is the top of the stack, 1 is what would be the top
33 ! of the stack after a 'drop', and so on.
35 ! ##inc-d and ##inc-r affect locations as follows. Location D 0 before
36 ! an ##inc-d 1 becomes D 1 after ##inc-d 1.
37 TUPLE: loc { n read-only } ;
45 SYNTAX: D scan-word <ds-loc> parsed ;
46 SYNTAX: R scan-word <rs-loc> parsed ;