Commit e9d303dc authored by nr@eecs.harvard.edu's avatar nr@eecs.harvard.edu
Browse files

refactor duplicated code in main/HscMain

  I kept making mistakes because all the ZipCfg and CPS stuff
  was called from two different places (compiling Haskell and 
  compiling Cmm).  Now it is called from a single place, and therefore
  successfully turned off by default.

  I still don't know why turning it on causes rts/Apply.cmm not to
  compile; that development is new since yesterday.
parent 95c5ef95
...@@ -594,17 +594,9 @@ hscCompile cgguts ...@@ -594,17 +594,9 @@ hscCompile cgguts
codeGen dflags this_mod data_tycons codeGen dflags this_mod data_tycons
dir_imps cost_centre_info dir_imps cost_centre_info
stg_binds hpc_info stg_binds hpc_info
-------- Optionally convert to and from zipper ------ --- Optionally run experimental Cmm transformations ---
cmms <- cmms <- optionallyConvertAndOrCPS dflags cmms
if dopt Opt_ConvertToZipCfgAndBack dflags -- ^ unless certain dflags are on, the identity function
then mapM (testCmmConversion dflags) cmms
else return cmms
------------ Optionally convert to CPS --------------
cmms <-
if not (dopt Opt_ConvertToZipCfgAndBack dflags) &&
dopt Opt_RunCPSZ dflags
then cmmCPS dflags cmms
else return cmms
------------------ Code output ----------------------- ------------------ Code output -----------------------
rawcmms <- cmmToRawCmm cmms rawcmms <- cmmToRawCmm cmms
(_stub_h_exists, stub_c_exists) (_stub_h_exists, stub_c_exists)
...@@ -717,10 +709,9 @@ hscCmmFile dflags filename = do ...@@ -717,10 +709,9 @@ hscCmmFile dflags filename = do
case maybe_cmm of case maybe_cmm of
Nothing -> return False Nothing -> return False
Just cmm -> do Just cmm -> do
cmm <- testCmmConversion dflags cmm cmms <- optionallyConvertAndOrCPS dflags [cmm]
--continuationC <- cmmCPS dflags cmm >>= cmmToRawCmm rawCmms <- cmmToRawCmm cmms
continuationC <- cmmToRawCmm [cmm] codeOutput dflags no_mod no_loc NoStubs [] rawCmms
codeOutput dflags no_mod no_loc NoStubs [] continuationC
return True return True
where where
no_mod = panic "hscCmmFile: no_mod" no_mod = panic "hscCmmFile: no_mod"
...@@ -728,6 +719,20 @@ hscCmmFile dflags filename = do ...@@ -728,6 +719,20 @@ hscCmmFile dflags filename = do
ml_hi_file = panic "hscCmmFile: no hi file", ml_hi_file = panic "hscCmmFile: no hi file",
ml_obj_file = panic "hscCmmFile: no obj file" } ml_obj_file = panic "hscCmmFile: no obj file" }
optionallyConvertAndOrCPS :: DynFlags -> [Cmm] -> IO [Cmm]
optionallyConvertAndOrCPS dflags cmms =
do -------- Optionally convert to and from zipper ------
cmms <- if dopt Opt_ConvertToZipCfgAndBack dflags
then mapM (testCmmConversion dflags) cmms
else return cmms
--------- Optionally convert to CPS (MDA) -----------
cmms <- if not (dopt Opt_ConvertToZipCfgAndBack dflags) &&
dopt Opt_RunCPSZ dflags
then cmmCPS dflags cmms
else return cmms
return cmms
testCmmConversion :: DynFlags -> Cmm -> IO Cmm testCmmConversion :: DynFlags -> Cmm -> IO Cmm
testCmmConversion dflags cmm = testCmmConversion dflags cmm =
do showPass dflags "CmmToCmm" do showPass dflags "CmmToCmm"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment