| 40 | } |
| 41 | |
| 42 | spv_result_t ValidateScope(ValidationState_t& _, const Instruction* inst, |
| 43 | uint32_t scope) { |
| 44 | spv::Op opcode = inst->opcode(); |
| 45 | bool is_int32 = false, is_const_int32 = false; |
| 46 | uint32_t value = 0; |
| 47 | std::tie(is_int32, is_const_int32, value) = _.EvalInt32IfConst(scope); |
| 48 | |
| 49 | if (!is_int32) { |
| 50 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 51 | << spvOpcodeString(opcode) << ": expected scope to be a 32-bit int"; |
| 52 | } |
| 53 | |
| 54 | if (!is_const_int32) { |
| 55 | if (_.HasCapability(spv::Capability::Shader) && |
| 56 | !_.HasCapability(spv::Capability::CooperativeMatrixNV)) { |
| 57 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 58 | << "Scope ids must be OpConstant when Shader capability is " |
| 59 | << "present"; |
| 60 | } |
| 61 | if (_.HasCapability(spv::Capability::Shader) && |
| 62 | _.HasCapability(spv::Capability::CooperativeMatrixNV) && |
| 63 | !spvOpcodeIsConstant(_.GetIdOpcode(scope))) { |
| 64 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 65 | << "Scope ids must be constant or specialization constant when " |
| 66 | << "CooperativeMatrixNV capability is present"; |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | if (is_const_int32 && !IsValidScope(value)) { |
| 71 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 72 | << "Invalid scope value:\n " << _.Disassemble(*_.FindDef(scope)); |
| 73 | } |
| 74 | |
| 75 | return SPV_SUCCESS; |
| 76 | } |
| 77 | |
| 78 | spv_result_t ValidateExecutionScope(ValidationState_t& _, |
| 79 | const Instruction* inst, uint32_t scope) { |
no test coverage detected