GithubHelp home page GithubHelp logo

lufie0509z / lava Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ustb-owl/lava

0.0 0.0 0.0 18.07 MB

A compiler of C subset by USTB OWL Wheel Lab.

License: GNU General Public License v3.0

C++ 97.65% C 0.39% Pawn 1.06% CMake 0.69% NASL 0.21%

lava's Introduction

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

lava's People

Contributors

yvan-xy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.