hoopl 3.7.1.0 → 3.7.2.2
raw patch · 7 files changed
+103/−6 lines, 7 filesdep ~basebinary-added
Dependency ranges changed: base
Files
- Compiler/Hoopl/Dataflow.hs +4/−1
- Compiler/Hoopl/GraphUtil.hs +63/−0
- Compiler/Hoopl/Label.hs +14/−3
- Compiler/Hoopl/MkGraph.hs +2/−1
- README +17/−0
- hoopl.cabal +3/−1
- hoopl.pdf binary
Compiler/Hoopl/Dataflow.hs view
@@ -57,7 +57,7 @@ module Compiler.Hoopl.Dataflow ( DataflowLattice(..)- , ChangeFlag(..)+ , ChangeFlag(..), changeIf , ForwardPass(..), FwdTransfer, FwdRewrite, SimpleFwdRewrite , noFwdRewrite, thenFwdRw, shallowFwdRw, deepFwdRw , BackwardPass(..), BwdTransfer, BwdRewrite, SimpleBwdRewrite@@ -82,10 +82,13 @@ fact_name :: String, -- Documentation fact_bot :: a, -- Lattice bottom element fact_extend :: a -> a -> (ChangeFlag,a), -- Lattice join plus change flag+ -- (changes iff result > first arg) fact_do_logging :: Bool -- log changes } data ChangeFlag = NoChange | SomeChange+changeIf :: Bool -> ChangeFlag+changeIf changed = if changed then SomeChange else NoChange ----------------------------------------------------------------------------- -- Analyze and rewrite forward: the interface
+ Compiler/Hoopl/GraphUtil.hs view
@@ -0,0 +1,63 @@+{-# LANGUAGE GADTs #-}+{-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} -- bug in GHC++-- N.B. addBasicBlocks won't work on OO without a Node (branch/label) constraint++module Compiler.Hoopl.GraphUtil+ ( gCat, addEntrySeq, addExitSeq -- , addBasicBlocks+ , gCatClosed+ , gCatAny+ , bodyGraph+ )++where++import Compiler.Hoopl.Graph++bodyGraph :: Body n -> Graph n C C+bodyGraph b = GMany NothingO b NothingO+++gCatAny :: Graph n e a -> Graph n a x -> Graph n e x+gCat :: Graph n e O -> Graph n O x -> Graph n e x+addEntrySeq :: Graph n O C -> Graph n C x -> Graph n O x+addExitSeq :: Graph n e C -> Graph n C O -> Graph n e O+--addBasicBlocks :: Graph n e x -> Graph n C C -> Graph n e x+gCatClosed :: Graph n e C -> Graph n C x -> Graph n e x++gCatAny GNil g2 = g2+gCatAny g1 GNil = g1++gCatAny (GUnit b1) (GUnit b2) + = GUnit (b1 `BCat` b2)++gCatAny (GUnit b) (GMany (JustO e) bs x) + = GMany (JustO (b `BCat` e)) bs x++gCatAny (GMany e bs (JustO x)) (GUnit b2) + = GMany e bs (JustO (x `BCat` b2))++gCatAny (GMany e1 bs1 (JustO x1)) (GMany (JustO e2) bs2 x2)+ = GMany e1 (addBlock (x1 `BCat` e2) bs1 `BodyCat` bs2) x2++gCatAny (GMany e1 bs1 NothingO) (GMany NothingO bs2 x2)+ = GMany e1 (bs1 `BodyCat` bs2) x2++gCat = gCatAny+addEntrySeq = gCatAny+addExitSeq = gCatAny+gCatClosed = gCatAny++{-+addEntrySeq (GMany entry body NothingO) (GMany NothingO body' exit) + = GMany entry (body `BodyCat` body') exit+ +addExitSeq (GMany entry body NothingO) (GMany NothingO body' exit) + = GMany entry (body `BodyCat` body') exit+ +--addBasicBlocks GNil g2 = g2+++gCatClosed (GMany e1 bs1 NothingO) (GMany NothingO bs2 x2)+ = GMany e1 (bs1 `BodyCat` bs2) x2+-}
Compiler/Hoopl/Label.hs view
@@ -5,8 +5,9 @@ , FactBase, noFacts, mkFactBase, unitFact, lookupFact, extendFactBase , delFromFactBase, unionFactBase , elemFactBase, factBaseLabels, factBaseList- , LabelSet, emptyLabelSet, extendLabelSet, mkLabelSet, elemLabelSet, labelSetElems- , minusLabelSet, unionLabelSet+ , LabelSet, emptyLabelSet, extendLabelSet, reduceLabelSet+ , mkLabelSet, elemLabelSet, labelSetElems+ , minusLabelSet, unionLabelSet, interLabelSet, sizeLabelSet, ) where@@ -73,7 +74,7 @@ delFromFactBase fb blks = foldr (M.delete . unLabel . fst) fb blks -----------------------type LabelSet = S.IntSet+type LabelSet = S.IntSet -- ought to be a newtype or we expose the rep... emptyLabelSet :: LabelSet emptyLabelSet = S.empty@@ -81,6 +82,9 @@ extendLabelSet :: LabelSet -> Label -> LabelSet extendLabelSet lbls (Label bid) = S.insert bid lbls +reduceLabelSet :: LabelSet -> Label -> LabelSet+reduceLabelSet lbls (Label bid) = S.delete bid lbls+ elemLabelSet :: Label -> LabelSet -> Bool elemLabelSet (Label bid) lbls = S.member bid lbls @@ -93,6 +97,13 @@ unionLabelSet :: LabelSet -> LabelSet -> LabelSet unionLabelSet = S.union +interLabelSet :: LabelSet -> LabelSet -> LabelSet+interLabelSet = S.intersection++sizeLabelSet :: LabelSet -> Int+sizeLabelSet = S.size+ mkLabelSet :: [Label] -> LabelSet mkLabelSet = S.fromList . map unLabel+
Compiler/Hoopl/MkGraph.hs view
@@ -2,9 +2,10 @@ module Compiler.Hoopl.MkGraph ( AGraph, (<*>) , emptyAGraph, withFreshLabels- , mkMiddle, mkMiddles, mkLast, mkEntry, mkBranch, mkLabel, mkWhileDo+ , mkFirst, mkMiddle, mkMiddles, mkLast, mkEntry, mkBranch, mkLabel, mkWhileDo , addEntrySeq, addExitSeq, catAGraphs , IfThenElseable(mkIfThenElse)+ , Node(mkLabelNode, mkBranchNode) ) where
+ README view
@@ -0,0 +1,17 @@+This is Hoopl, a higher-order optimization library.+There are two unpublished papers describing Hoopl:++ Hoopl: Dataflow Optimization Made Simple+ Hoopl: A Modular, Reusable Library for Dataflow Analysis and Transformation++The second such paper is attached to this package.++The version number is split into four parts:++ 3. Third major body plan (phylum)+ 7. Seventh iteration (roughly) of data structures+ 2. Major version; changes when clients must change+ 1. Minor version; changes when clients can stay the same+++Version 3.7.2.2 has KNOWN BUGS! John Dias will update soon.
hoopl.cabal view
@@ -1,5 +1,5 @@ Name: hoopl-Version: 3.7.1.0+Version: 3.7.2.2 Description: Higher-order optimization library License: BSD3 License-file: LICENSE@@ -9,6 +9,7 @@ Cabal-Version: >=1.2 Synopsis: A library to support dataflow analysis and optimization Category: Compilers/Interpeters+Extra-source-files: README, hoopl.pdf Library Build-Depends: base >= 3 && < 5, containers@@ -16,4 +17,5 @@ Compiler.Hoopl.Dataflow, Compiler.Hoopl.Graph, Compiler.Hoopl.MkGraph, Compiler.Hoopl.Fuel, Compiler.Hoopl.Label+ Other-modules: Compiler.Hoopl.GraphUtil ghc-options: -Wall -fno-warn-name-shadowing
+ hoopl.pdf view
binary file changed (absent → 255637 bytes)