How hard would it be to create a new backend in D?
Walter Bright
newshound2 at digitalmars.com
Sun Aug 7 10:09:07 UTC 2022
On 8/6/2022 11:02 AM, welkam wrote:
> On Saturday, 6 August 2022 at 07:39:36 UTC, Walter Bright wrote:
>>
>> The dmd backend is already in D :-)
>>
>> But since it's all Boost Licensed, anyone can use 0..100% of it for their own
>> backend project. No asking is required.
>>
>> Have fun!
>
> But where is inliner located?
DMD has two inliners, a front end one and a back end one. Here's the back end one:
https://github.com/dlang/dmd/blob/master/compiler/src/dmd/backend/inliner.d
> I read that several other languages (Jai, Zig) are
> trying to make their own x86_64 backends because GCC and LLVM are too slow. If
> DMD backend had its IR well documented and inliner implemented not in the
> frontend I could see a future where it could be used by other languages.
The IR is very simple:
https://github.com/dlang/dmd/blob/master/compiler/src/dmd/backend/el.d#L70
It's a binary tree. Not clever at all. It's about 50 lines of declaration.
Too see it in action, use the --b --f switches:
./dmd test.d -c --b --f
which will pretty print the IR before and after optimization. There are some
other switches, like --r which will show the register allocator at work.
More information about the Digitalmars-d
mailing list