Validates that OpSpecConstant specializes to either int or float type.
| 573 | |
| 574 | // Validates that OpSpecConstant specializes to either int or float type. |
| 575 | spv_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 | |
| 590 | spv_result_t ValidateSpecConstantOp(ValidationState_t& _, |
| 591 | const Instruction* inst) { |
no test coverage detected