Moved the Pass list from Main to its own module (PassList) and included the usage-checking pass (when the appropriate option is turned on)

This commit is contained in:
Neil Brown 2008-01-16 03:26:20 +00:00
parent b8e4864d08
commit 5988684c00
3 changed files with 58 additions and 25 deletions

26
Main.hs
View File

@ -45,23 +45,9 @@ import Metadata
import ParseOccam import ParseOccam
import ParseRain import ParseRain
import Pass import Pass
import PassList
import PreprocessOccam import PreprocessOccam
import PrettyShow 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 type OptFunc = CompState -> IO CompState
@ -281,15 +267,7 @@ compile mode fn outHandle
ModeCompile -> ModeCompile ->
do progress "Passes:" do progress "Passes:"
let passes let passes = getPassList optsPS
= concat [ if csFrontend optsPS == FrontendRain
then rainPasses
else []
, commonPasses
, case csBackend optsPS of
BackendC -> genCPasses
BackendCPPCSP -> genCPPCSPPasses
]
ast2 <- runPasses passes ast1 ast2 <- runPasses passes ast1
debug "{{{ Generate code" debug "{{{ Generate code"

View File

@ -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/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/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/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/TLP.hs backends/BackendPasses.hs backends/AnalyseAsm.hs
tock_SOURCES_hs += backends/GenerateC.hs backends/GenerateCPPCSP.hs tock_SOURCES_hs += backends/GenerateC.hs backends/GenerateCPPCSP.hs
tock_SOURCES_hs += Main.hs tock_SOURCES_hs += Main.hs

55
common/PassList.hs Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
-}
-- | 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
]