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

Function ValidateSConvert

source/val/validate_conversion.cpp:216–259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

214}
215
216spv_result_t ValidateSConvert(ValidationState_t& _, const Instruction* inst,
217 uint32_t operand_index = 2) {
218 const spv::Op opcode = inst->opcode();
219 const uint32_t result_type = inst->type_id();
220 if (!_.IsIntScalarType(result_type) && !_.IsIntVectorType(result_type) &&
221 !_.IsIntCooperativeMatrixType(result_type) &&
222 !_.IsIntCooperativeVectorNVType(result_type))
223 return _.diag(SPV_ERROR_INVALID_DATA, inst)
224 << "Expected int scalar or vector type as Result Type: "
225 << spvOpcodeString(opcode);
226
227 const uint32_t input_type = _.GetOperandTypeId(inst, operand_index);
228 if (!input_type ||
229 (!_.IsIntScalarType(input_type) && !_.IsIntVectorType(input_type) &&
230 !_.IsIntCooperativeMatrixType(input_type) &&
231 !_.IsIntCooperativeVectorNVType(input_type)))
232 return _.diag(SPV_ERROR_INVALID_DATA, inst)
233 << "Expected input to be int scalar or vector: "
234 << spvOpcodeString(opcode);
235
236 if (_.IsCooperativeVectorNVType(result_type) ||
237 _.IsCooperativeVectorNVType(input_type)) {
238 spv_result_t ret =
239 _.CooperativeVectorDimensionsMatch(inst, result_type, input_type);
240 if (ret != SPV_SUCCESS) return ret;
241 } else if (_.IsCooperativeMatrixType(result_type) ||
242 _.IsCooperativeMatrixType(input_type)) {
243 spv_result_t ret =
244 _.CooperativeMatrixShapesMatch(inst, result_type, input_type, true);
245 if (ret != SPV_SUCCESS) return ret;
246 } else {
247 if (_.GetDimension(result_type) != _.GetDimension(input_type))
248 return _.diag(SPV_ERROR_INVALID_DATA, inst)
249 << "Expected input to have the same dimension as Result Type: "
250 << spvOpcodeString(opcode);
251 }
252
253 if (_.GetBitWidth(result_type) == _.GetBitWidth(input_type))
254 return _.diag(SPV_ERROR_INVALID_DATA, inst)
255 << "Expected input to have different bit width from Result "
256 "Type: "
257 << spvOpcodeString(opcode);
258 return SPV_SUCCESS;
259}
260
261spv_result_t ValidateFConvert(ValidationState_t& _, const Instruction* inst,
262 uint32_t operand_index = 2) {

Callers 1

ConversionPassFunction · 0.85

Calls 15

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

Tested by

no test coverage detected