@@ -167,6 +167,35 @@ void SPIRVInstPrinter::printInst(const MCInst *MI, uint64_t Address,
167167 MI, FirstVariableIndex, OS);
168168 printRemainingVariableOps (MI, FirstVariableIndex + 1 , OS);
169169 break ;
170+ case SPIRV::OpSwitch:
171+ if (MI->getFlags () & SPIRV::INST_PRINTER_WIDTH64) {
172+ // In binary format 64-bit types are split into two 32-bit operands,
173+ // but in text format combine these into a single 64-bit value as
174+ // this is what tools such as spirv-as require.
175+ const unsigned NumOps = MI->getNumOperands ();
176+ for (unsigned OpIdx = NumFixedOps; OpIdx < NumOps;) {
177+ if (OpIdx + 1 >= NumOps || !MI->getOperand (OpIdx).isImm () ||
178+ !MI->getOperand (OpIdx + 1 ).isImm ()) {
179+ continue ;
180+ }
181+ OS << ' ' ;
182+ uint64_t LowBits = MI->getOperand (OpIdx).getImm ();
183+ uint64_t HighBits = MI->getOperand (OpIdx + 1 ).getImm ();
184+ uint64_t CombinedValue = (HighBits << 32 ) | LowBits;
185+ OS << formatImm (CombinedValue);
186+ OpIdx += 2 ;
187+
188+ // Next should be the label
189+ if (OpIdx < NumOps) {
190+ OS << ' ' ;
191+ printOperand (MI, OpIdx, OS);
192+ OpIdx++;
193+ }
194+ }
195+ } else {
196+ printRemainingVariableOps (MI, NumFixedOps, OS);
197+ }
198+ break ;
170199 case SPIRV::OpImageSampleImplicitLod:
171200 case SPIRV::OpImageSampleDrefImplicitLod:
172201 case SPIRV::OpImageSampleProjImplicitLod:
0 commit comments