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

Basic-blocks-based intermediate language and flow analysis. #607

Merged
merged 21 commits into from
Jul 8, 2024

Conversation

gabrielsferre
Copy link
Contributor

Changing the previous intermediate language, which was a tree, to a new one made out of a graph of basic blocks. This change is being made so it's easier to implement future optimizations for the generated code using standard flow analysis techniques. Here, we're already using flow analysis on the blocks to identify uninitialized variables.

src/pallene/coder.lua Outdated Show resolved Hide resolved
src/pallene/ir.lua Outdated Show resolved Hide resolved

-- Transform parent node
return f(cmd) or cmd
function ir.flatten_cmd(block_list)
Copy link
Member

Choose a reason for hiding this comment

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

I'm looking forward to deleting this flatten_cmd funciton. If I remember correctly, it only exists because of how we implement gc.lua: it uses the commands themselves as keys in the table.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It can be removed now. I don't think the gc needs it, it uses the Cmd object itself as the table's key, not the index on flatten_cmd.

Copy link
Member

Choose a reason for hiding this comment

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

I am also looking forward to getting rid of commands as table keys :) see #575

In a basic block world, the GC analysis should work with basic blocks indices aa the key.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm working on changing the gc to use flow analysis. Should we wait to make this change of "get rid of cmds as keys" for another PR?

Copy link
Member

Choose a reason for hiding this comment

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

It's ok to leave it for next PR (but in that case, please open an issue so we do not forget)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

src/pallene/coder.lua Outdated Show resolved Hide resolved
src/pallene/coder.lua Outdated Show resolved Hide resolved
src/pallene/ir.lua Show resolved Hide resolved
src/pallene/to_ir.lua Outdated Show resolved Hide resolved
src/pallene/uninitialized.lua Outdated Show resolved Hide resolved
src/pallene/uninitialized.lua Outdated Show resolved Hide resolved
src/pallene/uninitialized.lua Show resolved Hide resolved
Copy link
Member

@hugomg hugomg left a comment

Choose a reason for hiding this comment

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

One last thing...

src/pallene/coder.lua Show resolved Hide resolved
@hugomg hugomg merged commit 89851b6 into master Jul 8, 2024
2 checks passed
@hugomg hugomg deleted the tcc-gabrielsferreira branch July 8, 2024 20:08
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