1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
4 <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
5 <title>The GHC Commentary - Spineless Tagless C</title>
8 <body BGCOLOR="FFFFFF">
9 <h1>The GHC Commentary - Spineless Tagless C</h1>
11 The C code generated by GHC doesn't use higher-level features of C to be
12 able to control as precisely as possible what code is generated.
13 Moreover, it uses special features of gcc (such as, first class labels)
14 to produce more efficient code.
16 STG C makes ample use of C's macro language to define idioms, which also
17 reduces the size of the generated C code (thus, reducing I/O times).
18 These macros are defined in the C headers located in GHC's <a
19 href="http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/ghc/includes/"><code>includes</code></a>
22 <h4><code>TailCalls.h</code></h4>
25 href="http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/ghc/includes/TailCalls.h"><code>TailCalls.h</code></a>
26 defines how tail calls are implemented - and in particular - optimised
27 in GHC generated code. The default case, for an architecture for which
28 GHC is not optimised, is to use the mini interpreter described in the <a
29 href="http://research.microsoft.com/copyright/accept.asp?path=/users/simonpj/papers/spineless-tagless-gmachine.ps.gz&pub=34">STG paper.</a>
31 For supported architectures, various tricks are used to generate
32 assembler implementing proper tail calls. On i386, gcc's first class
33 labels are used to directly jump to a function pointer. Furthermore,
34 markers of the form <code>--- BEGIN ---</code> and <code>--- END
35 ---</code> are added to the assembly right after the function prologue
36 and before the epilogue. These markers are used by <a
37 href="../the-beast/mangler.html">the Evil Mangler.</a>
41 Last modified: Wed Aug 8 19:28:29 EST 2001