X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fmaster-project%2Freport.git;a=blobdiff_plain;f=Chapters%2FNormalization.tex;h=1e5b200c0a82922b4f1b0c0350b09d6212372980;hp=f1b53dfa7bc681969763e478045cec681ca62b09;hb=4a1874f15102d7ad201d9f1f7fa8800bebff4ffc;hpb=4703461b0093f5c9a83876fad9d21a34c7a28eb4 diff --git a/Chapters/Normalization.tex b/Chapters/Normalization.tex index f1b53df..1e5b200 100644 --- a/Chapters/Normalization.tex +++ b/Chapters/Normalization.tex @@ -7,9 +7,9 @@ % space at the start of the frame. \define[1]\example{ \framed[offset=1mm,align=right,strut=no,background=box,frame=off]{ - \setuptyping[option=LAM,style=sans,before=,after=] + \setuptyping[option=LAM,style=sans,before=,after=,strip=auto] \typebuffer[#1] - \setuptyping[option=none,style=\tttf] + \setuptyping[option=none,style=\tttf,strip=auto] } } @@ -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 to use + non-alphanumerics 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 @@ -908,7 +950,7 @@ \starttrans (letrec binds in E) M - ----------------- + ------------------------ letrec binds in E M \stoptrans