Skip to content
This repository was archived by the owner on Jul 12, 2024. It is now read-only.

Flat codegen with infrastructure for adaptions. #11

Merged
merged 5 commits into from
Mar 11, 2024

Conversation

sjrd
Copy link
Collaborator

@sjrd sjrd commented Mar 7, 2024

Draft because based on #10, which should be merged before this one.

sjrd added 3 commits March 7, 2024 11:22
* Don't introduce RETURN; it is implicit for the whole expression.
* Don't flatten Blocks; they don't generate BLOCK's anymore so
  their codegen is already flat.
This will make it easier to insert adaptations afterward.

More importantly, it makes the codegen linear. When concatenating
lists it can quickly become exponential in the size of a method.
@sjrd sjrd force-pushed the flat-codegen-with-adapt branch from 1ccf6ff to 796ec22 Compare March 8, 2024 07:37
@sjrd sjrd marked this pull request as ready for review March 8, 2024 07:37
sjrd added 2 commits March 8, 2024 17:39
`genTree` now takes an `expectedType`. It computes what kind of
tree it actually generates. If the generated type is such that the
wasm type is not a subtype of the expected wasm type, `genAdapt`
makes the adaptation.

Currently, the only real adaptation that we need is from any type
to `NoType` (i.e., `void`). Indeed, in the IR type system, `void`
is a supertype of all types, but it is not the case in the wasm
type system.
It is a nullable reference of the `undef` struct.
Copy link
Owner

@tanishiking tanishiking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes much easier to comprehend the program! Thanks

}

private def transformAssign(t: IRTrees.Assign): List[WasmInstr] = {
val wasmRHS = transformTree(t.rhs)
private def genAdapt(generatedType: IRTypes.Type, expectedType: IRTypes.Type): Unit = {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@tanishiking tanishiking merged commit e198109 into tanishiking:main Mar 11, 2024
1 check passed
@sjrd sjrd deleted the flat-codegen-with-adapt branch March 11, 2024 07:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants