ARM first & default LDC
Max Haughton
maxhaton at gmail.com
Thu Dec 17 22:07:19 UTC 2020
On Thursday, 17 December 2020 at 16:02:05 UTC, Guillaume Piolat
wrote:
> On Thursday, 17 December 2020 at 10:02:56 UTC, claptrap wrote:
>>
>> And yet why does DMD suck at optimising code? Because a
>> freedom to do something that nobody has the resources to do is
>> next to useless.
>
> DMD builds fast, and is small, it has some value and it would
> be more used if you could somehow rely on code generation. (for
> example, raylib ships with a tinycc compiler for speed of
> compile-run loop)
>
> However I think an ARM backend may be just too much debt when
> we don't have a reliable x86 backend in DMD. And I don't know
> why it's the case, it has been a constant over years.
>
> (for info: the particular issue that irks me is
> https://issues.dlang.org/show_bug.cgi?id=21474)
>
> I'd be really wary to release something built with DMD and
> optimizations on.
> This is not _only_ about speed imho.
If we really wanted an ARM backend in DMD it would probably be
simpler to just build one from scratch. The basic optimizations
needed to get vaguely acceptable performance for a fast/test
build aren't all that complicated, especially if you build SSA
(massively simplfies quite a few optimizations). It's still a big
job, but it would also probably be useful to speed up CTFE as
well (having a clean and reusable IR -> JIT).
The current backend is fairly unwieldy, true, but it's also very
old and could be a lot smaller now we have things like ranges (or
even templates) - as with many things in the compiler it
doesn't/can't use modern D for various reasons.
For an empirical guess of how big a backend would be - cranelift
is a modern (not just SSA) backend aimed at build times rather
than runtime efficiency, and it clocks in (cranelift/codegen) at
roughly 90k lines (the whole project warts and all is 130k). The
current dmd backend is 97k. We could be significantly more
concise because we have better metaprogramming - i.e. LLVM has a
huge amount of boilerplate and DSLs that could be done fairly
easily either as metaprogamming or mixin DSLs.
Is it worth it? No idea, but it isn't a totally unrealistic
proposition (More realistically would be a dub project being
merged in, I have a few rubbish backend projects on various
computers of mine but none are remotely worth publishing).
More information about the Digitalmars-d
mailing list