Giter VIP home page Giter VIP logo

cminus-compiler's Introduction

Cminus Compiler

This is course project of Principles of Compiler. We have built a compiler for C Minus programming language.

Team

Members

We got full marks in every subtask.๐Ÿ˜

Lab

Lab1

Lexical analyzer.

# in project root dir

# build
./do_cmake.sh && make -C build/

# generate tokens
./build/test_lex

# compare
diff tokens/gcd.tokens lab1/TA_tokens/gcd.tokens

Lab2

Syntax analyzer.

# in project root dir

# build
./do_cmake.sh && make -C build/

# generate syntex tree
./build/test_syntax

# compare
diff syntree lab2/TA_syntree

Lab3

Lab3-0

Build LLVM. Handcraft several LLVM IR files and LLVM IR generators.

See README.md to build LLVM.

# in lab3-0 dir

# test IR files
lli assign_hand.ll ; echo $?
lli call_hand.ll ; echo $?
lli if_hand.ll ; echo $?
lli while_hand.ll ; echo $?

# test IR generators
mkdir temp
c++ assign_generator.cpp -o ./temp/assign_generator `llvm-config --cxxflags --ldflags --libs --system-libs` --std=c++14 && ./temp/assign_generator > ./temp/assign_generated.ll && lli ./temp/assign_generated.ll ; echo $?
c++ call_generator.cpp -o ./temp/call_generator `llvm-config --cxxflags --ldflags --libs --system-libs` --std=c++14 && ./temp/call_generator > ./temp/call_generated.ll && lli ./temp/call_generated.ll ; echo $?
c++ if_generator.cpp -o ./temp/if_generator `llvm-config --cxxflags --ldflags --libs --system-libs` --std=c++14 && ./temp/if_generator > ./temp/if_generated.ll && lli ./temp/if_generated.ll ; echo $?
c++ while_generator.cpp -o ./temp/while_generator `llvm-config --cxxflags --ldflags --libs --system-libs` --std=c++14 && ./temp/while_generator > ./temp/while_generated.ll && lli ./temp/while_generated.ll ; echo $?

Lab3-1

LLVM IR generator.

# in lab3-1 dir

# build `cminusc` executable file
mkdir build && cd build
cmake .. -DLLVM_DIR=/path/to/your/llvm/install/lib/cmake/llvm/
make -j

## test `cminusc` executable file
../test.sh

Lab3-2

We are required to read source code about LLVM Pass. No need for coding.

Lab4

We are required to read source code about reigster allocation in LLVM. No need for coding.

cminus-compiler's People

Contributors

gbxu avatar gloit042 avatar kingzevin avatar shao-xy avatar uncleduo avatar wangjwchn avatar weirane avatar youhuibai avatar yusanshi avatar

Watchers

 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.