<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 13 December 2013 06:08, H. S. Teoh <span dir="ltr"><<a href="mailto:hsteoh@quickfur.ath.cx" target="_blank">hsteoh@quickfur.ath.cx</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Thu, Dec 12, 2013 at 08:57:42PM +0100, Max Samukha wrote:<br>
> On Thursday, 12 December 2013 at 17:56:12 UTC, Walter Bright wrote:<br>
><br>
> >11. inline assembler being a part of the language rather than an<br>
> >extension that is in a markedly different format for every<br>
> >compiler<br>
><br>
> Ahem. If we admit that x86 is not the only ISA in exsistence, then<br>
> what is (under)specified here <a href="http://dlang.org/iasm.html" target="_blank">http://dlang.org/iasm.html</a> is a<br>
> platform-specific extension.<br>
<br>
</div></div>I've always wondered about that. What is D supposed to do with asm<br>
blocks when compiling for a CPU that *isn't* x86?? What *should* a<br>
conforming compiler do? Translate x86 asm into the target CPU's<br>
instructions?  Abort compilation? None of those options sound<br>
particularly appealing to me.<br></blockquote><div><br></div><div>It occurs to me that a little sugar would be nice, rather than:</div><div><br></div><div>version(x86)</div><div>{</div><div>  asm</div><div>  {</div><div>
    ...</div><div>  }</div><div>}</div><div>else version(ARM)</div><div>{</div><div>  asm</div><div>  {</div><div>    ...</div><div>  }</div><div>}</div><div><br></div><div>Which appears basically everywhere an asm block does. 'asm' could optionally receive an architecture as argument, and lower to the version wrapper:</div>
<div><br></div><div>asm(x86)</div><div>{</div><div>  ...</div><div>}</div><div>else asm(ARM)</div><div>{</div><div>  ...</div><div>}</div><div><br></div><div>(The 'else's in those examples seem unnecessary)</div></div>
</div></div>