| 558 | } |
| 559 | |
| 560 | spv_result_t ValidateGenericCastToPtr(ValidationState_t& _, |
| 561 | const Instruction* inst, |
| 562 | uint32_t operand_index = 2) { |
| 563 | const spv::Op opcode = inst->opcode(); |
| 564 | const uint32_t result_type = inst->type_id(); |
| 565 | spv::StorageClass result_storage_class; |
| 566 | uint32_t result_data_type = 0; |
| 567 | if (!_.GetPointerTypeInfo(result_type, &result_data_type, |
| 568 | &result_storage_class)) |
| 569 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 570 | << "Expected Result Type to be a pointer: " |
| 571 | << spvOpcodeString(opcode); |
| 572 | |
| 573 | if (result_storage_class != spv::StorageClass::Workgroup && |
| 574 | result_storage_class != spv::StorageClass::CrossWorkgroup && |
| 575 | result_storage_class != spv::StorageClass::Function) |
| 576 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 577 | << "Expected Result Type to have storage class Workgroup, " |
| 578 | << "CrossWorkgroup or Function: " << spvOpcodeString(opcode); |
| 579 | |
| 580 | const uint32_t input_type = _.GetOperandTypeId(inst, operand_index); |
| 581 | spv::StorageClass input_storage_class; |
| 582 | uint32_t input_data_type = 0; |
| 583 | if (!_.GetPointerTypeInfo(input_type, &input_data_type, &input_storage_class)) |
| 584 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 585 | << "Expected input to be a pointer: " << spvOpcodeString(opcode); |
| 586 | |
| 587 | if (input_storage_class != spv::StorageClass::Generic) |
| 588 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 589 | << "Expected input to have storage class Generic: " |
| 590 | << spvOpcodeString(opcode); |
| 591 | |
| 592 | if (result_data_type != input_data_type) |
| 593 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 594 | << "Expected input and Result Type to point to the same type: " |
| 595 | << spvOpcodeString(opcode); |
| 596 | return SPV_SUCCESS; |
| 597 | } |
| 598 | |
| 599 | spv_result_t ValidateGenericCastToPtrExplicit(ValidationState_t& _, |
| 600 | const Instruction* inst) { |
no test coverage detected