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

Vars #269

Merged
merged 58 commits into from
Apr 3, 2024
Merged

Vars #269

merged 58 commits into from
Apr 3, 2024

Conversation

leissa
Copy link
Member

@leissa leissa commented Mar 17, 2024

This is sth I wanted to do for years, but I never really figured out how to do that exactly:
I want to get rid of thorin::Scope and, instead, work with free Vars. This is a major milestone with the new subsystem working but the old stuff is still in place - although I've already ported some of it. So, expect more PRs to come.

  • Def::local_muts()/Def::local_vars() are Vars/mutables reachable by following immutable Def::extended_ops().
  • Def::local_muts()/Def::local_vars() are cached and hash-consed.
  • Def::free_vars() compute a global solution, i.e., by transitively following mutables as well.
  • Def::free_vars() are computed on demand and cached.
    They will be transitively invalidated by following fv_consumers(), if a mutable is mutated.
  • Def::is_closed()/Def::is_open() to check whether a Def contains free vars.

Change log

  • removed ScopeRewriter in favor of new free_var-based VarRewriter
  • simplifed rewrite interface
  • PooledSet and Pool to hash-cons and arena-allocate sets
  • sanity check whether externals are closed
  • fixed issue in cps2ds.cpp but one issue remains (cps2ds sometimes introduces ownerless Vars #271)
  • minor bug fixes/additions here & there

Future directions

  • lazy rewrite/substitution (only substitute one mutable and a time and continue substituting as needed to prevent quadratic runtime when resolving curried beta-reduction etc)
  • completely remove thorin::Scope
  • new textual outputs
    • a simple output that dumps everything up to mutables
    • a proper "decompilation" of the thorin Graph into a thorin AST

@leissa leissa marked this pull request as ready for review March 20, 2024 18:42
@leissa
Copy link
Member Author

leissa commented Apr 2, 2024

@fodinabor, @NeuralCoder3 bump

lit/direct/ad_mem.thorin.disabled2 Outdated Show resolved Hide resolved
include/thorin/util/pool.h Outdated Show resolved Hide resolved
src/thorin/def.cpp Outdated Show resolved Hide resolved
src/thorin/fe/lexer.cpp Outdated Show resolved Hide resolved
src/thorin/pass/pass.cpp Show resolved Hide resolved
src/thorin/plug/direct/pass/cps2ds.cpp Show resolved Hide resolved
* also give Def::stub the same treatement as Def::rebuild
@leissa leissa merged commit b301731 into master Apr 3, 2024
12 checks passed
@leissa leissa deleted the vars branch April 3, 2024 12:42
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