-
Notifications
You must be signed in to change notification settings - Fork 103
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][ThroughMLIR] Support lowering cir.condition and cir.while to scf.condition, scf.while #636
[CIR][ThroughMLIR] Support lowering cir.condition and cir.while to scf.condition, scf.while #636
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.
Looks great, minor nit.
// RUN: FileCheck %s --input-file %t.mlir | ||
|
||
!s32i = !cir.int<s, 32> | ||
module { |
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 either add a comment with the C/C++ code we could use to regen this test in case CIR changes significantly or add a test coming from C/C++ source.
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.
Ok, I will add some comment and test case
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.
Hello, I add a test coming from C source , can you review it?
@ShivaChen can you review this and let us know if anything should be done regarding the loop canonicalization pass? |
Sure, I'll take a look. |
Hello, if you have review the code, and agree with me, I want to try to move the |
Yes, I agree LowerCIRLoopToSCF.cpp could be right place to go. Thanks! |
It seems cir.while to scf.while have one to one mapping. |
#include "llvm/Analysis/RegionInfo.h" | ||
#include "llvm/IR/Type.h" | ||
#include "llvm/IR/Value.h" | ||
#include "llvm/Support/Casting.h" |
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.
nit: does the new adding include lines are required?
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.
These files are generated by clangd’s auto-completion, and I believe they are not necessary
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.
Hello, I have moved the CIRWhileOpLowering to LoweringSCFLoop.cpp , can you review it?
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.
Could we remove the un-required including lines?
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.
The motivation of SCFLoop class is to collect loop upper bound, lower bound and step which would be needed for SCFForOp. Given that SCFWhileOp didn't require these operands, should we avoid use SCFLoop for SCFWhileOp?
#include "llvm/Analysis/RegionInfo.h" | ||
#include "llvm/IR/Type.h" | ||
#include "llvm/IR/Value.h" | ||
#include "llvm/Support/Casting.h" |
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.
Could we remove the un-required including lines?
Do you mean I add a SCFWhileLoop class ? And I will delete the header file. @ShivaChen |
I think the way you implement CIRWhileOpLowering in e882b20 |
@@ -965,6 +973,27 @@ class CIRYieldOpLowering | |||
} | |||
}; | |||
|
|||
class CIRConditionOpLowering |
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.
It seems ConditionOp only be used for loops. Should we move to LowerCIRLoopToSCF.cpp?
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.
I move the CIRConditionOpLowering to LoweriCIRLoopToSCF
Could you remove the changes of deleting empty lines and include headers in LowerCIRToMLIR.cpp? |
Sorry , comparing with the old LowerCIRToMLIR.cpp , I don`t find some empty lines, and I have already deleted the un-used header files. @ShivaChen |
It seems I could see when clicking File Chagned on the web page but it could be a nit-picking. |
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.
LGTM. It'd be best not to touch random lines next PRs, you can probably set you IDE to only format changed lines.
Thanks for the review @ShivaChen
…f.condition, scf.while (llvm#636) This pr intruduces CIRConditionLowering and CIRWhileLowering for lowering to scf.
…f.condition, scf.while (llvm#636) This pr intruduces CIRConditionLowering and CIRWhileLowering for lowering to scf.
…f.condition, scf.while (llvm#636) This pr intruduces CIRConditionLowering and CIRWhileLowering for lowering to scf.
…f.condition, scf.while (llvm#636) This pr intruduces CIRConditionLowering and CIRWhileLowering for lowering to scf.
…f.condition, scf.while (#636) This pr intruduces CIRConditionLowering and CIRWhileLowering for lowering to scf.
This pr intruduces CIRConditionLowering and CIRWhileLowering for lowering to scf.