futhark-0.25.32: An optimising compiler for a functional, array-oriented language.

Safe Haskell | Safe-Inferred
Language | GHC2021

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

- transformFunDef :: (MonadFreshNames m, FirstOrderRep torep) => Scope torep -> FunDef SOACS -> m (FunDef torep)
- transformConsts :: (MonadFreshNames m, FirstOrderRep torep) => Stms SOACS -> m (Stms torep)
- type FirstOrderRep rep = (Buildable rep, BuilderOps rep, LetDec SOACS ~ LetDec rep, LParamInfo SOACS ~ LParamInfo rep, AliasableRep rep)
- type Transformer m = (MonadBuilder m, LocalScope (Rep m) m, Buildable (Rep m), BuilderOps (Rep m), LParamInfo SOACS ~ LParamInfo (Rep m), AliasableRep (Rep m))
- transformStmRecursively :: (Transformer m, LetDec (Rep m) ~ LetDec SOACS) => Stm SOACS -> m ()
- transformLambda :: (MonadFreshNames m, Buildable rep, BuilderOps rep, LocalScope somerep m, SameScope somerep rep, LetDec rep ~ LetDec SOACS, AliasableRep rep) => Lambda SOACS -> m (Lambda rep)
- transformSOAC :: Transformer m => Pat (LetDec (Rep m)) -> SOAC (Rep m) -> m ()

# 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, AliasableRep 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), AliasableRep (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, AliasableRep 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 `SOAC`s depending on the given rep.