summaryrefslogtreecommitdiff
path: root/compiler/cmm/CmmPipeline.hs
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2012-03-09 11:06:25 +0000
committerSimon Marlow <marlowsd@gmail.com>2012-03-15 13:25:15 +0000
commit643eb066aa221976d2d57f2e2a2c46bc7fb44e24 (patch)
tree512fe81bea1accf506d65e9f6bd7267ec054f94c /compiler/cmm/CmmPipeline.hs
parent2c4b427cdef4198ead5546e77cf30c8b71ba02dd (diff)
downloadhaskell-643eb066aa221976d2d57f2e2a2c46bc7fb44e24.tar.gz
Remove the old stack layout algorithms
Also, do removeDeadAssignments instead of cmmLiveness before stack allocation, because the former also does liveness analysis, and we can do just one liveness analysis instead of two. The stack layout algorithm doesn't introduce any dead assignments, so this doesn't affect the generated code.
Diffstat (limited to 'compiler/cmm/CmmPipeline.hs')
-rw-r--r--compiler/cmm/CmmPipeline.hs59
1 files changed, 13 insertions, 46 deletions
diff --git a/compiler/cmm/CmmPipeline.hs b/compiler/cmm/CmmPipeline.hs
index c7d3e561cc..470751bce4 100644
--- a/compiler/cmm/CmmPipeline.hs
+++ b/compiler/cmm/CmmPipeline.hs
@@ -16,12 +16,12 @@ import CmmLive
import CmmBuildInfoTables
import CmmCommonBlockElim
import CmmProcPoint
-import CmmSpillReload
import CmmRewriteAssignments
-import CmmStackLayout
import CmmContFlowOpt
import OptimizationFuel
import CmmLayoutStack
+import Hoopl
+import CmmUtils
import DynFlags
import ErrUtils
@@ -95,9 +95,6 @@ cpsTop :: HscEnv -> CmmDecl -> IO ([(CLabel, CAFSet)], [(CAFSet, CmmDecl)])
cpsTop _ p@(CmmData {}) = return ([], [(Set.empty, p)])
cpsTop hsc_env (CmmProc h@(TopInfo {stack_info=StackInfo {arg_space=entry_off}}) l g) =
do
- -- Why bother doing these early: dualLivenessWithInsertion,
- -- insertLateReloads, rewriteAssignments?
-
----------- Control-flow optimisations ---------------
g <- {-# SCC "cmmCfgOpts(1)" #-} return $ cmmCfgOpts g
dump Opt_D_dump_cmmz_cfg "Post control-flow optimsations" g
@@ -110,63 +107,33 @@ cpsTop hsc_env (CmmProc h@(TopInfo {stack_info=StackInfo {arg_space=entry_off}})
----------- Proc points -------------------
let callPPs = {-# SCC "callProcPoints" #-} callProcPoints g
- procPoints <- {-# SCC "minimalProcPointSet" #-} run $ minimalProcPointSet (targetPlatform dflags) callPPs g
+ procPoints <- {-# SCC "minimalProcPointSet" #-} run $
+ minimalProcPointSet (targetPlatform dflags) callPPs g
+ ----------- Layout the stack and manifest Sp ---------------
+ -- (also does: removeDeadAssignments, and lowerSafeForeignCalls)
(g, stackmaps) <- {-# SCC "layoutStack" #-}
run $ cmmLayoutStack procPoints entry_off g
dump Opt_D_dump_cmmz_sp "Layout Stack" g
--- g <- {-# SCC "addProcPointProtocols" #-} run $ addProcPointProtocols callPPs procPoints g
--- dump Opt_D_dump_cmmz_proc "Post Proc Points Added" g
---
--- ----------- Spills and reloads -------------------
--- g <- {-# SCC "dualLivenessWithInsertion" #-} run $ dualLivenessWithInsertion procPoints g
--- dump Opt_D_dump_cmmz_spills "Post spills and reloads" g
---
-- ----------- Sink and inline assignments -------------------
--- g <- {-# SCC "rewriteAssignments" #-} runOptimization $ rewriteAssignments platform g
+-- g <- {-# SCC "rewriteAssignments" #-} runOptimization $
+-- rewriteAssignments platform g
-- dump Opt_D_dump_cmmz_rewrite "Post rewrite assignments" g
---
-
- ----------- Eliminate dead assignments -------------------
- g <- {-# SCC "removeDeadAssignments" #-} runOptimization $ removeDeadAssignments g
- dump Opt_D_dump_cmmz_dead "Post remove dead assignments" g
-
--- ----------- Zero dead stack slots (Debug only) ---------------
--- -- Debugging: stubbing slots on death can cause crashes early
--- g <- if opt_StubDeadValues
--- then {-# SCC "stubSlotsOnDeath" #-} run $ stubSlotsOnDeath g
--- else return g
--- dump Opt_D_dump_cmmz_stub "Post stub dead stack slots" g
---
--- --------------- Stack layout ----------------
--- slotEnv <- {-# SCC "liveSlotAnal" #-} run $ liveSlotAnal g
--- let spEntryMap = getSpEntryMap entry_off g
--- mbpprTrace "live slot analysis results: " (ppr slotEnv) $ return ()
--- let areaMap = {-# SCC "layout" #-} layout procPoints spEntryMap slotEnv entry_off g
--- mbpprTrace "areaMap" (ppr areaMap) $ return ()
---
--- ------------ Manifest the stack pointer --------
--- g <- {-# SCC "manifestSP" #-} run $ manifestSP spEntryMap areaMap entry_off g
--- dump Opt_D_dump_cmmz_sp "Post manifestSP" g
--- -- UGH... manifestSP can require updates to the procPointMap.
--- -- We can probably do something quicker here for the update...
------------- Split into separate procedures ------------
- procPointMap <- {-# SCC "procPointAnalysis" #-} run $ procPointAnalysis procPoints g
+ procPointMap <- {-# SCC "procPointAnalysis" #-} run $
+ procPointAnalysis procPoints g
dumpWith dflags ppr Opt_D_dump_cmmz_procmap "procpoint map" procPointMap
- gs <- {-# SCC "splitAtProcPoints" #-} run $ splitAtProcPoints l callPPs procPoints procPointMap
- (CmmProc h l g)
+ gs <- {-# SCC "splitAtProcPoints" #-} run $
+ splitAtProcPoints l callPPs procPoints procPointMap (CmmProc h l g)
dumps Opt_D_dump_cmmz_split "Post splitting" gs
- ------------- More CAFs and foreign calls ------------
+ ------------- More CAFs ------------------------------
cafEnv <- {-# SCC "cafAnal" #-} run $ cafAnal platform g
let localCAFs = catMaybes $ map (localCAFInfo platform cafEnv) gs
mbpprTrace "localCAFs" (pprPlatform platform localCAFs) $ return ()
--- gs <- {-# SCC "lowerSafeForeignCalls" #-} run $ mapM (lowerSafeForeignCalls areaMap) gs
--- dumps Opt_D_dump_cmmz_lower "Post lowerSafeForeignCalls" gs
-
-- NO MORE GRAPH TRANSFORMATION AFTER HERE -- JUST MAKING INFOTABLES
gs <- {-# SCC "setInfoTableStackMap" #-}
return $ map (setInfoTableStackMap stackmaps) gs