fix simd intrinsic compilation

db4
Joe Groff 2009-11-24 11:37:28 -08:00
parent d94ffe6d78
commit 65d8060075
4 changed files with 29 additions and 13 deletions

View File

@ -45,6 +45,12 @@ SYMBOL: loops
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 -- )

View File

@ -151,6 +151,8 @@ MACRO: check-elements ( quots -- )
[ length 1 - \ and <repetition> [ ] like ]
tri 3append ;
ERROR: bad-simd-intrinsic node ;
MACRO: if-literals-match ( quots -- )
[ length ] [ ] [ length ] tri
! n quots n
@ -165,7 +167,7 @@ MACRO: if-literals-match ( quots -- )
! node literals quot
[ _ firstn ] dip call
drop
] [ 2drop emit-primitive ] if
] [ 2drop bad-simd-intrinsic ] if
] ;
CONSTANT: [unary] [ ds-drop ds-pop ]

View File

@ -77,14 +77,6 @@ IN: compiler.cfg.intrinsics.simd
[ [ ^^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?
@ -107,6 +99,14 @@ IN: compiler.cfg.intrinsics.simd
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) ]

View File

@ -1,8 +1,9 @@
! 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
@ -98,8 +99,15 @@ vector>vector-intrinsics [ { byte-array } "default-output-classes" set-word-prop
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 '[