| 328 | } |
| 329 | |
| 330 | spv_result_t ValidateConvertPtrToU(ValidationState_t& _, |
| 331 | const Instruction* inst, |
| 332 | uint32_t operand_index = 2) { |
| 333 | const spv::Op opcode = inst->opcode(); |
| 334 | const uint32_t result_type = inst->type_id(); |
| 335 | const bool has_masked_gather_scatter = |
| 336 | _.HasCapability(spv::Capability::MaskedGatherScatterINTEL); |
| 337 | |
| 338 | bool valid_result_type = _.IsUnsignedIntScalarType(result_type); |
| 339 | if (!valid_result_type && has_masked_gather_scatter) { |
| 340 | valid_result_type = _.IsUnsignedIntVectorType(result_type); |
| 341 | } |
| 342 | |
| 343 | if (!valid_result_type) { |
| 344 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 345 | << "Expected unsigned int scalar type as Result Type" |
| 346 | << (has_masked_gather_scatter ? " (or vector of unsigned int with " |
| 347 | "MaskedGatherScatterINTEL)" |
| 348 | : "") |
| 349 | << ": " << spvOpcodeString(opcode); |
| 350 | } |
| 351 | |
| 352 | const uint32_t input_type = _.GetOperandTypeId(inst, operand_index); |
| 353 | |
| 354 | bool valid_input_type = _.IsPointerType(input_type); |
| 355 | if (!valid_input_type && has_masked_gather_scatter && input_type) { |
| 356 | if (_.IsVectorType(input_type)) { |
| 357 | const uint32_t component_type = _.GetComponentType(input_type); |
| 358 | valid_input_type = _.IsPointerType(component_type); |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | if (!valid_input_type) { |
| 363 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 364 | << "Expected input to be a pointer" |
| 365 | << (has_masked_gather_scatter |
| 366 | ? " (or vector of pointers with MaskedGatherScatterINTEL)" |
| 367 | : "") |
| 368 | << ": " << spvOpcodeString(opcode); |
| 369 | } |
| 370 | |
| 371 | if (has_masked_gather_scatter && _.IsVectorType(result_type)) { |
| 372 | if (!_.IsVectorType(input_type)) { |
| 373 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 374 | << "Expected input to be a vector when Result Type is a vector: " |
| 375 | << spvOpcodeString(opcode); |
| 376 | } |
| 377 | if (_.GetDimension(result_type) != _.GetDimension(input_type)) { |
| 378 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 379 | << "Expected input to have the same dimension as Result Type: " |
| 380 | << spvOpcodeString(opcode); |
| 381 | } |
| 382 | } |
| 383 | |
| 384 | if (_.addressing_model() == spv::AddressingModel::Logical) |
| 385 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 386 | << "Logical addressing not supported: " << spvOpcodeString(opcode); |
| 387 |
no test coverage detected