-
Notifications
You must be signed in to change notification settings - Fork 9
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
Should there be a higher level API? #18
Draft
jumerckx
wants to merge
11
commits into
JuliaLabs:main
Choose a base branch
from
jumerckx:jm/higher-level
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-authored-by: jumerckx <[email protected]>
Co-authored-by: jumerckx <[email protected]>
* functions in Pass.jl have not yet been properly adapted. * I might've been a bit too enthousiastic with removing contexts: MModule and PassManager might still need to keep theirs. * The way code_mlir in brutus.jl now uses context might need a closer look.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Inspired by Beaver I've been thinking about the possiblity of a higher level API to write MLIR IR. At the lowest level, adding operations to a block could be achieved by using a similar mechanism as the context in thread local storage:
using
esc
in the macro would make sure that the created values are available outside the@Block
expression, enabling other blocks to reference those values as well.Things fall apart when introducing control flow.
cf.br
needs to be able to reference blocks that are yet to be created. I tried writing@Region
and@Block
which I believe is a dumbed-down version of how things work in Beaver (I don't really understand Elixir, code). This is the code in this PR but it isn't meant for merging, rather for showing what I tried and didn't work very well.Here,
@Block
pushes the code it encompasses on a stack and first creates all blocks. Only at the end is the actual code from within each block run. I got this working usingeval
which isn't good all variables are then visible in module scope.Also, even if this approach worked, I believe it's not entirely correct because blocks that are dominated by a block can access its values, this doesn't necessarily mean that those values are defined in order in code. e.g. if bb3 dominates bb2, bb2 can access it's values.
Lastly, block arguments aren't accounted for here but I imagine these could be added to the macro (
@Block arg::argtype begin
)At this point I think it might not be worth it to try writing an all-encompassing high-level API that is quickly becoming riddled by magic (which I've already been warned of by @maleadt, who mentors my master thesis). But maybe there is some middleground such as operation functions returning their value or perhaps even using the automatic pushing to the block on the thread-local stack?
Any feedback would be greatly appreciated!
Jules