ghc-9.10.3: The GHC API

Safe Haskell | None
Language | GHC2021

GHC.Cmm.Dataflow

Synopsis

- type C = 'Closed
- type O = 'Open
- data Block (n :: Extensibility -> Extensibility -> Type) (e :: Extensibility) (x :: Extensibility)
- lastNode :: forall n (x :: Extensibility). Block n x C -> n O C
- entryLabel :: forall (x :: Extensibility). NonLocal thing => thing C x -> Label
- foldNodesBwdOO :: (node O O -> f -> f) -> Block node O O -> f -> f
- foldRewriteNodesBwdOO :: forall f node. (node O O -> f -> UniqSM (Block node O O, f)) -> Block node O O -> f -> UniqSM (Block node O O, f)
- data DataflowLattice a = DataflowLattice {
  - fact_bot :: a
  - fact_join :: JoinFun a
  }
- newtype OldFact a = OldFact a
- newtype NewFact a = NewFact a
- data JoinedFact a
  - = Changed !a
  - | NotChanged !a
- type TransferFun f = CmmBlock -> FactBase f -> FactBase f
- type RewriteFun f = CmmBlock -> FactBase f -> UniqSM (CmmBlock, FactBase f)
- type family Fact (x :: Extensibility) f
- type FactBase f = LabelMap f
- getFact :: DataflowLattice f -> Label -> FactBase f -> f
- mkFactBase :: DataflowLattice f -> [(Label, f)] -> FactBase f
- analyzeCmmFwd :: forall (node :: Extensibility -> Extensibility -> Type) f. NonLocal node => DataflowLattice f -> TransferFun' node f -> GenCmmGraph node -> FactBase f -> FactBase f
- analyzeCmmBwd :: forall (node :: Extensibility -> Extensibility -> Type) f. NonLocal node => DataflowLattice f -> TransferFun' node f -> GenCmmGraph node -> FactBase f -> FactBase f
- rewriteCmmBwd :: forall (node :: Extensibility -> Extensibility -> Type) f. NonLocal node => DataflowLattice f -> RewriteFun' node f -> GenCmmGraph node -> FactBase f -> UniqSM (GenCmmGraph node, FactBase f)
- changedIf :: Bool -> a -> JoinedFact a
- joinOutFacts :: forall n f (e :: Extensibility). NonLocal n => DataflowLattice f -> n e C -> FactBase f -> f
- joinFacts :: DataflowLattice f -> [f] -> f

# Documentation

type C = 'Closed Source #

type O = 'Open Source #

data Block (n :: Extensibility -> Extensibility -> Type) (e :: Extensibility) (x :: Extensibility) Source #

A sequence of nodes. May be any of four shapes (OO, OC, CO, CC). Open at the entry means single entry, mutatis mutandis for exit. A closedclosed block is a basic/ block and can't be extended further. Clients should avoid manipulating blocks and should stick to either nodes or graphs.

#### Instances

Instances details

OutputableP Platform (Block CmmNode C C) Source # |
Instance details Defined in GHC.Cmm.Node Methods pdoc :: Platform -> Block CmmNode C C -> SDoc Source #
OutputableP Platform (Block CmmNode C O) Source # |
Instance details Defined in GHC.Cmm.Node Methods pdoc :: Platform -> Block CmmNode C O -> SDoc Source #
OutputableP Platform (Block CmmNode O C) Source # |
Instance details Defined in GHC.Cmm.Node Methods pdoc :: Platform -> Block CmmNode O C -> SDoc Source #
OutputableP Platform (Block CmmNode O O) Source # |
Instance details Defined in GHC.Cmm.Node Methods pdoc :: Platform -> Block CmmNode O O -> SDoc Source #
OutputableP Platform (Graph CmmNode e x) Source # |
Instance details Defined in GHC.Cmm.Node Methods pdoc :: Platform -> Graph CmmNode e x -> SDoc Source #
NonLocal n => NonLocal (Block n) Source # |
Instance details Defined in GHC.Cmm.Dataflow.Graph Methods entryLabel :: forall (x :: Extensibility). Block n C x -> Label Source # successors :: forall (e :: Extensibility). Block n e C -> [Label] Source #

lastNode :: forall n (x :: Extensibility). Block n x C -> n O C Source #

entryLabel Source #

Arguments

:: forall (x :: Extensibility). NonLocal thing |
=> thing C x |
-> Label | The label of a first node or block

foldNodesBwdOO :: (node O O -> f -> f) -> Block node O O -> f -> f Source #

Folds backward over all nodes of an open-open block. Strict in the accumulator.

foldRewriteNodesBwdOO :: forall f node. (node O O -> f -> UniqSM (Block node O O, f)) -> Block node O O -> f -> UniqSM (Block node O O, f) Source #

Folds backward over all the nodes of an open-open block and allows rewriting them. The accumulator is both the block of nodes and `f` (usually dataflow facts). Strict in both accumulated parts.

data DataflowLattice a Source #

Constructors

DataflowLattice |

Fields

- fact_bot :: a
- fact_join :: JoinFun a

newtype OldFact a Source #

Constructors

OldFact a |

newtype NewFact a Source #

Constructors

NewFact a |

data JoinedFact a Source #

The result of joining OldFact and NewFact.

Constructors

Changed !a | Result is different than OldFact.
NotChanged !a | Result is the same as OldFact.

type TransferFun f = CmmBlock -> FactBase f -> FactBase f Source #

type RewriteFun f = CmmBlock -> FactBase f -> UniqSM (CmmBlock, FactBase f) Source #

Function for rewriting and analysis combined. To be used with `rewriteCmm`.

Currently set to work with `UniqSM` monad, but we could probably abstract that away (if we do that, we might want to specialize the fixpoint algorithms to the particular monads through SPECIALIZE).

type family Fact (x :: Extensibility) f Source #

#### Instances

Instances details

type Fact C f Source # |
Instance details Defined in GHC.Cmm.Dataflow type Fact C f = FactBase f
type Fact O f Source # |
Instance details Defined in GHC.Cmm.Dataflow type Fact O f = f

type FactBase f = LabelMap f Source #

getFact :: DataflowLattice f -> Label -> FactBase f -> f Source #

mkFactBase :: DataflowLattice f -> [(Label, f)] -> FactBase f Source #

Returns the joined facts for each label.

analyzeCmmFwd :: forall (node :: Extensibility -> Extensibility -> Type) f. NonLocal node => DataflowLattice f -> TransferFun' node f -> GenCmmGraph node -> FactBase f -> FactBase f Source #

analyzeCmmBwd :: forall (node :: Extensibility -> Extensibility -> Type) f. NonLocal node => DataflowLattice f -> TransferFun' node f -> GenCmmGraph node -> FactBase f -> FactBase f Source #

rewriteCmmBwd :: forall (node :: Extensibility -> Extensibility -> Type) f. NonLocal node => DataflowLattice f -> RewriteFun' node f -> GenCmmGraph node -> FactBase f -> UniqSM (GenCmmGraph node, FactBase f) Source #

changedIf :: Bool -> a -> JoinedFact a Source #

joinOutFacts :: forall n f (e :: Extensibility). NonLocal n => DataflowLattice f -> n e C -> FactBase f -> f Source #

Returns the result of joining the facts from all the successors of the provided node or block.

joinFacts :: DataflowLattice f -> [f] -> f Source #