Hoopl.Dataflow

ghc-8.6.3: The GHC API

Safe Haskell | None
Language | Haskell2010

Hoopl.Dataflow

Synopsis

- data C
- data O
- data Block n e x
- lastNode :: Block n x C -> n O C
- entryLabel :: NonLocal thing => thing C x -> Label
- foldNodesBwdOO :: (CmmNode O O -> f -> f) -> Block CmmNode O O -> f -> f
- foldRewriteNodesBwdOO :: forall f. (CmmNode O O -> f -> UniqSM (Block CmmNode O O, f)) -> Block CmmNode O O -> f -> UniqSM (Block CmmNode 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 f :: *
- type FactBase f = LabelMap f
- getFact :: DataflowLattice f -> Label -> FactBase f -> f
- mkFactBase :: DataflowLattice f -> [(Label, f)] -> FactBase f
- analyzeCmmFwd :: DataflowLattice f -> TransferFun f -> CmmGraph -> FactBase f -> FactBase f
- analyzeCmmBwd :: DataflowLattice f -> TransferFun f -> CmmGraph -> FactBase f -> FactBase f
- rewriteCmmBwd :: DataflowLattice f -> RewriteFun f -> CmmGraph -> FactBase f -> UniqSM (CmmGraph, FactBase f)
- changedIf :: Bool -> a -> JoinedFact a
- joinOutFacts :: NonLocal n => DataflowLattice f -> n e C -> FactBase f -> f
- joinFacts :: DataflowLattice f -> [f] -> f

# Documentation

data C #

Used at the type level to indicate a "closed" structure which supports control transfer only through the use of named labels---no "fallthrough" is permitted. The number of control-flow edges is unconstrained.

Instances

Outputable (Block CmmNode C C) # |
Instance details Defined in PprCmm Methods ppr :: Block CmmNode C C -> SDoc # pprPrec :: Rational -> Block CmmNode C C -> SDoc #
Outputable (Block CmmNode C O) # |
Instance details Defined in PprCmm Methods ppr :: Block CmmNode C O -> SDoc # pprPrec :: Rational -> Block CmmNode C O -> SDoc #
Outputable (Block CmmNode O C) # |
Instance details Defined in PprCmm Methods ppr :: Block CmmNode O C -> SDoc # pprPrec :: Rational -> Block CmmNode O C -> SDoc #
type Fact C f # |
Instance details Defined in Hoopl.Dataflow type Fact C f = FactBase f
type IndexedCO C a _b # |
Instance details Defined in Hoopl.Block type IndexedCO C a _b = a

data O #

Used at the type level to indicate an "open" structure with a unique, unnamed control-flow edge flowing in or out. Fallthrough and concatenation are permitted at an open point.

Instances

Outputable (Block CmmNode C O) # |
Instance details Defined in PprCmm Methods ppr :: Block CmmNode C O -> SDoc # pprPrec :: Rational -> Block CmmNode C O -> SDoc #
Outputable (Block CmmNode O C) # |
Instance details Defined in PprCmm Methods ppr :: Block CmmNode O C -> SDoc # pprPrec :: Rational -> Block CmmNode O C -> SDoc #
Outputable (Block CmmNode O O) # |
Instance details Defined in PprCmm Methods ppr :: Block CmmNode O O -> SDoc # pprPrec :: Rational -> Block CmmNode O O -> SDoc #
type Fact O f # |
Instance details Defined in Hoopl.Dataflow type Fact O f = f
type IndexedCO O _a b # |
Instance details Defined in Hoopl.Block type IndexedCO O _a b = b

data Block n e x #

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

NonLocal n => NonLocal (Block n) # |
Instance details Defined in Hoopl.Graph Methods entryLabel :: Block n C x -> Label # successors :: Block n e C -> [Label] #
Outputable (Block CmmNode C C) # |
Instance details Defined in PprCmm Methods ppr :: Block CmmNode C C -> SDoc # pprPrec :: Rational -> Block CmmNode C C -> SDoc #
Outputable (Block CmmNode C O) # |
Instance details Defined in PprCmm Methods ppr :: Block CmmNode C O -> SDoc # pprPrec :: Rational -> Block CmmNode C O -> SDoc #
Outputable (Block CmmNode O C) # |
Instance details Defined in PprCmm Methods ppr :: Block CmmNode O C -> SDoc # pprPrec :: Rational -> Block CmmNode O C -> SDoc #
Outputable (Block CmmNode O O) # |
Instance details Defined in PprCmm Methods ppr :: Block CmmNode O O -> SDoc # pprPrec :: Rational -> Block CmmNode O O -> SDoc #
Outputable (Graph CmmNode e x) # |
Instance details Defined in PprCmm Methods ppr :: Graph CmmNode e x -> SDoc # pprPrec :: Rational -> Graph CmmNode e x -> SDoc #

lastNode :: Block n x C -> n O C #

entryLabel #

Arguments

:: NonLocal thing |
=> thing C x |
-> Label | The label of a first node or block

foldNodesBwdOO :: (CmmNode O O -> f -> f) -> Block CmmNode O O -> f -> f #

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

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

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 #

Constructors

DataflowLattice |
Fields fact_bot :: a fact_join :: JoinFun a

newtype OldFact a #

Constructors

OldFact a |

newtype NewFact a #

Constructors

NewFact a |

data JoinedFact a #

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 #

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

Function for rewrtiting 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 f :: * #

Instances

type Fact C f # |
Instance details Defined in Hoopl.Dataflow type Fact C f = FactBase f
type Fact O f # |
Instance details Defined in Hoopl.Dataflow type Fact O f = f

type FactBase f = LabelMap f #

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

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

Returns the joined facts for each label.

analyzeCmmFwd :: DataflowLattice f -> TransferFun f -> CmmGraph -> FactBase f -> FactBase f #

analyzeCmmBwd :: DataflowLattice f -> TransferFun f -> CmmGraph -> FactBase f -> FactBase f #

rewriteCmmBwd :: DataflowLattice f -> RewriteFun f -> CmmGraph -> FactBase f -> UniqSM (CmmGraph, FactBase f) #

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

joinOutFacts :: NonLocal n => DataflowLattice f -> n e C -> FactBase f -> f #

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

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