From: Matthijs Kooijman Date: Wed, 4 Nov 2009 14:26:58 +0000 (+0100) Subject: Describe Top level binding inlining. X-Git-Tag: final-thesis~173 X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fmaster-project%2Freport.git;a=commitdiff_plain;h=63011ad76e4813e43544f8e938be40de2853acb4;hp=2623fc848f36caddf9513b9e0dc37419a53d486c Describe Top level binding inlining. --- diff --git a/Chapters/Normalization.tex b/Chapters/Normalization.tex index f1b53df..89c2d4a 100644 --- a/Chapters/Normalization.tex +++ b/Chapters/Normalization.tex @@ -862,8 +862,50 @@ Since its exact role and need is not clear yet, this transformation is not yet specified. - \subsubsection{Compiler generated top level binding inlining} - TODO + \subsubsection{Top level binding inlining} + This transform takes simple top level bindings generated by the + \small{GHC} compiler. \small{GHC} sometimes generates very simple + \quote{wrapper} bindings, which are bound to just a variable + reference, or a partial application to constants or other variable + references. + + Note that this transformation is completely optional. It is not + required to get any function into normal form, but it does help making + the resulting VHDL output easier to read (since it removes a bunch of + components that are really boring). + + This transform takes any top level binding generated by the compiler, + whose normalized form contains only a single let binding. + + \starttrans + x = λa0 ... λan.let y = E in y + ~ + x + -------------------------------------- \lam{x} is generated by the compiler + λa0 ... λan.let y = E in y + \stoptrans + + \startbuffer[from] + (+) :: Word -> Word -> Word + (+) = GHC.Num.(+) @Word $dNum + ~ + (+) a b + \stopbuffer + \startbuffer[to] + GHC.Num.(+) @ Alu.Word $dNum a b + \stopbuffer + + \transexample{Top level binding inlining}{from}{to} + + Without this transformation, the (+) function would generate an + architecture which would just add its inputs. This generates a lot of + overhead in the VHDL, which is particularly annoying when browsing the + generated RTL schematic (especially since + is not allowed in VHDL + architecture names\footnote{Technically, it is allowed when using + extended identifiers, but it seems that none of the tooling likes + extended identifiers in filenames, so it effectively doesn't work}, so + the entity would be called \quote{w7aA7f} or something similarly + unreadable and autogenerated). \subsection{Program structure} These transformations are aimed at normalizing the overall structure