@@ -4269,5 +4269,64 @@ class SPIRVPredicatedIOINTELInst : public SPIRVInstTemplateBase {
42694269_SPIRV_OP (PredicatedLoad, true , 6 , true )
42704270_SPIRV_OP(PredicatedStore, false , 4 , true )
42714271#undef _SPIRV_OP
4272+
4273+ template <Op OC> class SPIRVFSigmoidINTELInstBase : public SPIRVUnaryInst <OC> {
4274+ protected:
4275+ SPIRVCapVec getRequiredCapability () const override {
4276+ return getVec (internal::CapabilitySigmoidINTEL);
4277+ }
4278+
4279+ std::optional<ExtensionID> getRequiredExtension () const override {
4280+ return ExtensionID::SPV_INTEL_sigmoid;
4281+ }
4282+
4283+ void validate () const override {
4284+ SPIRVUnaryInst<OC>::validate ();
4285+
4286+ SPIRVType *ResCompTy = this ->getType ();
4287+ SPIRVWord ResCompCount = 1 ;
4288+ if (ResCompTy->isTypeVector ()) {
4289+ ResCompCount = ResCompTy->getVectorComponentCount ();
4290+ ResCompTy = ResCompTy->getVectorComponentType ();
4291+ }
4292+
4293+ // validate is a const method, whilst getOperand is non-const method
4294+ // because it may call a method of class Module that may modify LiteralMap
4295+ // of Module field. That modification is not impacting validate method for
4296+ // these instructions, so const_cast is safe here.
4297+ using SPVFSigmoidTy = SPIRVFSigmoidINTELInstBase<OC>;
4298+ const SPIRVValue *Input = const_cast <SPVFSigmoidTy *>(this )->getOperand (0 );
4299+
4300+ SPIRVType *InCompTy = Input->getType ();
4301+ SPIRVWord InCompCount = 1 ;
4302+ if (InCompTy->isTypeVector ()) {
4303+ InCompCount = InCompTy->getVectorComponentCount ();
4304+ InCompTy = InCompTy->getVectorComponentType ();
4305+ }
4306+
4307+ auto InstName = OpCodeNameMap::map (OC);
4308+ SPIRVErrorLog &SPVErrLog = this ->getModule ()->getErrorLog ();
4309+
4310+ SPVErrLog.checkError (
4311+ ResCompTy->isTypeFloat (16 ) || ResCompTy->isTypeFloat (32 ) ||
4312+ ResCompTy->isTypeFloat (16 , FPEncodingBFloat16KHR),
4313+ SPIRVEC_InvalidInstruction,
4314+ InstName + " \n Result value must be a scalar or vector of floating-point"
4315+ " 16-bit or 32-bit type\n " );
4316+ SPVErrLog.checkError (
4317+ ResCompTy == InCompTy, SPIRVEC_InvalidInstruction,
4318+ InstName +
4319+ " \n Input type must have the same component type as result type\n " );
4320+ SPVErrLog.checkError (
4321+ ResCompCount == InCompCount, SPIRVEC_InvalidInstruction,
4322+ InstName + " \n Input type must have the same number of components as "
4323+ " result type\n " );
4324+ }
4325+ };
4326+
4327+ #define _SPIRV_OP (x, ...) \
4328+ typedef SPIRVFSigmoidINTELInstBase<internal::Op##x> SPIRV##x;
4329+ _SPIRV_OP (FSigmoidINTEL)
4330+ #undef _SPIRV_OP
42724331} // namespace SPIRV
42734332#endif // SPIRV_LIBSPIRV_SPIRVINSTRUCTION_H
0 commit comments