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

Function ValidateSignedInt

source/val/validate_arithmetics.cpp:123–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121}
122
123spv_result_t ValidateSignedInt(ValidationState_t& _, const Instruction* inst,
124 uint32_t starting_index = 2) {
125 const spv::Op opcode = inst->opcode();
126 const uint32_t result_type = inst->type_id();
127 bool supportsCoopMat =
128 (opcode != spv::Op::OpIMul && opcode != spv::Op::OpSRem &&
129 opcode != spv::Op::OpSMod);
130 bool supportsCoopVec =
131 (opcode != spv::Op::OpSRem && opcode != spv::Op::OpSMod);
132 if (!_.IsIntScalarType(result_type) && !_.IsIntVectorType(result_type) &&
133 !(supportsCoopMat && _.IsIntCooperativeMatrixType(result_type)) &&
134 !(opcode == spv::Op::OpIMul &&
135 _.IsCooperativeMatrixKHRType(result_type) &&
136 _.IsIntCooperativeMatrixType(result_type)) &&
137 !(supportsCoopVec && _.IsIntCooperativeVectorNVType(result_type)))
138 return _.diag(SPV_ERROR_INVALID_DATA, inst)
139 << "Expected int scalar or vector type as Result Type: "
140 << spvOpcodeString(opcode);
141
142 const uint32_t dimension = _.GetDimension(result_type);
143 const uint32_t bit_width = _.GetBitWidth(result_type);
144
145 for (size_t operand_index = starting_index;
146 operand_index < inst->operands().size(); ++operand_index) {
147 const uint32_t type_id = _.GetOperandTypeId(inst, operand_index);
148
149 if (supportsCoopVec && _.IsCooperativeVectorNVType(result_type)) {
150 if (!_.IsCooperativeVectorNVType(type_id)) {
151 return _.diag(SPV_ERROR_INVALID_DATA, inst)
152 << "Expected arithmetic operands to be of Result Type: "
153 << spvOpcodeString(opcode) << " operand index " << operand_index;
154 }
155 spv_result_t ret =
156 _.CooperativeVectorDimensionsMatch(inst, type_id, result_type);
157 if (ret != SPV_SUCCESS) return ret;
158 }
159
160 if (supportsCoopMat && _.IsCooperativeMatrixKHRType(result_type)) {
161 if (!_.IsCooperativeMatrixKHRType(type_id) ||
162 !_.IsIntCooperativeMatrixType(type_id)) {
163 return _.diag(SPV_ERROR_INVALID_DATA, inst)
164 << "Expected arithmetic operands to be of Result Type: "
165 << spvOpcodeString(opcode) << " operand index " << operand_index;
166 }
167 spv_result_t ret =
168 _.CooperativeMatrixShapesMatch(inst, result_type, type_id, false);
169 if (ret != SPV_SUCCESS) return ret;
170 }
171
172 if (!type_id ||
173 (!_.IsIntScalarType(type_id) && !_.IsIntVectorType(type_id) &&
174 !(supportsCoopMat && _.IsIntCooperativeMatrixType(result_type)) &&
175 !(opcode == spv::Op::OpIMul &&
176 _.IsCooperativeMatrixKHRType(result_type) &&
177 _.IsIntCooperativeMatrixType(result_type)) &&
178 !(supportsCoopVec && _.IsIntCooperativeVectorNVType(result_type))))
179 return _.diag(SPV_ERROR_INVALID_DATA, inst)
180 << "Expected int scalar or vector type as operand: "

Callers 1

ArithmeticsPassFunction · 0.85

Calls 15

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

Tested by

no test coverage detected