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