Hello, i have submitted a custom GSoC proposal for improving cmm code generation in GHC. Cmm is an IR that gets compiled to native code directly or through LLVM. It is targeted by STG, an earlier GHC IR.
I am wondering if there are other code generation options in haskell ( or a language with particularly good interop, i think agda fits) .
Apparently a few people have implemented ANF based code generators, but i havent found them. There are various llvm libraries, although they are individually not that active. Am i missng something else ? Like is there some library to target another IR, or like targetting C code ? ( cmm technically can , but this is outdated )
I think the C backend of GHC should still be stable. There are a some packages that do their own code generation such as accelerate which generates LLVM using the llvm-pretty package (or at least I heard they were looking to switch to that).
Their github paga says “Currently, llvm-pretty supports LLVM versions up through 17” . LLVM is already on version 20.
Thanks for pointing the c backend of cmm. It may have a reusable c AST and pretty printer. But currently the C GHC backend itself is not desirable since it can produce either slow portable code or code that depends on unstable gcc features.
The custom GSoC proposal i formulated is about either upgrading and updating the llvm backend for cmm ( the code generation part of GHC ). Or introducing an improved register allocator for the code generator that directly takes cmm.
However i was also wondering if i could improve the c code generator to produce fast code that would work both on clang and gcc and across versions