Using EEP mode
- Compile the compiler (instructions assume macOS with clang & CMake installed)
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=debug .. && cmake --build .
cd ..
- The compiler binary will now be
build/jcc
- Run the compiler with
-Teep
flag on your file, e.g./LOCATION_OF_JCC/build/jcc -Teep -Lasm mul.c
- the-Lasm
flag will print out the EEP assembly as well - It will output a file next to it suffixed by
.obj
which will be your EEP assembly - Rename this from
.c.obj
to.ram
and then you can import it into Issie
JCC is designed to be a pure C11 (no dependencies) C11/C18/C23 compiler.
No, it is text based
- 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
- All code located in the
- Code Generation
- Converts the IR into a list of 1:1 machine code instructions
- These are all target specific
- 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