Commits

Even Wiik Thomassen committed 99ac395

GHC code generation improvements.

  • Participants
  • Parent commits 94b92b4

Comments (0)

Files changed (5)

File acronyms.tex

 \newacronym{gadt}{GADT}{generalized algebraic data types}
 \newacronym{ghc}{GHC}{the Glasgow Haskell Compiler}
 \newacronym{ghci}{GHCi}{GHC's interactive environment}
+\newacronym{gcc}{GCC}{GNU Compiler Collection}
 \newacronym{hsc}{Hsc}{Haskell compiler}
 \newacronym{ir}{IR}{intermediate representation}
 \newacronym{jit}{JIT}{just-in-time compilation}
 optimizations, and other optimizations performed by \gls{ghc}, are described in
 \autoref{sec:ghc-optimizations}.
 
-After the optimization stage the code can either be turned over to the backend
-to generate low-level code, or it can be turned into bytecode. The bytecode is
-used by the interactive Haskell interpreter, \gls{ghci}. Before code
-generation, Core is transformed into another intermediate representation called
-\gls{stg}. \gls{stg} is a A-normalized lambda calculus that defines \gls{ghc}'s
-execution model.
+After the \textit{optimization} stage the code can either be turned over to the
+backend to generate low-level code, or it can be turned into bytecode. The
+bytecode is used by the interactive Haskell interpreter, \gls{ghci}. Before
+code generation, Core is transformed into another intermediate representation
+called \gls{stg}. \gls{stg} is a A-normalized lambda calculus that defines
+\gls{ghc}'s execution model~\cite{jones89}.
 
-\mytodo{Describe better/more accurate the code generation}
-The next step of the backend is to convert \gls{stg} into yet another
-intermediate representation, \gls{cmm}. \gls{cmm} is a variant of the C--
-language, and is almost a subset of C that support tail
-calls~\cite{jones89, terei, ghc}. \gls{cmm} serves as input to the three code
-generating backends provided by \gls{ghc}:
+The next step is the actual \textit{code generation}, which convert \gls{stg}
+into another intermediate representation, \gls{cmm}. \gls{cmm} is a variant of
+the C-- language, and is almost a subset of C that support tail recursive
+calls~\cite{terei, ghc}. \gls{cmm} is finally converted to
+object code by one of three low-level code generating backends:
 \begin{itemize}
-    \item The C code generator, which generates C code that can be ported to
-        many different platforms, but is not as fast as the other backends, and
-        is significantly slower to compile.
+    \item The C code generator, which pretty-print \gls{cmm} to C code. The C
+        code is then compiled with \gls{gcc}. Is very portable, as it can be
+        used on most architectures that support \gls{gcc}, but the produced
+        code is not as fast as the other two backends and the compilation
+        process is significantly slower.
+    \item The native code generator that only support a few architectures, but
+        produces faster code than the C backend.
     \item The LLVM code generator, which produce LLVM IR that is compiled with
-        LLVM.
-    \item The native code generator, which supports a few architectures, and
-        produces fast code.
+        LLVM\@. This backend is described in more detail in \mypref{sec:llvm}.
 \end{itemize}
-The process of these code generator backends can be seen in
+An overview over the process of these code generator backends can be seen in
 \autoref{fig:ghc-backends}~\cite{ghc, terei}.
 
 \begin{figure}[tbp]
 \end{figure}
 
 The strictness analyzer finds variables and arguments that can be treated
-strictly, and allows optimizations such as unboxing that would not be allowed
+strictly, which enable optimizations such as unboxing that would not be allowed
 for lazy arguments~\cite{jones93}. Let-floating moves let bindings closer to
 where they are used, which avoids unnecessary allocations if they are on a
 branch that is never executed~\cite{jones96}. Constructor specialization

File img/ghc-compilation.dia

Binary file modified.

File img/ghc-compilation.png

Old
Old image
New
New image
 % Chapters
 %----------
 %\include{introduction}
-%\include{ghc} % Haskell, GHC, Core
+\include{ghc} % Haskell, GHC, Core
 \include{rpython} % Python, PyPy, RPython, JIT
 \include{extcore} % GHC's External Core
 \include{pyhaskell} % Everyhing about PyHaskell
 %\include{evaluation}  % (result)
 %\include{discussion}
 %\include{conclusion}
-%\include{related}
+\include{related}
 
 % Appendices
 %------------