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

Function ValidateShift

source/val/validate_bitwise.cpp:60–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60spv_result_t ValidateShift(ValidationState_t& _, const Instruction* inst,
61 uint32_t starting_index = 2) {
62 const spv::Op opcode = inst->opcode();
63 const uint32_t result_type = inst->type_id();
64 if (!_.IsIntScalarType(result_type) && !_.IsIntVectorType(result_type) &&
65 !_.IsIntCooperativeVectorNVType(result_type))
66 return _.diag(SPV_ERROR_INVALID_DATA, inst)
67 << "Expected int scalar or vector type as Result Type: "
68 << spvOpcodeString(opcode);
69
70 const uint32_t result_dimension = _.GetDimension(result_type);
71 const uint32_t base_type = _.GetOperandTypeId(inst, starting_index);
72 const uint32_t shift_type = _.GetOperandTypeId(inst, starting_index + 1);
73
74 if (!base_type ||
75 (!_.IsIntScalarType(base_type) && !_.IsIntVectorType(base_type) &&
76 !_.IsIntCooperativeVectorNVType(base_type)))
77 return _.diag(SPV_ERROR_INVALID_DATA, inst)
78 << "Expected Base to be int scalar or vector: "
79 << spvOpcodeString(opcode);
80
81 if (_.GetDimension(base_type) != result_dimension)
82 return _.diag(SPV_ERROR_INVALID_DATA, inst)
83 << "Expected Base to have the same dimension "
84 << "as Result Type: " << spvOpcodeString(opcode);
85
86 if (_.GetBitWidth(base_type) != _.GetBitWidth(result_type))
87 return _.diag(SPV_ERROR_INVALID_DATA, inst)
88 << "Expected Base to have the same bit width "
89 << "as Result Type: " << spvOpcodeString(opcode);
90
91 if (!shift_type ||
92 (!_.IsIntScalarType(shift_type) && !_.IsIntVectorType(shift_type) &&
93 !_.IsIntCooperativeVectorNVType(shift_type)))
94 return _.diag(SPV_ERROR_INVALID_DATA, inst)
95 << "Expected Shift to be int scalar or vector: "
96 << spvOpcodeString(opcode);
97
98 if (_.GetDimension(shift_type) != result_dimension)
99 return _.diag(SPV_ERROR_INVALID_DATA, inst)
100 << "Expected Shift to have the same dimension "
101 << "as Result Type: " << spvOpcodeString(opcode);
102 return SPV_SUCCESS;
103}
104
105spv_result_t ValidateBitwise(ValidationState_t& _, const Instruction* inst,
106 uint32_t starting_index = 2) {

Callers 1

BitwisePassFunction · 0.85

Calls 10

spvOpcodeStringFunction · 0.85
IsIntScalarTypeMethod · 0.80
IsIntVectorTypeMethod · 0.80
diagMethod · 0.80
GetDimensionMethod · 0.80
GetOperandTypeIdMethod · 0.80
GetBitWidthMethod · 0.80
opcodeMethod · 0.45
type_idMethod · 0.45

Tested by

no test coverage detected