@@ -174,5 +174,59 @@ TEST(OpcodeLookupExtInstTest, Operands) {
174174 SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER}));
175175}
176176
177+ // Test printingClass
178+
179+ struct OpcodePrintingClassCase {
180+ std::string name;
181+ PrintingClass expected;
182+ };
183+
184+ std::ostream& operator <<(std::ostream& os,
185+ const OpcodePrintingClassCase& opcc) {
186+ os << " OPCC('" << opcc.name << " ', " << static_cast <int >(opcc.expected )
187+ << " )" ;
188+ return os;
189+ }
190+
191+ using OpcodePrintingClassTest =
192+ ::testing::TestWithParam<OpcodePrintingClassCase>;
193+
194+ TEST_P (OpcodePrintingClassTest, OpcodeLookup_ByName) {
195+ InstructionDesc* desc = nullptr ;
196+ auto status = LookupOpcode (GetParam ().name .data (), &desc);
197+ EXPECT_EQ (status, SPV_SUCCESS);
198+ ASSERT_NE (desc, nullptr );
199+ EXPECT_EQ (desc->printingClass , GetParam ().expected );
200+ }
201+
202+ INSTANTIATE_TEST_SUITE_P (
203+ Samples, OpcodePrintingClassTest,
204+ ValuesIn (std::vector<OpcodePrintingClassCase>{
205+ {" ConstantFunctionPointerINTEL" , PrintingClass::k_exclude},
206+ {" Nop" , PrintingClass::kMiscellaneous },
207+ {" SourceContinued" , PrintingClass::kDebug },
208+ {" Decorate" , PrintingClass::kAnnotation },
209+ {" Extension" , PrintingClass::kExtension },
210+ {" MemoryModel" , PrintingClass::kMode_Setting },
211+ {" Variable" , PrintingClass::kMemory },
212+ {" CooperativeMatrixPerElementOpNV" , PrintingClass::kFunction },
213+ {" SampledImage" , PrintingClass::kImage },
214+ {" ConvertFToU" , PrintingClass::kConversion },
215+ {" VectorExtractDynamic" , PrintingClass::kComposite },
216+ {" IAdd" , PrintingClass::kArithmetic },
217+ {" ShiftRightLogical" , PrintingClass::kBit },
218+ {" Any" , PrintingClass::kRelational_and_Logical },
219+ {" DPdx" , PrintingClass::kDerivative },
220+ {" Branch" , PrintingClass::kControl_Flow },
221+ {" AtomicLoad" , PrintingClass::kAtomic },
222+ {" ControlBarrier" , PrintingClass::kBarrier },
223+ {" GroupAll" , PrintingClass::kGroup },
224+ {" EnqueueMarker" , PrintingClass::kDevice_Side_Enqueue },
225+ {" ReadPipe" , PrintingClass::kPipe },
226+ {" GroupNonUniformElect" , PrintingClass::kNon_Uniform },
227+ // Skipping "Reserved" because it's probably an
228+ // unstable class.
229+ }));
230+
177231} // namespace
178232} // namespace spvtools
0 commit comments