-
Notifications
You must be signed in to change notification settings - Fork 85
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
[CIR][Lowering] Add scf.scope lowering to standard dialects #262
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace "[MLIR]" in the title with "[Lowering]". Thanks.
|
||
for (auto &block : scopeOp.getRegion()) { | ||
rewriter.setInsertionPointToEnd(&block); | ||
auto yield = cast<mlir::cir::YieldOp>(block.getTerminator()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does every block in the scope have a yield? I recall that some blocks can have a return op. @bcardosolopes can you please confirm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, possible terminators are YieldOp, ReturnOp, ThrowOp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. The doc seems to be a little outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created #265 to track this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requesting changes based on @htyu comments.
I'm ok with this direction, but if you're willing to go an extra mile, the ProperWay™ to do this is to unwrap cir.scope
as part of LoweringPrepare.cpp
pass, in a CIR to CIR transformation. This way both LLVM and MLIR lowering can share the same scope unwrapping logic.
If the region only has one block: then it's a matter of moving the alloca's to the parent region entry block. If there's more than one block than you need to also tie cleanup blocks.
|
||
for (auto &block : scopeOp.getRegion()) { | ||
rewriter.setInsertionPointToEnd(&block); | ||
auto yield = cast<mlir::cir::YieldOp>(block.getTerminator()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, possible terminators are YieldOp, ReturnOp, ThrowOp
4bf2084
to
2356c02
Compare
Are you referring to the cleanup/optimization steps before the CIR lowering? If I understand it correctly, don't you still need a lowering rewrite pattern for |
I just realized that scf.scope is higher level and will benefit from direct lowering, nevermind! |
This PR adds MLIR lowering of `cir.scope`. I also notice that the MLIR unit tests still uses old integer types. I will fix those in a separate PR.
This PR adds MLIR lowering of `cir.scope`. I also notice that the MLIR unit tests still uses old integer types. I will fix those in a separate PR.
This PR adds MLIR lowering of `cir.scope`. I also notice that the MLIR unit tests still uses old integer types. I will fix those in a separate PR.
This PR adds MLIR lowering of `cir.scope`. I also notice that the MLIR unit tests still uses old integer types. I will fix those in a separate PR.
This PR adds MLIR lowering of `cir.scope`. I also notice that the MLIR unit tests still uses old integer types. I will fix those in a separate PR.
This PR adds MLIR lowering of `cir.scope`. I also notice that the MLIR unit tests still uses old integer types. I will fix those in a separate PR.
This PR adds MLIR lowering of `cir.scope`. I also notice that the MLIR unit tests still uses old integer types. I will fix those in a separate PR.
This PR adds MLIR lowering of `cir.scope`. I also notice that the MLIR unit tests still uses old integer types. I will fix those in a separate PR.
This PR adds MLIR lowering of `cir.scope`. I also notice that the MLIR unit tests still uses old integer types. I will fix those in a separate PR.
This PR adds MLIR lowering of `cir.scope`. I also notice that the MLIR unit tests still uses old integer types. I will fix those in a separate PR.
This PR adds MLIR lowering of
cir.scope
.I also notice that the MLIR unit tests still uses old integer types. I will fix those in a separate PR.