From 443b648d7371032f42956f85156f0d9d28ab769b Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Sat, 13 Oct 2007 20:52:42 +0000 Subject: [PATCH] Corrected the pass that creates abbreviations for output expressions to also work on OutputCase statements --- transformations/PassTest.hs | 23 +++++++++++++++++++++++ transformations/SimplifyComms.hs | 6 +++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/transformations/PassTest.hs b/transformations/PassTest.hs index 1c8d86e..20ee538 100644 --- a/transformations/PassTest.hs +++ b/transformations/PassTest.hs @@ -219,6 +219,29 @@ testOutExprs = TestList (defineName (xName) $ simpleDefDecl "x" A.Byte) (checkTempVarTypes "testOutExprs 3" [("temp_var", A.Byte)]) + -- Test that OutputCase is also processed: + ,TestCase $ testPassWithItemsStateCheck "testOutExprs 4" + (tag2 A.Seq DontCare $ (abbr "temp_var" A.Int (eXM 1)) + (tag2 A.OnlyP DontCare $ tag4 A.OutputCase emptyMeta chan (simpleName "foo") + [tag2 A.OutExpression emptyMeta (tag2 A.ExprVariable DontCare (tag2 A.Variable DontCare (Named "temp_var" DontCare)))]) + ) + (outExprs $ + A.OutputCase emptyMeta chan (simpleName "foo") [outXM 1] + ) + (defineName (xName) $ simpleDefDecl "x" A.Int) + (checkTempVarTypes "testOutExprs 3" [("temp_var", A.Int)]) + + -- Test that an empty outputcase works okay: + + ,TestCase $ testPass "testOutExprs 5" + (tag2 A.Seq DontCare $ + (tag2 A.OnlyP DontCare $ A.OutputCase emptyMeta chan (simpleName "foo") []) + ) + (outExprs $ + A.OutputCase emptyMeta chan (simpleName "foo") [] + ) + (return ()) + ] where outX = A.OutExpression emptyMeta $ exprVariable "x" diff --git a/transformations/SimplifyComms.hs b/transformations/SimplifyComms.hs index 92d49ab..86cf06f 100644 --- a/transformations/SimplifyComms.hs +++ b/transformations/SimplifyComms.hs @@ -44,8 +44,12 @@ outExprs = doGeneric `extM` doProcess doProcess :: A.Process -> PassM A.Process doProcess (A.Output m c ois) = do (ois', specs) <- mapAndUnzipM changeItem ois - let foldedSpec = foldl1 (.) specs + let foldedSpec = foldl (.) id specs return $ A.Seq m (foldedSpec $ A.OnlyP m $ A.Output m c ois') + doProcess (A.OutputCase m c tag ois) + = do (ois', specs) <- mapAndUnzipM changeItem ois + let foldedSpec = foldl (.) id specs + return $ A.Seq m (foldedSpec $ A.OnlyP m $ A.OutputCase m c tag ois') doProcess p = doGeneric p changeItem :: A.OutputItem -> PassM (A.OutputItem, A.Structured -> A.Structured)