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

Cecil Ward cecil at cecilward.com
Wed Jul 15 00:26:13 UTC 2020


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.


More information about the Digitalmars-d mailing list