diff options
-rw-r--r-- | Stackify.hs | 18 |
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) = |