5 ms·
I am all in favor of hacking for studying and fun. But for practical reasons - are you familiar with Bellard's tcc?
by beagle3 11y ago
I am all in favor of hacking for studying and fun. But for practical reasons - are you familiar with Bellard's tcc?
- andrewchambers 11y agoI am, it is referenced in the readme. Tcc's code is not really so readable in my opinion, which is something I want to address. Tcc also has no desire to become an optimizing compiler in the future. Personally I think 8cc is far superior to tcc in many important ways, but is not as mature as tcc. I love C so considered using 8cc as a base for expansion, but there is a reason llvm and gcc are in C++ and not C. I dislike C++ for many logical and illogical reasons, and think Go is a fair compromise with keeping close to C roots.
- jevinskie 11y agoFrom the README: The code is heavily inspired by https://github.com/rui314/8cc https://github.com/rui314/8cc as well as http://bellard.org/tcc/ http://bellard.org/tcc/. I recommend studying the source code of 8cc before contributing here, as 8cc is currently far more mature.
- rswier 11y agoThe last time I checked, tcc lacked even a simple AST. This led to some pretty weird emitted code (such as swapping parameters on the stack.) Implementing an AST is not hard, just push and pop nodes on a stack. It also makes a nice front-end/back-end interface.
- andrewchambers 11y agoEliminating memory allocations made tcc extremely fast, They use a value stack rather than an AST. I just think an AST is a bit easier to follow because it means the parser has less code generation logic embedded in it.
- rswier 11y agoNo malloc/free necessary. Just pile up nodes on a stack, then "deallocate" to any saved position.