X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fmain%2FHscMain.lhs;h=a9c9a1501d6bfd36de82ed6089d4345116e5bf8a;hb=663b391470a783e8f23414c07c18a020850d2fb8;hp=282ec0f2cc19ef2b22079e1486e659835244cdaa;hpb=e5f78a4a5309b598d5195aa49a0bf7a206942cea;p=ghc-hetmet.git diff --git a/compiler/main/HscMain.lhs b/compiler/main/HscMain.lhs index 282ec0f..a9c9a15 100644 --- a/compiler/main/HscMain.lhs +++ b/compiler/main/HscMain.lhs @@ -51,8 +51,9 @@ import Module ( emptyModuleEnv, ModLocation(..) ) import RdrName ( GlobalRdrEnv, RdrName, emptyGlobalRdrEnv ) import HsSyn ( HsModule, LHsBinds, HsGroup, LIE, LImportDecl, HsDoc, HaddockModInfo ) +import CoreSyn import SrcLoc ( Located(..) ) -import StringBuffer ( hGetStringBuffer, stringToStringBuffer ) +import StringBuffer import Parser import Lexer import SrcLoc ( mkSrcLoc ) @@ -74,6 +75,8 @@ import Name ( Name, NamedThing(..) ) import SimplStg ( stg2stg ) import CodeGen ( codeGen ) import CmmParse ( parseCmmFile ) +import CmmCPS +import CmmInfo import CodeOutput ( codeOutput ) import NameEnv ( emptyNameEnv ) @@ -183,7 +186,8 @@ data HscChecked Maybe (HsDoc Name), HaddockModInfo Name)) -- typechecked (Maybe (LHsBinds Id, GlobalRdrEnv, ModDetails)) - + -- desugared + (Maybe [CoreBind]) -- Status of a compilation to hard-code or nothing. data HscStatus @@ -472,13 +476,11 @@ hscSimplify :: ModGuts -> Comp ModGuts hscSimplify ds_result = do hsc_env <- gets compHscEnv liftIO $ do - flat_result <- {-# SCC "Flattening" #-} - flatten hsc_env ds_result ------------------- -- SIMPLIFY ------------------- simpl_result <- {-# SCC "Core2Core" #-} - core2core hsc_env flat_result + core2core hsc_env ds_result return simpl_result -------------------------------------------------------------- @@ -599,12 +601,15 @@ hscCompile cgguts ------------------ Code generation ------------------ abstractC <- {-# SCC "CodeGen" #-} codeGen dflags this_mod data_tycons - foreign_stubs dir_imps cost_centre_info + dir_imps cost_centre_info stg_binds hpc_info + ------------------ Convert to CPS -------------------- + --continuationC <- cmmCPS dflags abstractC >>= cmmToRawCmm + continuationC <- cmmToRawCmm abstractC ------------------ Code output ----------------------- (stub_h_exists,stub_c_exists) <- codeOutput dflags this_mod location foreign_stubs - dependencies abstractC + dependencies continuationC return stub_c_exists hscConst :: b -> a -> Comp b @@ -646,8 +651,8 @@ hscInteractive (iface, details, cgguts) ------------------------------ -hscFileCheck :: HscEnv -> ModSummary -> IO (Maybe HscChecked) -hscFileCheck hsc_env mod_summary = do { +hscFileCheck :: HscEnv -> ModSummary -> Bool -> IO (Maybe HscChecked) +hscFileCheck hsc_env mod_summary compileToCore = do { ------------------- -- PARSE ------------------- @@ -666,14 +671,14 @@ hscFileCheck hsc_env mod_summary = do { -- RENAME and TYPECHECK ------------------- (tc_msgs, maybe_tc_result) - <- _scc_ "Typecheck-Rename" + <- {-# SCC "Typecheck-Rename" #-} tcRnModule hsc_env (ms_hsc_src mod_summary) True{-save renamed syntax-} rdr_module ; printErrorsAndWarnings dflags tc_msgs ; case maybe_tc_result of { - Nothing -> return (Just (HscChecked rdr_module Nothing Nothing)); + Nothing -> return (Just (HscChecked rdr_module Nothing Nothing Nothing)); Just tc_result -> do let type_env = tcg_type_env tc_result md = ModDetails { @@ -685,8 +690,7 @@ hscFileCheck hsc_env mod_summary = do { md_rules = [panic "no rules"], -- Rules are CoreRules, not the -- RuleDecls we get out of the typechecker - md_vect_info = - panic "HscMain.hscFileCheck: no VectInfo" + md_vect_info = noVectInfo -- VectInfo is added by the Core -- vectorisation pass } @@ -696,11 +700,17 @@ hscFileCheck hsc_env mod_summary = do { let doc = tcg_doc tc_result hmi = tcg_hmi tc_result return (decl,imports,exports,doc,hmi) - return (Just (HscChecked rdr_module + maybeModGuts <- + if compileToCore then + deSugar hsc_env (ms_location mod_summary) tc_result + else + return Nothing + return (Just (HscChecked rdr_module rnInfo (Just (tcg_binds tc_result, tcg_rdr_env tc_result, - md)))) + md)) + (fmap mg_binds maybeModGuts))) }}}} @@ -710,7 +720,9 @@ hscCmmFile dflags filename = do case maybe_cmm of Nothing -> return False Just cmm -> do - codeOutput dflags no_mod no_loc NoStubs [] [cmm] + --continuationC <- cmmCPS dflags [cmm] >>= cmmToRawCmm + continuationC <- cmmToRawCmm [cmm] + codeOutput dflags no_mod no_loc NoStubs [] continuationC return True where no_mod = panic "hscCmmFile: no_mod" @@ -719,6 +731,8 @@ hscCmmFile dflags filename = do ml_obj_file = panic "hscCmmFile: no obj file" } +myParseModule :: DynFlags -> FilePath -> Maybe StringBuffer + -> IO (Either ErrMsg (Located (HsModule RdrName))) myParseModule dflags src_filename maybe_src_buf = -------------------------- Parser ---------------- showPass dflags "Parser" >>