]> gitweb.factorcode.org Git - factor.git/commitdiff
implement vneg as an intrinsic in terms of load -0, subtract
authorJoe Groff <arcata@gmail.com>
Fri, 9 Oct 2009 18:16:39 +0000 (13:16 -0500)
committerJoe Groff <arcata@gmail.com>
Fri, 9 Oct 2009 18:16:39 +0000 (13:16 -0500)
basis/compiler/cfg/intrinsics/intrinsics.factor
basis/compiler/cfg/intrinsics/simd/simd.factor
basis/compiler/tree/propagation/simd/simd.factor
basis/math/vectors/simd/functor/functor.factor
basis/math/vectors/simd/intrinsics/intrinsics.factor
basis/math/vectors/specialization/specialization.factor

index 2dcd6d4b453cc7128a53e9ceb6da521399b37ffe..a27c8e81ddaa241d0dd27e39d4f76e557ad4920c 100644 (file)
@@ -159,6 +159,7 @@ IN: compiler.cfg.intrinsics
         { math.vectors.simd.intrinsics:(simd-v+-) [ [ ^^add-sub-vector ] emit-binary-vector-op ] }
         { math.vectors.simd.intrinsics:(simd-v-) [ [ ^^sub-vector ] emit-binary-vector-op ] }
         { math.vectors.simd.intrinsics:(simd-vs-) [ [ ^^saturated-sub-vector ] emit-binary-vector-op ] }
+        { math.vectors.simd.intrinsics:(simd-vneg) [ [ generate-neg-vector ] emit-unary-vector-op ] }
         { math.vectors.simd.intrinsics:(simd-v*) [ [ ^^mul-vector ] emit-binary-vector-op ] }
         { math.vectors.simd.intrinsics:(simd-vs*) [ [ ^^saturated-mul-vector ] emit-binary-vector-op ] }
         { math.vectors.simd.intrinsics:(simd-v/) [ [ ^^div-vector ] emit-binary-vector-op ] }
index 9986588e3e17e006398bd4bd1b4505755b67bfc7..7e8f388ce8c87e12fcf6d66c79f437aa5e58684f 100644 (file)
@@ -7,7 +7,10 @@ compiler.tree.propagation.info compiler.cfg.builder.blocks
 compiler.cfg.comparisons
 compiler.cfg.stacks compiler.cfg.stacks.local compiler.cfg.hats
 compiler.cfg.instructions compiler.cfg.registers
-compiler.cfg.intrinsics.alien ;
+compiler.cfg.intrinsics.alien
+specialized-arrays ;
+FROM: alien.c-types => float double ;
+SPECIALIZED-ARRAYS: float double ;
 IN: compiler.cfg.intrinsics.simd
 
 MACRO: check-elements ( quots -- )
@@ -177,3 +180,10 @@ MACRO: if-literals-match ( quots -- )
         ] 
     } cond ;
 
+:: generate-neg-vector ( src rep -- dst )
+    rep {
+        { float-4-rep [ float-array{ -0.0 -0.0 -0.0 -0.0 } underlying>> ^^load-constant ] }
+        { double-2-rep [ double-array{ -0.0 -0.0 } underlying>> ^^load-constant ] }
+        [ drop rep ^^zero-vector ]
+    } case
+    src rep ^^sub-vector ;
index 4e9734693b9982b444dd9c362a851aa0ee566470..7bda0fed30c026cbf5a51517ee9a0453bc286c19 100644 (file)
@@ -8,6 +8,7 @@ IN: compiler.tree.propagation.simd
 {
     (simd-v+)
     (simd-v-)
+    (simd-vneg)
     (simd-v+-)
     (simd-v*)
     (simd-v/)
index 15e37bbcd9e253288b9426679de80c13effbf64f..7f28f644e12fb468abed87716bc9f046f5387a6e 100644 (file)
@@ -109,7 +109,6 @@ ERROR: bad-schema op schema ;
     ! Some SIMD operations are defined in terms of others.
     {
         { vbroadcast [ swap nth ctor execute ] }
-        { vneg [ [ dup vbitxor ] keep v- ] }
         { n+v [ [ ctor execute ] dip v+ ] }
         { v+n [ ctor execute v+ ] }
         { n-v [ [ ctor execute ] dip v- ] }
index 0efb0c24179f2fc52575798ce573adea121acb5d..94307729a8769af07d97b19f0c9865708dea016e 100644 (file)
@@ -40,6 +40,7 @@ SYNTAX: SIMD-CONVERSION-OP:
 
 SIMD-OP: v+
 SIMD-OP: v-
+SIMD-OP: vneg
 SIMD-OP: v+-
 SIMD-OP: vs+
 SIMD-OP: vs-
@@ -148,6 +149,7 @@ M: vector-rep supported-simd-op?
         { \ (simd-v+-)           [ %add-sub-vector-reps        ] }
         { \ (simd-v-)            [ %sub-vector-reps            ] }
         { \ (simd-vs-)           [ %saturated-sub-vector-reps  ] }
+        { \ (simd-vneg)          [ %sub-vector-reps            ] }
         { \ (simd-v*)            [ %mul-vector-reps            ] }
         { \ (simd-vs*)           [ %saturated-mul-vector-reps  ] }
         { \ (simd-v/)            [ %div-vector-reps            ] }
index be959a2a2e202b92f0176b2e81581d4673641a71..28c3ee82c3ae3a98af5b8ffc3e71b8b5f00760a3 100644 (file)
@@ -69,6 +69,7 @@ H{
     { v+- { +vector+ +vector+ -> +vector+ } }
     { v+n { +vector+ +scalar+ -> +vector+ } }
     { v- { +vector+ +vector+ -> +vector+ } }
+    { vneg { +vector+ -> +vector+ } }
     { vs- { +vector+ +vector+ -> +vector+ } }
     { v-n { +vector+ +scalar+ -> +vector+ } }
     { v. { +vector+ +vector+ -> +scalar+ } }