ARM first & default LDC

Walter Bright newshound2 at digitalmars.com
Thu Dec 31 01:11:10 UTC 2020


On 12/30/2020 7:00 AM, Max Haughton wrote:
> Re: cost of DMD backend for ARM, the existing backend is loaded with 
> implementation details from the pentium 5 and 6 (pro), and is generally not very 
> nice to read or write

The overall design of it is pretty simple. The complexity comes from the 
complexity of the instruction set. There's no way to wish that complexity away. 
You'll even see it in the inline assembler. I'm actually rather surprised that 
the initial design of it has proven effective for nearly 40 years despite vast 
changes in the Intel architecture.

The CPU architecture that didn't fit in too well with the code generator design 
was the wacky x87 FPU, which used a primitive stack architecture. I never did a 
good job with that, but the point is moot these days as the x87 is effectively dead.


> - it would probably be easier to do a basic retargetable 
> code generator from scratch

Everyone thinks that. But not a chance. The last 1% will take 500% of the time, 
and you'll be chasing bugs for years that the old one already solved.


> but keep the existing backend for x86 in the meantime.
> 
> For a material estimate of size, the cranelift backend rust has is about 87k 
> lines (inc. tests IIRC) so somewhere on that order (and we can generate huge 
> amounts of code for free because D) - I think the our backend is a bit bigger 
> than that.

The backend of DMD is 121,000 lines, but that includes the optimizer, symbolic 
debug info, exception handling table generation, a lot for various object file 
formats, etc., all of which is pretty generically written. The actual code gen 
is around 39,000 lines.


More information about the Digitalmars-d mailing list