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

Function ValidateReservedReadWritePipe

source/val/validate_pipe.cpp:117–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115}
116
117spv_result_t ValidateReservedReadWritePipe(ValidationState_t& _,
118 const Instruction* inst) {
119 const uint32_t result_type = inst->type_id();
120 if (!_.IsIntScalarType(result_type, 32)) {
121 return _.diag(SPV_ERROR_INVALID_DATA, inst)
122 << "Result Type must be a 32-bit int scalar.";
123 }
124
125 if (inst->opcode() == spv::Op::OpReservedReadPipe) {
126 if (auto error = ValidatePipeType(_, inst, 2, ValidPipeType::READ_ONLY))
127 return error;
128 } else if (inst->opcode() == spv::Op::OpReservedWritePipe) {
129 if (auto error = ValidatePipeType(_, inst, 2, ValidPipeType::WRITE_ONLY))
130 return error;
131 }
132
133 const Instruction* reserve_id = _.FindDef(_.GetOperandTypeId(inst, 3));
134 if (reserve_id->opcode() != spv::Op::OpTypeReserveId) {
135 return _.diag(SPV_ERROR_INVALID_DATA, inst)
136 << "Reserve Id type must be OpTypeReserveId.";
137 }
138
139 const uint32_t index_id = _.GetOperandTypeId(inst, 4);
140 if (!_.IsIntScalarType(index_id, 32)) {
141 return _.diag(SPV_ERROR_INVALID_DATA, inst)
142 << "Index must be a 32-bit scalar integer.";
143 }
144
145 const Instruction* pointer_type = _.FindDef(_.GetOperandTypeId(inst, 5));
146 if (pointer_type->opcode() != spv::Op::OpTypePointer) {
147 return _.diag(SPV_ERROR_INVALID_DATA, inst)
148 << "Pointer must be a type of OpTypePointer.";
149 }
150 if (pointer_type->GetOperandAs<spv::StorageClass>(1) !=
151 spv::StorageClass::Generic) {
152 return _.diag(SPV_ERROR_INVALID_DATA, inst)
153 << "Pointer must be a OpTypePointer with a Generic storage class.";
154 }
155
156 if (auto error = ValidatePacketSizeAlign(_, inst, 6, 7)) return error;
157
158 return SPV_SUCCESS;
159}
160
161spv_result_t ValidateReservePackets(ValidationState_t& _,
162 const Instruction* inst) {

Callers 1

PipePassFunction · 0.85

Calls 8

ValidatePipeTypeFunction · 0.85
ValidatePacketSizeAlignFunction · 0.85
IsIntScalarTypeMethod · 0.80
diagMethod · 0.80
FindDefMethod · 0.80
GetOperandTypeIdMethod · 0.80
type_idMethod · 0.45
opcodeMethod · 0.45

Tested by

no test coverage detected