diff options
author | Michal Terepeta <michal.terepeta@gmail.com> | 2016-10-26 11:20:33 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2016-10-26 11:20:33 -0400 |
commit | b8effa7fad6f29b89215ff17c5aa7c8a83b93b10 (patch) | |
tree | db1a1c39789d6b50c88ac566ff459d5f70043a1d /compiler/cmm/Hoopl | |
parent | 48876ae04c4963f8d5a60a121ac85d52322faaee (diff) | |
download | haskell-b8effa7fad6f29b89215ff17c5aa7c8a83b93b10.tar.gz |
CmmUtils: remove the last dataflow functions
This commit:
- Moves the remaining few methods concerned with dataflow analysis
from `CmmUtils` to `Hoopl.Dataflow`.
- Refactors the code to not use `FwdPass` and simply pass `FwdTransfer`
and `DataflowLattice` directly.
Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>
Test Plan: validate
Reviewers: austin, simonmar, bgamari
Reviewed By: simonmar, bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2634
Diffstat (limited to 'compiler/cmm/Hoopl')
-rw-r--r-- | compiler/cmm/Hoopl/Dataflow.hs | 81 |
1 files changed, 52 insertions, 29 deletions
diff --git a/compiler/cmm/Hoopl/Dataflow.hs b/compiler/cmm/Hoopl/Dataflow.hs index 47142d5d7b..d8d37121f1 100644 --- a/compiler/cmm/Hoopl/Dataflow.hs +++ b/compiler/cmm/Hoopl/Dataflow.hs @@ -18,32 +18,55 @@ -- module Hoopl.Dataflow - ( DataflowLattice(..), OldFact(..), NewFact(..), Fact, mkFactBase + ( C, O, DataflowLattice(..), OldFact(..), NewFact(..), Fact, FactBase + , mkFactBase , ChangeFlag(..) - , FwdPass(..), FwdTransfer, mkFTransfer, mkFTransfer3, getFTransfer3 + , FwdPass(..), FwdTransfer, mkFTransfer3 - , BwdPass(..), BwdTransfer, mkBTransfer, mkBTransfer3, getBTransfer3 - - , noBwdRewrite, noFwdRewrite + , BwdPass(..), BwdTransfer, mkBTransfer3 + , dataflowAnalFwdBlocks, dataflowAnalBwd , analyzeFwd, analyzeFwdBlocks, analyzeBwd + + , changeIf + , joinOutFacts ) where -import UniqSupply +import BlockId +import Cmm import Data.Array -import Compiler.Hoopl hiding (noFwdRewrite, noBwdRewrite) - -noRewrite :: a -> b -> UniqSM (Maybe c) -noRewrite _ _ = return Nothing +import Compiler.Hoopl -noFwdRewrite :: FwdRewrite UniqSM n f -noFwdRewrite = FwdRewrite3 (noRewrite, noRewrite, noRewrite) +-- TODO(michalt): This wrapper will go away once we refactor the analyze* +-- methods. +dataflowAnalFwdBlocks + :: NonLocal n + => GenCmmGraph n + -> [(BlockId, f)] + -> DataflowLattice f + -> FwdTransfer n f + -> BlockEnv f +dataflowAnalFwdBlocks + (CmmGraph {g_entry = entry, g_graph = graph}) facts lattice xfer = + analyzeFwdBlocks + lattice xfer (JustC [entry]) graph (mkFactBase lattice facts) + +-- TODO(michalt): This wrapper will go away once we refactor the analyze* +-- methods. +dataflowAnalBwd + :: NonLocal n + => GenCmmGraph n + -> [(BlockId, f)] + -> DataflowLattice f + -> BwdTransfer n f + -> BlockEnv f +dataflowAnalBwd + (CmmGraph {g_entry = entry, g_graph = graph}) facts lattice xfer = + analyzeBwd lattice xfer (JustC [entry]) graph (mkFactBase lattice facts) -noBwdRewrite :: BwdRewrite UniqSM n f -noBwdRewrite = BwdRewrite3 (noRewrite, noRewrite, noRewrite) ---------------------------------------------------------------- -- Forward Analysis only @@ -52,14 +75,14 @@ noBwdRewrite = BwdRewrite3 (noRewrite, noRewrite, noRewrite) -- | if the graph being analyzed is open at the entry, there must -- be no other entry point, or all goes horribly wrong... analyzeFwd - :: forall n f e . NonLocal n => - FwdPass UniqSM n f + :: forall n f e . NonLocal n + => DataflowLattice f + -> FwdTransfer n f -> MaybeC e [Label] -> Graph n e C -> Fact e f -> FactBase f -analyzeFwd FwdPass { fp_lattice = lattice, - fp_transfer = FwdTransfer3 (ftr, mtr, ltr) } - entries g in_fact = graph g in_fact +analyzeFwd lattice (FwdTransfer3 (ftr, mtr, ltr)) entries g in_fact = + graph g in_fact where graph :: Graph n e C -> Fact e f -> FactBase f graph (GMany entry blockmap NothingO) @@ -94,14 +117,14 @@ analyzeFwd FwdPass { fp_lattice = lattice, -- | if the graph being analyzed is open at the entry, there must -- be no other entry point, or all goes horribly wrong... analyzeFwdBlocks - :: forall n f e . NonLocal n => - FwdPass UniqSM n f + :: forall n f e . NonLocal n + => DataflowLattice f + -> FwdTransfer n f -> MaybeC e [Label] -> Graph n e C -> Fact e f -> FactBase f -analyzeFwdBlocks FwdPass { fp_lattice = lattice, - fp_transfer = FwdTransfer3 (ftr, _, ltr) } - entries g in_fact = graph g in_fact +analyzeFwdBlocks lattice (FwdTransfer3 (ftr, _, ltr)) entries g in_fact = + graph g in_fact where graph :: Graph n e C -> Fact e f -> FactBase f graph (GMany entry blockmap NothingO) @@ -136,14 +159,14 @@ analyzeFwdBlocks FwdPass { fp_lattice = lattice, -- | if the graph being analyzed is open at the entry, there must -- be no other entry point, or all goes horribly wrong... analyzeBwd - :: forall n f e . NonLocal n => - BwdPass UniqSM n f + :: forall n f e . NonLocal n + => DataflowLattice f + -> BwdTransfer n f -> MaybeC e [Label] -> Graph n e C -> Fact C f -> FactBase f -analyzeBwd BwdPass { bp_lattice = lattice, - bp_transfer = BwdTransfer3 (ftr, mtr, ltr) } - entries g in_fact = graph g in_fact +analyzeBwd lattice (BwdTransfer3 (ftr, mtr, ltr)) entries g in_fact = + graph g in_fact where graph :: Graph n e C -> Fact C f -> FactBase f graph (GMany entry blockmap NothingO) |