Commit 5a12960
✨ Add OpenQASM-to-QC translation (#1780)
## Description
This is a rebased version of #1671 after #1671 was automatically closed
when #1751 was merged.
Original description by @J4MMlE:
> ## Description
>
> This PR adds a direct OpenQASM-to-QC translation that bypasses the
`qc::QuantumComputation`.
>
> The new flow reuses the existing parser and walks the AST directly to
emit QC dialect ops. Skipping `QuantumComputation` removes an
intermediate step and enables previously unsupported QASM3 features,
such as gate modifiers, classical computations, and control flow
structures.
>
> ### What works
>
> - All standard gates plus Qiskit-style MCX variants
> - Gate modifiers: `ctrl @`, `negctrl @`, `inv @`, nested combinations
> - Register declarations, qubit/bit allocation
> - Measure, reset, barrier
> - `if`/`else` over quantum statements
> - Hardware qubits convert to `qc.static`
> - Broadcasting (register-width gate calls)
>
> ### Current limitations
>
> - Gate parameters must be compile-time constants
> - `pow` modifier is unsupported (but will/should be once
[#1603](#1603) is
merged)
> - Layout pragmas are unsupported (they have no equivalent in `QC`)
## Checklist
- [x] The pull request only contains commits that are focused and
relevant to this change.
- [x] I have added appropriate tests that cover the new/changed
functionality.
- [x] ~~I have updated the documentation to reflect these changes.~~
- [x] I have added entries to the changelog for any noteworthy
additions, changes, fixes, or removals.
- [x] ~~I have added migration instructions to the upgrade guide (if
needed).~~
- [x] The changes follow the project's style guidelines and introduce no
new warnings.
- [x] The changes are fully tested and pass the CI checks.
- [x] I have reviewed my own code changes.
---------
Signed-off-by: Daniel Haag <121057143+denialhaag@users.noreply.github.com>
Co-authored-by: Anatol Bussejahn <anatol.bussejahn@tum.de>
Co-authored-by: Lukas Burgholzer <burgholzer@me.com>1 parent 89448cf commit 5a12960
12 files changed
Lines changed: 2714 additions & 48 deletions
File tree
- mlir
- include/mlir/Dialect/QC/Translation
- lib/Dialect/QC/Translation
- tools/mqt-cc
- unittests
- Dialect/QC/Translation
- programs
- test/circuits
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
601 | 601 | | |
602 | 602 | | |
603 | 603 | | |
| 604 | + | |
604 | 605 | | |
605 | 606 | | |
606 | 607 | | |
| |||
Lines changed: 45 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | | - | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
0 commit comments