@@ -4120,5 +4120,64 @@ class SPIRVPredicatedIOINTELInst : public SPIRVInstTemplateBase {
41204120_SPIRV_OP (PredicatedLoad, true , 6 , true )
41214121_SPIRV_OP(PredicatedStore, false , 4 , true )
41224122#undef _SPIRV_OP
4123+
4124+ template <Op OC> class SPIRVFSigmoidINTELInstBase : public SPIRVUnaryInst <OC> {
4125+ protected:
4126+ SPIRVCapVec getRequiredCapability () const override {
4127+ return getVec (internal::CapabilitySigmoidINTEL);
4128+ }
4129+
4130+ std::optional<ExtensionID> getRequiredExtension () const override {
4131+ return ExtensionID::SPV_INTEL_sigmoid;
4132+ }
4133+
4134+ void validate () const override {
4135+ SPIRVUnaryInst<OC>::validate ();
4136+
4137+ SPIRVType *ResCompTy = this ->getType ();
4138+ SPIRVWord ResCompCount = 1 ;
4139+ if (ResCompTy->isTypeVector ()) {
4140+ ResCompCount = ResCompTy->getVectorComponentCount ();
4141+ ResCompTy = ResCompTy->getVectorComponentType ();
4142+ }
4143+
4144+ // validate is a const method, whilst getOperand is non-const method
4145+ // because it may call a method of class Module that may modify LiteralMap
4146+ // of Module field. That modification is not impacting validate method for
4147+ // these instructions, so const_cast is safe here.
4148+ using SPVFSigmoidTy = SPIRVFSigmoidINTELInstBase<OC>;
4149+ const SPIRVValue *Input = const_cast <SPVFSigmoidTy *>(this )->getOperand (0 );
4150+
4151+ SPIRVType *InCompTy = Input->getType ();
4152+ SPIRVWord InCompCount = 1 ;
4153+ if (InCompTy->isTypeVector ()) {
4154+ InCompCount = InCompTy->getVectorComponentCount ();
4155+ InCompTy = InCompTy->getVectorComponentType ();
4156+ }
4157+
4158+ auto InstName = OpCodeNameMap::map (OC);
4159+ SPIRVErrorLog &SPVErrLog = this ->getModule ()->getErrorLog ();
4160+
4161+ SPVErrLog.checkError (
4162+ ResCompTy->isTypeFloat (16 ) || ResCompTy->isTypeFloat (32 ) ||
4163+ ResCompTy->isTypeFloat (16 , FPEncodingBFloat16KHR),
4164+ SPIRVEC_InvalidInstruction,
4165+ InstName + " \n Result value must be a scalar or vector of floating-point"
4166+ " 16-bit or 32-bit type\n " );
4167+ SPVErrLog.checkError (
4168+ ResCompTy == InCompTy, SPIRVEC_InvalidInstruction,
4169+ InstName +
4170+ " \n Input type must have the same component type as result type\n " );
4171+ SPVErrLog.checkError (
4172+ ResCompCount == InCompCount, SPIRVEC_InvalidInstruction,
4173+ InstName + " \n Input type must have the same number of components as "
4174+ " result type\n " );
4175+ }
4176+ };
4177+
4178+ #define _SPIRV_OP (x, ...) \
4179+ typedef SPIRVFSigmoidINTELInstBase<internal::Op##x> SPIRV##x;
4180+ _SPIRV_OP (FSigmoidINTEL)
4181+ #undef _SPIRV_OP
41234182} // namespace SPIRV
41244183#endif // SPIRV_LIBSPIRV_SPIRVINSTRUCTION_H
0 commit comments