on master help sign in
Remove cached deps'.
49c7abcMatus Tejiscak
src/IRTS/Compiler.hs+1−1
@@ -54,7 +54,7 @@ compile codegen f tm
54 let depMap = buildDepMap (tt_ctxt ist) used
54 let depMap = buildDepMap (tt_ctxt ist) used
55 let printCond (ctors, cond) = "if " ++ show (S.toList cond) ++ " -ctors- " ++ show (S.toList ctors)
55 let printCond (ctors, cond) = "if " ++ show (S.toList cond) ++ " -ctors- " ++ show (S.toList ctors)
56 let printDep (i, conds) = unlines . map (" "++) $ (show i : map printCond (S.toList conds))
56 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))
58 iLOG $ "USAGE ANALYSIS:\n" ++ unlines (map printItem . M.toList $ depMap)
58 iLOG $ "USAGE ANALYSIS:\n" ++ unlines (map printItem . M.toList $ depMap)
59 -- END TODO
59 -- END TODO
60
60
src/Idris/Erasure.hs+18−9
@@ -28,13 +28,9 @@ import Data.IntMap (IntMap)
28-- UseMap maps names to the set of used (reachable) argument positions.
28-- UseMap maps names to the set of used (reachable) argument positions.
29type UseMap = Map Name IntSet
29type UseMap = Map Name IntSet
30
30
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'.
31+-- DepMap maps functions (only functions) to their Deps.
37−type DepMap = Map Name Deps'
32+type DepMap = Map Name Deps
33+type FlatMap = Map (Name, Int) (Set (Ctors, Cond))
38
34
39-- Deps of a function is a map from argument index
35-- Deps of a function is a map from argument index
40-- to all usages of the argument, including conditions
36-- to all usages of the argument, including conditions
@@ -58,8 +54,21 @@ type Vars = Map Name Var
58type PatVar = Ctors -> Var
54type PatVar = Ctors -> Var
59type PatVars = Map Name PatVar
55type PatVars = Map Name PatVar
60
56
57+{-
58+-- Find the minimal consistent usage by forward chaining.
61minimalUsage :: DepMap -> UseMap
59minimalUsage :: 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+-}
63
72
64-- Build the dependency graph,
73-- Build the dependency graph,
65-- starting the depth-first search from a list of Names.
74-- starting the depth-first search from a list of Names.
@@ -73,7 +82,7 @@ buildDepMap ctx ns = dfs M.empty ns
73 dfs dmap [] = dmap
82 dfs dmap [] = dmap
74 dfs dmap (n : ns)
83 dfs dmap (n : ns)
75 | n `M.member` dmap = dfs dmap ns
84 | 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
77 where
86 where
78 next = [n | n <- S.toList depn, n `M.notMember` dmap]
87 next = [n | n <- S.toList depn, n `M.notMember` dmap]
79 depn = S.delete n (depNames deps)
88 depn = S.delete n (depNames deps)