| 221 | } |
| 222 | |
| 223 | spv_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. |
| 266 | spv_result_t LogicalsPass(ValidationState_t& _, const Instruction* inst) { |
no test coverage detected