USING: arrays assocs biassocs byte-arrays byte-arrays.hex
classes compiler.cfg compiler.cfg.comparisons compiler.cfg.instructions
compiler.cfg.intrinsics.simd compiler.cfg.intrinsics.simd.backend
-compiler.cfg.registers compiler.cfg.stacks.height
-compiler.cfg.stacks.local compiler.tree compiler.tree.propagation.info
+compiler.cfg.registers compiler.cfg.stacks.height compiler.cfg.stacks.local
+compiler.test compiler.tree compiler.tree.propagation.info
cpu.architecture fry hashtables kernel locals make namespaces sequences
system tools.test words ;
IN: compiler.cfg.intrinsics.simd.tests
[ shuffle-imm-cpu 1 float-4-rep [ emit-simd-select ] test-emit-literal ]
unit-test
+! ^load-neg-zero-vector
+{
+ V{
+ T{ ##load-reference
+ { dst 1 }
+ { obj B{ 0 0 0 128 0 0 0 128 0 0 0 128 0 0 0 128 } }
+ }
+ T{ ##load-reference
+ { dst 2 }
+ { obj B{ 0 0 0 0 0 0 0 128 0 0 0 0 0 0 0 128 } }
+ }
+ }
+} [
+ [
+ { float-4-rep double-2-rep } [ ^load-neg-zero-vector drop ] each
+ ] V{ } make
+] cfg-unit-test
+
+! ^load-add-sub-vector
+{
+ V{
+ T{ ##load-reference
+ { dst 1 }
+ { obj B{ 0 0 0 128 0 0 0 0 0 0 0 128 0 0 0 0 } }
+ }
+ T{ ##load-reference
+ { dst 2 }
+ { obj B{ 0 0 0 0 0 0 0 128 0 0 0 0 0 0 0 0 } }
+ }
+ T{ ##load-reference
+ { dst 3 }
+ { obj
+ B{ 255 0 255 0 255 0 255 0 255 0 255 0 255 0 255 0 }
+ }
+ }
+ T{ ##load-reference
+ { dst 4 }
+ { obj
+ B{ 255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0 }
+ }
+ }
+ T{ ##load-reference
+ { dst 5 }
+ { obj
+ B{ 255 255 255 255 0 0 0 0 255 255 255 255 0 0 0 0 }
+ }
+ }
+ T{ ##load-reference
+ { dst 6 }
+ { obj
+ B{ 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 }
+ }
+ }
+ }
+} [
+ [
+ {
+ float-4-rep
+ double-2-rep
+ char-16-rep
+ short-8-rep
+ int-4-rep
+ longlong-2-rep
+ } [ ^load-add-sub-vector drop ] each
+ ] V{ } make
+] cfg-unit-test
+
+! ^load-half-vector
+{
+ V{
+ T{ ##load-reference
+ { dst 1 }
+ { obj B{ 0 0 0 63 0 0 0 63 0 0 0 63 0 0 0 63 } }
+ }
+ T{ ##load-reference
+ { dst 2 }
+ { obj B{ 0 0 0 0 0 0 224 63 0 0 0 0 0 0 224 63 } }
+ }
+ }
+} [
+ [
+ { float-4-rep double-2-rep } [ ^load-half-vector drop ] each
+ ] V{ } make
+] cfg-unit-test
+
+! sign-bit-mask
+{
+ {
+ B{ 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 }
+ B{ 0 128 0 128 0 128 0 128 0 128 0 128 0 128 0 128 }
+ B{ 0 0 0 128 0 0 0 128 0 0 0 128 0 0 0 128 }
+ B{ 0 0 0 0 0 0 0 128 0 0 0 0 0 0 0 128 }
+ }
+} [
+ { char-16-rep short-8-rep int-4-rep longlong-2-rep } [ sign-bit-mask ] map
+] unit-test
+
+
! test with nonliteral/invalid reps
[ simple-ops-cpu [ emit-simd-v+ ] test-emit-nonliteral-rep ]
[ bad-simd-intrinsic? ] must-fail-with
! Copyright (C) 2009 Slava Pestov, Joe Groff.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien.c-types arrays byte-arrays combinators
+USING: accessors alien.c-types arrays assocs byte-arrays combinators
combinators.short-circuit compiler.cfg.comparisons
compiler.cfg.hats compiler.cfg.instructions
compiler.cfg.intrinsics compiler.cfg.intrinsics.alien
! compound vector ops
-: sign-bit-mask ( rep -- byte-array )
- signed-rep {
- { char-16-rep [ uchar-array{
+CONSTANT: rep>bit-mask {
+ {
+ char-16-rep uchar-array{
0x80 0x80 0x80 0x80
0x80 0x80 0x80 0x80
0x80 0x80 0x80 0x80
0x80 0x80 0x80 0x80
- } underlying>> ] }
- { short-8-rep [ ushort-array{
+ }
+ }
+ {
+ short-8-rep ushort-array{
0x8000 0x8000 0x8000 0x8000
0x8000 0x8000 0x8000 0x8000
- } underlying>> ] }
- { int-4-rep [ uint-array{
+ }
+ }
+ {
+ int-4-rep uint-array{
0x8000,0000 0x8000,0000
0x8000,0000 0x8000,0000
- } underlying>> ] }
- { longlong-2-rep [ ulonglong-array{
+ }
+ }
+ {
+ longlong-2-rep ulonglong-array{
0x8000,0000,0000,0000
0x8000,0000,0000,0000
- } underlying>> ] }
- } case ;
+ }
+ }
+}
+
+: sign-bit-mask ( rep -- byte-array )
+ signed-rep rep>bit-mask at underlying>> ;
+
+CONSTANT: rep>neg-zero {
+ { float-4-rep float-array{ -0.0 -0.0 -0.0 -0.0 } }
+ { double-2-rep double-array{ -0.0 -0.0 } }
+}
: ^load-neg-zero-vector ( rep -- dst )
- {
- { float-4-rep [ float-array{ -0.0 -0.0 -0.0 -0.0 } underlying>> ^^load-literal ] }
- { double-2-rep [ double-array{ -0.0 -0.0 } underlying>> ^^load-literal ] }
- } case ;
+ rep>neg-zero at underlying>> ^^load-literal ;
+
+CONSTANT: rep>add-sub {
+ { float-4-rep float-array{ -0.0 0.0 -0.0 0.0 } }
+ { double-2-rep double-array{ -0.0 0.0 } }
+ { char-16-rep char-array{ -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 } }
+ { short-8-rep short-array{ -1 0 -1 0 -1 0 -1 0 } }
+ { int-4-rep int-array{ -1 0 -1 0 } }
+ { longlong-2-rep longlong-array{ -1 0 } }
+}
: ^load-add-sub-vector ( rep -- dst )
- signed-rep {
- { float-4-rep [ float-array{ -0.0 0.0 -0.0 0.0 } underlying>> ^^load-literal ] }
- { double-2-rep [ double-array{ -0.0 0.0 } underlying>> ^^load-literal ] }
- { char-16-rep [ char-array{ -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 } underlying>> ^^load-literal ] }
- { short-8-rep [ short-array{ -1 0 -1 0 -1 0 -1 0 } underlying>> ^^load-literal ] }
- { int-4-rep [ int-array{ -1 0 -1 0 } underlying>> ^^load-literal ] }
- { longlong-2-rep [ longlong-array{ -1 0 } underlying>> ^^load-literal ] }
- } case ;
+ signed-rep rep>add-sub at underlying>> ^^load-literal ;
+
+CONSTANT: rep>half {
+ { float-4-rep float-array{ 0.5 0.5 0.5 0.5 } }
+ { double-2-rep double-array{ 0.5 0.5 } }
+}
: ^load-half-vector ( rep -- dst )
- {
- { float-4-rep [ float-array{ 0.5 0.5 0.5 0.5 } underlying>> ^^load-literal ] }
- { double-2-rep [ double-array{ 0.5 0.5 } underlying>> ^^load-literal ] }
- } case ;
+ rep>half at underlying>> ^^load-literal ;
: >variable-shuffle ( shuffle rep -- shuffle' )
rep-component-type heap-size