@@ -167,6 +167,34 @@ 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+ OS << ' ' ;
178+ if (OpIdx + 1 < NumOps && MI->getOperand (OpIdx).isImm () &&
179+ MI->getOperand (OpIdx + 1 ).isImm ()) {
180+ uint64_t LowBits = MI->getOperand (OpIdx).getImm ();
181+ uint64_t HighBits = MI->getOperand (OpIdx + 1 ).getImm ();
182+ uint64_t CombinedValue = (HighBits << 32 ) | LowBits;
183+ OS << formatImm (CombinedValue);
184+ OpIdx += 2 ;
185+
186+ // Next should be the label
187+ if (OpIdx < NumOps) {
188+ OS << ' ' ;
189+ printOperand (MI, OpIdx, OS);
190+ OpIdx++;
191+ }
192+ }
193+ }
194+ } else {
195+ printRemainingVariableOps (MI, NumFixedOps, OS);
196+ }
197+ break ;
170198 case SPIRV::OpImageSampleImplicitLod:
171199 case SPIRV::OpImageSampleDrefImplicitLod:
172200 case SPIRV::OpImageSampleProjImplicitLod:
0 commit comments