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
replaces implicit passes array registered at runtime with explicit function calls; simplify compilation pipeline #21444
Conversation
|
I have few questions. It seems that I need to duplicate lots of code to replace passes. Could I only make the pipeline explicit for C like backends and keep the rest under the umbrella of the passes? And are there other changes I should make to make the pipeline explicit? |
|
as far as I'm concerned, in an ideal world the c backend is something that would not be invoked at all until semantics and transformations have completed, more or less - ie we should not be calling the c backend at all until we know there's a sound nim ast - this way, we shield the semantic and transformation passes from what the C backend ultimately does - it would also mean splitting out any "useful" pre-c-generation work that the C backend does (ie calling transformations)... of course, there are degrees to this ideal and it's important that transformations don't lose significant optimization information that the backends can exploit, so there's a balance here.. Effectively, what we end up with is a "mid-level" IR comprising of a subset of the full AST, that still can be used for "nim-level" optimizations, ie where knowledge of nim semantics allows the implementation of useful code transformations - after that, the C pipeline takes or (or in the case of |
|
ah, which brings me to the other point: it would be nice at some point to be able to replace the VM with a different one - in This suggests that the pipeline might need some additional "plugin" points in the future, if this use case is to be covered - of course, this kind of stuff can also be maintained in an nlvm-specific fork of Nim. |
…to pr_passes_reword
| result = semWithPContext(PContext(context), n) | ||
|
|
||
| const semPass* = makePass(mySemOpen, mySemProcess, mySemClose, | ||
| isFrontend = true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this still required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not required. It is kept for tools like nimsuggest, drnim and nimfix and backward compatibilities. I have removed passes imports from other modules in the compiler. I can remove passes from nimsuggest and nimfix as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be done in a followup PR.
|
Thanks for your hard work on this PR! Hint: mm: orc; opt: speed; options: -d:release |
…tion calls; simplify compilation pipeline (nim-lang#21444) * abolish using passes in the compiler; simplify compilation pipeline * duplicate code * Really cool to have the same signature... * haul * unify other backends * refactor process * introduce PipelinePhase * refactor compiler * fixes passes * fixes nimsuggest * add a sentinel * enable docs checkj * activate doc testing * clean up * complete cleanups
…tion calls; simplify compilation pipeline (nim-lang#21444) * abolish using passes in the compiler; simplify compilation pipeline * duplicate code * Really cool to have the same signature... * haul * unify other backends * refactor process * introduce PipelinePhase * refactor compiler * fixes passes * fixes nimsuggest * add a sentinel * enable docs checkj * activate doc testing * clean up * complete cleanups
ref nim-lang/RFCs#503
follow up #21379
The processModule should handle all the logics by calling parser, sem, transf, codegen in order.
I'm keeping the passes interface for nimsuggest, nimfix and third-party library for backwards compatibilities.