[Mlir-commits] [mlir] [mlir][spirv] Add support for SwitchOp (PR #168713)

Jakub Kuderski llvmlistbot at llvm.org
Wed Nov 19 07:24:39 PST 2025


================
@@ -775,6 +775,27 @@ LogicalResult Serializer::processBranchOp(spirv::BranchOp branchOp) {
   return success();
 }
 
+LogicalResult Serializer::processSwitchOp(spirv::SwitchOp switchOp) {
+  uint32_t selectorID = getValueID(switchOp.getSelector());
+  uint32_t defaultLabelID = getOrCreateBlockID(switchOp.getDefaultTarget());
+  SmallVector<uint32_t> arguments{selectorID, defaultLabelID};
+
+  std::optional<mlir::DenseIntElementsAttr> literals = switchOp.getLiterals();
+  BlockRange targets = switchOp.getTargets();
+  if (literals) {
+    for (auto [literal, target] : llvm::zip(*literals, targets)) {
----------------
kuhar wrote:

Can we use zip_equals here? Are the lengths guaranteed to be the same?

https://github.com/llvm/llvm-project/pull/168713


More information about the Mlir-commits mailing list