Inter-compiler portability of asm between gdc and ldc2 (and dmd)
kinke
noone at nowhere.com
Sat Oct 3 13:27:23 UTC 2020
On Saturday, 3 October 2020 at 08:51:58 UTC, Paulo Pinto wrote:
> On Friday, 2 October 2020 at 22:01:53 UTC, Walter Bright wrote:
>> On 7/14/2020 5:26 PM, 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.
>>
>> DMD's inline assembler syntax is what is used in Intel's CPU
>> manuals. I sometimes wonder why other compilers don't do the
>> same. It can be a bit wacky, but it's not that much code to
>> implement and it makes following the code along with the
>> manuals much easier.
>
> It is also what I favour, the excuse those other compilers
> vendor give is that the clunky syntax they use is easier to
> integrate with the compiler backend for the optimiser's
> understanding of what is going on.
>
> Having studied compiler design as part of my major subjects, I
> say that the inline Assembly parser could build that
> information just as easily.
Yeah sure. See
https://github.com/ldc-developers/ldc/blob/master/gen/asm-x86.h
for an incomplete x86 implementation. And now imagine something
like this for every ISA supported by GCC and LLVM, and keeping it
up-to-date. - The whole point of the GCC/GDC-style assembly is
genericity - an instructions template provided by the user as a
string to be forwarded to the assembler (opaque for the
optimizer), and outputs/inputs/clobbers provided separately
because that's the only thing the pre-assembler stages need to
know.
Considering inline asm is mostly used as a last resort for some
very low-level stuff, extending the front-end by a full-blown
parser for every ISA would be an absolutely improportionate
effort.
More information about the Digitalmars-d
mailing list