From 48d3f10c81c3da327ff96aedbeb7b567bfc4f993 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 28 Sep 2009 16:33:39 -0500 Subject: [PATCH 1/3] Fix some load errors in various places --- basis/math/vectors/simd/simd.factor | 3 ++- basis/sequences/complex/complex-tests.factor | 3 ++- extra/benchmark/raytracer-simd/raytracer-simd.factor | 3 ++- extra/benchmark/simd-1/simd-1.factor | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/basis/math/vectors/simd/simd.factor b/basis/math/vectors/simd/simd.factor index e7d4f0e94b..230f43029a 100644 --- a/basis/math/vectors/simd/simd.factor +++ b/basis/math/vectors/simd/simd.factor @@ -20,8 +20,9 @@ ERROR: bad-base-type type ; PRIVATE> : define-simd-vocab ( type -- vocab ) + parse-base-type [ simd-vocab ] keep '[ - _ parse-base-type + _ [ define-simd-128 ] [ define-simd-256 ] bi ] generate-vocab ; diff --git a/basis/sequences/complex/complex-tests.factor b/basis/sequences/complex/complex-tests.factor index 04a80c6bee..0cb0b41a78 100644 --- a/basis/sequences/complex/complex-tests.factor +++ b/basis/sequences/complex/complex-tests.factor @@ -1,6 +1,7 @@ USING: specialized-arrays sequences.complex kernel sequences tools.test arrays accessors ; -SPECIALIZED-ARRAY: float +QUALIFIED-WITH: alien.c-types c +SPECIALIZED-ARRAY: c:float IN: sequences.complex.tests : test-array ( -- x ) diff --git a/extra/benchmark/raytracer-simd/raytracer-simd.factor b/extra/benchmark/raytracer-simd/raytracer-simd.factor index ff3a2bac3e..5a3c232b5a 100644 --- a/extra/benchmark/raytracer-simd/raytracer-simd.factor +++ b/extra/benchmark/raytracer-simd/raytracer-simd.factor @@ -5,7 +5,8 @@ USING: arrays accessors io io.files io.files.temp io.encodings.binary kernel math math.constants math.functions math.vectors math.vectors.simd math.parser make sequences sequences.private words hints classes.struct ; -SIMD: double +QUALIFIED-WITH: alien.c-types c +SIMD: c:double IN: benchmark.raytracer-simd ! parameters diff --git a/extra/benchmark/simd-1/simd-1.factor b/extra/benchmark/simd-1/simd-1.factor index f3ba5eb86e..4b3c4a5b9f 100644 --- a/extra/benchmark/simd-1/simd-1.factor +++ b/extra/benchmark/simd-1/simd-1.factor @@ -2,7 +2,8 @@ ! See http://factorcode.org/license.txt for BSD license. USING: kernel io math math.functions math.parser math.vectors math.vectors.simd sequences specialized-arrays ; -SIMD: float +QUALIFIED-WITH: alien.c-types c +SIMD: c:float SPECIALIZED-ARRAY: float-4 IN: benchmark.simd-1 From 420221129392e3c71790443a443af2dd4a89265e Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 28 Sep 2009 16:38:35 -0500 Subject: [PATCH 2/3] cpu.x86: cleanups --- basis/cpu/x86/assembler/assembler.factor | 4 +++ basis/cpu/x86/x86.factor | 31 ++++++++++-------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/basis/cpu/x86/assembler/assembler.factor b/basis/cpu/x86/assembler/assembler.factor index c097fe2b4d..57738ce4ba 100644 --- a/basis/cpu/x86/assembler/assembler.factor +++ b/basis/cpu/x86/assembler/assembler.factor @@ -618,11 +618,15 @@ ALIAS: PINSRQ PINSRD : MOVDQA ( dest src -- ) { HEX: 6f HEX: 7f } HEX: 66 2-operand-rm-mr-sse ; : MOVDQU ( dest src -- ) { HEX: 6f HEX: 7f } HEX: f3 2-operand-rm-mr-sse ; + + : PSHUFD ( dest src imm -- ) 4shuffler HEX: 70 HEX: 66 3-operand-rm-sse ; : PSHUFLW ( dest src imm -- ) 4shuffler HEX: 70 HEX: f2 3-operand-rm-sse ; : PSHUFHW ( dest src imm -- ) 4shuffler HEX: 70 HEX: f3 3-operand-rm-sse ; diff --git a/basis/cpu/x86/x86.factor b/basis/cpu/x86/x86.factor index 4540db1053..857e1ede6b 100644 --- a/basis/cpu/x86/x86.factor +++ b/basis/cpu/x86/x86.factor @@ -579,12 +579,12 @@ MACRO: available-reps ( alist -- ) '[ _ cond ] ; : unsign-rep ( rep -- rep' ) - dup { + { { uint-4-rep int-4-rep } { ulonglong-2-rep longlong-2-rep } { ushort-8-rep short-8-rep } { uchar-16-rep char-16-rep } - } at* [ nip ] [ drop ] if ; + } ?at drop ; M:: x86 %broadcast-vector ( dst src rep -- ) rep unsign-rep { @@ -592,22 +592,23 @@ M:: x86 %broadcast-vector ( dst src rep -- ) dst src float-4-rep %copy dst dst { 0 0 0 0 } SHUFPS ] } - { double-2-rep [ + { double-2-rep [ dst src MOVDDUP ] } { longlong-2-rep [ - dst src = [ - dst dst PUNPCKLQDQ - ] [ - dst src { 0 1 0 1 } PSHUFD - ] if + dst src = + [ dst dst PUNPCKLQDQ ] + [ dst src { 0 1 0 1 } PSHUFD ] + if ] } - { int-4-rep [ dst src { 0 0 0 0 } PSHUFD ] } - { short-8-rep [ + { int-4-rep [ + dst src { 0 0 0 0 } PSHUFD + ] } + { short-8-rep [ dst src { 0 0 0 0 } PSHUFLW dst dst PUNPCKLQDQ ] } - { char-16-rep [ + { char-16-rep [ dst src char-16-rep %copy dst dst PUNPCKLBW dst dst { 0 0 0 0 } PSHUFLW @@ -619,13 +620,7 @@ M: x86 %broadcast-vector-reps { ! Can't do this with sse1 since it will want to unbox ! a double-precision float and convert to single precision - { sse2? { - float-4-rep double-2-rep - longlong-2-rep ulonglong-2-rep - int-4-rep uint-4-rep - short-8-rep ushort-8-rep - char-16-rep uchar-16-rep - } } + { sse2? { float-4-rep double-2-rep longlong-2-rep ulonglong-2-rep int-4-rep uint-4-rep short-8-rep ushort-8-rep char-16-rep uchar-16-rep } } } available-reps ; M:: x86 %gather-vector-4 ( dst src1 src2 src3 src4 rep -- ) From e1a9b2556200d08707b6c8d24a06915bcb6e4668 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 28 Sep 2009 16:40:52 -0500 Subject: [PATCH 3/3] cpu.ppc: update for %unary/binary-float-function change --- basis/cpu/ppc/ppc.factor | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/basis/cpu/ppc/ppc.factor b/basis/cpu/ppc/ppc.factor index 670a9fd69e..d5ee166486 100644 --- a/basis/cpu/ppc/ppc.factor +++ b/basis/cpu/ppc/ppc.factor @@ -235,8 +235,13 @@ M:: ppc %box-float ( dst src temp -- ) dst 16 float temp %allot src dst float-offset STFD ; -: float-function-param ( i spill-slot -- ) - [ float-regs param-regs nth 1 ] [ n>> spill@ ] bi* LFD ; +GENERIC: float-function-param* ( dst src -- ) + +M: spill-slot float-function-param* [ 1 ] dip n>> spill@ LFD ; +M: integer float-function-param* FMR ; + +: float-function-param ( i src -- ) + [ float-regs param-regs nth ] dip float-function-param* ; : float-function-return ( reg -- ) float-regs return-reg double-rep %copy ;