[Mlir-commits] [mlir] [mlir][SPIR-V] Convert scf.index_switch to spirv.mlir.selection with spirv.Switch (PR #200573)
Igor Wodiany
llvmlistbot at llvm.org
Mon Jun 1 01:47:28 PDT 2026
================
@@ -293,6 +293,90 @@ struct IfOpConversion : SCFToSPIRVPattern<scf::IfOp> {
}
};
+//===----------------------------------------------------------------------===//
+// scf::IndexSwitchOp
+//===----------------------------------------------------------------------===//
+
+/// Pattern to convert a scf::IndexSwitchOp within kernel functions into
+/// spirv::SelectionOp with a spirv::SwitchOp header.
+struct IndexSwitchOpConversion final : SCFToSPIRVPattern<scf::IndexSwitchOp> {
+ using SCFToSPIRVPattern::SCFToSPIRVPattern;
+
+ LogicalResult
+ matchAndRewrite(scf::IndexSwitchOp switchOp, OpAdaptor adaptor,
+ ConversionPatternRewriter &rewriter) const override {
+ Location loc = switchOp.getLoc();
+
+ // Compute return types.
+ SmallVector<Type, 8> returnTypes;
+ for (auto result : switchOp.getResults()) {
+ auto convertedType = typeConverter.convertType(result.getType());
----------------
IgWod wrote:
nit: Probably worth spelling out types
https://github.com/llvm/llvm-project/pull/200573
More information about the Mlir-commits
mailing list