| 103 | } |
| 104 | |
| 105 | spv_result_t ValidateBitwise(ValidationState_t& _, const Instruction* inst, |
| 106 | uint32_t starting_index = 2) { |
| 107 | const spv::Op opcode = inst->opcode(); |
| 108 | const uint32_t result_type = inst->type_id(); |
| 109 | if (!_.IsIntScalarType(result_type) && !_.IsIntVectorType(result_type) && |
| 110 | !_.IsIntCooperativeVectorNVType(result_type)) |
| 111 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 112 | << "Expected int scalar or vector type as Result Type: " |
| 113 | << spvOpcodeString(opcode); |
| 114 | |
| 115 | const uint32_t result_dimension = _.GetDimension(result_type); |
| 116 | const uint32_t result_bit_width = _.GetBitWidth(result_type); |
| 117 | |
| 118 | for (size_t operand_index = starting_index; |
| 119 | operand_index < inst->operands().size(); ++operand_index) { |
| 120 | const uint32_t type_id = _.GetOperandTypeId(inst, operand_index); |
| 121 | if (!type_id || |
| 122 | (!_.IsIntScalarType(type_id) && !_.IsIntVectorType(type_id) && |
| 123 | !_.IsIntCooperativeVectorNVType(type_id))) |
| 124 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 125 | << "Expected int scalar or vector as operand: " |
| 126 | << spvOpcodeString(opcode) << " operand index " << operand_index; |
| 127 | |
| 128 | if (_.GetDimension(type_id) != result_dimension) |
| 129 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 130 | << "Expected operands to have the same dimension " |
| 131 | << "as Result Type: " << spvOpcodeString(opcode) |
| 132 | << " operand index " << operand_index; |
| 133 | |
| 134 | if (_.GetBitWidth(type_id) != result_bit_width) |
| 135 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 136 | << "Expected operands to have the same bit width " |
| 137 | << "as Result Type: " << spvOpcodeString(opcode) |
| 138 | << " operand index " << operand_index; |
| 139 | } |
| 140 | return SPV_SUCCESS; |
| 141 | } |
| 142 | |
| 143 | spv_result_t ValidateBitFieldInsert(ValidationState_t& _, |
| 144 | const Instruction* inst) { |
no test coverage detected