From 4d4da7ac238a6334fb5f2b8dfa8812f8e91d2b63 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 6 Oct 2009 21:28:33 -0500 Subject: [PATCH] break vector conversion intrinsics off to a math.vectors.conversion.backend vocab so the whole conversion vocab doesn't get sucked in by the compiler --- .../vectors/conversion/backend/backend.factor | 21 +++++++++++++++++++ .../math/vectors/conversion/conversion.factor | 18 +--------------- .../math/vectors/simd/functor/functor.factor | 2 +- .../vectors/simd/intrinsics/intrinsics.factor | 2 +- .../specialization/specialization.factor | 2 +- 5 files changed, 25 insertions(+), 20 deletions(-) create mode 100644 basis/math/vectors/conversion/backend/backend.factor diff --git a/basis/math/vectors/conversion/backend/backend.factor b/basis/math/vectors/conversion/backend/backend.factor new file mode 100644 index 0000000000..d47fab1b0e --- /dev/null +++ b/basis/math/vectors/conversion/backend/backend.factor @@ -0,0 +1,21 @@ +! (c)Joe Groff bsd license +USING: accessors alien.c-types arrays assocs classes combinators +cords fry kernel math math.vectors sequences ; +IN: math.vectors.conversion.backend + +: saturate-map-as ( v quot result -- w ) + [ element-type '[ @ _ c-type-clamp ] ] keep map-as ; inline + +: (v>float) ( i to-type -- f ) + [ >float ] swap new map-as ; +: (v>integer) ( f to-type -- i ) + [ >integer ] swap new map-as ; +: (vpack-signed) ( a b to-type -- ab ) + [ cord-append [ ] ] dip new saturate-map-as ; +: (vpack-unsigned) ( a b to-type -- ab ) + [ cord-append [ ] ] dip new saturate-map-as ; +: (vunpack-head) ( ab to-type -- a ) + [ dup length 2 /i head-slice ] dip new like ; +: (vunpack-tail) ( ab to-type -- b ) + [ dup length 2 /i tail-slice ] dip new like ; + diff --git a/basis/math/vectors/conversion/conversion.factor b/basis/math/vectors/conversion/conversion.factor index 7f09e50498..863cb9fea5 100644 --- a/basis/math/vectors/conversion/conversion.factor +++ b/basis/math/vectors/conversion/conversion.factor @@ -1,7 +1,7 @@ ! (c)Joe Groff bsd license USING: accessors alien.c-types arrays assocs classes combinators combinators.short-circuit cords fry kernel locals math -math.vectors sequences ; +math.vectors math.vectors.conversion.backend sequences ; FROM: alien.c-types => char uchar short ushort int uint longlong ulonglong float double ; IN: math.vectors.conversion @@ -10,22 +10,6 @@ ERROR: bad-vconvert-input value expected-type ; float) ( i to-type -- f ) - [ >float ] swap new map-as ; -: (v>integer) ( f to-type -- i ) - [ >integer ] swap new map-as ; -: (vpack-signed) ( a b to-type -- ab ) - [ cord-append [ ] ] dip new saturate-map-as ; -: (vpack-unsigned) ( a b to-type -- ab ) - [ cord-append [ ] ] dip new saturate-map-as ; -: (vunpack-head) ( ab to-type -- a ) - [ dup length 2 /i head-slice ] dip new like ; -: (vunpack-tail) ( ab to-type -- b ) - [ dup length 2 /i tail-slice ] dip new like ; - : float-type? ( c-type -- ? ) { float double } memq? ; : unsigned-type? ( c-type -- ? ) diff --git a/basis/math/vectors/simd/functor/functor.factor b/basis/math/vectors/simd/functor/functor.factor index efdddc16e0..15e37bbcd9 100644 --- a/basis/math/vectors/simd/functor/functor.factor +++ b/basis/math/vectors/simd/functor/functor.factor @@ -3,7 +3,7 @@ USING: accessors assocs byte-arrays classes classes.algebra effects fry functors generalizations kernel literals locals math math.functions math.vectors math.vectors.private math.vectors.simd.intrinsics -math.vectors.conversion math.vectors.conversion.private +math.vectors.conversion.backend math.vectors.specialization parser prettyprint.custom sequences sequences.private strings words definitions macros cpu.architecture namespaces arrays quotations combinators combinators.short-circuit sets diff --git a/basis/math/vectors/simd/intrinsics/intrinsics.factor b/basis/math/vectors/simd/intrinsics/intrinsics.factor index 6f0bea3b98..ee15c8d997 100644 --- a/basis/math/vectors/simd/intrinsics/intrinsics.factor +++ b/basis/math/vectors/simd/intrinsics/intrinsics.factor @@ -3,7 +3,7 @@ USING: alien alien.c-types alien.data assocs combinators cpu.architecture compiler.cfg.comparisons fry generalizations kernel libc macros math -math.vectors.conversion math.vectors.conversion.private +math.vectors.conversion.backend sequences effects accessors namespaces lexer parser vocabs.parser words arrays math.vectors ; IN: math.vectors.simd.intrinsics diff --git a/basis/math/vectors/specialization/specialization.factor b/basis/math/vectors/specialization/specialization.factor index fd76b005c6..be959a2a2e 100644 --- a/basis/math/vectors/specialization/specialization.factor +++ b/basis/math/vectors/specialization/specialization.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: words kernel make sequences effects sets kernel.private accessors combinators math math.intervals math.vectors -math.vectors.conversion math.vectors.conversion.private +math.vectors.conversion.backend namespaces assocs fry splitting classes.algebra generalizations locals compiler.tree.propagation.info ; IN: math.vectors.specialization