Commit 8df97e40 authored by nr@eecs.harvard.edu's avatar nr@eecs.harvard.edu

drop the old, redundant implementation of postorder_dfs

parent fd57f5b3
...@@ -430,41 +430,12 @@ single_exitg (Graph tail blocks) = foldUFM add (exit_count (lastTail tail)) bloc ...@@ -430,41 +430,12 @@ single_exitg (Graph tail blocks) = foldUFM add (exit_count (lastTail tail)) bloc
-- Better to geot [A,B,C,D] -- Better to geot [A,B,C,D]
postorder_dfs' :: LastNode l => LGraph m l -> [Block m l]
postorder_dfs' g@(LGraph _ blocks) =
let FGraph _ eblock _ = entry g
in vnode (zip eblock) (\acc _visited -> acc) [] emptyBlockSet
where
-- vnode ::
-- Block m l -> ([Block m l] -> BlockSet -> a) -> [Block m l] -> BlockSet -> a
vnode block@(Block id _) cont acc visited =
if elemBlockSet id visited then
cont acc visited
else
vchildren block (get_children block) cont acc (extendBlockSet visited id)
vchildren block bs cont acc visited =
let next children acc visited =
case children of [] -> cont (block : acc) visited
(b:bs) -> vnode b (next bs) acc visited
in next bs acc visited
get_children block = foldl add_id [] (succs block)
add_id rst id = case lookupBlockEnv blocks id of
Just b -> b : rst
Nothing -> rst
postorder_dfs g@(LGraph _ blockenv) = postorder_dfs g@(LGraph _ blockenv) =
let FGraph id eblock _ = entry g let FGraph id eblock _ = entry g in
dfs1 = zip eblock : zip eblock : postorder_dfs_from_except blockenv eblock (unitUniqSet id)
postorder_dfs_from_except blockenv eblock (unitUniqSet id)
dfs2 = postorder_dfs' g
-- in ASSERT (map blockId dfs1 == map blockId dfs2) dfs2
in if (map blockId dfs1 == map blockId dfs2) then dfs2 else panic "inconsistent DFS"
postorder_dfs_from
:: (HavingSuccessors b, LastNode l) => BlockEnv (Block m l) -> b -> [Block m l]
postorder_dfs_from blocks b = postorder_dfs_from_except blocks b emptyBlockSet
postorder_dfs_from_except :: forall b m l . (HavingSuccessors b, LastNode l) => BlockEnv (Block m l) -> b -> BlockSet -> [Block m l] postorder_dfs_from_except :: (HavingSuccessors b, LastNode l)
=> BlockEnv (Block m l) -> b -> BlockSet -> [Block m l]
postorder_dfs_from_except blocks b visited = postorder_dfs_from_except blocks b visited =
vchildren (get_children b) (\acc _visited -> acc) [] visited vchildren (get_children b) (\acc _visited -> acc) [] visited
where where
...@@ -486,6 +457,11 @@ postorder_dfs_from_except blocks b visited = ...@@ -486,6 +457,11 @@ postorder_dfs_from_except blocks b visited =
Just b -> b : rst Just b -> b : rst
Nothing -> rst Nothing -> rst
postorder_dfs_from
:: (HavingSuccessors b, LastNode l) => BlockEnv (Block m l) -> b -> [Block m l]
postorder_dfs_from blocks b = postorder_dfs_from_except blocks b emptyBlockSet
-- | Slightly more complicated than the usual fold because we want to tell block -- | Slightly more complicated than the usual fold because we want to tell block
-- 'b1' what its inline successor is going to be, so that if 'b1' ends with -- 'b1' what its inline successor is going to be, so that if 'b1' ends with
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment