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

Safe Haskell | Safe-Inferred
Language | GHC2021

Futhark.Analysis.PrimExp.Convert

Contents

- Module reexport
- Orphan instances

Description

Converting back and forth between `PrimExp`s. Use the `ToExp` instance to convert to Futhark expressions.

Synopsis

- primExpFromExp :: (MonadFail m, RepTypes rep) => (VName -> m (PrimExp v)) -> Exp rep -> m (PrimExp v)
- primExpFromSubExp :: PrimType -> SubExp -> PrimExp VName
- pe32 :: SubExp -> TPrimExp Int32 VName
- le32 :: a -> TPrimExp Int32 a
- pe64 :: SubExp -> TPrimExp Int64 VName
- le64 :: a -> TPrimExp Int64 a
- f32pe :: SubExp -> TPrimExp Float VName
- f32le :: a -> TPrimExp Float a
- f64pe :: SubExp -> TPrimExp Double VName
- f64le :: a -> TPrimExp Double a
- primExpFromSubExpM :: Applicative m => (VName -> m (PrimExp v)) -> SubExp -> m (PrimExp v)
- replaceInPrimExp :: (a -> PrimType -> PrimExp b) -> PrimExp a -> PrimExp b
- replaceInPrimExpM :: Monad m => (a -> PrimType -> m (PrimExp b)) -> PrimExp a -> m (PrimExp b)
- substituteInPrimExp :: Ord v => Map v (PrimExp v) -> PrimExp v -> PrimExp v
- primExpSlice :: Slice SubExp -> Slice (TPrimExp Int64 VName)
- subExpSlice :: MonadBuilder m => Slice (TPrimExp Int64 VName) -> m (Slice SubExp)
- module Futhark.Analysis.PrimExp

# Documentation

primExpFromExp :: (MonadFail m, RepTypes rep) => (VName -> m (PrimExp v)) -> Exp rep -> m (PrimExp v) Source #

Convert an expression to a `PrimExp`. The provided function is used to convert expressions that are not trivially `PrimExp`s. This includes constants and variable names, which are passed as `SubExp`s.

primExpFromSubExp :: PrimType -> SubExp -> PrimExp VName Source #

Convert `SubExp`s of a given type.

pe32 :: SubExp -> TPrimExp Int32 VName Source #

Shorthand for constructing a `TPrimExp` of type `Int32`.

le32 :: a -> TPrimExp Int32 a Source #

Shorthand for constructing a `TPrimExp` of type `Int32`, from a leaf.

pe64 :: SubExp -> TPrimExp Int64 VName Source #

Shorthand for constructing a `TPrimExp` of type `Int64`.

le64 :: a -> TPrimExp Int64 a Source #

Shorthand for constructing a `TPrimExp` of type `Int64`, from a leaf.

f32pe :: SubExp -> TPrimExp Float VName Source #

Shorthand for constructing a `TPrimExp` of type `Float32`.

f32le :: a -> TPrimExp Float a Source #

Shorthand for constructing a `TPrimExp` of type `Float32`, from a leaf.

f64pe :: SubExp -> TPrimExp Double VName Source #

Shorthand for constructing a `TPrimExp` of type `Float64`.

f64le :: a -> TPrimExp Double a Source #

Shorthand for constructing a `TPrimExp` of type `Float64`, from a leaf.

primExpFromSubExpM :: Applicative m => (VName -> m (PrimExp v)) -> SubExp -> m (PrimExp v) Source #

Like `primExpFromExp`, but for a `SubExp`.

replaceInPrimExp :: (a -> PrimType -> PrimExp b) -> PrimExp a -> PrimExp b Source #

As `replaceInPrimExpM`, but in the identity monad.

replaceInPrimExpM :: Monad m => (a -> PrimType -> m (PrimExp b)) -> PrimExp a -> m (PrimExp b) Source #

Applying a monadic transformation to the leaves in a `PrimExp`.

substituteInPrimExp :: Ord v => Map v (PrimExp v) -> PrimExp v -> PrimExp v Source #

Substituting names in a PrimExp with other PrimExps

primExpSlice :: Slice SubExp -> Slice (TPrimExp Int64 VName) Source #

Convert a `SubExp` slice to a `PrimExp` slice.

subExpSlice :: MonadBuilder m => Slice (TPrimExp Int64 VName) -> m (Slice SubExp) Source #

Convert a `PrimExp` slice to a `SubExp` slice.

# Module reexport

module Futhark.Analysis.PrimExp

# Orphan instances

ToExp v => ToExp (PrimExp v) Source # |
Instance details Methods toExp :: MonadBuilder m => PrimExp v -> m (Exp (Rep m)) Source #
ToExp v => ToExp (TPrimExp t v) Source # |
Instance details Methods toExp :: MonadBuilder m => TPrimExp t v -> m (Exp (Rep m)) Source #