Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FCC

FCC is a optimizing compiler for a (growing) C99 subset.

Try it out on your machine

Build:

./bd

Run tests:

python tests.py

Use:

./build/fcc test.c

Requirements:

  • CMake
  • clang (22.1.8)
  • clang development libraries
  • graphviz (15.1.0)
  • mold (optional)
  • python

Implemented Optimization Passes

  • Constant Folding
  • Dead Branch Elimination
  • Dead Block Elimination
  • Constant Hoisting
  • Dead Definition Elimination
  • Block Merge

Currently Lowered C Features

Functions

  • Function declarations and definitions
  • Function calls

Variables

  • Variable declarations
  • Variable assignment
  • SSA variable reads / writes with phi insertion

Expressions

Assignment Operators

  • +=
  • -=
  • *=
  • /=
  • %=

Binary arithmetic

  • Addition (+)
  • Subtraction (-)
  • Multiplication (*)
  • Division (/)
  • Modulus / Remainder (%)

Comparison operators

  • Less than (<)
  • Less than or equal (<=)
  • Greater than (>)
  • Greater than or equal (>=)
  • Equal (==)
  • Not equal (!=)

Unary operators

  • Unary plus (+x)
  • Unary minus (-x)
  • Logical NOT (!x)
  • Increment (pre & post)
  • Decrement (pre & post)

Logical operators

  • Logical AND (&&)
  • Logical OR (||)

Control Flow

  • if
  • if-else
  • while
  • for
  • break
  • continue

References

About

(WIP) C99 Optimizing Compiler

Resources

Stars

3 stars

Watchers

0 watching

Forks

Contributors

Languages