From 1e8a345a29ed034a6314e04b695e143ec1fff56f Mon Sep 17 00:00:00 2001 From: sewardj Date: Thu, 31 Jan 2002 18:01:34 +0000 Subject: [PATCH] [project @ 2002-01-31 18:01:34 by sewardj] Make a quite-large start on native code generator documentation. --- ghc/docs/comm/index.html | 1 + ghc/docs/comm/the-beast/ncg.html | 299 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 300 insertions(+) create mode 100644 ghc/docs/comm/the-beast/ncg.html diff --git a/ghc/docs/comm/index.html b/ghc/docs/comm/index.html index dd381c9..f18713c 100644 --- a/ghc/docs/comm/index.html +++ b/ghc/docs/comm/index.html @@ -56,6 +56,7 @@
  • The Mighty Simplifier
  • The Evil Mangler
  • Alien Functions +
  • The Native Code Generator

    RTS & Libraries

    diff --git a/ghc/docs/comm/the-beast/ncg.html b/ghc/docs/comm/the-beast/ncg.html new file mode 100644 index 0000000..2f0d799 --- /dev/null +++ b/ghc/docs/comm/the-beast/ncg.html @@ -0,0 +1,299 @@ + + + + + The GHC Commentary - The Native Code Generator + + + +

    The GHC Commentary - The Native Code Generator

    +

    + On x86 and sparc platforms, GHC can generate assembly code + directly, without having to go via C. This can sometimes almost + halve compilation time, and avoids the fragility and + horribleness of the mangler. The NCG is enabled by default for + non-optimising compilation on x86 and sparc. For most programs + it generates code which runs only about 1% slower than that + created by gcc on x86s, so it is well worth using even with + optimised compilation. FP-intensive x86 programs see a bigger + slowdown, and all sparc code runs about 5% slower due to + us not filling branch delay slots. +

    + In the distant past + the NCG could also generate Alpha code, and that machinery + is still there, but will need extensive refurbishment to + get it going again, due to underlying infrastructural changes. + Budding hackers thinking of doing a PowerPC port would do well + to use the sparc bits as a starting point. +

    + The NCG has always been something of a second-class citizen + inside GHC, an unloved child, rather. This means that its + integration into the compiler as a whole is rather clumsy, which + brings some problems described below. That apart, the NCG + proper is fairly cleanly designed, as target-independent as it + reasonably can be, and so should not be difficult to retarget. +

    + The following details are correct as per the CVS head of end-Jan + 2002. + +

    Overview

    + The top-level code generator fn is +

    + absCtoNat :: AbstractC -> UniqSM (SDoc, Pretty.Doc) +

    + The returned SDoc is for debugging, so is empty unless + you specify -ddump-stix. The Pretty.Doc + bit is the final assembly code. Translation involves three main + phases, the first and third of which are target-independent. +

    + +

    +

    Complications, observations, and possible improvements

    + +

    How to debug the NCG without losing your sanity

    + +

    How to debug the NCG without losing your sanity

    + + + + +

    + +Last modified: Fri Aug 10 11:47:41 EST 2001 + + + + -- 1.7.10.4