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

Function ValidatePtrCastToGeneric

source/val/validate_conversion.cpp:521–558  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

519}
520
521spv_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
560spv_result_t ValidateGenericCastToPtr(ValidationState_t& _,
561 const Instruction* inst,

Callers 1

ConversionPassFunction · 0.85

Calls 6

spvOpcodeStringFunction · 0.85
GetPointerTypeInfoMethod · 0.80
diagMethod · 0.80
GetOperandTypeIdMethod · 0.80
opcodeMethod · 0.45
type_idMethod · 0.45

Tested by

no test coverage detected