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

vmjit: remove expression-related workaround #1262

Merged

Conversation

zerbina
Copy link
Collaborator

@zerbina zerbina commented Mar 30, 2024

Summary

Make the MIR tree produced for standalone expressions (e.g.,
initializer of a const) syntactically well-formed. Previously, these
trees contained a trailing MIR expression, which required various
workarounds in other places (all of which are now removed).

Details

  • add the exprToMir procedure to mirgen; it produces a proper MIR
    body for standalone expressions by assigning the expression to the
    result variable
    • the body is wrapped in a scope (mnkScope), which means passes can
      now rely on the presence of an outermost scope block
  • use exprToMir in vmjit for producing the MIR body for standalone
    expressions
  • remove the dedicated code generation for standalone expressions from
    vmgen (genExpr)
  • unify the expression/statement handling in vmjit
  • remove the workarounds for trailing expressions from cgirgen and
    mirpasses

To replicate the previous behaviour, where no copy of the value was
introduced for lvalue expressions, vmjit wraps standalone lvalue
expressions in an nkHiddenAddr, prior to passing the AST to
exprToMir.

zerbina added 4 commits March 30, 2024 18:47
It's meant solely for vmjit, which supports only expression being
supplied.
* use the new `exprToMir`
* consolidate handling for full expressions and statements
* remove the now obsolete `vmgen.genExpr`

This finally resolves MIR bodies resulting from `vmjit` expressions
being not well-formed syntactically.
It's obsolete now that `vmjit` produces proper MIR bodies.
@zerbina zerbina added refactor Implementation refactor compiler/backend Related to backend system of the compiler simplification Removal of the old, unused, unnecessary or un/under-specified language features. labels Mar 30, 2024
@zerbina zerbina added this to the MIR phase milestone Mar 30, 2024
@saem
Copy link
Collaborator

saem commented Mar 30, 2024

/merge

Copy link

Merge requested by: @saem

Contents after the first section break of the PR description has been removed and preserved below:


Notes for Reviewers

@chore-runner chore-runner bot enabled auto-merge March 30, 2024 19:39
@chore-runner chore-runner bot added this pull request to the merge queue Mar 30, 2024
Merged via the queue into nim-works:devel with commit d7426b7 Mar 30, 2024
31 checks passed
@zerbina zerbina deleted the vmjit-remove-expression-workarounds branch March 31, 2024 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/backend Related to backend system of the compiler refactor Implementation refactor simplification Removal of the old, unused, unnecessary or un/under-specified language features.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants