@@ -4484,5 +4484,64 @@ class SPIRVPredicatedIOINTELInst : public SPIRVInstTemplateBase {
44844484_SPIRV_OP (PredicatedLoad, true , 6 , true )
44854485_SPIRV_OP(PredicatedStore, false , 4 , true )
44864486#undef _SPIRV_OP
4487+
4488+ template <Op OC> class SPIRVFSigmoidINTELInstBase : public SPIRVUnaryInst <OC> {
4489+ protected:
4490+ SPIRVCapVec getRequiredCapability () const override {
4491+ return getVec (internal::CapabilitySigmoidINTEL);
4492+ }
4493+
4494+ std::optional<ExtensionID> getRequiredExtension () const override {
4495+ return ExtensionID::SPV_INTEL_sigmoid;
4496+ }
4497+
4498+ void validate () const override {
4499+ SPIRVUnaryInst<OC>::validate ();
4500+
4501+ SPIRVType *ResCompTy = this ->getType ();
4502+ SPIRVWord ResCompCount = 1 ;
4503+ if (ResCompTy->isTypeVector ()) {
4504+ ResCompCount = ResCompTy->getVectorComponentCount ();
4505+ ResCompTy = ResCompTy->getVectorComponentType ();
4506+ }
4507+
4508+ // validate is a const method, whilst getOperand is non-const method
4509+ // because it may call a method of class Module that may modify LiteralMap
4510+ // of Module field. That modification is not impacting validate method for
4511+ // these instructions, so const_cast is safe here.
4512+ using SPVFSigmoidTy = SPIRVFSigmoidINTELInstBase<OC>;
4513+ const SPIRVValue *Input = const_cast <SPVFSigmoidTy *>(this )->getOperand (0 );
4514+
4515+ SPIRVType *InCompTy = Input->getType ();
4516+ SPIRVWord InCompCount = 1 ;
4517+ if (InCompTy->isTypeVector ()) {
4518+ InCompCount = InCompTy->getVectorComponentCount ();
4519+ InCompTy = InCompTy->getVectorComponentType ();
4520+ }
4521+
4522+ auto InstName = OpCodeNameMap::map (OC);
4523+ SPIRVErrorLog &SPVErrLog = this ->getModule ()->getErrorLog ();
4524+
4525+ SPVErrLog.checkError (
4526+ ResCompTy->isTypeFloat (16 ) || ResCompTy->isTypeFloat (32 ) ||
4527+ ResCompTy->isTypeFloat (16 , FPEncodingBFloat16KHR),
4528+ SPIRVEC_InvalidInstruction,
4529+ InstName + " \n Result value must be a scalar or vector of floating-point"
4530+ " 16-bit or 32-bit type\n " );
4531+ SPVErrLog.checkError (
4532+ ResCompTy == InCompTy, SPIRVEC_InvalidInstruction,
4533+ InstName +
4534+ " \n Input type must have the same component type as result type\n " );
4535+ SPVErrLog.checkError (
4536+ ResCompCount == InCompCount, SPIRVEC_InvalidInstruction,
4537+ InstName + " \n Input type must have the same number of components as "
4538+ " result type\n " );
4539+ }
4540+ };
4541+
4542+ #define _SPIRV_OP (x, ...) \
4543+ typedef SPIRVFSigmoidINTELInstBase<internal::Op##x> SPIRV##x;
4544+ _SPIRV_OP (FSigmoidINTEL)
4545+ #undef _SPIRV_OP
44874546} // namespace SPIRV
44884547#endif // SPIRV_LIBSPIRV_SPIRVINSTRUCTION_H
0 commit comments