]> gitweb.factorcode.org Git - factor.git/commitdiff
break simd intrinsics into a separate vocab so they can be intrinsified before the...
authorJoe Groff <arcata@gmail.com>
Thu, 19 Nov 2009 19:53:46 +0000 (11:53 -0800)
committerJoe Groff <arcata@gmail.com>
Thu, 19 Nov 2009 19:53:46 +0000 (11:53 -0800)
basis/compiler/cfg/intrinsics/simd/simd.factor
basis/compiler/cfg/value-numbering/simd/simd.factor
basis/compiler/tree/propagation/simd/simd.factor
basis/cpu/architecture/architecture.factor
basis/math/vectors/simd/simd.factor

index 54f105ca02c48fa752c3cd8ade70a68e7bb58818..5f4b71a8465edba47d0dfe09dfc03e9e438c119b 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien alien.c-types byte-arrays fry
 classes.algebra cpu.architecture kernel math sequences
-math.vectors math.vectors.simd math.vectors.simd.private
+math.vectors math.vectors.simd.intrinsics
 macros generalizations combinators combinators.short-circuit
 arrays locals compiler.tree.propagation.info
 compiler.cfg.builder.blocks
index 9bb44533134993c39c450e978c25fab2a4c02070..16d38bc5bb0ea75830a1372999c8353534063e54 100644 (file)
@@ -4,7 +4,7 @@ USING: accessors combinators combinators.short-circuit arrays
 fry kernel layouts math namespaces sequences cpu.architecture
 math.bitwise math.order classes
 vectors locals make alien.c-types io.binary grouping
-math.vectors.simd
+math.vectors.simd.intrinsics
 compiler.cfg
 compiler.cfg.registers
 compiler.cfg.comparisons
index b71a34e93821bd116846ce4f674b32959db4a625..679cc092736d14a6f947b1bc0ed8fa42953d9064 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors byte-arrays combinators fry sequences
 compiler.tree.propagation.info cpu.architecture kernel words math
-math.intervals math.vectors.simd math.vectors.simd.private ;
+math.intervals math.vectors.simd.intrinsics ;
 IN: compiler.tree.propagation.simd
 
 {
index f4d150033babd437174782978e32e6b44a6c08a0..86d68caa666f2d4f9879945d421d2d6db67e6345 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2006, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays assocs generic kernel kernel.private
+USING: accessors alien.c-types arrays assocs generic kernel kernel.private
 math memory namespaces make sequences layouts system hashtables
 classes alien byte-arrays combinators words sets fry ;
 IN: cpu.architecture
@@ -160,6 +160,9 @@ M: ulonglong-scalar-rep rep-size drop 8 ;
 
 GENERIC: rep-component-type ( rep -- n )
 
+: rep-length ( rep -- n )
+    16 swap rep-component-type heap-size /i ; foldable
+
 ! Methods defined in alien.c-types
 
 GENERIC: scalar-rep-of ( rep -- rep' )
index 5d96df8b7fa69c639de0672dc649deb1f53858d9..9265df734344bdf5eb2f4b3b85ba4f9293202d82 100644 (file)
@@ -1,18 +1,12 @@
 USING: accessors alien.c-types arrays byte-arrays classes combinators
 cpu.architecture effects fry functors generalizations generic
 generic.parser kernel lexer literals macros math math.functions
-math.vectors math.vectors.private namespaces parser
+math.vectors math.vectors.private math.vectors.simd.intrinsics namespaces parser
 prettyprint.custom quotations sequences sequences.private vocabs
 vocabs.loader words ;
 QUALIFIED-WITH: alien.c-types c
 IN: math.vectors.simd
 
-DEFER: vconvert
-DEFER: simd-with
-DEFER: simd-boa
-DEFER: simd-cast
-
-ERROR: bad-simd-call word ;
 ERROR: bad-simd-length got expected ;
 
 <<
@@ -30,68 +24,6 @@ PRIVATE>
 
 <PRIVATE
 
-! SIMD intrinsics
-
-: (simd-v+)                ( a b rep -- c ) \ v+ bad-simd-call ;
-: (simd-v-)                ( a b rep -- c ) \ v- bad-simd-call ;
-: (simd-vneg)              ( a   rep -- c ) \ vneg bad-simd-call ;
-: (simd-v+-)               ( a b rep -- c ) \ v+- bad-simd-call ;
-: (simd-vs+)               ( a b rep -- c ) \ vs+ bad-simd-call ;
-: (simd-vs-)               ( a b rep -- c ) \ vs- bad-simd-call ;
-: (simd-vs*)               ( a b rep -- c ) \ vs* bad-simd-call ;
-: (simd-v*)                ( a b rep -- c ) \ v* bad-simd-call ;
-: (simd-v/)                ( a b rep -- c ) \ v/ bad-simd-call ;
-: (simd-vmin)              ( a b rep -- c ) \ vmin bad-simd-call ;
-: (simd-vmax)              ( a b rep -- c ) \ vmax bad-simd-call ;
-: (simd-v.)                ( a b rep -- n ) \ v. bad-simd-call ;
-: (simd-vsqrt)             ( a   rep -- c ) \ vsqrt bad-simd-call ;
-: (simd-sum)               ( a   rep -- n ) \ sum bad-simd-call ;
-: (simd-vabs)              ( a   rep -- c ) \ vabs bad-simd-call ;
-: (simd-vbitand)           ( a b rep -- c ) \ vbitand bad-simd-call ;
-: (simd-vbitandn)          ( a b rep -- c ) \ vbitandn bad-simd-call ;
-: (simd-vbitor)            ( a b rep -- c ) \ vbitor bad-simd-call ;
-: (simd-vbitxor)           ( a b rep -- c ) \ vbitxor bad-simd-call ;
-: (simd-vbitnot)           ( a   rep -- c ) \ vbitnot bad-simd-call ;
-: (simd-vand)              ( a b rep -- c ) \ vand bad-simd-call ;
-: (simd-vandn)             ( a b rep -- c ) \ vandn bad-simd-call ;
-: (simd-vor)               ( a b rep -- c ) \ vor bad-simd-call ;
-: (simd-vxor)              ( a b rep -- c ) \ vxor bad-simd-call ;
-: (simd-vnot)              ( a   rep -- c ) \ vnot bad-simd-call ;
-: (simd-vlshift)           ( a n rep -- c ) \ vlshift bad-simd-call ;
-: (simd-vrshift)           ( a n rep -- c ) \ vrshift bad-simd-call ;
-: (simd-hlshift)           ( a n rep -- c ) \ hlshift bad-simd-call ;
-: (simd-hrshift)           ( a n rep -- c ) \ hrshift bad-simd-call ;
-: (simd-vshuffle-elements) ( a n rep -- c ) \ vshuffle-elements bad-simd-call ;
-: (simd-vshuffle-bytes)    ( a b rep -- c ) \ vshuffle-bytes bad-simd-call ;
-: (simd-vmerge-head)       ( a b rep -- c ) \ (vmerge-head) bad-simd-call ;
-: (simd-vmerge-tail)       ( a b rep -- c ) \ (vmerge-tail) bad-simd-call ;
-: (simd-v<=)               ( a b rep -- c ) \ v<= bad-simd-call ;
-: (simd-v<)                ( a b rep -- c ) \ v< bad-simd-call ;
-: (simd-v=)                ( a b rep -- c ) \ v= bad-simd-call ;
-: (simd-v>)                ( a b rep -- c ) \ v> bad-simd-call ;
-: (simd-v>=)               ( a b rep -- c ) \ v>= bad-simd-call ;
-: (simd-vunordered?)       ( a b rep -- c ) \ vunordered? bad-simd-call ;
-: (simd-vany?)             ( a   rep -- ? ) \ vany? bad-simd-call ;
-: (simd-vall?)             ( a   rep -- ? ) \ vall? bad-simd-call ;
-: (simd-vnone?)            ( a   rep -- ? ) \ vnone? bad-simd-call ;
-: (simd-v>float)           ( a   rep -- c ) \ vconvert bad-simd-call ;
-: (simd-v>integer)         ( a   rep -- c ) \ vconvert bad-simd-call ;
-: (simd-vpack-signed)      ( a b rep -- c ) \ vconvert bad-simd-call ;
-: (simd-vpack-unsigned)    ( a b rep -- c ) \ vconvert bad-simd-call ;
-: (simd-vunpack-head)      ( a   rep -- c ) \ vconvert bad-simd-call ;
-: (simd-vunpack-tail)      ( a   rep -- c ) \ vconvert bad-simd-call ;
-: (simd-with)              (   n rep -- v ) \ simd-with bad-simd-call ;
-: (simd-gather-2)          ( m n rep -- v ) \ simd-boa bad-simd-call ;
-: (simd-gather-4)          ( m n o p rep -- v ) \ simd-boa bad-simd-call ;
-: (simd-select)            ( a n rep -- n ) \ nth bad-simd-call ;
-
-PRIVATE>
-
-: alien-vector     (       c-ptr n rep -- value ) \ alien-vector bad-simd-call ;
-: set-alien-vector ( value c-ptr n rep --       ) \ set-alien-vector bad-simd-call ;
-
-<PRIVATE
-
 ! Helper for boolean vector literals
 
 : vector-true-value ( class -- value )
@@ -117,13 +49,6 @@ TUPLE: simd-128
 GENERIC: simd-element-type ( obj -- c-type )
 GENERIC: simd-rep ( simd -- rep )
 
-<<
-: assert-positive ( x -- y ) ;
-
-: rep-length ( rep -- n )
-    16 swap rep-component-type heap-size /i ; foldable
->>
-
 <<
 <PRIVATE
 
@@ -216,7 +141,25 @@ M: A like drop dup \ A instance? [ >A ] unless ; inline
 M: A hashcode* underlying>> hashcode* ; inline
 M: A clone [ clone ] change-underlying ; inline
 M: A length drop N ; inline
-M: A nth-unsafe swap \ A-rep (simd-select) ; inline
+M: A nth-unsafe
+    swap {
+        {  0 [  0 \ A-rep (simd-select) ] }
+        {  1 [  1 \ A-rep (simd-select) ] }
+        {  2 [  2 \ A-rep (simd-select) ] }
+        {  3 [  3 \ A-rep (simd-select) ] }
+        {  4 [  4 \ A-rep (simd-select) ] }
+        {  5 [  5 \ A-rep (simd-select) ] }
+        {  6 [  6 \ A-rep (simd-select) ] }
+        {  7 [  7 \ A-rep (simd-select) ] }
+        {  8 [  8 \ A-rep (simd-select) ] }
+        {  9 [  9 \ A-rep (simd-select) ] }
+        { 10 [ 10 \ A-rep (simd-select) ] }
+        { 11 [ 11 \ A-rep (simd-select) ] }
+        { 12 [ 12 \ A-rep (simd-select) ] }
+        { 13 [ 13 \ A-rep (simd-select) ] }
+        { 14 [ 14 \ A-rep (simd-select) ] }
+        { 15 [ 15 \ A-rep (simd-select) ] }
+    } case ; inline 
 M: A c:byte-length drop 16 ; inline
 
 M: A new-sequence
@@ -353,10 +296,6 @@ SIMD-128: double-2
 M: simd-128 vshuffle ( u perm -- v )
     vshuffle-bytes ; inline
 
-"compiler.tree.propagation.simd" require
-"compiler.cfg.intrinsics.simd" require
-"compiler.cfg.value-numbering.simd" require
-
 "mirrors" vocab [
     "math.vectors.simd.mirrors" require
 ] when