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

Function ValidateSpecConstant

source/val/validate_constants.cpp:575–588  ·  view source on GitHub ↗

Validates that OpSpecConstant specializes to either int or float type.

Source from the content-addressed store, hash-verified

573
574// Validates that OpSpecConstant specializes to either int or float type.
575spv_result_t ValidateSpecConstant(ValidationState_t& _,
576 const Instruction* inst) {
577 // Operand 0 is the <id> of the type that we're specializing to.
578 auto type_id = inst->GetOperandAs<const uint32_t>(0);
579 auto type_instruction = _.FindDef(type_id);
580 auto type_opcode = type_instruction->opcode();
581 if (type_opcode != spv::Op::OpTypeInt &&
582 type_opcode != spv::Op::OpTypeFloat) {
583 return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Specialization constant "
584 "must be an integer or "
585 "floating-point number.";
586 }
587 return SPV_SUCCESS;
588}
589
590spv_result_t ValidateSpecConstantOp(ValidationState_t& _,
591 const Instruction* inst) {

Callers 1

ConstantPassFunction · 0.85

Calls 3

FindDefMethod · 0.80
diagMethod · 0.80
opcodeMethod · 0.45

Tested by

no test coverage detected