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:
parent
3ce0eaf452
commit
360abc195e
|
@ -46,7 +46,7 @@ import Utils
|
||||||
|
|
||||||
--{{{ passes related to C generation
|
--{{{ passes related to C generation
|
||||||
genCPasses :: [Pass]
|
genCPasses :: [Pass]
|
||||||
genCPasses = makePasses
|
genCPasses = makePasses' ((== BackendC) . csBackend)
|
||||||
[ ("Identify parallel processes", identifyParProcs)
|
[ ("Identify parallel processes", identifyParProcs)
|
||||||
,("Transform wait for guards into wait until guards", transformWaitFor)
|
,("Transform wait for guards into wait until guards", transformWaitFor)
|
||||||
]
|
]
|
||||||
|
|
|
@ -134,7 +134,7 @@ cppgenOps = cgenOps {
|
||||||
--}}}
|
--}}}
|
||||||
|
|
||||||
genCPPCSPPasses :: [Pass]
|
genCPPCSPPasses :: [Pass]
|
||||||
genCPPCSPPasses = makePasses
|
genCPPCSPPasses = makePasses' ((== BackendCPPCSP) . csBackend)
|
||||||
[ ("Transform channels to ANY", chansToAny)
|
[ ("Transform channels to ANY", chansToAny)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,7 @@ data Monad m => Pass_ m = Pass {
|
||||||
,passName :: String
|
,passName :: String
|
||||||
,passPre :: Set.Set Property
|
,passPre :: Set.Set Property
|
||||||
,passPost :: Set.Set Property
|
,passPost :: Set.Set Property
|
||||||
|
,passEnabled :: CompState -> Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type Pass = Pass_ PassM
|
type Pass = Pass_ PassM
|
||||||
|
@ -82,7 +83,10 @@ runPassR p t
|
||||||
Right result -> tell w >> return result
|
Right result -> tell w >> return result
|
||||||
|
|
||||||
makePasses :: [(String, A.AST -> PassM A.AST)] -> [Pass]
|
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.
|
-- | Compose a list of passes into a single pass.
|
||||||
-- TODO this needs to examine dependencies rather than running them in order!
|
-- TODO this needs to examine dependencies rather than running them in order!
|
||||||
|
|
|
@ -34,21 +34,20 @@ import Unnest
|
||||||
commonPasses :: CompState -> [Pass]
|
commonPasses :: CompState -> [Pass]
|
||||||
commonPasses opts = concat $
|
commonPasses opts = concat $
|
||||||
[ simplifyTypes
|
[ simplifyTypes
|
||||||
] ++ (if csUsageChecking opts then [makePasses [("Usage checking", runPassR usageCheckPass)]] else []) ++
|
, makePasses' csUsageChecking [("Usage checking", runPassR usageCheckPass)]
|
||||||
[ simplifyExprs
|
, simplifyExprs
|
||||||
, simplifyProcs
|
, simplifyProcs
|
||||||
, unnest
|
, unnest
|
||||||
, simplifyComms
|
, simplifyComms
|
||||||
]
|
]
|
||||||
|
|
||||||
|
filterPasses :: CompState -> [Pass] -> [Pass]
|
||||||
|
filterPasses opts = filter (\p -> passEnabled p opts)
|
||||||
|
|
||||||
getPassList :: CompState -> [Pass]
|
getPassList :: CompState -> [Pass]
|
||||||
getPassList optsPS = concat [ if csFrontend optsPS == FrontendRain
|
getPassList optsPS = filterPasses optsPS $ concat
|
||||||
then rainPasses
|
[ rainPasses
|
||||||
else []
|
|
||||||
, commonPasses optsPS
|
, commonPasses optsPS
|
||||||
, case csBackend optsPS of
|
, genCPasses
|
||||||
BackendC -> genCPasses
|
, genCPPCSPPasses
|
||||||
BackendCPPCSP -> genCPPCSPPasses
|
|
||||||
_ -> []
|
|
||||||
]
|
]
|
||||||
|
|
|
@ -36,7 +36,7 @@ import Types
|
||||||
|
|
||||||
-- | An ordered list of the Rain-specific passes to be run.
|
-- | An ordered list of the Rain-specific passes to be run.
|
||||||
rainPasses :: [Pass]
|
rainPasses :: [Pass]
|
||||||
rainPasses = makePasses
|
rainPasses = makePasses' ((== FrontendRain) . csFrontend)
|
||||||
[ ("AST Validity check, Rain #1", excludeNonRainFeatures)
|
[ ("AST Validity check, Rain #1", excludeNonRainFeatures)
|
||||||
,("Resolve Int -> Int64",transformInt)
|
,("Resolve Int -> Int64",transformInt)
|
||||||
,("Uniquify variable declarations, record declared types and resolve variable names",uniquifyAndResolveVars) --depends on transformInt
|
,("Uniquify variable declarations, record declared types and resolve variable names",uniquifyAndResolveVars) --depends on transformInt
|
||||||
|
|
Loading…
Reference in New Issue
Block a user