]> gitweb.factorcode.org Git - factor.git/blob - basis/compiler/tree/propagation/simd/simd.factor
Merge branch 'master' of git://factorcode.org/git/factor into bitfields
[factor.git] / basis / compiler / tree / propagation / simd / simd.factor
1 ! Copyright (C) 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors byte-arrays combinators fry sequences
4 compiler.tree.propagation.info cpu.architecture kernel words math
5 math.intervals math.vectors.simd.intrinsics ;
6 IN: compiler.tree.propagation.simd
7
8 {
9     (simd-v+)
10     (simd-v-)
11     (simd-v+-)
12     (simd-v*)
13     (simd-v/)
14     (simd-vmin)
15     (simd-vmax)
16     (simd-sum)
17     (simd-vabs)
18     (simd-vsqrt)
19     (simd-vbitand)
20     (simd-vbitandn)
21     (simd-vbitor)
22     (simd-vbitxor)
23     (simd-vbitnot)
24     (simd-vand)
25     (simd-vandn)
26     (simd-vor)
27     (simd-vxor)
28     (simd-vnot)
29     (simd-vlshift)
30     (simd-vrshift)
31     (simd-hlshift)
32     (simd-hrshift)
33     (simd-vshuffle)
34     (simd-(vmerge-head))
35     (simd-(vmerge-tail))
36     (simd-(v>float))
37     (simd-(v>integer))
38     (simd-(vpack-signed))
39     (simd-(vpack-unsigned))
40     (simd-(vunpack-head))
41     (simd-(vunpack-tail))
42     (simd-v<=)
43     (simd-v<)
44     (simd-v=)
45     (simd-v>)
46     (simd-v>=)
47     (simd-vunordered?)
48     (simd-with)
49     (simd-gather-2)
50     (simd-gather-4)
51     alien-vector
52 } [ { byte-array } "default-output-classes" set-word-prop ] each
53
54 : scalar-output-class ( rep -- class )
55     dup literal?>> [
56         literal>> scalar-rep-of {
57             { float-rep [ float ] }
58             { double-rep [ float ] }
59             [ drop integer ]
60         } case
61     ] [ drop real ] if
62     <class-info> ;
63
64 \ (simd-sum) [ nip scalar-output-class ] "outputs" set-word-prop
65
66 \ (simd-v.) [ 2nip scalar-output-class ] "outputs" set-word-prop
67
68 {
69     (simd-vany?)
70     (simd-vall?)
71     (simd-vnone?)
72 } [ { boolean } "default-output-classes" set-word-prop ] each
73
74 \ (simd-select) [ 2nip scalar-output-class ] "outputs" set-word-prop
75
76 \ assert-positive [
77     real [0,inf] <class/interval-info> value-info-intersect
78 ] "outputs" set-word-prop
79
80 ! If SIMD is not available, inline alien-vector and set-alien-vector
81 ! to get a speedup
82 : inline-unless-intrinsic ( word -- )
83     dup '[ drop _ dup "intrinsic" word-prop [ drop f ] [ def>> ] if ]
84     "custom-inlining" set-word-prop ;
85
86 \ alien-vector inline-unless-intrinsic
87
88 \ set-alien-vector inline-unless-intrinsic