[clang] [CIR] Upstream support for lowering cir.switch to LLVM (PR #140425)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Mon May 19 14:06:40 PDT 2025
================
@@ -1038,6 +1038,37 @@ mlir::LogicalResult CIRToLLVMGlobalOpLowering::matchAndRewrite(
return mlir::success();
}
+mlir::LogicalResult CIRToLLVMSwitchFlatOpLowering::matchAndRewrite(
+ cir::SwitchFlatOp op, OpAdaptor adaptor,
+ mlir::ConversionPatternRewriter &rewriter) const {
+
+ llvm::SmallVector<mlir::APInt, 8> caseValues;
+ if (op.getCaseValues()) {
+ for (mlir::Attribute val : op.getCaseValues()) {
+ auto intAttr = dyn_cast<cir::IntAttr>(val);
+ caseValues.push_back(intAttr.getValue());
+ }
+ }
+
+ llvm::SmallVector<mlir::Block *, 8> caseDestinations;
+ llvm::SmallVector<mlir::ValueRange, 8> caseOperands;
+
+ for (mlir::Block *x : op.getCaseDestinations()) {
+ caseDestinations.push_back(x);
+ }
+
+ for (mlir::OperandRange x : op.getCaseOperands()) {
----------------
andykaylor wrote:
No braces
https://github.com/llvm/llvm-project/pull/140425
More information about the cfe-commits
mailing list