X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fmain%2FDriverPhases.hs;h=89a610021b92ca5fcffd41ed8d64f1e4cb59cfd4;hb=423d477bfecd490de1449c59325c8776f91d7aac;hp=64344958e501387377f932101b5a3d0f291849d1;hpb=0171936c9092666692c69a7f93fa75af976330cb;p=ghc-hetmet.git diff --git a/ghc/compiler/main/DriverPhases.hs b/ghc/compiler/main/DriverPhases.hs index 6434495..89a6100 100644 --- a/ghc/compiler/main/DriverPhases.hs +++ b/ghc/compiler/main/DriverPhases.hs @@ -1,5 +1,5 @@ ----------------------------------------------------------------------------- --- $Id: DriverPhases.hs,v 1.16 2002/03/04 17:01:30 simonmar Exp $ +-- $Id: DriverPhases.hs,v 1.29 2004/08/13 13:06:57 simonmar Exp $ -- -- GHC Driver -- @@ -7,18 +7,22 @@ -- ----------------------------------------------------------------------------- -#include "../includes/config.h" +#include "../includes/ghcconfig.h" module DriverPhases ( Phase(..), + happensBefore, startPhase, -- :: String -> Phase phaseInputExt, -- :: Phase -> String - haskellish_file, haskellish_suffix, - haskellish_src_file, haskellish_src_suffix, - hsbootish_file, hsbootish_suffix, - objish_file, objish_suffix, - cish_file, cish_suffix + isHaskellishFilename, + isHaskellSrcFilename, + isObjectFilename, + isCishFilename, + isExtCoreFilename, + isDynLibFilename, + isHaskellUserSrcFilename, + isSourceFilename -- :: FilePath -> Bool ) where import DriverUtil @@ -39,12 +43,10 @@ import DriverUtil -} data Phase - = MkDependHS -- haskell dependency generation - | Unlit + = Unlit | Cpp | HsPp | Hsc - | HsBoot | Cc | HCc -- Haskellised C (as opposed to vanilla C) compilation | Mangle -- assembly mangling, now done by a separate script. @@ -52,19 +54,35 @@ data Phase | SplitAs | As | Ln + | CmmCpp -- pre-process Cmm source + | Cmm -- parse & compile Cmm code #ifdef ILX | Ilx2Il | Ilasm #endif deriving (Eq, Show) +-- Partial ordering on phases: we want to know which phases will occur before +-- which others. This is used for sanity checking, to ensure that the +-- pipeline will stop at some point (see DriverPipeline.runPipeline). +x `happensBefore` y + | x `elem` haskell_pipe = y `elem` tail (dropWhile (/= x) haskell_pipe) + | x `elem` cmm_pipe = y `elem` tail (dropWhile (/= x) cmm_pipe) + | x `elem` c_pipe = y `elem` tail (dropWhile (/= x) c_pipe) + | otherwise = False + +haskell_post_hsc = [HCc,Mangle,SplitMangle,As,SplitAs,Ln] +haskell_pipe = Unlit : Cpp : HsPp : Hsc : haskell_post_hsc +cmm_pipe = CmmCpp : Cmm : haskell_post_hsc +c_pipe = [Cc,As,Ln] + -- the first compilation phase for a given file is determined -- by its suffix. startPhase "lhs" = Unlit startPhase "hs" = Cpp startPhase "hscpp" = HsPp startPhase "hspp" = Hsc -startPhase "hs-boot" = HsBoot +startPhase "hcr" = Hsc startPhase "hc" = HCc startPhase "c" = Cc startPhase "cpp" = Cc @@ -75,6 +93,8 @@ startPhase "raw_s" = Mangle startPhase "s" = As startPhase "S" = As startPhase "o" = Ln +startPhase "cmm" = CmmCpp +startPhase "cmmcpp" = Cmm startPhase _ = Ln -- all unknown file types -- the output suffix for a given phase is uniquely determined by @@ -90,26 +110,44 @@ phaseInputExt SplitMangle = "split_s" -- not really generated phaseInputExt As = "s" phaseInputExt SplitAs = "split_s" -- not really generated phaseInputExt Ln = "o" -phaseInputExt MkDependHS = "dep" -phaseInputExt HsBoot = "hs-boot" +phaseInputExt CmmCpp = "cmm" +phaseInputExt Cmm = "cmmcpp" #ifdef ILX phaseInputExt Ilx2Il = "ilx" phaseInputExt Ilasm = "il" #endif -haskellish_suffix = (`elem` [ "hs", "hspp", "hscpp", "lhs", "hc", "raw_s" ]) -haskellish_src_suffix = (`elem` [ "hs", "hspp", "hscpp", "lhs" ]) -cish_suffix = (`elem` [ "c", "cpp", "C", "cc", "cxx", "s", "S" ]) -hsbootish_suffix = (`elem` [ "hs-boot" ]) +haskellish_suffixes = [ "hs", "lhs", "hspp", "hscpp", "hcr", "hc", "raw_s", "cmm" ] +haskellish_src_suffixes = [ "hs", "lhs", "hspp", "hscpp", "hcr", "cmm" ] +cish_suffixes = [ "c", "cpp", "C", "cc", "cxx", "s", "S" ] +extcoreish_suffixes = [ "hcr" ] +haskellish_user_src_suffixes = [ "hs", "lhs" ] +-- Use the appropriate suffix for the system on which +-- the GHC-compiled code will run #if mingw32_TARGET_OS || cygwin32_TARGET_OS -objish_suffix = (`elem` [ "o", "O", "obj", "OBJ" ]) +objish_suffixes = [ "o", "O", "obj", "OBJ" ] +#else +objish_suffixes = [ "o" ] +#endif + +#ifdef mingw32_TARGET_OS +dynlib_suffixes = ["dll", "DLL"] +#elif defined(darwin_TARGET_OS) +dynlib_suffixes = ["dylib"] #else -objish_suffix = (`elem` [ "o" ]) +dynlib_suffixes = ["so"] #endif -haskellish_file = haskellish_suffix . getFileSuffix -haskellish_src_file = haskellish_src_suffix . getFileSuffix -cish_file = cish_suffix . getFileSuffix -objish_file = objish_suffix . getFileSuffix -hsbootish_file = hsbootish_suffix . getFileSuffix +isHaskellishFilename f = getFileSuffix f `elem` haskellish_suffixes +isHaskellSrcFilename f = getFileSuffix f `elem` haskellish_src_suffixes +isCishFilename f = getFileSuffix f `elem` cish_suffixes +isExtCoreFilename f = getFileSuffix f `elem` extcoreish_suffixes +isObjectFilename f = getFileSuffix f `elem` objish_suffixes +isHaskellUserSrcFilename f = getFileSuffix f `elem` haskellish_user_src_suffixes +isDynLibFilename f = getFileSuffix f `elem` dynlib_suffixes + +isSourceFilename :: FilePath -> Bool +isSourceFilename f = + isHaskellishFilename f || + isCishFilename f