@@ -3579,5 +3579,63 @@ template <Op OC> class SPIRVReadClockKHRInstBase : public SPIRVUnaryInst<OC> {
35793579_SPIRV_OP (ReadClockKHR)
35803580#undef _SPIRV_OP
35813581
3582+ template <Op OC> class SPIRVFSigmoidINTELInstBase : public SPIRVUnaryInst <OC> {
3583+ protected:
3584+ SPIRVCapVec getRequiredCapability () const override {
3585+ return getVec (internal::CapabilitySigmoidINTEL);
3586+ }
3587+
3588+ llvm::Optional<ExtensionID> getRequiredExtension () const override {
3589+ return ExtensionID::SPV_INTEL_sigmoid;
3590+ }
3591+
3592+ void validate () const override {
3593+ SPIRVUnaryInst<OC>::validate ();
3594+
3595+ SPIRVType *ResCompTy = this ->getType ();
3596+ SPIRVWord ResCompCount = 1 ;
3597+ if (ResCompTy->isTypeVector ()) {
3598+ ResCompCount = ResCompTy->getVectorComponentCount ();
3599+ ResCompTy = ResCompTy->getVectorComponentType ();
3600+ }
3601+
3602+ // validate is a const method, whilst getOperand is non-const method
3603+ // because it may call a method of class Module that may modify LiteralMap
3604+ // of Module field. That modification is not impacting validate method for
3605+ // these instructions, so const_cast is safe here.
3606+ using SPVFSigmoidTy = SPIRVFSigmoidINTELInstBase<OC>;
3607+ const SPIRVValue *Input = const_cast <SPVFSigmoidTy *>(this )->getOperand (0 );
3608+
3609+ SPIRVType *InCompTy = Input->getType ();
3610+ SPIRVWord InCompCount = 1 ;
3611+ if (InCompTy->isTypeVector ()) {
3612+ InCompCount = InCompTy->getVectorComponentCount ();
3613+ InCompTy = InCompTy->getVectorComponentType ();
3614+ }
3615+
3616+ auto InstName = OpCodeNameMap::map (OC);
3617+ SPIRVErrorLog &SPVErrLog = this ->getModule ()->getErrorLog ();
3618+
3619+ SPVErrLog.checkError (
3620+ ResCompTy->isTypeFloat (16 ) || ResCompTy->isTypeFloat (32 ) ||
3621+ ResCompTy->isTypeFloat (16 , FPEncodingBFloat16KHR),
3622+ SPIRVEC_InvalidInstruction,
3623+ InstName + " \n Result value must be a scalar or vector of floating-point"
3624+ " 16-bit or 32-bit type\n " );
3625+ SPVErrLog.checkError (
3626+ ResCompTy == InCompTy, SPIRVEC_InvalidInstruction,
3627+ InstName +
3628+ " \n Input type must have the same component type as result type\n " );
3629+ SPVErrLog.checkError (
3630+ ResCompCount == InCompCount, SPIRVEC_InvalidInstruction,
3631+ InstName + " \n Input type must have the same number of components as "
3632+ " result type\n " );
3633+ }
3634+ };
3635+
3636+ #define _SPIRV_OP (x, ...) \
3637+ typedef SPIRVFSigmoidINTELInstBase<internal::Op##x> SPIRV##x;
3638+ _SPIRV_OP (FSigmoidINTEL)
3639+ #undef _SPIRV_OP
35823640} // namespace SPIRV
35833641#endif // SPIRV_LIBSPIRV_SPIRVINSTRUCTION_H
0 commit comments