futhark-0.19.5: 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, FirstOrderLore tolore) => Scope tolore -> FunDef SOACS -> m (FunDef tolore) Source #

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

transformConsts :: (MonadFreshNames m, FirstOrderLore tolore) => Stms SOACS -> m (Stms tolore) Source #

First-order-transform these top-level constants.

type FirstOrderLore lore = (Bindable lore, BinderOps lore, LetDec SOACS ~ LetDec lore, LParamInfo SOACS ~ LParamInfo lore, CanBeAliased (Op lore)) Source #

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

type Transformer m = (MonadBinder m, LocalScope (Lore m) m, Bindable (Lore m), BinderOps (Lore m), LParamInfo SOACS ~ LParamInfo (Lore m), CanBeAliased (Op (Lore m))) Source #

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

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

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

transformLambda :: (MonadFreshNames m, Bindable lore, BinderOps lore, LocalScope somelore m, SameScope somelore lore, LetDec lore ~ LetDec SOACS, CanBeAliased (Op lore)) => Lambda -> m (Lambda lore) Source #

Recursively first-order-transform a lambda.

transformSOAC :: Transformer m => Pattern (Lore m) -> SOAC (Lore 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 lore.