|
MimIR 0.1
MimIR is my Intermediate Representation
|
MimIR is a pure, graph-based, higher-order intermediate representation rooted in the Calculus of Constructions. MimIR provides:
MimIR is well suited for DSL compilers, tensor compilers, automatic differentiation, regex engines, and other systems that need high-performance code from high-level abstractions.
| Feature | LLVM | MLIR | MimIR |
|---|---|---|---|
| Higher-order functions | ❌ | ⚠️ (regions only) | ✅ (first-class functions) |
| Parametric polymorphism | ❌ | ❌ | ✅ |
| Type-level abstraction | ❌ | ❌ | ✅ |
| Dependent types | ❌ | ❌ | ✅ |
| Semantic extensibility | ❌ | 🔧 (dialect-specific C++ semantics) | ✅ (typed axioms) |
| Program representation | CFG + instruction lists | CFG/regions + instruction lists | Arbitrary expressions (direct style + CPS) |
| Structural foundation | CFG + dominance | CFG/regions + dominance | Free variables + nesting |
| DSL embedding / semantics retention | ⬇️ Low | ➡️ Medium (dialects, lowering) | ⬆️ High (CC, partial evaluation, typed axioms, normalizers, lowering) |
See the full build options in the docs. For the rest of the documentation, start with the Command-Line Reference, Developer Guide, Language Reference, Plugin Guide, Phase Guide, and Rewriting Guide.
Declare new types, operations, and normalizers in a single .mim file. C++ provides the heavy lifting: optimization, lowering, and code generation.
MimIR uses a sea-of-nodes-style program graph and extends it to the Calculus of Constructions with higher-order functions, polymorphism, and dependent types. MimIR hits the sweet spot between a fully mutable IR, which is easy to construct, and a fully immutable IR:
Non-binder expressions are immutable:
Hash-consing, normalization, type checking, and partial evaluation happen automatically during graph construction.
Binders are mutable where needed:
They support variables and recursion by “tying the knot” through in-place mutation.
Terms and types share one graph:
Terms, types, and type-level computations all live in the same program graph as ordinary expressions.
Forget CFG dominance. MimIR uses free-variable nesting:
Free-variable queries “just work”:
This is always correct. MimIR maintains free-variable information lazily, locally, and transparently: results are computed on demand, memoized, and invalidated only where needed.
MimIR is a recursive acronym for MimIR is my Intermediate Representation.
In Norse mythology, Mímir was a being of immense wisdom. After being beheaded in the Æsir–Vanir War, Odin preserved his head, which continued to speak secret knowledge and offer counsel.
Today, you have Mímir's head at your fingertips.
Throughout the codebase, we consistently use mim / MIM for namespaces, macros, CMake variables, and related identifiers.
Ready to build the next generation of DSL compilers?
⭐ Star MimIR on GitHub, join Discord, and let's make high-performance DSLs easy.
MimIR is licensed under the MIT License.