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

New IR #20

Draft
wants to merge 54 commits into
base: main
Choose a base branch
from
Draft

New IR #20

wants to merge 54 commits into from

Conversation

Jakobeha
Copy link
Contributor

@Jakobeha Jakobeha commented Aug 8, 2024

No description provided.

probably still no optimizations
- Improve type system; add reference counting.
- Add `ConsumesNonEnvArg` effect for type system (TODO: know specifically what argument(s) it consumes, also probably move out of effects).
- Scope resolution progress.
- Make `InstrData` take `@Nullable` instead of `Optional` except in collections.
- Add built-in parsing and printing support for maps and improve it for collections.
Now I have to copy over the generic `StaticAnalysis` class.

Hopefully we can improve the IR so it's more understandable and has less special cases.
also remove `LdEnclosEnv` because we can just reference the enclosing env, and make `MaterializeEnv` not return anything because it seems it doesn't need to, so we can remove aliases from `AbstractEnv`. I'm looking if there are other places we can remove complexity.
implement copying abstract values and logging, fix copying in `ScopeAnalysisState`.
- rework parsing and printing code objects
- start adding parameter nodes
- Added general Java types
- Clarified some things
In draft, and start rewriting. Currently rewrote node identifiers, every global node, and every local node except phis and instruction outputs.
TODO `BBCompoundMutate`, `CFGCursor`, `CFGParsePrint`, and a lot more

Also, will probably get rid of `CFGPirSerialize`, because our IR is a lot different than PIR, so it's becoming cruft. We do need a lot more tests though, especially for the record/replay/rewind that `CFGParsePrint` handled.
`InstrData#fun`, `InstrData#inputs`, `InstrData#setInputs`, and `InstrData#checkInputNodeTypes`

Also some refactoring
Try to refactor out `UNBOUND` because it makes the types much harder, and I think we can just represent it using `@Nullable SEXP`/`null` or `Optional<SEXP>`/`Optional.empty()` in the places it can exist.

One issue is that we sometimes add unbound bindings to environments. However, it looks like `Rf_findVar` skips over unbound, so they would be equivalent to unset. I'm going to try removing them, and if tests fail, I'll re-add them and change the environment's `bindings` from `HashMap<String, SEXP>` to `HashMap<String, Optional<SEXP>>`.
- Don't prefix constants with `\`
- Escape symbols with `'`
- Put `NULL`, `TRUE`, `FALSE`, and `NA`s in `<` and `>`, so we don't parse Java identifiers as SEXPs
- Fix some undiscovered parsing and printing bugs
I probably have to rewrite most of this, too many casts and too much boilerplate...
Well, `org.prlprg.ir.type.sexp` compiles...
`RType` = enhanced, fine-grained `Class` (added documentation on the "fine-grained" part).

Also refactored and fixed `InstrData`, need to do finish `StmtData` and `JumpData` but we really need an idea of how this IR works before then.

I'm probably now going to work on getting this into a merge-able state, even disabling the IR tests and commenting unfinished code.
Some of the tests for non-IR parts of the compiler don't pass, but I have to investigate, because it's the compiler inlining things that GNU-R doesn't.

The IR is very unfinished, I had to disable the tests becase they wouldn't complete. `LatticeTests` also don't work, though they fail fast on relations that aren't yet fully implemented.
For seven functions:
- xor (base)
- isTRUE (base)
- append (base)
- mode (base)
- anyDots (compiler)
- missingArgs (compiler)
- patchLabels (compiler)

With both the potential annotations, and notes when I was manually reasoning about the optimizations.
they weren't actually tracked...
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