-
Notifications
You must be signed in to change notification settings - Fork 156
[CIR][ThroughMLIR] Lower simple SwitchOp #1742
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
base: main
Are you sure you want to change the base?
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.
Overall looks good, mostly nits
break; | ||
case CaseOpKind::Range: | ||
case CaseOpKind::Anyof: | ||
llvm_unreachable("NYI"); |
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.
Instead of llvm_unreachable
you can use emitError here and everywhere else
: public mlir::PassWrapper<MLIRLoweringPrepare, | ||
mlir::OperationPass<mlir::ModuleOp>> { | ||
// `scf.index_switch` requires that switch branches do not fall through. | ||
// We need to copy the next branch's body when the current `cir.case` does not |
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.
Seems like this violates 80-col?
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.
Seems clang-format didn't report that. I changed it manually.
d2c4ab8
to
8f89224
Compare
This deals with fall-through by copying the body of the next
cir.case
to the previous case. This is needed becausescf.index_switch
does not support falling through.