Skip to content

This fork is made for stubs required to build practical tasks of students on top of The LLVM Project.

License

Notifications You must be signed in to change notification settings

NN-complr-tech/compiler-course-2025

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Compiler course 2025

Build LLVM

Resources

What is LLVM?

LLLVM is a set of compiler and toolchain technologies that can be used to develop a frontend for any programming language and a backend for any instruction set architecture. LLVM is designed around a language-independent intermediate representation (IR) that serves as a portable, high-level assembly language that can be optimized with a variety of transformations over multiple passes. The name LLVM originally stood for Low Level Virtual Machine, though the project has expanded and the name is no longer officially an initialism.

This repository contains the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments.

The LLVM project has multiple components. The core of the project is itself called "LLVM". This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer.

0. Intro

This course will consist of 4 laboratory work. As part of the laboratory works, you will study all stages of compilation, starting with the generation of the AST tree, ending with code generation.

Note

Recommended OS - Linux (WSL).

1. Clone repository

  1. Create fork this repository
  2. Clone local fork
git clone https://github.com/<your-github-name>/llvm.git
cd llvm/
git checkout -b <name-your-branch>

2. Setup environment

sudo apt-get update \
    && sudo apt-get install -q -y --no-install-recommends \
        git \
        cmake \
        ccache \
        mold \
        clang \
        build-essential \
        ninja-build \
        python3 \
        python3-pip \
        wget \
        vim

3. Build project

cmake -G Ninja -S llvm -B build \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_CXX_COMPILER=clang++ \
    -DCMAKE_C_COMPILER=clang \
    -DLLVM_USE_LINKER=mold \
    -DLLVM_CCACHE_BUILD=ON \
    -DLLVM_ENABLE_ASSERTIONS=ON \
    -DLLVM_ENABLE_PROJECTS="clang;mlir" \
    -DLLVM_TARGETS_TO_BUILD=X86 # specify your target architecture (X86, Aarch64)
cmake --build build --config Release -j 4

4. Where to implement laboratory work?

Each directory has an implementation example.

ClangAST lab

cd clang/compiler-course/ # for labs
cd clang/test/compiler-course/ # for tests

LLVM IR lab

cd llvm/compiler-course/llvm-ir/ # for labs
cd llvm/test/compiler-course/ # for tests

Backend lab

cd llvm/compiler-course/backend/ # for labs
cd llvm/test/compiler-course/ # for tests

MLIR lab

cd mlir/compiler-course/ # for labs
cd mlir/test/compiler-course/ # for tests

5. Run tests

For all tests

cmake --build build --config Release -t \
    check-llvm-compiler-course \
    check-clang-compiler-course \
    check-mlir-compiler-course -j 4

For one test

./build/bin/llvm-lit -v /path/to/test_file

About

This fork is made for stubs required to build practical tasks of students on top of The LLVM Project.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • LLVM 37.1%
  • C++ 33.0%
  • C 16.9%
  • Assembly 8.9%
  • MLIR 1.3%
  • Python 0.9%
  • Other 1.9%