<div dir="ltr">On 27 May 2013 19:01, Iain Buclaw <span dir="ltr"><<a href="mailto:ibuclaw@ubuntu.com" target="_blank">ibuclaw@ubuntu.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 27 May 2013 09:21, Manu <<a href="mailto:turkeyman@gmail.com">turkeyman@gmail.com</a>> wrote:<br>
> Actually, I think the C counterpart is actually<br>
> __attribute__((__target__("targetstring"))), with bonus underscores ;)<br>
><br>
><br>
> On 27 May 2013 18:15, Manu <<a href="mailto:turkeyman@gmail.com">turkeyman@gmail.com</a>> wrote:<br>
>><br>
>> So we talked about this at DConf.<br>
>><br>
>> Working on std.simd, I need to be able to change the target parameter on a<br>
>> per-function basis.<br>
>> GCC supports this via: __attribute__((target("sse2"))) for instance.<br>
>><br>
>> I need the ability to set this from D, but the trick is, I need to be able<br>
>> to set the target string according to a template arg.<br>
>><br>
>> Eg:<br>
>>   enum Targets { SSE2, SSE3 };<br>
>>   enum targets[] = [ "sse2", "sse3" ];<br>
>><br>
>>   @attribute("target", targets[T]) // <- attribute needs to refer to the<br>
>> template arg T<br>
>>   void func(Targets T)();<br>
>><br>
>><br>
<br>
</div>I'll turn on rudimentary support, as the backend takes care of pretty<br>
much all the work.  But I think this should work as UDAs work off CTFE<br>
with string manipulation.<br>
<div class="im"><br>
<br>
>>   {<br>
>>     // this way, it is possibly to produce dynamic selection of code paths<br>
>> optimised for different CPU features (a task which is usually very tedious<br>
>> in C/C++)<br>
>>     func!(Targets.SSE2)();<br>
>>   }<br>
>><br>
><br>
<br>
</div>As a small experiment, I could turn on versioning for these<br>
functions...  However is only available for x86 targets.<br>
<br>
eg:<br>
<br>
void foo() @target("sse")    // mangled 'foo.sse'<br>
{<br>
}<br>
<br>
void foo() @target("mmx")   // mangled 'foo.mmx'<br>
{<br>
}<br></blockquote><div><br></div><div style>I'm confused, are you suggesting to handle these particular values explicitly in gdc?</div><div style>I was giving examples of the code I want to write (and work). I can handle this in std.simd.</div>
<div style>I don't think there's any reason to handle arch-specific cases like that in gdc.</div><div style><br></div><div style>Or rather, was the point you were trying to make here the possible support of a @target() attribute (which affects the mangling), rather than @attribute("target")?</div>
</div></div></div>