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

Safe Haskell | Safe-Inferred
Language | GHC2021

Futhark.Pipeline

Description

Definition of the core compiler driver building blocks. The spine of the compiler is the `FutharkM` monad, although note that individual passes are pure functions, and do not use the `FutharkM` monad (see Futhark.Pass).

Running the compiler involves producing an initial IR program (see Futhark.Compiler.Program), running a `Pipeline` to produce a final program (still in IR), then running an `Action`, which is usually a code generator.

Synopsis

- data Pipeline fromrep torep
- data PipelineConfig = PipelineConfig {
  - pipelineVerbose :: Bool
  - pipelineValidate :: Bool
  }
- data Action rep = Action {
  - actionName :: String
  - actionDescription :: String
  - actionProcedure :: Prog rep -> FutharkM ()
  }
- data FutharkM a
- runFutharkM :: FutharkM a -> Verbosity -> IO (Either CompilerError a)
- data Verbosity
  - = NotVerbose
  - | Verbose
  - | VeryVerbose
- module Futhark.Error
- onePass :: Checkable torep => Pass fromrep torep -> Pipeline fromrep torep
- passes :: Checkable rep => [Pass rep rep] -> Pipeline rep rep
- condPipeline :: (Prog rep -> Bool) -> Pipeline rep rep -> Pipeline rep rep
- runPipeline :: Pipeline fromrep torep -> PipelineConfig -> Prog fromrep -> FutharkM (Prog torep)

# Documentation

data Pipeline fromrep torep Source #

A compiler pipeline is conceptually a function from programs to programs, where the actual representation may change. Pipelines can be composed using their `Category` instance.

#### Instances

Instances details

Category Pipeline Source # |
Instance details Defined in Futhark.Pipeline Methods id :: forall (a :: k). Pipeline a a Source # (.) :: forall (b :: k) (c :: k) (a :: k). Pipeline b c -> Pipeline a b -> Pipeline a c Source #

data PipelineConfig Source #

Configuration object for running a compiler pipeline.

Constructors

PipelineConfig |

Fields

- pipelineVerbose :: Bool
- pipelineValidate :: Bool

data Action rep Source #

A compilation always ends with some kind of action.

Constructors

Action |

Fields

- actionName :: String
- actionDescription :: String
- actionProcedure :: Prog rep -> FutharkM ()

data FutharkM a Source #

The main Futhark compiler driver monad - basically some state tracking on top if `IO`.

#### Instances

Instances details

MonadIO FutharkM Source # |
Instance details Defined in Futhark.Pipeline Methods liftIO :: IO a -> FutharkM a Source #
Applicative FutharkM Source # |
Instance details Defined in Futhark.Pipeline Methods pure :: a -> FutharkM a Source # (<*>) :: FutharkM (a -> b) -> FutharkM a -> FutharkM b Source # liftA2 :: (a -> b -> c) -> FutharkM a -> FutharkM b -> FutharkM c Source # (*>) :: FutharkM a -> FutharkM b -> FutharkM b Source # (<*) :: FutharkM a -> FutharkM b -> FutharkM a Source #
Functor FutharkM Source # |
Instance details Defined in Futhark.Pipeline Methods fmap :: (a -> b) -> FutharkM a -> FutharkM b Source # (<$) :: a -> FutharkM b -> FutharkM a Source #
Monad FutharkM Source # |
Instance details Defined in Futhark.Pipeline Methods (>>=) :: FutharkM a -> (a -> FutharkM b) -> FutharkM b Source # (>>) :: FutharkM a -> FutharkM b -> FutharkM b Source # return :: a -> FutharkM a Source #
MonadFreshNames FutharkM Source # |
Instance details Defined in Futhark.Pipeline Methods getNameSource :: FutharkM VNameSource Source # putNameSource :: VNameSource -> FutharkM () Source #
MonadLogger FutharkM Source # |
Instance details Defined in Futhark.Pipeline Methods logMsg :: ToLog a => a -> FutharkM () Source # addLog :: Log -> FutharkM () Source #
MonadError CompilerError FutharkM Source # |
Instance details Defined in Futhark.Pipeline Methods throwError :: CompilerError -> FutharkM a Source # catchError :: FutharkM a -> (CompilerError -> FutharkM a) -> FutharkM a Source #

runFutharkM :: FutharkM a -> Verbosity -> IO (Either CompilerError a) Source #

Run a `FutharkM` action.

data Verbosity Source #

How much information to print to stderr while the compiler is running.

Constructors

NotVerbose | Silence is golden.
Verbose | Print messages about which pass is running.
VeryVerbose | Also print logs from individual passes.

#### Instances

Instances details

Eq Verbosity Source # |
Instance details Defined in Futhark.Compiler.Config Methods (==) :: Verbosity -> Verbosity -> Bool Source # (/=) :: Verbosity -> Verbosity -> Bool Source #
Ord Verbosity Source # |

Instance details

Defined in Futhark.Compiler.Config

Methods

compare :: Verbosity -> Verbosity -> Ordering Source #

(<) :: Verbosity -> Verbosity -> Bool Source #

(<=) :: Verbosity -> Verbosity -> Bool Source #

(>) :: Verbosity -> Verbosity -> Bool Source #

(>=) :: Verbosity -> Verbosity -> Bool Source #

max :: Verbosity -> Verbosity -> Verbosity Source #

min :: Verbosity -> Verbosity -> Verbosity Source #

module Futhark.Error

onePass :: Checkable torep => Pass fromrep torep -> Pipeline fromrep torep Source #

Construct a pipeline from a single compiler pass.

passes :: Checkable rep => [Pass rep rep] -> Pipeline rep rep Source #

Create a pipeline from a list of passes.

condPipeline :: (Prog rep -> Bool) -> Pipeline rep rep -> Pipeline rep rep Source #

Conditionally run pipeline if predicate is true.

runPipeline :: Pipeline fromrep torep -> PipelineConfig -> Prog fromrep -> FutharkM (Prog torep) Source #

Run the pipeline on the given program.