on master help sign in
Remove cached deps'.
commit49c7abcf77bfcb9d0b55a3aff2465bf83e6c98f9 authorMatus Tejiscak <ziman@functor.sk> dateFri 24 Jan 2014, 13:54 (13 years ago) parent7e308dd
2 files changed+19−10
src/IRTS/Compiler.hs+1−1 src/Idris/Erasure.hs+18−9
src/IRTS/Compiler.hs+1−1
@@ -54,7 +54,7 @@ compile codegen f tm
5454 let depMap = buildDepMap (tt_ctxt ist) used
5555 let printCond (ctors, cond) = "if " ++ show (S.toList cond) ++ " -ctors- " ++ show (S.toList ctors)
5656 let printDep (i, conds) = unlines . map (" "++) $ (show i : map printCond (S.toList conds))
57− let printItem (fn, (deps, depns)) = unlines ((show fn ++ " <- " ++ show (S.toList depns)) : map printDep (IM.toList deps))
57+ let printItem (fn, deps) = unlines (show fn : map printDep (IM.toList deps))
5858 iLOG $ "USAGE ANALYSIS:\n" ++ unlines (map printItem . M.toList $ depMap)
5959 -- END TODO
6060
src/Idris/Erasure.hs+18−9
@@ -28,13 +28,9 @@ import Data.IntMap (IntMap)
2828-- UseMap maps names to the set of used (reachable) argument positions.
2929type UseMap = Map Name IntSet
3030
31−-- Deps augmented with cached info.
32−-- fst = deps
33−-- snd = all names that the function depends on
34−type Deps' = (Deps, Set Name)
35−
36−-- DepMap maps functions (only functions) to their Deps'.
37−type DepMap = Map Name Deps'
31+-- DepMap maps functions (only functions) to their Deps.
32+type DepMap = Map Name Deps
33+type FlatMap = Map (Name, Int) (Set (Ctors, Cond))
3834
3935-- Deps of a function is a map from argument index
4036-- to all usages of the argument, including conditions
@@ -58,8 +54,21 @@ type Vars = Map Name Var
5854type PatVar = Ctors -> Var
5955type PatVars = Map Name PatVar
6056
57+{-
58+-- Find the minimal consistent usage by forward chaining.
6159minimalUsage :: DepMap -> UseMap
62−minimalUsage dmap = undefined
60+minimalUsage dmap =
61+ where
62+ flatten :: DepMap -> FlatMap
63+ flatten
64+
65+ trivials :: DepMap
66+ trivials = M.mapMaybeWithKey isTrivial dmap
67+
68+ isTrivial :: Name -> (Deps, Set Name) -> Maybe (Deps, Set Name)
69+ isTrivial n (deps, ns)
70+ where
71+-}
6372
6473-- Build the dependency graph,
6574-- starting the depth-first search from a list of Names.
@@ -73,7 +82,7 @@ buildDepMap ctx ns = dfs M.empty ns
7382 dfs dmap [] = dmap
7483 dfs dmap (n : ns)
7584 | n `M.member` dmap = dfs dmap ns
76− | otherwise = dfs (M.insert n (deps, depn) dmap) ns
85+ | otherwise = dfs (M.insert n deps dmap) ns
7786 where
7887 next = [n | n <- S.toList depn, n `M.notMember` dmap]
7988 depn = S.delete n (depNames deps)