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
7 ! Virtual CPU instructions, used by CFG and machine IRs
9 INSN: %cond-branch vreg ;
10 INSN: %unary dst src ;
13 INSN: %peek vreg loc ;
14 INSN: %replace vreg loc ;
17 INSN: %load-literal obj vreg ;
22 INSN: %frame-required n ;
28 INSN: %intrinsic quot vregs ;
31 INSN: %dispatch-label label ;
34 ! Unconditional branch to successor (CFG only)
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 ;
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 ;
57 INSN: %alien-invoke params ;
58 INSN: %alien-indirect params ;
59 INSN: %alien-callback params ;
61 GENERIC: uses-vregs ( insn -- seq )
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 ;