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

Function ValidateUnsignedInt

source/val/validate_arithmetics.cpp:77–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77spv_result_t ValidateUnsignedInt(ValidationState_t& _, const Instruction* inst,
78 uint32_t starting_index = 2) {
79 const spv::Op opcode = inst->opcode();
80 const uint32_t result_type = inst->type_id();
81 bool supportsCoopMat = (opcode == spv::Op::OpUDiv);
82 bool supportsCoopVec = (opcode == spv::Op::OpUDiv);
83 if (!_.IsUnsignedIntScalarType(result_type) &&
84 !_.IsUnsignedIntVectorType(result_type) &&
85 !(supportsCoopMat && _.IsUnsignedIntCooperativeMatrixType(result_type)) &&
86 !(supportsCoopVec && _.IsUnsignedIntCooperativeVectorNVType(result_type)))
87 return _.diag(SPV_ERROR_INVALID_DATA, inst)
88 << "Expected unsigned int scalar or vector type as Result Type: "
89 << spvOpcodeString(opcode);
90
91 for (size_t operand_index = starting_index;
92 operand_index < inst->operands().size(); ++operand_index) {
93 if (supportsCoopVec && _.IsCooperativeVectorNVType(result_type)) {
94 const uint32_t type_id = _.GetOperandTypeId(inst, operand_index);
95 if (!_.IsCooperativeVectorNVType(type_id)) {
96 return _.diag(SPV_ERROR_INVALID_DATA, inst)
97 << "Expected arithmetic operands to be of Result Type: "
98 << spvOpcodeString(opcode) << " operand index " << operand_index;
99 }
100 spv_result_t ret =
101 _.CooperativeVectorDimensionsMatch(inst, type_id, result_type);
102 if (ret != SPV_SUCCESS) return ret;
103 } else if (supportsCoopMat && _.IsCooperativeMatrixKHRType(result_type)) {
104 const uint32_t type_id = _.GetOperandTypeId(inst, operand_index);
105 if (!_.IsCooperativeMatrixKHRType(type_id) ||
106 !_.IsUnsignedIntCooperativeMatrixType(type_id)) {
107 return _.diag(SPV_ERROR_INVALID_DATA, inst)
108 << "Expected arithmetic operands to be of Result Type: "
109 << spvOpcodeString(opcode) << " operand index " << operand_index;
110 }
111 spv_result_t ret =
112 _.CooperativeMatrixShapesMatch(inst, result_type, type_id, false);
113 if (ret != SPV_SUCCESS) return ret;
114 } else if (_.GetOperandTypeId(inst, operand_index) != result_type)
115 return _.diag(SPV_ERROR_INVALID_DATA, inst)
116 << "Expected arithmetic operands to be of Result Type: "
117 << spvOpcodeString(opcode) << " operand index " << operand_index;
118 }
119
120 return SPV_SUCCESS;
121}
122
123spv_result_t ValidateSignedInt(ValidationState_t& _, const Instruction* inst,
124 uint32_t starting_index = 2) {

Callers 1

ArithmeticsPassFunction · 0.85

Tested by

no test coverage detected