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

Function ValidateIntCompare

source/val/validate_logicals.cpp:223–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221}
222
223spv_result_t ValidateIntCompare(ValidationState_t& _, const Instruction* inst,
224 uint32_t operand_index = 2) {
225 const spv::Op opcode = inst->opcode();
226 const uint32_t result_type = inst->type_id();
227 if (!_.IsBoolScalarType(result_type) && !_.IsBoolVectorType(result_type))
228 return _.diag(SPV_ERROR_INVALID_DATA, inst)
229 << "Expected bool scalar or vector type as Result Type: "
230 << spvOpcodeString(opcode);
231
232 const uint32_t left_type = _.GetOperandTypeId(inst, operand_index);
233 const uint32_t right_type = _.GetOperandTypeId(inst, operand_index + 1);
234
235 if (!left_type ||
236 (!_.IsIntScalarType(left_type) && !_.IsIntVectorType(left_type)))
237 return _.diag(SPV_ERROR_INVALID_DATA, inst)
238 << "Expected operands to be scalar or vector int: "
239 << spvOpcodeString(opcode);
240
241 if (_.GetDimension(result_type) != _.GetDimension(left_type))
242 return _.diag(SPV_ERROR_INVALID_DATA, inst)
243 << "Expected vector sizes of Result Type and the operands to be"
244 << " equal: " << spvOpcodeString(opcode);
245
246 if (!right_type ||
247 (!_.IsIntScalarType(right_type) && !_.IsIntVectorType(right_type)))
248 return _.diag(SPV_ERROR_INVALID_DATA, inst)
249 << "Expected operands to be scalar or vector int: "
250 << spvOpcodeString(opcode);
251
252 if (_.GetDimension(result_type) != _.GetDimension(right_type))
253 return _.diag(SPV_ERROR_INVALID_DATA, inst)
254 << "Expected vector sizes of Result Type and the operands to be"
255 << " equal: " << spvOpcodeString(opcode);
256
257 if (_.GetBitWidth(left_type) != _.GetBitWidth(right_type))
258 return _.diag(SPV_ERROR_INVALID_DATA, inst)
259 << "Expected both operands to have the same component bit "
260 "width: "
261 << spvOpcodeString(opcode);
262 return SPV_SUCCESS;
263}
264
265// Validates correctness of logical instructions.
266spv_result_t LogicalsPass(ValidationState_t& _, const Instruction* inst) {

Callers 1

LogicalsPassFunction · 0.85

Calls 11

spvOpcodeStringFunction · 0.85
IsBoolScalarTypeMethod · 0.80
IsBoolVectorTypeMethod · 0.80
diagMethod · 0.80
GetOperandTypeIdMethod · 0.80
IsIntScalarTypeMethod · 0.80
IsIntVectorTypeMethod · 0.80
GetDimensionMethod · 0.80
GetBitWidthMethod · 0.80
opcodeMethod · 0.45
type_idMethod · 0.45

Tested by

no test coverage detected