@@ -4200,5 +4200,101 @@ _SPIRV_OP(ConvertHandleToSamplerINTEL)
4200
4200
_SPIRV_OP(ConvertHandleToSampledImageINTEL)
4201
4201
#undef _SPIRV_OP
4202
4202
4203
+ class SPIRVUntypedPrefetchKHR : public SPIRVInstruction {
4204
+ public:
4205
+ static const Op OC = OpUntypedPrefetchKHR;
4206
+ static const SPIRVWord FixedWordCount = 3 ;
4207
+
4208
+ SPIRVUntypedPrefetchKHR (SPIRVType *Ty, std::vector<SPIRVWord> &TheArgs,
4209
+ SPIRVBasicBlock *BB)
4210
+ : SPIRVInstruction(FixedWordCount, OC, BB) {
4211
+ setHasNoId ();
4212
+ setHasNoType ();
4213
+ PtrTy = TheArgs[0 ];
4214
+ NumBytes = TheArgs[1 ];
4215
+ if (TheArgs.size () > 2 )
4216
+ RW.push_back (TheArgs[2 ]);
4217
+ if (TheArgs.size () > 3 )
4218
+ Locality.push_back (TheArgs[3 ]);
4219
+ if (TheArgs.size () > 4 )
4220
+ CacheTy.push_back (TheArgs[4 ]);
4221
+ assert (BB && " Invalid BB" );
4222
+ validate ();
4223
+ }
4224
+
4225
+ SPIRVUntypedPrefetchKHR () : SPIRVInstruction(OC) {
4226
+ setHasNoId ();
4227
+ setHasNoType ();
4228
+ }
4229
+
4230
+ void validate () const override {
4231
+ SPIRVInstruction::validate ();
4232
+ SPIRVErrorLog &SPVErrLog = this ->getModule ()->getErrorLog ();
4233
+ std::string InstName = " OpUntypedPrefetchKHR" ;
4234
+ SPVErrLog.checkError (getValueType (PtrTy)->isTypePointer (),
4235
+ SPIRVEC_InvalidInstruction,
4236
+ InstName + " \n First argument must be a pointer\n " );
4237
+ SPVErrLog.checkError (
4238
+ getValueType (PtrTy)->getPointerStorageClass () ==
4239
+ StorageClassCrossWorkgroup,
4240
+ SPIRVEC_InvalidInstruction,
4241
+ InstName + " \n First argument must be a pointer in CrossWorkgroup "
4242
+ " storage class\n " );
4243
+ SPVErrLog.checkError (
4244
+ getValueType (NumBytes)->isTypeInt (), SPIRVEC_InvalidInstruction,
4245
+ InstName + " \n Second argument (Num Bytes) must be an integer\n " );
4246
+ SPVErrLog.checkError (
4247
+ RW.empty () || (RW.size () == 1 && getValueType (RW[0 ])->isTypeInt ()),
4248
+ SPIRVEC_InvalidInstruction,
4249
+ InstName + " \n Third argument (RW) must be an integer\n " );
4250
+ SPVErrLog.checkError (
4251
+ Locality.empty () ||
4252
+ (Locality.size () == 1 && getValueType (Locality[0 ])->isTypeInt ()),
4253
+ SPIRVEC_InvalidInstruction,
4254
+ InstName + " \n Fourth argument (Locality) must be an integer\n " );
4255
+ SPVErrLog.checkError (
4256
+ CacheTy.empty () ||
4257
+ (CacheTy.size () == 1 && getValueType (CacheTy[0 ])->isTypeInt ()),
4258
+ SPIRVEC_InvalidInstruction,
4259
+ InstName + " \n Fifth argument (Cache Type) must be an integer\n " );
4260
+ }
4261
+
4262
+ void setWordCount (SPIRVWord TheWordCount) override {
4263
+ SPIRVEntry::setWordCount (TheWordCount);
4264
+ if (TheWordCount > 3 )
4265
+ RW.resize (1 );
4266
+ if (TheWordCount > 4 )
4267
+ Locality.resize (1 );
4268
+ if (TheWordCount > 5 )
4269
+ CacheTy.resize (1 );
4270
+ }
4271
+ const std::vector<SPIRVWord> getArguments () const {
4272
+ std::vector<SPIRVWord> Args;
4273
+ Args.push_back (PtrTy);
4274
+ Args.push_back (NumBytes);
4275
+ if (!RW.empty ())
4276
+ Args.push_back (RW[0 ]);
4277
+ if (!Locality.empty ())
4278
+ Args.push_back (Locality[0 ]);
4279
+ if (!CacheTy.empty ())
4280
+ Args.push_back (CacheTy[0 ]);
4281
+ return Args;
4282
+ }
4283
+
4284
+ SPIRVCapVec getRequiredCapability () const override {
4285
+ return getVec (CapabilityUntypedPointersKHR);
4286
+ }
4287
+ std::optional<ExtensionID> getRequiredExtension () const override {
4288
+ return ExtensionID::SPV_KHR_untyped_pointers;
4289
+ }
4290
+ _SPIRV_DEF_ENCDEC5 (PtrTy, NumBytes, RW, Locality, CacheTy)
4291
+ protected:
4292
+ SPIRVId PtrTy;
4293
+ SPIRVId NumBytes;
4294
+ std::vector<SPIRVId> RW;
4295
+ std::vector<SPIRVId> Locality;
4296
+ std::vector<SPIRVId> CacheTy;
4297
+ };
4298
+
4203
4299
} // namespace SPIRV
4204
4300
#endif // SPIRV_LIBSPIRV_SPIRVINSTRUCTION_H
0 commit comments