Skip to content

vgeddes/scheme-compiler

Repository files navigation

Another Scheme Compiler

Still in early development!

Current design
==============

* CPS high-level IR
  Raw scheme source code undergoes macro expansion, alpha conversion, 
  CPS conversion, beta reduction, closure conversion, and finally,
  conversion to the Tree IR.
* Tree-based low-level IR
  Used as a convenient source IR for instruction selection. 
* x86-64 instruction selector
  Uses a near-optimal maximal munch algorithm, and a set of pattern-matching rules. 
* Linear scan register allocator
  After computing live ranges for temps, we allocate registers in a single 
  pass over the machine instructions. The allocator is able to temps which
  are pre-assigned a specific hardware register (due to calling conventions, etc)
* Assembler [TODO]

Written in Scheme!

Supported Language
==================

Primitives: lambda, let, begin, if, and, or, not, fx+, fx-, fx=, fx<=, fx>=, fx<, fx>
Data: closures, fixnums

Build
=====

Dependencies: Chicken Scheme

$ make


Usage
=====

Currently the `scc' executable takes an input file containing a Scheme program, and dumps the generated x86-64 assembly to standard out. Early days!

$ scc FILE

Example: Scheme program which calculates fibonacci(23)

$ scc tests/fibonacci-001.scm



About

A Scheme Compiler

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages