@@ -226,7 +226,8 @@ class SPIRVInstTemplateBase : public SPIRVInstruction {
226
226
virtual void init () {}
227
227
virtual void initImpl (Op OC, bool HasId = true , SPIRVWord WC = 0 ,
228
228
bool VariWC = false , unsigned Lit1 = ~0U ,
229
- unsigned Lit2 = ~0U , unsigned Lit3 = ~0U ) {
229
+ unsigned Lit2 = ~0U , unsigned Lit3 = ~0U ,
230
+ unsigned Lit4 = ~0U ) {
230
231
OpCode = OC;
231
232
if (!HasId) {
232
233
setHasNoId ();
@@ -238,6 +239,7 @@ class SPIRVInstTemplateBase : public SPIRVInstruction {
238
239
addLit (Lit1);
239
240
addLit (Lit2);
240
241
addLit (Lit3);
242
+ addLit (Lit4);
241
243
}
242
244
bool isOperandLiteral (unsigned I) const override { return Lit.count (I); }
243
245
void addLit (unsigned L) {
@@ -364,14 +366,16 @@ class SPIRVInstTemplateBase : public SPIRVInstruction {
364
366
365
367
template <typename BT = SPIRVInstTemplateBase, Op OC = OpNop, bool HasId = true ,
366
368
SPIRVWord WC = 0 , bool HasVariableWC = false , unsigned Literal1 = ~0U ,
367
- unsigned Literal2 = ~0U , unsigned Literal3 = ~0U >
369
+ unsigned Literal2 = ~0U , unsigned Literal3 = ~0U ,
370
+ unsigned Literal4 = ~0U >
368
371
class SPIRVInstTemplate : public BT {
369
372
public:
370
373
typedef BT BaseTy;
371
374
SPIRVInstTemplate () { init (); }
372
375
~SPIRVInstTemplate () override {}
373
376
void init () override {
374
- this ->initImpl (OC, HasId, WC, HasVariableWC, Literal1, Literal2, Literal3);
377
+ this ->initImpl (OC, HasId, WC, HasVariableWC, Literal1, Literal2, Literal3,
378
+ Literal4);
375
379
}
376
380
};
377
381
@@ -3854,5 +3858,85 @@ template <Op OC> class SPIRVReadClockKHRInstBase : public SPIRVUnaryInst<OC> {
3854
3858
_SPIRV_OP (ReadClockKHR)
3855
3859
#undef _SPIRV_OP
3856
3860
3861
+ class SPIRVTaskSequenceINTELInstBase : public SPIRVInstTemplateBase {
3862
+ public:
3863
+ std::optional<ExtensionID> getRequiredExtension () const override {
3864
+ return ExtensionID::SPV_INTEL_task_sequence;
3865
+ }
3866
+ };
3867
+
3868
+ class SPIRVTaskSequenceINTELInst : public SPIRVTaskSequenceINTELInstBase {
3869
+ public:
3870
+ SPIRVCapVec getRequiredCapability () const override {
3871
+ return getVec (internal::CapabilityTaskSequenceINTEL);
3872
+ }
3873
+ };
3874
+
3875
+ class SPIRVTaskSequenceCreateINTELInst : public SPIRVTaskSequenceINTELInst {
3876
+ protected:
3877
+ void validate () const override {
3878
+ SPIRVInstruction::validate ();
3879
+ std::string InstName = " TaskSequenceCreateINTEL" ;
3880
+ SPIRVErrorLog &SPVErrLog = this ->getModule ()->getErrorLog ();
3881
+
3882
+ SPIRVType *ResTy = this ->getType ();
3883
+ SPVErrLog.checkError (
3884
+ ResTy->isTypeTaskSequenceINTEL (), SPIRVEC_InvalidInstruction,
3885
+ InstName + " \n Result must be TaskSequenceINTEL type\n " );
3886
+
3887
+ SPIRVValue *Func =
3888
+ const_cast <SPIRVTaskSequenceCreateINTELInst *>(this )->getOperand (0 );
3889
+ SPVErrLog.checkError (
3890
+ Func->getOpCode () == OpFunction, SPIRVEC_InvalidInstruction,
3891
+ InstName + " \n First argument is expected to be a function.\n " );
3892
+
3893
+ SPIRVConstant *PipelinedConst = static_cast <SPIRVConstant *>(
3894
+ const_cast <SPIRVTaskSequenceCreateINTELInst *>(this )->getOperand (1 ));
3895
+ const int Pipelined = PipelinedConst->getZExtIntValue ();
3896
+ SPVErrLog.checkError (Pipelined >= -1 , SPIRVEC_InvalidInstruction,
3897
+ InstName + " \n Pipeline must be a 32 bit integer with "
3898
+ " the value bigger or equal to -1.\n " );
3899
+
3900
+ const int ClusterMode =
3901
+ static_cast <SPIRVConstant *>(
3902
+ const_cast <SPIRVTaskSequenceCreateINTELInst *>(this )->getOperand (2 ))
3903
+ ->getZExtIntValue ();
3904
+ SPVErrLog.checkError (
3905
+ ClusterMode >= -1 && ClusterMode <= 1 , SPIRVEC_InvalidInstruction,
3906
+ InstName + " \n ClusterMode valid values are -1, 0, 1.\n " );
3907
+
3908
+ const uint32_t GetCapacity =
3909
+ static_cast <SPIRVConstant *>(
3910
+ const_cast <SPIRVTaskSequenceCreateINTELInst *>(this )->getOperand (3 ))
3911
+ ->getZExtIntValue ();
3912
+ SPVErrLog.checkError (
3913
+ GetCapacity, SPIRVEC_InvalidInstruction,
3914
+ InstName + " \n GetCapacity must be unsigned 32 bit integer.\n " );
3915
+
3916
+ const uint32_t AsyncCapacity =
3917
+ static_cast <SPIRVConstant *>(
3918
+ const_cast <SPIRVTaskSequenceCreateINTELInst *>(this )->getOperand (4 ))
3919
+ ->getZExtIntValue ();
3920
+ SPVErrLog.checkError (
3921
+ AsyncCapacity, SPIRVEC_InvalidInstruction,
3922
+ InstName + " \n AsyncCapacity must be unsigned 32 bit integer.\n " );
3923
+ }
3924
+ };
3925
+
3926
+ #define _SPIRV_OP (x, ...) \
3927
+ typedef SPIRVInstTemplate<SPIRVTaskSequenceINTELInst, \
3928
+ internal::Op##x##INTEL, __VA_ARGS__> \
3929
+ SPIRV##x##INTEL;
3930
+ _SPIRV_OP (TaskSequenceAsync, false , 2 , true )
3931
+ _SPIRV_OP(TaskSequenceGet, true , 4 , false )
3932
+ _SPIRV_OP(TaskSequenceRelease, false , 2 , false )
3933
+ #undef _SPIRV_OP
3934
+ #define _SPIRV_OP (x, ...) \
3935
+ typedef SPIRVInstTemplate<SPIRVTaskSequenceCreateINTELInst, \
3936
+ internal::Op##x##INTEL, __VA_ARGS__> \
3937
+ SPIRV##x##INTEL;
3938
+ _SPIRV_OP (TaskSequenceCreate, true , 8 , false , 1 , 2 , 3 , 4 )
3939
+ #undef _SPIRV_OP
3940
+
3857
3941
} // namespace SPIRV
3858
3942
#endif // SPIRV_LIBSPIRV_SPIRVINSTRUCTION_H
0 commit comments