<p>Cmm is a fork of C-- used by GHC for codegen. I was previously thinking of using LLVM but Cmm seems to be a nicer, easier way to go.</p>

<compilers><intermediate-representation>
Is Cmm suitable for use in compilers besides GHC?
<p>It depends what your goals are.
Having looked into GHC's backend a fair bit, while Cmm is certainly a usable backend, using it will almost certainly create a permanent dependency on the entire GHC library. Cmm these days is quite tied into the GHC source code, and therefore separating it from the GHC source would be quite difficult - If you're OK having a dependency on GHC, then sure, it's most likely completely doable to use Cmm as a backend.</p>
<p>I will note that having a dependency on LLVM is probably &quot;less extreme&quot; than having a dependency on GHC, as LLVM has been ported to more platforms than GHC and is almost certainly installed more often.</p>
<p>In terms of Cmm being &quot;easier&quot;, I can't comment, as I've used neither for a large project.</p>

CC BY-SA 4.0
2023-05-17T03:42:23.877Z
2024-09-09T12:55:15.253Z
2024-09-09T12:55:15.253Z
blueberry
# Is Cmm suitable for use in compilers besides GHC?
Posted by: username_0 on 2023-05-17
Cmm is a fork of C-- used by GHC for codegen. I was previously thinking of using LLVM but Cmm seems to be a nicer, easier way to go.
**Tags:** compilers intermediate-representation
---
## 1 answers
### Answer by username_1 on 2023-05-17. Score: 5 | Accepted answer
It depends what your goals are.
Having looked into GHC's backend a fair bit, while Cmm is certainly a usable backend, using it will almost certainly create a permanent dependency on the entire GHC library. Cmm these days is quite tied into the GHC source code, and therefore separating it from the GHC source would be quite difficult - If you're OK having a dependency on GHC, then sure, it's most likely completely doable to use Cmm as a backend.

I will note that having a dependency on LLVM is probably "less extreme" than having a dependency on GHC, as LLVM has been ported to more platforms than GHC and is almost certainly installed more often.

In terms of Cmm being "easier", I can't comment, as I've used neither for a large project.
---
