end-stack-analysis
] with-scope ; inline
+: with-dummy-cfg-builder ( node quot -- )
+ [
+ [ V{ } clone procedures ] 2dip
+ '[ _ t t [ _ call( node -- ) ] with-cfg-builder ] with-variable
+ ] { } make drop ;
+
GENERIC: emit-node ( node -- )
: emit-nodes ( nodes -- )
[ length 1 - \ and <repetition> [ ] like ]
tri 3append ;
+ERROR: bad-simd-intrinsic node ;
+
MACRO: if-literals-match ( quots -- )
[ length ] [ ] [ length ] tri
! n quots n
! node literals quot
[ _ firstn ] dip call
drop
- ] [ 2drop emit-primitive ] if
+ ] [ 2drop bad-simd-intrinsic ] if
] ;
CONSTANT: [unary] [ ds-drop ds-pop ]
[ [ ^^fill-vector ] [ ^^xor-vector ] bi ]
} v-vector-op ;
-:: ^minmax-compare-vector ( src1 src2 rep cc -- dst )
- cc order-cc {
- { cc< [ src1 src2 rep ^^max-vector src1 rep cc/= ^^compare-vector ] }
- { cc<= [ src1 src2 rep ^^min-vector src1 rep cc= ^^compare-vector ] }
- { cc> [ src1 src2 rep ^^min-vector src1 rep cc/= ^^compare-vector ] }
- { cc>= [ src1 src2 rep ^^max-vector src1 rep cc= ^^compare-vector ] }
- } case ;
-
:: ^((compare-vector)) ( src1 src2 rep {cc,swap} -- dst )
{cc,swap} first2 :> ( cc swap? )
swap?
not? [ rep ^not-vector ] when
] if ;
+:: ^minmax-compare-vector ( src1 src2 rep cc -- dst )
+ cc order-cc {
+ { cc< [ src1 src2 rep ^^max-vector src1 rep cc/= ^(compare-vector) ] }
+ { cc<= [ src1 src2 rep ^^min-vector src1 rep cc= ^(compare-vector) ] }
+ { cc> [ src1 src2 rep ^^min-vector src1 rep cc/= ^(compare-vector) ] }
+ { cc>= [ src1 src2 rep ^^max-vector src1 rep cc= ^(compare-vector) ] }
+ } case ;
+
: ^compare-vector ( src1 src2 rep cc -- dst )
{
[ ^(compare-vector) ]
! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors byte-arrays combinators continuations fry sequences
-compiler.tree.propagation.info cpu.architecture kernel words make math
-math.intervals math.vectors.simd.intrinsics ;
+USING: accessors assocs byte-arrays combinators compiler.cfg.builder
+continuations fry sequences compiler.tree.propagation.info
+cpu.architecture kernel words make math math.intervals
+math.vectors.simd.intrinsics ;
IN: compiler.tree.propagation.simd
CONSTANT: vector>vector-intrinsics
real [0,inf] <class/interval-info> value-info-intersect
] "outputs" set-word-prop
+: clone-with-value-infos ( node -- node' )
+ clone dup in-d>> [ dup value-info ] H{ } map>assoc >>info ;
+
: try-intrinsic ( node intrinsic-quot -- ? )
- '[ [ _ call( node -- ) ] { } make drop t ] [ 2drop f ] recover ;
+ '[
+ _ clone-with-value-infos
+ _ with-dummy-cfg-builder
+ t
+ ] [ drop f ] recover ;
: inline-unless-intrinsic ( word -- )
dup '[