Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
426 commits
Select commit Hold shift + click to select a range
3c719cc
Add docstrings to operations
denialhaag Nov 4, 2025
dc80d1c
Improve assembly format of flux.ctrl
denialhaag Nov 4, 2025
e71d02e
Add docstrings to conversion patterns
denialhaag Nov 4, 2025
e1da5a3
Add docstring to foldParameterArityTrait
denialhaag Nov 4, 2025
b63e248
Put translation on a more permanent footing
denialhaag Nov 5, 2025
b570fb8
Make all operations controllable in Quartz-to-Flux conversion
denialhaag Nov 5, 2025
5281f15
Make all operations controllable in Flux builder
denialhaag Nov 5, 2025
c3e9d23
WIP: Convert CtrlOp to QIR
denialhaag Nov 5, 2025
95c77cf
Fix linter errors
denialhaag Nov 5, 2025
5c6acd4
Add verifiers to CtrlOps
denialhaag Nov 5, 2025
b58e9b2
Merge branch 'main' into dialect-implementation
burgholzer Nov 5, 2025
7440f12
🚨 silence a compiler warning
burgholzer Nov 5, 2025
37de9e7
♻️ refactor parameter handling
burgholzer Nov 6, 2025
bda0237
🚧 WIP better module equivalence checking
burgholzer Nov 6, 2025
ebd73f9
♻️ refactor QIR conversion and builder to comply with QIR 2.0
burgholzer Nov 7, 2025
0684b54
🚧 WIP on ctrl modifier
burgholzer Nov 10, 2025
49a830c
🚨 fix compiler warnings
burgholzer Nov 10, 2025
04ce9f9
♻️ fix CtrlOp handling and improve conversions
burgholzer Nov 11, 2025
6a536fe
Merge branch 'main' into dialect-implementation
burgholzer Nov 11, 2025
0d1a582
♻️ make Quartz and Flux builder directly inherit from OpBuilder
burgholzer Nov 11, 2025
aba0103
Fix a good portion of the linter errors
denialhaag Nov 17, 2025
02307e9
Fix more linter errors
denialhaag Nov 17, 2025
f168c05
Support CX conversion to QIR
denialhaag Nov 17, 2025
2a7eb06
Streamline unitary tests
denialhaag Nov 17, 2025
be7f87b
Also support CRX, CU2, and CWAP conversions to QIR
denialhaag Nov 17, 2025
0f700c3
Fix linter errors
denialhaag Nov 17, 2025
077360f
Fix linter error about nondeterministic order
denialhaag Nov 17, 2025
a4b9075
Fix QIR of conversion of quartz.measure
denialhaag Nov 17, 2025
a30417b
Streamline QIR conversions
denialhaag Nov 17, 2025
8d88a48
Revert "Fix linter error about nondeterministic order"
denialhaag Nov 17, 2025
c09b40f
Include correct header
denialhaag Nov 17, 2025
f15c9a2
Use QIR conversion state for converting controlled operations
denialhaag Nov 18, 2025
5aebf4a
Fix static matrices and add initial support for controlled ones
denialhaag Nov 18, 2025
ce03531
Remove unnecessary header
denialhaag Nov 18, 2025
8ab3435
Remove unnecessary headers
denialhaag Nov 18, 2025
53ba841
Fix static matrices for multiple controls
denialhaag Nov 18, 2025
3d4b879
Add support for S and Sdg without looking for commonalities yet
denialhaag Nov 20, 2025
e606f3f
Streamline conversions by defining template functions
denialhaag Nov 20, 2025
4ebb7f2
Streamline builders by defining template functions
denialhaag Nov 20, 2025
2428304
Add support for Id
denialhaag Nov 20, 2025
6412088
Add support for Y, Z, H, T, Tdg, SX, and SXdg
denialhaag Nov 20, 2025
8130308
Use std::numbers::pi
denialhaag Nov 20, 2025
b7ee9b9
Improve support for nested regions
denialhaag Nov 22, 2025
2aca4ab
Streamline canonicalizations by defining template functions
denialhaag Nov 22, 2025
8798f34
Fix linter errors
denialhaag Nov 22, 2025
f55ebba
Ignore this one linter error
denialhaag Nov 22, 2025
80715e7
Fix remaining linter errors
denialhaag Nov 22, 2025
cfe1576
Include missing header
denialhaag Nov 22, 2025
d6ced4d
Modularize standard gates
denialhaag Nov 24, 2025
7eb161a
Fix linter errors
denialhaag Nov 24, 2025
92019ce
Add support for RY
denialhaag Nov 24, 2025
4fe3739
Add support for RZ and P
denialhaag Nov 24, 2025
85a3956
Fix linter errors
denialhaag Nov 24, 2025
b71e6fc
Rename removeInversePair()
denialhaag Nov 24, 2025
a487837
Streamline canonicalizations by defining template functions
denialhaag Nov 24, 2025
dff917d
Modularize modifiers
denialhaag Nov 24, 2025
530e847
Support multi-controlled operations in QIR
denialhaag Nov 24, 2025
dd599ca
Simplify template functions of QIR builders
denialhaag Nov 24, 2025
639afe8
Add support for R
denialhaag Nov 24, 2025
466eb0a
Add support for iSWAP
denialhaag Nov 24, 2025
05db54f
Fix linter errors
denialhaag Nov 24, 2025
bbd10c3
Add canonicalizer to SWAP
denialhaag Nov 24, 2025
866c2c3
Add untested canonicalizer to U2
denialhaag Nov 24, 2025
65eeab9
Fix linter errors
denialhaag Nov 24, 2025
7f8d5ab
Merge branch 'main' into dialect-implementation
denialhaag Nov 27, 2025
adc03b8
Merge branch 'main' into dialect-implementation
denialhaag Nov 27, 2025
f3f3ebe
Use macros to define Quartz builder methods
denialhaag Nov 27, 2025
fbbe245
Use macros also for Flux and QIR builders
denialhaag Nov 27, 2025
af9de49
Use macros for converters
denialhaag Nov 27, 2025
cff1d62
Use macros for builder header files
denialhaag Nov 27, 2025
aae623c
Add support for DCX and ECR
denialhaag Nov 28, 2025
7442fc5
Add support for U
denialhaag Nov 28, 2025
41298c6
Add support for RXX
denialhaag Nov 28, 2025
e45bf4b
Add support for XXPlusYY
denialhaag Nov 28, 2025
f02d52e
Add support for RYY, RZX, and RZZ
denialhaag Nov 28, 2025
f4778f8
Add support for XXMinusYY
denialhaag Nov 28, 2025
0800cb7
Remove unnecessary header inclusions
denialhaag Nov 28, 2025
d6924e3
Merge branch 'main' into dialect-implementation
denialhaag Nov 28, 2025
f3085a1
Fix linter error
denialhaag Nov 28, 2025
dfa7a78
Get rid of Flux helpers because they are no longer helpful
denialhaag Nov 28, 2025
46dece7
Simplify QIR helpers
denialhaag Nov 28, 2025
cf2f9dd
Merge branch 'main' into dialect-implementation
denialhaag Nov 30, 2025
171adda
🎨 pre-commit fixes
pre-commit-ci[bot] Nov 30, 2025
06b576c
Use macros for translation
denialhaag Dec 1, 2025
eb7b62e
Implement all merge and inverse-pair canonicalizations
denialhaag Dec 1, 2025
b73803d
Add canonicalizations for XXPlusYY and XXMinusYY
denialhaag Dec 1, 2025
7e6ce39
Fix equivalence checking of constants
denialhaag Dec 1, 2025
b5bc9c4
Further modularize operations
denialhaag Dec 1, 2025
614e2ca
Use macros for QIR function names
denialhaag Dec 1, 2025
bdade00
Run linter on all files
denialhaag Dec 1, 2025
1280e4c
Add square-root canonicalizations
denialhaag Dec 1, 2025
db73361
Remove unnecessary headers
denialhaag Dec 1, 2025
b2876b9
Maybe fix linter error
denialhaag Dec 1, 2025
d5f3e57
Add canonicalization patterns for removing trivial rotations
denialhaag Dec 2, 2025
2642929
Add initial support for GPhase
denialhaag Dec 2, 2025
73d8471
Revert "Maybe fix linter error"
denialhaag Dec 2, 2025
4c8e042
Fix docstrings for GPhase
denialhaag Dec 2, 2025
b14efec
Fix header path
denialhaag Dec 2, 2025
3a7df64
Use MemWrite instead of MemAlloc
denialhaag Dec 2, 2025
d8fd8a0
Fix linter errors
denialhaag Dec 2, 2025
5b0aeec
Another attempt at fixing the linter error about slicing
denialhaag Dec 2, 2025
f80bc01
Revert "Another attempt at fixing the linter error about slicing"
denialhaag Dec 2, 2025
d94463c
Fix conversion of controlled GPhase operations
denialhaag Dec 2, 2025
280ec05
Streamline qubit variables
denialhaag Dec 2, 2025
9d557b1
Add support for barriers
denialhaag Dec 2, 2025
957b5d8
Remove matrix extraction for now
denialhaag Dec 2, 2025
1eb3607
Fix linter errors
denialhaag Dec 2, 2025
754372e
Add barrier canonicalization and remove it from QIR
denialhaag Dec 2, 2025
984212d
Add Bell test
denialhaag Dec 2, 2025
d01d260
Add current version of cgphase test
denialhaag Dec 3, 2025
319c19d
Add test for already implemented U2 canonicalization
denialhaag Dec 3, 2025
e360420
Add remaining U2 canonicalizations
denialhaag Dec 3, 2025
280d3a6
Add R canonicalizations
denialhaag Dec 3, 2025
3c0baaa
Add U canonicalizations
denialhaag Dec 3, 2025
a640013
Look forward instead of backward for barrier canonicalization
denialhaag Dec 3, 2025
93b53c5
Inline controlled GPhaseOps in Flux
denialhaag Dec 3, 2025
248b411
Drop support for controlled global phases in QIR
denialhaag Dec 3, 2025
f718704
Inline controlled GPhaseOps in Quartz
denialhaag Dec 3, 2025
29e5db2
Fix linter errors
denialhaag Dec 3, 2025
50933e2
Ignore slicing error for now
denialhaag Dec 3, 2025
87bdd11
Remove everything related to memref
denialhaag Dec 5, 2025
c892f42
Fix docstrings and descriptions
denialhaag Dec 5, 2025
0d8c771
Trivial code simplifications
denialhaag Dec 5, 2025
d9507b6
Add assertion messages
denialhaag Dec 5, 2025
d9ed92f
Add bounds checks on qubit index
denialhaag Dec 5, 2025
d4a1c8f
Make QIR builder private again
denialhaag Dec 5, 2025
a89530e
Rename TRANSLATION_HEADERS_SOURCE
denialhaag Dec 5, 2025
8fafdc2
Remove redundant glob patterns
denialhaag Dec 5, 2025
6aed309
Add RemoveTrivialP pattern
denialhaag Dec 5, 2025
aa6627f
Remove unnecessary header
denialhaag Dec 8, 2025
b6b62c1
Simplify Value initializations
denialhaag Dec 8, 2025
b7b22a8
Improve comparison of floating-point values
denialhaag Dec 8, 2025
dded22b
Remove state from addInitialize()
denialhaag Dec 8, 2025
09b0086
Fix module initialization
denialhaag Dec 8, 2025
f091b44
Add guard to FluxUtils.h
denialhaag Dec 8, 2025
c9d4bd5
Improve comparison of betas
denialhaag Dec 8, 2025
1458542
Do not using namespace in FulxUtils.h
denialhaag Dec 8, 2025
61dcd02
Replace asserts with fatal errors
denialhaag Dec 8, 2025
7a8f91f
Use reportFatalUsageError where it makes sense
denialhaag Dec 8, 2025
c4a3e6a
Remove unnecessary flushes
denialhaag Dec 8, 2025
a6e0dec
Use getNumPosControls()
denialhaag Dec 8, 2025
e8533d2
Simplify builders by defining a helper function
denialhaag Dec 8, 2025
96411ee
Rename PhaseOp.cpp
denialhaag Dec 8, 2025
813f2d7
Rename odsBuilder and odsState arguments
denialhaag Dec 8, 2025
97950e0
Include variant
denialhaag Dec 8, 2025
2669b30
Make use of interface methods in canonicalization patterns
denialhaag Dec 8, 2025
7b75a94
Remove unnecessary header
denialhaag Dec 8, 2025
0537ffb
Fix module initialization
denialhaag Dec 8, 2025
f5529be
Fix linter errors
denialhaag Dec 8, 2025
5a2842c
Fix remaining linter errors
denialhaag Dec 8, 2025
9c8242f
Improve error handling
denialhaag Dec 8, 2025
c637630
Improve null safety in QIRUtils.cpp
denialhaag Dec 8, 2025
7bdb289
Fix insertion point
denialhaag Dec 8, 2025
de23c39
Add bounds checks to CtrlOp methods
denialhaag Dec 8, 2025
a0e54d5
Fix docstrings
denialhaag Dec 8, 2025
e7ac020
Validate register size
denialhaag Dec 8, 2025
cccac6f
Validate static index
denialhaag Dec 8, 2025
25b8805
Use inline constexpr instead of static constexpr
denialhaag Dec 8, 2025
c2513ec
Include headers in header file
denialhaag Dec 8, 2025
b53ccd6
Streamline Flux helpers
denialhaag Dec 8, 2025
b1d352a
Clarify insertion guard names
denialhaag Dec 8, 2025
dcb2b08
Mark command-line options as static instead of const
denialhaag Dec 8, 2025
4f2b535
Add comment to explain handling of nested CtrlOps
denialhaag Dec 8, 2025
cca9959
Make use of getParameter() to improve readability of conversions
denialhaag Dec 8, 2025
998242c
Improve documentation of compiler pipeline
denialhaag Dec 8, 2025
481bc80
Revert "Mark command-line options as static instead of const"
denialhaag Dec 8, 2025
218cb98
Further improve null safety in QIRUtils.cpp
denialhaag Dec 8, 2025
bebe71b
Do not explicitly erase body CtrlOp
denialhaag Dec 8, 2025
448feea
Fix RemoveTrivialCtrl patterns
denialhaag Dec 8, 2025
bd42b36
Use op.emitError() instead of llvm::errs()
denialhaag Dec 8, 2025
282dca8
Do not using OpConversionPattern
denialhaag Dec 8, 2025
c28b779
Validate result index
denialhaag Dec 8, 2025
af4ed3c
Fix docstring
denialhaag Dec 8, 2025
1713672
Add unit test for nested CtrlOps
denialhaag Dec 8, 2025
fc1c4a4
Include more headers in header files
denialhaag Dec 8, 2025
5bfe41a
Simply erase operation in RemoveTrivialCtrl pattern for Quartz
denialhaag Dec 8, 2025
d342a27
Remove const from Value and ValueRange
denialhaag Dec 9, 2025
d792424
Remove const from more Values
denialhaag Dec 9, 2025
6eabd43
Use factor method to create ModuleOp
denialhaag Dec 14, 2025
71ba049
Add --record-intermediates flag
denialhaag Dec 14, 2025
0776019
Update docstrings in QIRUtils.h
denialhaag Dec 14, 2025
3999b42
Document current limitations of Quartz-to-QIR conversion
denialhaag Dec 14, 2025
a382021
Remove dialect-name variables
denialhaag Dec 14, 2025
4c655b3
Let pipeline fail if config is not valid
denialhaag Dec 14, 2025
bbbe2b7
Load dialects in constructors
denialhaag Dec 14, 2025
864dbf2
Make default classical-register name more safe
denialhaag Dec 14, 2025
94458a8
Make createResultLabel more safe
denialhaag Dec 14, 2025
c50594b
Ensure that builders cannot be used after finalization
denialhaag Dec 14, 2025
8cc1959
Use auto instead of Value to maybe get rid of const linter errors
denialhaag Dec 14, 2025
d574f84
Ignore downcast linter error for now
denialhaag Dec 14, 2025
e15acd9
Bump minimum MLIR version for clarity
denialhaag Dec 14, 2025
b3545bf
Sort qubits before deallocating
denialhaag Dec 14, 2025
842c653
Add assertions to Quartz-to-Flux conversion
denialhaag Dec 14, 2025
6b447a2
Give ClassicalRegister ownership of name
denialhaag Dec 15, 2025
14cab18
Fix trivial CtrlOps
denialhaag Dec 15, 2025
657d1c7
Do not use const std::string
denialhaag Dec 15, 2025
ba33fa1
Save name before inserting it into DenseMap
denialhaag Dec 15, 2025
351bb36
Fix docstrings
denialhaag Dec 15, 2025
4374c90
Update docs to reflect corrected required LLVM version
denialhaag Dec 15, 2025
02a7611
Add error handling to translation
denialhaag Dec 15, 2025
adf603b
Validate builder states before finalizing
denialhaag Dec 15, 2025
48f5097
Improve state validation in runPipeline()
denialhaag Dec 15, 2025
b4b39a5
Include missing headers in header files
denialhaag Dec 15, 2025
30f2fb6
Remove unused variables
denialhaag Dec 15, 2025
1424035
Ensure that builders cannot be finalized twice
denialhaag Dec 15, 2025
ef12141
Improve deallocation order
denialhaag Dec 15, 2025
fd6e2f1
Include missing header
denialhaag Dec 15, 2025
c8fcc5a
Improve docstrings
denialhaag Dec 15, 2025
157a469
Improve more docstrings
denialhaag Dec 15, 2025
a764536
Fix assembly formats of some Quartz operations
denialhaag Dec 15, 2025
04c8b04
Improve docstrings one more time
denialhaag Dec 15, 2025
1194973
Improve error message if bit index is out of bounds
denialhaag Dec 15, 2025
ef698db
Fix linter errors
denialhaag Dec 15, 2025
e5cd6d1
Use llvm::cast to fix linter error
denialhaag Dec 15, 2025
f02db72
Remove redesign concept
denialhaag Dec 15, 2025
b171269
Revert "Use llvm::cast to fix linter error"
denialhaag Dec 15, 2025
32a7092
✏️ docstring fixes
burgholzer Dec 15, 2025
d8a182a
🚨 include fixes reported by local clang-tidy
burgholzer Dec 15, 2025
c02310c
👌 address code rabbit comment
burgholzer Dec 15, 2025
4bece21
🔧 lower tolerance
burgholzer Dec 15, 2025
5082913
🐛 Fix canonicalization of controlled global phase
burgholzer Dec 15, 2025
c333456
✏️ ensure consistent parameter names
burgholzer Dec 15, 2025
3ffb553
🚨 add a dedicated clang-tidy file for MLIR
burgholzer Dec 16, 2025
58cd84c
🚨 some more clang-tidy fixes
burgholzer Dec 16, 2025
7eedc26
🚨 hide noisy clang-tidy warning for LLVM
burgholzer Dec 16, 2025
9b41f85
👌 code rabbit fixes
burgholzer Dec 16, 2025
0fd3566
🎨 miscellaneous code quality improvements
burgholzer Dec 16, 2025
a1f39d9
Rename Quartz to QC and Flux to QCO
denialhaag Dec 17, 2025
7e73480
Do not check llvm-include-order
denialhaag Dec 17, 2025
476d743
Fix linter errors
denialhaag Dec 17, 2025
e1d3de8
Update changelog
denialhaag Dec 17, 2025
8d8faeb
Merge branch 'main' into dialect-implementation
denialhaag Dec 17, 2025
b44ba89
Address the Rabbit's comments
denialhaag Dec 17, 2025
e195428
Fix remaining linter errors
denialhaag Dec 17, 2025
9cb28d0
Address the Rabit's remaining comments
denialhaag Dec 17, 2025
421cf4b
Update dialect descriptions
denialhaag Dec 17, 2025
c76577c
One more fix for the Rabbit
denialhaag Dec 17, 2025
b2837ad
Do not mark type as const
denialhaag Dec 17, 2025
e3b24f3
Do not annotate F64 values
denialhaag Dec 17, 2025
e017879
Fix intermediate recording
denialhaag Dec 17, 2025
f315640
Improve description of CtrlOp
denialhaag Dec 17, 2025
c2998d3
Mark operator<< as maybe unused
denialhaag Dec 17, 2025
3db1dfe
Fix naming of QIR blocks
denialhaag Dec 17, 2025
5acaff9
Do not mark filename as const
denialhaag Dec 17, 2025
eb903d0
Streamline assembly formats
denialhaag Dec 17, 2025
aa56d96
Improve description of YieldOp
denialhaag Dec 17, 2025
6a116a7
Improve compilation-record messages
denialhaag Dec 17, 2025
1f9378e
Throw out negative controls altogether
denialhaag Dec 17, 2025
d536db3
Use correct register map
denialhaag Dec 17, 2025
4de31e1
Undo accidental change
denialhaag Dec 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ jobs:
cmake-args: -DBUILD_MQT_CORE_BENCHMARKS=ON -DBUILD_MQT_CORE_MLIR=ON -DBUILD_MQT_CORE_BINDINGS=ON
clang-version: 21
build-project: true
files-changed-only: true
files-changed-only: false
setup-python: true
install-pkgs: "pybind11==3.0.1"
cpp-linter-extra-args: "-std=c++20"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/reusable-mlir-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ jobs:
- name: Build MLIR lit target
run: cmake --build build --config ${{ matrix.coverage && 'Debug' || 'Release' }} --target mqt-core-mlir-lit-test-build-only

- name: Build MLIR translation unittests
run: cmake --build build --config ${{ matrix.coverage && 'Debug' || 'Release' }} --target mqt-core-mlir-translation-test --target mqt-core-mlir-wireiterator-test
- name: Build MLIR unittests
run: cmake --build build --config ${{ matrix.coverage && 'Debug' || 'Release' }} --target mqt-core-mlir-unittests

# Test
- name: Run lit tests
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning], with the exception that minor rel

### Added

- ✨ Add initial infrastructure for new QC and QCO MLIR dialects ([#1264]) ([**@burgholzer**], [**@denialhaag**])
- ✨ Return device handle from `add_dynamic_device_library` for direct backend creation ([#1381]) ([**@marcelwa**])
- ✨ Add IQM JSON support for job submission in Qiskit-QDMI Backend ([#1375], [#1382]) ([**@marcelwa**], [**@burgholzer**])
- ✨ Add authentication support for QDMI sessions with token, username/password, auth file, auth URL, and project ID parameters ([#1355]) ([**@marcelwa**])
Expand Down Expand Up @@ -307,6 +308,7 @@ _📚 Refer to the [GitHub Release Notes](https://github.com/munich-quantum-tool
[#1276]: https://github.com/munich-quantum-toolkit/core/pull/1276
[#1271]: https://github.com/munich-quantum-toolkit/core/pull/1271
[#1269]: https://github.com/munich-quantum-toolkit/core/pull/1269
[#1264]: https://github.com/munich-quantum-toolkit/core/pull/1264
[#1263]: https://github.com/munich-quantum-toolkit/core/pull/1263
[#1247]: https://github.com/munich-quantum-toolkit/core/pull/1247
[#1246]: https://github.com/munich-quantum-toolkit/core/pull/1246
Expand Down
2 changes: 1 addition & 1 deletion cmake/SetupMLIR.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
set(MQT_MLIR_SOURCE_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/mlir/include")
set(MQT_MLIR_BUILD_INCLUDE_DIR "${PROJECT_BINARY_DIR}/mlir/include")
set(MQT_MLIR_MIN_VERSION
"21.0"
"21.1"
CACHE STRING "Minimum required MLIR version")

# MLIR must be installed on the system
Expand Down
2 changes: 1 addition & 1 deletion docs/mlir/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,6 @@ module {

## Development

Building the MLIR library requires LLVM version 21.0 or later.
Building the MLIR library requires LLVM version 21.1 or later.
Our CI pipeline on GitHub continuously builds and tests the MLIR library on Linux, macOS, and Windows.
To access the latest build logs, visit the [GitHub Actions page](https://github.com/munich-quantum-toolkit/core/actions/workflows/ci.yml).
9 changes: 9 additions & 0 deletions mlir/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
InheritParentConfig: true
Checks: |
llvm-namespace-comment,
llvm-prefer-isa-or-dyn-cast-in-conditionals,
llvm-prefer-register-over-unsigned,
llvm-prefer-static-over-anonymous-namespace,
-misc-use-anonymous-namespace,
llvm-twine-local,
-cppcoreguidelines-pro-bounds-avoid-unchecked-container-access
145 changes: 145 additions & 0 deletions mlir/include/mlir/Compiler/CompilerPipeline.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
/*
* Copyright (c) 2023 - 2025 Chair for Design Automation, TUM
* Copyright (c) 2025 Munich Quantum Software Company GmbH
* All rights reserved.
*
* SPDX-License-Identifier: MIT
*
* Licensed under the MIT License
*/

#pragma once

#include <mlir/Pass/PassManager.h>
#include <mlir/Support/LogicalResult.h>
#include <string>

namespace mlir {
class ModuleOp;

/**
* @brief Configuration for the quantum compiler pipeline
*
* @details
* Controls which stages of the compilation pipeline are executed and
* diagnostic options for profiling and debugging.
*/
struct QuantumCompilerConfig {
/// Convert to QIR at the end of the pipeline
bool convertToQIR = false;

/// Record intermediate IR at each stage for debugging/testing
bool recordIntermediates = false;

/// Enable pass timing statistics (MLIR builtin)
bool enableTiming = false;

/// Enable pass statistics (MLIR builtin)
bool enableStatistics = false;

/// Print IR after each stage
bool printIRAfterAllStages = false;
};

/**
* @brief Records the state of IR at various compilation stages
*
* @details
* Stores string representations of the MLIR module at different
* points in the compilation pipeline. Useful for testing and debugging.
* All stages are recorded when recordIntermediates is enabled.
*/
struct CompilationRecord {
std::string afterQCImport;
std::string afterInitialCanon;
std::string afterQCOConversion;
std::string afterQCOCanon;
std::string afterOptimization;
std::string afterOptimizationCanon;
std::string afterQCConversion;
std::string afterQCCanon;
std::string afterQIRConversion;
std::string afterQIRCanon;
};

/**
* @brief Main quantum compiler pipeline
*
* @details
* Provides a high-level interface for compiling quantum programs through
* the MQT compiler infrastructure. The pipeline stages are:
*
* 1. QC dialect (reference semantics) - imported from
* qc::QuantumComputation
* 2. Canonicalization + cleanup
* 3. QCO dialect (value semantics) - enables SSA-based optimizations
* 4. Canonicalization + cleanup
* 5. Quantum optimization passes
* 6. Canonicalization + cleanup
* 7. QC dialect - converted back for backend lowering
* 8. Canonicalization + cleanup
* 9. QIR (Quantum Intermediate Representation) - optional final lowering
* 10. Canonicalization + cleanup
*
* Following MLIR best practices, canonicalization and dead value removal
* are always run after each major transformation stage.
*/
class QuantumCompilerPipeline {
public:
explicit QuantumCompilerPipeline(const QuantumCompilerConfig& config = {})
: config_(config) {}

/**
* @brief Run the complete compilation pipeline on a module
*
* @details
* Executes all enabled compilation stages on the provided MLIR module.
* If recordIntermediates is enabled in the config, captures IR snapshots
* at every stage (10 snapshots total for full pipeline).
*
* Automatically configures the PassManager with:
* - Timing statistics if enableTiming is true
* - Pass statistics if enableStatistics is true
* - IR printing after each stage if printIRAfterAllStages is true
*
* @param module The MLIR module to compile
* @param record Optional pointer to record intermediate states
* @return success() if compilation succeeded, failure() otherwise
*/
LogicalResult runPipeline(ModuleOp module,
CompilationRecord* record = nullptr) const;

private:
/**
* @brief Add canonicalization and cleanup passes
*
* @details
* Always adds the standard MLIR canonicalization pass followed by dead
* value removal.
*/
static void addCleanupPasses(PassManager& pm);

/**
* @brief Configure PassManager with diagnostic options
*
* @details
* Enables timing, statistics, and IR printing based on config flags.
* Uses MLIR's builtin PassManager configuration methods.
*/
void configurePassManager(PassManager& pm) const;

QuantumCompilerConfig config_;
};

/**
* @brief Utility to capture IR as string
*
* @details
* Prints the MLIR module to a string for recording or comparison.
*
* @param module The module to convert to string
* @return String representation of the IR
*/
std::string captureIR(ModuleOp module);

} // namespace mlir
3 changes: 3 additions & 0 deletions mlir/include/mlir/Conversion/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ add_subdirectory(MQTRefToMQTOpt)
add_subdirectory(MQTOptToMQTRef)
add_subdirectory(MQTRefToQIR)
add_subdirectory(QIRToMQTRef)
add_subdirectory(QCOToQC)
add_subdirectory(QCToQCO)
add_subdirectory(QCToQIR)
13 changes: 13 additions & 0 deletions mlir/include/mlir/Conversion/QCOToQC/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) 2023 - 2025 Chair for Design Automation, TUM
# Copyright (c) 2025 Munich Quantum Software Company GmbH
# All rights reserved.
#
# SPDX-License-Identifier: MIT
#
# Licensed under the MIT License

set(LLVM_TARGET_DEFINITIONS QCOToQC.td)
mlir_tablegen(QCOToQC.h.inc -gen-pass-decls -name QCOToQC)
add_public_tablegen_target(QCOToQCIncGen)

add_mlir_doc(QCOToQC MLIRQCOToQC Conversions/ -gen-pass-doc)
21 changes: 21 additions & 0 deletions mlir/include/mlir/Conversion/QCOToQC/QCOToQC.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2023 - 2025 Chair for Design Automation, TUM
* Copyright (c) 2025 Munich Quantum Software Company GmbH
* All rights reserved.
*
* SPDX-License-Identifier: MIT
*
* Licensed under the MIT License
*/

#pragma once

#include <mlir/Pass/Pass.h> // from @llvm-project

namespace mlir {
#define GEN_PASS_DECL_QCOTOQC
#include "mlir/Conversion/QCOToQC/QCOToQC.h.inc"

#define GEN_PASS_REGISTRATION
#include "mlir/Conversion/QCOToQC/QCOToQC.h.inc"
} // namespace mlir
26 changes: 26 additions & 0 deletions mlir/include/mlir/Conversion/QCOToQC/QCOToQC.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) 2023 - 2025 Chair for Design Automation, TUM
// Copyright (c) 2025 Munich Quantum Software Company GmbH
// All rights reserved.
//
// SPDX-License-Identifier: MIT
//
// Licensed under the MIT License

include "mlir/Pass/PassBase.td"

def QCOToQC : Pass<"qco-to-qc"> {
let summary = "Convert QCO dialect to QC dialect.";

let description = [{
This pass converts all operations from the QCO dialect to their equivalent
operations in the QC dialect. It handles the transformation of qubit
values in QCO to qubit references in QC, ensuring that the semantics
of quantum operations are preserved during the conversion process.
}];

// Define dependent dialects
let dependentDialects = [
"mlir::qco::QCODialect",
"mlir::qc::QCDialect"
];
}
13 changes: 13 additions & 0 deletions mlir/include/mlir/Conversion/QCToQCO/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) 2023 - 2025 Chair for Design Automation, TUM
# Copyright (c) 2025 Munich Quantum Software Company GmbH
# All rights reserved.
#
# SPDX-License-Identifier: MIT
#
# Licensed under the MIT License

set(LLVM_TARGET_DEFINITIONS QCToQCO.td)
mlir_tablegen(QCToQCO.h.inc -gen-pass-decls -name QCToQCO)
add_public_tablegen_target(QCToQCOIncGen)

add_mlir_doc(QCToQCO MLIRQCToQCO Conversions/ -gen-pass-doc)
21 changes: 21 additions & 0 deletions mlir/include/mlir/Conversion/QCToQCO/QCToQCO.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2023 - 2025 Chair for Design Automation, TUM
* Copyright (c) 2025 Munich Quantum Software Company GmbH
* All rights reserved.
*
* SPDX-License-Identifier: MIT
*
* Licensed under the MIT License
*/

#pragma once

#include <mlir/Pass/Pass.h> // from @llvm-project

namespace mlir {
#define GEN_PASS_DECL_QCTOQCO
#include "mlir/Conversion/QCToQCO/QCToQCO.h.inc"

#define GEN_PASS_REGISTRATION
#include "mlir/Conversion/QCToQCO/QCToQCO.h.inc"
} // namespace mlir
26 changes: 26 additions & 0 deletions mlir/include/mlir/Conversion/QCToQCO/QCToQCO.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) 2023 - 2025 Chair for Design Automation, TUM
// Copyright (c) 2025 Munich Quantum Software Company GmbH
// All rights reserved.
//
// SPDX-License-Identifier: MIT
//
// Licensed under the MIT License

include "mlir/Pass/PassBase.td"

def QCToQCO : Pass<"qc-to-qco"> {
let summary = "Convert QC dialect to QCO dialect.";

let description = [{
This pass converts all operations from the QC dialect to their equivalent
operations in the QCO dialect. It handles the transformation of qubit
references in QC to qubit values in QCO, ensuring that the semantics
of quantum operations are preserved during the conversion process.
}];

// Define dependent dialects
let dependentDialects = [
"mlir::qc::QCDialect",
"mlir::qco::QCODialect"
];
}
13 changes: 13 additions & 0 deletions mlir/include/mlir/Conversion/QCToQIR/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) 2023 - 2025 Chair for Design Automation, TUM
# Copyright (c) 2025 Munich Quantum Software Company GmbH
# All rights reserved.
#
# SPDX-License-Identifier: MIT
#
# Licensed under the MIT License

set(LLVM_TARGET_DEFINITIONS QCToQIR.td)
mlir_tablegen(QCToQIR.h.inc -gen-pass-decls -name QCToQIR)
add_public_tablegen_target(QCToQIRIncGen)

add_mlir_doc(QCToQIR MLIRQCToQIR Conversions/ -gen-pass-doc)
21 changes: 21 additions & 0 deletions mlir/include/mlir/Conversion/QCToQIR/QCToQIR.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2023 - 2025 Chair for Design Automation, TUM
* Copyright (c) 2025 Munich Quantum Software Company GmbH
* All rights reserved.
*
* SPDX-License-Identifier: MIT
*
* Licensed under the MIT License
*/

#pragma once

#include <mlir/Pass/Pass.h> // from @llvm-project

namespace mlir {
#define GEN_PASS_DECL_QCTOQIR
#include "mlir/Conversion/QCToQIR/QCToQIR.h.inc"

#define GEN_PASS_REGISTRATION
#include "mlir/Conversion/QCToQIR/QCToQIR.h.inc"
} // namespace mlir
Loading
Loading