Merge branch 'cλash' of http://git.stderr.nl/matthijs/projects/master-project
authorChristiaan Baaij <christiaan.baaij@gmail.com>
Tue, 8 Sep 2009 11:31:38 +0000 (13:31 +0200)
committerChristiaan Baaij <christiaan.baaij@gmail.com>
Tue, 8 Sep 2009 11:31:38 +0000 (13:31 +0200)
* 'cλash' of http://git.stderr.nl/matthijs/projects/master-project:
  Add a trailing newline to HighOrdAlu.
  Add comments to the inlinetoplevel transformation.
  Update comments for inlinenonrep.
  Fix typo.
  Fix typo.

HighOrdAlu.hs
cλash/CLasH/Normalize.hs
cλash/CLasH/VHDL/Generate.hs

index bdbdc3c28821a8aae361e33d445cffb5c05d41bc..8467c38d92ad815bc55053937a5445aac4a0f01f 100644 (file)
@@ -28,4 +28,4 @@ actual_alu :: (Opcode, Vector D4 (SizedInt D8), Vector D4 (SizedInt D8)) -> Vect
 --actual_alu = alu (constant Low) andop
 actual_alu (opc, a, b) = alu (anyset (+) (0 :: SizedInt D8)) (andop (-)) opc a b
 
-runalu = P.map actual_alu sim_input
\ No newline at end of file
+runalu = P.map actual_alu sim_input
index 6fd6a2e03cb0df3c5e553a57306f294b48e5d1cb..40eab93c3787e27d9b599d939aeccd8e77264352 100644 (file)
@@ -305,26 +305,45 @@ letmergetop = everywhere ("letmerge", letmerge)
 -}
 
 --------------------------------
--- Function inlining
+-- Non-representable binding inlining
 --------------------------------
--- Remove a = B bindings, with B :: a -> b, or B :: forall x . T, from let
--- expressions everywhere. This means that any value that still needs to be
--- applied to something else (polymorphic values need to be applied to a
--- Type) will be inlined, and will eventually be applied to all their
--- arguments.
+-- Remove a = B bindings, with B of a non-representable type, from let
+-- expressions everywhere. This means that any value that we can't generate a
+-- signal for, will be inlined and hopefully turned into something we can
+-- represent.
 --
 -- This is a tricky function, which is prone to create loops in the
 -- transformations. To fix this, we make sure that no transformation will
--- create a new let binding with a function type. These other transformations
--- will just not work on those function-typed values at first, but the other
--- transformations (in particular β-reduction) should make sure that the type
--- of those values eventually becomes primitive.
+-- create a new let binding with a non-representable type. These other
+-- transformations will just not work on those function-typed values at first,
+-- but the other transformations (in particular β-reduction) should make sure
+-- that the type of those values eventually becomes representable.
 inlinenonreptop :: Transform
 inlinenonreptop = everywhere ("inlinenonrep", inlinebind ((Monad.liftM not) . isRepr . snd))
 
+--------------------------------
+-- Top level function inlining
+--------------------------------
+-- This transformation inlines top level bindings that have been generated by
+-- the compiler and are really simple. Really simple currently means that the
+-- normalized form only contains a single binding, which catches most of the
+-- cases where a top level function is created that simply calls a type class
+-- method with a type and dictionary argument, e.g.
+--   fromInteger = GHC.Num.fromInteger (SizedWord D8) $dNum
+-- which is later called using simply
+--   fromInteger (smallInteger 10)
+-- By inlining such calls to simple, compiler generated functions, we prevent
+-- huge amounts of trivial components in the VHDL output, which the user never
+-- wanted. We never inline user-defined functions, since we want to preserve
+-- all structure defined by the user. Currently this includes all functions
+-- that were created by funextract, since we would get loops otherwise.
+--
+-- Note that "defined by the compiler" isn't completely watertight, since GHC
+-- doesn't seem to set all those names as "system names", we apply some
+-- guessing here.
 inlinetoplevel, inlinetopleveltop :: Transform
 -- Any system name is candidate for inlining. Never inline user-defined
--- functions, to preserver structure.
+-- functions, to preserve structure.
 inlinetoplevel expr@(Var f) | not $ isUserDefined f = do
   norm <- isNormalizeable f
   -- See if this is a top level binding for which we have a body
index b058e06c4b2ed3cc5b844fce8efbf293996a92c4..dee2a794694394b371f26129a1e79c54ae6c5da2 100644 (file)
@@ -207,7 +207,7 @@ mkConcSm (bndr, app@(CoreSyn.App _ _))= do
   let valargs = get_val_args (Var.varType f) args
   genApplication (Left bndr) f (map Left valargs)
 
--- A single alt case must be a selector. This means thee scrutinee is a simple
+-- A single alt case must be a selector. This means the scrutinee is a simple
 -- variable, the alternative is a dataalt with a single non-wild binder that
 -- is also returned.
 mkConcSm (bndr, expr@(CoreSyn.Case (CoreSyn.Var scrut) b ty [alt]))