![]() The full Haskell source of the compiler lives at. While all of these advanced language features could actually be quite helpful in writing a compiler, I've left them out of mcc in order to attempt to be more beginner friendly. For reference, the Haskell used in this project falls somewhere in what that answer would deem the early intermediate category, as there are a lot of Monad transformers, but no fancy GADTs, TypeFamilies, recursion schemes, or any of the other billion extensions that GHC has to offer. To learn the language, consult the resources mentioned in this superb Stackoverflow answer. This tutorial assumes some familiarity with Haskell. Moreover, basically everyone already knows C 1, and being able to compare our compiler's output to clang's is an excellent debugging resource. Also, although kaleidescope is a fine teaching language for compiler construction, our version of C, stripped down though it is, is still meatier, and will allow us to dive a little deeper into LLVM features. In particular, it was written before the IRBuilder module was added to the Haskell bindings and required users to write a lot of plumbing themselves which is now handled by the library. However, it uses an older version of LLVM than is currently available. Stephen Diehl's translation of the kaleidescope tutorial provides an excellent introduction to building a simple language using Haskell and LLVM. mc source file and produces an executable. At the end of the series, we'll have a beautiful executable, mcc (Micro C Compiler), that takes one. ![]() We'll have basic numeric types, a real bool type, pointers, and structs. Our language, Micro C, is basically a small subset of real C. In this series, we will explore how to write a compiler for a small subset of C to LLVM in Haskell.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |