{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeFamilies #-}

-- | A simple representation with SOACs and nested parallelism.
module Futhark.IR.SOACS
  ( SOACS,

    -- * Module re-exports
    module Futhark.IR.Prop,
    module Futhark.IR.Traversals,
    module Futhark.IR.Pretty,
    module Futhark.IR.Syntax,
    module Futhark.IR.SOACS.SOAC,
  )
where

import Futhark.Builder
import Futhark.Construct
import Futhark.IR.Pretty
import Futhark.IR.Prop
import Futhark.IR.SOACS.SOAC
import Futhark.IR.Syntax
import Futhark.IR.Traversals
import qualified Futhark.IR.TypeCheck as TC

-- | The rep for the basic representation.
data SOACS

instance RepTypes SOACS where
  type Op SOACS = SOAC SOACS

instance ASTRep SOACS where
  expTypesFromPat :: Pat (LetDec SOACS) -> m [BranchType SOACS]
expTypesFromPat = [ExtType] -> m [ExtType]
forall (m :: * -> *) a. Monad m => a -> m a
return ([ExtType] -> m [ExtType])
-> (Pat Type -> [ExtType]) -> Pat Type -> m [ExtType]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pat Type -> [ExtType]
forall dec. Typed dec => Pat dec -> [ExtType]
expExtTypesFromPat

instance TC.CheckableOp SOACS where
  checkOp :: OpWithAliases (Op SOACS) -> TypeM SOACS ()
checkOp = OpWithAliases (Op SOACS) -> TypeM SOACS ()
forall rep. Checkable rep => SOAC (Aliases rep) -> TypeM rep ()
typeCheckSOAC

instance TC.Checkable SOACS

instance Buildable SOACS where
  mkBody :: Stms SOACS -> Result -> Body SOACS
mkBody = BodyDec SOACS -> Stms SOACS -> Result -> Body SOACS
forall rep. BodyDec rep -> Stms rep -> Result -> Body rep
Body ()
  mkExpPat :: [Ident] -> Exp SOACS -> Pat (LetDec SOACS)
mkExpPat [Ident]
merge Exp SOACS
_ = [Ident] -> Pat Type
basicPat [Ident]
merge
  mkExpDec :: Pat (LetDec SOACS) -> Exp SOACS -> ExpDec SOACS
mkExpDec Pat (LetDec SOACS)
_ Exp SOACS
_ = ()
  mkLetNames :: [VName] -> Exp SOACS -> m (Stm SOACS)
mkLetNames = [VName] -> Exp SOACS -> m (Stm SOACS)
forall rep (m :: * -> *).
(ExpDec rep ~ (), LetDec rep ~ Type, MonadFreshNames m,
 TypedOp (Op rep), HasScope rep m) =>
[VName] -> Exp rep -> m (Stm rep)
simpleMkLetNames

instance BuilderOps SOACS

instance PrettyRep SOACS