X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fmain%2FDriverPhases.hs;h=c094663bcb56cdcb733ae2a83e741de9277797d1;hb=53fe941370fd7fc90bf2e725f0f0b7c0382ceb4e;hp=89e8ef4b8ae2027053f63ac718f25756b054abec;hpb=b8b47abe336d17ae5354a9bb15c44564b51c97ef;p=ghc-hetmet.git diff --git a/ghc/compiler/main/DriverPhases.hs b/ghc/compiler/main/DriverPhases.hs index 89e8ef4..c094663 100644 --- a/ghc/compiler/main/DriverPhases.hs +++ b/ghc/compiler/main/DriverPhases.hs @@ -1,21 +1,28 @@ ----------------------------------------------------------------------------- --- $Id: DriverPhases.hs,v 1.9 2001/05/08 10:58:48 simonmar Exp $ +-- $Id: DriverPhases.hs,v 1.28 2003/10/22 14:31:09 simonmar Exp $ -- -- GHC Driver -- --- (c) Simon Marlow 2000 +-- (c) The University of Glasgow 2002 -- ----------------------------------------------------------------------------- +#include "../includes/config.h" + module DriverPhases ( Phase(..), + happensBefore, startPhase, -- :: String -> Phase phaseInputExt, -- :: Phase -> String - haskellish_file, haskellish_suffix, - haskellish_src_file, haskellish_src_suffix, - objish_file, objish_suffix, - cish_file, cish_suffix + isHaskellishFilename, + isHaskellSrcFilename, + isObjectFilename, + isCishFilename, + isExtCoreFilename, + isDynLibFilename, + isHaskellUserSrcFilename, + isSourceFilename -- :: FilePath -> Bool ) where import DriverUtil @@ -36,26 +43,47 @@ import DriverUtil -} data Phase - = MkDependHS -- haskell dependency generation - | Unlit + = Unlit | Cpp - | Hsc -- ToDo: HscTargetLang + | HsPp + | Hsc | Cc | HCc -- Haskellised C (as opposed to vanilla C) compilation | Mangle -- assembly mangling, now done by a separate script. | SplitMangle -- after mangler if splitting | SplitAs | As - | Ln + | Ln +#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` c_pipe = y `elem` tail (dropWhile (/= x) c_pipe) + | otherwise = False + +haskell_pipe = [Unlit,Cpp,HsPp,Hsc,HCc,Mangle,SplitMangle,As,SplitAs,Ln] +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 "hcr" = Hsc startPhase "hc" = HCc startPhase "c" = Cc +startPhase "cpp" = Cc +startPhase "C" = Cc +startPhase "cc" = Cc +startPhase "cxx" = Cc startPhase "raw_s" = Mangle startPhase "s" = As startPhase "S" = As @@ -66,6 +94,7 @@ startPhase _ = Ln -- all unknown file types -- the input requirements of the next phase. phaseInputExt Unlit = "lhs" phaseInputExt Cpp = "lpp" -- intermediate only +phaseInputExt HsPp = "hscpp" phaseInputExt Hsc = "hspp" phaseInputExt HCc = "hc" phaseInputExt Cc = "c" @@ -74,19 +103,42 @@ phaseInputExt SplitMangle = "split_s" -- not really generated phaseInputExt As = "s" phaseInputExt SplitAs = "split_s" -- not really generated phaseInputExt Ln = "o" -phaseInputExt MkDependHS = "dep" +#ifdef ILX +phaseInputExt Ilx2Il = "ilx" +phaseInputExt Ilasm = "il" +#endif -haskellish_suffix = (`elem` [ "hs", "hspp", "lhs", "hc", "raw_s" ]) -haskellish_src_suffix = (`elem` [ "hs", "hspp", "lhs" ]) -cish_suffix = (`elem` [ "c", "s", "S" ]) -- maybe .cc et al.?? +haskellish_suffixes = [ "hs", "lhs", "hspp", "hscpp", "hcr", "hc", "raw_s" ] +haskellish_src_suffixes = [ "hs", "lhs", "hspp", "hscpp", "hcr"] +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_suffix = (`elem` [ "o" ]) +objish_suffixes = [ "o" ] #endif -haskellish_file = haskellish_suffix . getFileSuffix -haskellish_src_file = haskellish_src_suffix . getFileSuffix -cish_file = cish_suffix . getFileSuffix -objish_file = objish_suffix . getFileSuffix +#ifdef mingw32_TARGET_OS +dynlib_suffixes = ["dll", "DLL"] +#elif defined(darwin_TARGET_OS) +dynlib_suffixes = ["dylib"] +#else +dynlib_suffixes = ["so"] +#endif + +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