How hard would it be to create a new backend in D?

rempas rempas at tutanota.com
Sat Aug 6 04:41:24 UTC 2022


On Friday, 5 August 2022 at 22:09:44 UTC, user1234 wrote:
>
> I think you can try things without writing a backend. If I 
> believe the diagram of what currently works that seems possible 
> to use LDC to produce LLVM IR and then MIR in theory could use 
> that, ...

LLVM is the slow part of LDC (D's frontend is actually faster than
C's frontend for LLVM as LDC compiles cod faster than Clang) so
this will not help...

> but MIR does not produce native executables so why?

What do you mean with native? ELF (at least for Unix)? Mir has
its own format which is a binary format (including machine 
instructions).
It then uses its own linker so no problem! The format is also 
cross-platform
so in general there are no problems with its format. It also uses 
JIT
so it can probably do some more optimizations (or at least there 
is room
to make them, it don't know what happens in the moment). When it 
comes
to its runtime performance, there is a directory called 
"c-benchmarks"
where I have run the tests (compiling mir from the `bbv` branch) 
and
compared to `GCC -O2`, mir has about 83%-85% of its runtime 
performance
while compiling code about 4-5 times faster on average! If you 
wonder
why I care about compilation times so much, please check my other
reply in this thread.


More information about the Digitalmars-d mailing list