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

Function ValidateConvertUToPtr

source/val/validate_conversion.cpp:437–519  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

435}
436
437spv_result_t ValidateConvertUToPtr(ValidationState_t& _,
438 const Instruction* inst,
439 uint32_t operand_index = 2) {
440 const spv::Op opcode = inst->opcode();
441 const uint32_t result_type = inst->type_id();
442 const bool has_masked_gather_scatter =
443 _.HasCapability(spv::Capability::MaskedGatherScatterINTEL);
444
445 bool valid_result_type = _.IsPointerType(result_type);
446 if (!valid_result_type && has_masked_gather_scatter) {
447 if (_.IsVectorType(result_type)) {
448 const uint32_t component_type = _.GetComponentType(result_type);
449 valid_result_type = _.IsPointerType(component_type);
450 }
451 }
452
453 if (!valid_result_type) {
454 return _.diag(SPV_ERROR_INVALID_DATA, inst)
455 << "Expected Result Type to be a pointer"
456 << (has_masked_gather_scatter
457 ? " (or vector of pointers with MaskedGatherScatterINTEL)"
458 : "")
459 << ": " << spvOpcodeString(opcode);
460 }
461
462 const uint32_t input_type = _.GetOperandTypeId(inst, operand_index);
463
464 bool valid_input_type = input_type && _.IsIntScalarType(input_type);
465 if (!valid_input_type && has_masked_gather_scatter && input_type) {
466 valid_input_type = _.IsIntVectorType(input_type);
467 }
468
469 if (!valid_input_type) {
470 return _.diag(SPV_ERROR_INVALID_DATA, inst)
471 << "Expected int scalar as input"
472 << (has_masked_gather_scatter
473 ? " (or vector of int with MaskedGatherScatterINTEL)"
474 : "")
475 << ": " << spvOpcodeString(opcode);
476 }
477
478 if (has_masked_gather_scatter && _.IsVectorType(result_type)) {
479 if (!_.IsVectorType(input_type)) {
480 return _.diag(SPV_ERROR_INVALID_DATA, inst)
481 << "Expected input to be a vector when Result Type is a vector: "
482 << spvOpcodeString(opcode);
483 }
484 if (_.GetDimension(result_type) != _.GetDimension(input_type)) {
485 return _.diag(SPV_ERROR_INVALID_DATA, inst)
486 << "Expected input to have the same dimension as Result Type: "
487 << spvOpcodeString(opcode);
488 }
489 }
490
491 if (_.addressing_model() == spv::AddressingModel::Logical)
492 return _.diag(SPV_ERROR_INVALID_DATA, inst)
493 << "Logical addressing not supported: " << spvOpcodeString(opcode);
494

Callers 1

ConversionPassFunction · 0.85

Calls 15

spvOpcodeStringFunction · 0.85
spvIsVulkanEnvFunction · 0.85
IsPointerTypeMethod · 0.80
IsVectorTypeMethod · 0.80
diagMethod · 0.80
GetOperandTypeIdMethod · 0.80
IsIntScalarTypeMethod · 0.80
IsIntVectorTypeMethod · 0.80
GetDimensionMethod · 0.80
addressing_modelMethod · 0.80
GetPointerTypeInfoMethod · 0.80
GetBitWidthMethod · 0.80

Tested by

no test coverage detected