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

Safe Haskell | None
Language | GHC2021

Futhark.Pass

Description

Definition of a polymorphic (generic) pass that can work with programs of any rep.

Synopsis

- data PassM a
- runPassM :: MonadFreshNames m => PassM a -> m (a, Log)
- data Pass fromrep torep = Pass {
  - passName :: String
  - passDescription :: String
  - passFunction :: Prog fromrep -> PassM (Prog torep)
  }
- passLongOption :: Pass fromrep torep -> String
- parPass :: (a -> PassM b) -> [a] -> PassM [b]
- intraproceduralTransformation :: (Scope rep -> Stms rep -> PassM (Stms rep)) -> Prog rep -> PassM (Prog rep)
- intraproceduralTransformationWithConsts :: (Stms fromrep -> PassM (Stms torep)) -> (Stms torep -> FunDef fromrep -> PassM (FunDef torep)) -> Prog fromrep -> PassM (Prog torep)

# Documentation

data PassM a Source #

The monad in which passes execute.

#### Instances

Instances details

MonadFreshNames PassM Source # |
Instance details Defined in Futhark.Pass Methods getNameSource :: PassM VNameSource Source # putNameSource :: VNameSource -> PassM () Source #
MonadLogger PassM Source # |
Instance details Defined in Futhark.Pass Methods logMsg :: ToLog a => a -> PassM () Source # addLog :: Log -> PassM () Source #
Applicative PassM Source # |
Instance details Defined in Futhark.Pass Methods pure :: a -> PassM a Source # (<*>) :: PassM (a -> b) -> PassM a -> PassM b Source # liftA2 :: (a -> b -> c) -> PassM a -> PassM b -> PassM c Source # (*>) :: PassM a -> PassM b -> PassM b Source # (<*) :: PassM a -> PassM b -> PassM a Source #
Functor PassM Source # |
Instance details Defined in Futhark.Pass Methods fmap :: (a -> b) -> PassM a -> PassM b Source # (<$) :: a -> PassM b -> PassM a Source #
Monad PassM Source # |
Instance details Defined in Futhark.Pass Methods (>>=) :: PassM a -> (a -> PassM b) -> PassM b Source # (>>) :: PassM a -> PassM b -> PassM b Source # return :: a -> PassM a Source #

runPassM :: MonadFreshNames m => PassM a -> m (a, Log) Source #

Execute a `PassM` action, yielding logging information and either an error pretty or a result.

data Pass fromrep torep Source #

A compiler pass transforming a `Prog` of a given rep to a `Prog` of another rep.

Constructors

Pass |

Fields

- passName :: String

  Name of the pass. Keep this short and simple. It will be used to automatically generate a command-line option name via `passLongOption`.

- passDescription :: String

  A slightly longer description, which will show up in the command-line --help option.

- passFunction :: Prog fromrep -> PassM (Prog torep)

passLongOption :: Pass fromrep torep -> String Source #

Take the name of the pass, turn spaces into dashes, and make all characters lowercase.

parPass :: (a -> PassM b) -> [a] -> PassM [b] Source #

Apply a `PassM` operation in parallel to multiple elements, joining together the name sources and logs, and propagating any error properly.

intraproceduralTransformation :: (Scope rep -> Stms rep -> PassM (Stms rep)) -> Prog rep -> PassM (Prog rep) Source #

Like `intraproceduralTransformationWithConsts`, but do not change the top-level constants, and simply pass along their `Scope`.

intraproceduralTransformationWithConsts :: (Stms fromrep -> PassM (Stms torep)) -> (Stms torep -> FunDef fromrep -> PassM (FunDef torep)) -> Prog fromrep -> PassM (Prog torep) Source #

Apply some operation to the top-level constants. Then applies an operation to all the function definitions, which are also given the transformed constants so they can be brought into scope. The function definition transformations are run in parallel (with `parPass`), since they cannot affect each other.