Giter VIP home page Giter VIP logo

llvm-experiments's Introduction

Experiments with the LLVM compiler infrastructure

Yet another learning path to the heart of the LLVM compiler infrastructure.

  1. llvm-first-step - the simplest llvm demo: just reads a bitcode file and outs how many basic blocks are in every function.

  2. llvm-front-clang-demo - let's see how to deal with clang-lib: lexer, parser, diagnostics, traversing the AST, etc. The most interesting example is declared-methods-c.cpp that demonstrates how to distinguish declarations from definitions.

  3. llvm-ir-custom-passes - a collection of analysis and optimization passes for the opt tool. You can start from the FunctionArgumentUsagePass analysis pass that diagnoses type mismatches around function calls. The idea is borrowed from the task Writing your own Analysis Pass, course CSCI565 Compilers Design.

    P.S. There is an instruction how to build the passes as a part of the LLVM build tree and a patch for LLVM sources which can help you register the passes.

  4. llvm-backend-x86-machine-pass - a collection of machine passes for the X86 backend. Passes demonstrate how to deal with the code generation, data-flow analysis, register allocation, MC layer and other cool back-end stuff.

    P.S. There is an instruction how to build the machine passes as a part of the LLVM build tree and a patch for LLVM sources which can help you register the passes.

  5. llvm-ir-tests - a bunch of source code (C/C++) and .bc files to test the compiler infrastructure.

  6. llvm-unit-tests - in the XXI century without unit tests? No way! There are all unit tests for the code in the repository. The directory matches to the unittests one from the LLVM source tree.

I wish to thank Bruno Cardoso Lopes and Rafael Auler, the authors of Getting Started with LLVM Core Libraries. Their book is the best introduction in the LLVM infrastructure I met. Some examples from the book were used as a kick-starters for the project.

Building the project

You need CMake to build the experiments (those parts which don't have to be built as parts of the LLVM source tree). The variable LLVM_INSTALL_PREFIX must point to the parent directory of an LLVM installation.

Note: The build type of the experiments should correspond to the build type of the LLVM installation taken in account otherwise a number of linker errors will occur at least, if you are using the MSVC compiler.

# mkdir build
# cd build
# cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_INSTALL_PREFIX="<PATH_TO_YOUR_LLVM>" -G"Ninja" ..
# cmake --build .

Now the unit tests can be starting from the build/llvm-unit-tests dir:

# cd llvm-unit-tests
# ctest -V

...

100% tests passed, 0 tests failed out of ...

llvm-experiments's People

Contributors

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