diff options
author | tomsmeding <tom.smeding@gmail.com> | 2017-08-27 20:34:57 +0200 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2017-08-27 20:34:57 +0200 |
commit | c129641b18156b463cd12318ba956c85a9017e39 (patch) | |
tree | 1b17cfa6b009db854380c983b7ea9a00507b9513 /Optimiser.hs | |
parent | aa049227c17f15ad22092f1fcab4410bbf3521ba (diff) |
Tenth
Diffstat (limited to 'Optimiser.hs')
-rw-r--r-- | Optimiser.hs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Optimiser.hs b/Optimiser.hs index 531bc7d..cea0601 100644 --- a/Optimiser.hs +++ b/Optimiser.hs @@ -203,6 +203,9 @@ movPush (IRFunc rt name al bbs sid) = IRFunc rt name al (map goBB bbs) sid | d' == d = if d' == s' then push mov rest term else push (d', s') rest term | d' == s = IMov d s : push (d', replaceRef d s s') rest term | otherwise = IMov d' (replaceRef d s s') : push mov rest term + push mov@(d, _) (ILea d' n : rest) term + | d' == d = ILea d' n : go rest term + | otherwise = ILea d' n : push mov rest term push mov@(d, s) (IResize d' s' : rest) term | d' == d = IResize d' (replaceRef d s s') : go rest term | d' == s = IMov d s : IResize d' (replaceRef d s s') : go rest term @@ -306,6 +309,9 @@ arithPush (IRFunc rt name al allbbs sid) = IRFunc rt name al resbbs sid propagate ari@(_, d, s1, s2) (Left ins@(IResize md _) : rest) | d /= md && md /= s1 && md /= s2 = fmap (Left ins :) $ propagate ari rest | otherwise = (False, Left ins : rest) + propagate ari@(_, d, s1, s2) (Left ins@(ILea md _) : rest) + | d /= md && md /= s1 && md /= s2 = fmap (Left ins :) $ propagate ari rest + | otherwise = (False, Left ins : rest) propagate ari (Left INop : rest) = propagate ari rest propagate (at, d, s1, s2) (Right term@(IJcc ct r1 r2 i1 i2) : rest) | (r1 == d || r2 == d) && @@ -389,6 +395,7 @@ removeUnusedInstructions (IRFunc rt name al bbs sid) = IRFunc rt name al (map go goI :: IRIns -> Maybe IRIns goI ins@(IMov d _) = pureInstruction d ins + goI ins@(ILea d _) = pureInstruction d ins goI ins@(IStore _ _) = Just ins goI ins@(ILoad d _) = pureInstruction d ins goI ins@(IAri _ d _ _) = pureInstruction d ins @@ -560,6 +567,7 @@ findAllRefsInss inss = uniq $ sort $ concatMap findAllRefsIns inss findAllRefsIns :: IRIns -> [Ref] findAllRefsIns (IMov a b) = [a, b] +findAllRefsIns (ILea a _) = [a] findAllRefsIns (IStore a b) = [a, b] findAllRefsIns (ILoad a b) = [a, b] findAllRefsIns (IAri _ a b c) = [a, b, c] |