]> gitweb.factorcode.org Git - factor.git/blob - unfinished/compiler/machine/machine.factor
Merge branch 'master' of git://factorcode.org/git/factor
[factor.git] / unfinished / compiler / machine / machine.factor
1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: assocs accessors arrays namespaces kernel math
4 sequences compiler.instructions compiler.instructions.syntax ;
5 IN: compiler.machine
6
7 ! Machine representation. Flat list of instructions, all
8 ! registers allocated, with labels and jumps.
9
10 INSN: _prologue n ;
11 INSN: _epilogue n ;
12
13 INSN: _label label ;
14
15 : <label> ( -- label ) \ <label> counter ;
16 : define-label ( name -- ) <label> swap set ;
17 : resolve-label ( label/name -- ) dup integer? [ get ] unless _label ;
18
19 TUPLE: _cond-branch vreg label ;
20
21 INSN: _branch label ;
22 INSN: _branch-f < _cond-branch ;
23 INSN: _branch-t < _cond-branch ;
24 INSN: _if-intrinsic label quot vregs ;
25
26 M: _cond-branch uses-vregs vreg>> 1array ;
27 M: _if-intrinsic uses-vregs vregs>> values ;