diff --git a/Main.hs b/Main.hs index 9bc9845..a8cdb5a 100644 --- a/Main.hs +++ b/Main.hs @@ -45,23 +45,9 @@ import Metadata import ParseOccam import ParseRain import Pass +import PassList import PreprocessOccam import PrettyShow -import RainPasses -import SimplifyComms -import SimplifyExprs -import SimplifyProcs -import SimplifyTypes -import Unnest - -commonPasses :: [(String, Pass)] -commonPasses = - [ ("Simplify types", simplifyTypes) - , ("Simplify expressions", simplifyExprs) - , ("Simplify processes", simplifyProcs) - , ("Flatten nested declarations", unnest) - , ("Simplify communications", simplifyComms) - ] type OptFunc = CompState -> IO CompState @@ -281,15 +267,7 @@ compile mode fn outHandle ModeCompile -> do progress "Passes:" - let passes - = concat [ if csFrontend optsPS == FrontendRain - then rainPasses - else [] - , commonPasses - , case csBackend optsPS of - BackendC -> genCPasses - BackendCPPCSP -> genCPPCSPPasses - ] + let passes = getPassList optsPS ast2 <- runPasses passes ast1 debug "{{{ Generate code" diff --git a/Makefile.am b/Makefile.am index 92cff7a..b80e33b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -60,7 +60,7 @@ tock_SOURCES_hs += common/Pass.hs common/TreeUtils.hs common/Intrinsics.hs commo tock_SOURCES_hs += common/Pattern.hs common/Errors.hs common/ShowCode.hs common/PrettyShow.hs tock_SOURCES_hs += common/EvalConstants.hs common/Utils.hs common/CompState.hs common/Types.hs tock_SOURCES_hs += common/Metadata.hs common/AST.hs common/FlowGraph.hs common/FlowAlgorithms.hs -tock_SOURCES_hs += common/TagAST.hs +tock_SOURCES_hs += common/TagAST.hs common/PassList.hs tock_SOURCES_hs += backends/TLP.hs backends/BackendPasses.hs backends/AnalyseAsm.hs tock_SOURCES_hs += backends/GenerateC.hs backends/GenerateCPPCSP.hs tock_SOURCES_hs += Main.hs diff --git a/common/PassList.hs b/common/PassList.hs new file mode 100644 index 0000000..a4b2e6f --- /dev/null +++ b/common/PassList.hs @@ -0,0 +1,55 @@ +{- +Tock: a compiler for parallel languages +Copyright (C) 2007 University of Kent + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation, either version 2 of the License, or (at your +option) any later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +-} + +-- | Lists of passes +module PassList (getPassList) where + +import ArrayUsageCheck +import CompState +import GenerateC +import GenerateCPPCSP +import Pass +import RainPasses +import SimplifyComms +import SimplifyExprs +import SimplifyProcs +import SimplifyTypes +import Unnest + +commonPasses :: CompState -> [(String, Pass)] +commonPasses opts = + [ ("Simplify types", simplifyTypes) + , ("Simplify expressions", simplifyExprs) + ] + ++ (if csUsageChecking opts then [("Check array usage", checkArrayUsage)] else []) ++ + [ + ("Simplify processes", simplifyProcs) + , ("Flatten nested declarations", unnest) + , ("Simplify communications", simplifyComms) + ] + + +getPassList :: CompState -> [(String, Pass)] +getPassList optsPS = concat [ if csFrontend optsPS == FrontendRain + then rainPasses + else [] + , commonPasses optsPS + , case csBackend optsPS of + BackendC -> genCPasses + BackendCPPCSP -> genCPPCSPPasses + ]