[llvm] [SPIRV] Print split 64-bit OpSwitch operands as a single operand for text output (PR #164886)

Nick Sarnie via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 27 07:15:59 PDT 2025


================
@@ -167,6 +167,35 @@ void SPIRVInstPrinter::printInst(const MCInst *MI, uint64_t Address,
               MI, FirstVariableIndex, OS);
           printRemainingVariableOps(MI, FirstVariableIndex + 1, OS);
           break;
+        case SPIRV::OpSwitch:
+          if (MI->getFlags() & SPIRV::INST_PRINTER_WIDTH64) {
+            // In binary format 64-bit types are split into two 32-bit operands,
+            // but in text format combine these into a single 64-bit value as
+            // this is what tools such as spirv-as require.
+            const unsigned NumOps = MI->getNumOperands();
+            for (unsigned OpIdx = NumFixedOps; OpIdx < NumOps;) {
+              if (OpIdx + 1 >= NumOps || !MI->getOperand(OpIdx).isImm() ||
+                  !MI->getOperand(OpIdx + 1).isImm()) {
+                continue;
----------------
sarnex wrote:

Ah good point, let me make it an assert.

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


More information about the llvm-commits mailing list