From: Matthijs Kooijman Date: Tue, 23 Jun 2009 14:12:50 +0000 (+0200) Subject: Make appsimpl also simplify dataconstructors. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=9026d70f3c7e17eb361139cea95c5b1aa6c4b2a7;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git 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. --- 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