]> gitweb.factorcode.org Git - factor.git/blob - basis/compiler/tree/propagation/simd/simd.factor
update compiler.tree.propagation.simd, and don't load it till math.vectors.simd is...
[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 ;
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-bytes)
35     (simd-vshuffle-elements)
36     (simd-vmerge-head)
37     (simd-vmerge-tail)
38     (simd-v>float)
39     (simd-v>integer)
40     (simd-vpack-signed)
41     (simd-vpack-unsigned)
42     (simd-vunpack-head)
43     (simd-vunpack-tail)
44     (simd-v<=)
45     (simd-v<)
46     (simd-v=)
47     (simd-v>)
48     (simd-v>=)
49     (simd-vunordered?)
50     (simd-with)
51     (simd-gather-2)
52     (simd-gather-4)
53     alien-vector
54     alien-vector-aligned
55 } [ { byte-array } "default-output-classes" set-word-prop ] each
56
57 : scalar-output-class ( rep -- class )
58     dup literal?>> [
59         literal>> scalar-rep-of {
60             { float-rep [ float ] }
61             { double-rep [ float ] }
62             [ drop integer ]
63         } case
64     ] [ drop real ] if
65     <class-info> ;
66
67 \ (simd-sum) [ nip scalar-output-class ] "outputs" set-word-prop
68
69 \ (simd-v.) [ 2nip scalar-output-class ] "outputs" set-word-prop
70
71 {
72     (simd-vany?)
73     (simd-vall?)
74     (simd-vnone?)
75 } [ { boolean } "default-output-classes" set-word-prop ] each
76
77 \ (simd-select) [ 2nip scalar-output-class ] "outputs" set-word-prop
78
79 \ assert-positive [
80     real [0,inf] <class/interval-info> value-info-intersect
81 ] "outputs" set-word-prop
82
83 ! If SIMD is not available, inline alien-vector and set-alien-vector
84 ! to get a speedup
85 : inline-unless-intrinsic ( word -- )
86     dup '[ drop _ dup "intrinsic" word-prop [ drop f ] [ def>> ] if ]
87     "custom-inlining" set-word-prop ;
88
89 \ alien-vector inline-unless-intrinsic
90
91 \ set-alien-vector inline-unless-intrinsic