How hard would it be to create a new backend in D?
rempas
rempas at tutanota.com
Sat Aug 6 08:04:37 UTC 2022
On Saturday, 6 August 2022 at 07:10:43 UTC, user1234 wrote:
>
> I suggested to experiment MIR like that, it was not a proposal
> on the final design.
> Experimenting using LLVM IR could be useful to determine if
> working seriously on the project is worth.
>
> Anyway if you want to put your hand in the hard stuff from the
> start I think you have two options.
>
> 1. Create an AST visitor that generate MIR format after DMDFE
> semantics
> 2. Create the MIR representation after the part of the backend
> that generate DMD IR (s2ir, e2ir, etc.) has run.
>
> The second option might be easier because the production will
> most of the time map 1:1 to a MIR equivalent.
>
> The first option is IMO would be harder because of forward
> references and imports. and even without that, that would
> require to split visiting in several passes (decls, aggregate
> members, function headers, function bodies)
>
Thank you for the info! The thing is (and why I make the question
originally)
how do I find info about how to get started? I don't even know
how DMD
works and how it's IR works. Does DMD's frontend parses the text
and then
outputs something like LLVM-IR (but for DMD) which we can take
and then
translate it to the final backend that we need (in our case mir)
or something
else? That's what I want to know. So yeah, is there a legit
documentation or
something or do backend developers have to guess how things work
and do
"hacking"?
> About the "how hard" I think that compiler programming is not
> hard but that takes time. I estimate that this could take you
> from 1 month to 3 months to finish however you 'd get results
> much earlier, e.g if you handle just a few constructs.
That's actually pretty nice! I don't mind about putting the work
but I
mind the work to be strain-forward and make sense. I would expect
to
see actual documentation and info about how things work in
detail. If
not, then I would probably spend the time to design and implement
my
own language.
More information about the Digitalmars-d
mailing list