summaryrefslogtreecommitdiff
path: root/Intermediate.hs
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2019-11-29 12:01:43 +0100
committertomsmeding <tom.smeding@gmail.com>2019-11-30 10:19:16 +0100
commit5347cb83e730a84fabe162dfc722132cc3ed0f75 (patch)
tree8fc73547c30f66365eb5d48e73ac11e9e302da66 /Intermediate.hs
parentfbe7dbf3b1efe3615f87f0327871ebfd80f1e050 (diff)
WIP push temporaries before calls
Requires liveness analysis
Diffstat (limited to 'Intermediate.hs')
-rw-r--r--Intermediate.hs11
1 files changed, 8 insertions, 3 deletions
diff --git a/Intermediate.hs b/Intermediate.hs
index b0f12b9..2705431 100644
--- a/Intermediate.hs
+++ b/Intermediate.hs
@@ -5,6 +5,7 @@ import qualified Data.Map.Strict as Map
import Data.Maybe
import AST
+import Util
data IRProgram =
@@ -60,20 +61,24 @@ termOf (BB _ _ t) = t
class AllRefs a where
allRefs :: a -> [Ref]
+instance AllRefs BB where
+ allRefs (BB _ inss term) =
+ sortUniq $ concatMap (allRefs . snd) inss ++ allRefs term
+
instance AllRefs InsCode where
allRefs (IAssign r) = [r]
allRefs (IParam _) = []
allRefs (IClosure _) = []
allRefs (IData _) = []
- allRefs (ICallC r rs) = r : rs
- allRefs (IAllocClo _ rs) = rs
+ allRefs (ICallC r rs) = sortUniq (r : rs)
+ allRefs (IAllocClo _ rs) = sortUniq rs
allRefs (IDiscard r) = [r]
instance AllRefs Terminator where
allRefs (IBr r _ _) = [r]
allRefs (IJmp _) = []
allRefs (IRet r) = [r]
- allRefs (ITailC r rs) = r : rs
+ allRefs (ITailC r rs) = sortUniq (r : rs)
allRefs IExit = []
allRefs IUnknown = []