Safe Haskell | None |
---|---|
Language | Haskell2010 |
Data.Macaw.CFG.DemandSet
Description
Provides a monad that allows one to record a list of values and statements, and then resolve all their dependencies to see what additional computations must be run to provide inputs to the statements and compute the final value.
Synopsis
- data DemandComp arch ids a
- type AssignIdSet ids = Set (Some (AssignId ids))
- runDemandComp :: DemandContext arch -> DemandComp arch ids () -> AssignIdSet ids
- addValueDemands :: forall arch ids (tp :: Type). Value arch ids tp -> DemandComp arch ids ()
- addStmtDemands :: Stmt arch ids -> DemandComp arch ids ()
- data DemandContext arch = DemandContext {
- archFnHasSideEffects :: !(forall (v :: Type -> Type) (tp :: Type). ArchFn arch v tp -> Bool)
- demandConstraints :: !(forall a. ((FoldableFC (ArchFn arch), FoldableF (ArchStmt arch)) => a) -> a)
- hasSideEffects :: forall arch (f :: Type -> Type) (tp :: Type). DemandContext arch -> AssignRhs arch f tp -> Bool
- stmtNeeded :: AssignIdSet ids -> Stmt arch ids -> Bool
Documentation
data DemandComp arch ids a Source #
This is a monad that one can use for recording which values and statements we need to compute.
Use runDemandComp
to get the assignments that need to be computed.
Instances
Applicative (DemandComp arch ids) Source # | |
Defined in Data.Macaw.CFG.DemandSet Methods pure :: a -> DemandComp arch ids a # (<*>) :: DemandComp arch ids (a -> b) -> DemandComp arch ids a -> DemandComp arch ids b # liftA2 :: (a -> b -> c) -> DemandComp arch ids a -> DemandComp arch ids b -> DemandComp arch ids c # (*>) :: DemandComp arch ids a -> DemandComp arch ids b -> DemandComp arch ids b # (<*) :: DemandComp arch ids a -> DemandComp arch ids b -> DemandComp arch ids a # | |
Functor (DemandComp arch ids) Source # | |
Defined in Data.Macaw.CFG.DemandSet Methods fmap :: (a -> b) -> DemandComp arch ids a -> DemandComp arch ids b # (<$) :: a -> DemandComp arch ids b -> DemandComp arch ids a # | |
Monad (DemandComp arch ids) Source # | |
Defined in Data.Macaw.CFG.DemandSet Methods (>>=) :: DemandComp arch ids a -> (a -> DemandComp arch ids b) -> DemandComp arch ids b # (>>) :: DemandComp arch ids a -> DemandComp arch ids b -> DemandComp arch ids b # return :: a -> DemandComp arch ids a # |
type AssignIdSet ids = Set (Some (AssignId ids)) Source #
A set of assignments
runDemandComp :: DemandContext arch -> DemandComp arch ids () -> AssignIdSet ids Source #
Run demand computation and return the set of assignments that are needed to compute all the values we needed.
addValueDemands :: forall arch ids (tp :: Type). Value arch ids tp -> DemandComp arch ids () Source #
Add any subassignments needed to compute values to demand set.
addStmtDemands :: Stmt arch ids -> DemandComp arch ids () Source #
Parse statement, and if it has side effects, add assignments needed to compute statement to demand set.
DemandContext
data DemandContext arch Source #
This provides the architecture specific functions needed to resolve demand sets.
Constructors
DemandContext | |
Fields
|
hasSideEffects :: forall arch (f :: Type -> Type) (tp :: Type). DemandContext arch -> AssignRhs arch f tp -> Bool Source #
Return true if assign rhs has side effects (and thus should always be demanded)
Filtering after demand set is computed.
stmtNeeded :: AssignIdSet ids -> Stmt arch ids -> Bool Source #
This returns true if the statement should be kept given the demand set.