Cmm learning tools

Simon Peyton Jones simonpj at
Tue Jul 17 19:37:01 UTC 2018

Here’s a little bit of background.

  *   C—started when Norman Ramsey and I decided to have a stab at designing a “portable assembly language”.
  *   Our primary motivation was GHC: I wanted to clearly separate the business of turning lambda calculus into an imperative language, from that of turning the imperative language into machine instructions for a particular CPU architecture.  But our intention was that many compilers, not just GHC, could generate C--.
  *   We published a series of papers describing why this goal is less easy than it looks (tail calls, garbage collection, exception handling, lightweight threading).
  *   But then along came LLVM.   It’s goal was the same (some differences in emphasis).   And LLVM “won” – it gained mindshare, a corporate sponsor, an ecosystem.   I’m quite happy about this – hundreds of person-years invested by someone else 😊.
  *   As a result C—is really a GHC-only language (though nothing stops other compilers from using it)
     *   Cmm is the GHC data type (defined in compiler/cmm) that represents C—syntax trees internally in GHC.
     *   We do parse foo.cmm for a few runtime system support files; e.g. rts/Apply.cmm
     *   But most Cmm is generated from STG by compiler/codeGen
     *   We do CPS conversion on Cmm
     *   …and then either emit LLVM, or generate assembly code directly (compiler/nativeGen)

I hope that helps a bit.


From: ghc-devs <ghc-devs-bounces at> On Behalf Of Gabor Greif
Sent: 17 July 2018 07:17
To: Daniel Cartwright <chessai1996 at>
Cc: ghc-devs at
Subject: Re: Cmm learning tools

No worries! I searched for C--, which was its name back in the day. There are a bunch of other conference papers in the "GHC commentary" too.



Em ter, 17 de jul de 2018 às 08:00, Daniel Cartwright <chessai1996 at<mailto:chessai1996 at>> escreveu:
Thanks, I'll check it out.

P.S.: Apologies if my request seemed low-effort w.r.t. searching, I did spend a good 15 minutes doing so before asking, and was unable to find the document you just produced.

On Tue, Jul 17, 2018, 1:49 AM Gabor Greif <ggreif at<mailto:ggreif at>> wrote:
Hello Daniel,

a quick web search brought up this manual:<>

Please note that Cmm is slightly different, but it should get you started.



Em ter, 17 de jul de 2018 às 05:20, Daniel Cartwright <chessai1996 at<mailto:chessai1996 at>> escreveu:
Hello all, I've recently become interested in learning Cmm, but cannot seem to find any concrete learning resources or extensive papers. It doesn't help that the web seems to contain a lot of useless information for a newcomer to Cmm. If anyone could provide some reading material about Cmm, I would be most grateful.
ghc-devs mailing list
ghc-devs at<mailto:ghc-devs at><>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ghc-devs mailing list