@@ -105,6 +105,57 @@ TEST_F(ValidateMisc, SizeOfValid) {
105105 EXPECT_EQ (SPV_SUCCESS, ValidateInstructions (SPV_ENV_UNIVERSAL_1_1));
106106}
107107
108+ TEST_F (ValidateMisc, SizeOfFloat) {
109+ const std::string spirv = R"(
110+ OpCapability Addresses
111+ OpCapability Kernel
112+ OpMemoryModel Physical64 OpenCL
113+ OpEntryPoint Kernel %f "f"
114+ %void = OpTypeVoid
115+ %f32 = OpTypeFloat 32
116+ %ptr = OpTypePointer CrossWorkgroup %f32
117+ %fnTy = OpTypeFunction %void
118+ %f = OpFunction %void None %fnTy
119+ %entry = OpLabel
120+ %s = OpSizeOf %f32 %ptr
121+ OpReturn
122+ OpFunctionEnd
123+ )" ;
124+
125+ CompileSuccessfully (spirv, SPV_ENV_UNIVERSAL_1_1);
126+ EXPECT_EQ (SPV_ERROR_INVALID_DATA,
127+ ValidateInstructions (SPV_ENV_UNIVERSAL_1_1));
128+ EXPECT_THAT (
129+ getDiagnosticString (),
130+ HasSubstr (" Expected OpSizeOf Result Type to be a 32-bit int scalar" ));
131+ }
132+
133+ TEST_F (ValidateMisc, SizeOfVector) {
134+ const std::string spirv = R"(
135+ OpCapability Addresses
136+ OpCapability Kernel
137+ OpMemoryModel Physical64 OpenCL
138+ OpEntryPoint Kernel %f "f"
139+ %void = OpTypeVoid
140+ %i32 = OpTypeInt 32 0
141+ %v2i32 = OpTypeVector %i32 2
142+ %ptr = OpTypePointer CrossWorkgroup %v2i32
143+ %fnTy = OpTypeFunction %void
144+ %f = OpFunction %void None %fnTy
145+ %entry = OpLabel
146+ %s = OpSizeOf %v2i32 %ptr
147+ OpReturn
148+ OpFunctionEnd
149+ )" ;
150+
151+ CompileSuccessfully (spirv, SPV_ENV_UNIVERSAL_1_1);
152+ EXPECT_EQ (SPV_ERROR_INVALID_DATA,
153+ ValidateInstructions (SPV_ENV_UNIVERSAL_1_1));
154+ EXPECT_THAT (
155+ getDiagnosticString (),
156+ HasSubstr (" Expected OpSizeOf Result Type to be a 32-bit int scalar" ));
157+ }
158+
108159const std::string ShaderClockSpirv = R"(
109160OpCapability Shader
110161OpCapability Int64
0 commit comments