]> gitweb.factorcode.org Git - factor.git/blob - unfinished/compiler/instructions/instructions.factor
Merge branch 'master' of git://factorcode.org/git/factor
[factor.git] / unfinished / compiler / instructions / instructions.factor
1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: assocs accessors arrays kernel sequences
4 compiler.instructions.syntax ;
5 IN: compiler.instructions
6
7 ! Virtual CPU instructions, used by CFG and machine IRs
8
9 INSN: %cond-branch vreg ;
10 INSN: %unary dst src ;
11
12 ! Stack operations
13 INSN: %peek vreg loc ;
14 INSN: %replace vreg loc ;
15 INSN: %inc-d n ;
16 INSN: %inc-r n ;
17 INSN: %load-literal obj vreg ;
18
19 ! Calling convention
20 INSN: %prologue ;
21 INSN: %epilogue ;
22 INSN: %frame-required n ;
23 INSN: %return ;
24
25 ! Subroutine calls
26 INSN: %call word ;
27 INSN: %jump word ;
28 INSN: %intrinsic quot vregs ;
29
30 ! Jump tables
31 INSN: %dispatch-label label ;
32 INSN: %dispatch ;
33
34 ! Unconditional branch to successor (CFG only)
35 INSN: %branch ;
36
37 ! Conditional branches (CFG only)
38 INSN: %branch-f < %cond-branch ;
39 INSN: %branch-t < %cond-branch ;
40 INSN: %if-intrinsic quot vregs ;
41 INSN: %boolean-intrinsic quot vregs out ;
42
43 ! Boxing and unboxing
44 INSN: %copy < %unary ;
45 INSN: %copy-float < %unary ;
46 INSN: %unbox-float < %unary ;
47 INSN: %unbox-f < %unary ;
48 INSN: %unbox-alien < %unary ;
49 INSN: %unbox-byte-array < %unary ;
50 INSN: %unbox-any-c-ptr < %unary ;
51 INSN: %box-float < %unary ;
52 INSN: %box-alien < %unary ;
53
54 INSN: %gc ;
55
56 ! FFI
57 INSN: %alien-invoke params ;
58 INSN: %alien-indirect params ;
59 INSN: %alien-callback params ;
60
61 GENERIC: uses-vregs ( insn -- seq )
62
63 M: insn uses-vregs drop f ;
64 M: %peek uses-vregs vreg>> 1array ;
65 M: %replace uses-vregs vreg>> 1array ;
66 M: %load-literal uses-vregs vreg>> 1array ;
67 M: %cond-branch uses-vregs vreg>> 1array ;
68 M: %unary uses-vregs [ dst>> ] [ src>> ] bi 2array ;
69 M: %intrinsic uses-vregs vregs>> values ;
70 M: %if-intrinsic uses-vregs vregs>> values ;
71 M: %boolean-intrinsic uses-vregs
72     [ vregs>> values ] [ out>> ] bi suffix ;