module Futhark.Pass.FirstOrderTransform
  ( firstOrderTransform )
  where

import Futhark.Transform.FirstOrderTransform (transformFunDef, transformStms)
import Futhark.Representation.SOACS (SOACS, scopeOf)
import Futhark.Representation.Kernels (Kernels)
import Futhark.Pass

firstOrderTransform :: Pass SOACS Kernels
firstOrderTransform :: Pass SOACS Kernels
firstOrderTransform =
  String
-> String
-> (Prog SOACS -> PassM (Prog Kernels))
-> Pass SOACS Kernels
forall fromlore tolore.
String
-> String
-> (Prog fromlore -> PassM (Prog tolore))
-> Pass fromlore tolore
Pass
  String
"first order transform"
  String
"Transform all second-order array combinators to for-loops." ((Prog SOACS -> PassM (Prog Kernels)) -> Pass SOACS Kernels)
-> (Prog SOACS -> PassM (Prog Kernels)) -> Pass SOACS Kernels
forall a b. (a -> b) -> a -> b
$
  (Stms SOACS -> PassM (Stms Kernels))
-> (Stms Kernels -> FunDef SOACS -> PassM (FunDef Kernels))
-> Prog SOACS
-> PassM (Prog Kernels)
forall fromlore tolore.
(Stms fromlore -> PassM (Stms tolore))
-> (Stms tolore -> FunDef fromlore -> PassM (FunDef tolore))
-> Prog fromlore
-> PassM (Prog tolore)
intraproceduralTransformationWithConsts
  Stms SOACS -> PassM (Stms Kernels)
forall (m :: * -> *) tolore.
(MonadFreshNames m, Bindable tolore, BinderOps tolore,
 LetAttr SOACS ~ LetAttr tolore, CanBeAliased (Op tolore)) =>
Stms SOACS -> m (Stms tolore)
transformStms (Scope Kernels -> FunDef SOACS -> PassM (FunDef Kernels)
forall (m :: * -> *) tolore.
(MonadFreshNames m, Bindable tolore, BinderOps tolore,
 LetAttr SOACS ~ LetAttr tolore, CanBeAliased (Op tolore)) =>
Scope tolore -> FunDef SOACS -> m (FunDef tolore)
transformFunDef (Scope Kernels -> FunDef SOACS -> PassM (FunDef Kernels))
-> (Stms Kernels -> Scope Kernels)
-> Stms Kernels
-> FunDef SOACS
-> PassM (FunDef Kernels)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Stms Kernels -> Scope Kernels
forall lore a. Scoped lore a => a -> Scope lore
scopeOf)