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

Igor Wodiany llvmlistbot at llvm.org
Wed Nov 19 08:50:00 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)) {
----------------
IgWod-IMG wrote:

Yes, the verifier enforces literals and targets have the same size.

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


More information about the Mlir-commits mailing list