From 9026d70f3c7e17eb361139cea95c5b1aa6c4b2a7 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Tue, 23 Jun 2009 16:12:50 +0200 Subject: [PATCH] Make appsimpl also simplify dataconstructors. These were previously left alone, since they were considered already simple (they're simple variable references). However, a dataconstructor can be translated to a VHDL expression, which can be assigned to a signal, but not used in the port map of an component instantiation. Also prevent letremovetop from inlining the datacon again. --- Normalize.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Normalize.hs b/Normalize.hs index 747a95b..9ee919a 100644 --- a/Normalize.hs +++ b/Normalize.hs @@ -140,7 +140,7 @@ letflattop = everywhere ("letflat", letflat) -------------------------------- -- Remove a = b bindings from let expressions everywhere letremovetop :: Transform -letremovetop = everywhere ("letremove", inlinebind (\(b, e) -> case e of (Var v) -> True; otherwise -> False)) +letremovetop = everywhere ("letremove", inlinebind (\(b, e) -> case e of (Var v) | not $ Id.isDataConWorkId v -> True; otherwise -> False)) -------------------------------- -- Function inlining @@ -288,8 +288,9 @@ caseremovetop = everywhere ("caseremove", caseremove) -------------------------------- -- Make sure that all arguments in an application are simple variables. appsimpl, appsimpltop :: Transform --- Don't simplify arguments that are already simple -appsimpl expr@(App f (Var _)) = return expr +-- Don't simplify arguments that are already simple. Do simplify datacons, +-- however, since we can't portmap literals. +appsimpl expr@(App f (Var v)) | not $ Id.isDataConWorkId v = return expr -- Simplify all non-applicable (to prevent loops with inlinefun) arguments, -- except for type arguments (since a let can't bind type vars, only a lambda -- can). Do this by introducing a new Let that binds the argument and passing -- 2.30.2