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

Function ValidateConvertFToS

source/val/validate_conversion.cpp:85–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85spv_result_t ValidateConvertFToS(ValidationState_t& _, const Instruction* inst,
86 uint32_t operand_index = 2) {
87 const spv::Op opcode = inst->opcode();
88 const uint32_t result_type = inst->type_id();
89 if (!_.IsIntScalarType(result_type) && !_.IsIntVectorType(result_type) &&
90 !_.IsIntCooperativeMatrixType(result_type) &&
91 !_.IsIntCooperativeVectorNVType(result_type))
92 return _.diag(SPV_ERROR_INVALID_DATA, inst)
93 << "Expected int scalar or vector type as Result Type: "
94 << spvOpcodeString(opcode);
95
96 const uint32_t input_type = _.GetOperandTypeId(inst, operand_index);
97 if (!input_type ||
98 (!_.IsFloatScalarType(input_type) && !_.IsFloatVectorType(input_type) &&
99 !_.IsFloatCooperativeMatrixType(input_type) &&
100 !_.IsFloatCooperativeVectorNVType(input_type)))
101 return _.diag(SPV_ERROR_INVALID_DATA, inst)
102 << "Expected input to be float scalar or vector: "
103 << spvOpcodeString(opcode);
104
105 if (_.IsCooperativeVectorNVType(result_type) ||
106 _.IsCooperativeVectorNVType(input_type)) {
107 spv_result_t ret =
108 _.CooperativeVectorDimensionsMatch(inst, result_type, input_type);
109 if (ret != SPV_SUCCESS) return ret;
110 } else if (_.IsCooperativeMatrixType(result_type) ||
111 _.IsCooperativeMatrixType(input_type)) {
112 spv_result_t ret =
113 _.CooperativeMatrixShapesMatch(inst, result_type, input_type, true);
114 if (ret != SPV_SUCCESS) return ret;
115 } else {
116 if (_.GetDimension(result_type) != _.GetDimension(input_type))
117 return _.diag(SPV_ERROR_INVALID_DATA, inst)
118 << "Expected input to have the same dimension as Result Type: "
119 << spvOpcodeString(opcode);
120 }
121
122 if (auto error = ValidateShaderBitWidth(_, inst)) return error;
123
124 return SPV_SUCCESS;
125}
126
127spv_result_t ValidateConvertIntToF(ValidationState_t& _,
128 const Instruction* inst,

Callers 1

ConversionPassFunction · 0.85

Calls 15

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

Tested by

no test coverage detected