├── .clang-format ├── .clang-tidy ├── .github ├── CODEOWNERS ├── renos_updated.sh └── workflows │ ├── clang_tidy_review_comments.yml │ ├── lint.yml │ └── test.yml ├── .gitignore ├── .pre-commit-config.yaml ├── CMakeLists.txt ├── CONTRIBUTING.md ├── LICENSE.txt ├── README.md ├── check_format.sh ├── cmake ├── AddQSSC.cmake ├── AddWarnings.cmake ├── apple-clang.cmake ├── bundle_static_library.cmake ├── linux-gcc.cmake └── llvm-clang.cmake ├── conan ├── clang-tools-extra │ └── conanfile.py ├── llvm │ └── conanfile.py └── qasm │ ├── conandata.yml │ └── conanfile.py ├── conan_deps.sh ├── conandata.yml ├── conanfile.py ├── docs └── variable-lowering.rst ├── include ├── API │ ├── api.h │ └── errors.h ├── Arguments │ ├── Arguments.h │ ├── CMakeLists.txt │ └── Signature.h ├── CMakeLists.txt ├── Config.h.in ├── Config │ ├── CLIConfig.h │ ├── EnvVarConfig.h │ └── QSSConfig.h ├── Conversion │ ├── CMakeLists.txt │ ├── OQ3ToStandard │ │ └── OQ3ToStandard.h │ ├── QUIRToLLVM │ │ └── QUIRToLLVM.h │ ├── QUIRToPulse │ │ ├── LoadPulseCals.h │ │ └── QUIRToPulse.h │ └── QUIRToStandard │ │ ├── SwitchOpLowering.h │ │ ├── TypeConversion.h │ │ └── VariablesToGlobalMemRefConversion.h ├── Dialect │ ├── CMakeLists.txt │ ├── OQ3 │ │ ├── CMakeLists.txt │ │ ├── IR │ │ │ ├── CMakeLists.txt │ │ │ ├── OQ3AngleOps.td │ │ │ ├── OQ3ArithmeticOps.td │ │ │ ├── OQ3ArrayOps.td │ │ │ ├── OQ3Base.td │ │ │ ├── OQ3CBitOps.td │ │ │ ├── OQ3CastOps.td │ │ │ ├── OQ3Dialect.h │ │ │ ├── OQ3GateOps.td │ │ │ ├── OQ3Ops.h │ │ │ ├── OQ3Ops.td │ │ │ ├── OQ3Patterns.td │ │ │ ├── OQ3Types.h │ │ │ └── OQ3VariableOps.td │ │ └── Transforms │ │ │ ├── CMakeLists.txt │ │ │ ├── LimitCBitWidth.h │ │ │ └── Passes.h │ ├── Pulse │ │ ├── CMakeLists.txt │ │ ├── IR │ │ │ ├── CMakeLists.txt │ │ │ ├── Pulse.td │ │ │ ├── PulseAttributes.h │ │ │ ├── PulseAttributes.td │ │ │ ├── PulseDialect.h │ │ │ ├── PulseDialect.td │ │ │ ├── PulseInterfaces.h │ │ │ ├── PulseInterfaces.td │ │ │ ├── PulseOps.h │ │ │ ├── PulseOps.td │ │ │ ├── PulseTraits.h │ │ │ ├── PulseTraits.td │ │ │ ├── PulseTypes.h │ │ │ └── PulseTypes.td │ │ ├── Transforms │ │ │ ├── ClassicalOnlyDetection.h │ │ │ ├── InlineRegion.h │ │ │ ├── LabelPlayOpDurations.h │ │ │ ├── MergeDelays.h │ │ │ ├── Passes.h │ │ │ ├── RemoveUnusedArguments.h │ │ │ ├── SchedulePort.h │ │ │ ├── Scheduling.h │ │ │ └── SystemCreation.h │ │ └── Utils │ │ │ └── Utils.h │ ├── QCS │ │ ├── CMakeLists.txt │ │ ├── IR │ │ │ ├── CMakeLists.txt │ │ │ ├── QCSAttributes.h │ │ │ ├── QCSBase.td │ │ │ ├── QCSDialect.h │ │ │ ├── QCSOps.h │ │ │ ├── QCSOps.td │ │ │ └── QCSTypes.h │ │ └── Utils │ │ │ ├── CMakeLists.txt │ │ │ └── ParameterInitialValueAnalysis.h │ ├── QUIR │ │ ├── CMakeLists.txt │ │ ├── IR │ │ │ ├── CMakeLists.txt │ │ │ ├── QUIR.td │ │ │ ├── QUIRAttributes.h │ │ │ ├── QUIRAttributes.td │ │ │ ├── QUIRDialect.h │ │ │ ├── QUIRDialect.td │ │ │ ├── QUIREnums.h │ │ │ ├── QUIREnums.td │ │ │ ├── QUIRInterfaces.h │ │ │ ├── QUIRInterfaces.td │ │ │ ├── QUIROps.h │ │ │ ├── QUIROps.td │ │ │ ├── QUIRTestInterfaces.h │ │ │ ├── QUIRTraits.h │ │ │ ├── QUIRTraits.td │ │ │ ├── QUIRTypeConstraints.td │ │ │ ├── QUIRTypes.h │ │ │ └── QUIRTypes.td │ │ ├── Transforms │ │ │ ├── AddShotLoop.h │ │ │ ├── Analysis.h │ │ │ ├── AngleConversion.h │ │ │ ├── BreakReset.h │ │ │ ├── CMakeLists.txt │ │ │ ├── ConvertDurationUnits.h │ │ │ ├── ExtractCircuits.h │ │ │ ├── FunctionArgumentSpecialization.h │ │ │ ├── LoadElimination.h │ │ │ ├── MergeCircuitMeasures.h │ │ │ ├── MergeCircuits.h │ │ │ ├── MergeMeasures.h │ │ │ ├── MergeParallelResets.h │ │ │ ├── Passes.h │ │ │ ├── QUIRCircuitAnalysis.h │ │ │ ├── QuantumDecoration.h │ │ │ ├── RemoveQubitOperands.h │ │ │ ├── RemoveUnusedCircuits.h │ │ │ ├── ReorderCircuits.h │ │ │ ├── ReorderMeasurements.h │ │ │ ├── SubroutineCloning.h │ │ │ ├── UnusedVariable.h │ │ │ └── VariableElimination.h │ │ └── Utils │ │ │ └── Utils.h │ ├── RegisterDialects.h │ └── RegisterPasses.h ├── Frontend │ ├── CMakeLists.txt │ └── OpenQASM3 │ │ ├── BaseQASM3Visitor.h │ │ ├── CMakeLists.txt │ │ ├── OpenQASM3Frontend.h │ │ ├── PrintQASM3Visitor.h │ │ ├── QUIRGenQASM3Visitor.h │ │ └── QUIRVariableBuilder.h ├── HAL │ ├── Compile │ │ ├── TargetCompilationManager.h │ │ └── ThreadedCompilationManager.h │ ├── PassRegistration.h │ ├── SystemConfiguration.h │ ├── TargetOperationPass.h │ ├── TargetSystem.h │ ├── TargetSystemInfo.h │ └── TargetSystemRegistry.h ├── Payload │ ├── CMakeLists.txt │ ├── PatchableZipPayload.h │ ├── Payload.h │ └── PayloadRegistry.h ├── Plugin │ ├── PluginInfo.h │ └── PluginRegistry.h ├── QSSC.h ├── Support │ └── Pimpl.h ├── Utils │ ├── DebugIndent.h │ ├── LegacyInputConversion.h │ ├── OperationUtils.h │ └── SymbolCacheAnalysis.h └── qss-c │ └── Dialect │ ├── OQ3.h │ ├── Pulse.h │ ├── QCS.h │ └── QUIR.h ├── lib ├── API │ ├── CMakeLists.txt │ ├── api.cpp │ └── errors.cpp ├── Arguments │ ├── Arguments.cpp │ ├── CMakeLists.txt │ └── Signature.cpp ├── Bindings │ └── Python │ │ ├── DialectOQ3.cpp │ │ ├── DialectPulse.cpp │ │ ├── DialectQCS.cpp │ │ └── DialectQUIR.cpp ├── CAPI │ ├── CMakeLists.txt │ └── Dialect │ │ ├── CMakeLists.txt │ │ ├── OQ3.cpp │ │ ├── Pulse.cpp │ │ ├── QCS.cpp │ │ └── QUIR.cpp ├── CMakeLists.txt ├── Config │ ├── CLIConfig.cpp │ ├── CMakeLists.txt │ ├── EnvVarConfig.cpp │ └── QSSConfig.cpp ├── Conversion │ ├── CMakeLists.txt │ ├── OQ3ToStandard │ │ ├── CMakeLists.txt │ │ └── OQ3ToStandard.cpp │ ├── QUIRToPulse │ │ ├── CMakeLists.txt │ │ ├── LoadPulseCals.cpp │ │ └── QUIRToPulse.cpp │ └── QUIRToStandard │ │ ├── CMakeLists.txt │ │ ├── SwitchOpLowering.cpp │ │ ├── TypeConversion.cpp │ │ └── VariablesToGlobalMemRefConversion.cpp ├── Dialect │ ├── CMakeLists.txt │ ├── OQ3 │ │ ├── CMakeLists.txt │ │ ├── IR │ │ │ ├── CMakeLists.txt │ │ │ ├── OQ3Dialect.cpp │ │ │ ├── OQ3Ops.cpp │ │ │ └── OQ3Patterns.cpp │ │ └── Transforms │ │ │ ├── CMakeLists.txt │ │ │ ├── LimitCBitWidth.cpp │ │ │ └── Passes.cpp │ ├── Pulse │ │ ├── CMakeLists.txt │ │ ├── IR │ │ │ ├── CMakeLists.txt │ │ │ ├── PulseAttributes.cpp │ │ │ ├── PulseDialect.cpp │ │ │ ├── PulseInterfaces.cpp │ │ │ └── PulseOps.cpp │ │ ├── Transforms │ │ │ ├── CMakeLists.txt │ │ │ ├── ClassicalOnlyDetection.cpp │ │ │ ├── InlineRegion.cpp │ │ │ ├── LabelPlayOpDurations.cpp │ │ │ ├── MergeDelays.cpp │ │ │ ├── Passes.cpp │ │ │ ├── RemoveUnusedArguments.cpp │ │ │ ├── SchedulePort.cpp │ │ │ └── Scheduling.cpp │ │ └── Utils │ │ │ ├── CMakeLists.txt │ │ │ └── Utils.cpp │ ├── QCS │ │ ├── CMakeLists.txt │ │ ├── IR │ │ │ ├── CMakeLists.txt │ │ │ ├── QCSDialect.cpp │ │ │ └── QCSOps.cpp │ │ └── Utils │ │ │ ├── CMakeLists.txt │ │ │ └── ParameterInitialValueAnalysis.cpp │ └── QUIR │ │ ├── CMakeLists.txt │ │ ├── IR │ │ ├── CMakeLists.txt │ │ ├── QUIRAttributes.cpp │ │ ├── QUIRDialect.cpp │ │ ├── QUIRInterfaces.cpp │ │ ├── QUIROps.cpp │ │ └── QUIRTestInterfaces.cpp │ │ ├── Transforms │ │ ├── AddShotLoop.cpp │ │ ├── Analysis.cpp │ │ ├── AngleConversion.cpp │ │ ├── BreakReset.cpp │ │ ├── CMakeLists.txt │ │ ├── ConvertDurationUnits.cpp │ │ ├── ExtractCircuits.cpp │ │ ├── FunctionArgumentSpecialization.cpp │ │ ├── LoadElimination.cpp │ │ ├── MergeCircuitMeasures.cpp │ │ ├── MergeCircuits.cpp │ │ ├── MergeMeasures.cpp │ │ ├── MergeParallelResets.cpp │ │ ├── Passes.cpp │ │ ├── QUIRCircuitAnalysis.cpp │ │ ├── QuantumDecoration.cpp │ │ ├── RemoveQubitOperands.cpp │ │ ├── RemoveUnusedCircuits.cpp │ │ ├── ReorderCircuits.cpp │ │ ├── ReorderMeasurements.cpp │ │ ├── SubroutineCloning.cpp │ │ ├── UnusedVariable.cpp │ │ └── VariableElimination.cpp │ │ └── Utils │ │ ├── CMakeLists.txt │ │ └── Utils.cpp ├── Frontend │ ├── CMakeLists.txt │ └── OpenQASM3 │ │ ├── BaseQASM3Visitor.cpp │ │ ├── CMakeLists.txt │ │ ├── OpenQASM3Frontend.cpp │ │ ├── PrintQASM3Visitor.cpp │ │ ├── QUIRGenQASM3Visitor.cpp │ │ └── QUIRVariableBuilder.cpp ├── HAL │ ├── CMakeLists.txt │ ├── Compile │ │ ├── CMakeLists.txt │ │ ├── TargetCompilationManager.cpp │ │ └── ThreadedCompilationManager.cpp │ ├── PassRegistration.cpp │ ├── SystemConfiguration.cpp │ ├── TargetSystem.cpp │ ├── TargetSystemInfo.cpp │ ├── TargetSystemRegistry.cpp │ └── Targets.inc.in ├── Payload │ ├── CMakeLists.txt │ ├── Payload.cpp │ ├── Payloads.inc.in │ └── ZipPayload │ │ ├── CMakeLists.txt │ │ ├── PatchableZipPayload.cpp │ │ ├── Payload.inc │ │ ├── ZipPayload.cpp │ │ ├── ZipPayload.h │ │ ├── ZipUtil.cpp │ │ └── ZipUtil.h ├── QSSC.cpp └── Utils │ ├── CMakeLists.txt │ ├── DebugIndent.cpp │ └── LegacyInputConversion.cpp ├── licenses └── APACHE2.0LLVM.txt ├── python_lib ├── CMakeLists.txt ├── MANIFEST.in ├── README.md ├── dummy.c ├── pyproject.toml.in ├── qss_compiler │ ├── CMakeLists.txt │ ├── __init__.py │ ├── compile.py │ ├── examples │ │ ├── SequenceEx.mlir │ │ ├── SequenceEx.py │ │ ├── TestOps.mlir │ │ ├── TestOps.py │ │ ├── parse.py │ │ ├── pulse.py │ │ └── test_out.mlir │ ├── exceptions.py │ ├── lib.cpp │ ├── lib_enums.cpp │ ├── lib_enums.h │ ├── link.py │ └── mlir │ │ └── dialects │ │ ├── OQ3.pyi │ │ ├── OQ3.td │ │ ├── Pulse.td │ │ ├── QCS.pyi │ │ ├── QCS.td │ │ ├── QUIR.td │ │ ├── _oq3_ops_ext.py │ │ ├── _pulse_ops_ext.py │ │ ├── _qcs_ops_ext.py │ │ ├── _quir_ops_ext.py │ │ ├── oq3.py │ │ ├── pulse.py │ │ ├── pulse.pyi │ │ ├── qcs.py │ │ ├── quir.py │ │ └── quir.pyi ├── setup.cfg └── setup.py ├── qssc-activate.in ├── releasenotes ├── config.yaml └── notes │ ├── add-0f909e339cf09ae9.yaml │ ├── add-bitnot-support-7ad288e5a87b7302.yaml │ ├── add-bytecode-support-c8c11ab44f93c659.yaml │ ├── add-compile-warnings-9e80ff424ff16342.yaml │ ├── add-contribution-guidelines-76301ef50bcf53ae.yaml │ ├── add-extract-circuits-pass-72576158242077c6.yaml │ ├── add-handling-for-two-qubit-gate-error-8a73c93f9cb47759.yaml │ ├── add-label-playop-duration-pass-2c79b1506b8b5854.yaml │ ├── add-max-threads-4073cc0b39df6d68.yaml │ ├── add-merge-circuit-measures-e2b80378bf659793.yaml │ ├── add-pre-commit-d2fca33ddaf13b35.yaml │ ├── add-qssc-error-reporting-mechanisms-82fa32e30d30ccce.yaml │ ├── add-releasenotes-895d8791ff596b6d.yaml │ ├── add-timing-manager-support-9de5e2407fc95330.yaml │ ├── add-unsupported-openqasm3-input-a584bb990cd9c9ff.yaml │ ├── add_qeqem_output_type-54d1bdeff9f3b305.yaml │ ├── control-system-resources-exceeded-error-d2a2c15c52fa02dd.yaml │ ├── default-only-switch-64bb951256d7d2b5.yaml │ ├── dialect-python-bindings-ab57b480118d6632.yaml │ ├── link-threading-d295374d01595205.yaml │ ├── mixframe-scheduling-9f2a5e5ba922e6a0.yaml │ ├── optimize-greedy-rewrites-b042d4e824642f9a.yaml │ ├── parallel-reset-bottom-up-traversal-0ad69d49e9d6e6e1.yaml │ ├── refactor_bind-ab3c07883604767b.yaml │ ├── remove-function-localization-d5caa312fcabb7b3.yaml │ ├── soo-ER-raise-OpenQASM3ParseFailure-7db973ddd38ece7e.yaml │ ├── support-arith-math-operations-f2f9280d24366383.yaml │ ├── support-barrier-in-quir-to-pulse-5eeadde1f85f0c0e.yaml │ ├── symbol-cache-analysis-e135ccc3fe625e2e.yaml │ ├── symbol-cache-use-densemap-c178e05e59c41bbe.yaml │ ├── test-overlap-all-5d170626357867d6.yaml │ ├── update-parameter-handling-cfa04a0bd7250401.yaml │ ├── user-error-updates-3fe6706fbf8ffab8.yaml │ └── verbosity-added-215754a25363b046.yaml ├── requirements-dev.txt ├── targets └── systems │ └── mock │ ├── CMakeLists.txt │ ├── Conversion │ └── QUIRToStandard │ │ ├── QUIRToStandard.cpp │ │ └── QUIRToStandard.h │ ├── MockTarget.cpp │ ├── MockTarget.h │ ├── MockUtils.cpp │ ├── MockUtils.h │ ├── Target.inc │ ├── Transforms │ ├── QubitLocalization.cpp │ └── QubitLocalization.h │ └── test │ ├── CMakeLists.txt │ ├── lit.local.cfg.py │ ├── python_lib │ ├── conftest.py │ ├── pytest.ini │ └── test_compile_mock.py │ ├── static │ ├── Conversion │ │ └── QUIRToStd │ │ │ └── llvmgen.mlir │ ├── Transforms │ │ └── qubit-localization.mlir │ └── integration │ │ ├── mlir │ │ ├── bell-v0.mlir │ │ ├── mlir-timing.mlir │ │ └── scf-iterative-phase-estimation.mlir │ │ └── openqasm3 │ │ ├── bell-v0.qasm │ │ ├── example.qasm │ │ └── reset-v0.qasm │ └── test.cfg ├── test ├── CMakeLists.txt ├── Config │ └── test-config.tst ├── Conversion │ ├── QUIRToPulse │ │ ├── .gitkeep │ │ └── convert-quir-to-pulse.mlir │ └── QUIRToStandard │ │ └── .gitkeep ├── Dialect │ ├── Arith │ │ └── arith-ops-canonicalize.mlir │ ├── Math │ │ └── math-ops-canonicalize.mlir │ ├── OQ3 │ │ ├── IR │ │ │ ├── fold-cbit-extractbit.mlir │ │ │ ├── math.mlir │ │ │ └── ops.mlir │ │ ├── Transforms │ │ │ └── limit-cbit-width.mlir │ │ └── integration │ │ │ └── openqasm3 │ │ │ └── cbit-width.qasm │ ├── Pulse │ │ ├── IR │ │ │ ├── ops-error-testing.mlir │ │ │ └── ops.mlir │ │ └── Transforms │ │ │ ├── classical-only-detection.mlir │ │ │ ├── merge-delay.mlir │ │ │ ├── pulse-inline.mlir │ │ │ ├── pulse-prune.mlir │ │ │ ├── pulse-slice.mlir │ │ │ ├── remove-unused-arguments.mlir │ │ │ ├── schedule-port-acquire.mlir │ │ │ └── schedule-port-drive.mlir │ ├── QCS │ │ └── Utils │ │ │ └── parameter-initial-value-analysis.mlir │ └── QUIR │ │ ├── IR │ │ ├── angle-cmp-ops.mlir │ │ ├── canonicalization.mlir │ │ ├── control-flow.mlir │ │ ├── declarations.mlir │ │ ├── error-testing.mlir │ │ ├── gate-tests.mlir │ │ ├── invalid.mlir │ │ ├── ops-error-testing.mlir │ │ ├── ops.mlir │ │ ├── qubit-op-interface.mlir │ │ ├── test.mlir │ │ └── verify-circuit.mlir │ │ ├── Transforms │ │ ├── add-shot-loop.mlir │ │ ├── arg-specialization0.mlir │ │ ├── arg-specialization1.mlir │ │ ├── arg-specialization2.mlir │ │ ├── break-reset-gates-in-circuit.mlir │ │ ├── break-reset-multiqubit.mlir │ │ ├── break-reset-nested.mlir │ │ ├── break-reset.mlir │ │ ├── canonicalize-assign-cbit-bit.mlir │ │ ├── canonicalize-bit-eqeqone.mlir │ │ ├── classical-only-detection.mlir │ │ ├── convert-duration-units.mlir │ │ ├── convert-quir-angles.mlir │ │ ├── extract-circuits.mlir │ │ ├── for-localization.mlir │ │ ├── load-elimination.mlir │ │ ├── load-elimination2.mlir │ │ ├── merge-circuit-issue-1833.mlir │ │ ├── merge-circuit-measures.mlir │ │ ├── merge-circuits.mlir │ │ ├── merge-measurements-circuits.mlir │ │ ├── merge-measures.mlir │ │ ├── merge-resets.mlir │ │ ├── merge-resets2.mlir │ │ ├── quantum-decoration.mlir │ │ ├── remove-unused-circuits.mlir │ │ ├── remove-unused-variables.mlir │ │ ├── reorder-circuits.mlir │ │ ├── reorder-measurements-2.mlir │ │ ├── reorder-measurements-issue-1730.mlir │ │ ├── reorder-measurements-issue-910-2.mlir │ │ ├── reorder-measurements-issue-910.mlir │ │ ├── reorder-measurements-issue-921.mlir │ │ ├── reorder-measurements.mlir │ │ ├── subroutine-cloning.mlir │ │ ├── variable-elimination1.mlir │ │ ├── variable-elimination2.mlir │ │ └── variable-elimination3.mlir │ │ └── integration │ │ ├── iterative-phase-estimation.mlir │ │ ├── measure-reset.mlir │ │ ├── qasm-bell-v0.mlir │ │ ├── qasm-bell-v1.mlir │ │ ├── qasm-bell-v2.mlir │ │ ├── qasm-reset-v0.mlir │ │ ├── qasm-reset-v0b.mlir │ │ ├── qasm-reset-v1.mlir │ │ ├── qasm-reset-v1b.mlir │ │ └── scf-teleportation.mlir ├── Frontend │ └── OpenQASM3 │ │ ├── angles.qasm │ │ ├── arith-ops.qasm │ │ ├── assign.qasm │ │ ├── barrier.qasm │ │ ├── bell-v0.qasm │ │ ├── bell-v1.qasm │ │ ├── bit-int-compare.qasm │ │ ├── bitindices.qasm │ │ ├── bitops-reg.qasm │ │ ├── bitops.qasm │ │ ├── bitops2.qasm │ │ ├── bitstring-init.qasm │ │ ├── bool_conditional_assign.qasm │ │ ├── booleans.qasm │ │ ├── builtin-constants.qasm │ │ ├── cast-op.qasm │ │ ├── cbit.qasm │ │ ├── classical-subroutines.qasm │ │ ├── compare-bits.qasm │ │ ├── compare-bool.qasm │ │ ├── complex.qasm │ │ ├── conditionals.qasm │ │ ├── delay-inside-controlflow.qasm │ │ ├── delay.qasm │ │ ├── diagnostics-parse-error.qasm │ │ ├── diagnostics-unsupported-error.qasm │ │ ├── extern.qasm │ │ ├── floats.qasm │ │ ├── for-loop.qasm │ │ ├── for-loop2.qasm │ │ ├── for-loop3.qasm │ │ ├── gate.qasm │ │ ├── gates-issue-655-2.qasm │ │ ├── gates-issue-655.qasm │ │ ├── handle-ints.qasm │ │ ├── input-output-variables.qasm │ │ ├── input-parameters-errors.qasm │ │ ├── input-parameters-if.qasm │ │ ├── input-parameters-while.qasm │ │ ├── input-parameters.qasm │ │ ├── ints.qasm │ │ ├── ipe-v0.qasm │ │ ├── ipe-v1.qasm │ │ ├── logical-bool-op.qasm │ │ ├── main.qasm │ │ ├── math-ops.qasm │ │ ├── measure-multi-clregs.qasm │ │ ├── measure.qasm │ │ ├── mixed-param-subroutines.qasm │ │ ├── multi-param-gatedef.qasm │ │ ├── multi-qubit-gatedef.qasm │ │ ├── nested-gatecalls.qasm │ │ ├── nested-if.qasm │ │ ├── not-equal.qasm │ │ ├── qasm-version-sring.qasm │ │ ├── quantum-subroutines.qasm │ │ ├── qubit.qasm │ │ ├── reset-v0.qasm │ │ ├── reset-v1.qasm │ │ ├── return.qasm │ │ ├── rz-issue-655.qasm │ │ ├── stretch.qasm │ │ ├── switch-1.qasm │ │ ├── switch-2.qasm │ │ ├── switch-default-only.qasm3 │ │ ├── switch-no-default.qasm │ │ ├── teleport.qasm │ │ ├── test-include.inc │ │ ├── test-include.qasm │ │ ├── while-1.qasm │ │ ├── while-2.qasm │ │ └── while-3.qasm ├── IO │ ├── bytecode.mlir │ └── none.mlir ├── lit.cfg.py ├── lit.site.cfg.py.in ├── python_lib │ ├── conftest.py │ ├── pytest.ini │ ├── test_compile.py │ ├── test_link.py │ └── test_python_bindings.py └── unittest │ ├── CMakeLists.txt │ ├── HAL │ └── TargetSystemRegistryTest.cpp │ ├── Payload │ └── PayloadRegistryTest.cpp │ └── quir-dialect.cpp └── tools ├── CMakeLists.txt ├── qss-compiler ├── CMakeLists.txt └── qss-compiler.cpp └── qss-opt ├── CMakeLists.txt └── qss-opt.cpp /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | BasedOnStyle: LLVM 3 | --- 4 | Language: Cpp 5 | AlwaysBreakTemplateDeclarations: Yes 6 | RemoveBracesLLVM: Yes 7 | --- 8 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # This file defines the set of people responsible for different sections of the 2 | # codebase 3 | # 4 | # Being listed as a code owner on a section here means that user is empowered 5 | # to approve and merge pull requests for that section of code. It also comes 6 | # with an expected responsibility to review and maintain those subsections of 7 | # the repository. 8 | # 9 | # A PR can be merged when approved by at least one codeowner. For PRs that touch 10 | # more than one section with non-overlapping codeowners more than one codeowner 11 | # may be required to approve a PR. 12 | # 13 | # However, every contributor to the project can (and should!) review open PRs. This 14 | # file is just about outlining responsibility for maintainership and final 15 | # review/merging of PRs in different subsections of the repository. 16 | 17 | # Global rule, unless specialized by a later one 18 | * @openqasm/qe-maintainers 19 | 20 | # folders (also their corresponding tests) 21 | 22 | # Override the release notes directories to have _no_ code owners, so any review 23 | # from somebody with write access is acceptable. 24 | /releasenotes/notes 25 | -------------------------------------------------------------------------------- /.github/renos_updated.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This script makes sure a reno has been updated in the PR. 3 | 4 | reno lint 5 | 6 | CHANGED_FILES=$(git diff --name-only origin/main $GITHUB_SHA) 7 | for file in $CHANGED_FILES 8 | do 9 | root=$(echo "./$file" | awk -F/ '{print FS $2}' | cut -c2-) 10 | if [ "$root" = "releasenotes" ]; then 11 | exit 0; 12 | fi 13 | done 14 | 15 | echo Please add or update a release note in ./releasenotes >&2 16 | exit 1 17 | -------------------------------------------------------------------------------- /.github/workflows/clang_tidy_review_comments.yml: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2024. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | # Workaround CI permissions for forks 14 | # https://github.com/ZedThree/clang-tidy-review?tab=readme-ov-file#usage-in-fork-environments-split-workflow 15 | name: Post clang-tidy review comments 16 | 17 | on: 18 | workflow_run: 19 | # The name field of the lint action 20 | # Defined in lint.yml workflow 21 | workflows: 22 | - Static Checks 23 | types: 24 | - completed 25 | 26 | jobs: 27 | post-clang-tidy: 28 | name: Post clang-tidy review comments 29 | runs-on: ubuntu-latest 30 | steps: 31 | - uses: ZedThree/clang-tidy-review/post@v0.14.0 32 | # lgtm_comment_body, max_comments, and annotations need to be set on the posting workflow in a split setup 33 | with: 34 | # adjust options as necessary 35 | lgtm_comment_body: '' 36 | annotations: false 37 | max_comments: 10 38 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/pre-commit/pre-commit-hooks 3 | rev: v4.1.0 4 | hooks: 5 | - id: no-commit-to-branch 6 | stages: [commit] 7 | args: [--branch, main, --pattern, release/.*, --pattern, .*/release/.*] 8 | - id: check-json 9 | stages: [commit] 10 | - id: end-of-file-fixer 11 | stages: [commit] 12 | exclude: '.+(\.s[ql][23])$' 13 | - id: trailing-whitespace 14 | stages: [commit] 15 | args: [--markdown-linebreak-ext=md] 16 | exclude: '.+(\.s[ql][23])$' 17 | - id: check-merge-conflict 18 | stages: [commit] 19 | - id: debug-statements 20 | stages: [commit] 21 | - repo: https://github.com/psf/black 22 | rev: 22.3.0 23 | hooks: 24 | - id: black 25 | stages: [commit] 26 | args: 27 | - "-l 100" 28 | - repo: https://github.com/pre-commit/mirrors-clang-format 29 | rev: v17.0.5 30 | hooks: 31 | - id: clang-format 32 | stages: [commit] 33 | args: 34 | - "--style=file:.clang-format" 35 | - repo: https://github.com/PyCQA/flake8.git 36 | rev: 4.0.1 37 | hooks: 38 | - id: flake8 39 | stages: [commit] 40 | args: 41 | - "--max-line-length=100" 42 | - "--extend-ignore=W503" 43 | -------------------------------------------------------------------------------- /check_format.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # (C) Copyright IBM 2023. 4 | # 5 | # This code is part of Qiskit. 6 | # 7 | # This code is licensed under the Apache License, Version 2.0 with LLVM 8 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | # file in the root directory of this source tree. 10 | # 11 | # Any modifications or derivative works of this code must retain this 12 | # copyright notice, and modified files need to carry a notice indicating 13 | # that they have been altered from the originals. 14 | 15 | # Expects first argument as path to clang-format binary 16 | # following arguments as paths to files to format 17 | 18 | clang_format_bin=$1 19 | files="${@:2}" 20 | 21 | diff <(cat ${files}) <(${clang_format_bin} --style=file ${files}) 22 | -------------------------------------------------------------------------------- /cmake/linux-gcc.cmake: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | set (CXX_FLAGS 14 | -std=c++17 15 | 16 | -fno-strict-aliasing 17 | -fexceptions 18 | -fno-omit-frame-pointer 19 | -fno-stack-protector 20 | 21 | -pthread 22 | 23 | -Werror 24 | ) 25 | list (JOIN CXX_FLAGS " " CXX_FLAGS_STR) 26 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_FLAGS_STR}") 27 | 28 | # Google Sanitizers ------------------------------------------------------------ 29 | if(ENABLE_ADDRESS_SANITIZER) 30 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") 31 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=leak") 32 | endif() 33 | 34 | if(ENABLE_UNDEFINED_SANITIZER) 35 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined") 36 | endif() 37 | 38 | if(ENABLE_THREAD_SANITIZER) 39 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread") 40 | endif() 41 | 42 | set (CMAKE_CXX_FLAGS_DEBUG "-g3 -O0") 43 | set (CMAKE_CXX_FLAGS_RELEASE "-g -O2 -DNOVERIFY") 44 | 45 | # set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold") 46 | set (CMAKE_CXX_STANDARD_LIBRARIES "-lstdc++fs -lpthread") 47 | -------------------------------------------------------------------------------- /conan/qasm/conandata.yml: -------------------------------------------------------------------------------- 1 | sources: 2 | hash: "ec7731bf645240a597cd9ebb2c395b114f155ed2" 3 | requirements: 4 | - "gmp/6.3.0" 5 | - "mpfr/4.1.0" 6 | - "mpc/1.3.1" 7 | - "bison/3.8.2" 8 | - "flex/2.6.4" 9 | build_requirements: 10 | - "bison/3.8.2" 11 | - "flex/2.6.4" 12 | -------------------------------------------------------------------------------- /conan_deps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # (C) Copyright IBM 2023. 4 | # 5 | # This code is part of Qiskit. 6 | # 7 | # This code is licensed under the Apache License, Version 2.0 with LLVM 8 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | # file in the root directory of this source tree. 10 | # 11 | # Any modifications or derivative works of this code must retain this 12 | # copyright notice, and modified files need to carry a notice indicating 13 | # that they have been altered from the originals. 14 | 15 | conan export ./conan/qasm qss/stable 16 | conan export ./conan/llvm/conanfile.py @ 17 | conan export ./conan/clang-tools-extra/conanfile.py @ 18 | -------------------------------------------------------------------------------- /conandata.yml: -------------------------------------------------------------------------------- 1 | requirements: 2 | - gtest/1.11.0 3 | - libzip/1.10.1 4 | - zlib/1.2.13 5 | - zstd/1.5.5 6 | - nlohmann_json/3.9.1 7 | - pybind11/2.11.1 8 | - clang-tools-extra/17.0.5-0@ 9 | - llvm/17.0.5-0@ 10 | - qasm/0.3.3@qss/stable 11 | -------------------------------------------------------------------------------- /include/Arguments/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | -------------------------------------------------------------------------------- /include/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_subdirectory(Conversion) 14 | add_subdirectory(Dialect) 15 | add_subdirectory(Frontend) 16 | add_subdirectory(Arguments) 17 | add_subdirectory(Payload) 18 | -------------------------------------------------------------------------------- /include/Config.h.in: -------------------------------------------------------------------------------- 1 | //===- config.h ------------------------------------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | // 17 | // configuration variables passed by build system 18 | // 19 | //===----------------------------------------------------------------------===// 20 | 21 | #ifndef QSSC_CONFIG_H 22 | #define QSSC_CONFIG_H 23 | 24 | #define QSSC_VERSION_MAJOR "${QSSC_VERSION_MAJOR}" 25 | #define QSSC_VERSION_MINOR "${QSSC_VERSION_MINOR}" 26 | #define QSSC_VERSION_PATCH "${QSSC_VERSION_PATCH}" 27 | #define QSSC_VERSION "${QSSC_VERSION}" 28 | 29 | #define QSSC_RESOURCES_INSTALL_PREFIX "${QSSC_RESOURCES_INSTALL_PREFIX}" 30 | 31 | #endif // QSSC_CONFIG_H 32 | -------------------------------------------------------------------------------- /include/Conversion/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | -------------------------------------------------------------------------------- /include/Conversion/QUIRToStandard/SwitchOpLowering.h: -------------------------------------------------------------------------------- 1 | //===- SwitchOpLowering.h ---------------------------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// \file 18 | /// This file exposes patterns for lowering quir.switch. 19 | /// 20 | //===----------------------------------------------------------------------===// 21 | 22 | #ifndef QUIRTOSTD_SWITCHOPLOWERING_H 23 | #define QUIRTOSTD_SWITCHOPLOWERING_H 24 | 25 | namespace mlir::quir { 26 | 27 | void populateSwitchOpLoweringPatterns(RewritePatternSet &patterns); 28 | 29 | }; // namespace mlir::quir 30 | 31 | #endif // QUIRTOSTD_SWITCHOPLOWERING_H 32 | -------------------------------------------------------------------------------- /include/Conversion/QUIRToStandard/VariablesToGlobalMemRefConversion.h: -------------------------------------------------------------------------------- 1 | //===- VariablesToGobalMemRefConversion.h -----------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// \file 18 | /// This file exposes patterns for lowering QUIR variable declarations, 19 | /// variable use, and variable assignments to std. For that purpose, it 20 | /// introduces a global variable for each QUIR variable declaration via a 21 | /// GlobalMemRef. All variable references and assignments are converted into 22 | /// load and store op against the global memrefs. 23 | /// 24 | //===----------------------------------------------------------------------===// 25 | 26 | #include "mlir/IR/BuiltinTypes.h" 27 | #include "mlir/Transforms/DialectConversion.h" 28 | 29 | #include "Dialect/QUIR/IR/QUIRTypes.h" 30 | 31 | namespace mlir::quir { 32 | 33 | void populateVariableToGlobalMemRefConversionPatterns( 34 | RewritePatternSet &patterns, mlir::TypeConverter &typeConverter, 35 | bool externalizeOutputVariables); 36 | 37 | }; // namespace mlir::quir 38 | -------------------------------------------------------------------------------- /include/Dialect/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_subdirectory(OQ3) 14 | add_subdirectory(QUIR) 15 | add_subdirectory(Pulse) 16 | add_subdirectory(QCS) 17 | -------------------------------------------------------------------------------- /include/Dialect/OQ3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # Any modifications or derivative works of this code must retain this 4 | # copyright notice, and modified files need to carry a notice indicating 5 | # that they have been altered from the originals. 6 | 7 | add_subdirectory(IR) 8 | add_subdirectory(Transforms) 9 | -------------------------------------------------------------------------------- /include/Dialect/OQ3/IR/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # Any modifications or derivative works of this code must retain this 4 | # copyright notice, and modified files need to carry a notice indicating 5 | # that they have been altered from the originals. 6 | 7 | add_mlir_dialect(OQ3Ops oq3) 8 | add_mlir_doc(OQ3Ops OQ3Ops generated/Dialect/OQ3/ -gen-dialect-doc -dialect=oq3) 9 | 10 | set(LLVM_TARGET_DEFINITIONS OQ3Dialect.td) 11 | 12 | set(LLVM_TARGET_DEFINITIONS OQ3Patterns.td) 13 | mlir_tablegen(OQ3Patterns.inc -gen-rewriters) 14 | add_public_tablegen_target(MLIROQ3PatternsIncGen) 15 | -------------------------------------------------------------------------------- /include/Dialect/OQ3/IR/OQ3ArithmeticOps.td: -------------------------------------------------------------------------------- 1 | //===- OQ3ArithmeticOps.td - OpenQASM 3 arithmetic ops -----*- tablegen -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // Any modifications or derivative works of this code must retain this 6 | // copyright notice, and modified files need to carry a notice indicating 7 | // that they have been altered from the originals. 8 | // 9 | //===----------------------------------------------------------------------===// 10 | /// 11 | /// This is the definition file for the OpenQASM 3 dialect arithmetic 12 | /// operations. 13 | /// 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef OQ3_ARITHMETIC_OPS 17 | #define OQ3_ARITHMETIC_OPS 18 | 19 | include "mlir/Interfaces/InferTypeOpInterface.td" 20 | 21 | class OQ3_ArithmeticUnaryOp traits = []> : 22 | OQ3_UnaryOp; 24 | 25 | class OQ3_ArithmeticBinaryOp traits = []> : 26 | OQ3_BinaryOp { 29 | let arguments = (ins AnyClassical:$lhs, AnyClassical:$rhs); 30 | let results = (outs AnyClassical:$result); 31 | let assemblyFormat = [{ 32 | attr-dict $lhs `,` $rhs `:` `(` type($lhs) `,` type($rhs) `)` `->` type($result) 33 | }]; 34 | } 35 | 36 | #endif // OQ3_ARITHMETIC_OPS 37 | -------------------------------------------------------------------------------- /include/Dialect/OQ3/IR/OQ3CastOps.td: -------------------------------------------------------------------------------- 1 | //===- OQ3CastOps.td - OpenQASM 3 dialect cast ops ---------*- tablegen -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // Any modifications or derivative works of this code must retain this 6 | // copyright notice, and modified files need to carry a notice indicating 7 | // that they have been altered from the originals. 8 | // 9 | //===----------------------------------------------------------------------===// 10 | /// 11 | /// This is the operation definition file for OpenQASM 3 cast operations. 12 | /// 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef OQ3_CAST_OPS 16 | #define OQ3_CAST_OPS 17 | 18 | def OQ3_CastOp : OQ3_Op<"cast", [Pure]> { 19 | let summary = "Cast between classical types"; 20 | let description = [{ 21 | The `oq3.cast` operation represents a cast between different classical types, including non-OQ3 types. 22 | 23 | Example: 24 | ```mlir 25 | %ang1 = "oq3.cast"(%creg) : (memref<10xi1>) -> !quir.angle<20> 26 | ``` 27 | }]; 28 | 29 | let arguments = (ins AnyClassical:$arg); 30 | let results = (outs AnyClassical:$out); 31 | 32 | let hasCanonicalizer = 1; 33 | } 34 | 35 | #endif // OQ3_CAST_OPS 36 | -------------------------------------------------------------------------------- /include/Dialect/OQ3/IR/OQ3Dialect.h: -------------------------------------------------------------------------------- 1 | //===- OQ3Dialect.h - OpenQASM 3 dialect ------------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // Any modifications or derivative works of this code must retain this 6 | // copyright notice, and modified files need to carry a notice indicating 7 | // that they have been altered from the originals. 8 | // 9 | //===----------------------------------------------------------------------===// 10 | /// 11 | /// This file declares the OpenQASM 3 dialect in MLIR. 12 | /// 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef DIALECT_OQ3_OQ3DIALECT_H_ 16 | #define DIALECT_OQ3_OQ3DIALECT_H_ 17 | 18 | #include "mlir/Dialect/Arith/IR/Arith.h" 19 | #include "mlir/Dialect/LLVMIR/LLVMDialect.h" 20 | #include "mlir/Dialect/Math/IR/Math.h" 21 | #include "mlir/Dialect/SCF/IR/SCF.h" 22 | #include "mlir/IR/BuiltinOps.h" 23 | #include "mlir/IR/Dialect.h" 24 | 25 | #include "Dialect/OQ3/IR/OQ3OpsDialect.h.inc" 26 | 27 | #endif // DIALECT_OQ3_OQ3DIALECT_H_ 28 | -------------------------------------------------------------------------------- /include/Dialect/OQ3/IR/OQ3GateOps.td: -------------------------------------------------------------------------------- 1 | //===- OQ3GateOps.td - OpenQASM 3 dialect gate ops ---------*- tablegen -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // Any modifications or derivative works of this code must retain this 6 | // copyright notice, and modified files need to carry a notice indicating 7 | // that they have been altered from the originals. 8 | // 9 | //===----------------------------------------------------------------------===// 10 | /// 11 | /// This is the operation definition file for OpenQASM 3 gate operations. 12 | /// 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef OQ3_GATE_OPS 16 | #define OQ3_GATE_OPS 17 | 18 | //===----------------------------------------------------------------------===// 19 | // Stretch ops 20 | //===----------------------------------------------------------------------===// 21 | 22 | def OQ3_DeclareStretchOp : OQ3_Op<"declare_stretch", [Pure]> { 23 | let summary = "Declare a new stretch."; 24 | let description = [{ 25 | The `oq3.declare_stretch` operation creates a new QUIR `Stretch` type, representing an unknown duration of time. 26 | 27 | Example: 28 | ```mlir 29 | %dur = "oq3.declare_stretch"() : () -> !quir.stretch 30 | ``` 31 | }]; 32 | 33 | let results = (outs AnyStretch:$out); 34 | 35 | let assemblyFormat = [{ 36 | attr-dict `:` type($out) 37 | }]; 38 | } 39 | 40 | #endif // OQ3_GATE_OPS 41 | -------------------------------------------------------------------------------- /include/Dialect/OQ3/IR/OQ3Ops.h: -------------------------------------------------------------------------------- 1 | //===- OQ3Ops.h - OpenQASM 3 dialect ops ------------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // Any modifications or derivative works of this code must retain this 6 | // copyright notice, and modified files need to carry a notice indicating 7 | // that they have been altered from the originals. 8 | // 9 | //===----------------------------------------------------------------------===// 10 | /// 11 | /// This file declares the operations in the OpenQASM 3 dialect. 12 | /// 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef DIALECT_OQ3_OQ3OPS_H_ 16 | #define DIALECT_OQ3_OQ3OPS_H_ 17 | 18 | #include "Dialect/OQ3/IR/OQ3Types.h" 19 | #include "Dialect/QUIR/IR/QUIRInterfaces.h" 20 | #include "Dialect/QUIR/IR/QUIRTraits.h" 21 | #include "Dialect/QUIR/IR/QUIRTypes.h" 22 | 23 | #include "mlir/IR/BuiltinOps.h" 24 | 25 | #define GET_OP_CLASSES 26 | #include "Dialect/OQ3/IR/OQ3Ops.h.inc" 27 | 28 | #endif // DIALECT_OQ3_OQ3OPS_H_ 29 | -------------------------------------------------------------------------------- /include/Dialect/OQ3/IR/OQ3Ops.td: -------------------------------------------------------------------------------- 1 | //===- OQ3Ops.td - OpenQASM 3 dialect ops ------------------*- tablegen -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // Any modifications or derivative works of this code must retain this 6 | // copyright notice, and modified files need to carry a notice indicating 7 | // that they have been altered from the originals. 8 | // 9 | //===----------------------------------------------------------------------===// 10 | /// 11 | /// This is the main operation definition file for OpenQASM 3 operations. 12 | /// 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef OQ3_OPS 16 | #define OQ3_OPS 17 | 18 | // TODO: Temporary, until constraints between `OpenQASM3`, `QUIR`, `Pulse`, and 19 | // `System` dialects are ironed out. 20 | include "Dialect/QUIR/IR/QUIRInterfaces.td" 21 | include "Dialect/QUIR/IR/QUIRTraits.td" 22 | include "Dialect/QUIR/IR/QUIRTypeConstraints.td" 23 | 24 | include "Dialect/OQ3/IR/OQ3Base.td" 25 | include "Dialect/OQ3/IR/OQ3ArithmeticOps.td" 26 | include "Dialect/OQ3/IR/OQ3AngleOps.td" 27 | include "Dialect/OQ3/IR/OQ3ArrayOps.td" 28 | include "Dialect/OQ3/IR/OQ3CastOps.td" 29 | include "Dialect/OQ3/IR/OQ3CBitOps.td" 30 | include "Dialect/OQ3/IR/OQ3GateOps.td" 31 | include "Dialect/OQ3/IR/OQ3VariableOps.td" 32 | 33 | #endif // OQ3_OPS 34 | -------------------------------------------------------------------------------- /include/Dialect/OQ3/IR/OQ3Patterns.td: -------------------------------------------------------------------------------- 1 | //===- OQ3Patterns.td - OpenQASM 3 dialect DRR ------------*-- tablegen -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // Any modifications or derivative works of this code must retain this 6 | // copyright notice, and modified files need to carry a notice indicating 7 | // that they have been altered from the originals. 8 | // 9 | //===----------------------------------------------------------------------===// 10 | /// 11 | /// This file declares the OpenQASM 3 declarative rewrite rules (DRR), or 12 | /// patterns. 13 | /// 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef OQ3_PATTERNS 17 | #define OQ3_PATTERNS 18 | 19 | include "mlir/IR/BuiltinOps.td" 20 | include "mlir/IR/PatternBase.td" 21 | include "Dialect/OQ3/IR/OQ3Ops.td" 22 | 23 | def CBitNotNotPat : Pat< 24 | (OQ3_CBitNotOp (OQ3_CBitNotOp $in)), (replaceWithValue $in)>; 25 | 26 | #endif // OQ3_PATTERNS 27 | -------------------------------------------------------------------------------- /include/Dialect/OQ3/IR/OQ3Types.h: -------------------------------------------------------------------------------- 1 | //===- OQ3Types.h - OpenQASM 3 dialect types --------------*- C++ -*-=========// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // Any modifications or derivative works of this code must retain this 6 | // copyright notice, and modified files need to carry a notice indicating 7 | // that they have been altered from the originals. 8 | // 9 | //===----------------------------------------------------------------------===// 10 | /// 11 | /// This file declares the types in the OpenQASM 3 dialect. 12 | /// 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef DIALECT_OQ3_OQ3TYPES_H_ 16 | #define DIALECT_OQ3_OQ3TYPES_H_ 17 | 18 | // TODO: Temporary, until constraints between `OQ3`, `QUIR`, `Pulse`, and 19 | // `QCS` dialects are ironed out. 20 | #include "Dialect/QUIR/IR/QUIRTypes.h" 21 | 22 | namespace mlir::oq3 {} // namespace mlir::oq3 23 | 24 | #endif // DIALECT_OQ3_OQ3TYPES_H_ 25 | -------------------------------------------------------------------------------- /include/Dialect/OQ3/Transforms/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | -------------------------------------------------------------------------------- /include/Dialect/OQ3/Transforms/Passes.h: -------------------------------------------------------------------------------- 1 | //===- Passes.h - OQ3 Passes -----------------------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef OQ3_OQ3PASSES_H 18 | #define OQ3_OQ3PASSES_H 19 | 20 | #include "LimitCBitWidth.h" 21 | 22 | namespace mlir::oq3 { 23 | void registerOQ3Passes(); 24 | void registerOQ3PassPipeline(); 25 | 26 | } // namespace mlir::oq3 27 | 28 | #endif // OQ3_OQ3PASSES_H 29 | -------------------------------------------------------------------------------- /include/Dialect/Pulse/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_subdirectory(IR) 14 | -------------------------------------------------------------------------------- /include/Dialect/Pulse/IR/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_mlir_dialect(Pulse pulse) 14 | add_mlir_doc(Pulse PulseDialect generated/Dialect/Pulse/ -gen-dialect-doc -dialect=pulse) 15 | 16 | set(LLVM_TARGET_DEFINITIONS Pulse.td) 17 | mlir_tablegen(PulseAttributes.h.inc -gen-attrdef-decls -attrdefs-dialect=pulse) 18 | mlir_tablegen(PulseAttributes.cpp.inc -gen-attrdef-defs -attrdefs-dialect=pulse) 19 | 20 | add_mlir_interface(PulseInterfaces) 21 | -------------------------------------------------------------------------------- /include/Dialect/Pulse/IR/Pulse.td: -------------------------------------------------------------------------------- 1 | //===- Pulse.td - Pulse dialect ----------------------------*- tablegen -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef PULSE_TD 18 | #define PULSE_TD 19 | 20 | include "Dialect/Pulse/IR/PulseDialect.td" 21 | 22 | #endif // PULSE_TD 23 | -------------------------------------------------------------------------------- /include/Dialect/Pulse/IR/PulseAttributes.h: -------------------------------------------------------------------------------- 1 | //===- PulseAttributes.h - Pulse dialect attributes -------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// Attributes for the Pulse dialect 18 | /// 19 | //===----------------------------------------------------------------------===// 20 | 21 | #ifndef PULSE_PULSEATTRIBUTES_H 22 | #define PULSE_PULSEATTRIBUTES_H 23 | 24 | #include "mlir/IR/Attributes.h" 25 | #include "mlir/IR/DialectImplementation.h" 26 | 27 | namespace mlir::quir {} // namespace mlir::quir 28 | 29 | #define GET_ATTRDEF_CLASSES 30 | #include "Dialect/Pulse/IR/PulseAttributes.h.inc" 31 | 32 | #endif // PULSE_PULSEATTRIBUTES_H 33 | -------------------------------------------------------------------------------- /include/Dialect/Pulse/IR/PulseAttributes.td: -------------------------------------------------------------------------------- 1 | //===- PulseAttributes.td - Pulse dialect attributes -------*- tablegen -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | 17 | 18 | #ifndef PULSE_ATTRIBUTES 19 | #define PULSE_ATTRIBUTES 20 | 21 | 22 | include "mlir/IR/BuiltinAttributes.td" 23 | include "mlir/IR/OpBase.td" 24 | 25 | #endif // PULSE_ATTRIBUTES 26 | -------------------------------------------------------------------------------- /include/Dialect/Pulse/IR/PulseDialect.h: -------------------------------------------------------------------------------- 1 | //===- PulseDialect.h - Pulse dialect ---------------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// This file declares the Pulse dialect in MLIR. 18 | /// 19 | //===----------------------------------------------------------------------===// 20 | 21 | #ifndef PULSE_PULSEDIALECT_H 22 | #define PULSE_PULSEDIALECT_H 23 | 24 | #include "mlir/Dialect/LLVMIR/LLVMDialect.h" 25 | 26 | #include "Dialect/Pulse/IR/PulseDialect.h.inc" 27 | 28 | #endif // PULSE_PULSEDIALECT_H 29 | -------------------------------------------------------------------------------- /include/Dialect/Pulse/IR/PulseTraits.td: -------------------------------------------------------------------------------- 1 | //===- PulseTraits.td - Pulse dialect traits -*- C++ -*-======================// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// Traits for the Pulse dialect 18 | /// 19 | //===----------------------------------------------------------------------===// 20 | 21 | #ifndef PULSE_TRAITS 22 | #define PULSE_TRAITS 23 | 24 | include "mlir/IR/OpBase.td" 25 | 26 | // Pulse Traits 27 | 28 | /// Operation is allowed within a real-time scheduled pulse.sequence 29 | def SequenceAllowed : NativeOpTrait<"SequenceAllowed">{ 30 | let cppNamespace= "::mlir::pulse"; 31 | } 32 | 33 | /// Operation must be within a real-time scheduled pulse.sequence 34 | def SequenceRequired : NativeOpTrait<"SequenceRequired">{ 35 | let cppNamespace= "::mlir::pulse"; 36 | } 37 | 38 | /// Operation receives a target argument 39 | def HasTargetFrame : NativeOpTrait<"HasTargetFrame">{ 40 | let cppNamespace= "::mlir::pulse"; 41 | } 42 | 43 | #endif // PULSE_TRAITS 44 | -------------------------------------------------------------------------------- /include/Dialect/Pulse/IR/PulseTypes.h: -------------------------------------------------------------------------------- 1 | //===- PulseTypes.h - Pulse dialect ops -------------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef PULSE_PULSETYPES_H 18 | #define PULSE_PULSETYPES_H 19 | 20 | #include "mlir/IR/BuiltinTypes.h" 21 | #include "mlir/IR/Dialect.h" 22 | #include "mlir/IR/OpDefinition.h" 23 | #include "mlir/IR/Types.h" 24 | 25 | #define GET_TYPEDEF_CLASSES 26 | #include "Dialect/Pulse/IR/PulseTypes.h.inc" 27 | 28 | #endif // PULSE_PULSETYPES_H 29 | -------------------------------------------------------------------------------- /include/Dialect/Pulse/Transforms/InlineRegion.h: -------------------------------------------------------------------------------- 1 | //===- InlineRegion.h - Inlining all dialects -------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// This file declares the pass for inlining all dialects 18 | /// 19 | //===----------------------------------------------------------------------===// 20 | 21 | #ifndef PULSE_INLINE_REGION_H 22 | #define PULSE_INLINE_REGION_H 23 | 24 | #include "mlir/IR/BuiltinOps.h" 25 | #include "mlir/Pass/Pass.h" 26 | 27 | namespace mlir::pulse { 28 | 29 | class InlineRegionPass 30 | : public PassWrapper> { 31 | public: 32 | void runOnOperation() override; 33 | 34 | llvm::StringRef getArgument() const override; 35 | llvm::StringRef getDescription() const override; 36 | llvm::StringRef getName() const override; 37 | }; 38 | 39 | } // namespace mlir::pulse 40 | #endif // PULSE_INLINE_REGION_H 41 | -------------------------------------------------------------------------------- /include/Dialect/Pulse/Transforms/LabelPlayOpDurations.h: -------------------------------------------------------------------------------- 1 | //===- LabelPlayOpDurations.cpp - Label PlayOps with Durations --*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2024. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// This file defines the pass for labeling pulse.play operations with the 18 | /// duration of the waveform being played. 19 | //===----------------------------------------------------------------------===// 20 | 21 | #ifndef PULSE_LABEL_PLAY_DURATION_H 22 | #define PULSE_LABEL_PLAY_DURATION_H 23 | 24 | #include "mlir/IR/BuiltinOps.h" 25 | #include "mlir/Pass/Pass.h" 26 | 27 | namespace mlir::pulse { 28 | 29 | class LabelPlayOpDurationsPass 30 | : public PassWrapper> { 31 | public: 32 | void runOnOperation() override; 33 | 34 | llvm::StringRef getArgument() const override; 35 | llvm::StringRef getDescription() const override; 36 | llvm::StringRef getName() const override; 37 | }; 38 | } // namespace mlir::pulse 39 | 40 | #endif // PULSE_LABEL_PLAY_DURATION_H 41 | -------------------------------------------------------------------------------- /include/Dialect/Pulse/Transforms/MergeDelays.h: -------------------------------------------------------------------------------- 1 | //===- MergeDelays.h - Merge back to back pulse.delays ---------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// This file declares the pass for merging back to back pulse.delays. 18 | /// The current implementation defaults to ignoring the target, there 19 | /// is an option to override this. 20 | /// 21 | //===----------------------------------------------------------------------===// 22 | 23 | #ifndef PULSE_MERGE_DELAYS_H 24 | #define PULSE_MERGE_DELAYS_H 25 | 26 | #include "Dialect/Pulse/IR/PulseOps.h" 27 | 28 | #include "mlir/Pass/Pass.h" 29 | 30 | namespace mlir::pulse { 31 | 32 | class MergeDelayPass 33 | : public PassWrapper> { 34 | public: 35 | void runOnOperation() override; 36 | 37 | llvm::StringRef getArgument() const override; 38 | llvm::StringRef getDescription() const override; 39 | llvm::StringRef getName() const override; 40 | }; 41 | } // namespace mlir::pulse 42 | 43 | #endif // PULSE_MERGE_DELAY_H 44 | -------------------------------------------------------------------------------- /include/Dialect/Pulse/Transforms/RemoveUnusedArguments.h: -------------------------------------------------------------------------------- 1 | //===- RemoveUnusedArguments.h - remove unused args from call ---*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// This file declares the pass for removing arguments from pulse.call_sequence 18 | /// where the argument is unused in the callee pulse.sequence. 19 | /// 20 | //===----------------------------------------------------------------------===// 21 | 22 | #ifndef PULSE_REMOVE_UNUSED_ARGUMENTS_H 23 | #define PULSE_REMOVE_UNUSED_ARGUMENTS_H 24 | 25 | #include 26 | #include 27 | 28 | #include "Dialect/Pulse/IR/PulseOps.h" 29 | #include "mlir/Pass/Pass.h" 30 | 31 | namespace mlir::pulse { 32 | 33 | class RemoveUnusedArgumentsPass 34 | : public PassWrapper> { 35 | public: 36 | void runOnOperation() override; 37 | 38 | llvm::StringRef getArgument() const override; 39 | llvm::StringRef getDescription() const override; 40 | llvm::StringRef getName() const override; 41 | }; 42 | } // namespace mlir::pulse 43 | 44 | #endif // PULSE_REMOVE_UNUSED_ARGUMENTS_H 45 | -------------------------------------------------------------------------------- /include/Dialect/QCS/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_subdirectory(IR) 14 | add_subdirectory(Utils) 15 | -------------------------------------------------------------------------------- /include/Dialect/QCS/IR/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_mlir_dialect(QCSOps qcs) 14 | add_mlir_doc(QCSOps QCSOps generated/Dialect/QCS/ -gen-dialect-doc -dialect=qcs) 15 | 16 | set(LLVM_TARGET_DEFINITIONS QCSDialect.td) 17 | -------------------------------------------------------------------------------- /include/Dialect/QCS/IR/QCSAttributes.h: -------------------------------------------------------------------------------- 1 | //===- QCSAttributes.h - QCS dialect attributes -----------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// This file declares Quantum Control System dialect specific attributes. 18 | /// 19 | //===----------------------------------------------------------------------===// 20 | 21 | #ifndef DIALECT_QCS_QCSATTRIBUTES_H_ 22 | #define DIALECT_QCS_QCSATTRIBUTES_H_ 23 | 24 | #include "llvm/ADT/StringRef.h" 25 | 26 | namespace mlir::qcs { 27 | static inline llvm::StringRef getShotLoopAttrName() { return "qcs.shot_loop"; } 28 | static inline llvm::StringRef getNumShotsAttrName() { return "qcs.num_shots"; } 29 | } // namespace mlir::qcs 30 | 31 | #endif // DIALECT_QCS_QCSATTRIBUTES_H_ 32 | -------------------------------------------------------------------------------- /include/Dialect/QCS/IR/QCSDialect.h: -------------------------------------------------------------------------------- 1 | //===- QCSDialect.h - Quantum Control System dialect ------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// This file declares the Quantum Control System dialect in MLIR. 18 | /// 19 | //===----------------------------------------------------------------------===// 20 | 21 | #ifndef DIALECT_QCS_QCSDIALECT_H_ 22 | #define DIALECT_QCS_QCSDIALECT_H_ 23 | 24 | #include "mlir/IR/Dialect.h" 25 | 26 | #include "Dialect/QCS/IR/QCSOpsDialect.h.inc" 27 | 28 | #endif // DIALECT_QCS_QCSDIALECT_H_ 29 | -------------------------------------------------------------------------------- /include/Dialect/QCS/IR/QCSOps.h: -------------------------------------------------------------------------------- 1 | //===- QCSOps.h - Quantum Control System dialect ops ------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// This file declares the operations in the Quantum Control System dialect. 18 | /// 19 | //===----------------------------------------------------------------------===// 20 | 21 | #ifndef DIALECT_QCS_QCSOPS_H_ 22 | #define DIALECT_QCS_QCSOPS_H_ 23 | 24 | #include 25 | 26 | // TODO: move necessary components to `QCS` 27 | #include "Dialect/QUIR/IR/QUIRInterfaces.h" 28 | #include "Dialect/QUIR/IR/QUIRTraits.h" 29 | 30 | #include "Dialect/QCS/IR/QCSTypes.h" 31 | 32 | #include "mlir/IR/SymbolTable.h" 33 | #include "llvm/ADT/StringMap.h" 34 | 35 | #define GET_OP_CLASSES 36 | #include "Dialect/QCS/IR/QCSOps.h.inc" 37 | 38 | #endif // DIALECT_QCS_QCSOPS_H_ 39 | -------------------------------------------------------------------------------- /include/Dialect/QCS/IR/QCSTypes.h: -------------------------------------------------------------------------------- 1 | //===- QCSTypes.h - Quantum Control System dialect types --*- C++ -*-=========// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// This file declares the types in the Quantum Control System dialect. 18 | /// 19 | //===----------------------------------------------------------------------===// 20 | 21 | #ifndef DIALECT_QCS_QCSTYPES_H_ 22 | #define DIALECT_QCS_QCSTYPES_H_ 23 | 24 | // TODO: Temporary, until constraints between `OpenQASM3`, `QUIR`, `Pulse`, and 25 | // `System` dialects are ironed out. 26 | #include "Dialect/QUIR/IR/QUIRTypes.h" 27 | 28 | #include 29 | 30 | namespace mlir::qcs { 31 | using ParameterType = std::variant; 32 | } // namespace mlir::qcs 33 | 34 | #endif // DIALECT_QCS_QCSTYPES_H_ 35 | -------------------------------------------------------------------------------- /include/Dialect/QCS/Utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | -------------------------------------------------------------------------------- /include/Dialect/QUIR/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_subdirectory(IR) 14 | add_subdirectory(Transforms) 15 | -------------------------------------------------------------------------------- /include/Dialect/QUIR/IR/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023, 2024. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_mlir_dialect(QUIR quir) 14 | add_mlir_doc(QUIR QUIRDialect generated/Dialect/QUIR/ -gen-dialect-doc -dialect=quir) 15 | 16 | set(LLVM_TARGET_DEFINITIONS QUIR.td) 17 | mlir_tablegen(QUIRAttributes.h.inc -gen-attrdef-decls -attrdefs-dialect=quir) 18 | mlir_tablegen(QUIRAttributes.cpp.inc -gen-attrdef-defs -attrdefs-dialect=quir) 19 | add_public_tablegen_target(QUIRAttributesIncGen) 20 | 21 | set(LLVM_TARGET_DEFINITIONS QUIR.td) 22 | mlir_tablegen(QUIREnums.h.inc -gen-enum-decls) 23 | mlir_tablegen(QUIREnums.cpp.inc -gen-enum-defs) 24 | add_public_tablegen_target(QUIREnumsIncGen) 25 | 26 | # This dependency makes sure that the attributes and enums include files are 27 | # generated before anything that requires the include files generated for the 28 | # QUIR dialect 29 | add_dependencies(MLIRQUIRIncGen QUIREnumsIncGen QUIRAttributesIncGen) 30 | 31 | add_mlir_interface(QUIRInterfaces) 32 | -------------------------------------------------------------------------------- /include/Dialect/QUIR/IR/QUIR.td: -------------------------------------------------------------------------------- 1 | //===- QuirDialect.td - Quir dialect -----------------------*- tablegen -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef QUIR_TD 18 | #define QUIR_TD 19 | 20 | include "Dialect/QUIR/IR/QUIRDialect.td" 21 | include "Dialect/QUIR/IR/QUIREnums.td" 22 | include "Dialect/QUIR/IR/QUIRTypes.td" 23 | include "Dialect/QUIR/IR/QUIRTypeConstraints.td" 24 | include "Dialect/QUIR/IR/QUIRAttributes.td" 25 | include "Dialect/QUIR/IR/QUIRTraits.td" 26 | include "Dialect/QUIR/IR/QUIROps.td" 27 | 28 | #endif // QUIR_TD 29 | -------------------------------------------------------------------------------- /include/Dialect/QUIR/IR/QUIRDialect.h: -------------------------------------------------------------------------------- 1 | //===- QuirDialect.h - Quir dialect -----------------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// This file declares the QUIR dialect in MLIR. 18 | /// 19 | //===----------------------------------------------------------------------===// 20 | 21 | #ifndef QUIR_QUIRDIALECT_H 22 | #define QUIR_QUIRDIALECT_H 23 | 24 | #include "Dialect/OQ3/IR/OQ3Dialect.h" 25 | #include "Dialect/QCS/IR/QCSDialect.h" 26 | 27 | #include "mlir/Dialect/Arith/IR/Arith.h" 28 | #include "mlir/Dialect/LLVMIR/LLVMDialect.h" 29 | #include "mlir/Dialect/SCF/IR/SCF.h" 30 | #include "mlir/IR/BuiltinOps.h" 31 | #include "mlir/IR/Dialect.h" 32 | 33 | #include 34 | 35 | #include "Dialect/QUIR/IR/QUIRDialect.h.inc" 36 | 37 | #endif // QUIR_QUIRDIALECT_H 38 | -------------------------------------------------------------------------------- /include/Dialect/QUIR/IR/QUIREnums.h: -------------------------------------------------------------------------------- 1 | //===- QUIREnums.h - QUIR dialect enums -------------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef QUIR_QUIRENUMS_H 18 | #define QUIR_QUIRENUMS_H 19 | 20 | #include "mlir/IR/BuiltinTypes.h" 21 | #include "mlir/IR/Dialect.h" 22 | #include "mlir/IR/DialectImplementation.h" 23 | #include "mlir/IR/OpDefinition.h" 24 | 25 | #define GET_ENUM_CLASSES 26 | #include "Dialect/QUIR/IR/QUIREnums.h.inc" 27 | 28 | namespace mlir {} // namespace mlir 29 | 30 | #endif // QUIR_QUIRENUMS_H 31 | -------------------------------------------------------------------------------- /include/Dialect/QUIR/IR/QUIREnums.td: -------------------------------------------------------------------------------- 1 | //===- QUIREnums.td - QUIR dialect enums -------------------*- tablegen -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | 17 | 18 | #ifndef QUIR_ENUMS 19 | #define QUIR_ENUMS 20 | 21 | include "Dialect/QUIR/IR/QUIRDialect.td" 22 | 23 | include "mlir/IR/EnumAttr.td" 24 | 25 | def TimeUnits : I32EnumAttr< 26 | "TimeUnits", "time units enum", 27 | [ 28 | // dt is the "scheduling rate" of the target system 29 | // ie., the smallest step of time exposed. 30 | I32EnumAttrCase<"dt", 0>, 31 | I32EnumAttrCase<"s", 1>, 32 | I32EnumAttrCase<"ms", 2>, 33 | I32EnumAttrCase<"us", 3>, 34 | I32EnumAttrCase<"ns", 4>, 35 | I32EnumAttrCase<"ps", 5>, 36 | I32EnumAttrCase<"fs", 6>, 37 | 38 | ]> { 39 | let genSpecializedAttr = 0; 40 | let cppNamespace = "::mlir::quir"; 41 | 42 | } 43 | 44 | def QUIR_TimeUnitsAttr : EnumAttr< 45 | QUIRDialect, TimeUnits, "time_units">; 46 | 47 | #endif // QUIR_ENUMS 48 | -------------------------------------------------------------------------------- /include/Dialect/QUIR/IR/QUIROps.h: -------------------------------------------------------------------------------- 1 | //===- QUIROps.h - QUIR dialect ops -----------------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef QUIR_QUIROPS_H 18 | #define QUIR_QUIROPS_H 19 | 20 | #include "Dialect/QUIR/IR/QUIRAttributes.h" 21 | #include "Dialect/QUIR/IR/QUIRInterfaces.h" 22 | #include "Dialect/QUIR/IR/QUIRTraits.h" 23 | #include "Dialect/QUIR/IR/QUIRTypes.h" 24 | 25 | #include "mlir/Dialect/Func/IR/FuncOps.h" 26 | #include "mlir/IR/Builders.h" 27 | #include "mlir/IR/BuiltinOps.h" 28 | #include "mlir/IR/BuiltinTypes.h" 29 | #include "mlir/IR/Dialect.h" 30 | #include "mlir/IR/DialectImplementation.h" 31 | #include "mlir/IR/FunctionInterfaces.h" 32 | #include "mlir/IR/OpDefinition.h" 33 | #include "mlir/Interfaces/CallInterfaces.h" 34 | #include "mlir/Interfaces/ControlFlowInterfaces.h" 35 | #include "mlir/Interfaces/SideEffectInterfaces.h" 36 | #include "mlir/Transforms/InliningUtils.h" 37 | 38 | #include 39 | #include 40 | 41 | #define GET_OP_CLASSES 42 | #include "Dialect/QUIR/IR/QUIR.h.inc" 43 | 44 | #endif // QUIR_QUIROPS_H 45 | -------------------------------------------------------------------------------- /include/Dialect/QUIR/IR/QUIRTestInterfaces.h: -------------------------------------------------------------------------------- 1 | //===- QUIRTestInterfaces.h - QUIR Dialect interface tests -*- C++ -*-========// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// Tests for the QUIR dialect interfaces 18 | /// 19 | //===----------------------------------------------------------------------===// 20 | 21 | #ifndef QUIR_TESTQUIRINTERFACES_H 22 | #define QUIR_TESTQUIRINTERFACES_H 23 | 24 | #include "mlir/Pass/Pass.h" 25 | 26 | namespace mlir::quir { 27 | 28 | //===----------------------------------------------------------------------===// 29 | // QubitOpInterface 30 | //===----------------------------------------------------------------------===// 31 | 32 | struct TestQubitOpInterfacePass 33 | : public PassWrapper> { 34 | void runOnOperation() override; 35 | 36 | llvm::StringRef getArgument() const override; 37 | llvm::StringRef getDescription() const override; 38 | llvm::StringRef getName() const override; 39 | }; 40 | 41 | } // namespace mlir::quir 42 | 43 | #endif // QUIR_QUIRTESTINTERFACES_H 44 | -------------------------------------------------------------------------------- /include/Dialect/QUIR/IR/QUIRTraits.h: -------------------------------------------------------------------------------- 1 | //===- QUIRTraits.h - QUIR dialect traits -*- C++ -*-=========================// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// Traits for the QUIR dialect 18 | /// 19 | //===----------------------------------------------------------------------===// 20 | 21 | #ifndef QUIR_QUIRTRAITS_H 22 | #define QUIR_QUIRTRAITS_H 23 | 24 | #include "mlir/IR/OpDefinition.h" 25 | 26 | //===----------------------------------------------------------------------===// 27 | // Operation Trait Types 28 | //===----------------------------------------------------------------------===// 29 | 30 | namespace mlir::quir { 31 | 32 | template 33 | class CPTPOp : public mlir::OpTrait::TraitBase {}; 34 | 35 | template 36 | class UnitaryOp : public mlir::OpTrait::TraitBase {}; 37 | 38 | } // namespace mlir::quir 39 | 40 | #endif // QUIR_QUIRTRAITS_H 41 | -------------------------------------------------------------------------------- /include/Dialect/QUIR/IR/QUIRTraits.td: -------------------------------------------------------------------------------- 1 | //===- QUIRTraits.td - QUIR dialect traits -*- C++ -*-========================// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// Traits for the QUIR dialect 18 | /// 19 | //===----------------------------------------------------------------------===// 20 | 21 | #ifndef QUIR_TRAITS 22 | #define QUIR_TRAITS 23 | 24 | include "mlir/IR/OpBase.td" 25 | 26 | // QUIR Traits 27 | 28 | // Operation applies a quantum channel to the quantum system. 29 | // i.e., it is a completely positive trace perserving (CPTP) map 30 | def CPTPOp : NativeOpTrait<"CPTPOp">{ 31 | let cppNamespace= "::mlir::quir"; 32 | } 33 | 34 | // Operation applies a unitary transformation to the quantum system. 35 | // Is a subclass of CPTPOp. 36 | def UnitaryOp : NativeOpTrait<"UnitaryOp"> { 37 | let cppNamespace= "::mlir::quir"; 38 | } 39 | 40 | #endif // QUIR_TRAITS 41 | -------------------------------------------------------------------------------- /include/Dialect/QUIR/IR/QUIRTypes.h: -------------------------------------------------------------------------------- 1 | //===- QUIRTypes.h - QUIR dialect types -------------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef QUIR_QUIRTYPES_H 18 | #define QUIR_QUIRTYPES_H 19 | 20 | #include "Dialect/QUIR/IR/QUIREnums.h" 21 | 22 | #include "mlir/IR/BuiltinTypes.h" 23 | #include "mlir/IR/Dialect.h" 24 | #include "mlir/IR/OpDefinition.h" 25 | #include "mlir/IR/Types.h" 26 | #include "mlir/Interfaces/InferTypeOpInterface.h" 27 | #include "mlir/Interfaces/SideEffectInterfaces.h" 28 | 29 | #define GET_TYPEDEF_CLASSES 30 | #include "Dialect/QUIR/IR/QUIRTypes.h.inc" 31 | 32 | namespace mlir::quir { 33 | 34 | /// Check whether a type is a bool (i1) 35 | inline bool isBoolType(mlir::Type type) { return type.isInteger(1); } 36 | 37 | } // namespace mlir::quir 38 | 39 | #endif // QUIR_QUIRTYPES_H 40 | -------------------------------------------------------------------------------- /include/Dialect/QUIR/Transforms/Analysis.h: -------------------------------------------------------------------------------- 1 | //===- Analysis.h - QUIR Analyses -------------------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// This file declares QUIR analyses. 18 | /// 19 | //===----------------------------------------------------------------------===// 20 | 21 | #ifndef QUIR_ANALYSIS_H 22 | #define QUIR_ANALYSIS_H 23 | 24 | #include "mlir/IR/Operation.h" 25 | 26 | namespace mlir::quir { 27 | 28 | // Validate that all operations contained within an operation are unitary 29 | // or a scf::yieldOp operation. 30 | // TODO: This should be replace by analysis performed on a canonicalized 31 | // quir.circuit operation 32 | struct PurelyUnitaryAnalysis { 33 | 34 | bool isPurelyUnitary = true; 35 | 36 | PurelyUnitaryAnalysis(mlir::Operation *op); 37 | }; 38 | 39 | } // namespace mlir::quir 40 | 41 | #endif // QUIR_ANALYSIS_H 42 | -------------------------------------------------------------------------------- /include/Dialect/QUIR/Transforms/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | -------------------------------------------------------------------------------- /include/Dialect/QUIR/Transforms/LoadElimination.h: -------------------------------------------------------------------------------- 1 | //===- LoadElimination.h - Remove unnecessary loads -------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// This file declares the pass for replacing unnecessary variable loads. 18 | /// 19 | //===----------------------------------------------------------------------===// 20 | 21 | #ifndef QUIR_LOAD_ELIMINATION_H 22 | #define QUIR_LOAD_ELIMINATION_H 23 | 24 | #include "mlir/Pass/Pass.h" 25 | 26 | namespace mlir::quir { 27 | 28 | struct LoadEliminationPass 29 | : public PassWrapper> { 30 | void runOnOperation() override; 31 | 32 | llvm::StringRef getArgument() const override; 33 | llvm::StringRef getDescription() const override; 34 | llvm::StringRef getName() const override; 35 | }; // struct LoadEliminationPass 36 | 37 | } // namespace mlir::quir 38 | 39 | #endif // QUIR_LOAD_ELIMINATION_H 40 | -------------------------------------------------------------------------------- /include/Dialect/QUIR/Transforms/RemoveUnusedCircuits.h: -------------------------------------------------------------------------------- 1 | //===- RemoveUnusedCircuits.h - Remove Unused Circuits ----------- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2024. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// This file declares the pass for removing unused circuits. 18 | /// 19 | //===----------------------------------------------------------------------===// 20 | 21 | #ifndef QUIR_REMOVE_UNUSED_CIRCUITS_H 22 | #define QUIR_REMOVE_UNUSED_CIRCUITS_H 23 | 24 | #include "mlir/Pass/Pass.h" 25 | 26 | namespace mlir::quir { 27 | 28 | /// @brief Merge together measures in a circuit that are topologically 29 | /// adjacent into a single variadic measurement. 30 | struct RemoveUnusedCircuitsPass 31 | : public PassWrapper> { 32 | void runOnOperation() override; 33 | 34 | llvm::StringRef getArgument() const override; 35 | llvm::StringRef getDescription() const override; 36 | llvm::StringRef getName() const override; 37 | }; // struct RemoveUnusedCircuits 38 | 39 | } // namespace mlir::quir 40 | 41 | #endif // QUIR_REMOVE_UNUSED_CIRCUITS_H 42 | -------------------------------------------------------------------------------- /include/Dialect/QUIR/Transforms/ReorderCircuits.h: -------------------------------------------------------------------------------- 1 | //===- ReorderCircuits.h - Move call_circuits ops later ---------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // 14 | //===----------------------------------------------------------------------===// 15 | /// 16 | /// This file declares the pass for moving call_circuits operations later 17 | /// when possible. 18 | /// 19 | //===----------------------------------------------------------------------===// 20 | 21 | #ifndef QUIR_REORDER_CIRCUITS_H 22 | #define QUIR_REORDER_CIRCUITS_H 23 | 24 | #include "mlir/Pass/Pass.h" 25 | 26 | namespace mlir::quir { 27 | 28 | /// @brief Move call_circuits when possible 29 | struct ReorderCircuitsPass 30 | : public PassWrapper> { 31 | void runOnOperation() override; 32 | 33 | llvm::StringRef getArgument() const override; 34 | llvm::StringRef getDescription() const override; 35 | llvm::StringRef getName() const override; 36 | }; // struct ReorderCircuitsPass 37 | 38 | } // namespace mlir::quir 39 | 40 | #endif // QUIR_REORDER_CIRCUITS_H 41 | -------------------------------------------------------------------------------- /include/Dialect/QUIR/Transforms/ReorderMeasurements.h: -------------------------------------------------------------------------------- 1 | //===- ReorderMeasurements.h - Move measurement ops later -------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// This file declares the pass for moving measurements as late as possible 18 | /// 19 | //===----------------------------------------------------------------------===// 20 | 21 | #ifndef QUIR_REORDER_MEASURES_H 22 | #define QUIR_REORDER_MEASURES_H 23 | 24 | #include "mlir/Pass/Pass.h" 25 | 26 | namespace mlir::quir { 27 | 28 | /// @brief Move measures in a circuit to be as late as possible topologically 29 | struct ReorderMeasurementsPass 30 | : public PassWrapper> { 31 | void runOnOperation() override; 32 | 33 | llvm::StringRef getArgument() const override; 34 | llvm::StringRef getDescription() const override; 35 | llvm::StringRef getName() const override; 36 | }; // struct ReorderMeasurementsPass 37 | 38 | } // namespace mlir::quir 39 | 40 | #endif // QUIR_REORDER_MEASURES_H 41 | -------------------------------------------------------------------------------- /include/Dialect/RegisterDialects.h: -------------------------------------------------------------------------------- 1 | //===- OperationUtils.h -----------------------------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// Utility functions related to MLIR Dialect handling. 18 | /// 19 | //===----------------------------------------------------------------------===// 20 | 21 | #ifndef UTILS_DIALECTUTILS_H 22 | #define UTILS_DIALECTUTILS_H 23 | 24 | #include "mlir/IR/DialectRegistry.h" 25 | #include "mlir/InitAllDialects.h" 26 | 27 | #include "Dialect/OQ3/IR/OQ3Dialect.h" 28 | #include "Dialect/Pulse/IR/PulseDialect.h" 29 | #include "Dialect/QCS/IR/QCSDialect.h" 30 | #include "Dialect/QUIR/IR/QUIRDialect.h" 31 | 32 | namespace qssc::dialect { 33 | 34 | /// Register all qss-compiler dialects returning a dialect registry 35 | inline void registerDialects(mlir::DialectRegistry ®istry) { 36 | mlir::registerAllDialects(registry); 37 | registry.insert(); 39 | } 40 | } // namespace qssc::dialect 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /include/Frontend/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_subdirectory(OpenQASM3) 14 | -------------------------------------------------------------------------------- /include/Frontend/OpenQASM3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | -------------------------------------------------------------------------------- /include/HAL/PassRegistration.h: -------------------------------------------------------------------------------- 1 | //===- PassRegistration.h - Top-level pass registration ---------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | // 17 | // This file declares the top-level functions for registering passes and 18 | // pipelines 19 | // 20 | //===----------------------------------------------------------------------===// 21 | #ifndef PASSREGISTRATION_H 22 | #define PASSREGISTRATION_H 23 | 24 | #include "llvm/Support/Error.h" 25 | 26 | namespace qssc::hal { 27 | /// Register all registered MLIR passes 28 | /// for the registered Targets with the 29 | /// QSSC system. 30 | llvm::Error registerTargetPasses(); 31 | /// Register all registered MLIR pass pipelines 32 | /// for the registered Targets with the 33 | /// QSSC system. 34 | llvm::Error registerTargetPipelines(); 35 | } // namespace qssc::hal 36 | 37 | #endif // PASSREGISTRATION_H 38 | -------------------------------------------------------------------------------- /include/HAL/SystemConfiguration.h: -------------------------------------------------------------------------------- 1 | //===- SystemConfiguration.h - Config info ----------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | // 17 | // This file declares the classes for config data 18 | // 19 | //===----------------------------------------------------------------------===// 20 | #ifndef QSSC_SYSTEMCONFIGURATION_H 21 | #define QSSC_SYSTEMCONFIGURATION_H 22 | 23 | #include "Payload/Payload.h" 24 | 25 | #include "llvm/ADT/APFloat.h" 26 | #include "llvm/ADT/APInt.h" 27 | 28 | #include 29 | #include 30 | 31 | namespace qssc::hal { 32 | 33 | class SystemConfiguration { 34 | public: 35 | uint getNumQubits() const { return numQubits; } 36 | 37 | virtual ~SystemConfiguration(); 38 | 39 | protected: 40 | SystemConfiguration() = default; 41 | 42 | uint numQubits; 43 | }; 44 | } // namespace qssc::hal 45 | #endif // QSSC_SYSTEMCONFIGURATION_H 46 | -------------------------------------------------------------------------------- /include/Payload/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | -------------------------------------------------------------------------------- /include/Payload/PayloadRegistry.h: -------------------------------------------------------------------------------- 1 | //===- PayloadRegistry.h - Payload Registry ---------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | // 17 | // Declaration of the QSSC payload registry system. 18 | // 19 | //===----------------------------------------------------------------------===// 20 | #ifndef PAYLOADREGISTRY_H 21 | #define PAYLOADREGISTRY_H 22 | 23 | #include "Payload.h" 24 | 25 | #include "Plugin/PluginInfo.h" 26 | #include "Plugin/PluginRegistry.h" 27 | 28 | namespace qssc::payload::registry { 29 | 30 | using PayloadInfo = plugin::registry::PluginInfo; 31 | using PayloadRegistry = plugin::registry::PluginRegistry; 32 | 33 | } // namespace qssc::payload::registry 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /include/Support/Pimpl.h: -------------------------------------------------------------------------------- 1 | //===- Pimpl.h - Pointer-to-implementation pointer wrapper ------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | // 17 | // Wraps a unique_ptr, propagating const-ness. 18 | // For use in the Pimpl idiom. 19 | // 20 | // https://en.cppreference.com/w/cpp/language/pimpl 21 | // 22 | //===----------------------------------------------------------------------===// 23 | 24 | #ifndef QSS_OPT_PIMPL_H 25 | #define QSS_OPT_PIMPL_H 26 | 27 | #include 28 | 29 | namespace qssc::support { 30 | 31 | template 32 | class Pimpl { 33 | public: 34 | explicit Pimpl(std::unique_ptr impl) : impl(std::move(impl)) {} 35 | inline const T *operator->() const { return impl.get(); } 36 | inline T *operator->() { return impl.get(); } 37 | 38 | private: 39 | std::unique_ptr impl; 40 | }; 41 | 42 | } // namespace qssc::support 43 | 44 | #endif // QSS_OPT_PIMPL_H 45 | -------------------------------------------------------------------------------- /include/Utils/LegacyInputConversion.h: -------------------------------------------------------------------------------- 1 | //===- LegacyInputConversion.h ----------------------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef UTILS_LEGACY_INPUT_CONVERSION_H 18 | #define UTILS_LEGACY_INPUT_CONVERSION_H 19 | 20 | #include "Utils/SystemDefinition.h" 21 | 22 | #include "mlir/IR/Operation.h" 23 | 24 | #include 25 | 26 | namespace qssc::utils { 27 | 28 | class LegacyInputConversion : public SystemDefinition { 29 | 30 | public: 31 | ~LegacyInputConversion() = default; 32 | LegacyInputConversion(mlir::Operation *op) {} 33 | void create(const std::string &calibrationsFilename, 34 | const std::string &expParamsFilename, 35 | const std::string &backendConfigFilename); 36 | }; 37 | 38 | } // namespace qssc::utils 39 | 40 | #endif // UTILS_LEGACY_INPUT_CONVERSION_H 41 | -------------------------------------------------------------------------------- /include/qss-c/Dialect/OQ3.h: -------------------------------------------------------------------------------- 1 | //===- OQ3.h - OQ3 Dialect for C --------------------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2024. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// This file declares the c interface for the OQ3 dialect 18 | /// 19 | //===----------------------------------------------------------------------===// 20 | #ifndef C_DIALECT_OQ3_H 21 | #define C_DIALECT_OQ3_H 22 | 23 | #include "mlir-c/IR.h" 24 | #include "mlir-c/Support.h" 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(OQ3, oq3); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif // C_DIALECT_OQ3_H 37 | -------------------------------------------------------------------------------- /include/qss-c/Dialect/QCS.h: -------------------------------------------------------------------------------- 1 | //===- QCS.h - QCS Dialect for C --------------------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2024. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// This file declares the c interface for the QCS dialect 18 | /// 19 | //===----------------------------------------------------------------------===// 20 | 21 | #ifndef C_DIALECT_QCS_H 22 | #define C_DIALECT_QCS_H 23 | 24 | #include "mlir-c/IR.h" 25 | #include "mlir-c/Support.h" 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(QCS, qcs); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif // C_DIALECT_QCS_H 38 | -------------------------------------------------------------------------------- /lib/API/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_library(QSSCAPI api.cpp) 14 | 15 | add_library(QSSCError errors.cpp) 16 | 17 | set(LIBS 18 | qasm::qasm 19 | ) 20 | target_link_libraries(QSSCAPI ${LIBS} QSSCError) 21 | 22 | target_sources(QSSCAPI 23 | PRIVATE api.cpp errors.cpp 24 | INTERFACE FILE_SET HEADERS 25 | BASE_DIRS ${QSSC_INCLUDE_DIR}/API 26 | FILES ${QSSC_INCLUDE_DIR}/API/api.h ${QSSC_INCLUDE_DIR}/API/errors.h 27 | ) 28 | 29 | add_dependencies(QSSCAPI QSSCError MLIROQ3Dialect MLIRQCSDialect MLIRQUIRDialect mlir-headers) 30 | -------------------------------------------------------------------------------- /lib/Arguments/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_library(QSSCArguments Signature.cpp Arguments.cpp) 14 | add_dependencies(QSSCArguments mlir-headers) 15 | 16 | target_link_libraries(QSSCArguments QSSCPayloadZip libzip::zip) 17 | -------------------------------------------------------------------------------- /lib/CAPI/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2024. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | function(qss_dialects_target_includes target) 14 | set(_DIRS 15 | ${MLIR_INCLUDE_DIRS} 16 | ${PROJECT_SOURCE_DIR}/include 17 | ${PROJECT_BINARY_DIR}/include 18 | ) 19 | set_property(TARGET ${target} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES 20 | $) 21 | if(TARGET obj.${target}) 22 | set_property(TARGET ${target} APPEND PROPERTY INCLUDE_DIRECTORIES 23 | $) 24 | endif() 25 | endfunction() 26 | 27 | 28 | set(GLOBAL APPEND PROPERTY QSSC_CAPI_LIBS) 29 | function(add_qss_upstream_c_api_library name) 30 | add_mlir_public_c_api_library(${name} ${ARGN}) 31 | set(GLOBAL APPEND PROPERTY QSSC_CAPI_LIBS ${name}) 32 | qss_dialects_target_includes(${name}) 33 | endfunction() 34 | 35 | add_subdirectory(Dialect) 36 | -------------------------------------------------------------------------------- /lib/CAPI/Dialect/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2024. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_qss_upstream_c_api_library(MLIRCAPIPulse 14 | Pulse.cpp 15 | 16 | PARTIAL_SOURCES_INTENDED 17 | LINK_LIBS PUBLIC 18 | MLIRCAPIIR 19 | MLIRPulseDialect 20 | MLIRPulseTransforms 21 | ) 22 | 23 | add_qss_upstream_c_api_library(MLIRCAPIQUIR 24 | QUIR.cpp 25 | 26 | ADDITIONAL_HEADER_DIRS 27 | ${PROJECT_SOURCE_DIR}/include/QUIR 28 | 29 | PARTIAL_SOURCES_INTENDED 30 | LINK_LIBS PUBLIC 31 | MLIRCAPIIR 32 | MLIRQUIRDialect 33 | MLIRQUIRTransforms 34 | MLIRQUIRUtils 35 | ) 36 | 37 | add_qss_upstream_c_api_library(MLIRCAPIQCS 38 | QCS.cpp 39 | 40 | PARTIAL_SOURCES_INTENDED 41 | LINK_LIBS PUBLIC 42 | MLIRCAPIIR 43 | MLIRQCSDialect 44 | ) 45 | 46 | add_qss_upstream_c_api_library(MLIRCAPIOQ3 47 | OQ3.cpp 48 | 49 | PARTIAL_SOURCES_INTENDED 50 | LINK_LIBS PUBLIC 51 | MLIRCAPIIR 52 | MLIROQ3Dialect 53 | MLIROQ3Transforms 54 | ) 55 | 56 | set(mlir_qssc_capi_libs 57 | MLIRCAPIPulse 58 | MLIRCAPIQUIR 59 | MLIRCAPIQCS 60 | MLIRCAPIOQ3 61 | CACHE STRING 62 | "List of capi libs" 63 | FORCE 64 | ) 65 | -------------------------------------------------------------------------------- /lib/CAPI/Dialect/OQ3.cpp: -------------------------------------------------------------------------------- 1 | //===- OQ3.cpp - OQ3 dialect CAPI registration ------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2024. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// This file implements the OQ3 dialect registration of the CAPI 18 | /// 19 | //===----------------------------------------------------------------------===// 20 | 21 | // NOLINTNEXTLINE(misc-include-cleaner) 22 | #include "qss-c/Dialect/OQ3.h" 23 | 24 | #include "Dialect/OQ3/IR/OQ3Dialect.h" 25 | 26 | #include "mlir/CAPI/Registration.h" 27 | 28 | using namespace mlir; 29 | 30 | MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(OQ3, oq3, oq3::OQ3Dialect) 31 | -------------------------------------------------------------------------------- /lib/CAPI/Dialect/QCS.cpp: -------------------------------------------------------------------------------- 1 | //===- QCS.cpp - QCS dialect CAPI registration ------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2024. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// This file implements the QCS dialect registration of the CAPI 18 | /// 19 | //===----------------------------------------------------------------------===// 20 | 21 | // NOLINTNEXTLINE(misc-include-cleaner) 22 | #include "qss-c/Dialect/QCS.h" 23 | 24 | // NOLINTNEXTLINE(misc-include-cleaner) 25 | #include "Dialect/QCS/IR/QCSDialect.h" 26 | 27 | #include "mlir/CAPI/Registration.h" 28 | 29 | using namespace mlir; 30 | 31 | MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(QCS, qcs, qcs::QCSDialect) 32 | -------------------------------------------------------------------------------- /lib/Config/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # Any modifications or derivative works of this code must retain this 4 | # copyright notice, and modified files need to carry a notice indicating 5 | # that they have been altered from the originals. 6 | 7 | # Add QSSConfig lib 8 | qssc_add_library(QSSConfig 9 | QSSConfig.cpp 10 | CLIConfig.cpp 11 | EnvVarConfig.cpp 12 | 13 | ADDITIONAL_HEADER_DIRS 14 | ${QSSC_INCLUDE_DIR}/Config 15 | ) 16 | -------------------------------------------------------------------------------- /lib/Conversion/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_subdirectory(OQ3ToStandard) 14 | add_subdirectory(QUIRToPulse) 15 | add_subdirectory(QUIRToStandard) 16 | -------------------------------------------------------------------------------- /lib/Conversion/OQ3ToStandard/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # Any modifications or derivative works of this code must retain this 4 | # copyright notice, and modified files need to carry a notice indicating 5 | # that they have been altered from the originals. 6 | 7 | add_mlir_conversion_library(OQ3ToStandard 8 | OQ3ToStandard.cpp 9 | 10 | ADDITIONAL_HEADER_DIRS 11 | ${PROJECT_SOURCE_DIR}/include/Conversion/OQ3ToStandard/ 12 | 13 | LINK_COMPONENTS 14 | Core 15 | 16 | LINK_LIBS PUBLIC 17 | MLIRIR 18 | MLIROQ3Dialect 19 | ) 20 | -------------------------------------------------------------------------------- /lib/Conversion/QUIRToPulse/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_mlir_conversion_library(QUIRToPulse 14 | 15 | LoadPulseCals.cpp 16 | QUIRToPulse.cpp 17 | 18 | ADDITIONAL_HEADER_DIRS 19 | ${PROJECT_SOURCE_DIR}/include/Conversion/QUIRToPulse/ 20 | 21 | LINK_COMPONENTS 22 | Core 23 | 24 | LINK_LIBS PUBLIC 25 | MLIRIR 26 | MLIRComplexDialect 27 | MLIROQ3Dialect 28 | MLIRPulseDialect 29 | MLIRQUIRDialect 30 | ) 31 | -------------------------------------------------------------------------------- /lib/Conversion/QUIRToStandard/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_mlir_conversion_library(QUIRToStandard 14 | SwitchOpLowering.cpp 15 | TypeConversion.cpp 16 | VariablesToGlobalMemRefConversion.cpp 17 | 18 | ADDITIONAL_HEADER_DIRS 19 | ${PROJECT_SOURCE_DIR}/include/Conversion/QUIRToStandard/ 20 | 21 | LINK_COMPONENTS 22 | Core 23 | 24 | LINK_LIBS PUBLIC 25 | MLIRIR 26 | MLIRQUIRDialect 27 | ) 28 | -------------------------------------------------------------------------------- /lib/Dialect/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_subdirectory(OQ3) 14 | add_subdirectory(QUIR) 15 | add_subdirectory(Pulse) 16 | add_subdirectory(QCS) 17 | -------------------------------------------------------------------------------- /lib/Dialect/OQ3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # Any modifications or derivative works of this code must retain this 4 | # copyright notice, and modified files need to carry a notice indicating 5 | # that they have been altered from the originals. 6 | 7 | add_subdirectory(IR) 8 | add_subdirectory(Transforms) 9 | -------------------------------------------------------------------------------- /lib/Dialect/OQ3/IR/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # Any modifications or derivative works of this code must retain this 4 | # copyright notice, and modified files need to carry a notice indicating 5 | # that they have been altered from the originals. 6 | 7 | add_mlir_dialect_library(MLIROQ3Dialect 8 | OQ3Dialect.cpp 9 | OQ3Ops.cpp 10 | OQ3Patterns.cpp 11 | 12 | ADDITIONAL_HEADER_DIRS 13 | ${PROJECT_SOURCE_DIR}/include/OQ3 14 | 15 | DEPENDS 16 | MLIROQ3PatternsIncGen 17 | 18 | LINK_LIBS PUBLIC 19 | MLIRIR 20 | MLIRMathDialect 21 | ) 22 | -------------------------------------------------------------------------------- /lib/Dialect/OQ3/Transforms/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_mlir_dialect_library(MLIROQ3Transforms 14 | LimitCBitWidth.cpp 15 | Passes.cpp 16 | 17 | ADDITIONAL_HEADER_DIRS 18 | ${PROJECT_SOURCE_DIR}/include/OQ3 19 | 20 | DEPENDS 21 | MLIROQ3OpsIncGen 22 | 23 | LINK_LIBS PUBLIC 24 | MLIRIR 25 | ) 26 | -------------------------------------------------------------------------------- /lib/Dialect/OQ3/Transforms/Passes.cpp: -------------------------------------------------------------------------------- 1 | //===- Passes.cpp - OQ3 Passes ----------------------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | 17 | #include "Dialect/OQ3/Transforms/Passes.h" 18 | #include "Dialect/OQ3/Transforms/LimitCBitWidth.h" 19 | 20 | #include "mlir/Pass/PassManager.h" 21 | #include "mlir/Pass/PassRegistry.h" 22 | 23 | #include 24 | 25 | namespace mlir::oq3 { 26 | 27 | void oq3PassPipelineBuilder(OpPassManager &pm) { 28 | pm.addPass(std::make_unique()); 29 | } 30 | 31 | void registerOQ3Passes() { 32 | //===----------------------------------------------------------------------===// 33 | // Transform Passes 34 | //===----------------------------------------------------------------------===// 35 | PassRegistration(); 36 | } 37 | 38 | void registerOQ3PassPipeline() { 39 | PassPipelineRegistration<> const pipeline( 40 | "oq3Opt", "Enable OQ3-specific optimizations", oq3PassPipelineBuilder); 41 | } 42 | } // end namespace mlir::oq3 43 | -------------------------------------------------------------------------------- /lib/Dialect/Pulse/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_subdirectory(IR) 14 | add_subdirectory(Transforms) 15 | add_subdirectory(Utils) 16 | -------------------------------------------------------------------------------- /lib/Dialect/Pulse/IR/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_mlir_dialect_library(MLIRPulseDialect 14 | 15 | PulseAttributes.cpp 16 | PulseDialect.cpp 17 | PulseInterfaces.cpp 18 | PulseOps.cpp 19 | 20 | ADDITIONAL_HEADER_DIRS 21 | ${PROJECT_SOURCE_DIR}/include/Pulse 22 | 23 | DEPENDS 24 | MLIRPulseIncGen 25 | 26 | LINK_LIBS PUBLIC 27 | MLIRIR 28 | QSSCUtils 29 | ) 30 | -------------------------------------------------------------------------------- /lib/Dialect/Pulse/IR/PulseAttributes.cpp: -------------------------------------------------------------------------------- 1 | //===- PulseAttributes.cpp - Pulse dialect attributes -----------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | -------------------------------------------------------------------------------- /lib/Dialect/Pulse/Transforms/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_mlir_dialect_library(MLIRPulseTransforms 14 | ClassicalOnlyDetection.cpp 15 | InlineRegion.cpp 16 | LabelPlayOpDurations.cpp 17 | MergeDelays.cpp 18 | Passes.cpp 19 | RemoveUnusedArguments.cpp 20 | SchedulePort.cpp 21 | Scheduling.cpp 22 | ADDITIONAL_HEADER_DIRS 23 | ${PROJECT_SOURCE_DIR}/include/Pulse 24 | 25 | DEPENDS 26 | MLIRPulseIncGen 27 | 28 | LINK_LIBS PUBLIC 29 | MLIRIR 30 | QSSCUtils 31 | ) 32 | -------------------------------------------------------------------------------- /lib/Dialect/Pulse/Utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_mlir_dialect_library(MLIRPulseUtils 14 | 15 | Utils.cpp 16 | 17 | ADDITIONAL_HEADER_DIRS 18 | ${PROJECT_SOURCE_DIR}/include/Pulse 19 | 20 | DEPENDS 21 | MLIRPulseIncGen 22 | 23 | LINK_LIBS PUBLIC 24 | MLIRIR 25 | ) 26 | -------------------------------------------------------------------------------- /lib/Dialect/QCS/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_subdirectory(IR) 14 | add_subdirectory(Utils) 15 | -------------------------------------------------------------------------------- /lib/Dialect/QCS/IR/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_mlir_dialect_library(MLIRQCSDialect 14 | QCSDialect.cpp 15 | QCSOps.cpp 16 | 17 | ADDITIONAL_HEADER_DIRS 18 | ${PROJECT_SOURCE_DIR}/include/QCS 19 | 20 | LINK_LIBS PUBLIC 21 | MLIRIR 22 | ) 23 | -------------------------------------------------------------------------------- /lib/Dialect/QCS/Utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_mlir_dialect_library(MLIRQCSUtils 14 | ParameterInitialValueAnalysis.cpp 15 | 16 | ADDITIONAL_HEADER_DIRS 17 | ${PROJECT_SOURCE_DIR}/include/QCS 18 | 19 | DEPENDS 20 | MLIROQ3OpsIncGen 21 | 22 | LINK_LIBS PUBLIC 23 | MLIRIR 24 | ) 25 | -------------------------------------------------------------------------------- /lib/Dialect/QUIR/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_subdirectory(IR) 14 | add_subdirectory(Transforms) 15 | add_subdirectory(Utils) 16 | -------------------------------------------------------------------------------- /lib/Dialect/QUIR/IR/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_mlir_dialect_library(MLIRQUIRDialect 14 | QUIRAttributes.cpp 15 | QUIRDialect.cpp 16 | QUIRInterfaces.cpp 17 | QUIROps.cpp 18 | QUIRTestInterfaces.cpp 19 | 20 | ADDITIONAL_HEADER_DIRS 21 | ${PROJECT_SOURCE_DIR}/include/QUIR 22 | 23 | DEPENDS 24 | MLIRQUIRIncGen 25 | 26 | LINK_LIBS PUBLIC 27 | MLIRIR 28 | MLIRArithDialect 29 | MLIRLLVMDialect 30 | MLIRMathDialect 31 | MLIROQ3Dialect 32 | MLIRQCSDialect 33 | MLIRSCFDialect 34 | ) 35 | -------------------------------------------------------------------------------- /lib/Dialect/QUIR/Transforms/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023, 2024. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_mlir_dialect_library(MLIRQUIRTransforms 14 | Analysis.cpp 15 | AddShotLoop.cpp 16 | AngleConversion.cpp 17 | BreakReset.cpp 18 | ConvertDurationUnits.cpp 19 | ExtractCircuits.cpp 20 | FunctionArgumentSpecialization.cpp 21 | LoadElimination.cpp 22 | MergeCircuits.cpp 23 | MergeCircuitMeasures.cpp 24 | MergeMeasures.cpp 25 | MergeParallelResets.cpp 26 | Passes.cpp 27 | QuantumDecoration.cpp 28 | QUIRCircuitAnalysis.cpp 29 | RemoveQubitOperands.cpp 30 | RemoveUnusedCircuits.cpp 31 | ReorderMeasurements.cpp 32 | ReorderCircuits.cpp 33 | SubroutineCloning.cpp 34 | UnusedVariable.cpp 35 | VariableElimination.cpp 36 | 37 | ADDITIONAL_HEADER_DIRS 38 | ${PROJECT_SOURCE_DIR}/include/QUIR 39 | 40 | DEPENDS 41 | MLIRQUIRIncGen 42 | 43 | LINK_LIBS PUBLIC 44 | MLIRIR 45 | ) 46 | -------------------------------------------------------------------------------- /lib/Dialect/QUIR/Utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_mlir_dialect_library(MLIRQUIRUtils 14 | 15 | Utils.cpp 16 | 17 | ADDITIONAL_HEADER_DIRS 18 | ${PROJECT_SOURCE_DIR}/include/QUIR 19 | 20 | DEPENDS 21 | MLIRQUIRIncGen 22 | 23 | LINK_LIBS PUBLIC 24 | MLIRIR 25 | ) 26 | -------------------------------------------------------------------------------- /lib/Frontend/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_subdirectory(OpenQASM3) 14 | -------------------------------------------------------------------------------- /lib/Frontend/OpenQASM3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | ADD_LIBRARY(QSSCOpenQASM3Frontend OpenQASM3Frontend.cpp BaseQASM3Visitor.cpp PrintQASM3Visitor.cpp QUIRGenQASM3Visitor.cpp QUIRVariableBuilder.cpp) 14 | include_directories(${OPENQASM_INCLUDE_DIR}) 15 | include_directories(${PROJECT_SOURCE_DIR}/include) 16 | 17 | target_link_libraries(QSSCOpenQASM3Frontend 18 | qasm::qasm 19 | ) 20 | 21 | # enforce dependencies on QUIR tblgen generated headers 22 | add_dependencies(QSSCOpenQASM3Frontend MLIRQUIRDialect) 23 | -------------------------------------------------------------------------------- /lib/HAL/Compile/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | qssc_add_library(QSSCHALCompile 14 | TargetCompilationManager.cpp 15 | ThreadedCompilationManager.cpp 16 | 17 | ADDITIONAL_HEADER_DIRS 18 | ${QSSC_INCLUDE_DIR}/HAL/Compile 19 | 20 | LINK_LIBS 21 | QSSCHAL 22 | ) 23 | -------------------------------------------------------------------------------- /lib/HAL/PassRegistration.cpp: -------------------------------------------------------------------------------- 1 | //===- PassRegistration.cpp -------------------------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | 17 | #include "HAL/PassRegistration.h" 18 | #include "HAL/TargetSystemRegistry.h" 19 | 20 | #include "llvm/Support/Error.h" 21 | 22 | #include 23 | 24 | using namespace qssc; 25 | using namespace qssc::hal; 26 | 27 | llvm::Error hal::registerTargetPasses() { 28 | llvm::Error err = llvm::Error::success(); 29 | for (const auto &target : 30 | registry::TargetSystemRegistry::registeredPlugins()) { 31 | err = 32 | llvm::joinErrors(std::move(err), target.second.registerTargetPasses()); 33 | } 34 | return err; 35 | } 36 | 37 | llvm::Error hal::registerTargetPipelines() { 38 | llvm::Error err = llvm::Error::success(); 39 | for (const auto &target : 40 | registry::TargetSystemRegistry::registeredPlugins()) { 41 | err = llvm::joinErrors(std::move(err), 42 | target.second.registerTargetPassPipelines()); 43 | } 44 | return err; 45 | } 46 | -------------------------------------------------------------------------------- /lib/HAL/SystemConfiguration.cpp: -------------------------------------------------------------------------------- 1 | //===- SystemConfiguration.cpp - Config info --------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | // 17 | // This file implements the classes for config data 18 | // 19 | //===----------------------------------------------------------------------===// 20 | 21 | #include "HAL/SystemConfiguration.h" 22 | 23 | qssc::hal::SystemConfiguration::~SystemConfiguration() = default; 24 | -------------------------------------------------------------------------------- /lib/HAL/Targets.inc.in: -------------------------------------------------------------------------------- 1 | //===- Targets.inc - System Target Registry ---------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// !! This file is generated by CMake configure. !! 18 | /// 19 | /// It includes (quite literally) the registration headers of all QSS targets 20 | /// specified to CMake generate. 21 | /// 22 | //===----------------------------------------------------------------------===// 23 | @TARGET_REGISTRATION_INCLUDE_SECTION@ 24 | -------------------------------------------------------------------------------- /lib/Payload/Payloads.inc.in: -------------------------------------------------------------------------------- 1 | //===- Payloads.inc - Payload Registry -------------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // Any modifications or derivative works of this code must retain this 6 | // copyright notice, and modified files need to carry a notice indicating 7 | // that they have been altered from the originals. 8 | // 9 | //===----------------------------------------------------------------------===// 10 | /// 11 | /// !! This file is generated by CMake configure. !! 12 | /// 13 | /// It includes (quite literally) the registration headers of all QSS targets 14 | /// specified to CMake generate. 15 | /// 16 | //===----------------------------------------------------------------------===// 17 | @PAYLOAD_REGISTRATION_INCLUDE_SECTION@ 18 | -------------------------------------------------------------------------------- /lib/Payload/ZipPayload/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | set(QSSC_PAYLOAD_PATHS 14 | ${QSSC_PAYLOAD_PATHS} 15 | ${CMAKE_CURRENT_SOURCE_DIR} 16 | ) 17 | 18 | qssc_add_plugin(QSSCPayloadZip QSSC_PAYLOAD_PLUGIN 19 | PatchableZipPayload.cpp 20 | ZipPayload.cpp 21 | ZipUtil.cpp 22 | 23 | ADDITIONAL_HEADER_DIRS 24 | ${CMAKE_CURRENT_SOURCE_DIR} 25 | ${QSSC_INCLUDE_DIR}/Payload 26 | 27 | LINK_LIBS 28 | QSSCPayload 29 | libzip::zip 30 | 31 | PLUGIN_REGISTRATION_HEADERS 32 | ${CMAKE_CURRENT_SOURCE_DIR}/Payload.inc 33 | ) 34 | 35 | add_dependencies(QSSCPayloadZip mlir-headers) 36 | -------------------------------------------------------------------------------- /lib/Payload/ZipPayload/Payload.inc: -------------------------------------------------------------------------------- 1 | //===- Payload.inc - Mock payload registration ------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// This file defines static objects that register payloads 18 | /// with the QSS compiler core. 19 | /// 20 | //===----------------------------------------------------------------------===// 21 | 22 | #ifndef PAYLOAD_PAYLOAD_ZIPPAYLOAD_H 23 | #define PAYLOAD_PAYLOAD_ZIPPAYLOAD_H 24 | 25 | #include "ZipPayload.h" 26 | 27 | namespace qssc::payload { 28 | 29 | [[maybe_unused]] int registrar = init(); 30 | 31 | } // namespace qssc::payload 32 | 33 | #endif // PAYLOAD_PAYLOAD_ZIPPAYLOAD_H 34 | -------------------------------------------------------------------------------- /lib/Payload/ZipPayload/ZipUtil.h: -------------------------------------------------------------------------------- 1 | //===- ZipUtil.h ------------------------------------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | /// 17 | /// Declares the Zip Utilities 18 | /// 19 | //===----------------------------------------------------------------------===// 20 | 21 | #ifndef PAYLOAD_ZIPUTIL_H 22 | #define PAYLOAD_ZIPUTIL_H 23 | 24 | #include 25 | 26 | namespace qssc::payload { 27 | 28 | // read zip into buffer - buffer allocated in function 29 | char *read_zip_src_to_buffer(zip_source_t *zip_src, zip_int64_t &sz); 30 | 31 | } // namespace qssc::payload 32 | 33 | #endif // PAYLOAD_ZIPUTIL_H 34 | -------------------------------------------------------------------------------- /lib/Utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | set(SOURCES DebugIndent.cpp) 14 | 15 | add_library(QSSCUtils ${SOURCES}) 16 | target_link_libraries(QSSCUtils ${BOOST_LIBRARIES}) 17 | -------------------------------------------------------------------------------- /python_lib/MANIFEST.in: -------------------------------------------------------------------------------- 1 | graft qss_compiler 2 | prune qss_compiler/CMakeFiles/* 3 | global-exclude CMakeLists.txt 4 | global-exclude cmake_install.cmake 5 | -------------------------------------------------------------------------------- /python_lib/dummy.c: -------------------------------------------------------------------------------- 1 | //===- dummy.c ----------------------------------------------------*- C -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | // This distribution contains platform-specific C++ libraries, but they are not 17 | // built with distutils. We create a dummy Extension object so that distutils 18 | // knows to make the binary platform-specific. 19 | //===----------------------------------------------------------------------===// 20 | 21 | #include 22 | 23 | int main() { return 0; } 24 | 25 | void initdummy() {} 26 | -------------------------------------------------------------------------------- /python_lib/pyproject.toml.in: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = [ 3 | "setuptools>=40.6.0", 4 | "wheel", 5 | "setuptools_scm[toml]>=6.0,<8.0", 6 | ] 7 | build-backend = "setuptools.build_meta" 8 | 9 | [tool.setuptools_scm] 10 | write_to = "${CMAKE_CURRENT_BINARY_DIR}/qss_compiler/_version.py" 11 | root = "${CMAKE_SOURCE_DIR}" 12 | fallback_version = "${VERSION_STRING}" 13 | -------------------------------------------------------------------------------- /python_lib/qss_compiler/__init__.py: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | from ._version import version as __version__ # noqa: F401 13 | from .py_qssc import __doc__ # noqa: F401 14 | 15 | from .compile import ( # noqa: F401 16 | compile_file, 17 | compile_file_async, 18 | compile_str, 19 | compile_str_async, 20 | InputType, 21 | OutputType, 22 | CompileOptions, 23 | ) 24 | 25 | from .exceptions import ( # noqa: F401 26 | QSSCompilationFailure, 27 | QSSCompilerError, 28 | ) 29 | 30 | from .py_qssc import ( # noqa: F401 31 | Diagnostic, 32 | ErrorCategory, 33 | Severity, 34 | ) 35 | 36 | from .link import ( # noqa: F401 37 | link_file, 38 | LinkOptions, 39 | ) 40 | -------------------------------------------------------------------------------- /python_lib/qss_compiler/examples/SequenceEx.mlir: -------------------------------------------------------------------------------- 1 | module { 2 | pulse.sequence public @test() -> i1 { 3 | %c5_i32 = arith.constant 5 : i32 4 | %cst = arith.constant 2.500000e+00 : f64 5 | %cst_0 = arith.constant 0.000000e+00 : f64 6 | %0 = complex.create %cst, %cst_0 : complex 7 | %1 = pulse.const_waveform(%c5_i32, %0) : (i32, complex) -> !pulse.waveform 8 | %false = arith.constant false 9 | pulse.return %false : i1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /python_lib/qss_compiler/examples/parse.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | 4 | # (C) Copyright IBM 2024. 5 | # 6 | # This code is part of Qiskit. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http:#www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | 20 | import sys 21 | from qss_compiler.mlir.ir import Context, Module 22 | from qss_compiler.mlir.dialects import pulse, quir 23 | 24 | with Context() as ctx: 25 | pulse.pulse.register_dialect() 26 | quir.quir.register_dialect() 27 | 28 | with open(sys.argv[1]) as f: 29 | data = f.read() 30 | print(data) 31 | module = Module.parse(data) 32 | 33 | 34 | print(str(module)) 35 | -------------------------------------------------------------------------------- /python_lib/qss_compiler/lib_enums.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | namespace py = pybind11; 6 | 7 | void addErrorCategory(py::module &m); 8 | 9 | void addSeverity(py::module &m); 10 | 11 | void addDiagnostic(py::module &m); 12 | -------------------------------------------------------------------------------- /python_lib/qss_compiler/mlir/dialects/OQ3.pyi: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2024. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http:#www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | # based on llvm-project/mlir/python/mlir/_mlir_libs/_mlir/dialects/pdl.pyi 18 | 19 | from typing import Optional # noqa: F401 20 | 21 | from ..ir import Type, Context # noqa: F401 22 | 23 | __all__ = [] 24 | -------------------------------------------------------------------------------- /python_lib/qss_compiler/mlir/dialects/OQ3.td: -------------------------------------------------------------------------------- 1 | //===- OQ3.td - OQ3 dialect python includer ----------------*- tablegen -*-===// 2 | // 3 | // (C) Copyright IBM 2024. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef PYTHON_BINDINGS_OQ3_OPS 18 | #define PYTHON_BINDINGS_OQ3_OPS 19 | 20 | include "Dialect/OQ3/IR/OQ3Ops.td" 21 | 22 | #endif // PYTHON_BINDINGS_OQ3_OPS 23 | -------------------------------------------------------------------------------- /python_lib/qss_compiler/mlir/dialects/Pulse.td: -------------------------------------------------------------------------------- 1 | //===- Pulse.td - Pulse dialect python includer ------------*- tablegen -*-===// 2 | // 3 | // (C) Copyright IBM 2024. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef PYTHON_BINDINGS_PULSE_OPS 18 | #define PYTHON_BINDINGS_PULSE_OPS 19 | 20 | include "Dialect/Pulse/IR/Pulse.td" 21 | 22 | #endif // PYTHON_BINDINGS_PULSE_OPS 23 | -------------------------------------------------------------------------------- /python_lib/qss_compiler/mlir/dialects/QCS.pyi: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2024. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http:#www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | # based on llvm-project/mlir/python/mlir/_mlir_libs/_mlir/dialects/pdl.pyi 18 | 19 | from typing import Optional # noqa: F401 20 | 21 | from ..ir import Type, Context # noqa: F401 22 | 23 | __all__ = [] 24 | -------------------------------------------------------------------------------- /python_lib/qss_compiler/mlir/dialects/QCS.td: -------------------------------------------------------------------------------- 1 | //===- QCS.td - QCS dialect python includer ----------------*- tablegen -*-===// 2 | // 3 | // (C) Copyright IBM 2024. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef PYTHON_BINDINGS_QCS_OPS 18 | #define PYTHON_BINDINGS_QCS_OPS 19 | 20 | include "mlir/IR/OpBase.td" 21 | include "Dialect/QCS/IR/QCSBase.td" 22 | include "Dialect/QCS/IR/QCSOps.td" 23 | 24 | #endif // PYTHON_BINDINGS_QCS_OPS 25 | -------------------------------------------------------------------------------- /python_lib/qss_compiler/mlir/dialects/QUIR.td: -------------------------------------------------------------------------------- 1 | //===- QUIR.td - QUIR dialect python includer --------------*- tablegen -*-===// 2 | // 3 | // (C) Copyright IBM 2024. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef PYTHON_BINDINGS_QUIR_OPS 18 | #define PYTHON_BINDINGS_QUIR_OPS 19 | 20 | include "Dialect/QUIR/IR/QUIR.td" 21 | 22 | #endif // PYTHON_BINDINGS_QUIR_OPS 23 | -------------------------------------------------------------------------------- /python_lib/qss_compiler/mlir/dialects/_oq3_ops_ext.py: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2024. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http:#www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | try: 18 | from ..ir import * # noqa: F401, F403 19 | from .oq3 import * # noqa: F401, F403 20 | from .._mlir_libs._qeDialectsOQ3 import * # noqa: F401, F403 21 | from ._ods_common import ( # noqa: F401 22 | get_default_loc_context as _get_default_loc_context, 23 | ) 24 | 25 | from typing import Any, List, Optional, Union # noqa: F401 26 | except ImportError as e: 27 | raise RuntimeError("Error loading imports from extension module") from e 28 | -------------------------------------------------------------------------------- /python_lib/qss_compiler/mlir/dialects/_qcs_ops_ext.py: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2024. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http:#www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | try: 18 | from ..ir import * # noqa: F401, F403 19 | from ..ir import IntegerAttr, IntegerType, BoolAttr 20 | from .oq3 import * # noqa: F401, F403 21 | from .._mlir_libs._qeDialectsOQ3 import * # noqa: F401, F403 22 | from ._ods_common import ( # noqa: F401 23 | get_default_loc_context as _get_default_loc_context, 24 | ) 25 | 26 | from typing import Any, List, Optional, Union # noqa: F401 27 | except ImportError as e: 28 | raise RuntimeError("Error loading imports from extension module") from e 29 | 30 | 31 | class ShotInitOp: 32 | def __init__(self, numShots, *, startNCOs=False, loc=None, ip=None): 33 | super().__init__(loc=loc, ip=ip) 34 | self.attributes["qcs.numShots"] = IntegerAttr.get( 35 | IntegerType.get_signless(32), numShots 36 | ) # black/flake8 line length conflict 37 | self.attributes["quir.startNCOs"] = BoolAttr.get(startNCOs) 38 | -------------------------------------------------------------------------------- /python_lib/qss_compiler/mlir/dialects/oq3.py: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2024. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http:#www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | from ._oq3_ops_gen import * # noqa: F403, F401 18 | from .._mlir_libs._qeDialectsOQ3 import * # noqa: F403, F401 19 | 20 | from ..ir import UnitAttr # noqa: F403, F401 21 | from . import scf # noqa: F403, F401 22 | -------------------------------------------------------------------------------- /python_lib/qss_compiler/mlir/dialects/pulse.py: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2024. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http:#www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | from ._pulse_ops_gen import * # noqa: F403, F401 18 | from .._mlir_libs._qeDialectsPulse import * # noqa: F403, F401 19 | -------------------------------------------------------------------------------- /python_lib/qss_compiler/mlir/dialects/qcs.py: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2024. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http:#www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | from ._qcs_ops_gen import * # noqa: F403, F401 18 | from .._mlir_libs._qeDialectsQCS import * # noqa: F403, F401 19 | 20 | from ..ir import UnitAttr # noqa: F403, F401 21 | from . import scf # noqa: F403, F401 22 | -------------------------------------------------------------------------------- /python_lib/qss_compiler/mlir/dialects/quir.py: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2024. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http:#www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | from ._quir_ops_gen import * # noqa: F403, F401 18 | from .._mlir_libs._qeDialectsQUIR import * # noqa: F403, F401 19 | 20 | from ..ir import UnitAttr 21 | from . import scf 22 | 23 | 24 | class ShotLoop(scf.ForOp): 25 | def __init__(self, lb, ub, step): 26 | super().__init__(lb, ub, step) 27 | self.attributes["quir.shotLoop"] = UnitAttr.get() 28 | -------------------------------------------------------------------------------- /python_lib/qss_compiler/mlir/dialects/quir.pyi: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2024. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http:#www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | # based on llvm-project/mlir/python/mlir/_mlir_libs/_mlir/dialects/pdl.pyi 18 | 19 | from typing import Optional 20 | 21 | from ..ir import Type, Context 22 | 23 | __all__ = [ 24 | "AngleType", 25 | ] 26 | 27 | class AngleType(Type): 28 | @staticmethod 29 | def isinstance(type: Type) -> bool: ... 30 | @staticmethod 31 | def get(context: Optional[Context] = None) -> AngleType: ... 32 | -------------------------------------------------------------------------------- /python_lib/setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | name = qss-compiler 3 | version = file: VERSION.txt 4 | license = Apache License 2.0 5 | description = IBM Quantum System Software Compiler 6 | long_description = file: README.md 7 | long_description_content_type = text/markdown; charset=UTF-8 8 | url = https://github.com/Qiskit/qss-compiler 9 | author = IBM Quantum 10 | author_email = Thomas.A.Alexander@ibm.com 11 | classifiers = 12 | Programming Language :: Python :: 3 13 | Development Status :: 2 - Pre-Alpha 14 | Environment :: Console 15 | License :: OSI Approved :: Apache Software License 16 | Intended Audience :: Developers”” 17 | Intended Audience :: Science/Research 18 | Operating System :: MacOS :: MacOS X 19 | Operating System :: POSIX :: Linux 20 | Programming Language :: Python :: 3 :: Only 21 | Programming Language :: Python :: 3.7 22 | Programming Language :: Python :: 3.8 23 | Topic :: Scientific/Engineering 24 | 25 | [options] 26 | zip_safe = False 27 | include_package_data = True 28 | packages = find: 29 | python_requires = >=3.7 30 | 31 | [options.package_data] 32 | qss_compiler = *.so 33 | 34 | [options.packages.find] 35 | where = . 36 | include = * 37 | 38 | [options.extras_require] 39 | test = 40 | pytest 41 | 42 | is_pure=false 43 | 44 | [bdist_wheel] 45 | universal = 0 46 | 47 | [build_reno] 48 | output-file = RELEASENOTES.txt 49 | repo-root = ../ 50 | -------------------------------------------------------------------------------- /python_lib/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # (C) Copyright IBM 2023. 4 | # 5 | # This code is part of Qiskit. 6 | # 7 | # This code is licensed under the Apache License, Version 2.0 with LLVM 8 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | # file in the root directory of this source tree. 10 | # 11 | # Any modifications or derivative works of this code must retain this 12 | # copyright notice, and modified files need to carry a notice indicating 13 | # that they have been altered from the originals. 14 | 15 | """Setup module for Quantum System Software Compiler package.""" 16 | 17 | from setuptools import setup, Extension 18 | 19 | setup( 20 | # This distribution contains platform-specific C++ libraries, but they are not 21 | # built with distutils. We create a dummy Extension object so that distutils 22 | # knows to make the binary platform-specific. 23 | ext_modules=[Extension("dummy", sources=["dummy.c"])], 24 | ) 25 | -------------------------------------------------------------------------------- /qssc-activate.in: -------------------------------------------------------------------------------- 1 | # Use with "source qssc-activate" to prepare variables for build envronment. 2 | # Do not run it directly. 3 | 4 | qssc-deactivate() { 5 | # unset environment variables 6 | if [ -n "${QSSC_RESOURCES:-}" ]; then 7 | unset QSSC_RESOURCES 8 | fi 9 | unset -f qssc-deactivate 10 | } 11 | 12 | QSSC_RESOURCES="@QSSC_RESOURCES_OUTPUT_INTDIR@" 13 | export QSSC_RESOURCES 14 | -------------------------------------------------------------------------------- /releasenotes/config.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | encoding: utf8 3 | default_branch: main 4 | collapse_pre_releases: true 5 | branch_name_prefix: release/ 6 | branch_name_re: release/.+ 7 | -------------------------------------------------------------------------------- /releasenotes/notes/add-0f909e339cf09ae9.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | features: 3 | - | 4 | Adds CircuitBarrierCircuitPattern to MergeCircuitsPass to allow two call_circuit 5 | operations with barriers in between to be merged into one with the barriers 6 | inserted into the new circuit. 7 | -------------------------------------------------------------------------------- /releasenotes/notes/add-bitnot-support-7ad288e5a87b7302.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | fixes: 3 | - | 4 | Fixes failure to parse expressions with bitnot operation. Refer to 5 | `#278 ` for more 6 | details. 7 | -------------------------------------------------------------------------------- /releasenotes/notes/add-bytecode-support-c8c11ab44f93c659.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | features: 3 | - | 4 | Support for `MLIR Bytecode `_ has been 5 | added to the qe-compiler for both input and output to the CLI and C++/Python APIs. 6 | To take bytecode as input treat it as normal MLIR, the compiler will automatically 7 | detect if it is bytecode or the MLIR textual format. Bytecode input may be explicitly 8 | specified with ``./qss-compiler -X=bytecode ...``. 9 | To emit bytecode from the compiler ``./qss-compiler ... -o test.bc`` or 10 | ``./qss-compiler ... --emit bytecode -o file.bc`` 11 | - | 12 | The core qss-compiler compile API has been rewritten and refactored to align with 13 | MLIROptMain. This enables better forward compatiability and integration with 14 | MLIR bytecode through the compiler and its Python bindings. 15 | -------------------------------------------------------------------------------- /releasenotes/notes/add-compile-warnings-9e80ff424ff16342.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | other: 3 | - | 4 | Adds LLVM style compile warnings with the option to disable using conan install .. enable_warnings=False 5 | -------------------------------------------------------------------------------- /releasenotes/notes/add-contribution-guidelines-76301ef50bcf53ae.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | features: 3 | - | 4 | Contribution guidelines for the project have been added to `CONTRIBUTING.md `_ 5 | -------------------------------------------------------------------------------- /releasenotes/notes/add-extract-circuits-pass-72576158242077c6.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | features: 3 | - | 4 | Add new ExtractCircuitsPass. This pass will walk the main func and extract 5 | quantum operations into quir.circuits. It is intended to be run after all 6 | reordering and merging has been completed. The pass currently requires 7 | --enable-circuits=true in order to have effect. 8 | deprecations: 9 | - | 10 | Circuit formation during QUIRGen has been deprecated. This form of circuit 11 | generation is now controlled by the --enable-circuits-from-qasm command 12 | line option. 13 | -------------------------------------------------------------------------------- /releasenotes/notes/add-handling-for-two-qubit-gate-error-8a73c93f9cb47759.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | features: 3 | - | 4 | Add a new ErrorCategory of type QSSTargetUnsupportedOperation 5 | to handle non existing gate operation. 6 | -------------------------------------------------------------------------------- /releasenotes/notes/add-label-playop-duration-pass-2c79b1506b8b5854.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | other: 3 | - | 4 | Add LabelPlayOpsDurationPass to add a pulse.duration label to pulse.play 5 | operations based on the duration of the waveform being played. 6 | -------------------------------------------------------------------------------- /releasenotes/notes/add-max-threads-4073cc0b39df6d68.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | features: 3 | - | 4 | It is now possible to set the maximum number of threads for the MLIR context. 5 | This can be done through the CLI option ``--max-threads=`` or the 6 | environment variable ``export QSSC_MAX_THREADS=``. 7 | -------------------------------------------------------------------------------- /releasenotes/notes/add-merge-circuit-measures-e2b80378bf659793.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | fixes: 3 | - | 4 | Adds MergeCircuitMeasuresPass to replicate measurement merging performance 5 | when using circuits. 6 | -------------------------------------------------------------------------------- /releasenotes/notes/add-pre-commit-d2fca33ddaf13b35.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | features: 3 | - | 4 | Support for `pre-commit `_ has been added to the 5 | project. To install: 6 | 7 | pip install pre-commit 8 | pre-commit install 9 | 10 | To run on all files: 11 | 12 | pre-commit run --all-files 13 | -------------------------------------------------------------------------------- /releasenotes/notes/add-qssc-error-reporting-mechanisms-82fa32e30d30ccce.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | features: 3 | - | 4 | Added the ability to easily return QSSC diagnostics from the standard MLIR diagnostic mechanisms 5 | and callback handlers through easy to use helper methods. It is now possible to write code like: 6 | 7 | .. code-block:: cpp 8 | 9 | qssc::emitError(op, qssc::ErrorCategory::OpenQASM3UnsupportedInput) << "Error message \n"; 10 | 11 | The diagnostic will be treated like a normal MLIR diagnostic but will also encode the QSSC 12 | information to be decoded by the compiler's diagnostic handlers. 13 | -------------------------------------------------------------------------------- /releasenotes/notes/add-releasenotes-895d8791ff596b6d.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | features: 3 | - | 4 | Support for `reno release notes `_ has been added to the project. 5 | See the `contribution guidelines `_ 6 | for instructions on how to add a release note. 7 | -------------------------------------------------------------------------------- /releasenotes/notes/add-timing-manager-support-9de5e2407fc95330.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | features: 3 | - | 4 | Support has been added for LLVM 17's TimingManager to the qss-compiler 5 | tool. This includes support for timing integration in the TargetCompilationManager 6 | and targets themselves. This allows fine-grained tracking of compilation 7 | across targets and pass managers. 8 | -------------------------------------------------------------------------------- /releasenotes/notes/add-unsupported-openqasm3-input-a584bb990cd9c9ff.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | features: 3 | - | 4 | A new diagnostic has been added for unsupported OpenQASM 3 semantics - ``OpenQASM3UnsupportedInput``. 5 | This should be raised when the input OpenQASM 3 semantics are not valid for the compiler. 6 | -------------------------------------------------------------------------------- /releasenotes/notes/add_qeqem_output_type-54d1bdeff9f3b305.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | features: 3 | - | 4 | Support ``qe-qem`` emit action in python. This commit adds a new value of 5 | enumeration ``OutputType.QEQEM``. With this option. ``compile_str()`` can 6 | generate target-specific payloads. 7 | -------------------------------------------------------------------------------- /releasenotes/notes/control-system-resources-exceeded-error-d2a2c15c52fa02dd.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | features: 3 | - | 4 | A new QSSControlSystemResourcesExceeded error has been added as an error 5 | category. This can be raised as an error whenever the compiler detects that 6 | an input circuit will exceed the capabilities of the control system. 7 | -------------------------------------------------------------------------------- /releasenotes/notes/default-only-switch-64bb951256d7d2b5.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | fixes: 3 | - | 4 | Switch statements with only a default region will now correctly compile. 5 | -------------------------------------------------------------------------------- /releasenotes/notes/dialect-python-bindings-ab57b480118d6632.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | features: 3 | - | 4 | Python bindings for the compiler's custom dialects have been added, along 5 | with some examples of their usage. Full compatibility has not been 6 | accomplished yet, but this serves as a proof of concept for future 7 | enablement. 8 | -------------------------------------------------------------------------------- /releasenotes/notes/link-threading-d295374d01595205.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | features: 3 | - | 4 | Adds `number_of_threads` parameter to qss_compiler.link_file 5 | interface to control number of threads used during linking. 6 | -------------------------------------------------------------------------------- /releasenotes/notes/mixframe-scheduling-9f2a5e5ba922e6a0.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | features: 3 | - | 4 | Scheduling of a quantum circuit based on the availability of mix frames 5 | is added in order to reduce the overall duration of the scheduled pulse 6 | sequence compared to that of port-based scheduling. 7 | -------------------------------------------------------------------------------- /releasenotes/notes/optimize-greedy-rewrites-b042d4e824642f9a.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | features: 3 | - | 4 | The performance of the QUIRAngleConversionPass has been improved by a factor of 5 | ~8-10x by optimizing the greedy rewrite behaviour. 6 | - | 7 | Parallelize control flow improves by ~8-10x due to a quadratic scaling factor 8 | that was uncovered. 9 | -------------------------------------------------------------------------------- /releasenotes/notes/parallel-reset-bottom-up-traversal-0ad69d49e9d6e6e1.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | features: 3 | - | 4 | Parallel reset merging passes have been switched to a bottom up traversal 5 | as this is roughly 3x faster. 6 | -------------------------------------------------------------------------------- /releasenotes/notes/refactor_bind-ab3c07883604767b.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | upgrade: 3 | - | 4 | Allow target-specific parameter bindings when ``qe-qem`` is specified as 5 | an emit action. 6 | -------------------------------------------------------------------------------- /releasenotes/notes/remove-function-localization-d5caa312fcabb7b3.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | fixes: 3 | - | 4 | Remove function localization pass as this is not being used for any 5 | compilation features as was initially planned. 6 | -------------------------------------------------------------------------------- /releasenotes/notes/soo-ER-raise-OpenQASM3ParseFailure-7db973ddd38ece7e.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | features: 3 | - | 4 | Few of the failing test cases that raise the generic ``QSSCompilationFailure`` 5 | will now raise ``OpenQASM3ParseFailure`` when the parse returns an Error 6 | diagnostic. 7 | -------------------------------------------------------------------------------- /releasenotes/notes/support-arith-math-operations-f2f9280d24366383.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | features: 3 | - | 4 | Support has been added for the following OpenQASM 3 operations: 5 | 6 | * addition (*, *=) for integers and floats 7 | * subtraction (*, *=) for integers and floats 8 | * multiplication (*, *=) for integers and floats 9 | * division (*, *=) for integers and floats 10 | * modulo (*, *=) for integers and floats 11 | * power (**) for integers and floats 12 | * cos() for floats 13 | * sin() for floats 14 | * tan() for floats 15 | * atan() for floats 16 | * exp() for floats 17 | * ln() for floats 18 | * sqrt() for floats 19 | -------------------------------------------------------------------------------- /releasenotes/notes/support-barrier-in-quir-to-pulse-5eeadde1f85f0c0e.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | features: 3 | - | 4 | Support for handling quir.barriers is added to quirToPulse pass. 5 | -------------------------------------------------------------------------------- /releasenotes/notes/symbol-cache-analysis-e135ccc3fe625e2e.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | other: 3 | - | 4 | Adds SymbolCacheAnalysis for caching call to callee lookups in using an 5 | MLIR analysis. 6 | -------------------------------------------------------------------------------- /releasenotes/notes/symbol-cache-use-densemap-c178e05e59c41bbe.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | features: 3 | - | 4 | Symbol cache now uses llvm::DenseMap for performance reasons. 5 | -------------------------------------------------------------------------------- /releasenotes/notes/test-overlap-all-5d170626357867d6.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | fixes: 3 | - | 4 | Fixes bug related to assumption in MergeCircuitsPass that all quantum instructions 5 | are located in a quir.circuit when attempting to merge circuits. Applies the qubit overlap 6 | test to all quantum operations in between quir.call_circuit calls. 7 | -------------------------------------------------------------------------------- /releasenotes/notes/update-parameter-handling-cfa04a0bd7250401.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | features: 3 | - | 4 | Handling of ``qcs.parameter_load`` operations has been modified to be more direct 5 | with reads straight from the angle variables. This brings significant performance enhancements 6 | as a large number of MLIR operations have been removed. The consequence is that if an OpenQASM 3 7 | input parameter value is written to this value will not be dynamically resolved. This could be 8 | fixed in later versions of the compiler by using memref like semantics for parameters. 9 | fixes: 10 | - | 11 | Significant performance enhancements for both constant and parameter gate angles. 12 | -------------------------------------------------------------------------------- /releasenotes/notes/user-error-updates-3fe6706fbf8ffab8.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | features: 3 | - | 4 | User-facing diagnostics will now be collected from targets for forwarding 5 | to the python library. The python library will raise exceptions specific to 6 | user-facing diagnostics as appropriate. As an example, a new user diagnostic 7 | was added for jobs that are too long. 8 | -------------------------------------------------------------------------------- /releasenotes/notes/verbosity-added-215754a25363b046.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | features: 3 | - | 4 | Compiler output can now be controlled using the --verbosity flag or via the 5 | environment variable QSSC_VERBOSITY. 6 | -------------------------------------------------------------------------------- /requirements-dev.txt: -------------------------------------------------------------------------------- 1 | breathe 2 | cmake>=3.23 3 | conan==1.62.0 4 | dataclasses 5 | Jinja2==3.0.3 # https://github.com/sphinx-doc/sphinx/issues/10291 6 | lit>=12.0.0 7 | markupsafe==2.0.1 8 | myst-parser 9 | ninja>=1.10 10 | numpy 11 | pre-commit 12 | pybind11==2.11.1 13 | pytest 14 | pytest-asyncio 15 | setuptools_scm>=6.0,<8.0 16 | reno 17 | Sphinx>=4.0,<7.2 18 | sphinx-rtd-theme 19 | sphinx-sitemap 20 | -------------------------------------------------------------------------------- /targets/systems/mock/MockUtils.h: -------------------------------------------------------------------------------- 1 | //===- MockUtils.h ----------------------------------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | // 17 | // Declaration of utility functions for the Mock Target 18 | // 19 | //===----------------------------------------------------------------------===// 20 | 21 | #ifndef HAL_MOCKUTILS_H 22 | #define HAL_MOCKUTILS_H 23 | 24 | #include 25 | 26 | namespace mlir { 27 | class ModuleOp; 28 | } // end namespace mlir 29 | 30 | namespace qssc::targets::systems::mock { 31 | 32 | // Looks for and returns the Controller submodule if it exists 33 | // Returns nullptr otherwise 34 | auto getControllerModule(mlir::ModuleOp topModuleOp) -> mlir::ModuleOp; 35 | 36 | auto getActuatorModules(mlir::ModuleOp topModuleOp) 37 | -> std::vector; 38 | 39 | } // namespace qssc::targets::systems::mock 40 | 41 | #endif // HAL_MOCKUTILS_H 42 | -------------------------------------------------------------------------------- /targets/systems/mock/Target.inc: -------------------------------------------------------------------------------- 1 | //===- Target.inc - Mock target registration --------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | // 17 | // This file defines static objects that register system targets 18 | // with the QSS compiler core. 19 | // 20 | //===----------------------------------------------------------------------===// 21 | 22 | #ifndef HAL_TARGETS_MOCK_TARGET_H 23 | #define HAL_TARGETS_MOCK_TARGET_H 24 | 25 | #include "MockTarget.h" 26 | 27 | namespace qssc::targets::systems::mock { 28 | 29 | [[maybe_unused]] int registrar = init(); 30 | 31 | } // namespace qssc::targets::systems::mock 32 | 33 | #endif // HAL_TARGETS_MOCK_TARGET_H 34 | -------------------------------------------------------------------------------- /targets/systems/mock/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | qssc_add_lit_test_suite(check-mock 14 | "Mock Static" 15 | "${CMAKE_CURRENT_SOURCE_DIR}" 16 | "${LIT_TEST_EXTRA_ARGS} -v -DTEST_CFG=${CMAKE_CURRENT_SOURCE_DIR}/test.cfg" 17 | ) 18 | -------------------------------------------------------------------------------- /targets/systems/mock/test/lit.local.cfg.py: -------------------------------------------------------------------------------- 1 | # ===- lit.local.cfg.py --------------------------------------*- Python -*-===// 2 | # 3 | # (C) Copyright IBM 2023. 4 | # 5 | # This code is part of Qiskit. 6 | # 7 | # This code is licensed under the Apache License, Version 2.0 with LLVM 8 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | # file in the root directory of this source tree. 10 | # 11 | # Any modifications or derivative works of this code must retain this 12 | # copyright notice, and modified files need to carry a notice indicating 13 | # that they have been altered from the originals. 14 | # 15 | # ===----------------------------------------------------------------------===// 16 | 17 | # flake8: noqa 18 | 19 | config.substitutions.append(("%TEST_CFG", lit_config.params["TEST_CFG"])) 20 | -------------------------------------------------------------------------------- /targets/systems/mock/test/python_lib/pytest.ini: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | [pytest] 14 | asyncio_mode = strict 15 | -------------------------------------------------------------------------------- /targets/systems/mock/test/static/integration/mlir/bell-v0.mlir: -------------------------------------------------------------------------------- 1 | // RUN: qss-compiler %s --target mock --config %TEST_CFG --emit=qem --plaintext-payload | FileCheck %s 2 | // RUN: cat %s | qss-compiler --include-source -X mlir --target mock --config %TEST_CFG --emit=qem --plaintext-payload | FileCheck %s --match-full-lines --check-prefix CHECK-SOURCE 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | 15 | // CHECK: Manifest 16 | func.func @main () -> i32 { 17 | 18 | %q0 = quir.declare_qubit {id = 0 : i32} : !quir.qubit<1> 19 | %q1 = quir.declare_qubit {id = 1 : i32} : !quir.qubit<1> 20 | %a0 = quir.constant #quir.angle<1.57079632679> : !quir.angle<20> 21 | %a1 = quir.constant #quir.angle<0.0> : !quir.angle<20> 22 | %a2 = quir.constant #quir.angle<3.14159265359> : !quir.angle<20> 23 | quir.builtin_U %q0, %a0, %a1, %a2 : !quir.qubit<1>, !quir.angle<20>, !quir.angle<20>, !quir.angle<20> 24 | quir.builtin_CX %q0, %q1 : !quir.qubit<1>, !quir.qubit<1> 25 | %zero = arith.constant 0 : i32 26 | return %zero : i32 27 | } 28 | 29 | // CHECK-SOURCE: File: manifest/input.mlir 30 | -------------------------------------------------------------------------------- /targets/systems/mock/test/static/integration/openqasm3/bell-v0.qasm: -------------------------------------------------------------------------------- 1 | OPENQASM 3.0; 2 | // RUN: qss-compiler %s --target mock --config %TEST_CFG --emit=qem --plaintext-payload --enable-circuits-from-qasm=false | FileCheck %s 3 | 4 | // (C) Copyright IBM 2023, 2024. 5 | // 6 | // This code is part of Qiskit. 7 | // 8 | // This code is licensed under the Apache License, Version 2.0 with LLVM 9 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 10 | // file in the root directory of this source tree. 11 | // 12 | // Any modifications or derivative works of this code must retain this 13 | // copyright notice, and modified files need to carry a notice indicating 14 | // that they have been altered from the originals. 15 | 16 | // CHECK: Manifest 17 | // CHECK: MockAcquire_0.mlir 18 | // CHECK: MockController.mlir 19 | // CHECK: MockDrive_0.mlir 20 | // CHECK: MockDrive_1.mlir 21 | // CHECK: controller.bin 22 | // CHECK: llvmModule.ll 23 | qubit $0; 24 | qubit $1; 25 | 26 | gate cx control, target { } 27 | 28 | bit c0; 29 | bit c1; 30 | 31 | U(1.57079632679, 0.0, 3.14159265359) $0; 32 | cx $0, $1; 33 | measure $0 -> c0; 34 | measure $1 -> c1; 35 | -------------------------------------------------------------------------------- /targets/systems/mock/test/static/integration/openqasm3/example.qasm: -------------------------------------------------------------------------------- 1 | OPENQASM 3.0; 2 | // RUN: qss-compiler %s --target mock --config %TEST_CFG --emit=qem --plaintext-payload --enable-circuits-from-qasm=false| FileCheck %s 3 | // RUN: cat %s | qss-compiler --include-source -X=qasm --target mock --config %TEST_CFG --emit=qem --plaintext-payload --enable-circuits-from-qasm=false | FileCheck %s --match-full-lines --check-prefix CHECK-SOURCE 4 | 5 | // (C) Copyright IBM 2023, 2024. 6 | // 7 | // This code is part of Qiskit. 8 | // 9 | // This code is licensed under the Apache License, Version 2.0 with LLVM 10 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 11 | // file in the root directory of this source tree. 12 | // 13 | // Any modifications or derivative works of this code must retain this 14 | // copyright notice, and modified files need to carry a notice indicating 15 | // that they have been altered from the originals. 16 | 17 | // CHECK: Manifest 18 | 19 | qubit $0; 20 | bit c0; 21 | U(1.57079632679, 0.0, 3.14159265359) $0; 22 | measure $0 -> c0; 23 | 24 | // CHECK-SOURCE: manifest/input.qasm 25 | // CHECK-SOURCE: qubit $0; 26 | // CHECK-SOURCE: measure $0 -> c0; 27 | -------------------------------------------------------------------------------- /targets/systems/mock/test/static/integration/openqasm3/reset-v0.qasm: -------------------------------------------------------------------------------- 1 | OPENQASM 3.0; 2 | // RUN: qss-compiler %s --target mock --config %TEST_CFG --emit=qem --plaintext-payload | FileCheck %s 3 | 4 | // (C) Copyright IBM 2023. 5 | // 6 | // This code is part of Qiskit. 7 | // 8 | // This code is licensed under the Apache License, Version 2.0 with LLVM 9 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 10 | // file in the root directory of this source tree. 11 | // 12 | // Any modifications or derivative works of this code must retain this 13 | // copyright notice, and modified files need to carry a notice indicating 14 | // that they have been altered from the originals. 15 | 16 | // CHECK: Manifest 17 | qubit $0; 18 | reset $0; 19 | -------------------------------------------------------------------------------- /targets/systems/mock/test/test.cfg: -------------------------------------------------------------------------------- 1 | num_qubits 2 2 | acquire_multiplexing_ratio_to_1 5 3 | controllerNodeId 1000 4 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | enable_testing() 14 | 15 | # Configure core unit testing. 16 | add_subdirectory(unittest) 17 | 18 | # Target for all LIT testing. 19 | add_custom_target(check-qss-compiler COMMENT "Running LIT suites") 20 | 21 | # Target for all testing. 22 | add_custom_target(check-tests DEPENDS run-qss-compiler-unittests check-qss-compiler COMMENT "Running all tests") 23 | 24 | # Add QSS core LIT suite. 25 | qssc_add_lit_test_suite(check-qss-core "QSS Compiler Core" "${CMAKE_CURRENT_SOURCE_DIR}" "${LIT_TEST_EXTRA_ARGS}") 26 | 27 | # Add target LIT suites. 28 | foreach(lit_dir ${QSSC_TARGET_TEST_DIRS}) 29 | message(STATUS "Adding LIT directory: ${lit_dir}") 30 | add_subdirectory("${lit_dir}" "${CMAKE_CURRENT_BINARY_DIR}/Targets/${lit_dir}") 31 | endforeach() 32 | -------------------------------------------------------------------------------- /test/Config/test-config.tst: -------------------------------------------------------------------------------- 1 | // RUN: qss-compiler --target Mock --config path/to/config --allow-unregistered-dialect=false \ 2 | // RUN: --add-target-passes=false --verbosity=info --max-threads=5 --show-config - | FileCheck %s --check-prefix CLI 3 | // RUN: QSSC_TARGET_NAME="MockEnv" QSSC_TARGET_CONFIG_PATH="path/to/config/Env" QSSC_VERBOSITY=DEBUG QSSC_MAX_THREADS=10 \ 4 | // RUN: qss-compiler --allow-unregistered-dialect=false --add-target-passes=false --show-config - | FileCheck %s --check-prefix ENV 5 | // REQUIRES: !asserts 6 | 7 | // CLI: inputType: none 8 | // CLI: emitAction: mlir 9 | // CLI: targetName: Mock 10 | // CLI: targetConfigPath: path/to/config 11 | // CLI: verbosity: Info 12 | // CLI: addTargetPasses: 0 13 | // CLI: showTargets: 0 14 | // CLI: showPayloads: 0 15 | // CLI: showConfig: 1 16 | // CLI: payloadName: - 17 | // CLI: emitPlaintextPayload: 0 18 | // CLI: includeSource: 0 19 | // CLI: compileTargetIR: 0 20 | // CLI: bypassPayloadTargetCompilation: 0 21 | // CLI: maxThreads: 5 22 | 23 | // CLI: allowUnregisteredDialects: 0 24 | // CLI: dumpPassPipeline: 0 25 | // CLI: emitBytecode: 0 26 | // CLI: emitBytecodeVersion: None 27 | // CLI: irdlFile: 28 | // CLI: runReproducer: 0 29 | // CLI: showDialects: 0 30 | // CLI: splitInputFile: 0 31 | // CLI: useExplicitModule: 0 32 | // CLI: verifyDiagnostics: 0 33 | // CLI: verifyPasses: 0 34 | // CLI: verifyRoundTrip: 0 35 | 36 | // ENV: targetName: MockEnv 37 | // ENV: targetConfigPath: path/to/config/Env 38 | // ENV: verbosity: Debug 39 | // ENV: addTargetPasses: 0 40 | // ENV: maxThreads: 10 41 | // ENV: allowUnregisteredDialects: 0 42 | -------------------------------------------------------------------------------- /test/Conversion/QUIRToPulse/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openqasm/qe-compiler/2be58329623bdb8c01401dff06e40ba5aa22cc1e/test/Conversion/QUIRToPulse/.gitkeep -------------------------------------------------------------------------------- /test/Conversion/QUIRToStandard/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openqasm/qe-compiler/2be58329623bdb8c01401dff06e40ba5aa22cc1e/test/Conversion/QUIRToStandard/.gitkeep -------------------------------------------------------------------------------- /test/Dialect/OQ3/IR/fold-cbit-extractbit.mlir: -------------------------------------------------------------------------------- 1 | // RUN: qss-opt %s --canonicalize | qss-opt | FileCheck %s --implicit-check-not cbit_extractbit 2 | // Verify that all oq3.cbit_extractbit operations are eliminated 3 | 4 | // CHECK: func.func @single_bit(%[[ARG0:.*]]: i1) -> i1 { 5 | func.func @single_bit(%bit: i1) -> i1 { 6 | %2 = oq3.cbit_extractbit(%bit : i1) [0] : i1 7 | // CHECK: return %[[ARG0]] : i1 8 | return %2 : i1 9 | } 10 | 11 | // CHECK: func.func @two_bits(%[[ARG0:.*]]: !quir.cbit<2>, %[[ARG1:.*]]: i1, %[[ARG2:.*]]: i1) 12 | func.func @two_bits(%cbit: !quir.cbit<2>, %bit1: i1, %bit2: i1) -> i1 { 13 | %0 = oq3.cbit_insertbit(%cbit : !quir.cbit<2>)[0] = %bit1 : !quir.cbit<2> 14 | %1 = oq3.cbit_insertbit(%cbit : !quir.cbit<2>)[1] = %bit2 : !quir.cbit<2> 15 | 16 | %2 = oq3.cbit_extractbit(%1 : !quir.cbit<2>) [1] : i1 17 | // CHECK: return %[[ARG2]] : i1 18 | return %2 : i1 19 | } 20 | -------------------------------------------------------------------------------- /test/Dialect/OQ3/IR/ops.mlir: -------------------------------------------------------------------------------- 1 | // RUN: qss-opt %s | qss-opt | FileCheck %s 2 | // Verify the printed output can be parsed. 3 | // RUN: qss-opt %s --mlir-print-op-generic | qss-opt | FileCheck %s 4 | 5 | func.func @extract(%in: !quir.cbit<2>) -> i1 { 6 | // CHECK: oq3.cbit_extractbit(%arg0 : !quir.cbit<2>) [1] : i1 7 | %1 = oq3.cbit_extractbit(%in : !quir.cbit<2>) [1] : i1 8 | // CHECK: return %0 : i1 9 | return %1 : i1 10 | } 11 | 12 | func.func @insert(%cbit: !quir.cbit<2>, %bit :i1) -> !quir.cbit<2> { 13 | // CHECK: oq3.cbit_insertbit(%arg0 : !quir.cbit<2>) [0] = %arg1 : !quir.cbit<2> 14 | %1 = oq3.cbit_insertbit(%cbit : !quir.cbit<2>)[0] = %bit : !quir.cbit<2> 15 | // CHECK: return %0 : !quir.cbit<2> 16 | return %1 : !quir.cbit<2> 17 | } 18 | -------------------------------------------------------------------------------- /test/Dialect/QUIR/IR/canonicalization.mlir: -------------------------------------------------------------------------------- 1 | // RUN: qss-compiler -X=mlir --canonicalize %s | FileCheck %s 2 | 3 | // 4 | // This code is part of Qiskit. 5 | // 6 | // (C) Copyright IBM 2023. 7 | // 8 | // This code is licensed under the Apache License, Version 2.0 with LLVM 9 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 10 | // file in the root directory of this source tree. 11 | // 12 | // Any modifications or derivative works of this code must retain this 13 | // copyright notice, and modified files need to carry a notice indicating 14 | // that they have been altered from the originals. 15 | 16 | // CHECK: func.func @t1 17 | func.func @t1 (%arg1 : !quir.cbit<1>) -> (!quir.cbit<1>) { 18 | // CHECK: oq3.cbit_not %{{.*}} : !quir.cbit<1> 19 | // CHECK-NOT: oq3.cbit_not %{{.*}} : !quir.cbit<1> 20 | %c2 = oq3.cbit_not %arg1 : !quir.cbit<1> 21 | %c3 = oq3.cbit_not %c2 : !quir.cbit<1> 22 | %c4 = oq3.cbit_not %c3 : !quir.cbit<1> 23 | return %c4 : !quir.cbit<1> 24 | } 25 | 26 | // CHECK: func.func @t2 27 | func.func @t2 (%arg1 : !quir.cbit<1>) -> (!quir.cbit<1>) { 28 | // CHECK-NOT: oq3.cbit_not %{{.*}} : !quir.cbit<1> 29 | // CHECK-NOT: oq3.cbit_not %{{.*}} : !quir.cbit<1> 30 | %c2 = oq3.cbit_not %arg1 : !quir.cbit<1> 31 | %c3 = oq3.cbit_not %c2 : !quir.cbit<1> 32 | return %c3 : !quir.cbit<1> 33 | } 34 | 35 | // CHECK: func.func @t7 36 | func.func @t7 (%arg0 : i32, %arg1 : f32) -> (i32, f32) { 37 | %r1 = "oq3.cast"(%arg0) : (i32) -> i32 38 | %r2 = "oq3.cast"(%arg1) : (f32) -> f32 39 | // CHECK: return %arg0, %arg1 : i32, f32 40 | return %r1, %r2 : i32, f32 41 | } 42 | -------------------------------------------------------------------------------- /test/Dialect/QUIR/Transforms/add-shot-loop.mlir: -------------------------------------------------------------------------------- 1 | // RUN: qss-compiler -X=mlir --add-shot-loop %s | FileCheck %s 2 | 3 | // 4 | // This code is part of Qiskit. 5 | // 6 | // (C) Copyright IBM 2023. 7 | // 8 | // This code is licensed under the Apache License, Version 2.0 with LLVM 9 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 10 | // file in the root directory of this source tree. 11 | // 12 | // Any modifications or derivative works of this code must retain this 13 | // copyright notice, and modified files need to carry a notice indicating 14 | // that they have been altered from the originals. 15 | 16 | func.func @main() { 17 | qcs.init 18 | // CHECK: scf.for 19 | // CHECK: qcs.shot_init 20 | // CHECK: qcs.shot_loop 21 | qcs.finalize 22 | return 23 | } 24 | -------------------------------------------------------------------------------- /test/Dialect/QUIR/Transforms/break-reset-nested.mlir: -------------------------------------------------------------------------------- 1 | // RUN: qss-compiler -X=mlir --break-reset %s | FileCheck %s 2 | 3 | // 4 | // This code is part of Qiskit. 5 | // 6 | // (C) Copyright IBM 2023. 7 | // 8 | // This code is licensed under the Apache License, Version 2.0 with LLVM 9 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 10 | // file in the root directory of this source tree. 11 | // 12 | // Any modifications or derivative works of this code must retain this 13 | // copyright notice, and modified files need to carry a notice indicating 14 | // that they have been altered from the originals. 15 | 16 | // CHECK: scf.if %arg1 { 17 | // CHECK-NEXT: scf.if %arg2 { 18 | // CHECK-NEXT: %{{.*}} = quir.measure(%arg0) {quir.noReportRuntime} : (!quir.qubit<1>) -> i1 19 | // CHECK-NEXT: scf.if %0 { 20 | // CHECK-NEXT: quir.call_gate @x(%arg0) : (!quir.qubit<1>) -> () 21 | func.func @main (%inq : !quir.qubit<1>, %cond1 : i1, %cond2 : i1) { 22 | scf.if %cond1 { 23 | scf.if %cond2 { 24 | quir.reset %inq : !quir.qubit<1> 25 | } 26 | } 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /test/Dialect/QUIR/Transforms/convert-quir-angles.mlir: -------------------------------------------------------------------------------- 1 | // RUN: qss-compiler -X=mlir --convert-quir-angles %s | FileCheck %s 2 | 3 | // 4 | // This code is part of Qiskit. 5 | // 6 | // (C) Copyright IBM 2023. 7 | // 8 | // This code is licensed under the Apache License, Version 2.0 with LLVM 9 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 10 | // file in the root directory of this source tree. 11 | // 12 | // Any modifications or derivative works of this code must retain this 13 | // copyright notice, and modified files need to carry a notice indicating 14 | // that they have been altered from the originals. 15 | 16 | module { 17 | func.func @rz(%arg0: !quir.qubit<1>, %arg1: !quir.angle<64>) { 18 | return 19 | } 20 | func.func @main() -> i32 { 21 | %c0_i32 = arith.constant 0 : i32 22 | %0 = quir.declare_qubit {id = 2 : i32} : !quir.qubit<1> 23 | // CHECK: {{.*}} = quir.constant #quir.angle<0.000000e+00> : !quir.angle<64> 24 | %1 = quir.constant #quir.angle<0.000000e+00> : !quir.angle<32> 25 | quir.call_gate @rz(%0, %1) : (!quir.qubit<1>, !quir.angle<32>) -> () 26 | qcs.finalize 27 | return %c0_i32 : i32 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /test/Dialect/QUIR/Transforms/for-localization.mlir: -------------------------------------------------------------------------------- 1 | // RUN: qss-compiler -X=mlir --classical-only-detection %s | FileCheck %s 2 | 3 | // 4 | // This code is part of Qiskit. 5 | // 6 | // (C) Copyright IBM 2023. 7 | // 8 | // This code is licensed under the Apache License, Version 2.0 with LLVM 9 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 10 | // file in the root directory of this source tree. 11 | // 12 | // Any modifications or derivative works of this code must retain this 13 | // copyright notice, and modified files need to carry a notice indicating 14 | // that they have been altered from the originals. 15 | 16 | %q1 = quir.declare_qubit {id = 1 : i32} : !quir.qubit<1> 17 | %ang = quir.constant #quir.angle<0.00> : !quir.angle<20> 18 | %ang_incr = quir.constant #quir.angle<0.1> : !quir.angle<20> 19 | %lb = arith.constant 0 : index 20 | %ub = arith.constant 10 : index 21 | %step = arith.constant 1 : index 22 | // CHECK: %{{.*}} = scf.for %{{.*}} = %{{.*}} to %{{.*}} step %{{.*}} iter_args(%{{.*}} = %{{.*}}) -> (!quir.angle<20>) 23 | %ang_final = scf.for %iv = %lb to %ub step %step 24 | iter_args(%ang_iter = %ang) -> (!quir.angle<20>) { 25 | quir.call_gate @RX(%q1, %ang_iter) : (!quir.qubit<1>, !quir.angle<20>) -> () 26 | %ang_sum = oq3.angle_add %ang_iter, %ang_incr : !quir.angle<20> 27 | scf.yield %ang_sum : !quir.angle<20> 28 | } 29 | -------------------------------------------------------------------------------- /test/Dialect/QUIR/Transforms/merge-measurements-circuits.mlir: -------------------------------------------------------------------------------- 1 | // RUN: qss-compiler -X=mlir --enable-circuits=true --subroutine-cloning --merge-measures-topological %s | FileCheck %s 2 | 3 | // 4 | // This code is part of Qiskit. 5 | // 6 | // (C) Copyright IBM 2023. 7 | // 8 | // This code is licensed under the Apache License, Version 2.0 with LLVM 9 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 10 | // file in the root directory of this source tree. 11 | // 12 | // Any modifications or derivative works of this code must retain this 13 | // copyright notice, and modified files need to carry a notice indicating 14 | // that they have been altered from the originals. 15 | 16 | 17 | module { 18 | quir.circuit @circuit_0(%arg0: !quir.qubit<1>, %arg1: !quir.qubit<1>) -> (i1, i1) { 19 | %0 = quir.measure(%arg0) : (!quir.qubit<1>) -> i1 20 | %1 = quir.measure(%arg1) : (!quir.qubit<1>) -> i1 21 | quir.return %0, %1: i1, i1 22 | // CHECK: [[MEASURE:%.*]]:2 = quir.measure(%arg0, %arg1) : (!quir.qubit<1>, !quir.qubit<1>) -> (i1, i1) 23 | // CHECK: quir.return [[MEASURE]]#0, [[MEASURE]]#1 : i1, i1 24 | } 25 | func.func @main() -> i32 { 26 | %0 = quir.declare_qubit {id = 0 : i32} : !quir.qubit<1> 27 | %1 = quir.declare_qubit {id = 1 : i32} : !quir.qubit<1> 28 | %2:2 = quir.call_circuit @circuit_0(%0, %1) : (!quir.qubit<1>, !quir.qubit<1>) -> (i1, i1) 29 | %c0_i32 = arith.constant 0 : i32 30 | return %c0_i32 : i32 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /test/Dialect/QUIR/integration/measure-reset.mlir: -------------------------------------------------------------------------------- 1 | // RUN: qss-compiler -X=mlir %s | FileCheck %s 2 | 3 | // 4 | // This code is part of Qiskit. 5 | // 6 | // (C) Copyright IBM 2023. 7 | // 8 | // This code is licensed under the Apache License, Version 2.0 with LLVM 9 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 10 | // file in the root directory of this source tree. 11 | // 12 | // Any modifications or derivative works of this code must retain this 13 | // copyright notice, and modified files need to carry a notice indicating 14 | // that they have been altered from the originals. 15 | 16 | module { 17 | func.func @bar() { 18 | %0 = arith.constant 1 : i32 19 | // CHECK: %{{.*}} = quir.declare_qubit : !quir.qubit<1> 20 | %qa1 = quir.declare_qubit : !quir.qubit<1> 21 | %qb1 = quir.declare_qubit : !quir.qubit<1> 22 | %qc1 = quir.declare_qubit : !quir.qubit<1> 23 | // CHECK: quir.reset %{{.*}} : !quir.qubit<1> 24 | quir.reset %qa1 : !quir.qubit<1> 25 | quir.reset %qb1 : !quir.qubit<1> 26 | quir.reset %qc1 : !quir.qubit<1> 27 | // CHECK: quir.measure(%{{.*}}) : (!quir.qubit<1>) -> i1 28 | %res1 = "quir.measure"(%qb1) : (!quir.qubit<1>) -> i1 29 | // SYNCH: quir.measure(%{{.*}}) : (!quir.qubit<1>) -> i1 30 | // SYNCH-NEXT: qcs.synchronize %{{.*}} : (!quir.qubit<1>) -> () 31 | return 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /test/Dialect/QUIR/integration/qasm-reset-v0.mlir: -------------------------------------------------------------------------------- 1 | // RUN: qss-compiler -X=mlir %s | FileCheck %s 2 | 3 | // 4 | // This code is part of Qiskit. 5 | // 6 | // (C) Copyright IBM 2023. 7 | // 8 | // This code is licensed under the Apache License, Version 2.0 with LLVM 9 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 10 | // file in the root directory of this source tree. 11 | // 12 | // Any modifications or derivative works of this code must retain this 13 | // copyright notice, and modified files need to carry a notice indicating 14 | // that they have been altered from the originals. 15 | 16 | // CHECK: %{{.*}} = quir.declare_qubit {id = 0 : i32} : !quir.qubit<1> 17 | %q0 = quir.declare_qubit {id = 0 : i32} : !quir.qubit<1> 18 | // CHECK: quir.reset %{{.*}} : !quir.qubit<1> 19 | quir.reset %q0 : !quir.qubit<1> 20 | -------------------------------------------------------------------------------- /test/Dialect/QUIR/integration/qasm-reset-v0b.mlir: -------------------------------------------------------------------------------- 1 | // RUN: qss-compiler -X=mlir %s | FileCheck %s 2 | 3 | // 4 | // This code is part of Qiskit. 5 | // 6 | // (C) Copyright IBM 2023. 7 | // 8 | // This code is licensed under the Apache License, Version 2.0 with LLVM 9 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 10 | // file in the root directory of this source tree. 11 | // 12 | // Any modifications or derivative works of this code must retain this 13 | // copyright notice, and modified files need to carry a notice indicating 14 | // that they have been altered from the originals. 15 | 16 | // CHECK: %{{.*}} = quir.declare_qubit {id = 0 : i32} : !quir.qubit<1> 17 | %q0 = quir.declare_qubit {id = 0 : i32} : !quir.qubit<1> 18 | %q1 = quir.declare_qubit {id = 1 : i32} : !quir.qubit<1> 19 | // CHECK: quir.reset %{{.*}} : !quir.qubit<1> 20 | quir.reset %q0 : !quir.qubit<1> 21 | quir.reset %q1 : !quir.qubit<1> 22 | -------------------------------------------------------------------------------- /test/Dialect/QUIR/integration/qasm-reset-v1.mlir: -------------------------------------------------------------------------------- 1 | // RUN: qss-compiler -X=mlir %s | FileCheck %s 2 | 3 | // 4 | // This code is part of Qiskit. 5 | // 6 | // (C) Copyright IBM 2023. 7 | // 8 | // This code is licensed under the Apache License, Version 2.0 with LLVM 9 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 10 | // file in the root directory of this source tree. 11 | // 12 | // Any modifications or derivative works of this code must retain this 13 | // copyright notice, and modified files need to carry a notice indicating 14 | // that they have been altered from the originals. 15 | 16 | func.func @main () -> i32 { 17 | // CHECK: %{{.*}} = quir.declare_qubit {id = 0 : i32} : !quir.qubit<1> 18 | // qubit %0; 19 | %q0 = quir.declare_qubit {id = 0 : i32} : !quir.qubit<1> 20 | // result = measure %0; 21 | %zero_ind = arith.constant 0 : index 22 | %mres = "quir.measure"(%q0) : (!quir.qubit<1>) -> i1 23 | // if (result) { 24 | scf.if %mres { 25 | // U(pi, 0, pi) %0; 26 | %zero_ang = quir.constant #quir.angle<0.0> : !quir.angle<20> 27 | %pi_ang = quir.constant #quir.angle<3.14159> : !quir.angle<20> 28 | quir.builtin_U %q0, %pi_ang, %zero_ang, %pi_ang : !quir.qubit<1>, !quir.angle<20>, !quir.angle<20>, !quir.angle<20> 29 | } 30 | %bigfloat = arith.constant 1.0 : f64 31 | %smallfloat = arith.constant 0.5 : f32 32 | %zero = arith.constant 0 : i32 33 | return %zero : i32 34 | } 35 | -------------------------------------------------------------------------------- /test/Dialect/QUIR/integration/qasm-reset-v1b.mlir: -------------------------------------------------------------------------------- 1 | // RUN: qss-compiler -X=mlir %s | FileCheck %s 2 | 3 | // 4 | // This code is part of Qiskit. 5 | // 6 | // (C) Copyright IBM 2023. 7 | // 8 | // This code is licensed under the Apache License, Version 2.0 with LLVM 9 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 10 | // file in the root directory of this source tree. 11 | // 12 | // Any modifications or derivative works of this code must retain this 13 | // copyright notice, and modified files need to carry a notice indicating 14 | // that they have been altered from the originals. 15 | 16 | func.func @main () -> i32 { 17 | // CHECK: %{{.*}} = quir.declare_qubit {id = 0 : i32} : !quir.qubit<1> 18 | // qubit %0; 19 | %q0 = quir.declare_qubit {id = 0 : i32} : !quir.qubit<1> 20 | // result = measure %0; 21 | %zero_ind = arith.constant 0 : index 22 | %mres = "quir.measure"(%q0) : (!quir.qubit<1>) -> i1 23 | // if (result==1) { 24 | %one_i1 = arith.constant 1 : i1 25 | %condition = arith.cmpi "eq", %mres, %one_i1 : i1 26 | scf.if %condition { 27 | // U(pi, 0, pi) %0; 28 | %zero_ang = quir.constant #quir.angle<0.0> : !quir.angle<20> 29 | %pi_ang = quir.constant #quir.angle<3.14159> : !quir.angle<20> 30 | quir.builtin_U %q0, %pi_ang, %zero_ang, %pi_ang : !quir.qubit<1>, !quir.angle<20>, !quir.angle<20>, !quir.angle<20> 31 | } 32 | %zero = arith.constant 0 : i32 33 | return %zero : i32 34 | } 35 | -------------------------------------------------------------------------------- /test/Frontend/OpenQASM3/barrier.qasm: -------------------------------------------------------------------------------- 1 | OPENQASM 3.0; 2 | // RUN: qss-compiler -X=qasm --emit=mlir %s | FileCheck %s --match-full-lines --check-prefix MLIR 3 | 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // (C) Copyright IBM 2023. 8 | // 9 | // This code is licensed under the Apache License, Version 2.0 with LLVM 10 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 11 | // file in the root directory of this source tree. 12 | // 13 | // Any modifications or derivative works of this code must retain this 14 | // copyright notice, and modified files need to carry a notice indicating 15 | // that they have been altered from the originals. 16 | 17 | qubit $0; 18 | qubit $1; 19 | // MLIR: quir.barrier %{{.*}} : (!quir.qubit<1>) -> () 20 | barrier $0; 21 | // MLIR: quir.barrier %{{.*}}, %{{.*}} : (!quir.qubit<1>, !quir.qubit<1>) -> () 22 | barrier $0, $1; 23 | -------------------------------------------------------------------------------- /test/Frontend/OpenQASM3/bit-int-compare.qasm: -------------------------------------------------------------------------------- 1 | OPENQASM 3.0; 2 | // RUN: qss-compiler --num-shots=1 %s | FileCheck %s 3 | // 4 | // Test implicit bit to int cast in comparisons. 5 | 6 | // 7 | // This code is part of Qiskit. 8 | // 9 | // (C) Copyright IBM 2023. 10 | // 11 | // This code is licensed under the Apache License, Version 2.0 with LLVM 12 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 13 | // file in the root directory of this source tree. 14 | // 15 | // Any modifications or derivative works of this code must retain this 16 | // copyright notice, and modified files need to carry a notice indicating 17 | // that they have been altered from the originals. 18 | 19 | qubit $0; 20 | 21 | bit[5] a = "10101"; 22 | 23 | gate x q0 { 24 | U(3.14159265359, 0.0, 3.14159265359) q0; 25 | } 26 | 27 | x $0; 28 | 29 | // Test implicit cast of bit[n] to int 30 | // CHECK: %{{.*}} = arith.constant 21 : i32 31 | // CHECK-NEXT: %{{.*}} = "oq3.cast"(%{{.*}}) : (!quir.cbit<5>) -> i32 32 | // CHECK-NEXT: %{{.*}} = arith.cmpi eq, %{{.*}}, %{{.*}} : i32 33 | if(a == 21){ 34 | x $0; 35 | } 36 | -------------------------------------------------------------------------------- /test/Frontend/OpenQASM3/bitops2.qasm: -------------------------------------------------------------------------------- 1 | OPENQASM 3.0; 2 | // RUN: qss-compiler -X=qasm --emit=ast-pretty %s | FileCheck %s --check-prefix AST-PRETTY 3 | // RUN: qss-compiler -X=qasm --emit=mlir %s | FileCheck %s --check-prefix MLIR 4 | 5 | // 6 | // This code is part of Qiskit. 7 | // 8 | // (C) Copyright IBM 2023. 9 | // 10 | // This code is licensed under the Apache License, Version 2.0 with LLVM 11 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 12 | // file in the root directory of this source tree. 13 | // 14 | // Any modifications or derivative works of this code must retain this 15 | // copyright notice, and modified files need to carry a notice indicating 16 | // that they have been altered from the originals. 17 | 18 | // MLIR: module 19 | // MLIR: func.func @main 20 | 21 | // AST-PRETTY: DeclarationNode(type=ASTTypeQubitContainer 22 | qubit $0; 23 | 24 | gate x q0 { 25 | U(3.14159265359, 0.0, 3.14159265359) q0; 26 | } 27 | 28 | x $0; 29 | 30 | bit a; 31 | bit b = 0; 32 | 33 | a = measure $0; // expected "1" 34 | 35 | if (a == 1) { 36 | // expected branch 37 | b = 1; 38 | } 39 | 40 | if (b == 0) { 41 | // expected not to happen 42 | x $0; 43 | } 44 | 45 | b = measure $0; // expected "1" 46 | 47 | // on hardware, expect to measure "11" 48 | 49 | // previously, this code failed to compile while lowering the comparison in 50 | // second if condition 51 | -------------------------------------------------------------------------------- /test/Frontend/OpenQASM3/builtin-constants.qasm: -------------------------------------------------------------------------------- 1 | OPENQASM 3.0; 2 | // RUN: qss-compiler -X=qasm --emit=ast %s 3 | // 4 | // This test case validates OpenQASM 3's builtin constants pi, tau, and euler. 5 | 6 | // 7 | // This code is part of Qiskit. 8 | // 9 | // (C) Copyright IBM 2023. 10 | // 11 | // This code is licensed under the Apache License, Version 2.0 with LLVM 12 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 13 | // file in the root directory of this source tree. 14 | // 15 | // Any modifications or derivative works of this code must retain this 16 | // copyright notice, and modified files need to carry a notice indicating 17 | // that they have been altered from the originals. 18 | 19 | qubit $0; 20 | 21 | U(pi, pi / 2, euler) $0; 22 | 23 | angle[3] a = euler; 24 | 25 | U(π, τ, ε) $0; 26 | 27 | U(1.5 * π, τ / 2, 1.5 * ε) $0; 28 | 29 | 30 | // gate declarations 31 | gate phase(lambda) q { 32 | U(0, 0, lambda) q; 33 | } 34 | 35 | phase(1.8125 * pi) $0; 36 | phase(1.8125 * π) $0; 37 | 38 | phase(0.4 * tau) $0; 39 | phase(0.4 * τ) $0; 40 | 41 | phase(1.5 * euler) $0; 42 | phase(1.5 * ε) $0; 43 | 44 | angle phi = 1.5 * π + τ / 2 - 1.5 * ε; 45 | -------------------------------------------------------------------------------- /test/Frontend/OpenQASM3/diagnostics-parse-error.qasm: -------------------------------------------------------------------------------- 1 | OPENQASM 3.0; 2 | // Ensure piping of input also works with diagnostics. 3 | // TODO: Once https://github.com/openqasm/qe-qasm/issues/35 4 | // is fixed this test will error and the workaround 5 | // in OpenQASM3Frontend.cpp for line number offsets 6 | // will need to be removed for the test to pass. 7 | // RUN: cat %s | ( qss-compiler -X=qasm --emit=mlir || true ) 2>&1 | FileCheck %s 8 | // RUN: ( qss-compiler -X=qasm --emit=mlir %s || true ) 2>&1 | FileCheck %s 9 | 10 | int a; 11 | int b; 12 | 13 | a &&& b; 14 | // CHECK: 13:5: error: syntax error, unexpected '&' 15 | // CHECK: a &&& b; 16 | // CHECK: ^ 17 | -------------------------------------------------------------------------------- /test/Frontend/OpenQASM3/diagnostics-unsupported-error.qasm: -------------------------------------------------------------------------------- 1 | OPENQASM 3.0; 2 | // Ensure piping of input also works with diagnostics. 3 | // TODO: Once https://github.com/openqasm/qe-qasm/issues/35 4 | // is fixed this test will error and the workaround 5 | // in QUIRGenQASM3Visitor.cpp 6 | // for line number offsets 7 | // will need to be removed for the test to pass. 8 | // RUN: cat %s | ( qss-compiler -X=qasm --emit=mlir || true ) 2>&1 | FileCheck %s 9 | // RUN: ( qss-compiler -X=qasm --emit=mlir %s || true ) 2>&1 | FileCheck %s 10 | 11 | int a; 12 | float b; 13 | int c; 14 | c = float(a) + b; 15 | 16 | // CHECK: error: Unsupported cast destination type ASTTypeFloat 17 | // CHECK: c = float(a) + b; 18 | // CHECK: ^ 19 | // CHECK: error: Addition is not supported on value of type: 'none' 20 | // CHECK: c = float(a) + b; 21 | // CHECK: ^ 22 | -------------------------------------------------------------------------------- /test/Frontend/OpenQASM3/main.qasm: -------------------------------------------------------------------------------- 1 | OPENQASM 3.0; 2 | // RUN: qss-compiler -X=qasm --emit=mlir %s | FileCheck %s --match-full-lines --check-prefix MLIR 3 | 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // (C) Copyright IBM 2023. 8 | // 9 | // This code is licensed under the Apache License, Version 2.0 with LLVM 10 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 11 | // file in the root directory of this source tree. 12 | // 13 | // Any modifications or derivative works of this code must retain this 14 | // copyright notice, and modified files need to carry a notice indicating 15 | // that they have been altered from the originals. 16 | 17 | // MLIR: module { 18 | // MLIR: func.func @main() -> i32 { 19 | 20 | qubit $0; 21 | 22 | // MLIR: return %c0_i32 : i32 23 | -------------------------------------------------------------------------------- /test/Frontend/OpenQASM3/mixed-param-subroutines.qasm: -------------------------------------------------------------------------------- 1 | // RUN: qss-compiler -X=qasm --emit=ast-pretty %s | FileCheck %s --match-full-lines --check-prefix AST-PRETTY 2 | OPENQASM 3.0; 3 | 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // (C) Copyright IBM 2023. 8 | // 9 | // This code is licensed under the Apache License, Version 2.0 with LLVM 10 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 11 | // file in the root directory of this source tree. 12 | // 13 | // Any modifications or derivative works of this code must retain this 14 | // copyright notice, and modified files need to carry a notice indicating 15 | // that they have been altered from the originals. 16 | 17 | // AST-PRETTY: DeclarationNode(type=ASTTypeFunctionDeclaration, FunctionDeclarationNode(FunctionDefinitionNode(name=mixed_params, mangled name=_QF12mixed_paramsFrB1EFp0_II32_1iEFp1_QC1_1qEE_, 18 | // AST-PRETTY: parameters=[DeclarationNode(type=ASTTypeMPInteger, IdentifierNode(name=i, bits=32)) 19 | // AST-PRETTY: DeclarationNode(type=ASTTypeQubitContainer, IdentifierNode(name=q, bits=1)) 20 | // AST-PRETTY: ], 21 | // AST-PRETTY: results=ResultNode(CBitNode(name=bitset, bits=1)) 22 | // AST-PRETTY: statements=[ 23 | // AST-PRETTY: ReturnNode(MeasureNode(qubits=[QubitContainerNode(QubitNode(name=%q:0, bits=1))], result=CBitNode(name=ast-measure-result-{{.*}}, bits=1)) 24 | // AST-PRETTY: )]) 25 | 26 | def mixed_params(int[32] i, qubit q) -> bit { 27 | return measure q; 28 | } 29 | -------------------------------------------------------------------------------- /test/Frontend/OpenQASM3/qasm-version-sring.qasm: -------------------------------------------------------------------------------- 1 | OPENQASM 3; 2 | 3 | // RUN: qss-compiler -X=qasm --emit=mlir %s 4 | 5 | // 6 | // This code is part of Qiskit. 7 | // 8 | // (C) Copyright IBM 2023. 9 | // 10 | // This code is licensed under the Apache License, Version 2.0 with LLVM 11 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 12 | // file in the root directory of this source tree. 13 | // 14 | // Any modifications or derivative works of this code must retain this 15 | // copyright notice, and modified files need to carry a notice indicating 16 | // that they have been altered from the originals. 17 | 18 | // Error parsing the OPENQASM line directive. 19 | // OPENQASM3; 20 | -------------------------------------------------------------------------------- /test/Frontend/OpenQASM3/quantum-subroutines.qasm: -------------------------------------------------------------------------------- 1 | // RUN: qss-compiler -X=qasm --emit=ast-pretty %s | FileCheck %s --match-full-lines --check-prefix AST-PRETTY 2 | OPENQASM 3.0; 3 | 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // (C) Copyright IBM 2023. 8 | // 9 | // This code is licensed under the Apache License, Version 2.0 with LLVM 10 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 11 | // file in the root directory of this source tree. 12 | // 13 | // Any modifications or derivative works of this code must retain this 14 | // copyright notice, and modified files need to carry a notice indicating 15 | // that they have been altered from the originals. 16 | 17 | // AST-PRETTY: DeclarationNode(type=ASTTypeFunctionDeclaration, FunctionDeclarationNode(FunctionDefinitionNode(name=quantum_params, mangled name=_QF14quantum_paramsFrB1EFp0_QC1_2q0EE_, 18 | // AST-PRETTY: parameters=[DeclarationNode(type=ASTTypeQubitContainer, IdentifierNode(name=q0, bits=1)) 19 | // AST-PRETTY: ], 20 | // AST-PRETTY: results=ResultNode(CBitNode(name=bitset, bits=1)) 21 | // AST-PRETTY: statements=[ 22 | // AST-PRETTY: ReturnNode(MeasureNode(qubits=[QubitContainerNode(QubitNode(name=%q0:0, bits=1))], result=CBitNode(name=ast-measure-result-{{.*}}, bits=1)) 23 | // AST-PRETTY: )]) 24 | def quantum_params(qubit q0) -> bit { 25 | return measure q0; 26 | } 27 | -------------------------------------------------------------------------------- /test/Frontend/OpenQASM3/stretch.qasm: -------------------------------------------------------------------------------- 1 | OPENQASM 3.0; 2 | // RUN: qss-compiler -X=qasm --emit=ast-pretty %s | FileCheck %s --match-full-lines --check-prefix AST-PRETTY 3 | // RUN: qss-compiler -X=qasm --emit=mlir %s | FileCheck %s --match-full-lines --check-prefix MLIR 4 | 5 | // 6 | // This code is part of Qiskit. 7 | // 8 | // (C) Copyright IBM 2023. 9 | // 10 | // This code is licensed under the Apache License, Version 2.0 with LLVM 11 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 12 | // file in the root directory of this source tree. 13 | // 14 | // Any modifications or derivative works of this code must retain this 15 | // copyright notice, and modified files need to carry a notice indicating 16 | // that they have been altered from the originals. 17 | 18 | // AST-PRETTY: StretchStatementNode(StretchNode(name=a)) 19 | // AST-PRETTY: StretchStatementNode(StretchNode(name=b)) 20 | // MLIR: {{.*}} = oq3.declare_stretch : !quir.stretch 21 | // MLIR: {{.*}} = oq3.declare_stretch : !quir.stretch 22 | stretch a; 23 | stretch b; 24 | -------------------------------------------------------------------------------- /test/Frontend/OpenQASM3/switch-default-only.qasm3: -------------------------------------------------------------------------------- 1 | OPENQASM 3.0; 2 | // RUN: qss-compiler -X=qasm --emit=ast-pretty %s | FileCheck %s --match-full-lines --check-prefix AST-PRETTY 3 | // RUN: qss-compiler -X=qasm --emit=mlir %s --enable-circuits-from-qasm=false| FileCheck %s --match-full-lines --check-prefixes MLIR 4 | // RUN: qss-compiler -X=qasm --emit=mlir %s --enable-circuits-from-qasm | FileCheck %s --match-full-lines --check-prefixes MLIR 5 | 6 | // 7 | // This code is part of Qiskit. 8 | // 9 | // (C) Copyright IBM 2023, 2024. 10 | // 11 | // This code is licensed under the Apache License, Version 2.0 with LLVM 12 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 13 | // file in the root directory of this source tree. 14 | // 15 | // Any modifications or derivative works of this code must retain this 16 | // copyright notice, and modified files need to carry a notice indicating 17 | // that they have been altered from the originals. 18 | 19 | int i = 15; 20 | qubit $0; 21 | // MLIR: quir.switch %{{.*}}{ 22 | // MLIR-NEXT: }[] 23 | // AST-PRETTY: SwitchStatementNode(SwitchQuantity(name=i, type=ASTTypeIdentifier), 24 | switch (i) { 25 | // AST-PRETTY:statements=[ 26 | // AST-PRETTY:], 27 | // AST-PRETTY:default statement=[ 28 | // AST-PRETTY:]) 29 | default: { 30 | } 31 | break; 32 | } 33 | -------------------------------------------------------------------------------- /test/Frontend/OpenQASM3/switch-no-default.qasm: -------------------------------------------------------------------------------- 1 | OPENQASM 3.0; 2 | // RUN: qss-compiler -X=qasm --emit=ast-pretty %s | FileCheck %s --match-full-lines --check-prefix AST-PRETTY 3 | // RUN: qss-compiler -X=qasm --emit=mlir %s --enable-circuits-from-qasm=false| FileCheck %s --match-full-lines --check-prefixes MLIR 4 | // RUN: qss-compiler -X=qasm --emit=mlir %s --enable-circuits-from-qasm | FileCheck %s --match-full-lines --check-prefixes MLIR 5 | 6 | // 7 | // This code is part of Qiskit. 8 | // 9 | // (C) Copyright IBM 2023, 2024. 10 | // 11 | // This code is licensed under the Apache License, Version 2.0 with LLVM 12 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 13 | // file in the root directory of this source tree. 14 | // 15 | // Any modifications or derivative works of this code must retain this 16 | // copyright notice, and modified files need to carry a notice indicating 17 | // that they have been altered from the originals. 18 | 19 | int i = 15; 20 | qubit $0; 21 | // MLIR: quir.switch %{{.*}}{ 22 | // MLIR: }[0 : { 23 | // MLIR: }] 24 | // AST-PRETTY: SwitchStatementNode(SwitchQuantity(name=i, type=ASTTypeIdentifier), 25 | switch (i) { 26 | // AST-PRETTY: statements=[ 27 | // AST-PRETTY: CaseStatementNode(case=0, ), 28 | // AST-PRETTY: ], 29 | case 0: { 30 | } 31 | break; 32 | } 33 | -------------------------------------------------------------------------------- /test/Frontend/OpenQASM3/test-include.inc: -------------------------------------------------------------------------------- 1 | // (C) Copyright IBM 2023. 2 | // 3 | // This code is part of Qiskit. 4 | // 5 | // This code is licensed under the Apache License, Version 2.0 with LLVM 6 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | // file in the root directory of this source tree. 8 | // 9 | // Any modifications or derivative works of this code must retain this 10 | // copyright notice, and modified files need to carry a notice indicating 11 | // that they have been altered from the originals. 12 | 13 | gate rz(theta) q { 14 | U(0, 0, theta) q; 15 | } 16 | -------------------------------------------------------------------------------- /test/Frontend/OpenQASM3/test-include.qasm: -------------------------------------------------------------------------------- 1 | OPENQASM 3.0; 2 | // RUN: qss-compiler -I=%S %s --emit=mlir | FileCheck %s 3 | 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // (C) Copyright IBM 2023. 8 | // 9 | // This code is licensed under the Apache License, Version 2.0 with LLVM 10 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 11 | // file in the root directory of this source tree. 12 | // 13 | // Any modifications or derivative works of this code must retain this 14 | // copyright notice, and modified files need to carry a notice indicating 15 | // that they have been altered from the originals. 16 | 17 | // CHECK: func.func @rz 18 | include "test-include.inc"; 19 | qubit $0; 20 | rz(0) $0; 21 | -------------------------------------------------------------------------------- /test/IO/bytecode.mlir: -------------------------------------------------------------------------------- 1 | // Ensure bytecode is emitted 2 | // RUN: qss-compiler %s --emit=bytecode | hexdump -C | FileCheck %s --check-prefix BC 3 | // Ensure bytecode is emitted with file extension 4 | // RUN: qss-compiler %s -o bytecode_output.bc && hexdump -C bytecode_output.bc | FileCheck %s --check-prefix BC 5 | 6 | // Check bytecode is parse/emit roundtripable 7 | // RUN: qss-compiler %s --emit=bytecode -o test.bc && qss-compiler test.bc -X=bytecode --emit=mlir | FileCheck %s 8 | // Check that the compiler automatically differentiates between MLIR/bytecode 9 | // RUN: qss-compiler %s --emit=bytecode -o test.bc && qss-compiler test.bc -X=mlir --emit=mlir | FileCheck %s 10 | 11 | // Look for the bytecode magic number 12 | // https://mlir.llvm.org/docs/BytecodeFormat/#magic-number 13 | // BC: 4d 4c ef 52 14 | 15 | // CHECK: module { 16 | func.func @dummy() { 17 | // CHECK: func.func @dummy() { 18 | return 19 | // CHECK: return 20 | } 21 | -------------------------------------------------------------------------------- /test/IO/none.mlir: -------------------------------------------------------------------------------- 1 | // Test emitting nothing. Useful for testing and benchmark purposes 2 | // RUN: qss-compiler %s --emit=none | if [[ $(ls -A | head -c1 | wc -c) -ne 0 ]]; then exit 0; fi 3 | 4 | func.func @dummy() { 5 | return 6 | } 7 | -------------------------------------------------------------------------------- /test/python_lib/pytest.ini: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http:#www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | [pytest] 18 | asyncio_mode = strict 19 | -------------------------------------------------------------------------------- /test/python_lib/test_link.py: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | """ 14 | Unit tests for the linker API. 15 | """ 16 | import pytest 17 | 18 | from qss_compiler import link_file 19 | from qss_compiler.exceptions import QSSLinkerNotImplemented 20 | 21 | 22 | def test_linker_not_implemented(tmp_path): 23 | qem_file = tmp_path / "test.txt" 24 | arg_file = tmp_path / "dummy.txt" 25 | with open(qem_file, "w") as f: 26 | f.write("dummy") 27 | 28 | with pytest.raises(QSSLinkerNotImplemented) as error: 29 | link_file( 30 | input_file=qem_file, 31 | output_file=arg_file, 32 | target="Mock", 33 | arguments={}, 34 | ) 35 | 36 | assert str(error.value.message) == "Unable to load bind arguments implementation for target." 37 | -------------------------------------------------------------------------------- /test/unittest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | package_add_test_with_libs(unittest-quir-dialect 14 | quir-dialect.cpp 15 | 16 | LIBRARIES 17 | QSSCLib 18 | ) 19 | 20 | set(TEST_FILES 21 | Payload/PayloadRegistryTest.cpp 22 | ) 23 | 24 | if (QSSC_WITH_MOCK_TARGET) 25 | set(TEST_FILES 26 | HAL/TargetSystemRegistryTest.cpp 27 | ${CMAKE_CURRENT_SOURCE_DIR} 28 | ) 29 | endif () 30 | 31 | package_add_test_with_libs(unittest-qss-compiler 32 | ${TEST_FILES} 33 | 34 | LIBRARIES 35 | QSSCLib 36 | ) 37 | 38 | add_custom_target(run-qss-compiler-unittests 39 | COMMAND ${CMAKE_CTEST_COMMAND} 40 | DEPENDS ${QSSC_UNITTESTS} 41 | ) 42 | -------------------------------------------------------------------------------- /test/unittest/Payload/PayloadRegistryTest.cpp: -------------------------------------------------------------------------------- 1 | //===- PayloadRegistryTest.cpp ----------------------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // Any modifications or derivative works of this code must retain this 6 | // copyright notice, and modified files need to carry a notice indicating 7 | // that they have been altered from the originals. 8 | // 9 | //===----------------------------------------------------------------------===// 10 | /// 11 | /// \file 12 | /// This file implements test cases for PayloadRegistry. 13 | /// 14 | //===----------------------------------------------------------------------===// 15 | 16 | #include "gtest/gtest.h" 17 | 18 | #include "Payload/PayloadRegistry.h" 19 | 20 | namespace { 21 | 22 | TEST(PayloadRegistry, LookupZipPayload) { 23 | // As a compiler developer, I want to register and lookup payloads by name. 24 | 25 | const char *zipName = "ZIP"; 26 | 27 | EXPECT_TRUE(qssc::payload::registry::PayloadRegistry::pluginExists(zipName)); 28 | 29 | auto payloadInfoOpt = 30 | qssc::payload::registry::PayloadRegistry::lookupPluginInfo(zipName); 31 | const bool payloadInfoPresent = payloadInfoOpt.has_value(); 32 | EXPECT_TRUE(payloadInfoPresent); 33 | 34 | auto *payloadInfo = payloadInfoOpt.value(); 35 | 36 | ASSERT_NE(payloadInfo, nullptr); 37 | EXPECT_EQ(payloadInfo->getName(), zipName); 38 | } 39 | 40 | } // anonymous namespace 41 | -------------------------------------------------------------------------------- /tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_subdirectory(qss-compiler) 14 | add_subdirectory(qss-opt) 15 | -------------------------------------------------------------------------------- /tools/qss-compiler/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_llvm_executable(qss-compiler qss-compiler.cpp) 14 | llvm_update_compile_flags(qss-compiler) 15 | target_link_libraries(qss-compiler PRIVATE QSSCLib) 16 | mlir_check_all_link_libraries(qss-compiler) 17 | -------------------------------------------------------------------------------- /tools/qss-compiler/qss-compiler.cpp: -------------------------------------------------------------------------------- 1 | //===- qss-compiler.cpp -----------------------------------------*- C++ -*-===// 2 | // 3 | // (C) Copyright IBM 2023. 4 | // 5 | // This code is part of Qiskit. 6 | // 7 | // This code is licensed under the Apache License, Version 2.0 with LLVM 8 | // Exceptions. You may obtain a copy of this license in the LICENSE.txt 9 | // file in the root directory of this source tree. 10 | // 11 | // Any modifications or derivative works of this code must retain this 12 | // copyright notice, and modified files need to carry a notice indicating 13 | // that they have been altered from the originals. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | 17 | #include "API/api.h" 18 | 19 | #include "llvm/Support/Error.h" 20 | #include "llvm/Support/raw_ostream.h" 21 | 22 | #include 23 | #include 24 | 25 | int main(int argc, const char **argv) { 26 | 27 | auto err = qssc::compileMain( 28 | argc, argv, "Quantum System Software (QSS) Backend Compiler\n", {}); 29 | if (err) { 30 | llvm::logAllUnhandledErrors(std::move(err), llvm::errs(), "Error: "); 31 | return EXIT_FAILURE; 32 | } 33 | return qssc::asMainReturnCode(std::move(err)); 34 | } 35 | -------------------------------------------------------------------------------- /tools/qss-opt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright IBM 2023. 2 | # 3 | # This code is part of Qiskit. 4 | # 5 | # This code is licensed under the Apache License, Version 2.0 with LLVM 6 | # Exceptions. You may obtain a copy of this license in the LICENSE.txt 7 | # file in the root directory of this source tree. 8 | # 9 | # Any modifications or derivative works of this code must retain this 10 | # copyright notice, and modified files need to carry a notice indicating 11 | # that they have been altered from the originals. 12 | 13 | add_llvm_executable(qss-opt qss-opt.cpp) 14 | llvm_update_compile_flags(qss-opt) 15 | target_link_libraries(qss-opt PRIVATE QSSCLib) 16 | 17 | mlir_check_all_link_libraries(qss-opt) 18 | --------------------------------------------------------------------------------