Skip to content

Split compiler into multiple passes #64

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

Merged
merged 61 commits into from
Jul 21, 2025
Merged

Split compiler into multiple passes #64

merged 61 commits into from
Jul 21, 2025

Conversation

SirLynix
Copy link
Contributor

@SirLynix SirLynix commented Jul 10, 2025

  • Split SanitizeVisitor into multiple passes
  • AST is no longer cloned everytime it's processed, instead it's transformed in place and cloned beforehand.
  • Access to a struct field is no longer expressed as an AccessIndexExpression but using the new AccessFieldExpression
  • Backend (writers) interface have been changed a lot

Copy link

codecov bot commented Jul 16, 2025

Codecov Report

Attention: Patch coverage is 77.14953% with 978 lines in your changes missing coverage. Please review.

Project coverage is 76.65%. Comparing base (d6aa156) to head (beff6f5).
Report is 61 commits behind head on main.

Files with missing lines Patch % Lines
...NZSL/Ast/Transformations/ValidationTransformer.cpp 67.43% 468 Missing ⚠️
src/NZSL/Ast/Transformations/Transformer.cpp 86.38% 70 Missing ⚠️
src/CNZSL/BackendParameters.cpp 0.00% 63 Missing ⚠️
src/NZSL/Ast/IndexRemapperVisitor.cpp 72.41% 56 Missing ⚠️
src/NZSL/SpirV/SpirvExpressionLoad.cpp 57.00% 46 Missing ⚠️
...Transformations/ConstantPropagationTransformer.cpp 68.54% 39 Missing ⚠️
src/NZSL/Ast/Utils.cpp 71.02% 31 Missing ⚠️
...Ast/Transformations/EliminateUnusedTransformer.cpp 82.65% 17 Missing ⚠️
...Ast/Transformations/ConstantRemovalTransformer.cpp 80.51% 15 Missing ⚠️
...st/Transformations/StructAssignmentTransformer.cpp 87.90% 15 Missing ⚠️
... and 33 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #64      +/-   ##
==========================================
- Coverage   77.11%   76.65%   -0.47%     
==========================================
  Files         159      185      +26     
  Lines       21656    23343    +1687     
  Branches     6456     7041     +585     
==========================================
+ Hits        16701    17894    +1193     
- Misses       4853     5351     +498     
+ Partials      102       98       -4     
Files with missing lines Coverage Δ
include/NZSL/Ast/AstSerializer.hpp 100.00% <ø> (ø)
include/NZSL/Ast/Cloner.hpp 100.00% <ø> (ø)
include/NZSL/Ast/Cloner.inl 100.00% <100.00%> (ø)
include/NZSL/Ast/ConstantValue.inl 93.33% <ø> (-3.22%) ⬇️
include/NZSL/Ast/ExpressionType.hpp 95.83% <ø> (+4.16%) ⬆️
include/NZSL/Ast/ExpressionValue.hpp 100.00% <ø> (ø)
include/NZSL/Ast/IndexRemapperVisitor.hpp 100.00% <ø> (ø)
include/NZSL/Ast/IndexRemapperVisitor.inl 100.00% <100.00%> (ø)
include/NZSL/Ast/NodeList.hpp 91.11% <100.00%> (+0.20%) ⬆️
include/NZSL/Ast/Nodes.hpp 45.45% <ø> (ø)
... and 99 more

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d6aa156...beff6f5. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@SirLynix SirLynix marked this pull request as ready for review July 16, 2025 17:09
SirLynix added 27 commits July 17, 2025 10:51
this is to get a better view of the work remaining
This is already handled in a better way by the SpirvAstVisitor
…s in assignment

When using partial compilation, struct member indices may become unknown and should be resolved later. When this happens AccessMemberExpression will be generated instead of AccessFieldExpression

Maybe member indices should be kept and take disabled/unknown field into account?
Structs field now have their own dedicated node: AccessField
Handling module import when indices can't be resolved caused (probably) unsolvable issues when a compiled modules was imported into another one

All code generation test passes
…on structs

Previous compiled NZSL AST would use AccessIndex instead of AccessField for structs
Improves performance also for BindingResolverTransformer as it doesn't need to visit function content
SirLynix added 17 commits July 17, 2025 17:51
It could be out of bounds (due to same-type constraint)
It could be triggered even in a partial compilation
If fromExpr is replaced by another expression (by the ComputeConstantValue call), fromExprType is no longer valid
it breaks variable declaration inside branches, such as
```
const if (HasNormal) let normal: vec3[f32];
```
…ntQueryCallback isn't set or doesn't find constant
@SirLynix SirLynix merged commit c1bcaa9 into main Jul 21, 2025
92 checks passed
@SirLynix SirLynix deleted the multipass branch July 21, 2025 16:55
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.

1 participant