C to RISC-V Compiler

ctoriscvcompiler

C to RISC-V Compiler

Description:

C-to-RISC-V-Compiler is a full compiler project that translates a subset of C into RV32I RISC-V assembly through a complete compilation pipeline: lexical analysis, recursive-descent parsing, typed AST construction, semantic analysis, IR generation, optimization, and final code generation. It includes a handwritten lexer and parser, a semantic checker for scope and type validation, a three-address-style intermediate representation with explicit control-flow graphs, and lightweight optimization passes such as constant folding, propagation, dead code elimination, and jump simplification. The backend emits textual RV32I assembly following a calling-convention model with proper stack-frame management, global data emission, and helper support for operations like multiply and divide, while the project also includes diagnostics, example programs, and test suites to validate each compiler stage end to end.