Author Topic: Implementation based on Clang or...?  (Read 12723 times)

lerno

  • Full Member
  • ***
  • Posts: 247
    • View Profile
Implementation based on Clang or...?
« on: December 20, 2018, 08:25:20 PM »
There are two lightweight C-based compilers of C, TCC and recently 9cc.

One idea would be to implement the C2 compiler on top of either of those instead. TCC is known for it's very fast compilations speed. The fact that both are written in C allows us to potentially implement them in C2 instead.

Possibilities

1. Use C2-Clang/LLVM to compile a mod of 9cc/TCC rewritten in C2
2. Write C2-9cc/TCC which then is piece by piece replaced by C2 implementation.

Obviously this is something for the future and should not detract from the current work on C2-Clang/LLVM.

bas

  • Full Member
  • ***
  • Posts: 220
    • View Profile
Re: Implementation based on Clang or...?
« Reply #1 on: December 21, 2018, 08:01:54 AM »
Why?? What would that bring for the language. It's just work at the moment. I think the most important
thing is the language itself, not the implementation.

A compiler consists of:
- tokenizer
- parser
- analyser +  diagnostics
- code generator

currently, only the tokenizer + diagnostics are not lean, because they use Clang implementation for C/C++. The rest is quite lean already.

lerno

  • Full Member
  • ***
  • Posts: 247
    • View Profile
Re: Implementation based on Clang or...?
« Reply #2 on: December 21, 2018, 11:17:22 AM »
Well I was not talking about "at the moment" but toward the future of a possible self-hosted C2.