From 19465d7ad8e913f2807a3512dae1cda71f2f8467 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Fri, 13 Dec 2019 13:49:50 +0100 Subject: Clean up FuncInfo in Stackify --- Stackify.hs | 18 ++++-------------- 1 file 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) = -- cgit v1.2.3