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

Iain Buclaw ibuclaw at gdcproject.org
Fri Jul 17 21:36:52 UTC 2020


On 17/07/2020 05:34, Cecil Ward via Digitalmars-d wrote:
> On Thursday, 16 July 2020 at 15:08:39 UTC, Iain Buclaw wrote:
>> I am open to improving the syntax if that helps with interoperability between GDC and LDC.
>>
>> https://issues.dlang.org/show_bug.cgi?id=20594
> 
> Some very interesting ideas brought up there, Iain. Good stuff. I would very much welcome some of those developments. Would it be possible to be possible to have multiple alternative syntaxes so we don’t have to deprecate anything just because of its age?
> 

Yes, if the proposed style is adopted, you can immediately tell which style you should be parsing as during or after the first parsed expression.

e.g:

  asm {
    insn: "foo";  // Seen a label -> consume insn string and parse rest as new style.
  }

  asm {
    "bar",        // Seen a comma (,) instead of a colon (:) after insn, parse rest as new style.
  }

I'm sure there's a few more things that need to be ironed out first though before I seriously consider any work on it.


> I must say I do like the power of the GCC/GDC asm binding interface / ‘glue’ system that connects the high level language to the asm. The notation is hard to understand in places though and your ideas provide a way to go even further and make big improvements in readability and learning curve. I keep having to reread the docs concerning returned / modified input registers and so on.
> 

It's a pretty brute tool.  I prefer to call it a glorified asm_printf(), where the onus is on you to tell the compiler what is happening, rather than the compiler trying to understand what you mean (which is what you get with DMD-style iasm).

> Idea. Perhaps someone could write an asm binding system notation -> english decoder, a tool that you could run to tell you what your asm binding interface definition is doing. Output in long-winded and explicit english and including things such as lists of possibilities for registers you are selecting or restricting an operand to bind to. I haven’t expressed myself very well here but I hope someone gets the drift.
> 
> Perhaps I should do binding definitions for every x86-64 instruction. That would keep me busy.

You mean, like in compiler-explorer?

https://explore.dgnu.org/z/LWqJdi

Hover over the asm instructions to see explanations.


More information about the Digitalmars-d mailing list