JCC is designed to be a pure C11 (no dependencies) C11/C18/C23 compiler.
No, it is text based
It currently supports AArch64 almost fully, with partial WIP RISC-V support.
- Preprocessor
- Frontend - Lexer + Parser
- Semantic analysis - Typecheck
- Intermediate Representations and passes
- All code located in the
ir
folder - IR representation structs and helper methods are in
ir/ir.h
andir/ir.c
- Pretty-printing functionality is in
ir/prettyprint.h
andir/prettyprint.c
- This also includes graph-building functionality with graphviz
- IR building
- This stage converts the AST into an SSA IR form
- It assumes the AST is entirely valid and well-typed
- Code is
ir/build.h
andir/build.c
- Lowering
- Firstly, global lowering is performed. This lowers certain operations that are lowered on all platforms
- E.g
br.switch
s are converted into a series of if-elses, andloadglb/storeglb
operations are transformed toloadaddr/storeaddr
- E.g
- This converts the IR into the platform-native form
- Then, per-target lowering occurs
- For example, AArch64 has no
%
instr, sox = a % b
is converted toc = a / b; x = a - (c * b)
- For example, AArch64 has no
- The code for lowering is within the appropriate backend folders
- Firstly, global lowering is performed. This lowers certain operations that are lowered on all platforms
- Register allocation
- Simple LSRA, done seperately across floating-point & general-purpose registers
- Eliminate phi
- Splits critical edges and inserts moves to preserve semantics of phi ops
- All code located in the
- Code Generation
- Converts the IR into a list of 1:1 machine code instructions
- These are all target specific
- Currently codegen does too much - in the future I would like to move lots of its responsibilities (e.g ABI) into IR passes
- Emitting
- Actually emits the instructions from code generation into memory
- Object file building
- Writes the object file to disk
- Currently only macOS Mach-O format supported
- Code is
macos/mach-o.h
andmacos/mach-o.c
- Linking