Cwerg aims to be a complete, compact and fast "from-scratch" compiler for a C-like language. It consists of the following components:
-
Frontend: Overview, Additional Docs
A low-level C-like language with a Python inspired concrete syntax. Still actively development
-
Backend: Overview, Backend IR, Additional Docs
Muti-target (currently: X86-64, Aarch64, Arm32).
Also suitable for other compilers and as a JIT.
Defines an IR that serves as the interface between frontend and backend.
-
Deprecated C Frontend (translates a subset of C to Cwerg IR)
-
Deprecated WASM Frontend (translates WASM/WASI coded to Cwerg IR)
Most components are implemented twice (see rationale):
- spec/reference implementation: Python 3.9
- high performance implementation: C++17 (with limited STL usage)
Re-implementations in other languages are explicitly encouraged. A lot of code is table driven to facilitate that.
Cwerg de-emphasizes quality of the generated code (the hope is to come within 50% of state of the art compilers) in favor of a small code base that can be understood by a single developer and very fast translation times. Explicit line number targets are in place to prevent feature creep:
- frontend: 10kLOC
- backend 10kLOC (target independent code) + 5kLOC (per target)