<div class="gmail_quote">On 6 January 2012 12:16, a <span dir="ltr"><<a href="mailto:a@a.com">a@a.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">Walter Bright Wrote:<br>
<br>
> which provides two functions:<br>
><br>
>     __v128 simdop(operator, __v128 op1);<br>
>     __v128 simdop(operator, __v128 op1, __v128 op2);<br>
<br>
</div>You would also need functions that take an immediate too to support instructions such as shufps.<br>
<div class="im"><br>
> One caveat is it is typeless; a __v128 could be used as 4 packed ints or 2<br>
> packed doubles. One problem with making it typed is it'll add 10 more types to<br>
> the base compiler, instead of one. Maybe we should just bite the bullet and do<br>
> the types:<br>
><br>
>      __vdouble2<br>
>      __vfloat4<br>
>      __vlong2<br>
>      __vulong2<br>
>      __vint4<br>
>      __vuint4<br>
>      __vshort8<br>
>      __vushort8<br>
>      __vbyte16<br>
>      __vubyte16<br>
<br>
</div>I don't see it being typeless as a problem. The purpose of this is to expose hardware capabilities to D code and the vector registers are typeless, so why shouldn't vector type be "typeless" too? Types such as vfloat4 can be implemented in a library (which could also be made portable and have a nice API).<br>

</blockquote></div><br><div>Hooray! I think we're on exactly the same page. That's refreshing :)</div><div><br></div><div>I think this __simdop( op, v1, v2, etc ) api is a bit of a bad idea... there are too many permutations of arguments.</div>
<div>I know some PPC functions that receive FIVE arguments (2-3 regs, and 2-3 literals)..</div><div>Why not just expose the opcodes as intrinsic functions directly, for instance (maybe in std.simd.sse)?</div><div>__v128 __sse_mul_ss( __v128 v1, __v128 v2 );</div>
<div>__v128 __sse_mul_ps( __v128 v1, __v128 v2 );</div><div>__v128 __sse_madd_epi16( __v128 v1, __v128 v2, __v128 v3 ); // <- some have more args</div><div style="text-align:-webkit-auto"><span style="text-align:left">__v128 __sse_shuffle_ps(</span> __v128 v1, __v128 v2, immutable int i ); // <- some need literal ints</div>
<div>etc...<br><br></div><div>This works best for other architectures too I think, they expose their own set of intrinsics, and some have rather different parameter layouts.</div><div>VMX for instance (perhaps in std.simd.vmx?):</div>
<div>__v128 __vmx_vmsum4fp( __v128 v1, __v128 v2, __v128 v3 );</div><div>__v128 __vmx_vpermwi( __v128 v1, immutable int i ); // <-- needs a literal</div><div>__v128 __vmx_vrlimi( __v128 v1, __v128 v2, immutable int mask, immutable int rot ); // <-- you really don't want to add your enum style function for all these prototypes?</div>
<div>etc...</div><div><br></div><div>I have seen at least these argument lists:</div><div>( v1 )</div><div>( v1, v2 )</div><div>( v1, v2, v3 )</div><div>( v1, immutable int )</div><div>( v1, v2, immutable int )</div><div>
( v1, v2, 
immutable int, 
immutable int )</div>