Skip to content
/ ucc Public

An optimizing compiler for a large subset of the C programming language

License

Notifications You must be signed in to change notification settings

xqb64/ucc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ucc

This is a Rust implementation of the C compiler from Nora Sandler's book.

How it works

At the forefront is the compiler driver, which orchestrates the compilation process---from lexing and parsing, through several stages of semantic analysis, such as variable resolution, loop labeling, and type checking. After generating an intermediate representation (IR), the compiler passes it through an iterative optimization pipeline. This pipeline leverages forward and backward data-flow analysis, liveness analysis, and address-taken analysis to implement optimizations such as constant folding, unreachable code elimination, copy propagation, and dead store elimination. Finally, it generates and optimizes the x86_64 assembly code using a graph coloring-based register allocator with conservative coalescing, before emitting the optimized code.

Status

  • char (in both unsigned and signed variants)
  • short
  • int (in both unsigned and signed variants)
  • long (in both unsigned and signed variants)
  • float
  • double
  • void
  • if/else
  • switch
  • while
  • do while
  • for
  • break
  • continue
  • ConsideredHarmful
  • static
  • extern
  • arrays
  • structs
  • sizeof
  • enums
  • unions
  • typedef

License

Licensed under the MIT license.

About

An optimizing compiler for a large subset of the C programming language

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages