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