11module Stg.GHC.Backend where
22
33-- Compiler
4- import GHC
4+ import GHC hiding ( Backend )
55import GHC.Paths ( libdir )
66import GHC.Platform ( platformOS , osSubsectionsViaSymbols )
77import GHC.Driver.CodeOutput
@@ -10,11 +10,12 @@ import GHC.Driver.Main
1010import GHC.Driver.Phases
1111import GHC.Driver.Pipeline
1212import GHC.Driver.Session
13- -- import GHC.Driver.Types
1413import GHC.Utils.Error
1514import GHC.Utils.Outputable
1615import GHC.Builtin.Names (rOOT_MAIN )
1716import GHC.Unit.State
17+ import GHC.Types.Basic
18+ import GHC.Types.HpcInfo
1819
1920-- Stg Types
2021import GHC.Data.FastString
@@ -33,7 +34,7 @@ import GHC.Cmm
3334import GHC.Cmm.Info (cmmToRawCmm )
3435import GHC.StgToCmm (codeGen )
3536import GHC.Types.Unique.Supply ( mkSplitUniqSupply , initUs_ )
36- import GHC.StgToCmm.Types ( CgInfos ( .. ))
37+ import GHC.StgToCmm.Types
3738
3839import Control.Monad.Trans
3940import Control.Monad
@@ -61,11 +62,11 @@ modl = rOOT_MAIN
6162data Backend = NCG | LLVM
6263
6364
64- compileToObject :: Backend -> Unit -> ModuleName -> ForeignStubs -> [TyCon ] -> [StgTopBinding ] -> FilePath -> IO ()
65+ compileToObject :: Backend -> Unit -> ModuleName -> C. ForeignStubs -> [TyCon ] -> [StgTopBinding ] -> FilePath -> IO ()
6566compileToObject backend unitId modName stubs tyCons topBinds_simple outputName = do
6667 runGhc (Just libdir) $ compileToObjectM backend unitId modName stubs tyCons topBinds_simple outputName
6768
68- compileToObjectM :: Backend -> Unit -> ModuleName -> ForeignStubs -> [TyCon ] -> [StgTopBinding ] -> FilePath -> Ghc ()
69+ compileToObjectM :: Backend -> Unit -> ModuleName -> C. ForeignStubs -> [TyCon ] -> [StgTopBinding ] -> FilePath -> Ghc ()
6970compileToObjectM backend unitId modName stubs tyCons topBinds_simple outputName = do
7071 dflags <- getSessionDynFlags
7172
@@ -103,7 +104,7 @@ compileToObjectM backend unitId modName stubs tyCons topBinds_simple outputName
103104 -- Compile
104105 dflags <- getSessionDynFlags
105106 pkgs <- setSessionDynFlags $
106- dflags { hscTarget = target, ghcLink = NoLink }
107+ dflags { targetPlatform = target, ghcLink = NoLink }
107108 `gopt_set` Opt_KeepSFiles
108109 `gopt_set` Opt_KeepLlvmFiles
109110-- `dopt_set` Opt_D_dump_cmm
@@ -125,7 +126,7 @@ compileToObjectM backend unitId modName stubs tyCons topBinds_simple outputName
125126 pure ()
126127
127128
128- compileProgram :: Backend -> Bool -> [String ] -> [String ] -> [String ] -> [String ] -> ForeignStubs -> [TyCon ] -> [StgTopBinding ] -> IO ()
129+ compileProgram :: Backend -> Bool -> [String ] -> [String ] -> [String ] -> [String ] -> C. ForeignStubs -> [TyCon ] -> [StgTopBinding ] -> IO ()
129130compileProgram backend noHsMain incPaths libPaths ldOpts clikeFiles stubs tyCons topBinds_simple = runGhc (Just libdir) $ do
130131 dflags <- getSessionDynFlags
131132
@@ -176,7 +177,7 @@ type CollectedCCs
176177 setSessionDynFlags $
177178 (if noHsMain then flip gopt_set Opt_NoHsMain else id ) $
178179 dflags
179- { hscTarget = target
180+ { targetPlatform = target
180181 , ghcLink = LinkBinary
181182 , libraryPaths = libraryPaths dflags ++ libPaths
182183 , ldInputs = ldInputs dflags ++ map Option ldOpts
@@ -220,12 +221,12 @@ newGen :: DynFlags
220221 -> HscEnv
221222 -> FilePath
222223 -> Module
223- -> ForeignStubs
224+ -> C. ForeignStubs
224225 -> [TyCon ]
225226 -> CollectedCCs
226227 -> [StgTopBinding ]
227228 -> HpcInfo
228- -> IO (FilePath , Maybe FilePath , [(ForeignSrcLang , FilePath )], CgInfos )
229+ -> IO (FilePath , Maybe FilePath , [(ForeignSrcLang , FilePath )], CmmCgInfos )
229230newGen dflags hsc_env output_filename this_mod foreign_stubs data_tycons cost_centre_info stg_binds hpc_info = do
230231 -- TODO: add these to parameters
231232 let location = ModLocation
0 commit comments