From d4a795139f6e642441f0b497663d35f025a9480c Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sat, 30 Nov 2019 09:07:55 +0100 Subject: TODO note in Main about stackification --- Main.hs | 11 +++++++++++ Util.hs | 3 +++ lisphs.cabal | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Main.hs b/Main.hs index c378dde..2173653 100644 --- a/Main.hs +++ b/Main.hs @@ -38,6 +38,17 @@ parseOptions' (_, Just _) (_:_) = putStrLn "At most one filename argument expect parseOptions :: [String] -> IO (Options, Maybe FilePath) parseOptions = parseOptions' (Options False False, Nothing) +-- TODO: 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 consequences: +-- 1. No temporaries ever need to be pushed from the global context, or +-- "main function", since they can never be wrongly mutated: that +-- requires re-entering the function in which they were defined, but one +-- can never re-enter the "main function". +-- 2. No temporaries ever need to be pushed before a tail call; since no +-- local variables are live after it (obviously). (Global variables are +-- covered by point (1.).) liveness :: IRProgram -> Map.Map Int [Set.Set Int] liveness (IRProgram bbs _ _) = let sets = livenessAnalysis bbs bidOf itemsOf outEdges fread fwrite diff --git a/Util.hs b/Util.hs index 11b5658..9c3fbf0 100644 --- a/Util.hs +++ b/Util.hs @@ -1,5 +1,8 @@ +{-# LANGUAGE TupleSections #-} module Util where +import Data.Function (on) +import Data.List import qualified Data.Map.Strict as Map diff --git a/lisphs.cabal b/lisphs.cabal index 3bde869..32aebbe 100644 --- a/lisphs.cabal +++ b/lisphs.cabal @@ -13,4 +13,4 @@ executable lisp ghc-options: -Wall -O2 build-depends: base >= 4 && < 5, containers, filepath, mtl, parsec, text - other-modules: AST, Compiler, CompilerMacros, DString, Intermediate, Liveness, Optimiser, Parser, VM + other-modules: AST, Compiler, CompilerMacros, DString, Intermediate, Liveness, Optimiser, Parser, Util, VM -- cgit v1.2.3-54-g00ecf