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

Function ValidateConvertFToU

source/val/validate_conversion.cpp:42–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42spv_result_t ValidateConvertFToU(ValidationState_t& _, const Instruction* inst,
43 uint32_t operand_index = 2) {
44 const spv::Op opcode = inst->opcode();
45 const uint32_t result_type = inst->type_id();
46 if (!_.IsUnsignedIntScalarType(result_type) &&
47 !_.IsUnsignedIntVectorType(result_type) &&
48 !_.IsUnsignedIntCooperativeMatrixType(result_type) &&
49 !_.IsUnsignedIntCooperativeVectorNVType(result_type))
50 return _.diag(SPV_ERROR_INVALID_DATA, inst)
51 << "Expected unsigned int scalar or vector type as Result Type: "
52 << spvOpcodeString(opcode);
53
54 const uint32_t input_type = _.GetOperandTypeId(inst, operand_index);
55 if (!input_type ||
56 (!_.IsFloatScalarType(input_type) && !_.IsFloatVectorType(input_type) &&
57 !_.IsFloatCooperativeMatrixType(input_type) &&
58 !_.IsFloatCooperativeVectorNVType(input_type)))
59 return _.diag(SPV_ERROR_INVALID_DATA, inst)
60 << "Expected input to be float scalar or vector: "
61 << spvOpcodeString(opcode);
62
63 if (_.IsCooperativeVectorNVType(result_type) ||
64 _.IsCooperativeVectorNVType(input_type)) {
65 spv_result_t ret =
66 _.CooperativeVectorDimensionsMatch(inst, result_type, input_type);
67 if (ret != SPV_SUCCESS) return ret;
68 } else if (_.IsCooperativeMatrixType(result_type) ||
69 _.IsCooperativeMatrixType(input_type)) {
70 spv_result_t ret =
71 _.CooperativeMatrixShapesMatch(inst, result_type, input_type, true);
72 if (ret != SPV_SUCCESS) return ret;
73 } else {
74 if (_.GetDimension(result_type) != _.GetDimension(input_type))
75 return _.diag(SPV_ERROR_INVALID_DATA, inst)
76 << "Expected input to have the same dimension as Result Type: "
77 << spvOpcodeString(opcode);
78 }
79
80 if (auto error = ValidateShaderBitWidth(_, inst)) return error;
81
82 return SPV_SUCCESS;
83}
84
85spv_result_t ValidateConvertFToS(ValidationState_t& _, const Instruction* inst,
86 uint32_t operand_index = 2) {

Callers 1

ConversionPassFunction · 0.85

Calls 15

spvOpcodeStringFunction · 0.85
ValidateShaderBitWidthFunction · 0.85
diagMethod · 0.80
GetOperandTypeIdMethod · 0.80
IsFloatScalarTypeMethod · 0.80
IsFloatVectorTypeMethod · 0.80

Tested by

no test coverage detected