MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / ValidateUConvert

Function ValidateUConvert

source/val/validate_conversion.cpp:170–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

168}
169
170spv_result_t ValidateUConvert(ValidationState_t& _, const Instruction* inst,
171 uint32_t operand_index = 2) {
172 const spv::Op opcode = inst->opcode();
173 const uint32_t result_type = inst->type_id();
174 if (!_.IsUnsignedIntScalarType(result_type) &&
175 !_.IsUnsignedIntVectorType(result_type) &&
176 !_.IsUnsignedIntCooperativeMatrixType(result_type) &&
177 !_.IsUnsignedIntCooperativeVectorNVType(result_type))
178 return _.diag(SPV_ERROR_INVALID_DATA, inst)
179 << "Expected unsigned int scalar or vector type as Result Type: "
180 << spvOpcodeString(opcode);
181
182 const uint32_t input_type = _.GetOperandTypeId(inst, operand_index);
183 if (!input_type ||
184 (!_.IsIntScalarType(input_type) && !_.IsIntVectorType(input_type) &&
185 !_.IsIntCooperativeMatrixType(input_type) &&
186 !_.IsIntCooperativeVectorNVType(input_type)))
187 return _.diag(SPV_ERROR_INVALID_DATA, inst)
188 << "Expected input to be int scalar or vector: "
189 << spvOpcodeString(opcode);
190
191 if (_.IsCooperativeVectorNVType(result_type) ||
192 _.IsCooperativeVectorNVType(input_type)) {
193 spv_result_t ret =
194 _.CooperativeVectorDimensionsMatch(inst, result_type, input_type);
195 if (ret != SPV_SUCCESS) return ret;
196 } else if (_.IsCooperativeMatrixType(result_type) ||
197 _.IsCooperativeMatrixType(input_type)) {
198 spv_result_t ret =
199 _.CooperativeMatrixShapesMatch(inst, result_type, input_type, true);
200 if (ret != SPV_SUCCESS) return ret;
201 } else {
202 if (_.GetDimension(result_type) != _.GetDimension(input_type))
203 return _.diag(SPV_ERROR_INVALID_DATA, inst)
204 << "Expected input to have the same dimension as Result Type: "
205 << spvOpcodeString(opcode);
206 }
207
208 if (_.GetBitWidth(result_type) == _.GetBitWidth(input_type))
209 return _.diag(SPV_ERROR_INVALID_DATA, inst)
210 << "Expected input to have different bit width from Result "
211 "Type: "
212 << spvOpcodeString(opcode);
213 return SPV_SUCCESS;
214}
215
216spv_result_t ValidateSConvert(ValidationState_t& _, const Instruction* inst,
217 uint32_t operand_index = 2) {

Callers 1

ConversionPassFunction · 0.85

Calls 15

spvOpcodeStringFunction · 0.85
diagMethod · 0.80
GetOperandTypeIdMethod · 0.80
IsIntScalarTypeMethod · 0.80
IsIntVectorTypeMethod · 0.80

Tested by

no test coverage detected