fix primitive emit fallback for simd intrinsics
							parent
							
								
									a3e4ecfc7d
								
							
						
					
					
						commit
						59d85f7ad6
					
				| 
						 | 
				
			
			@ -3,7 +3,7 @@ USING: accessors arrays assocs classes combinators
 | 
			
		|||
combinators.short-circuit compiler.cfg.builder.blocks
 | 
			
		||||
compiler.cfg.registers compiler.cfg.stacks
 | 
			
		||||
compiler.cfg.stacks.local compiler.tree.propagation.info
 | 
			
		||||
cpu.architecture effects fry generalizations help.lint.checks
 | 
			
		||||
cpu.architecture effects fry generalizations
 | 
			
		||||
kernel locals macros math namespaces quotations sequences
 | 
			
		||||
splitting stack-checker words ;
 | 
			
		||||
IN: compiler.cfg.intrinsics.simd.backend
 | 
			
		||||
| 
						 | 
				
			
			@ -145,6 +145,12 @@ CONSTANT: can-has-words
 | 
			
		|||
 | 
			
		||||
! Intrinsic code emission
 | 
			
		||||
 | 
			
		||||
MACRO: check-elements ( quots -- )
 | 
			
		||||
    [ length '[ _ firstn ] ]
 | 
			
		||||
    [ '[ _ spread ] ]
 | 
			
		||||
    [ length 1 - \ and <repetition> [ ] like ]
 | 
			
		||||
    tri 3append ;
 | 
			
		||||
 | 
			
		||||
MACRO: if-literals-match ( quots -- )
 | 
			
		||||
    [ length ] [ ] [ length ] tri
 | 
			
		||||
    ! n quots n
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
! (c)2009 Joe Groff bsd license
 | 
			
		||||
USING: arrays assocs biassocs byte-arrays byte-arrays.hex
 | 
			
		||||
classes compiler.cfg.comparisons compiler.cfg.instructions
 | 
			
		||||
classes compiler.cfg compiler.cfg.comparisons compiler.cfg.instructions
 | 
			
		||||
compiler.cfg.intrinsics.simd compiler.cfg.registers
 | 
			
		||||
compiler.cfg.stacks.local compiler.tree
 | 
			
		||||
compiler.tree.propagation.info cpu.architecture fry kernel
 | 
			
		||||
compiler.cfg.stacks.height compiler.cfg.stacks.local 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
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -34,8 +34,25 @@ IN: compiler.cfg.intrinsics.simd.tests
 | 
			
		|||
        } }
 | 
			
		||||
    } ;
 | 
			
		||||
 | 
			
		||||
: test-node-nonliteral-rep ( -- node )
 | 
			
		||||
    T{ #call
 | 
			
		||||
        { in-d  { 1 2 3 4 } }
 | 
			
		||||
        { out-d { 5 } }
 | 
			
		||||
        { info H{
 | 
			
		||||
            { 1 T{ value-info { class byte-array } } }
 | 
			
		||||
            { 2 T{ value-info { class byte-array } } }
 | 
			
		||||
            { 3 T{ value-info { class byte-array } } }
 | 
			
		||||
            { 4 T{ value-info { class object } } }
 | 
			
		||||
            { 5 T{ value-info { class byte-array } } }
 | 
			
		||||
        } }
 | 
			
		||||
    } ;
 | 
			
		||||
 | 
			
		||||
: test-compiler-env ( -- x )
 | 
			
		||||
    H{ } clone
 | 
			
		||||
        T{ basic-block { id 0 } }
 | 
			
		||||
            [ \ basic-block pick set-at ]
 | 
			
		||||
            [ 0 swap associate \ ds-heights pick set-at ]
 | 
			
		||||
            [ 0 swap associate \ rs-heights pick set-at ] tri
 | 
			
		||||
        T{ current-height { d 0 } { r 0 } { emit-d 0 } { emit-r 0 } } \ current-height pick set-at
 | 
			
		||||
        H{ } clone \ local-peek-set pick set-at
 | 
			
		||||
        H{ } clone \ replace-mapping pick set-at
 | 
			
		||||
| 
						 | 
				
			
			@ -61,6 +78,13 @@ IN: compiler.cfg.intrinsics.simd.tests
 | 
			
		|||
        ] with-variable
 | 
			
		||||
    ] make-classes ; inline
 | 
			
		||||
 | 
			
		||||
: test-emit-nonliteral-rep ( cpu quot -- node )
 | 
			
		||||
    [
 | 
			
		||||
        [ new \ cpu ] dip '[
 | 
			
		||||
            test-compiler-env [ test-node-nonliteral-rep @ ] bind
 | 
			
		||||
        ] with-variable
 | 
			
		||||
    ] make-classes ; inline
 | 
			
		||||
 | 
			
		||||
CONSTANT: signed-reps
 | 
			
		||||
    { char-16-rep short-8-rep int-4-rep longlong-2-rep float-4-rep double-2-rep }
 | 
			
		||||
CONSTANT: all-reps
 | 
			
		||||
| 
						 | 
				
			
			@ -504,5 +528,19 @@ unit-test
 | 
			
		|||
 | 
			
		||||
! select
 | 
			
		||||
[ { ##shuffle-vector-imm ##vector>scalar } ]
 | 
			
		||||
[ shuffle-imm-cpu int-4-rep [ emit-simd-select ] test-emit ]
 | 
			
		||||
[ shuffle-imm-cpu 1 int-4-rep [ emit-simd-select ] test-emit-literal ]
 | 
			
		||||
unit-test
 | 
			
		||||
 | 
			
		||||
! test with nonliteral/invalid reps
 | 
			
		||||
[ { ##inc-d ##branch } ]
 | 
			
		||||
[ simple-ops-cpu [ emit-simd-v+ ] test-emit-nonliteral-rep ]
 | 
			
		||||
unit-test
 | 
			
		||||
 | 
			
		||||
[ { ##branch } ]
 | 
			
		||||
[ simple-ops-cpu f [ emit-simd-v+ ] test-emit ]
 | 
			
		||||
unit-test
 | 
			
		||||
 | 
			
		||||
[ { ##branch } ]
 | 
			
		||||
[ simple-ops-cpu 3 [ emit-simd-v+ ] test-emit ]
 | 
			
		||||
unit-test
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue