Inter-compiler portability of asm between gdc and ldc2 (and dmd)

Cecil Ward cecil at cecilward.com
Wed Jul 15 12:59:00 UTC 2020


On Wednesday, 15 July 2020 at 00:26:13 UTC, Cecil Ward wrote:
> I have a fair amount of code written in D which uses GDC’s 
> syntax for inline asm and currently it is therefore GDC-only. 
> It would like people to be able to build it alternatively using 
> LDC as well, and maybe even DMD.
>
> It’s a shame about the huge syntactic differences between the 
> asm syntax of GDC and LDC; both have their merits, but GDC 
> seems to me to be the most powerful, although I don’t pretend 
> to have studied LDC’s approach just glanced at it once very 
> briefly.
>
> I wish that the two could converge on a syntax that has the 
> best features of each. Alternatively perhaps I should be 
> building something that writes out the correct source code 
> according to which compiler is being used. There are rather too 
> many ways of going about such a thing.
>
> Could anyone give me some advice about the pros and cons of the 
> various ways of dealing with this?
>
> Has anyone for example done something using templates or 
> mixin-ful goodness generating code on-the fly?
>
> Alternatively I could just give up and be forced to maintain 
> two parallel implementations of certain modules forever more, 
> provided there is zero runtime overhead, no cost in terms of 
> speed or bloat.

Sorry, I should have explained - I meant writing out D sourcecode 
on the fly with mixin or whatever it is - still getting my head 
around that wondrous technology. I can definitely see the day 
coming when I no longer miss #defines.

As for writing out machine code at runtime - now there’s another 
question of mine some day - for another thread, would be better.

—





More information about the Digitalmars-d mailing list