-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved backend support #182
base: master
Are you sure you want to change the base?
Conversation
I think it's better to base the backends upon
That't the thing. The backends should not be based upon the |
This pull request allows for easier implementation of backends for thorin.
It builds upon the NeuralCoder3/thorin2/improved-backends branch that handles the underlying changes.
Ontop, we implement functional backends for OCaml and Haskell to showcase the backends.
Currently, some commits from higher-order codegen are merged into this branch.
Therefore, #181 should be merged first.
The CLI interface is adapted to accept the request for arbitrary backends (as opposed to hard-coded ones).
However, the LLVM backend is special-cased to allow backward compatibility with the
output-ll
notation.The new notation is to invoke
thorin --backend [backend-name] --output [stream]
.Example:
--backend ll --output Tmp.ll
--backend hs --output -
The backend names are specified by the entries in
backends
as registered inregister_backends
.This pull request eases the creation of new backends and helps with modularity.
Further applications would be:
Limitations
Currently, more complex programs do not work out of the box after translation.
This is not an inherent flaw of the backend but rather a carried-over issue from the printer in general.
The scoping issues (and partly also the precedence issues) carry over to the generated code.
Furthermore, not all code can be transpiled right now. For instance, dependent code segments and dialect-specific axioms are not handled in the functional backends.
The new Rust backend is more limited due to the syntactical differences between Thorin and Rust.
One problem is the concept of addressing arguments at tuple and individual levels leading to moves of non-copyable objects.
Possible improvements
The state as presented in this pull request is not optimal.
Possible improvements include: