{"id":19926408,"url":"https://github.com/mini-llvm/mini-llvm","last_synced_at":"2026-06-10T17:31:50.890Z","repository":{"id":258081252,"uuid":"865726241","full_name":"mini-llvm/mini-llvm","owner":"mini-llvm","description":"A minimal implementation of the LLVM core libraries and tools","archived":false,"fork":false,"pushed_at":"2026-06-06T07:29:19.000Z","size":299,"stargazers_count":15,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-06-06T09:13:37.936Z","etag":null,"topics":["llvm"],"latest_commit_sha":null,"homepage":"https://mini-llvm.github.io/mini-llvm/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mini-llvm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-10-01T02:54:48.000Z","updated_at":"2026-06-06T07:29:22.000Z","dependencies_parsed_at":"2025-05-07T06:28:47.487Z","dependency_job_id":"7b2b254e-4a05-4373-a7cd-b361299b96b2","html_url":"https://github.com/mini-llvm/mini-llvm","commit_stats":null,"previous_names":["mini-llvm/mini-llvm"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mini-llvm/mini-llvm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mini-llvm%2Fmini-llvm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mini-llvm%2Fmini-llvm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mini-llvm%2Fmini-llvm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mini-llvm%2Fmini-llvm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mini-llvm","download_url":"https://codeload.github.com/mini-llvm/mini-llvm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mini-llvm%2Fmini-llvm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34163253,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-10T02:00:07.152Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["llvm"],"created_at":"2024-11-12T22:29:11.624Z","updated_at":"2026-06-10T17:31:50.882Z","avatar_url":"https://github.com/mini-llvm.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# mini-llvm\n\n**A minimal implementation of the LLVM core libraries and tools**\n\n| main | develop |\n|:-:|:-:|\n| [![build](https://github.com/mini-llvm/mini-llvm/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/mini-llvm/mini-llvm/actions/workflows/build.yml?query=branch%3Amain) | [![build](https://github.com/mini-llvm/mini-llvm/actions/workflows/build.yml/badge.svg?branch=develop)](https://github.com/mini-llvm/mini-llvm/actions/workflows/build.yml?query=branch%3Adevelop) |\n\n\u003c/div\u003e\n\n## Table of Contents\n\n- [Overview](#overview)\n- [Components](#components)\n- [Highlights](#highlights)\n- [Design](#design)\n- [Features](#features)\n- [Usage](#usage)\n- [Build](#build)\n- [Testing](#testing)\n- [Installation](#installation)\n- [References](#references)\n- [License](#license)\n\n## Overview\n\n**mini-llvm** is a minimal implementation of the LLVM core libraries and tools, supporting a strict subset of LLVM IR constructs. It aims to demonstrate the essential principles of modern compiler design in a clear, concise, and approachable way.\n\n## Components\n\n- The mini-llvm core library (`libmini-llvm`)\n- The `mini-llc` command-line tool\n\n## Highlights\n\n- Modern C++ (C++23)\n- Cross-platform compatibility (Linux \u0026 Windows)\n- Easy integration (CMake \u0026 Bazel)\n- No external dependencies\n\n## Design\n\n![Design](assets/design.svg)\n\n## Features\n\n### Supported Targets\n\n- `riscv64`\n\nAlthough `riscv64` is currently the only supported target, the flexible architecture design of mini-llvm enables adding new targets with minimal effort.\n\n### Supported IR Constructs\n\n#### Types\n\n- `void`\n- Integer types\n  - `i1`\n  - `i8`\n  - `i16`\n  - `i32`\n  - `i64`\n- Floating-point types\n  - `float`\n  - `double`\n- `ptr`\n- Array types\n- Function types\n- `label`\n\n#### Constants\n\n- Integer constants\n- Floating-point constants\n- `null`\n- Array constants\n- `poison`\n\n#### Instructions\n\n- Terminators\n  - `br`\n  - `ret`\n- Binary operators\n  - Integer\n    - Arithmetic\n      - `add`\n      - `sub`\n      - `mul`\n      - `sdiv`\n      - `udiv`\n      - `srem`\n      - `urem`\n      - `and`\n      - `or`\n      - `xor`\n      - `shl`\n      - `lshr`\n      - `ashr`\n    - Relational\n      - `icmp`\n  - Floating-point\n    - Arithmetic\n      - `fadd`\n      - `fsub`\n      - `fmul`\n      - `fdiv`\n      - `frem`\n    - Relational\n      - `fcmp`\n- Unary operators\n  - Floating-point\n    - Arithmetic\n      - `fneg`\n- Casting operators\n  - Integer\n    - `trunc`\n    - `sext`\n    - `zext`\n  - Floating-point\n    - `fptrunc`\n    - `fpext`\n  - Integer ↔️ Floating-point\n    - `sitofp`\n    - `uitofp`\n    - `fptosi`\n    - `fptoui`\n  - Pointer ↔️ Integer\n    - `ptrtoint`\n    - `inttoptr`\n  - `bitcast`\n- Memory management\n  - `alloca`\n  - `load`\n  - `store`\n  - `getelemenetptr`\n- Other\n  - `select`\n  - `call`\n  - `phi`\n\n#### Attributes\n\n- `alwaysinline`\n- `argmemonly`\n- `inaccessiblemem_or_argmemonly`\n- `inaccessiblememonly`\n- `noinline`\n- `readnone`\n- `readonly`\n\n### Transform \u0026 Analysis Passes\n\n#### IR-Level\n\n- `AlgebraicSimplification`\n- `ArrayFlattening`\n- `AttributeDeduction`\n- `BasicBlockMerging`\n- `BranchSimplification`\n- `ConstantFolding`\n- `DeadCodeElimination`\n- `DeadStoreElimination`\n- `FunctionInlining`\n- `GlobalCodeMotion`\n- `GlobalDeadCodeElimination`\n- `GlobalValueNumbering`\n- `InstructionCombining`\n- `JumpThreading`\n- `Mem2Reg`\n- `PoisonPropagation`\n- `RedundantLoadElimination`\n- `StrengthReduction`\n- `TailCallElimination`\n- `TailDuplication`\n- `UnreachableBlockElimination`\n- `AliasAnalysis`\n- `DominatorTreeAnalysis`\n- `LoopTreeAnalysis`\n\n#### MIR-Level\n\n- `BasicBlockMerging`\n- `BasicBlockReordering`\n- `CopyPropagation`\n- `DeadCodeElimination`\n- `JumpThreading`\n- `NullOperationElimination`\n- `RegisterReuse`\n- `StackOffsetEvaluation`\n- `TailDuplication`\n- `UnreachableBlockElimination`\n- `ZeroRegisterReplacement`\n- `BranchPredictionAnalysis`\n- `LiveVariableAnalysis`\n- `RISCVConstantPropagation` (`riscv64`)\n\n#### MC-Level\n\n- `RISCVFallthrough` (`riscv64`)\n- `RISCVUnusedLabelElimination` (`riscv64`)\n\n### Register Allocators\n\n- `GraphColoringAllocator`\n- `LinearScanAllocator`\n- `NaiveAllocator`\n\n## Usage\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003emain.ll\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n```llvm\n@format = private constant [15 x i8] c\"Hello, world!\\0A\\00\"\n\ndeclare i32 @printf(ptr, ...)\n\ndefine i32 @main() {\n0:\n  %1 = call i32 (ptr, ...) @printf(ptr @format)\n  ret i32 0\n}\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n```sh\nmini-llc --target riscv64 -o main.s main.ll\n```\n\n## Build\n\n| Linux | macOS | Windows |\n|:-:|:-:|:-:|\n| ✅ | ✅ | ✅ |\n\n| GCC | Clang | MSVC |\n|:-:|:-:|:-:|\n| ≥ 14 | ≥ 18 (libstdc++ ≥ 14, libc++ ❌*) | ≥ 19.42 (VS 2022 17.12) |\n\n\\* libc++ lacks support for certain C++23 features such as `std::move_only_function` and `std::views::enumerate`\n\n| CMake | Bazel |\n|:-:|:-:|\n| ≥ 3.20 | ≥ 7.1 |\n\n```sh\ngit clone --depth=1 --recurse-submodules --shallow-submodules \u003crepo-url\u003e\n```\n\n### With CMake\n\n```sh\nsudo apt-get update\nsudo apt-get install -y g++-14 cmake ninja-build\n\ncd \u003crepo-dir\u003e\nmkdir build \u0026\u0026 cd build\n\ncmake -DCMAKE_CXX_COMPILER=g++-14 -DCMAKE_BUILD_TYPE=Release -DMINI_LLVM_TESTS=ON -G Ninja ..\ncmake --build .\n\n./tools/mini-llc/mini-llc --help\n```\n\n| Build Option | Default | Description |\n| - | - | - |\n| `BUILD_SHARED_LIBS` | `OFF` | Build mini-llvm as a shared library (libmini-llvm.so) |\n| `MINI_LLVM_TESTS` | `OFF` | Build tests |\n| `MINI_LLVM_FUZZ` | `OFF` | Build fuzz targets |\n| `MINI_LLVM_DOCS` | `OFF` | Build docs (requires Doxygen and Graphviz) |\n\n### With Bazel\n\n```sh\nsudo apt-get update\nsudo apt-get install -y g++-14\n\n# Install Bazel: https://bazel.build/install/ubuntu\n\ncd \u003crepo-dir\u003e\n\nCC=gcc-14 CXX=g++-14 bazel build -c opt //...\n\n./bazel-bin/tools/mini-llc/mini-llc --help\n```\n\n| Build Option | Default | Description |\n| - | - | - |\n| `--//:shared` | `false` | Build mini-llvm as a shared library (libmini-llvm.so) |\n\n## Testing\n\n### Unit Tests\n\n```sh\n# CMake\ncd \u003crepo-dir\u003e/build\nctest\n\n# Bazel\ncd \u003crepo-dir\u003e\nCC=gcc-14 CXX=g++-14 bazel test -c opt //unittests:unittests\n```\n\n### Integration Tests\n\n```sh\nsudo apt-get update\nsudo apt-get install -y gcc-riscv64-linux-gnu qemu-user\n\nsudo mkdir -p /usr/gnemul\nsudo ln -s /usr/riscv64-linux-gnu /usr/gnemul/qemu-riscv64\n\ncd \u003crepo-dir\u003e/tests/mini-llc\n\n# CMake\n./test_all.sh \\\n  --mini-llc ../../build/bin/mini-llc \\\n  --target riscv64 \\\n  --driver riscv64-linux-gnu-gcc \\\n  --emulator qemu-riscv64\n\n# Bazel\n./test_all.sh \\\n  --mini-llc ../../bazel-bin/tools/mini-llc/mini-llc \\\n  --target riscv64 \\\n  --driver riscv64-linux-gnu-gcc \\\n  --emulator qemu-riscv64\n```\n\n## Installation\n\n```sh\n# CMake\ncd \u003crepo-dir\u003e/build\ncmake --install .\n```\n\n## References\n\n- LLVM Language Reference Manual. https://llvm.org/docs/LangRef.html\n- Cliff Click. 1995. Global code motion/global value numbering. In *Proceedings of the ACM SIGPLAN 1995 Conference on Programming Language Design and Implementation* (PLDI '95). Association for Computing Machinery, New York, NY, USA, 246–257. https://doi.org/10.1145/207110.207154\n- Ron Cytron, Jeanne Ferrante, Barry K. Rosen, Mark N. Wegman, and F. Kenneth Zadeck. 1991. Efficiently computing static single assignment form and the control dependence graph. *ACM Trans. Program. Lang. Syst.* 13, 4 (Oct. 1991), 451–490. https://doi.org/10.1145/115372.115320\n- Torbjörn Granlund and Peter L. Montgomery. 1994. Division by invariant integers using multiplication. In *Proceedings of the ACM SIGPLAN 1994 Conference on Programming Language Design and Implementation* (PLDI '94). Association for Computing Machinery, New York, NY, USA, 61–72. https://doi.org/10.1145/178243.178249\n- Thomas Lengauer and Robert Endre Tarjan. 1979. A fast algorithm for finding dominators in a flowgraph. *ACM Trans. Program. Lang. Syst.* 1, 1 (Jan. 1979), 121–141. https://doi.org/10.1145/357062.357071\n- Massimiliano Poletto and Vivek Sarkar. 1999. Linear scan register allocation. *ACM Trans. Program. Lang. Syst.* 21, 5 (Sept. 1999), 895–913. https://doi.org/10.1145/330249.330250\n\n## License\n\nmini-llvm is licensed under the [MIT license](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmini-llvm%2Fmini-llvm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmini-llvm%2Fmini-llvm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmini-llvm%2Fmini-llvm/lists"}