Skip to content

ustb-owl/Lava

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.
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:

define i32 @main() {
entry:
  br label %while.cond0

while.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_exit0

loop.body0: ; preds: while.cond0
  %t1 = mul i32 %phi1, 2
  %t0 = add i32 %phi0, 1
  br label %while.cond0

inline_exit0: ; preds: while.cond0
  ret i32 %phi1
}

CFG genereated by Lava:
cfg

Automated Testing Tools

See lava-test

About

A compiler of C subset by USTB OWL Wheel Lab.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages