summaryrefslogtreecommitdiff
path: root/compiler/cmm/CmmContFlowOpt.hs
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2011-08-22 13:56:17 +0100
committerSimon Marlow <marlowsd@gmail.com>2011-08-25 11:12:30 +0100
commit5b167f5edad7d3268de20452da7af05c38972f7c (patch)
tree36a14e64b510ede91e4e334f3e44d865321adcde /compiler/cmm/CmmContFlowOpt.hs
parent3108accd634a521b25471df19f063c2061d6d3ee (diff)
downloadhaskell-5b167f5edad7d3268de20452da7af05c38972f7c.tar.gz
Snapshot of codegen refactoring to share with simonpj
Diffstat (limited to 'compiler/cmm/CmmContFlowOpt.hs')
-rw-r--r--compiler/cmm/CmmContFlowOpt.hs13
1 files changed, 4 insertions, 9 deletions
diff --git a/compiler/cmm/CmmContFlowOpt.hs b/compiler/cmm/CmmContFlowOpt.hs
index 42fc239e28..a04b3a43e1 100644
--- a/compiler/cmm/CmmContFlowOpt.hs
+++ b/compiler/cmm/CmmContFlowOpt.hs
@@ -10,8 +10,7 @@ where
import BlockId
import Cmm
-import CmmDecl
-import CmmExpr
+import CmmUtils
import qualified OldCmm as Old
import Maybes
@@ -22,7 +21,7 @@ import Prelude hiding (succ, unzip, zip)
import Util
------------------------------------
-runCmmContFlowOpts :: Cmm -> Cmm
+runCmmContFlowOpts :: CmmPgm -> CmmPgm
runCmmContFlowOpts prog = runCmmOpts cmmCfgOpts prog
oldCmmCfgOpts :: Old.ListGraph Old.CmmStmt -> Old.ListGraph Old.CmmStmt
@@ -34,18 +33,14 @@ cmmCfgOpts =
-- Here branchChainElim can ultimately be replaced
-- with a more exciting combination of optimisations
-runCmmOpts :: (g -> g) -> GenCmm d h g -> GenCmm d h g
+runCmmOpts :: (g -> g) -> GenCmmPgm d h g -> GenCmmPgm d h g
-- Lifts a transformer on a single graph to one on the whole program
-runCmmOpts opt = mapProcs (optProc opt)
+runCmmOpts opt = map (optProc opt)
optProc :: (g -> g) -> GenCmmTop d h g -> GenCmmTop d h g
optProc _ top@(CmmData {}) = top
optProc opt (CmmProc info lbl g) = CmmProc info lbl (opt g)
-------------------------------------
-mapProcs :: (GenCmmTop d h s -> GenCmmTop d h s) -> GenCmm d h s -> GenCmm d h s
-mapProcs f (Cmm tops) = Cmm (map f tops)
-
----------------------------------------------------------------
oldBranchChainElim :: Old.ListGraph Old.CmmStmt -> Old.ListGraph Old.CmmStmt
-- If L is not captured in an instruction, we can remove any