| 519 | } |
| 520 | |
| 521 | spv_result_t ValidatePtrCastToGeneric(ValidationState_t& _, |
| 522 | const Instruction* inst, |
| 523 | uint32_t operand_index = 2) { |
| 524 | const spv::Op opcode = inst->opcode(); |
| 525 | const uint32_t result_type = inst->type_id(); |
| 526 | spv::StorageClass result_storage_class; |
| 527 | uint32_t result_data_type = 0; |
| 528 | if (!_.GetPointerTypeInfo(result_type, &result_data_type, |
| 529 | &result_storage_class)) |
| 530 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 531 | << "Expected Result Type to be a pointer: " |
| 532 | << spvOpcodeString(opcode); |
| 533 | |
| 534 | if (result_storage_class != spv::StorageClass::Generic) |
| 535 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 536 | << "Expected Result Type to have storage class Generic: " |
| 537 | << spvOpcodeString(opcode); |
| 538 | |
| 539 | const uint32_t input_type = _.GetOperandTypeId(inst, operand_index); |
| 540 | spv::StorageClass input_storage_class; |
| 541 | uint32_t input_data_type = 0; |
| 542 | if (!_.GetPointerTypeInfo(input_type, &input_data_type, &input_storage_class)) |
| 543 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 544 | << "Expected input to be a pointer: " << spvOpcodeString(opcode); |
| 545 | |
| 546 | if (input_storage_class != spv::StorageClass::Workgroup && |
| 547 | input_storage_class != spv::StorageClass::CrossWorkgroup && |
| 548 | input_storage_class != spv::StorageClass::Function) |
| 549 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 550 | << "Expected input to have storage class Workgroup, " |
| 551 | << "CrossWorkgroup or Function: " << spvOpcodeString(opcode); |
| 552 | |
| 553 | if (result_data_type != input_data_type) |
| 554 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 555 | << "Expected input and Result Type to point to the same type: " |
| 556 | << spvOpcodeString(opcode); |
| 557 | return SPV_SUCCESS; |
| 558 | } |
| 559 | |
| 560 | spv_result_t ValidateGenericCastToPtr(ValidationState_t& _, |
| 561 | const Instruction* inst, |
no test coverage detected