Moved the enabling/disabling of passes based on CompState from PassList to the point of the declaration of the passes

This commit is contained in:
Neil Brown 2008-02-16 11:09:25 +00:00
parent 3ce0eaf452
commit 360abc195e
5 changed files with 16 additions and 13 deletions

View File

@ -46,7 +46,7 @@ import Utils
--{{{ passes related to C generation
genCPasses :: [Pass]
genCPasses = makePasses
genCPasses = makePasses' ((== BackendC) . csBackend)
[ ("Identify parallel processes", identifyParProcs)
,("Transform wait for guards into wait until guards", transformWaitFor)
]

View File

@ -134,7 +134,7 @@ cppgenOps = cgenOps {
--}}}
genCPPCSPPasses :: [Pass]
genCPPCSPPasses = makePasses
genCPPCSPPasses = makePasses' ((== BackendCPPCSP) . csBackend)
[ ("Transform channels to ANY", chansToAny)
]

View File

@ -57,6 +57,7 @@ data Monad m => Pass_ m = Pass {
,passName :: String
,passPre :: Set.Set Property
,passPost :: Set.Set Property
,passEnabled :: CompState -> Bool
}
type Pass = Pass_ PassM
@ -82,7 +83,10 @@ runPassR p t
Right result -> tell w >> return result
makePasses :: [(String, A.AST -> PassM A.AST)] -> [Pass]
makePasses = map (\(s, p) -> Pass p s Set.empty Set.empty)
makePasses = map (\(s, p) -> Pass p s Set.empty Set.empty (const True))
makePasses' :: (CompState -> Bool) -> [(String, A.AST -> PassM A.AST)] -> [Pass]
makePasses' f = map (\(s, p) -> Pass p s Set.empty Set.empty f)
-- | Compose a list of passes into a single pass.
-- TODO this needs to examine dependencies rather than running them in order!

View File

@ -34,21 +34,20 @@ import Unnest
commonPasses :: CompState -> [Pass]
commonPasses opts = concat $
[ simplifyTypes
] ++ (if csUsageChecking opts then [makePasses [("Usage checking", runPassR usageCheckPass)]] else []) ++
[ simplifyExprs
, makePasses' csUsageChecking [("Usage checking", runPassR usageCheckPass)]
, simplifyExprs
, simplifyProcs
, unnest
, simplifyComms
]
filterPasses :: CompState -> [Pass] -> [Pass]
filterPasses opts = filter (\p -> passEnabled p opts)
getPassList :: CompState -> [Pass]
getPassList optsPS = concat [ if csFrontend optsPS == FrontendRain
then rainPasses
else []
getPassList optsPS = filterPasses optsPS $ concat
[ rainPasses
, commonPasses optsPS
, case csBackend optsPS of
BackendC -> genCPasses
BackendCPPCSP -> genCPPCSPPasses
_ -> []
, genCPasses
, genCPPCSPPasses
]

View File

@ -36,7 +36,7 @@ import Types
-- | An ordered list of the Rain-specific passes to be run.
rainPasses :: [Pass]
rainPasses = makePasses
rainPasses = makePasses' ((== FrontendRain) . csFrontend)
[ ("AST Validity check, Rain #1", excludeNonRainFeatures)
,("Resolve Int -> Int64",transformInt)
,("Uniquify variable declarations, record declared types and resolve variable names",uniquifyAndResolveVars) --depends on transformInt