3 ms·
Cool! Any plans for emitting assembly, c or llvm? There seem to be an awful lot of resources on compiler frontends, and not so much on the backend.
by mrkeen 6y ago
Cool! Any plans for emitting assembly, c or llvm?
There seem to be an awful lot of resources on compiler frontends, and not so much on the backend.
- mhh__ 6y agoThere are a lot of resources on compiler backends, just that GCC and LLVM don't follow them. The GCC and LLVM machine models for example are very sophisticated and I've never seen anything like them documented in a textbook because they all basically assume a early 2000s RISC machine rather than a CISC with a very bulky decoder.
- myk9001 6y agoYou might find [CS 6120: Advanced Compilers: The Self-Guided Online Course][1] interesting. I'm slowly working through it, but basically its focus is intermediate representations, optimizations, etc. A link to the course was on the first page of HN some time ago. If you want to know more about LLVM IR specifically, check this [talk from 2019 EuroLLVM Developers’ Meeting][2] Also -- and you knew it was coming -- I've written [a toy-compiler of a Scala subset][3] myself :) I'm new to F# and writing compilers, so I'm sure the code is full of rookie mistakes. Still, it works and does generate assembly and executables for Linux and Windows. [1]: https://www.cs.cornell.edu/courses/cs6120/2020fa/self-guided/ https://www.cs.cornell.edu/courses/cs6120/2020fa/self-guided... [2]: https://www.youtube.com/watch?v=m8G_S5LwlTo https://www.youtube.com/watch?v=m8G_S5LwlTo [3]: https://github.com/mykolav/coollang-2020-fs https://github.com/mykolav/coollang-2020-fs
- norswap 6y agoI plan to show how to emit Java bytecode - the advantage being that you don't have to write your own GC, and you benefit from the JVM JIT compiler. I think in general the backend is much easier (especially if you don't have to do your own optimizations) - you mostly need to know a couple of patterns for working with tree-like structures.