# shecc

A self-hosting, educational optimizing C compiler that targets 32-bit Arm, AArch64, 32-bit RISC-V and x86-64, producing Linux ELF binaries.

shecc is a self-compiling optimizing compiler for a subset of the C language, built from scratch to target 32-bit Arm, AArch64, 32-bit RISC-V and x86-64. It generates executable Linux ELF binaries directly, with a self-contained front end and an integrated machine code generator, so no external assembler or linker is needed, and it ships a minimal C standard library for basic I/O on GNU/Linux.

Compilation runs in two passes: the first checks syntax and breaks complex statements into basic operations, and the second translates those operations into target machine code through an architecture-independent, static single assignment based middle-end. A register allocator suited to RISC-style architectures and support for dynamic linking against glibc round out the pipeline, and it emits ELF32 for Arm and RISC-V or ELF64 for AArch64 and x86-64 depending on the target's pointer width.

The compiler accepts a substantial subset of C syntax, including the common data types, control-flow statements, arithmetic and bitwise operators, arrays, typedefs, pointer arithmetic and preprocessor directives. It is written in ANSI C and released under the BSD-2-Clause license.

Website: https://github.com/sysprog21/shecc
