futhark-0.22.2: An optimising compiler for a functional, array-oriented language.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Futhark.Transform.FirstOrderTransform

Description

The code generator cannot handle the array combinators (map and friends), so this module was written to transform them into the equivalent do-loops. The transformation is currently rather naive, and - it's certainly worth considering when we can express such transformations in-place.

Synopsis

Documentation

transformFunDef :: (MonadFreshNames m, FirstOrderRep torep) => Scope torep -> FunDef SOACS -> m (FunDef torep) Source #

First-order-transform a single function, with the given scope provided by top-level constants.

transformConsts :: (MonadFreshNames m, FirstOrderRep torep) => Stms SOACS -> m (Stms torep) Source #

First-order-transform these top-level constants.

type FirstOrderRep rep = (Buildable rep, BuilderOps rep, LetDec SOACS ~ LetDec rep, LParamInfo SOACS ~ LParamInfo rep, CanBeAliased (Op rep)) Source #

The constraints that must hold for a rep in order to be the target of first-order transformation.

type Transformer m = (MonadBuilder m, LocalScope (Rep m) m, Buildable (Rep m), BuilderOps (Rep m), LParamInfo SOACS ~ LParamInfo (Rep m), CanBeAliased (Op (Rep m))) Source #

The constraints that a monad must uphold in order to be used for first-order transformation.

transformStmRecursively :: (Transformer m, LetDec (Rep m) ~ LetDec SOACS) => Stm SOACS -> m () Source #

First transform any nested Body or Lambda elements, then apply transformSOAC if the expression is a SOAC.

transformLambda :: (MonadFreshNames m, Buildable rep, BuilderOps rep, LocalScope somerep m, SameScope somerep rep, LetDec rep ~ LetDec SOACS, CanBeAliased (Op rep)) => Lambda SOACS -> m (Lambda rep) Source #

Recursively first-order-transform a lambda.

transformSOAC :: Transformer m => Pat (LetDec (Rep m)) -> SOAC (Rep m) -> m () Source #

Transform a single SOAC into a do-loop. The body of the lambda is untouched, and may or may not contain further SOACs depending on the given rep.