Safe Haskell | None |
---|---|
Language | Haskell2010 |
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
- literal :: (Type a, (Literal :|| Type) :<: dom) => a -> ASTF (dom :|| Typeable) 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
- data FeldOpts = FeldOpts {}
- data Target
- inTarget :: Target -> FeldOpts -> Bool
- defaultFeldOpts :: FeldOpts
- 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) => FeldOpts -> feature a -> Args (AST (dom :|| Typeable)) a -> Opt (ASTF (Decor Info (dom :|| Typeable)) (DenResult a))
- constructFeatOpt :: Typeable (DenResult a) => FeldOpts -> feature a -> Args (AST (Decor Info (dom :|| Typeable))) a -> Opt (ASTF (Decor Info (dom :|| Typeable)) (DenResult a))
- constructFeatUnOpt :: Typeable (DenResult a) => FeldOpts -> 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, Render dom, Constrained dom, Optimize dom dom) => OptimizeSuper dom
- constructFeat :: (Typeable (DenResult a), Optimize feature dom) => FeldOpts -> feature a -> Args (AST (Decor Info (dom :|| Typeable))) a -> Opt (ASTF (Decor Info (dom :|| Typeable)) (DenResult a))
- optimizeM :: OptimizeSuper dom => FeldOpts -> ASTF (dom :|| Typeable) a -> Opt (ASTF (Decor Info (dom :|| Typeable)) a)
- optimize :: (Typeable a, OptimizeSuper dom) => FeldOpts -> ASTF (dom :|| Typeable) a -> ASTF (Decor Info (dom :|| Typeable)) a
- constructFeatUnOptDefaultTyp :: (feature :<: dom, SizeProp feature, Typeable (DenResult a), Show (Size (DenResult a)), Lattice (Size (DenResult a))) => FeldOpts -> 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)) => FeldOpts -> 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) => FeldOpts -> 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
- class Monotonic feature where
- viewMonotonicInc :: Monotonic dom => ASTF (Decor Info (dom :|| Typeable)) a -> [ASTF (Decor Info (dom :|| Typeable)) a]
- viewMonotonicDec :: Monotonic dom => ASTF (Decor Info (dom :|| Typeable)) a -> [ASTF (Decor Info (dom :|| Typeable)) a]
Documentation
targetSpecialization :: BitWidth n -> ASTF dom a -> ASTF dom a Source
Specialize the program for a target platform with the given native bit width
class Sharable dom where Source
Indication whether a symbol is sharable or not
Nothing
Sharable Variable | |
Sharable Lambda | |
Sharable Let | |
Sharable Select | |
Sharable Tuple | |
Sharable Literal | |
Sharable Condition | |
Sharable Empty | |
Sharable COMPLEX | |
Sharable ORD | |
Sharable EQ | |
Sharable Logic | |
Sharable BITS | |
Sharable INTEGRAL | |
Sharable Error | |
Sharable FLOATING | |
Sharable NUM | |
Sharable FRACTIONAL | |
Sharable NoInline | |
Sharable REALFLOAT | |
Sharable Trace | |
Sharable FFI | |
Sharable Save | |
Sharable Array | |
Sharable FUTURE | |
Sharable Mutable | |
Sharable Switch | |
Sharable Conversion | |
Sharable MutableReference | |
Sharable Loop | |
Sharable MutableArray | |
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 where Source
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
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 = String Source
Information about the source code of an expression
Type and size information of a Feldspar program
class LatticeSize1 m where Source
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 a Source
It the expression is a literal, its value is returned, otherwise Nothing
literal :: (Type a, (Literal :|| Type) :<: dom) => a -> ASTF (dom :|| Typeable) a Source
Construct a Literal
literalDecor :: (Type a, (Literal :|| Type) :<: dom) => a -> ASTF (Decor Info (dom :|| Typeable)) a Source
constFold :: (Typed dom, (Literal :|| Type) :<: dom) => SourceInfo -> ASTF (Decor Info (dom :|| Typeable)) a -> a -> ASTF (Decor Info (dom :|| Typeable)) a Source
Replaces an expression with a literal if the type permits, otherwise returns the expression unchanged.
A record with options for explicit passing in rewrite rules.
defaultFeldOpts :: FeldOpts Source
Default options.
localVar :: Typeable b => VarId -> Info b -> Opt a -> Opt a Source
Insert a variable into the environment
localSource :: SourceInfo -> Opt a -> Opt a Source
Change the SourceInfo
environment
class Optimize feature dom where Source
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) => FeldOpts -> 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) => FeldOpts -> 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) => FeldOpts -> 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, Render dom, Constrained dom, Optimize dom dom) => OptimizeSuper dom Source
constructFeat :: (Typeable (DenResult a), Optimize feature dom) => FeldOpts -> 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 => FeldOpts -> 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) => FeldOpts -> ASTF (dom :|| Typeable) a -> ASTF (Decor Info (dom :|| Typeable)) a Source
Optimization of an expression. This function runs optimizeM
and extracts
the result.
constructFeatUnOptDefaultTyp :: (feature :<: dom, SizeProp feature, Typeable (DenResult a), Show (Size (DenResult a)), Lattice (Size (DenResult a))) => FeldOpts -> 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)) => FeldOpts -> 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
optimizeFeatDefault :: (Optimize feature dom, Typeable (DenResult a), OptimizeSuper dom) => FeldOpts -> feature a -> Args (AST (dom :|| Typeable)) a -> Opt (ASTF (Decor Info (dom :|| Typeable)) (DenResult a)) Source
Convenient default implementation of optimizeFeat
class Monotonic feature where Source
The Monotonic
class represents (weak) monotonicity
Nothing
monotonicInc :: feature a -> Args (AST (Decor Info (dom :|| Typeable))) a -> [ASTF (Decor Info (dom :|| Typeable)) (DenResult a)] Source
Return the arguments for which the symbol is monotonic increasing
forAll a. [a] = monotonicInc (f a) ==> f a >= a
monotonicDec :: feature a -> Args (AST (Decor Info (dom :|| Typeable))) a -> [ASTF (Decor Info (dom :|| Typeable)) (DenResult a)] Source
Return the arguments for which the symbol is monotonic decreasing
forAll a. [a] = monotonicDec (f a) ==> f a <= a
Monotonic Variable | |
Monotonic Lambda | |
Monotonic Let | |
Monotonic Select | |
Monotonic Tuple | |
Monotonic Literal | |
Monotonic Identity | |
Monotonic Condition | |
Monotonic Empty | |
Monotonic COMPLEX | |
Monotonic ORD | |
Monotonic EQ | |
Monotonic Logic | |
Monotonic BITS | |
Monotonic INTEGRAL | |
Monotonic Error | |
Monotonic FLOATING | |
Monotonic NUM | |
Monotonic FRACTIONAL | |
Monotonic NoInline | |
Monotonic REALFLOAT | |
Monotonic Trace | |
Monotonic FFI | |
Monotonic Save | |
Monotonic Array | |
Monotonic FUTURE | |
Monotonic Mutable | |
Monotonic Switch | |
Monotonic Conversion | |
Monotonic MutableReference | |
Monotonic Loop | |
Monotonic MutableArray | |
Monotonic MutableToPure | |
Monotonic ParFeature | |
Monotonic PropSize | |
Monotonic (MONAD Par) | |
Monotonic (MONAD Mut) | |
Monotonic (ConditionM m) | |
Monotonic (LoopM m) | |
Monotonic dom => Monotonic (Decor Info dom) | |
Monotonic (Decor SourceInfo1 Identity) | |
Monotonic sym => Monotonic ((:||) sym pred) | |
(Monotonic sub1, Monotonic sub2) => Monotonic ((:+:) sub1 sub2) | |
Monotonic sym => Monotonic (SubConstr2 c sym p1 p2) |