summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2019-12-13 13:49:50 +0100
committertomsmeding <tom.smeding@gmail.com>2019-12-13 13:49:50 +0100
commit19465d7ad8e913f2807a3512dae1cda71f2f8467 (patch)
treeb5f3cc3b84fb4bca61a5cf4c71e176d528bf93af
parentfe57886e5d2122f9ea785012818b3f885e8d6a3f (diff)
Clean up FuncInfo in Stackify
-rw-r--r--Stackify.hs18
1 files changed, 4 insertions, 14 deletions
diff --git a/Stackify.hs b/Stackify.hs
index df43358..b4430ca 100644
--- a/Stackify.hs
+++ b/Stackify.hs
@@ -10,11 +10,6 @@ import Intermediate
import Liveness
-data FuncInfo =
- FuncInfo { fiInit :: Int
- , fiBBs :: [BB]
- , fiTemps :: [Int] }
-
-- Note about stackification. Temporaries need to be pushed before a call
-- if they're live after it and they could, conceivably, be wrongly mutated
-- by the called function otherwise. This has a couple of interesting
@@ -29,19 +24,14 @@ data FuncInfo =
stackify :: IRProgram -> IRProgram
stackify (IRProgram origbbs gfds datas) =
let (mainCode, funcCodes) = partitionFunctions gfds origbbs
- infos = FuncInfo 0 mainCode (onlyTemporaries (allRefs mainCode))
- : [FuncInfo bid0 bbs (onlyTemporaries (allRefs bbs))
- | (GlobFuncDef bid0 _ _, bbs) <- funcCodes]
- infos' = map stackifyF infos
- resbbs = concatMap fiBBs infos'
+ resbbs = concatMap stackifyF (mainCode : map snd funcCodes)
in optimise (IRProgram resbbs gfds datas)
where
- -- TODO: initBid and temps are actually unused, I think
- stackifyF :: FuncInfo -> FuncInfo
- stackifyF (FuncInfo initBid bbs temps) =
+ stackifyF :: [BB] -> [BB]
+ stackifyF bbs =
let livemap = liveness bbs
bbs' = [stackifyBB (livemap Map.! bid) bb | bb@(BB bid _ _) <- bbs]
- in FuncInfo initBid bbs' temps
+ in bbs'
stackifyBB :: [(Set.Set Int, Set.Set Int)] -> BB -> BB
stackifyBB live (BB bid inss term) =