add native QIR emitter and parser (LLVM IR, zero dependencies)#32
Merged
add native QIR emitter and parser (LLVM IR, zero dependencies)#32
Conversation
Introduce qir/ package with full QIR v2.0 support (opaque pointers, LLVM 16+). The emitter converts goqu circuits to spec-compliant LLVM IR text (.ll files) targeting both Base Profile and Adaptive Profile. The parser reads QIR back into goqu circuits with round-trip fidelity. - qir/emitter: Emit/EmitString API, 20+ gate intrinsic mappings, automatic decomposition of non-QIR gates via existing transpile infra, profile auto-detection via circuit.IsDynamic(), full control flow support (if/else, while, for, switch) for Adaptive Profile - qir/parser: Parse/ParseString/ParseFile API, line-based LLVM IR extraction, reverse gate mapping with cx/cnot and ccx/ccnot aliases, handles tail call, nonnull, writeonly/readonly attributes - qir/token: Token types for the LLVM IR subset lexer - Gate names aligned to PyQIR/Azure Quantum conventions (ccx__body, tuple_record_output, s__adj/t__adj) - 35 tests including round-trip verification
- gofmt: fix formatting in emitter.go, parser/gates.go, token/token.go - gocritic: rewrite if-else chain to switch in round-trip test - unparam: remove always-nil error returns from extractOperations and extractQubitIndices - gosec G304: sanitize file path with filepath.Clean in ParseFile
|
Codecov Report❌ Patch coverage is ❌ Your patch status has failed because the patch coverage (55.02%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #32 +/- ##
==========================================
- Coverage 72.21% 71.46% -0.75%
==========================================
Files 157 165 +8
Lines 16715 17491 +776
==========================================
+ Hits 12070 12500 +430
- Misses 3718 4036 +318
- Partials 927 955 +28 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce qir/ package with full QIR v2.0 support (opaque pointers, LLVM 16+). The emitter converts goqu circuits to spec-compliant LLVM IR text (.ll files) targeting both Base Profile and Adaptive Profile. The parser reads QIR back into goqu circuits with round-trip fidelity.