... | ... | @@ -4,7 +4,7 @@ |
|
|
A `.cmm` file is rather like C--. The syntax is almost C-- (a few constructs are missing), and it is augmented with some macros that are expanded by GHC's code generator (eg. `INFO_TABLE()`). A `.cmm` file is compiled by GHC itself: the syntax is parsed by [compiler/GHC/Cmm/Parser.y](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/GHC/Cmm/Parser.y) and [compiler/GHC/Cmm/Lexer.x](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/GHC/Cmm/Lexer.x) into the [Cmm](commentary/compiler/cmm-type) data type, where it is then passed through one of the [back-ends](commentary/compiler/backends).
|
|
|
|
|
|
|
|
|
We use the C preprocessor on `.cmm` files, making extensive use of macros to make writing this low-level code a bit less tedious and error-prone. Most of our C-- macros are in [includes/Cmm.h](https://gitlab.haskell.org/ghc/ghc/blob/master/includes/Cmm.h). One useful fact about the macros is `P_` is an alias for `gcptr`, and you should not use it for non-garbage-collected pointers.
|
|
|
We use the C preprocessor on `.cmm` files, making extensive use of macros to make writing this low-level code a bit less tedious and error-prone. Most of our C-- macros are in [rts/include/Cmm.h](https://gitlab.haskell.org/ghc/ghc/blob/master/rts/include/Cmm.h). One useful fact about the macros is `P_` is an alias for `gcptr`, and you should not use it for non-garbage-collected pointers.
|
|
|
|
|
|
## Reading references
|
|
|
|
... | ... | @@ -25,4 +25,4 @@ Reading material for learning Cmm is somewhat scattered, so I (Arash) have creat |
|
|
It can take time to learn Cmm. One unintuitive thing to watch out for is that there are no function calls in low-level cmm code. The new syntax from 2012 allows function calls but you should know that they are kind of magical.
|
|
|
|
|
|
|
|
|
We say that **Cmm** is GHC's implementation of **C--**. This naming scheme is not done consistently everywhere, unfortunately. If you are interested in C-- (which have diverged from Cmm), you can check out its [specification](http://www.cs.tufts.edu/~nr/c--/extern/man2.pdf). |
|
|
We say that **Cmm** is GHC's implementation of **C--**. This naming scheme is not done consistently everywhere, unfortunately. If you are interested in C-- (which have diverged from Cmm), you can check out its [specification](http://www.cs.tufts.edu/~nr/c--/extern/man2.pdf). |
|
|
\ No newline at end of file |