{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
module Futhark.Representation.Seq
(
Seq
, simplifyProg
, module Futhark.Representation.AST.Attributes
, module Futhark.Representation.AST.Traversals
, module Futhark.Representation.AST.Pretty
, module Futhark.Representation.AST.Syntax
)
where
import Futhark.Pass
import Futhark.Representation.AST.Syntax
import Futhark.Representation.AST.Attributes
import Futhark.Representation.AST.Traversals
import Futhark.Representation.AST.Pretty
import Futhark.Binder
import Futhark.Construct
import qualified Futhark.TypeCheck as TypeCheck
import qualified Futhark.Optimise.Simplify.Engine as Engine
import qualified Futhark.Optimise.Simplify as Simplify
import Futhark.Optimise.Simplify.Rules
data Seq
instance Annotations Seq where
type Op Seq = ()
instance Attributes Seq where
expTypesFromPattern :: Pattern Seq -> m [BranchType Seq]
expTypesFromPattern = [ExtType] -> m [ExtType]
forall (m :: * -> *) a. Monad m => a -> m a
return ([ExtType] -> m [ExtType])
-> (PatternT Type -> [ExtType]) -> PatternT Type -> m [ExtType]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PatternT Type -> [ExtType]
forall attr. Typed attr => PatternT attr -> [ExtType]
expExtTypesFromPattern
instance TypeCheck.CheckableOp Seq where
checkOp :: OpWithAliases (Op Seq) -> TypeM Seq ()
checkOp = OpWithAliases (Op Seq) -> TypeM Seq ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure
instance TypeCheck.Checkable Seq where
instance Bindable Seq where
mkBody :: Stms Seq -> Result -> Body Seq
mkBody = BodyAttr Seq -> Stms Seq -> Result -> Body Seq
forall lore. BodyAttr lore -> Stms lore -> Result -> BodyT lore
Body ()
mkExpPat :: [Ident] -> [Ident] -> Exp Seq -> Pattern Seq
mkExpPat [Ident]
ctx [Ident]
val Exp Seq
_ = [Ident] -> [Ident] -> PatternT Type
basicPattern [Ident]
ctx [Ident]
val
mkExpAttr :: Pattern Seq -> Exp Seq -> ExpAttr Seq
mkExpAttr Pattern Seq
_ Exp Seq
_ = ()
mkLetNames :: [VName] -> Exp Seq -> m (Stm Seq)
mkLetNames = [VName] -> Exp Seq -> m (Stm Seq)
forall lore (m :: * -> *).
(ExpAttr lore ~ (), LetAttr lore ~ Type, MonadFreshNames m,
TypedOp (Op lore), HasScope lore m) =>
[VName] -> Exp lore -> m (Stm lore)
simpleMkLetNames
instance BinderOps Seq where
mkExpAttrB :: Pattern Seq -> Exp Seq -> m (ExpAttr Seq)
mkExpAttrB = Pattern Seq -> Exp Seq -> m (ExpAttr Seq)
forall (m :: * -> *).
(MonadBinder m, Bindable (Lore m)) =>
Pattern (Lore m) -> Exp (Lore m) -> m (ExpAttr (Lore m))
bindableMkExpAttrB
mkBodyB :: Stms Seq -> Result -> m (Body Seq)
mkBodyB = Stms Seq -> Result -> m (Body Seq)
forall (m :: * -> *).
(MonadBinder m, Bindable (Lore m)) =>
Stms (Lore m) -> Result -> m (Body (Lore m))
bindableMkBodyB
mkLetNamesB :: [VName] -> Exp Seq -> m (Stm Seq)
mkLetNamesB = [VName] -> Exp Seq -> m (Stm Seq)
forall (m :: * -> *).
(MonadBinder m, Bindable (Lore m)) =>
[VName] -> Exp (Lore m) -> m (Stm (Lore m))
bindableMkLetNamesB
instance PrettyLore Seq where
instance BinderOps (Engine.Wise Seq) where
mkExpAttrB :: Pattern (Wise Seq) -> Exp (Wise Seq) -> m (ExpAttr (Wise Seq))
mkExpAttrB = Pattern (Wise Seq) -> Exp (Wise Seq) -> m (ExpAttr (Wise Seq))
forall (m :: * -> *).
(MonadBinder m, Bindable (Lore m)) =>
Pattern (Lore m) -> Exp (Lore m) -> m (ExpAttr (Lore m))
bindableMkExpAttrB
mkBodyB :: Stms (Wise Seq) -> Result -> m (Body (Wise Seq))
mkBodyB = Stms (Wise Seq) -> Result -> m (Body (Wise Seq))
forall (m :: * -> *).
(MonadBinder m, Bindable (Lore m)) =>
Stms (Lore m) -> Result -> m (Body (Lore m))
bindableMkBodyB
mkLetNamesB :: [VName] -> Exp (Wise Seq) -> m (Stm (Wise Seq))
mkLetNamesB = [VName] -> Exp (Wise Seq) -> m (Stm (Wise Seq))
forall (m :: * -> *).
(MonadBinder m, Bindable (Lore m)) =>
[VName] -> Exp (Lore m) -> m (Stm (Lore m))
bindableMkLetNamesB
simpleSeq :: Simplify.SimpleOps Seq
simpleSeq :: SimpleOps Seq
simpleSeq = SimplifyOp Seq (Op Seq) -> SimpleOps Seq
forall lore.
(SimplifiableLore lore, Bindable lore) =>
SimplifyOp lore (Op lore) -> SimpleOps lore
Simplify.bindableSimpleOps (SimpleM Seq ((), Stms (Wise Seq))
-> () -> SimpleM Seq ((), Stms (Wise Seq))
forall a b. a -> b -> a
const (SimpleM Seq ((), Stms (Wise Seq))
-> () -> SimpleM Seq ((), Stms (Wise Seq)))
-> SimpleM Seq ((), Stms (Wise Seq))
-> ()
-> SimpleM Seq ((), Stms (Wise Seq))
forall a b. (a -> b) -> a -> b
$ ((), Stms (Wise Seq)) -> SimpleM Seq ((), Stms (Wise Seq))
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((), Stms (Wise Seq)
forall a. Monoid a => a
mempty))
simplifyProg :: Prog Seq -> PassM (Prog Seq)
simplifyProg :: Prog Seq -> PassM (Prog Seq)
simplifyProg = SimpleOps Seq
-> RuleBook (Wise Seq)
-> HoistBlockers Seq
-> Prog Seq
-> PassM (Prog Seq)
forall lore.
SimplifiableLore lore =>
SimpleOps lore
-> RuleBook (Wise lore)
-> HoistBlockers lore
-> Prog lore
-> PassM (Prog lore)
Simplify.simplifyProg SimpleOps Seq
simpleSeq RuleBook (Wise Seq)
forall lore. (BinderOps lore, Aliased lore) => RuleBook lore
standardRules HoistBlockers Seq
forall lore. HoistBlockers lore
blockers
where blockers :: HoistBlockers lore
blockers = HoistBlockers lore
forall lore. HoistBlockers lore
Engine.noExtraHoistBlockers