| 41 | } |
| 42 | |
| 43 | spv_result_t ValidateConstantOperand(ValidationState_t& _, |
| 44 | const Instruction* inst, size_t operand) { |
| 45 | std::string opcode_name = std::string("Op") + spvOpcodeString(inst->opcode()); |
| 46 | |
| 47 | const auto operand_id = inst->GetOperandAs<uint32_t>(operand); |
| 48 | const bool inst_is_spec_constant = spvOpcodeIsSpecConstant(inst->opcode()); |
| 49 | const auto operand_opcode = _.GetIdOpcode(operand_id); |
| 50 | const bool is_constant = spvOpcodeIsConstantOrUndef(operand_opcode); |
| 51 | const bool is_spec_constant = spvOpcodeIsSpecConstant(operand_opcode); |
| 52 | if (!is_constant) { |
| 53 | // All operands must be constant or undef. |
| 54 | return _.diag(SPV_ERROR_INVALID_ID, inst) |
| 55 | << opcode_name << " must only have constant or undef operands: <id> " |
| 56 | << _.getIdName(operand_id); |
| 57 | } else if (!inst_is_spec_constant && is_spec_constant) { |
| 58 | // Spec constants are only allowed for spec constant opcodes. |
| 59 | return _.diag(SPV_ERROR_INVALID_ID, inst) |
| 60 | << opcode_name << " must not have spec constant operands: <id> " |
| 61 | << _.getIdName(operand_id); |
| 62 | } |
| 63 | |
| 64 | return SPV_SUCCESS; |
| 65 | } |
| 66 | |
| 67 | spv_result_t ValidateConstantComposite(ValidationState_t& _, |
| 68 | const Instruction* inst) { |
no test coverage detected