Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/msiemens/rustiny
A Rust-like language compiling to x86-64 assembler
https://github.com/msiemens/rustiny
compiler rust
Last synced: 9 days ago
JSON representation
A Rust-like language compiling to x86-64 assembler
- Host: GitHub
- URL: https://github.com/msiemens/rustiny
- Owner: msiemens
- License: mit
- Created: 2015-03-06T11:15:50.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-06-17T16:12:18.000Z (over 2 years ago)
- Last Synced: 2024-10-14T21:09:19.674Z (23 days ago)
- Topics: compiler, rust
- Language: Rust
- Homepage:
- Size: 456 KB
- Stars: 53
- Watchers: 5
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RusTiny
This is an educational compiler for a Rust-like language that was originally
planned to target the fictional [Tiny architecture](https://github.com/msiemens/rust-tinyasm). But due to Tiny's limitations, RusTiny now targets x86-64 machines.
The syntax is based on Rust, but there are numerous semantic differences:- The only datatype is `int`. There also are `bool` and `char`, but these are
actually `int`s in disguise.
- No structs/classes, no modules, only functions. This keeps the whole
language managable for me.
- No `mut`, no borrow checker. Again: keep it simple.**NOTE:** This project is currently on hold as the current approach for SSA register allocation doesn't really pan out. I hope I'll find time to revisit project this sometime in the future.
## Goal
My goal is to get the compiler so far that I can write a program that
[approximates Pi](https://blog.m-siemens.de/exploring-computers-tiny-assembler/#approximatingdpid).## Architecture
The general data flow looks something like this:
Source File -(front)-> AST -(middle)-> IR -(back)-> Assembler
- `front`: Translates the source file into an Abstract Syntax Tree representation
- `middle`: Checks the AST for correctness, transforms it to an Intermediate Representation
and performs optimizations
- `back`: Translates the IR to ~~Tiny Assembly code~~ x86-64 assembly## Helpful Resources
Resources I found helpful:
- [**Introduction to Compiler Design** by Torben Ægidius Mogensen](http://www.springer.com/us/book/9780857298287)
- [**Engineering a Compiler** by Keith D. Cooper & Linda Torczon](http://store.elsevier.com/product.jsp?isbn=9780120884780)