Branch: WinOS-CMake Status: ✅ COMPLETE - All 13 tutorials available Date Completed: 2025-11-11
This document summarizes the complete Windows-native MLIR tutorial series created for the WinOS-CMake branch. All 13 tutorials from Jeremy Kun's original series have been adapted for Windows/MSYS2/CMake development.
Beyond platform adaptation, these tutorials have been significantly enhanced with pedagogical narrative grounded in Jeremy Kun's original 2023 blog articles. This enhancement represents a deliberate technical approach.
Goal: Transform technical reference material into contextual learning experiences that preserve Jeremy's "between the lines" insights while maintaining professional clarity.
Method: Each tutorial was systematically enhanced by:
-
Going through Jeremy's original blog articles - Direct consultation with source material at jeremykun.com, ensuring accuracy and completeness
-
Extracting conceptual depth - Identifying philosophical motivations, design trade-offs, honest assessments of limitations, and the "why" behind technical choices (not just the "how")
-
Professional reinterpretation - Translating Jeremy's conversational blog style into a concise narrative that maintains approachability while avoiding casual mimicry
-
Structured integration - Adding enhanced introductions explaining motivation before mechanism, and reorganizing Key Takeaways into "Conceptual" and "Practical" sections
-
Preserving candor - Retaining Jeremy's honest acknowledgments of friction points, incomplete features, documentation gaps, and learning curve challenges
Perspective and Purpose
- Why features exist (motivation and design philosophy)
- Trade-offs and economic arguments (e.g., "compile-time evaluation is leverage")
- Architectural insights (e.g., "traits invert the optimization burden")
- Design patterns and their implications (e.g., "storage classes hide complexity")
Honest assessments:
- Limitations and expressivity gaps (e.g., "DRR cannot check 'has single use' constraint")
- Documentation inadequacies (e.g., "trait list is missing quite a few...")
- Learning curve realities (e.g., "must dig through pass implementations to understand traits")
- Evolution and maturity acknowledgments (e.g., "DRR is in maintenance mode," "PDLL is incomplete as of this writing")
Contextual connections:
- How features compose (e.g., "folders + canonicalization + SCCP address complementary scopes")
- When to use each approach (e.g., "C++ patterns vs DRR vs PDLL")
- Why multiple mechanisms exist for similar tasks
- How design decisions cascade through passes (e.g., "trait discovery friction")
Before enhancement (technical focus):
## Traits
Traits are mixins that add behavior to operations. Add the Pure trait to enable optimizations.After enhancement (pedagogical depth):
## Traits: Inverting the Optimization Burden
When you define a custom dialect, there's a traditional problem: how do you get existing
compiler infrastructure to work with your new operations? The naive answer: write custom
passes for every optimization. This doesn't scale.
Traits invert this burden. Rather than making passes know about your dialect, you make
your dialect declare properties that passes already understand. The trait is a contract,
a zero-method interface that declares behavioral properties.
However, Jeremy's candid observation: "To figure out what each trait does, you have to
dig through the pass implementations." The official traits list "is missing quite a few."
This discovery friction is real...This enhancement approach ensures learners understand not just what to do, but why design decisions were made, when to apply different techniques, and what limitations exist in practice.
Time to Complete: estimated 4-6 hours Prerequisites: Basic C++ knowledge, Windows development setup
| # | Tutorial | File | Words | Status |
|---|---|---|---|---|
| 01 | Getting Started | 01-getting-started.md | 5,525 | ✅ Complete |
| 02 | Running and Testing | 02-running-and-testing.md | ~4,500 | ✅ Complete |
| 03 | Writing First Pass | 03-writing-first-pass.md | ~3,500 | ✅ Complete |
| 04 | Using Tablegen | 04-using-tablegen.md | 4,315 | ✅ Complete |
Topics Covered:
- Setting up Windows development environment
- MLIR architecture and dialects
- lit/FileCheck testing framework
- Pattern rewriting and IR manipulation
- TableGen code generation
Time to Complete: 10-12 hours Prerequisites: Completed beginner tutorials
| # | Tutorial | File | Words | Status |
|---|---|---|---|---|
| 05 | Defining a Dialect | 05-defining-dialect.md | 3,908 | ✅ Complete |
| 06 | Using Traits | 06-using-traits.md | 3,460 | ✅ Complete |
| 07 | Folders & Constant Propagation | 07-folders-constant-propagation.md | 3,591 | ✅ Complete |
| 08 | Verifiers | 08-verifiers.md | 3,407 | ✅ Complete |
| 09 | Canonicalizers | 09-canonicalizers.md | 3,855 | ✅ Complete |
Topics Covered:
- Custom dialect design and implementation
- Operation traits for optimization
- Constant folding and propagation
- IR verification and error messages
- Declarative rewrite patterns (DRR)
Time to Complete: 8-10 hours Prerequisites: Completed intermediate tutorials
| # | Tutorial | File | Words | Status |
|---|---|---|---|---|
| 10 | Dialect Conversion | 10-dialect-conversion.md | 3,080 | ✅ Complete |
| 11 | Lowering through LLVM | 11-lowering-through-llvm.md | 2,955 | ✅ Complete |
| 12 | Dataflow Analysis | 12-dataflow-analysis.md | 3,089 | ✅ Complete |
| 13 | PDLL Patterns | 13-pdll-patterns.md | 3,319 | ✅ Complete |
Topics Covered:
- Systematic dialect conversion framework
- Complete lowering pipeline to machine code
- Dataflow analysis and optimization
- PDLL (Pattern Description Language)
All 13 tutorials from Jeremy Kun's original series have been adapted and are available.
Every tutorial includes:
- PowerShell commands instead of bash
- CMake build instructions instead of Bazel
- MSYS2/MinGW64 toolchain references
- Windows-specific troubleshooting
All content is in the repository:
- No external dependencies for learning
- Links to original articles for additional context
- Complete code examples from the repository
- Progressive difficulty curve
Every tutorial follows the same structure:
- Original article attribution
- Windows adaptation note
- Comprehensive content sections
- Code examples with explanations
- Key takeaways
- Navigation links (previous/next)
- Additional resources
Emphasis on:
- Runnable examples in
tests/directory - Complete CMake build configurations
- Real-world code from the Poly dialect
- Debugging techniques for Windows
- FileCheck test patterns
mlir-tutorial/
├── docs/
│ ├── tutorials/
│ │ ├── README.md # Tutorial index
│ │ ├── 01-getting-started.md # Beginner
│ │ ├── 02-running-and-testing.md
│ │ ├── 03-writing-first-pass.md
│ │ ├── 04-using-tablegen.md
│ │ ├── 05-defining-dialect.md # Intermediate
│ │ ├── 06-using-traits.md
│ │ ├── 07-folders-constant-propagation.md
│ │ ├── 08-verifiers.md
│ │ ├── 09-canonicalizers.md
│ │ ├── 10-dialect-conversion.md # Advanced
│ │ ├── 11-lowering-through-llvm.md
│ │ ├── 12-dataflow-analysis.md
│ │ └── 13-pdll-patterns.md
│ └── TUTORIAL_COMPLETION_SUMMARY.md # This file
├── README.md # Updated with all tutorials
├── QUICKSTART.md # Fast setup guide
├── WINDOWS_SETUP.md # Comprehensive Windows guide
└── CHANGELOG-WinOS.md # Branch changelog
Goal: Learn MLIR from scratch
- Complete environment setup (QUICKSTART.md)
- Tutorial 01: Getting Started
- Tutorial 02: Running and Testing
- Tutorial 03: Writing First Pass
- Tutorial 04: Using Tablegen
- Continue with tutorials 05-13 in order
Estimated Time: 24-30 hours
Goal: Learn MLIR-specific features
- Skim tutorials 01-02 (setup and basics)
- Tutorial 03: Writing First Pass
- Tutorial 05: Defining a Dialect
- Tutorial 09: Canonicalizers
- Tutorial 10: Dialect Conversion
- Tutorial 11: Lowering through LLVM
Estimated Time: 12-15 hours
Goal: Focus on Windows-specific tooling
- WINDOWS_SETUP.md (comprehensive Windows guide)
- Tutorial 01: Getting Started
- Tutorial 02: Running and Testing (lit/FileCheck)
- Tutorial 04: Using Tablegen (CMake integration)
- Continue with remaining tutorials
Estimated Time: 20-25 hours
| Aspect | Original (Jeremy Kun) | WinOS-CMake Adaptation |
|---|---|---|
| Build System | Bazel/CMake | CMake focus |
| Platform | macOS/Linux primary | Windows primary |
| LLVM Installation | Build from source | Pre-built MSYS2 packages |
| Setup Time | 2-4 hours | 5-30 minutes |
| Shell | bash | PowerShell |
| Toolchain | System compiler | MSYS2/MinGW64 |
| Content | 100% MLIR concepts | 100% MLIR concepts |
| Examples | External links | In-repository |
✅ Original Article Links - Attribution and reference to Jeremy Kun's work
✅ Windows Adaptation Note - Clear statement about Windows focus
✅ Comprehensive Content - 2,500-4,500 words per tutorial
✅ Code Examples - 10-20 examples per tutorial with explanations
✅ CMake Integration - Complete build instructions for Windows
✅ PowerShell Commands - Windows-native shell examples
✅ FileCheck Tests - Testing patterns for transformations
✅ Debugging Sections - Windows-specific troubleshooting
✅ Navigation Links - Previous/Next tutorial links
✅ Key Takeaways - Summary of important concepts
✅ Additional Resources - Links to MLIR documentation
- Tutorial 01: Environment setup, MSYS2 vs MinGW64 explanation
- Tutorial 02: Complete lit/FileCheck reference
- Tutorial 03: VSCode debugging configuration
- Tutorial 04: TableGen generated code explanation
- Tutorial 05: Complete dialect implementation walkthrough
- Tutorial 06: Trait-enabled optimization examples
- Tutorial 07: SCCP pass detailed explanation
- Tutorial 08: Verification testing with verify-diagnostics
- Tutorial 09: DRR vs C++ pattern comparison
- Tutorial 10: Type converter implementation
- Tutorial 11: Lowering through LLVM overview
- Tutorial 12: Dataflow/Lattice theory practical application
- Tutorial 13: PDLL compilation and integration
-
Clone the repository:
git clone --branch WinOS-CMake https://github.com/YOUR-FORK/mlir-tutorial.git cd mlir-tutorial
-
Complete setup:
.\scripts\setup-msys2.ps1 .\scripts\build-windows.ps1
-
Start learning:
- Open docs/tutorials/README.md
- Begin with Tutorial 01
- Work through sequentially
To add or update tutorials:
- Follow existing format (see tutorials 01-13)
- Include Windows-specific examples
- Use PowerShell for commands
- Reference CMake (not Bazel)
- Test all code examples
- Update navigation links
- Add to README.md and tutorials/README.md
- Author: Jeremy Kun (@j2kun)
- Website: jeremykun.com
- Repository: github.com/j2kun/mlir-tutorial
- Branch: WinOS-CMake
- Focus: Native Windows development with MSYS2/CMake
- Goal: Support Fidelity Framework F# compiler development
- Approach: Deep narrative integration from Jeremy Kun's 2023 blog articles
- Method: Systematic extraction and professional reinterpretation of conceptual insights
- Scope: 11 tutorials (01, 04-13) enhanced with "between the lines" perspectives
- Verification: All enhanced tutorials verified against original source material (November 2025)
- LLVM Foundation for MLIR
- Jeremy Kun for excellent original tutorials and pedagogical depth
- MSYS2 project for pre-built LLVM packages
- Video walkthroughs for key tutorials
- Additional Windows-specific optimization tips
- Integration examples with F# Fidelity Framework
- Tracy profiler integration tutorial
- Advanced debugging techniques tutorial
- Performance comparison: Windows vs Linux MLIR
We welcome:
- Tutorial improvements and corrections
- Additional Windows-specific tips
- More examples and use cases
- Better explanations of complex topics
Same as the original mlir-tutorial repository: Apache 2.0 with LLVM Exceptions
- Setup Issues: See WINDOWS_SETUP.md
- Tutorial Questions: Read original articles at jeremykun.com
- MLIR Questions: Visit LLVM Discourse
- Windows-Specific Issues: Open issue on this fork
Status: ✅ COMPLETE - All 13 tutorials available for Windows-native MLIR development!
Enhancement: ✅ PEDAGOGICALLY ENRICHED - 11 tutorials feature deep narrative integration from Jeremy Kun's original blog articles, verified for accuracy and completeness (November 2025)
Last Updated: 2025-11-11