Safe Haskell | None |
---|
Defines different interpretations of Feldspar programs
- module Language.Syntactic.Constructs.Decoration
- module Feldspar.Core.Interpretation.Typed
- targetSpecialization :: BitWidth n -> ASTF dom a -> ASTF dom a
- class Sharable dom where
- class SizeProp feature where
- sizePropDefault :: Type (DenResult a) => feature a -> Args (WrapFull Info) a -> Size (DenResult a)
- resultType :: Type (DenResult a) => c a -> TypeRep (DenResult a)
- type SourceInfo = String
- data Info a where
- mkInfo :: Type a => Size a -> Info a
- mkInfoTy :: (Show (Size a), Lattice (Size a)) => TypeRep a -> Info a
- infoRange :: Type a => Info a -> RangeSet a
- class LatticeSize1 m where
- viewLiteral :: forall info dom a. (Literal :|| Type) :<: dom => ASTF (Decor info (dom :|| Typeable)) a -> Maybe a
- literalDecor :: (Type a, (Literal :|| Type) :<: dom) => a -> ASTF (Decor Info (dom :|| Typeable)) a
- constFold :: (Typed dom, (Literal :|| Type) :<: dom) => SourceInfo -> ASTF (Decor Info (dom :|| Typeable)) a -> a -> ASTF (Decor Info (dom :|| Typeable)) a
- data SomeInfo where
- data SomeType where
- data Env = Env {
- varEnv :: [(VarId, SomeInfo)]
- sourceEnv :: SourceInfo
- localVar :: Typeable b => VarId -> Info b -> Opt a -> Opt a
- localSource :: SourceInfo -> Opt a -> Opt a
- type Opt = Reader Env
- class Optimize feature dom where
- optimizeFeat :: (Typeable (DenResult a), OptimizeSuper dom) => feature a -> Args (AST (dom :|| Typeable)) a -> Opt (ASTF (Decor Info (dom :|| Typeable)) (DenResult a))
- constructFeatOpt :: Typeable (DenResult a) => feature a -> Args (AST (Decor Info (dom :|| Typeable))) a -> Opt (ASTF (Decor Info (dom :|| Typeable)) (DenResult a))
- constructFeatUnOpt :: Typeable (DenResult a) => feature a -> Args (AST (Decor Info (dom :|| Typeable))) a -> Opt (ASTF (Decor Info (dom :|| Typeable)) (DenResult a))
- class (AlphaEq dom dom (dom :|| Typeable) [(VarId, VarId)], AlphaEq dom dom (Decor Info (dom :|| Typeable)) [(VarId, VarId)], EvalBind dom, (Literal :|| Type) :<: dom, Typed dom, Constrained dom, Optimize dom dom) => OptimizeSuper dom
- constructFeat :: (Typeable (DenResult a), Optimize feature dom) => feature a -> Args (AST (Decor Info (dom :|| Typeable))) a -> Opt (ASTF (Decor Info (dom :|| Typeable)) (DenResult a))
- optimizeM :: OptimizeSuper dom => ASTF (dom :|| Typeable) a -> Opt (ASTF (Decor Info (dom :|| Typeable)) a)
- optimize :: (Typeable a, OptimizeSuper dom) => ASTF (dom :|| Typeable) a -> ASTF (Decor Info (dom :|| Typeable)) a
- constructFeatUnOptDefaultTyp :: (feature :<: dom, SizeProp feature, Typeable (DenResult a), Show (Size (DenResult a))) => TypeRep (DenResult a) -> feature a -> Args (AST (Decor Info (dom :|| Typeable))) a -> Opt (ASTF (Decor Info (dom :|| Typeable)) (DenResult a))
- constructFeatUnOptDefault :: (feature :<: dom, SizeProp feature, Type (DenResult a)) => feature a -> Args (AST (Decor Info (dom :|| Typeable))) a -> Opt (ASTF (Decor Info (dom :|| Typeable)) (DenResult a))
- optimizeFeatDefault :: (Optimize feature dom, Typeable (DenResult a), OptimizeSuper dom) => feature a -> Args (AST (dom :|| Typeable)) a -> Opt (ASTF (Decor Info (dom :|| Typeable)) (DenResult a))
- prjF :: Project (sub :|| Type) sup => sup sig -> Maybe ((sub :|| Type) sig)
- c' :: Type (DenResult sig) => feature sig -> (feature :|| Type) sig
Documentation
targetSpecialization :: BitWidth n -> ASTF dom a -> ASTF dom aSource
Specialize the program for a target platform with the given native bit width
class Sharable dom whereSource
Indication whether a symbol is sharable or not
Sharable Variable | |
Sharable Lambda | |
Sharable Let | |
Sharable Tuple | |
Sharable Select | |
Sharable Literal | |
Sharable Condition | |
Sharable Empty | |
Sharable ORD | |
Sharable EQ | |
Sharable Logic | |
Sharable BITS | |
Sharable COMPLEX | |
Sharable Error | |
Sharable FLOATING | |
Sharable NUM | |
Sharable FRACTIONAL | |
Sharable INTEGRAL | |
Sharable NoInline | |
Sharable Trace | |
Sharable FFI | |
Sharable Save | |
Sharable Array | |
Sharable FUTURE | |
Sharable Loop | |
Sharable Mutable | |
Sharable Conversion | |
Sharable MutableArray | |
Sharable MutableReference | |
Sharable MutableToPure | |
Sharable ParFeature | |
Sharable PropSize | |
Sharable (MONAD Par) | |
Sharable (MONAD Mut) | |
Sharable (ConditionM m) | |
Sharable (LoopM m) | |
Sharable dom => Sharable (Decor Info dom) | |
Sharable (Decor SourceInfo1 Identity) | |
Sharable sym => Sharable (:|| sym pred) | |
(Sharable sub1, Sharable sub2) => Sharable (:+: sub1 sub2) | |
Sharable sym => Sharable (SubConstr2 c sym p1 p2) |
class SizeProp feature whereSource
Forwards size propagation
sizeProp :: feature a -> Args (WrapFull Info) a -> Size (DenResult a)Source
Size propagation for a symbol given a list of argument sizes
SizeProp Identity | |
SizeProp Mutable | |
SizeProp MutableArray | |
SizeProp MutableReference | |
SizeProp MutableToPure | |
SizeProp ParFeature | |
SizeProp (MONAD Par) | |
SizeProp (MONAD Mut) | |
LatticeSize1 m => SizeProp (ConditionM m) | |
SizeProp (LoopM m) | |
SizeProp (:|| Let Type) | |
SizeProp (:|| Tuple Type) | |
SizeProp (:|| Select Type) | |
SizeProp (:|| Literal Type) | |
SizeProp (:|| (Decor SourceInfo1 Identity) Type) | |
SizeProp (:|| Condition Type) | |
SizeProp (:|| ORD Type) | |
SizeProp (:|| EQ Type) | |
SizeProp (:|| Logic Type) | |
SizeProp (:|| BITS Type) | |
SizeProp (:|| COMPLEX Type) | |
SizeProp (:|| Error Type) | |
SizeProp (:|| FLOATING Type) | |
SizeProp (:|| NUM Type) | |
SizeProp (:|| FRACTIONAL Type) | |
SizeProp (:|| INTEGRAL Type) | |
SizeProp (:|| NoInline Type) | |
SizeProp (:|| Trace Type) | |
SizeProp (:|| FFI Type) | |
SizeProp (:|| Save Type) | |
SizeProp (:|| Array Type) | |
SizeProp (:|| FUTURE Type) | |
SizeProp (:|| Loop Type) | |
SizeProp (:|| Conversion Type) | |
SizeProp (:|| PropSize Type) |
sizePropDefault :: Type (DenResult a) => feature a -> Args (WrapFull Info) a -> Size (DenResult a)Source
Convenient default implementation of sizeProp
resultType :: Type (DenResult a) => c a -> TypeRep (DenResult a)Source
Compute a type representation of a symbol's result type
type SourceInfo = StringSource
Information about the source code of an expression
Type and size information of a Feldspar program
Info :: Show (Size a) => TypeRep a -> Size a -> VarInfo -> SourceInfo -> Info a | |
|
class LatticeSize1 m whereSource
This class is used to allow constructs to be abstract in the monad. Its
purpose is similar to that of MonadType
.
viewLiteral :: forall info dom a. (Literal :|| Type) :<: dom => ASTF (Decor info (dom :|| Typeable)) a -> Maybe aSource
It the expression is a literal, its value is returned, otherwise Nothing
literalDecor :: (Type a, (Literal :|| Type) :<: dom) => a -> ASTF (Decor Info (dom :|| Typeable)) aSource
constFold :: (Typed dom, (Literal :|| Type) :<: dom) => SourceInfo -> ASTF (Decor Info (dom :|| Typeable)) a -> a -> ASTF (Decor Info (dom :|| Typeable)) aSource
Replaces an expression with a literal if the type permits, otherwise returns the expression unchanged.
localVar :: Typeable b => VarId -> Info b -> Opt a -> Opt aSource
Insert a variable into the environment
localSource :: SourceInfo -> Opt a -> Opt aSource
Change the SourceInfo
environment
class Optimize feature dom whereSource
Basic optimization of a feature
This optimization is similar to Optimize
, but it also performs size
inference. Size inference has to be done simultaneously with other
optimizations in order to avoid iterating the phases. (Size information may
help optimization and optimization may help size inference.)
optimizeFeat :: (Typeable (DenResult a), OptimizeSuper dom) => feature a -> Args (AST (dom :|| Typeable)) a -> Opt (ASTF (Decor Info (dom :|| Typeable)) (DenResult a))Source
Top-down and bottom-up optimization of a feature
constructFeatOpt :: Typeable (DenResult a) => feature a -> Args (AST (Decor Info (dom :|| Typeable))) a -> Opt (ASTF (Decor Info (dom :|| Typeable)) (DenResult a))Source
Optimized construction of an expression from a symbol and its optimized arguments
Note: This function should normally not be called directly. Instead, use
constructFeat
which has more accurate propagation of Info
.
constructFeatUnOpt :: Typeable (DenResult a) => feature a -> Args (AST (Decor Info (dom :|| Typeable))) a -> Opt (ASTF (Decor Info (dom :|| Typeable)) (DenResult a))Source
Unoptimized construction of an expression from a symbol and its optimized arguments
class (AlphaEq dom dom (dom :|| Typeable) [(VarId, VarId)], AlphaEq dom dom (Decor Info (dom :|| Typeable)) [(VarId, VarId)], EvalBind dom, (Literal :|| Type) :<: dom, Typed dom, Constrained dom, Optimize dom dom) => OptimizeSuper dom Source
constructFeat :: (Typeable (DenResult a), Optimize feature dom) => feature a -> Args (AST (Decor Info (dom :|| Typeable))) a -> Opt (ASTF (Decor Info (dom :|| Typeable)) (DenResult a))Source
Optimized construction of an expression from a symbol and its optimized arguments
optimizeM :: OptimizeSuper dom => ASTF (dom :|| Typeable) a -> Opt (ASTF (Decor Info (dom :|| Typeable)) a)Source
Optimization of an expression
In addition to running optimizeFeat
, this function performs constant
folding on all closed expressions, provided that the type permits making a
literal.
optimize :: (Typeable a, OptimizeSuper dom) => ASTF (dom :|| Typeable) a -> ASTF (Decor Info (dom :|| Typeable)) aSource
Optimization of an expression. This function runs optimizeM
and extracts
the result.
constructFeatUnOptDefaultTyp :: (feature :<: dom, SizeProp feature, Typeable (DenResult a), Show (Size (DenResult a))) => TypeRep (DenResult a) -> feature a -> Args (AST (Decor Info (dom :|| Typeable))) a -> Opt (ASTF (Decor Info (dom :|| Typeable)) (DenResult a))Source
Convenient default implementation of constructFeatUnOpt
. Uses sizeProp
to propagate size.
constructFeatUnOptDefault :: (feature :<: dom, SizeProp feature, Type (DenResult a)) => feature a -> Args (AST (Decor Info (dom :|| Typeable))) a -> Opt (ASTF (Decor Info (dom :|| Typeable)) (DenResult a))Source
Like constructFeatUnOptDefaultTyp
but without an explicit TypeRep