Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/y-nak/tiger-cranelift
Tiger language implementation using cranelift
https://github.com/y-nak/tiger-cranelift
compiler cranelift rust tiger
Last synced: 2 months ago
JSON representation
Tiger language implementation using cranelift
- Host: GitHub
- URL: https://github.com/y-nak/tiger-cranelift
- Owner: Y-Nak
- License: mit
- Created: 2020-01-24T00:07:41.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-03-24T13:22:23.000Z (almost 5 years ago)
- Last Synced: 2024-04-19T19:02:20.177Z (9 months ago)
- Topics: compiler, cranelift, rust, tiger
- Language: Rust
- Homepage:
- Size: 85 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tiger-Cranelift
Tiger-Cranelift is a Tiger language implementation using [cranelift](https://github.com/bytecodealliance/cranelift). This project is intended to be yet another demo of cranelift.
The compiler emits native binaries using cranelift-object backend.
You can also find official cranelift-jit example [simplejit-demo](https://github.com/bytecodealliance/simplejit-demo).## Specification
See [Tiger Compiler Reference Manual](https://www.lrde.epita.fr/~tiger/tiger.html).
Some features in the specification are still missing.
I'll implement them in my free time.## Implementation Summary
### Parsing
Simple hand-written recursive descent parser. So there is nothing to saying about parsing phase.### Semantic Analysis
Tiger language allows to define nested functions though closure is not allowed.
In order to resolve nested functions, I adopted lambda-lifting because it make easier to build Cranelift IR in later.### IR Building
All types in Tiger are lowered into ptr type of target machine to allow recursive type declaration like `type IntList = {head:int, tail: list}`.
In semantic analysis phase all functions are lifted up to top-level functions, so IR building phase is quite straight forward.## Run
In the project root,
```
Cargo run file_path
```### Compiler Options
```
USAGE:
tigerc [FLAGS] [OPTIONS]FLAGS:
-d Also dump cranelift IR
-h, --help Prints help information
-V, --version Prints version informationOPTIONS:
-O, --opt-level Specify optimization level [default: none] [possible values: none, speed,
speed_and_size]
-o Place the output into [default: ./a.out]ARGS:
```## Test
In the project root,
```
./test_all.sh
```This command runs all unit tests + file tests.
## TODO
* [ ] Add error handling returned from cranelift.
* [ ] Add simple GC.