Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ustb-owl/Lava
A compiler of C subset by USTB OWL Wheel Lab.
https://github.com/ustb-owl/Lava
compiler
Last synced: 2 months ago
JSON representation
A compiler of C subset by USTB OWL Wheel Lab.
- Host: GitHub
- URL: https://github.com/ustb-owl/Lava
- Owner: ustb-owl
- License: gpl-3.0
- Created: 2021-07-21T02:37:15.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-02-09T12:33:10.000Z (almost 2 years ago)
- Last Synced: 2024-08-02T07:02:01.995Z (5 months ago)
- Topics: compiler
- Language: C++
- Homepage:
- Size: 17.6 MB
- Stars: 11
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Lava
A compiler of C subset by USTB OWL Wheel Lab.Lava can compile extended SysY languate to ARM assembly and LLVM IR.
## Building
Lava requires:
- `cmake` 3.16 or later.
- C++ compiler supporting C++17 standard.```shell script
git clone https://github.com/ustb-owl/Lava
cd compiler && mkdir build && cd build
cmake .. && make -j8
./lacc -h
```## Usage
```
Usage: lacc [options...] [filename]
Options:
-o, --output set output file name
-S, --dump-asm generate asm file
-I, --dump-ir generate ir file
-T, --dump-ast generate ast file
-C, --dump-cfg generate visable CFG file
filename input filename (Required)
-h, --help Shows this page
```## Features
- Handwritten frontend.
- Strong typed IR in SSA form.
- Can emit LLVM IR
- Optimizer based on pass and pass manager.
- Flexible phase order
- Low-level IR (LLIR) for multi-architecture machine instruction abstraction.
- Visable control flow graph.LLVM IR generated by Lava:
```llvm
define i32 @main() {
entry:
br label %while.cond0while.cond0: ; preds: entry, loop.body0
%phi0 = phi i32 [ 0, %entry ], [ %t0, %loop.body0 ]
%phi1 = phi i32 [ 3, %entry ], [ %t1, %loop.body0 ]
%t2 = icmp slt i32 %phi0, 5
br i1 %t2, label %loop.body0, label %inline_exit0loop.body0: ; preds: while.cond0
%t1 = mul i32 %phi1, 2
%t0 = add i32 %phi0, 1
br label %while.cond0inline_exit0: ; preds: while.cond0
ret i32 %phi1
}
```
CFG genereated by Lava:
![cfg](https://github.com/ustb-owl/Lava/blob/master/doc/ir.svg?raw=true)## Automated Testing Tools
See [lava-test](https://github.com/ustb-owl/lava-test)