# structured-additive-IR **Repository Path**: mirrors_google-research/structured-additive-IR ## Basic Information - **Project Name**: structured-additive-IR - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-24 - **Last Updated**: 2025-11-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Structured Additive Intermediate Representation (Sair) An intermediate program representation, based on [MLIR](http://mlir.llvm.org) and designed to express implementation decisions on a program without losing the high-level structure of the code. It encodes implementation choices as attributes added on to existing operations (hence "additive" in the name). ## Coding Guidelines Follow [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html) whenever possible. Note that MLIR uses LLVM style that is often incompatible with Google style; only use LLVM style for MLIR overrides or CRTP hooks. Follow MLIR [testing guide](https://mlir.llvm.org/getting_started/TestingGuide/). In particular, IR attributes, types and operations should be tested using textual IR format via FileCheck. Non-IR components should be tested with unit tests. ## Build Instructions Prerequisites: * C++ compiler supporting C++17; * git, cmake, ninja (or make) Instructions: First, fetch LLVM repository from git. ``` cd git clone https://github.com/llvm/llvm-project cd llvm-project ``` Checkout the latest version of LLVM compatible with Sair, as specified in `LLVM_VERSION` in the repository. ``` VERSION=`cat /LLVM_VERSION` git checkout $VERSION ``` (If MLIR, LLVM and relevant headers are already installed, skip this step). Configure and compile LLVM with MLIR project enabled by following [MLIR instructions](https://mlir.llvm.org/getting_started/). Make sure to set up the installation path. The following is only given as example: ``` mkdir build cd build cmake ../llvm -DLLVM_ENABLE_PROJECTS='mlir' \ -DLLVM_TARGETS_TO_BUILD='host;NVPTX;AMDGPU' \ -DCMAKE_BUILD_TYPE=Release \ -DLLVM_ENABLE_ASSERTIONS=On \ -DLLVM_INCLUDE_Utils=On \ -DCMAKE_INSTALL_PREFIX= \ -G Ninja # Omit for "make" build. ninja install -j # make install -j ``` With MLIR installed, configure Sair. ``` cd mkdir build cd build cmake .. \ -DCMAKE_PREFIX_PATH= \ -DLLVM_EXTERNAL_LIT= \ -G Ninja # Omit for "make" build. ``` The `LLVM_EXTERNAL_LIT` line is necessary to configure LLVM's testing infrastructure to run Sair tests and can be omitted if one does not intend to run Sair tests. `llvm-lit` is often provided by system packages, or is available in the _build_ path of LLVM since it is intended for use at build time. Therefore, `` can point to the system installation of `llvm-lit`, if any, or to `/build/bin/llvm-lit` if LLVM was built from source. One can now build and test Sair. ``` # To compile, run: ninja sair-opt -j # make sair-opt # To check test (if Lit was configured), run: ninja check-sair -j # make check-sair ``` The compilation produces a single standalone statically-linked binary `sair-opt` that can be moved.