Skip to content
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

cbuilder: ccgexprs sweep part 1, basic if stmts #24381

Merged
merged 8 commits into from
Oct 31, 2024

Conversation

metagn
Copy link
Collaborator

@metagn metagn commented Oct 29, 2024

Most of what ccgexprs uses is now ported to cbuilder, so this PR makes around ~25% of ccgexprs use it, along with adding if stmts (no while/switch and for which is only used as for (tmp = a; tmp < b; tmp++)). The if builder does not add indents for blocks since we can't make Builder an object yet rather than an alias to string, this will likely be one of the last refactors.

Somewhat unrelated but ccgtypes is not ready yet because proc signatures are not implemented.

@Araq
Copy link
Member

Araq commented Oct 30, 2024

The code blow up is too much, use more helper procs please.

@metagn
Copy link
Collaborator Author

metagn commented Oct 31, 2024

The call & assignment builders have prebuilt argument versions now that are more readable but need more strings to be built, albeit not large ones. Some extra helpers are also added to deal with code duplication. Let me know if it's still not readable enough.

@Araq Araq merged commit 658c9da into nim-lang:devel Oct 31, 2024
19 checks passed
Copy link
Contributor

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from 658c9da

Hint: mm: orc; opt: speed; options: -d:release
176247 lines; 8.563s; 654.859MiB peakmem

Araq pushed a commit that referenced this pull request Nov 1, 2024
follows up #24381

This is about another 30% of ccgexprs (remaining is up to around line
3000), stopped right before the point where #24391 is required.

The `Genode::log` and `Genode::Cstring` calls in `genEcho` are left as
is but could be mangled in the future.
Araq pushed a commit that referenced this pull request Nov 3, 2024
Doing this early is useful so we can move the indentation logic into
`Builder` itself rather than mix it with the block logic in `ccgstmts`
(the `if` statements in #24381 have not been indented properly either).
However it also means `Builder` is now used for code that still
generates raw C code, so the diff won't be as clean when these get
updated.
metagn added a commit that referenced this pull request Nov 3, 2024
Finishes `genEnumInfo` as followup to #24351. As #24381 mentions this
covers every use of `for` loops in the codegen.

---------

Co-authored-by: Andreas Rumpf <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants